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/fxfa/app/xfa_fwltheme.h" | 7 #include "xfa/fxfa/app/xfa_fwltheme.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 delete m_pPictureBoxTP; | 69 delete m_pPictureBoxTP; |
70 delete m_pSrollBarTP; | 70 delete m_pSrollBarTP; |
71 delete m_pEditTP; | 71 delete m_pEditTP; |
72 delete m_pComboBoxTP; | 72 delete m_pComboBoxTP; |
73 delete m_pMonthCalendarTP; | 73 delete m_pMonthCalendarTP; |
74 delete m_pDateTimePickerTP; | 74 delete m_pDateTimePickerTP; |
75 delete m_pPushButtonTP; | 75 delete m_pPushButtonTP; |
76 delete m_pCaretTP; | 76 delete m_pCaretTP; |
77 delete m_pBarcodeTP; | 77 delete m_pBarcodeTP; |
78 } | 78 } |
79 FWL_ERR CXFA_FWLTheme::Initialize() { | 79 FWL_Error CXFA_FWLTheme::Initialize() { |
80 m_pTextOut = new CFDE_TextOut; | 80 m_pTextOut = new CFDE_TextOut; |
81 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); | 81 for (size_t i = 0; !m_pCalendarFont && i < FX_ArraySize(g_FWLTheme_CalFonts); |
82 ++i) { | 82 ++i) { |
83 m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, | 83 m_pCalendarFont = IFX_Font::LoadFont(g_FWLTheme_CalFonts[i], 0, 0, |
84 m_pApp->GetFDEFontMgr()); | 84 m_pApp->GetFDEFontMgr()); |
85 } | 85 } |
86 if (!m_pCalendarFont) { | 86 if (!m_pCalendarFont) { |
87 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 87 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
88 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( | 88 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetDefFontByCodePage( |
89 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); | 89 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); |
90 #else | 90 #else |
91 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( | 91 m_pCalendarFont = m_pApp->GetFDEFontMgr()->GetFontByCodePage( |
92 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); | 92 FX_CODEPAGE_MSWin_WesternEuropean, 0, NULL); |
93 #endif | 93 #endif |
94 } | 94 } |
95 | 95 |
96 ASSERT(NULL != m_pCalendarFont); | 96 ASSERT(NULL != m_pCalendarFont); |
97 FWLTHEME_Init(); | 97 FWLTHEME_Init(); |
98 return FWL_ERR_Succeeded; | 98 return FWL_Error::Succeeded; |
99 } | 99 } |
100 FWL_ERR CXFA_FWLTheme::Finalize() { | 100 FWL_Error CXFA_FWLTheme::Finalize() { |
101 if (m_pTextOut) { | 101 if (m_pTextOut) { |
102 m_pTextOut->Release(); | 102 m_pTextOut->Release(); |
103 m_pTextOut = NULL; | 103 m_pTextOut = NULL; |
104 } | 104 } |
105 if (m_pCalendarFont) { | 105 if (m_pCalendarFont) { |
106 m_pCalendarFont->Release(); | 106 m_pCalendarFont->Release(); |
107 m_pCalendarFont = NULL; | 107 m_pCalendarFont = NULL; |
108 } | 108 } |
109 FWLTHEME_Release(); | 109 FWLTHEME_Release(); |
110 return FWL_ERR_Succeeded; | 110 return FWL_Error::Succeeded; |
111 } | 111 } |
112 FX_BOOL CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) { | 112 FX_BOOL CXFA_FWLTheme::IsValidWidget(IFWL_Widget* pWidget) { |
113 return TRUE; | 113 return TRUE; |
114 } | 114 } |
115 uint32_t CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) { | 115 uint32_t CXFA_FWLTheme::GetThemeID(IFWL_Widget* pWidget) { |
116 return 0; | 116 return 0; |
117 } | 117 } |
118 uint32_t CXFA_FWLTheme::SetThemeID(IFWL_Widget* pWidget, | 118 uint32_t CXFA_FWLTheme::SetThemeID(IFWL_Widget* pWidget, |
119 uint32_t dwThemeID, | 119 uint32_t dwThemeID, |
120 FX_BOOL bChildren) { | 120 FX_BOOL bChildren) { |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 FX_BOOL CXFA_FWLTheme::DrawBackground(CFWL_ThemeBackground* pParams) { | 123 FX_BOOL CXFA_FWLTheme::DrawBackground(CFWL_ThemeBackground* pParams) { |
124 return GetTheme(pParams->m_pWidget)->DrawBackground(pParams); | 124 return GetTheme(pParams->m_pWidget)->DrawBackground(pParams); |
125 } | 125 } |
126 FX_BOOL CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { | 126 FX_BOOL CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { |
127 if (pParams->m_wsText.IsEmpty()) { | 127 if (pParams->m_wsText.IsEmpty()) |
128 return FWL_ERR_Indefinite; | 128 return FALSE; |
129 } | 129 |
130 if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) { | 130 if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) { |
131 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); | 131 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); |
132 if (!pWidget) { | 132 if (!pWidget) |
133 return FWL_ERR_Indefinite; | 133 return FALSE; |
134 } | 134 |
135 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 135 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
136 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 136 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
137 m_pTextOut->SetFont(m_pCalendarFont); | 137 m_pTextOut->SetFont(m_pCalendarFont); |
138 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); | 138 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); |
139 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); | 139 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); |
140 if ((pParams->m_iPart == CFWL_Part::DatesIn) && | 140 if ((pParams->m_iPart == CFWL_Part::DatesIn) && |
141 !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && | 141 !(pParams->m_dwStates & FWL_ITEMSTATE_MCD_Flag) && |
142 (pParams->m_dwStates & | 142 (pParams->m_dwStates & |
143 (CFWL_PartState_Hovered | CFWL_PartState_Selected))) { | 143 (CFWL_PartState_Hovered | CFWL_PartState_Selected))) { |
144 m_pTextOut->SetTextColor(0xFFFFFFFF); | 144 m_pTextOut->SetTextColor(0xFFFFFFFF); |
(...skipping 14 matching lines...) Expand all Loading... |
159 CFX_Matrix* pMatrix = pGraphics->GetMatrix(); | 159 CFX_Matrix* pMatrix = pGraphics->GetMatrix(); |
160 if (pMatrix) { | 160 if (pMatrix) { |
161 mtPart.Concat(*pMatrix); | 161 mtPart.Concat(*pMatrix); |
162 } | 162 } |
163 m_pTextOut->SetMatrix(mtPart); | 163 m_pTextOut->SetMatrix(mtPart); |
164 m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), | 164 m_pTextOut->DrawLogicText(pParams->m_wsText.c_str(), |
165 pParams->m_wsText.GetLength(), pParams->m_rtPart); | 165 pParams->m_wsText.GetLength(), pParams->m_rtPart); |
166 return TRUE; | 166 return TRUE; |
167 } | 167 } |
168 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); | 168 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); |
169 if (!pWidget) { | 169 if (!pWidget) |
170 return FWL_ERR_Indefinite; | 170 return FALSE; |
171 } | 171 |
172 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); | 172 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); |
173 CFX_Graphics* pGraphics = pParams->m_pGraphics; | 173 CFX_Graphics* pGraphics = pParams->m_pGraphics; |
174 CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); | 174 CFX_RenderDevice* pRenderDevice = pGraphics->GetRenderDevice(); |
175 if (!pRenderDevice) | 175 if (!pRenderDevice) |
176 return FALSE; | 176 return FALSE; |
177 m_pTextOut->SetRenderDevice(pRenderDevice); | 177 m_pTextOut->SetRenderDevice(pRenderDevice); |
178 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 178 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
179 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 179 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
180 m_pTextOut->SetFont(pAcc->GetFDEFont()); | 180 m_pTextOut->SetFont(pAcc->GetFDEFont()); |
181 m_pTextOut->SetFontSize(pAcc->GetFontSize()); | 181 m_pTextOut->SetFontSize(pAcc->GetFontSize()); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 if (!m_wsResource.IsEmpty()) | 339 if (!m_wsResource.IsEmpty()) |
340 return &m_wsResource; | 340 return &m_wsResource; |
341 } | 341 } |
342 } | 342 } |
343 return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); | 343 return GetTheme(pThemePart->m_pWidget)->GetCapacity(pThemePart, dwCapacity); |
344 } | 344 } |
345 FX_BOOL CXFA_FWLTheme::IsCustomizedLayout(IFWL_Widget* pWidget) { | 345 FX_BOOL CXFA_FWLTheme::IsCustomizedLayout(IFWL_Widget* pWidget) { |
346 return GetTheme(pWidget)->IsCustomizedLayout(pWidget); | 346 return GetTheme(pWidget)->IsCustomizedLayout(pWidget); |
347 } | 347 } |
348 FWL_ERR CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) { | 348 FWL_Error CXFA_FWLTheme::GetPartRect(CFWL_ThemePart* pThemePart) { |
349 CFX_RectF rect; | 349 CFX_RectF rect; |
350 return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rect); | 350 return GetTheme(pThemePart->m_pWidget)->GetPartRect(pThemePart, rect); |
351 } | 351 } |
352 FX_BOOL CXFA_FWLTheme::IsInPart(CFWL_ThemePart* pThemePart, | 352 FX_BOOL CXFA_FWLTheme::IsInPart(CFWL_ThemePart* pThemePart, |
353 FX_FLOAT fx, | 353 FX_FLOAT fx, |
354 FX_FLOAT fy) { | 354 FX_FLOAT fy) { |
355 return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy); | 355 return GetTheme(pThemePart->m_pWidget)->IsInPart(pThemePart, fx, fy); |
356 } | 356 } |
357 FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { | 357 FX_BOOL CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { |
358 if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) { | 358 if (pParams->m_pWidget->GetClassID() == FWL_CLASSHASH_MonthCalendar) { |
359 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); | 359 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); |
360 if (!pWidget) { | 360 if (!pWidget) |
361 return FWL_ERR_Indefinite; | 361 return FALSE; |
362 } | |
363 if (!pParams) | 362 if (!pParams) |
364 return FALSE; | 363 return FALSE; |
365 if (!m_pTextOut) | 364 if (!m_pTextOut) |
366 return FALSE; | 365 return FALSE; |
367 m_pTextOut->SetFont(m_pCalendarFont); | 366 m_pTextOut->SetFont(m_pCalendarFont); |
368 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); | 367 m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize); |
369 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); | 368 m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor); |
370 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 369 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
371 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 370 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
372 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), | 371 m_pTextOut->CalcLogicSize(pParams->m_wsText.c_str(), |
373 pParams->m_wsText.GetLength(), rect); | 372 pParams->m_wsText.GetLength(), rect); |
374 return TRUE; | 373 return TRUE; |
375 } | 374 } |
376 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); | 375 CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pParams->m_pWidget); |
377 if (!pWidget) { | 376 if (!pWidget) |
378 return FWL_ERR_Indefinite; | 377 return FALSE; |
379 } | 378 |
380 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); | 379 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); |
381 m_pTextOut->SetFont(pAcc->GetFDEFont()); | 380 m_pTextOut->SetFont(pAcc->GetFDEFont()); |
382 m_pTextOut->SetFontSize(pAcc->GetFontSize()); | 381 m_pTextOut->SetFontSize(pAcc->GetFontSize()); |
383 m_pTextOut->SetTextColor(pAcc->GetTextColor()); | 382 m_pTextOut->SetTextColor(pAcc->GetTextColor()); |
384 if (!pParams) | 383 if (!pParams) |
385 return FALSE; | 384 return FALSE; |
386 if (!m_pTextOut) | 385 if (!m_pTextOut) |
387 return FALSE; | 386 return FALSE; |
388 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); | 387 m_pTextOut->SetAlignment(pParams->m_iTTOAlign); |
389 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); | 388 m_pTextOut->SetStyles(pParams->m_dwTTOStyles); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 } | 483 } |
485 } | 484 } |
486 CFX_Color crLine(cr); | 485 CFX_Color crLine(cr); |
487 pParams->m_pGraphics->SetStrokeColor(&crLine); | 486 pParams->m_pGraphics->SetStrokeColor(&crLine); |
488 pParams->m_pGraphics->SetLineWidth(fWidth); | 487 pParams->m_pGraphics->SetLineWidth(fWidth); |
489 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); | 488 pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); |
490 return TRUE; | 489 return TRUE; |
491 } | 490 } |
492 return CFWL_EditTP::DrawBackground(pParams); | 491 return CFWL_EditTP::DrawBackground(pParams); |
493 } | 492 } |
OLD | NEW |