Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: xfa/src/fwl/theme/pushbuttontp.cpp

Issue 1803723002: Move xfa/src up to xfa/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fwl/theme/pictureboxtp.cpp ('k') | xfa/src/fwl/theme/scrollbartp.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/include/fwl/theme/pushbuttontp.h"
8
9 #include "xfa/include/fwl/basewidget/fwl_pushbutton.h"
10 #include "xfa/include/fwl/core/fwl_widget.h"
11
12 #define PUSHBUTTON_SIZE_Corner 2
13
14 CFWL_PushButtonTP::CFWL_PushButtonTP() {
15 m_pThemeData = new PBThemeData;
16 SetThemeData(0);
17 }
18 CFWL_PushButtonTP::~CFWL_PushButtonTP() {
19 if (m_pThemeData) {
20 delete m_pThemeData;
21 }
22 }
23 FX_BOOL CFWL_PushButtonTP::IsValidWidget(IFWL_Widget* pWidget) {
24 return pWidget->GetClassID() == FWL_CLASSHASH_PushButton;
25 }
26 FX_DWORD CFWL_PushButtonTP::SetThemeID(IFWL_Widget* pWidget,
27 FX_DWORD dwThemeID,
28 FX_BOOL bChildren) {
29 SetThemeData(FWL_GetThemeColor(dwThemeID));
30 return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
31 }
32 FX_BOOL CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) {
33 switch (pParams->m_iPart) {
34 case FWL_PART_PSB_Border: {
35 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix);
36 break;
37 }
38 case FWL_PART_PSB_Edge: {
39 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
40 &pParams->m_rtPart, &pParams->m_matrix);
41 break;
42 }
43 case FWL_PART_PSB_Background: {
44 CFX_RectF& rect = pParams->m_rtPart;
45 FX_FLOAT fRight = rect.right();
46 FX_FLOAT fBottom = rect.bottom();
47 CFX_Path strokePath;
48 strokePath.Create();
49 strokePath.MoveTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
50 strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, rect.top);
51 strokePath.LineTo(fRight, rect.top + PUSHBUTTON_SIZE_Corner);
52 strokePath.LineTo(fRight, fBottom - PUSHBUTTON_SIZE_Corner);
53 strokePath.LineTo(fRight - PUSHBUTTON_SIZE_Corner, fBottom);
54 strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, fBottom);
55 strokePath.LineTo(rect.left, fBottom - PUSHBUTTON_SIZE_Corner);
56 strokePath.LineTo(rect.left, rect.top + PUSHBUTTON_SIZE_Corner);
57 strokePath.LineTo(rect.left + PUSHBUTTON_SIZE_Corner, rect.top);
58 CFX_Path fillPath;
59 fillPath.Create();
60 fillPath.AddSubpath(&strokePath);
61 CFX_Graphics* pGraphics = pParams->m_pGraphics;
62 pGraphics->SaveGraphState();
63 CFX_RectF rtInner(rect);
64 rtInner.Deflate(PUSHBUTTON_SIZE_Corner + 1, PUSHBUTTON_SIZE_Corner + 1,
65 PUSHBUTTON_SIZE_Corner, PUSHBUTTON_SIZE_Corner);
66 fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
67 rtInner.height);
68 int32_t iColor = GetColorID(pParams->m_dwStates);
69 DrawAxialShading(pGraphics, rect.left + PUSHBUTTON_SIZE_Corner, rect.top,
70 rect.left + PUSHBUTTON_SIZE_Corner, rect.bottom(),
71 m_pThemeData->clrStart[iColor],
72 m_pThemeData->clrEnd[iColor], &fillPath,
73 FXFILL_ALTERNATE, &pParams->m_matrix);
74 CFX_Color crStroke(m_pThemeData->clrBorder[iColor]);
75 pGraphics->SetStrokeColor(&crStroke);
76 pGraphics->StrokePath(&strokePath, &pParams->m_matrix);
77 fillPath.Clear();
78 fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width,
79 rtInner.height);
80 CFX_Color crFill(m_pThemeData->clrFill[iColor]);
81 pGraphics->SetFillColor(&crFill);
82 pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix);
83 if (pParams->m_dwStates & FWL_PARTSTATE_PSB_Focused) {
84 rtInner.Inflate(1, 1, 0, 0);
85 DrawFocus(pGraphics, &rtInner, &pParams->m_matrix);
86 }
87 pGraphics->RestoreGraphState();
88 break;
89 }
90 default: {}
91 }
92 return TRUE;
93 }
94 void* CFWL_PushButtonTP::GetCapacity(CFWL_ThemePart* pThemePart,
95 FX_DWORD dwCapacity) {
96 if (dwCapacity == FWL_WGTCAPACITY_PSB_Margin) {
97 m_fValue = 0;
98 return &m_fValue;
99 }
100 return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
101 }
102 FWL_ERR CFWL_PushButtonTP::Initialize() {
103 InitTTO();
104 return CFWL_WidgetTP::Initialize();
105 }
106 FWL_ERR CFWL_PushButtonTP::Finalize() {
107 FinalizeTTO();
108 return CFWL_WidgetTP::Finalize();
109 }
110 void CFWL_PushButtonTP::SetThemeData(FX_DWORD dwID) {
111 if (dwID) {
112 m_pThemeData->clrBorder[0] = ArgbEncode(255, 55, 98, 6);
113 m_pThemeData->clrBorder[1] = ArgbEncode(255, 55, 98, 6);
114 m_pThemeData->clrBorder[2] = ArgbEncode(255, 55, 98, 6);
115 m_pThemeData->clrBorder[3] = ArgbEncode(255, 55, 98, 6);
116 m_pThemeData->clrBorder[4] = ArgbEncode(255, 172, 168, 153);
117 m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 246);
118 m_pThemeData->clrStart[1] = ArgbEncode(255, 223, 205, 180);
119 m_pThemeData->clrStart[2] = ArgbEncode(255, 252, 197, 149);
120 m_pThemeData->clrStart[3] = ArgbEncode(255, 194, 209, 143);
121 m_pThemeData->clrStart[4] = ArgbEncode(255, 216, 216, 216);
122 m_pThemeData->clrEnd[0] = ArgbEncode(255, 227, 209, 184);
123 m_pThemeData->clrEnd[1] = ArgbEncode(255, 248, 244, 228);
124 m_pThemeData->clrEnd[2] = ArgbEncode(255, 207, 114, 37);
125 m_pThemeData->clrEnd[3] = ArgbEncode(255, 144, 193, 84);
126 m_pThemeData->clrEnd[4] = ArgbEncode(255, 172, 168, 153);
127 m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
128 m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
129 m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
130 m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
131 m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
132 } else {
133 m_pThemeData->clrBorder[0] = ArgbEncode(255, 0, 60, 116);
134 m_pThemeData->clrBorder[1] = ArgbEncode(255, 0, 60, 116);
135 m_pThemeData->clrBorder[2] = ArgbEncode(255, 0, 60, 116);
136 m_pThemeData->clrBorder[3] = ArgbEncode(255, 0, 60, 116);
137 m_pThemeData->clrBorder[4] = ArgbEncode(255, 201, 199, 186);
138 m_pThemeData->clrStart[0] = ArgbEncode(255, 255, 255, 255);
139 m_pThemeData->clrStart[1] = ArgbEncode(255, 209, 204, 193);
140 m_pThemeData->clrStart[2] = ArgbEncode(255, 255, 240, 207);
141 m_pThemeData->clrStart[3] = ArgbEncode(255, 206, 231, 255);
142 m_pThemeData->clrStart[4] = ArgbEncode(255, 245, 244, 234);
143 m_pThemeData->clrEnd[0] = ArgbEncode(255, 214, 208, 197);
144 m_pThemeData->clrEnd[1] = ArgbEncode(255, 242, 241, 238);
145 m_pThemeData->clrEnd[2] = ArgbEncode(255, 229, 151, 0);
146 m_pThemeData->clrEnd[3] = ArgbEncode(255, 105, 130, 238);
147 m_pThemeData->clrEnd[4] = ArgbEncode(255, 245, 244, 234);
148 m_pThemeData->clrFill[0] = ArgbEncode(255, 255, 255, 255);
149 m_pThemeData->clrFill[1] = ArgbEncode(255, 226, 225, 218);
150 m_pThemeData->clrFill[2] = ArgbEncode(255, 255, 255, 255);
151 m_pThemeData->clrFill[3] = ArgbEncode(255, 255, 255, 255);
152 m_pThemeData->clrFill[4] = ArgbEncode(255, 245, 244, 234);
153 }
154 }
155 int32_t CFWL_PushButtonTP::GetColorID(FX_DWORD dwStates) {
156 return dwStates &= FWL_PARTSTATE_PSB_Mask;
157 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/theme/pictureboxtp.cpp ('k') | xfa/src/fwl/theme/scrollbartp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698