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/fwl/cfwl_pushbutton.h" | 7 #include "xfa/fwl/cfwl_pushbutton.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 uint32_t CFWL_PushButton::GetPartStates() { | 94 uint32_t CFWL_PushButton::GetPartStates() { |
95 uint32_t dwStates = CFWL_PartState_Normal; | 95 uint32_t dwStates = CFWL_PartState_Normal; |
96 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) | 96 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) |
97 dwStates |= CFWL_PartState_Focused; | 97 dwStates |= CFWL_PartState_Focused; |
98 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 98 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
99 dwStates = CFWL_PartState_Disabled; | 99 dwStates = CFWL_PartState_Disabled; |
100 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) | 100 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) |
101 dwStates |= CFWL_PartState_Pressed; | 101 dwStates |= CFWL_PartState_Pressed; |
102 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) | 102 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) |
103 dwStates |= CFWL_PartState_Hovered; | 103 dwStates |= CFWL_PartState_Hovered; |
104 else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) | |
105 dwStates |= CFWL_PartState_Default; | |
106 return dwStates; | 104 return dwStates; |
107 } | 105 } |
108 | 106 |
109 void CFWL_PushButton::UpdateTextOutStyles() { | 107 void CFWL_PushButton::UpdateTextOutStyles() { |
110 switch (m_pProperties->m_dwStyleExes & | 108 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; |
111 (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { | |
112 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: { | |
113 m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; | |
114 break; | |
115 } | |
116 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Top: { | |
117 m_iTTOAlign = FDE_TTOALIGNMENT_TopCenter; | |
118 break; | |
119 } | |
120 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Top: { | |
121 m_iTTOAlign = FDE_TTOALIGNMENT_TopRight; | |
122 break; | |
123 } | |
124 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_VCenter: { | |
125 m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; | |
126 break; | |
127 } | |
128 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: { | |
129 m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; | |
130 break; | |
131 } | |
132 case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Bottom: { | |
133 m_iTTOAlign = FDE_TTOALIGNMENT_BottomLeft; | |
134 break; | |
135 } | |
136 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_Bottom: { | |
137 m_iTTOAlign = FDE_TTOALIGNMENT_BottomCenter; | |
138 break; | |
139 } | |
140 case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_Bottom: { | |
141 m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; | |
142 break; | |
143 } | |
144 case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: | |
145 default: { | |
146 m_iTTOAlign = FDE_TTOALIGNMENT_Center; | |
147 break; | |
148 } | |
149 } | |
150 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; | 109 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; |
151 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) | 110 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) |
152 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 111 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
153 } | 112 } |
154 | 113 |
155 void CFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) { | 114 void CFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) { |
156 if (!pMessage) | 115 if (!pMessage) |
157 return; | 116 return; |
158 if (!IsEnabled()) | 117 if (!IsEnabled()) |
159 return; | 118 return; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (pMsg->m_dwKeyCode != FWL_VKEY_Return) | 241 if (pMsg->m_dwKeyCode != FWL_VKEY_Return) |
283 return; | 242 return; |
284 | 243 |
285 CFWL_EventMouse wmMouse(this); | 244 CFWL_EventMouse wmMouse(this); |
286 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; | 245 wmMouse.m_dwCmd = FWL_MouseCommand::LeftButtonUp; |
287 DispatchEvent(&wmMouse); | 246 DispatchEvent(&wmMouse); |
288 | 247 |
289 CFWL_Event wmClick(CFWL_Event::Type::Click, this); | 248 CFWL_Event wmClick(CFWL_Event::Type::Click, this); |
290 DispatchEvent(&wmClick); | 249 DispatchEvent(&wmClick); |
291 } | 250 } |
OLD | NEW |