| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/theme/cfwl_pushbuttontp.h" | 7 #include "xfa/fwl/theme/cfwl_pushbuttontp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/core/cfwl_themebackground.h" | 9 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 10 #include "xfa/fwl/core/ifwl_pushbutton.h" | 10 #include "xfa/fwl/core/ifwl_pushbutton.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 CFWL_PushButtonTP::~CFWL_PushButtonTP() {} | 22 CFWL_PushButtonTP::~CFWL_PushButtonTP() {} |
| 23 | 23 |
| 24 bool CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) { | 24 bool CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) { |
| 25 return pWidget && pWidget->GetClassID() == FWL_Type::PushButton; | 25 return pWidget && pWidget->GetClassID() == FWL_Type::PushButton; |
| 26 } | 26 } |
| 27 uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget, | 27 uint32_t CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget, |
| 28 uint32_t dwThemeID) { | 28 uint32_t dwThemeID) { |
| 29 SetThemeData(FWL_GetThemeColor(dwThemeID)); | 29 SetThemeData(FWL_GetThemeColor(dwThemeID)); |
| 30 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID); | 30 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID); |
| 31 } | 31 } |
| 32 FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { | 32 |
| 33 void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { |
| 33 switch (pParams->m_iPart) { | 34 switch (pParams->m_iPart) { |
| 34 case CFWL_Part::Border: { | 35 case CFWL_Part::Border: { |
| 35 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); | 36 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); |
| 36 break; | 37 break; |
| 37 } | 38 } |
| 38 case CFWL_Part::Edge: { | 39 case CFWL_Part::Edge: { |
| 39 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), | 40 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), |
| 40 &pParams->m_rtPart, &pParams->m_matrix); | 41 &pParams->m_rtPart, &pParams->m_matrix); |
| 41 break; | 42 break; |
| 42 } | 43 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 CFX_Color crFill(m_pThemeData->clrFill[iColor]); | 81 CFX_Color crFill(m_pThemeData->clrFill[iColor]); |
| 81 pGraphics->SetFillColor(&crFill); | 82 pGraphics->SetFillColor(&crFill); |
| 82 pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); | 83 pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); |
| 83 if (pParams->m_dwStates & CFWL_PartState_Focused) { | 84 if (pParams->m_dwStates & CFWL_PartState_Focused) { |
| 84 rtInner.Inflate(1, 1, 0, 0); | 85 rtInner.Inflate(1, 1, 0, 0); |
| 85 DrawFocus(pGraphics, &rtInner, &pParams->m_matrix); | 86 DrawFocus(pGraphics, &rtInner, &pParams->m_matrix); |
| 86 } | 87 } |
| 87 pGraphics->RestoreGraphState(); | 88 pGraphics->RestoreGraphState(); |
| 88 break; | 89 break; |
| 89 } | 90 } |
| 90 default: {} | 91 default: |
| 92 break; |
| 91 } | 93 } |
| 92 return TRUE; | |
| 93 } | 94 } |
| 95 |
| 94 void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart, | 96 void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart, |
| 95 CFWL_WidgetCapacity dwCapacity) { | 97 CFWL_WidgetCapacity dwCapacity) { |
| 96 if (dwCapacity == CFWL_WidgetCapacity::Margin) { | 98 if (dwCapacity == CFWL_WidgetCapacity::Margin) { |
| 97 m_fValue = 0; | 99 m_fValue = 0; |
| 98 return &m_fValue; | 100 return &m_fValue; |
| 99 } | 101 } |
| 100 return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); | 102 return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity); |
| 101 } | 103 } |
| 102 FWL_Error CFWL_PushButtonTP::Initialize() { | 104 |
| 105 void CFWL_PushButtonTP::Initialize() { |
| 103 InitTTO(); | 106 InitTTO(); |
| 104 return CFWL_WidgetTP::Initialize(); | 107 CFWL_WidgetTP::Initialize(); |
| 105 } | 108 } |
| 106 FWL_Error CFWL_PushButtonTP::Finalize() { | 109 |
| 110 void CFWL_PushButtonTP::Finalize() { |
| 107 FinalizeTTO(); | 111 FinalizeTTO(); |
| 108 return CFWL_WidgetTP::Finalize(); | 112 CFWL_WidgetTP::Finalize(); |
| 109 } | 113 } |
| 114 |
| 110 void CFWL_PushButtonTP::SetThemeData(uint32_t dwID) { | 115 void CFWL_PushButtonTP::SetThemeData(uint32_t dwID) { |
| 111 if (dwID) { | 116 if (dwID) { |
| 112 m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6); | 117 m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6); |
| 113 m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6); | 118 m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6); |
| 114 m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6); | 119 m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6); |
| 115 m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6); | 120 m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6); |
| 116 m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153); | 121 m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153); |
| 117 m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246); | 122 m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246); |
| 118 m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180); | 123 m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180); |
| 119 m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149); | 124 m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0); | 150 m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0); |
| 146 m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238); | 151 m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238); |
| 147 m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234); | 152 m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234); |
| 148 m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); | 153 m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255); |
| 149 m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); | 154 m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218); |
| 150 m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); | 155 m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255); |
| 151 m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); | 156 m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255); |
| 152 m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); | 157 m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234); |
| 153 } | 158 } |
| 154 } | 159 } |
| 160 |
| 155 int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) const { | 161 int32_t CFWL_PushButtonTP::GetColorID(uint32_t dwStates) const { |
| 156 int32_t color = 0; | 162 int32_t color = 0; |
| 157 if (dwStates & CFWL_PartState_Disabled) | 163 if (dwStates & CFWL_PartState_Disabled) |
| 158 color += 4; | 164 color += 4; |
| 159 if (dwStates & CFWL_PartState_Default) { | 165 if (dwStates & CFWL_PartState_Default) { |
| 160 color += 3; | 166 color += 3; |
| 161 } else { | 167 } else { |
| 162 if (dwStates & CFWL_PartState_Hovered) | 168 if (dwStates & CFWL_PartState_Hovered) |
| 163 color += 2; | 169 color += 2; |
| 164 if (dwStates & CFWL_PartState_Pressed) | 170 if (dwStates & CFWL_PartState_Pressed) |
| 165 color += 1; | 171 color += 1; |
| 166 } | 172 } |
| 167 return color; | 173 return color; |
| 168 } | 174 } |
| OLD | NEW |