| OLD | NEW |
| (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/datetimepickertp.h" | |
| 8 | |
| 9 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h" | |
| 10 #include "xfa/fwl/core/cfwl_themebackground.h" | |
| 11 | |
| 12 CFWL_DateTimePickerTP::CFWL_DateTimePickerTP() { | |
| 13 m_pThemeData = new DTPThemeData; | |
| 14 initThemeData(); | |
| 15 } | |
| 16 CFWL_DateTimePickerTP::~CFWL_DateTimePickerTP() { | |
| 17 delete m_pThemeData; | |
| 18 } | |
| 19 FX_BOOL CFWL_DateTimePickerTP::IsValidWidget(IFWL_Widget* pWidget) { | |
| 20 if (!pWidget) | |
| 21 return FALSE; | |
| 22 return pWidget->GetClassID() == FWL_CLASSHASH_DateTimePicker; | |
| 23 } | |
| 24 FX_BOOL CFWL_DateTimePickerTP::DrawBackground(CFWL_ThemeBackground* pParams) { | |
| 25 if (!pParams) | |
| 26 return FALSE; | |
| 27 switch (pParams->m_iPart) { | |
| 28 case FWL_PART_DTP_Border: { | |
| 29 DrawBorder(pParams->m_pGraphics, &pParams->m_rtPart, &pParams->m_matrix); | |
| 30 break; | |
| 31 } | |
| 32 case FWL_PART_DTP_Edge: { | |
| 33 DrawEdge(pParams->m_pGraphics, pParams->m_pWidget->GetStyles(), | |
| 34 &pParams->m_rtPart, &pParams->m_matrix); | |
| 35 break; | |
| 36 } | |
| 37 case FWL_PART_DTP_DropDownButton: { | |
| 38 DrawDropDownButton(pParams, &pParams->m_matrix); | |
| 39 break; | |
| 40 } | |
| 41 default: {} | |
| 42 } | |
| 43 return TRUE; | |
| 44 } | |
| 45 #ifdef THEME_XPSimilar | |
| 46 void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, | |
| 47 CFX_Matrix* pMatrix) { | |
| 48 uint32_t dwStates = pParams->m_dwStates; | |
| 49 dwStates &= 0x03; | |
| 50 FWLTHEME_STATE eState = FWLTHEME_STATE_Normal; | |
| 51 switch (eState & dwStates) { | |
| 52 case FWL_PARTSTATE_DTP_Normal: { | |
| 53 eState = FWLTHEME_STATE_Normal; | |
| 54 break; | |
| 55 } | |
| 56 case FWL_PARTSTATE_DTP_Hovered: { | |
| 57 eState = FWLTHEME_STATE_Hover; | |
| 58 break; | |
| 59 } | |
| 60 case FWL_PARTSTATE_DTP_Pressed: { | |
| 61 eState = FWLTHEME_STATE_Pressed; | |
| 62 break; | |
| 63 } | |
| 64 case FWL_PARTSTATE_DTP_Disabled: { | |
| 65 eState = FWLTHEME_STATE_Disabale; | |
| 66 break; | |
| 67 } | |
| 68 default: {} | |
| 69 } | |
| 70 DrawArrowBtn(pParams->m_pGraphics, &pParams->m_rtPart, | |
| 71 FWLTHEME_DIRECTION_Down, eState, pMatrix); | |
| 72 } | |
| 73 #else | |
| 74 void CFWL_DateTimePickerTP::DrawDropDownButton(CFWL_ThemeBackground* pParams, | |
| 75 CFX_Matrix* pMatrix) { | |
| 76 FX_BOOL bPressed = ((pParams->m_dwStates & FWL_PARTSTATE_DTP_Pressed) == | |
| 77 FWL_PARTSTATE_DTP_Pressed); | |
| 78 FX_FLOAT fWidth = bPressed ? 1.0f : 2.0f; | |
| 79 FWLTHEME_EDGE eType = bPressed ? FWLTHEME_EDGE_Flat : FWLTHEME_EDGE_Raised; | |
| 80 Draw3DRect(pParams->m_pGraphics, eType, fWidth, &pParams->m_rtPart, | |
| 81 FWLTHEME_COLOR_EDGELT1, FWLTHEME_COLOR_EDGELT2, | |
| 82 FWLTHEME_COLOR_EDGERB1, FWLTHEME_COLOR_EDGERB2, pMatrix); | |
| 83 CFX_Path path; | |
| 84 path.Create(); | |
| 85 path.AddRectangle(pParams->m_rtPart.left + fWidth, | |
| 86 pParams->m_rtPart.top + fWidth, | |
| 87 pParams->m_rtPart.width - 2 * fWidth, | |
| 88 pParams->m_rtPart.height - 2 * fWidth); | |
| 89 pParams->m_pGraphics->SaveGraphState(); | |
| 90 CFX_Color crFill(FWLTHEME_COLOR_Background); | |
| 91 pParams->m_pGraphics->SetFillColor(&crFill); | |
| 92 pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); | |
| 93 pParams->m_pGraphics->RestoreGraphState(); | |
| 94 FX_ARGB argbFill = ArgbEncode(255, 77, 97, 133); | |
| 95 switch (pParams->m_dwStates & 0x03) { | |
| 96 case FWL_PARTSTATE_DTP_Normal: { | |
| 97 } | |
| 98 case FWL_PARTSTATE_DTP_Hovered: { | |
| 99 } | |
| 100 case FWL_PARTSTATE_DTP_Pressed: { | |
| 101 argbFill = 0xFF000000; | |
| 102 break; | |
| 103 } | |
| 104 case FWL_PARTSTATE_DTP_Disabled: { | |
| 105 argbFill = 0xFFF0F0F0; | |
| 106 break; | |
| 107 } | |
| 108 } | |
| 109 DrawArrow(pParams->m_pGraphics, &pParams->m_rtPart, FWLTHEME_DIRECTION_Down, | |
| 110 argbFill, bPressed, pMatrix); | |
| 111 } | |
| 112 #endif | |
| 113 void CFWL_DateTimePickerTP::initThemeData() { | |
| 114 uint32_t* pData = (uint32_t*)&m_pThemeData->BoxBkColor; | |
| 115 *pData++ = 0, *pData++ = 0, *pData++ = ArgbEncode(255, 220, 220, 215), | |
| 116 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 117 *pData++ = ArgbEncode(255, 255, 240, 207), | |
| 118 *pData++ = ArgbEncode(255, 248, 179, 48), | |
| 119 *pData++ = ArgbEncode(255, 176, 176, 167), | |
| 120 *pData++ = ArgbEncode(255, 241, 239, 239), | |
| 121 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 122 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 123 *pData++ = ArgbEncode(255, 220, 220, 215), | |
| 124 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 125 *pData++ = ArgbEncode(255, 255, 240, 207), | |
| 126 *pData++ = ArgbEncode(255, 248, 179, 48), | |
| 127 *pData++ = ArgbEncode(255, 176, 176, 167), | |
| 128 *pData++ = ArgbEncode(255, 241, 239, 239), | |
| 129 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 130 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 131 *pData++ = ArgbEncode(255, 220, 220, 215), | |
| 132 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 133 *pData++ = ArgbEncode(255, 255, 240, 207), | |
| 134 *pData++ = ArgbEncode(255, 248, 179, 48), | |
| 135 *pData++ = ArgbEncode(255, 176, 176, 167), | |
| 136 *pData++ = ArgbEncode(255, 241, 239, 239), | |
| 137 *pData++ = ArgbEncode(255, 255, 255, 255), | |
| 138 *pData++ = ArgbEncode(255, 255, 255, 255); | |
| 139 } | |
| OLD | NEW |