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/src/foxitlib.h"
8 #define FWLTHEME_CAPACITY_CXFormBorder 3
9 #define FWLTHEME_CAPACITY_CYFormBorder 3
10 #define FWLTHEME_CAPACITY_CYNarrowCaption 18
11 #define FWLTHEME_CAPACITY_CYCaption 29
12 #define FWLTHEME_CAPACITY_BigIconSize 32
13 #define FWLTHEME_CAPACITY_SmallIconSize 16
14 #define FWLTHEME_CAPACITY_FormTextColor 0xFFFFFFFF
15 #define FWLTHEME_FORMBTN_Margin 5
16 #define FWLTHEME_FORMBTN_Span 2
17 #define FWLTHEME_FORMBTN_Size 21
CFWL_FormTP()18 CFWL_FormTP::CFWL_FormTP() : m_pActiveBitmap(NULL), m_pDeactivebitmap(NULL) {
19   m_pThemeData = new SBThemeData;
20   SetThemeData(0);
21   m_rtDisLBorder.Reset();
22   m_rtDisRBorder.Reset();
23   m_rtDisBBorder.Reset();
24   m_rtDisCaption.Reset();
25 }
~CFWL_FormTP()26 CFWL_FormTP::~CFWL_FormTP() {
27   if (m_pThemeData) {
28     delete m_pThemeData;
29     m_pThemeData = NULL;
30   }
31 }
Initialize()32 FWL_ERR CFWL_FormTP::Initialize() {
33   InitTTO();
34   InitCaption(TRUE);
35   InitCaption(FALSE);
36   return CFWL_WidgetTP::Initialize();
37 }
Finalize()38 FWL_ERR CFWL_FormTP::Finalize() {
39   FinalizeTTO();
40   if (m_pActiveBitmap) {
41     delete m_pActiveBitmap;
42     m_pActiveBitmap = NULL;
43   }
44   if (m_pDeactivebitmap) {
45     delete m_pDeactivebitmap;
46     m_pDeactivebitmap = NULL;
47   }
48   return CFWL_WidgetTP::Finalize();
49 }
IsValidWidget(IFWL_Widget * pWidget)50 FX_BOOL CFWL_FormTP::IsValidWidget(IFWL_Widget* pWidget) {
51   if (!pWidget)
52     return FALSE;
53   FX_DWORD dwHash = pWidget->GetClassID();
54   return dwHash == FWL_CLASSHASH_Form;
55 }
SetThemeID(IFWL_Widget * pWidget,FX_DWORD dwThemeID,FX_BOOL bChildren)56 FX_DWORD CFWL_FormTP::SetThemeID(IFWL_Widget* pWidget,
57                                  FX_DWORD dwThemeID,
58                                  FX_BOOL bChildren) {
59   if (m_pThemeData) {
60     SetThemeData(FWL_GetThemeColor(dwThemeID));
61   }
62   InitCaption(TRUE);
63   InitCaption(FALSE);
64   return CFWL_WidgetTP::SetThemeID(pWidget, dwThemeID, bChildren);
65 }
DrawBackground(CFWL_ThemeBackground * pParams)66 FX_BOOL CFWL_FormTP::DrawBackground(CFWL_ThemeBackground* pParams) {
67   if (!pParams)
68     return FALSE;
69   int32_t iActive = 0;
70   if (pParams->m_dwStates & FWL_PARTSTATE_FRM_Inactive) {
71     iActive = 1;
72   }
73   FWLTHEME_STATE eState = FWLTHEME_STATE_Normal;
74   switch (pParams->m_dwStates & 0x03) {
75     case FWL_PARTSTATE_FRM_Hover: {
76       eState = FWLTHEME_STATE_Hover;
77       break;
78     }
79     case FWL_PARTSTATE_FRM_Pressed: {
80       eState = FWLTHEME_STATE_Pressed;
81       break;
82     }
83     case FWL_PARTSTATE_FRM_Disabled: {
84       eState = FWLTHEME_STATE_Disabale;
85       break;
86     }
87     default: {}
88   }
89   switch (pParams->m_iPart) {
90     case FWL_PART_FRM_Border: {
91       DrawFormBorder(pParams->m_pGraphics, &pParams->m_rtPart, eState,
92                      &pParams->m_matrix, iActive);
93       break;
94     }
95     case FWL_PART_FRM_Edge: {
96       DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(),
97                &pParams->m_rtPart, &pParams->m_matrix);
98       break;
99     }
100     case FWL_PART_FRM_Background: {
101       FillBackground(pParams->m_pGraphics, &pParams->m_rtPart,
102                      &pParams->m_matrix);
103       break;
104     }
105     case FWL_PART_FRM_Caption: {
106       DrawCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
107                   &pParams->m_matrix, iActive);
108       break;
109     }
110     case FWL_PART_FRM_NarrowCaption: {
111       DrawNarrowCaption(pParams->m_pGraphics, &pParams->m_rtPart, eState,
112                         &pParams->m_matrix, iActive);
113       break;
114     }
115     case FWL_PART_FRM_CloseBox: {
116       DrawCloseBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
117                    &pParams->m_matrix, iActive);
118       break;
119     }
120     case FWL_PART_FRM_MinimizeBox: {
121       DrawMinimizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
122                       &pParams->m_matrix, iActive);
123       break;
124     }
125     case FWL_PART_FRM_MaximizeBox: {
126       DrawMaximizeBox(pParams->m_pGraphics, &pParams->m_rtPart, eState,
127                       pParams->m_dwData, &pParams->m_matrix, iActive);
128       break;
129     }
130     case FWL_PART_FRM_Icon: {
131       DrawIconImage(pParams->m_pGraphics, pParams->m_pImage, &pParams->m_rtPart,
132                     eState, &pParams->m_matrix, iActive);
133       break;
134     }
135     default: {}
136   }
137   return TRUE;
138 }
DrawText(CFWL_ThemeText * pParams)139 FX_BOOL CFWL_FormTP::DrawText(CFWL_ThemeText* pParams) {
140   if (!m_pTextOut)
141     return FALSE;
142   if (pParams->m_iPart == FWL_PART_FRM_Caption) {
143     m_pTextOut->SetTextColor(0xFFFFFFFF);
144   } else {
145     m_pTextOut->SetTextColor(0xFF000000);
146   }
147   return CFWL_WidgetTP::DrawText(pParams);
148 }
GetCapacity(CFWL_ThemePart * pThemePart,FX_DWORD dwCapacity)149 void* CFWL_FormTP::GetCapacity(CFWL_ThemePart* pThemePart,
150                                FX_DWORD dwCapacity) {
151   FX_BOOL bDefPro = FALSE;
152   FX_BOOL bDwordVal = FALSE;
153   switch (dwCapacity) {
154     case FWL_WGTCAPACITY_CXBorder: {
155       m_fValue = FWLTHEME_CAPACITY_CXFormBorder;
156       break;
157     }
158     case FWL_WGTCAPACITY_CYBorder: {
159       m_fValue = FWLTHEME_CAPACITY_CYFormBorder;
160       break;
161     }
162     case FWL_WGTCAPACITY_FRM_CYCaption: {
163       m_fValue = FWLTHEME_CAPACITY_CYCaption;
164       break;
165     }
166     case FWL_WGTCAPACITY_FRM_CYNarrowCaption: {
167       m_fValue = FWLTHEME_CAPACITY_CYCaption;
168       break;
169     }
170     case FWL_WGTCAPACITY_TextColor: {
171       bDwordVal = TRUE;
172       m_dwValue = FWLTHEME_CAPACITY_FormTextColor;
173       break;
174     }
175     case FWL_WGTCAPACITY_FRM_BigIcon: {
176       m_fValue = FWLTHEME_CAPACITY_BigIconSize;
177       break;
178     }
179     case FWL_WGTCAPACITY_FRM_SmallIcon: {
180       m_fValue = FWLTHEME_CAPACITY_SmallIconSize;
181       break;
182     }
183     default: { bDefPro = TRUE; }
184   }
185   if (!bDefPro) {
186     if (bDwordVal) {
187       return &m_dwValue;
188     }
189     return &m_fValue;
190   }
191   return CFWL_WidgetTP::GetCapacity(pThemePart, dwCapacity);
192 }
GetPartRect(CFWL_ThemePart * pThemePart,CFX_RectF & rtPart)193 FWL_ERR CFWL_FormTP::GetPartRect(CFWL_ThemePart* pThemePart,
194                                  CFX_RectF& rtPart) {
195   switch (pThemePart->m_iPart) {
196     case FWL_PART_FRM_CloseBox: {
197       CalCloseBox(pThemePart->m_pWidget, rtPart);
198       break;
199     }
200     case FWL_PART_FRM_MaximizeBox: {
201       CalMaxBox(pThemePart->m_pWidget, rtPart);
202       break;
203     }
204     case FWL_PART_FRM_MinimizeBox: {
205       CalMinBox(pThemePart->m_pWidget, rtPart);
206       break;
207     }
208     case FWL_PART_FRM_HeadText: {
209       CalCaption(pThemePart->m_pWidget, rtPart);
210       break;
211     }
212     case FWL_PART_FRM_Icon: {
213       CalIcon(pThemePart->m_pWidget, rtPart);
214       break;
215     }
216     default: {}
217   }
218   return FWL_ERR_Succeeded;
219 }
CalCloseBox(IFWL_Widget * pWidget,CFX_RectF & rect)220 void CFWL_FormTP::CalCloseBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
221   FX_DWORD dwStyles = pWidget->GetStyles();
222   CFX_RectF rtWidget;
223   pWidget->GetWidgetRect(rtWidget);
224   rtWidget.Offset(-rtWidget.left, -rtWidget.top);
225   if (dwStyles & FWL_WGTSTYLE_CloseBox) {
226     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
227              rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
228              FWLTHEME_FORMBTN_Size);
229   } else {
230     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Span,
231              rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
232   }
233 }
CalMaxBox(IFWL_Widget * pWidget,CFX_RectF & rect)234 void CFWL_FormTP::CalMaxBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
235   FX_DWORD dwStyles = pWidget->GetStyles();
236   CFX_RectF rtWidget;
237   pWidget->GetWidgetRect(rtWidget);
238   rtWidget.Offset(-rtWidget.left, -rtWidget.top);
239   if (dwStyles & FWL_WGTSTYLE_MaximizeBox) {
240     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
241                  FWLTHEME_FORMBTN_Span * 2,
242              rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
243              FWLTHEME_FORMBTN_Size);
244   } else {
245     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin + FWLTHEME_FORMBTN_Size +
246                  FWLTHEME_FORMBTN_Span * 2,
247              rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
248   }
249 }
CalMinBox(IFWL_Widget * pWidget,CFX_RectF & rect)250 void CFWL_FormTP::CalMinBox(IFWL_Widget* pWidget, CFX_RectF& rect) {
251   FX_DWORD dwStyles = pWidget->GetStyles();
252   CFX_RectF rtWidget;
253   pWidget->GetWidgetRect(rtWidget);
254   rtWidget.Offset(-rtWidget.left, -rtWidget.top);
255   if (dwStyles & FWL_WGTSTYLE_MinimizeBox) {
256     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
257                  FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
258              rtWidget.top + FWLTHEME_FORMBTN_Margin, FWLTHEME_FORMBTN_Size,
259              FWLTHEME_FORMBTN_Size);
260   } else {
261     rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin +
262                  FWLTHEME_FORMBTN_Size * 2 + FWLTHEME_FORMBTN_Span * 3,
263              rtWidget.top + FWLTHEME_FORMBTN_Margin, 0, 0);
264   }
265 }
CalCaption(IFWL_Widget * pWidget,CFX_RectF & rect)266 void CFWL_FormTP::CalCaption(IFWL_Widget* pWidget, CFX_RectF& rect) {
267   CFX_RectF rtWidget;
268   pWidget->GetWidgetRect(rtWidget);
269   rtWidget.Offset(-rtWidget.left, -rtWidget.top);
270   rect.Set(rtWidget.left + FWLTHEME_FORMBTN_Margin,
271            rtWidget.top + FWLTHEME_FORMBTN_Margin - 2,
272            rtWidget.width - FWLTHEME_FORMBTN_Margin * 2,
273            FWLTHEME_FORMBTN_Size + 2 * FWLTHEME_FORMBTN_Margin + 4);
274 }
CalIcon(IFWL_Widget * pWidget,CFX_RectF & rect)275 void CFWL_FormTP::CalIcon(IFWL_Widget* pWidget, CFX_RectF& rect) {}
DrawFormBorder(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)276 void CFWL_FormTP::DrawFormBorder(CFX_Graphics* pGraphics,
277                                  const CFX_RectF* pRect,
278                                  FWLTHEME_STATE eState,
279                                  CFX_Matrix* pMatrix,
280                                  int32_t iActive) {
281   CFX_RectF rt;
282   rt.Set(pRect->left, pRect->top, 1, pRect->height);
283   FX_FLOAT fBottom, fRight;
284   fBottom = pRect->bottom();
285   fRight = pRect->right();
286   CFX_Path path;
287   path.Create();
288   CFX_Color clrLine;
289   path.Clear();
290   path.MoveTo(pRect->left, pRect->top);
291   path.LineTo(pRect->left, fBottom - 1);
292   path.LineTo(fRight - 1, fBottom - 1);
293   path.LineTo(fRight - 1, pRect->top);
294   clrLine = m_pThemeData->clrFormBorder[iActive][2];
295   pGraphics->SetStrokeColor(&clrLine);
296   pGraphics->StrokePath(&path, pMatrix);
297   path.Clear();
298   path.MoveTo(pRect->left + 1, pRect->top);
299   path.LineTo(pRect->left + 1, fBottom - 2);
300   path.LineTo(fRight - 2, fBottom - 2);
301   path.LineTo(fRight - 2, pRect->top);
302   clrLine = m_pThemeData->clrFormBorder[iActive][1];
303   pGraphics->SetStrokeColor(&clrLine);
304   pGraphics->StrokePath(&path, pMatrix);
305   path.Clear();
306   path.MoveTo(pRect->left + 2, pRect->top);
307   path.LineTo(pRect->left + 2, fBottom - 3);
308   path.LineTo(fRight - 3, fBottom - 3);
309   path.LineTo(fRight - 3, pRect->top);
310   clrLine = m_pThemeData->clrFormBorder[iActive][0];
311   pGraphics->SetStrokeColor(&clrLine);
312   pGraphics->StrokePath(&path, pMatrix);
313   path.Clear();
314   path.MoveTo(pRect->left + 3, pRect->top);
315   path.LineTo(pRect->left + 3, fBottom - 4);
316   path.LineTo(fRight - 4, fBottom - 4);
317   path.LineTo(fRight - 4, pRect->top);
318   clrLine = m_pThemeData->clrFormBorder[iActive][4];
319   pGraphics->SetStrokeColor(&clrLine);
320   pGraphics->StrokePath(&path, pMatrix);
321   m_rtDisLBorder.Set(pRect->left, pRect->top + 29, 4, pRect->height - 29);
322   m_rtDisRBorder.Set(pRect->right() - 4, pRect->top + 29, 4,
323                      pRect->height - 29);
324   m_rtDisBBorder.Set(pRect->left, pRect->bottom() - 4, pRect->width, 4);
325   m_rtDisCaption.Set(pRect->left, pRect->top, pRect->width, 29);
326 }
DrawCaption(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)327 void CFWL_FormTP::DrawCaption(CFX_Graphics* pGraphics,
328                               const CFX_RectF* pRect,
329                               FWLTHEME_STATE eState,
330                               CFX_Matrix* pMatrix,
331                               int32_t iActive) {
332   CFX_RectF rt;
333   FX_FLOAT fBottom, fRight;
334   fBottom = pRect->bottom();
335   fRight = pRect->right();
336   rt.Set(pRect->left, pRect->top, pRect->width, 1);
337   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][0], &rt,
338                 pMatrix);
339   rt.Offset(0, 1);
340   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][1], &rt,
341                 pMatrix);
342   rt.Offset(0, 1);
343   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeTop[iActive][2], &rt,
344                 pMatrix);
345   rt.Set(pRect->left, pRect->bottom() - 1, pRect->width, 1);
346   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][2], &rt,
347                 pMatrix);
348   rt.Offset(0, -1);
349   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeBottom[iActive][1], &rt,
350                 pMatrix);
351   rt.Set(pRect->left, pRect->top, 1, pRect->height);
352   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][2], &rt,
353                 pMatrix);
354   rt.Set(pRect->left + 1, pRect->top + 1, 1, fBottom - 1);
355   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][1], &rt,
356                 pMatrix);
357   rt.Set(pRect->left + 2, pRect->top + 2, 1, fBottom - 2);
358   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeLeft[iActive][0], &rt,
359                 pMatrix);
360   rt.Set(fRight - 1, pRect->top, pRect->width, pRect->height);
361   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][2], &rt,
362                 pMatrix);
363   rt.Set(fRight - 2, pRect->top + 1, 1, fBottom - 1);
364   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][1], &rt,
365                 pMatrix);
366   rt.Set(fRight - 3, pRect->top + 2, 1, fBottom - 2);
367   FillSoildRect(pGraphics, m_pThemeData->clrHeadEdgeRight[iActive][0], &rt,
368                 pMatrix);
369   CFX_RectF rect(*pRect);
370   rect.Set(rect.left + 3, rect.top + 3, rect.width - 6, rect.height - 5);
371   if (iActive == 0) {
372     pGraphics->StretchImage(m_pActiveBitmap, rect, pMatrix);
373   } else {
374     pGraphics->StretchImage(m_pDeactivebitmap, rect, pMatrix);
375   }
376 }
DrawNarrowCaption(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)377 void CFWL_FormTP::DrawNarrowCaption(CFX_Graphics* pGraphics,
378                                     const CFX_RectF* pRect,
379                                     FWLTHEME_STATE eState,
380                                     CFX_Matrix* pMatrix,
381                                     int32_t iActive) {}
DrawCloseBox(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)382 void CFWL_FormTP::DrawCloseBox(CFX_Graphics* pGraphics,
383                                const CFX_RectF* pRect,
384                                FWLTHEME_STATE eState,
385                                CFX_Matrix* pMatrix,
386                                int32_t iActive) {
387   FX_FLOAT fRight = pRect->right();
388   FX_FLOAT fBottom = pRect->bottom();
389   FX_FLOAT fWidth = pRect->width;
390   FX_FLOAT fHeight = pRect->height;
391   pGraphics->SaveGraphState();
392   CFX_RectF rt(*pRect);
393   pGraphics->SetLineWidth(1.0f);
394   CFX_Path path;
395   path.Create();
396   path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
397   path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
398   path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
399   path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
400   CFX_Color crFill;
401   crFill = m_pThemeData->clrBtnEdgeOut[iActive];
402   pGraphics->SetFillColor(&crFill);
403   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
404   path.Clear();
405   path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
406   path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
407   path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
408   path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
409   crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
410   pGraphics->SetFillColor(&crFill);
411   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
412   path.Clear();
413   path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
414   path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
415   crFill = m_pThemeData->clrCloseBtEdgeLight[iActive][eState - 1];
416   pGraphics->SetFillColor(&crFill);
417   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
418   path.Clear();
419   path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
420   path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
421   crFill = m_pThemeData->clrCloseBtEdgeDark[iActive][eState - 1];
422   pGraphics->SetFillColor(&crFill);
423   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
424   path.Clear();
425   path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
426   DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2,
427                    fBottom - 2,
428                    m_pThemeData->clrCloseBtBKStart[iActive][eState - 1],
429                    m_pThemeData->clrCloseBtBKEnd[iActive][eState - 1], &path,
430                    FXFILL_WINDING, pMatrix);
431   CFX_RectF rtX(*pRect);
432   rtX.Inflate(-5, -5);
433   path.Clear();
434   FX_FLOAT frtXRight = rtX.right();
435   FX_FLOAT frtXBottom = rtX.bottom();
436   path.AddLine(rtX.left, rtX.top + 1, frtXRight - 1, frtXBottom);
437   path.AddLine(rtX.left, rtX.top, frtXRight, frtXBottom);
438   path.AddLine(rtX.left + 1, rtX.top, frtXRight, frtXBottom - 1);
439   path.AddLine(rtX.left, frtXBottom - 1, frtXRight - 1, rtX.top);
440   path.AddLine(rtX.left, frtXBottom, frtXRight, rtX.top);
441   path.AddLine(rtX.left + 1, frtXBottom, frtXRight, rtX.top + 1);
442   CFX_Color clrLine(0xffffffff);
443   pGraphics->SetLineWidth(1.0f);
444   pGraphics->SetStrokeColor(&clrLine);
445   pGraphics->StrokePath(&path, pMatrix);
446   pGraphics->RestoreGraphState();
447 }
DrawMinMaxBoxCommon(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)448 void CFWL_FormTP::DrawMinMaxBoxCommon(CFX_Graphics* pGraphics,
449                                       const CFX_RectF* pRect,
450                                       FWLTHEME_STATE eState,
451                                       CFX_Matrix* pMatrix,
452                                       int32_t iActive) {
453   pGraphics->SaveGraphState();
454   FX_FLOAT fRight = pRect->right();
455   FX_FLOAT fBottom = pRect->bottom();
456   FX_FLOAT fWidth = pRect->width;
457   FX_FLOAT fHeight = pRect->height;
458   CFX_RectF rt(*pRect);
459   pGraphics->SetLineWidth(1.0f);
460   CFX_Path path;
461   path.Create();
462   path.AddRectangle(rt.left + 1, rt.top, fWidth - 2, 1);
463   path.AddRectangle(rt.left, rt.top + 1, 1, fHeight - 2);
464   path.AddRectangle(fRight - 1, rt.top + 1, 1, fHeight - 2);
465   path.AddRectangle(rt.left + 1, fBottom - 1, fWidth - 2, 1);
466   CFX_Color crFill;
467   crFill = m_pThemeData->clrBtnEdgeOut[iActive];
468   pGraphics->SetFillColor(&crFill);
469   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
470   path.Clear();
471   path.AddRectangle(rt.left + 1, rt.top + 1, 1, 1);
472   path.AddRectangle(fRight - 2, rt.top + 1, 1, 1);
473   path.AddRectangle(rt.left + 1, fBottom - 2, 1, 1);
474   path.AddRectangle(fRight - 2, fBottom - 2, 1, 1);
475   crFill = m_pThemeData->clrBtnCornerLight[iActive][eState - 1];
476   pGraphics->SetFillColor(&crFill);
477   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
478   path.Clear();
479   path.AddRectangle(rt.left + 2, rt.top + 1, fWidth - 4, 1);
480   path.AddRectangle(rt.left + 1, rt.top + 2, 1, fHeight - 4);
481   crFill = m_pThemeData->clrNormalBtEdgeLight[iActive][eState - 1];
482   pGraphics->SetFillColor(&crFill);
483   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
484   path.Clear();
485   path.AddRectangle(fRight - 2, rt.top + 2, 1, fHeight - 4);
486   path.AddRectangle(rt.left + 2, fBottom - 2, fWidth - 4, 1);
487   crFill = m_pThemeData->clrNormalBtEdgeDark[iActive][eState - 1];
488   pGraphics->SetFillColor(&crFill);
489   pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix);
490   pGraphics->RestoreGraphState();
491   path.Clear();
492   path.AddRectangle(pRect->left + 2, pRect->top + 2, fWidth - 4, fHeight - 4);
493   DrawAxialShading(pGraphics, pRect->left + 2, pRect->top + 2, fRight - 2,
494                    fBottom - 2,
495                    m_pThemeData->clrNormalBtBKStart[iActive][eState - 1],
496                    m_pThemeData->clrNormalBtBKEnd[iActive][eState - 1], &path,
497                    FXFILL_WINDING, pMatrix);
498 }
DrawMinimizeBox(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)499 void CFWL_FormTP::DrawMinimizeBox(CFX_Graphics* pGraphics,
500                                   const CFX_RectF* pRect,
501                                   FWLTHEME_STATE eState,
502                                   CFX_Matrix* pMatrix,
503                                   int32_t iActive) {
504   DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
505   CFX_RectF rtMin;
506   rtMin.Set(pRect->left + 5, pRect->top + 13, pRect->width - 14,
507             pRect->height - 18);
508   FillSoildRect(pGraphics, 0xFFFFFFFF, &rtMin, pMatrix);
509 }
DrawMaximizeBox(CFX_Graphics * pGraphics,const CFX_RectF * pRect,FWLTHEME_STATE eState,FX_BOOL bMax,CFX_Matrix * pMatrix,int32_t iActive)510 void CFWL_FormTP::DrawMaximizeBox(CFX_Graphics* pGraphics,
511                                   const CFX_RectF* pRect,
512                                   FWLTHEME_STATE eState,
513                                   FX_BOOL bMax,
514                                   CFX_Matrix* pMatrix,
515                                   int32_t iActive) {
516   DrawMinMaxBoxCommon(pGraphics, pRect, eState, pMatrix);
517   FX_FLOAT fWidth = pRect->width;
518   FX_FLOAT fHeight = pRect->height;
519   if (bMax) {
520     CFX_Path path;
521     path.Create();
522     path.AddLine(pRect->left + 7, pRect->top + 6, pRect->left + 14,
523                  pRect->top + 6);
524     path.AddLine(pRect->left + 4, pRect->top + 9, pRect->left + 11,
525                  pRect->top + 9);
526     pGraphics->SaveGraphState();
527     pGraphics->SetLineWidth(2);
528     CFX_Color crStroke(0xFFFFFFFF);
529     pGraphics->SetStrokeColor(&crStroke);
530     pGraphics->StrokePath(&path, pMatrix);
531     pGraphics->SetLineWidth(1);
532     path.Clear();
533     path.AddLine(pRect->left + 4, pRect->top + 10, pRect->left + 4,
534                  pRect->top + 14);
535     path.AddLine(pRect->left + 10, pRect->top + 10, pRect->left + 10,
536                  pRect->top + 14);
537     path.AddLine(pRect->left + 13, pRect->top + 7, pRect->left + 13,
538                  pRect->top + 11);
539     path.AddLine(pRect->left + 4, pRect->top + 14, pRect->left + 10,
540                  pRect->top + 14);
541     path.AddLine(pRect->left + 12, pRect->top + 11, pRect->left + 12,
542                  pRect->top + 11);
543     pGraphics->StrokePath(&path, pMatrix);
544     pGraphics->RestoreGraphState();
545   } else {
546     CFX_RectF rtMax(*pRect);
547     rtMax.Inflate(-5, -5);
548     CFX_Path path;
549     path.Create();
550     path.AddRectangle(pRect->left + 5, pRect->top + 5, fWidth - 10,
551                       fHeight - 10);
552     path.AddRectangle(pRect->left + 6, pRect->top + 8, fWidth - 12,
553                       fHeight - 14);
554     pGraphics->SaveGraphState();
555     CFX_Color crFill(0xFFFFFFFF);
556     pGraphics->SetFillColor(&crFill);
557     pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix);
558     pGraphics->RestoreGraphState();
559   }
560 }
DrawIconImage(CFX_Graphics * pGraphics,CFX_DIBitmap * pDIBitmap,const CFX_RectF * pRect,FWLTHEME_STATE eState,CFX_Matrix * pMatrix,int32_t iActive)561 void CFWL_FormTP::DrawIconImage(CFX_Graphics* pGraphics,
562                                 CFX_DIBitmap* pDIBitmap,
563                                 const CFX_RectF* pRect,
564                                 FWLTHEME_STATE eState,
565                                 CFX_Matrix* pMatrix,
566                                 int32_t iActive) {
567   pGraphics->StretchImage(pDIBitmap, *pRect, pMatrix);
568 }
SetThemeData(FX_DWORD dwID)569 void CFWL_FormTP::SetThemeData(FX_DWORD dwID) {
570   m_pThemeData->clrTransWhite = ArgbEncode(0x65, 255, 255, 255);
571   m_pThemeData->clrCloseBtBKStart[0][0] = ArgbEncode(0xff, 240, 166, 148);
572   m_pThemeData->clrCloseBtBKEnd[0][0] = ArgbEncode(0xff, 228, 61, 5);
573   m_pThemeData->clrCloseBtBKStart[0][1] = ArgbEncode(0xff, 255, 184, 176);
574   m_pThemeData->clrCloseBtBKEnd[0][1] = ArgbEncode(0xff, 252, 107, 71);
575   m_pThemeData->clrCloseBtBKStart[0][2] = ArgbEncode(0xff, 141, 44, 20);
576   m_pThemeData->clrCloseBtBKEnd[0][2] = ArgbEncode(0xff, 202, 72, 33);
577   m_pThemeData->clrCloseBtEdgeLight[0][0] = ArgbEncode(0xff, 255, 122, 107);
578   m_pThemeData->clrCloseBtEdgeDark[0][0] = ArgbEncode(0xff, 218, 77, 54);
579   m_pThemeData->clrCloseBtEdgeLight[0][1] = ArgbEncode(0xff, 255, 93, 74);
580   m_pThemeData->clrCloseBtEdgeDark[0][1] = ArgbEncode(0xff, 218, 74, 51);
581   m_pThemeData->clrCloseBtEdgeLight[0][2] = ArgbEncode(0xff, 191, 61, 28);
582   m_pThemeData->clrCloseBtEdgeDark[0][2] = ArgbEncode(0xff, 93, 30, 13);
583   if (dwID) {
584     m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 194, 205, 149);
585     m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 170, 184, 131);
586     m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 168, 182, 128);
587     m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 194, 205, 149);
588     m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 117, 141, 94);
589     m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 139, 161, 105);
590     m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 171, 189, 133);
591     m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 155, 175, 125);
592     m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 128, 146, 103);
593     m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 94, 118, 79);
594     m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 139, 161, 105);
595     m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 234, 245, 201);
596     m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 194, 205, 149);
597     m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 175, 189, 133);
598     m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 153, 168, 121);
599     m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 150, 168, 103);
600     m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 182, 195, 162);
601     m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 128, 144, 84);
602     m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 234, 241, 208);
603     m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 169, 186, 112);
604     m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 199, 199, 190);
605     m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 133, 148, 88);
606     m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 163, 176, 137);
607     m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 118, 135, 83);
608     m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 154, 174, 105);
609     m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 154, 174, 105);
610     m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 172, 193, 123);
611     m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 154, 174, 105);
612     m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
613     m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
614     m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
615     m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
616     m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 117, 141, 94);
617     m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 139, 161, 105);
618     m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 171, 189, 133);
619     m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 164, 178, 127);
620     m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
621     m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 171, 189, 133);
622   } else {
623     m_pThemeData->clrHeadBK[0][0] = ArgbEncode(0xff, 3, 114, 255);
624     m_pThemeData->clrHeadBK[0][1] = ArgbEncode(0xff, 0, 85, 226);
625     m_pThemeData->clrHeadBK[0][2] = ArgbEncode(0xff, 0, 85, 226);
626     m_pThemeData->clrHeadBK[0][3] = ArgbEncode(0xff, 3, 114, 255);
627     m_pThemeData->clrHeadEdgeLeft[0][2] = ArgbEncode(0xff, 0, 32, 200);
628     m_pThemeData->clrHeadEdgeLeft[0][1] = ArgbEncode(0xff, 0, 61, 220);
629     m_pThemeData->clrHeadEdgeLeft[0][0] = ArgbEncode(0xff, 0, 54, 210);
630     m_pThemeData->clrHeadEdgeRight[0][0] = ArgbEncode(0xff, 0, 56, 234);
631     m_pThemeData->clrHeadEdgeRight[0][1] = ArgbEncode(0xff, 0, 50, 193);
632     m_pThemeData->clrHeadEdgeRight[0][2] = ArgbEncode(0xff, 0, 19, 139);
633     m_pThemeData->clrHeadEdgeTop[0][0] = ArgbEncode(0xff, 0, 88, 238);
634     m_pThemeData->clrHeadEdgeTop[0][1] = ArgbEncode(0xff, 63, 151, 255);
635     m_pThemeData->clrHeadEdgeTop[0][2] = ArgbEncode(0xff, 3, 114, 255);
636     m_pThemeData->clrHeadEdgeBottom[0][0] = ArgbEncode(0xff, 0, 96, 252);
637     m_pThemeData->clrHeadEdgeBottom[0][1] = ArgbEncode(0xff, 63, 151, 255);
638     m_pThemeData->clrHeadEdgeBottom[0][2] = ArgbEncode(0xff, 0, 67, 207);
639     m_pThemeData->clrNormalBtBKStart[0][2] = ArgbEncode(0xff, 0, 49, 112);
640     m_pThemeData->clrNormalBtBKEnd[0][2] = ArgbEncode(0xff, 0, 87, 188);
641     m_pThemeData->clrNormalBtBKStart[0][0] = ArgbEncode(0xff, 154, 183, 250);
642     m_pThemeData->clrNormalBtBKEnd[0][0] = ArgbEncode(0xff, 17, 110, 248);
643     m_pThemeData->clrNormalBtBKStart[0][1] = ArgbEncode(0xff, 164, 194, 255);
644     m_pThemeData->clrNormalBtBKEnd[0][1] = ArgbEncode(0xff, 29, 158, 255);
645     m_pThemeData->clrNormalBtEdgeLight[0][0] = ArgbEncode(0xff, 68, 120, 245);
646     m_pThemeData->clrNormalBtEdgeDark[0][0] = ArgbEncode(0xff, 24, 72, 187);
647     m_pThemeData->clrNormalBtEdgeLight[0][1] = ArgbEncode(0xff, 72, 122, 245);
648     m_pThemeData->clrNormalBtEdgeDark[0][1] = ArgbEncode(0xff, 35, 87, 195);
649     m_pThemeData->clrNormalBtEdgeLight[0][2] = ArgbEncode(0xff, 60, 114, 244);
650     m_pThemeData->clrNormalBtEdgeDark[0][2] = ArgbEncode(0xff, 21, 70, 185);
651     m_pThemeData->clrBtnCornerLight[0][0] = ArgbEncode(0xff, 220, 220, 220);
652     m_pThemeData->clrBtnCornerLight[0][1] = ArgbEncode(0xff, 255, 255, 255);
653     m_pThemeData->clrBtnCornerLight[0][2] = ArgbEncode(0xff, 225, 225, 225);
654     m_pThemeData->clrBtnEdgeOut[0] = ArgbEncode(0xff, 255, 255, 255);
655     m_pThemeData->clrFormBorder[0][0] = ArgbEncode(0xff, 0, 72, 241);
656     m_pThemeData->clrFormBorder[0][1] = ArgbEncode(0xff, 0, 61, 220);
657     m_pThemeData->clrFormBorder[0][2] = ArgbEncode(0xff, 0, 30, 160);
658     m_pThemeData->clrFormBorder[0][3] = ArgbEncode(0xff, 0, 19, 140);
659     m_pThemeData->clrFormBorder[0][4] = ArgbEncode(0xff, 255, 255, 255);
660     m_pThemeData->clrFormBorderLight[0] = ArgbEncode(0xff, 22, 106, 239);
661   }
662   m_pThemeData->clrCloseBtBKStart[1][0] = m_pThemeData->clrCloseBtBKStart[0][0];
663   m_pThemeData->clrCloseBtBKEnd[1][0] = m_pThemeData->clrCloseBtBKEnd[0][0];
664   m_pThemeData->clrCloseBtBKStart[1][1] = m_pThemeData->clrCloseBtBKStart[0][1];
665   m_pThemeData->clrCloseBtBKEnd[1][1] = m_pThemeData->clrCloseBtBKEnd[0][1];
666   m_pThemeData->clrCloseBtBKStart[1][2] = m_pThemeData->clrCloseBtBKStart[0][2];
667   m_pThemeData->clrCloseBtBKEnd[1][2] = m_pThemeData->clrCloseBtBKEnd[0][2];
668   m_pThemeData->clrCloseBtEdgeLight[1][0] =
669       m_pThemeData->clrCloseBtEdgeLight[0][0];
670   m_pThemeData->clrCloseBtEdgeDark[1][0] =
671       m_pThemeData->clrCloseBtEdgeDark[0][0];
672   m_pThemeData->clrCloseBtEdgeLight[1][1] =
673       m_pThemeData->clrCloseBtEdgeLight[0][1];
674   m_pThemeData->clrCloseBtEdgeDark[1][1] =
675       m_pThemeData->clrCloseBtEdgeDark[0][1];
676   m_pThemeData->clrCloseBtEdgeLight[1][2] =
677       m_pThemeData->clrCloseBtEdgeLight[0][2];
678   m_pThemeData->clrCloseBtEdgeDark[1][2] =
679       m_pThemeData->clrCloseBtEdgeDark[0][2];
680   m_pThemeData->clrHeadBK[1][0] = m_pThemeData->clrHeadBK[0][0];
681   m_pThemeData->clrHeadBK[1][1] = m_pThemeData->clrHeadBK[0][1];
682   m_pThemeData->clrHeadBK[1][2] = m_pThemeData->clrHeadBK[0][2];
683   m_pThemeData->clrHeadBK[1][3] = m_pThemeData->clrHeadBK[0][3];
684   m_pThemeData->clrHeadEdgeLeft[1][2] = m_pThemeData->clrHeadEdgeLeft[0][2];
685   m_pThemeData->clrHeadEdgeLeft[1][1] = m_pThemeData->clrHeadEdgeLeft[0][1];
686   m_pThemeData->clrHeadEdgeLeft[1][0] = m_pThemeData->clrHeadEdgeLeft[0][0];
687   m_pThemeData->clrHeadEdgeRight[1][0] = m_pThemeData->clrHeadEdgeRight[0][0];
688   m_pThemeData->clrHeadEdgeRight[1][1] = m_pThemeData->clrHeadEdgeRight[0][1];
689   m_pThemeData->clrHeadEdgeRight[1][2] = m_pThemeData->clrHeadEdgeRight[0][2];
690   m_pThemeData->clrHeadEdgeTop[1][0] = m_pThemeData->clrHeadEdgeTop[0][0];
691   m_pThemeData->clrHeadEdgeTop[1][1] = m_pThemeData->clrHeadEdgeTop[0][1];
692   m_pThemeData->clrHeadEdgeTop[1][2] = m_pThemeData->clrHeadEdgeTop[0][2];
693   m_pThemeData->clrHeadEdgeBottom[1][0] = m_pThemeData->clrHeadEdgeBottom[0][0];
694   m_pThemeData->clrHeadEdgeBottom[1][1] = m_pThemeData->clrHeadEdgeBottom[0][1];
695   m_pThemeData->clrHeadEdgeBottom[1][2] = m_pThemeData->clrHeadEdgeBottom[0][2];
696   m_pThemeData->clrNormalBtBKStart[1][2] =
697       m_pThemeData->clrNormalBtBKStart[0][2];
698   m_pThemeData->clrNormalBtBKEnd[1][2] = m_pThemeData->clrNormalBtBKEnd[0][2];
699   m_pThemeData->clrNormalBtBKStart[1][0] =
700       m_pThemeData->clrNormalBtBKStart[0][0];
701   m_pThemeData->clrNormalBtBKEnd[1][0] = m_pThemeData->clrNormalBtBKEnd[1][0];
702   m_pThemeData->clrNormalBtBKStart[1][1] =
703       m_pThemeData->clrNormalBtBKStart[0][1];
704   m_pThemeData->clrNormalBtBKEnd[1][1] = m_pThemeData->clrNormalBtBKEnd[0][1];
705   m_pThemeData->clrNormalBtEdgeLight[1][0] =
706       m_pThemeData->clrNormalBtEdgeLight[0][0];
707   m_pThemeData->clrNormalBtEdgeDark[1][0] =
708       m_pThemeData->clrNormalBtEdgeDark[0][0];
709   m_pThemeData->clrNormalBtEdgeLight[1][1] =
710       m_pThemeData->clrNormalBtEdgeLight[0][1];
711   m_pThemeData->clrNormalBtEdgeDark[1][1] =
712       m_pThemeData->clrNormalBtEdgeDark[0][1];
713   m_pThemeData->clrNormalBtEdgeLight[1][2] =
714       m_pThemeData->clrNormalBtEdgeLight[0][2];
715   m_pThemeData->clrNormalBtEdgeDark[1][2] =
716       m_pThemeData->clrNormalBtEdgeDark[0][2];
717   m_pThemeData->clrBtnCornerLight[1][0] = m_pThemeData->clrBtnCornerLight[0][0];
718   m_pThemeData->clrBtnCornerLight[1][1] = m_pThemeData->clrBtnCornerLight[0][1];
719   m_pThemeData->clrBtnCornerLight[1][2] = m_pThemeData->clrBtnCornerLight[0][2];
720   m_pThemeData->clrBtnEdgeOut[1] = m_pThemeData->clrBtnEdgeOut[0];
721   m_pThemeData->clrFormBorder[1][0] = m_pThemeData->clrFormBorder[0][0];
722   m_pThemeData->clrFormBorder[1][1] = m_pThemeData->clrFormBorder[0][1];
723   m_pThemeData->clrFormBorder[1][2] = m_pThemeData->clrFormBorder[0][2];
724   m_pThemeData->clrFormBorder[1][3] = m_pThemeData->clrFormBorder[0][3];
725   m_pThemeData->clrFormBorder[1][4] = m_pThemeData->clrFormBorder[0][4];
726   m_pThemeData->clrFormBorderLight[1] = m_pThemeData->clrFormBorderLight[0];
727   DeactiveForm();
728 }
DeactiveForm()729 void CFWL_FormTP::DeactiveForm() {
730   TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][0]);
731   TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][1]);
732   TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][2]);
733   TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrHeadBK[1][3]);
734   TransModeColor(m_pThemeData->clrTransWhite,
735                  m_pThemeData->clrHeadEdgeLeft[1][0]);
736   TransModeColor(m_pThemeData->clrTransWhite,
737                  m_pThemeData->clrHeadEdgeLeft[1][1]);
738   TransModeColor(m_pThemeData->clrTransWhite,
739                  m_pThemeData->clrHeadEdgeLeft[1][2]);
740   TransModeColor(m_pThemeData->clrTransWhite,
741                  m_pThemeData->clrHeadEdgeRight[1][0]);
742   TransModeColor(m_pThemeData->clrTransWhite,
743                  m_pThemeData->clrHeadEdgeRight[1][1]);
744   TransModeColor(m_pThemeData->clrTransWhite,
745                  m_pThemeData->clrHeadEdgeRight[1][2]);
746   TransModeColor(m_pThemeData->clrTransWhite,
747                  m_pThemeData->clrHeadEdgeTop[1][0]);
748   TransModeColor(m_pThemeData->clrTransWhite,
749                  m_pThemeData->clrHeadEdgeTop[1][1]);
750   TransModeColor(m_pThemeData->clrTransWhite,
751                  m_pThemeData->clrHeadEdgeTop[1][2]);
752   TransModeColor(m_pThemeData->clrTransWhite,
753                  m_pThemeData->clrHeadEdgeBottom[1][0]);
754   TransModeColor(m_pThemeData->clrTransWhite,
755                  m_pThemeData->clrHeadEdgeBottom[1][1]);
756   TransModeColor(m_pThemeData->clrTransWhite,
757                  m_pThemeData->clrHeadEdgeBottom[1][2]);
758   TransModeColor(m_pThemeData->clrTransWhite,
759                  m_pThemeData->clrNormalBtBKStart[1][0]);
760   TransModeColor(m_pThemeData->clrTransWhite,
761                  m_pThemeData->clrNormalBtBKStart[1][1]);
762   TransModeColor(m_pThemeData->clrTransWhite,
763                  m_pThemeData->clrNormalBtBKStart[1][2]);
764   TransModeColor(m_pThemeData->clrTransWhite,
765                  m_pThemeData->clrNormalBtBKEnd[1][0]);
766   TransModeColor(m_pThemeData->clrTransWhite,
767                  m_pThemeData->clrNormalBtBKEnd[1][1]);
768   TransModeColor(m_pThemeData->clrTransWhite,
769                  m_pThemeData->clrNormalBtBKEnd[1][2]);
770   TransModeColor(m_pThemeData->clrTransWhite,
771                  m_pThemeData->clrNormalBtEdgeLight[1][0]);
772   TransModeColor(m_pThemeData->clrTransWhite,
773                  m_pThemeData->clrNormalBtEdgeLight[1][1]);
774   TransModeColor(m_pThemeData->clrTransWhite,
775                  m_pThemeData->clrNormalBtEdgeLight[1][2]);
776   TransModeColor(m_pThemeData->clrTransWhite,
777                  m_pThemeData->clrNormalBtEdgeDark[1][0]);
778   TransModeColor(m_pThemeData->clrTransWhite,
779                  m_pThemeData->clrNormalBtEdgeDark[1][1]);
780   TransModeColor(m_pThemeData->clrTransWhite,
781                  m_pThemeData->clrNormalBtEdgeDark[1][2]);
782   TransModeColor(m_pThemeData->clrTransWhite,
783                  m_pThemeData->clrBtnCornerLight[1][0]);
784   TransModeColor(m_pThemeData->clrTransWhite,
785                  m_pThemeData->clrBtnCornerLight[1][1]);
786   TransModeColor(m_pThemeData->clrTransWhite,
787                  m_pThemeData->clrBtnCornerLight[1][2]);
788   TransModeColor(m_pThemeData->clrTransWhite, m_pThemeData->clrBtnEdgeOut[1]);
789   TransModeColor(m_pThemeData->clrTransWhite,
790                  m_pThemeData->clrFormBorder[1][0]);
791   TransModeColor(m_pThemeData->clrTransWhite,
792                  m_pThemeData->clrFormBorder[1][1]);
793   TransModeColor(m_pThemeData->clrTransWhite,
794                  m_pThemeData->clrFormBorder[1][2]);
795   TransModeColor(m_pThemeData->clrTransWhite,
796                  m_pThemeData->clrFormBorder[1][3]);
797   TransModeColor(m_pThemeData->clrTransWhite,
798                  m_pThemeData->clrFormBorder[1][4]);
799   TransModeColor(m_pThemeData->clrTransWhite,
800                  m_pThemeData->clrFormBorderLight[1]);
801   TransModeColor(m_pThemeData->clrTransWhite,
802                  m_pThemeData->clrCloseBtBKStart[1][0]);
803   TransModeColor(m_pThemeData->clrTransWhite,
804                  m_pThemeData->clrCloseBtBKStart[1][1]);
805   TransModeColor(m_pThemeData->clrTransWhite,
806                  m_pThemeData->clrCloseBtBKStart[1][2]);
807   TransModeColor(m_pThemeData->clrTransWhite,
808                  m_pThemeData->clrCloseBtBKEnd[1][0]);
809   TransModeColor(m_pThemeData->clrTransWhite,
810                  m_pThemeData->clrCloseBtBKEnd[1][1]);
811   TransModeColor(m_pThemeData->clrTransWhite,
812                  m_pThemeData->clrCloseBtBKEnd[1][2]);
813   TransModeColor(m_pThemeData->clrTransWhite,
814                  m_pThemeData->clrCloseBtEdgeLight[1][0]);
815   TransModeColor(m_pThemeData->clrTransWhite,
816                  m_pThemeData->clrCloseBtEdgeLight[1][1]);
817   TransModeColor(m_pThemeData->clrTransWhite,
818                  m_pThemeData->clrCloseBtEdgeLight[1][2]);
819   TransModeColor(m_pThemeData->clrTransWhite,
820                  m_pThemeData->clrCloseBtEdgeDark[1][0]);
821   TransModeColor(m_pThemeData->clrTransWhite,
822                  m_pThemeData->clrCloseBtEdgeDark[1][1]);
823   TransModeColor(m_pThemeData->clrTransWhite,
824                  m_pThemeData->clrCloseBtEdgeDark[1][2]);
825 }
TransModeColor(FX_ARGB clrFore,FX_ARGB & clrBack)826 void CFWL_FormTP::TransModeColor(FX_ARGB clrFore, FX_ARGB& clrBack) {
827   int32_t iAlfaF, iRF, iGF, iBF;
828   int32_t iAlfaB, iRB, iGB, iBB;
829   ArgbDecode(clrFore, iAlfaF, iRF, iGF, iBF);
830   ArgbDecode(clrBack, iAlfaB, iRB, iGB, iBB);
831   clrBack = ArgbEncode(0xff, iRB + (iRF - iRB) * iAlfaF / 255,
832                        iGB + (iGF - iGB) * iAlfaF / 255,
833                        iBB + (iBF - iBB) * iAlfaF / 255);
834 }
InitCaption(FX_BOOL bActive)835 void CFWL_FormTP::InitCaption(FX_BOOL bActive) {
836   if (bActive) {
837     CFX_FxgeDevice dev;
838     CFX_Graphics gs;
839     CFX_Path path;
840     path.Create();
841     if (m_pActiveBitmap) {
842       delete m_pActiveBitmap;
843       m_pActiveBitmap = NULL;
844     }
845     m_pActiveBitmap = new CFX_DIBitmap;
846     m_pActiveBitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
847     dev.Attach(m_pActiveBitmap);
848     gs.Create(&dev);
849     path.AddRectangle(0, 0, 1, 5);
850     DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[0][0],
851                      m_pThemeData->clrHeadBK[0][1], &path);
852     path.Clear();
853     path.AddRectangle(0, 5, 1, 15);
854     DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[0][1],
855                      m_pThemeData->clrHeadBK[0][2], &path);
856     path.Clear();
857     path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
858     DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
859                      m_pThemeData->clrHeadBK[0][2],
860                      m_pThemeData->clrHeadBK[0][3], &path);
861   } else {
862     CFX_FxgeDevice dev;
863     CFX_Graphics gs;
864     CFX_Path path;
865     path.Create();
866     if (m_pDeactivebitmap) {
867       delete m_pDeactivebitmap;
868       m_pDeactivebitmap = NULL;
869     }
870     m_pDeactivebitmap = new CFX_DIBitmap;
871     m_pDeactivebitmap->Create(1, FWLTHEME_CAPACITY_CYCaption, FXDIB_Argb);
872     dev.Attach(m_pDeactivebitmap);
873     gs.Create(&dev);
874     path.AddRectangle(0, 0, 1, 5);
875     DrawAxialShading(&gs, 0, 0, 0, 5, m_pThemeData->clrHeadBK[1][0],
876                      m_pThemeData->clrHeadBK[1][1], &path);
877     path.Clear();
878     path.AddRectangle(0, 5, 1, 15);
879     DrawAxialShading(&gs, 0, 5, 0, 20, m_pThemeData->clrHeadBK[1][1],
880                      m_pThemeData->clrHeadBK[1][2], &path);
881     path.Clear();
882     path.AddRectangle(0, 20, 1, FWLTHEME_CAPACITY_CYCaption - 19);
883     DrawAxialShading(&gs, 0, 20, 0, FWLTHEME_CAPACITY_CYCaption,
884                      m_pThemeData->clrHeadBK[1][2],
885                      m_pThemeData->clrHeadBK[1][3], &path);
886   }
887 }
888