diff options
author | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
commit | 9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch) | |
tree | c97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fwl/src/theme/pushbuttontp.cpp | |
parent | 780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff) | |
download | pdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz |
XFA: clang-format all pdfium code.
No behavior change.
Generated by:
find . -name '*.cpp' -o -name '*.h' | \
grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \
xargs ../../buildtools/mac/clang-format -i
Then manually merged https://codereview.chromium.org/1269223002/
See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion.
BUG=none
Diffstat (limited to 'xfa/src/fwl/src/theme/pushbuttontp.cpp')
-rw-r--r-- | xfa/src/fwl/src/theme/pushbuttontp.cpp | 282 |
1 files changed, 135 insertions, 147 deletions
diff --git a/xfa/src/fwl/src/theme/pushbuttontp.cpp b/xfa/src/fwl/src/theme/pushbuttontp.cpp index 9f3127f5b7..5820113f3b 100644 --- a/xfa/src/fwl/src/theme/pushbuttontp.cpp +++ b/xfa/src/fwl/src/theme/pushbuttontp.cpp @@ -5,161 +5,149 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../foxitlib.h"
-#define PUSHBUTTON_SIZE_Corner 2
-CFWL_PushButtonTP::CFWL_PushButtonTP()
-{
- m_pThemeData = FX_NEW PBThemeData;
- SetThemeData(0);
+#define PUSHBUTTON_SIZE_Corner 2
+CFWL_PushButtonTP::CFWL_PushButtonTP() {
+ m_pThemeData = FX_NEW PBThemeData;
+ SetThemeData(0);
}
-CFWL_PushButtonTP::~CFWL_PushButtonTP()
-{
- if (m_pThemeData) {
- delete m_pThemeData;
- }
+CFWL_PushButtonTP::~CFWL_PushButtonTP() {
+ if (m_pThemeData) {
+ delete m_pThemeData;
+ }
}
-FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget *pWidget)
-{
- return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
+FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) {
+ return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
}
-FX_DWORD CFWL_PushButtonTP::SetThemeID(IFWL_Widget *pWidget, FX_DWORD dwThemeID, FX_BOOL bChildren )
-{
- SetThemeData(FWL_GetThemeColor(dwThemeID));
- return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
+FX_DWORD CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget,
+ FX_DWORD dwThemeID,
+ FX_BOOL bChildren) {
+ SetThemeData(FWL_GetThemeColor(dwThemeID));
+ return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
}
-FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground *pParams)
-{
- switch(pParams->m_iPart) {
- case FWL_PART_PSB_Border: {
- DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_PSB_Edge: {
- DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), &pParams->m_rtPart, &pParams->m_matrix);
- break;
- }
- case FWL_PART_PSB_Background: {
- CFX_RectF &rect = pParams->m_rtPart;
- FX_FLOAT fRight = rect.right();
- FX_FLOAT fBottom = rect.bottom();
- CFX_Path strokePath;
- strokePath.Create();
- strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
- strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top);
- strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom);
- strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom);
- strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner);
- strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
- CFX_Path fillPath;
- fillPath.Create();
- fillPath.AddSubpath(&strokePath);
- CFX_Graphics *pGraphics = pParams->m_pGraphics;
- pGraphics->SaveGraphState();
- CFX_RectF rtInner(rect);
- rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1,
- PUSHBUTTON_SIZE_Corner + 1,
- PUSHBUTTON_SIZE_Corner,
- PUSHBUTTON_SIZE_Corner);
- fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
- int32_t iColor = GetColorID(pParams->m_dwStates);
- DrawAxialShading(pGraphics,
- rect.left + PUSHBUTTON_SIZE_Corner,
- rect.top,
- rect.left + PUSHBUTTON_SIZE_Corner,
- rect.bottom(),
- m_pThemeData->clrStart[iColor],
- m_pThemeData->clrEnd[iColor],
- &fillPath,
- FXFILL_ALTERNATE,
- &pParams->m_matrix);
- CFX_Color crStroke(m_pThemeData->clrBorder[iColor]);
- pGraphics->SetStrokeColor(&crStroke);
- pGraphics->StrokePath(&strokePath, &pParams->m_matrix);
- fillPath.Clear();
- fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height);
- CFX_Color crFill(m_pThemeData->clrFill[iColor]);
- pGraphics->SetFillColor(&crFill);
- pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
- if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
- rtInner.Inflate(1, 1, 0, 0);
- DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
- }
- pGraphics->RestoreGraphState();
- break;
- }
- default: {
- }
+FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
+ switch (pParams->m_iPart) {
+ case FWL_PART_PSB_Border: {
+ DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
+ break;
}
- return TRUE;
-}
-void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart *pThemePart, FX_DWORD dwCapacity)
-{
- if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
- m_fValue = 0;
- return &m_fValue;
+ case FWL_PART_PSB_Edge: {
+ DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
+ &pParams->m_rtPart, &pParams->m_matrix);
+ break;
+ }
+ case FWL_PART_PSB_Background: {
+ CFX_RectF& rect = pParams->m_rtPart;
+ FX_FLOAT fRight = rect.right();
+ FX_FLOAT fBottom = rect.bottom();
+ CFX_Path strokePath;
+ strokePath.Create();
+ strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
+ strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top);
+ strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom);
+ strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom);
+ strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner);
+ strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
+ CFX_Path fillPath;
+ fillPath.Create();
+ fillPath.AddSubpath(&strokePath);
+ CFX_Graphics* pGraphics = pParams->m_pGraphics;
+ pGraphics->SaveGraphState();
+ CFX_RectF rtInner(rect);
+ rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1,
+ PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner);
+ fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
+ rtInner.height);
+ int32_t iColor = GetColorID(pParams->m_dwStates);
+ DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top,
+ rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(),
+ m_pThemeData->clrStart[iColor],
+ m_pThemeData->clrEnd[iColor], &fillPath,
+ FXFILL_ALTERNATE, &pParams->m_matrix);
+ CFX_Color crStroke(m_pThemeData->clrBorder[iColor]);
+ pGraphics->SetStrokeColor(&crStroke);
+ pGraphics->StrokePath(&strokePath, &pParams->m_matrix);
+ fillPath.Clear();
+ fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
+ rtInner.height);
+ CFX_Color crFill(m_pThemeData->clrFill[iColor]);
+ pGraphics->SetFillColor(&crFill);
+ pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
+ if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
+ rtInner.Inflate(1, 1, 0, 0);
+ DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
+ }
+ pGraphics->RestoreGraphState();
+ break;
}
- return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
+ default: {}
+ }
+ return TRUE;
}
-FWL_ERR CFWL_PushButtonTP::Initialize()
-{
- InitTTO();
- return CFWL_WidgetTP::Initialize();
+void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart,
+ FX_DWORD dwCapacity) {
+ if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
+ m_fValue = 0;
+ return &m_fValue;
+ }
+ return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
}
-FWL_ERR CFWL_PushButtonTP::Finalize()
-{
- FinalizeTTO();
- return CFWL_WidgetTP::Finalize();
+FWL_ERR CFWL_PushButtonTP::Initialize() {
+ InitTTO();
+ return CFWL_WidgetTP::Initialize();
}
-void CFWL_PushButtonTP::SetThemeData(FX_DWORD dwID)
-{
- FX_ARGB *pData = (FX_ARGB*)&*m_pThemeData;
- if (dwID) {
- m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6);
- m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153);
- m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246);
- m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180);
- m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149);
- m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143);
- m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216);
- m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184);
- m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228);
- m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37);
- m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84);
- m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153);
- m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
- m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
- } else {
- m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116);
- m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186);
- m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193);
- m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207);
- m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255);
- m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234);
- m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197);
- m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238);
- m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0);
- m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238);
- m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234);
- m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
- m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
- m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
- }
+FWL_ERR CFWL_PushButtonTP::Finalize() {
+ FinalizeTTO();
+ return CFWL_WidgetTP::Finalize();
+}
+void CFWL_PushButtonTP::SetThemeData(FX_DWORD dwID) {
+ FX_ARGB* pData = (FX_ARGB*)&*m_pThemeData;
+ if (dwID) {
+ m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6);
+ m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153);
+ m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246);
+ m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180);
+ m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149);
+ m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143);
+ m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216);
+ m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184);
+ m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228);
+ m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37);
+ m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84);
+ m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153);
+ m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
+ m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
+ } else {
+ m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116);
+ m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186);
+ m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193);
+ m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207);
+ m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255);
+ m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234);
+ m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197);
+ m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238);
+ m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0);
+ m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238);
+ m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234);
+ m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
+ m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
+ m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
+ }
}
-int32_t CFWL_PushButtonTP::GetColorID(FX_DWORD dwStates)
-{
- return dwStates &= FWL_PARTSTATE_PSB_Mask;
+int32_t CFWL_PushButtonTP::GetColorID(FX_DWORD dwStates) {
+ return dwStates &= FWL_PARTSTATE_PSB_Mask;
}
|