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

Side by Side Diff: xfa/fwl/core/ifwl_form.cpp

Issue 2510793003: Continue formatting fwl/core (Closed)
Patch Set: format Created 4 years, 1 month 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
OLDNEW
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/core/ifwl_form.h" 7 #include "xfa/fwl/core/ifwl_form.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fde/tto/fde_textout.h" 10 #include "xfa/fde/tto/fde_textout.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return FWL_Type::Form; 81 return FWL_Type::Form;
82 } 82 }
83 83
84 bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { 84 bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const {
85 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) 85 if (wsClass == CFX_WideStringC(FWL_CLASS_Form))
86 return true; 86 return true;
87 return IFWL_Widget::IsInstance(wsClass); 87 return IFWL_Widget::IsInstance(wsClass);
88 } 88 }
89 89
90 void IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 90 void IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
91 if (bAutoSize) { 91 if (!bAutoSize) {
92 rect.Reset();
93 FX_FLOAT fCapHeight = GetCaptionHeight();
94 FX_FLOAT fCXBorder = GetBorderSize(true);
95 FX_FLOAT fCYBorder = GetBorderSize(false);
96 FX_FLOAT fEdge = GetEdgeWidth();
97 rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
98 rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
99 } else {
100 rect = m_pProperties->m_rtWidget; 92 rect = m_pProperties->m_rtWidget;
93 return;
101 } 94 }
95
96 rect.Reset();
97 FX_FLOAT fCapHeight = GetCaptionHeight();
98 FX_FLOAT fCXBorder = GetBorderSize(true);
99 FX_FLOAT fCYBorder = GetBorderSize(false);
100 FX_FLOAT fEdge = GetEdgeWidth();
101 rect.height += fCapHeight + fCYBorder + fEdge + fEdge;
102 rect.width += fCXBorder + fCXBorder + fEdge + fEdge;
102 } 103 }
104
103 void IFWL_Form::GetClientRect(CFX_RectF& rect) { 105 void IFWL_Form::GetClientRect(CFX_RectF& rect) {
104 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { 106 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) {
105 rect = m_pProperties->m_rtWidget; 107 rect = m_pProperties->m_rtWidget;
106 rect.Offset(-rect.left, -rect.top); 108 rect.Offset(-rect.left, -rect.top);
107 return; 109 return;
108 } 110 }
111
109 #ifdef FWL_UseMacSystemBorder 112 #ifdef FWL_UseMacSystemBorder
110 rect = m_rtRelative; 113 rect = m_rtRelative;
111 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 114 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
112 if (!pWidgetMgr) 115 if (!pWidgetMgr)
113 return; 116 return;
114 117
115 rect.left = 0; 118 rect.left = 0;
116 rect.top = 0; 119 rect.top = 0;
117 #else 120 #else
118 FX_FLOAT x = 0; 121 FX_FLOAT x = 0;
119 FX_FLOAT y = 0; 122 FX_FLOAT y = 0;
120 FX_FLOAT t = 0; 123 FX_FLOAT t = 0;
121 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 124 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
122 if (pTheme) { 125 if (pTheme) {
123 CFWL_ThemePart part; 126 CFWL_ThemePart part;
124 part.m_pWidget = this; 127 part.m_pWidget = this;
125 x = *static_cast<FX_FLOAT*>( 128 x = *static_cast<FX_FLOAT*>(
126 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder)); 129 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CXBorder));
127 y = *static_cast<FX_FLOAT*>( 130 y = *static_cast<FX_FLOAT*>(
128 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder)); 131 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYBorder));
129 t = *static_cast<FX_FLOAT*>( 132 t = *static_cast<FX_FLOAT*>(
130 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYCaption)); 133 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::CYCaption));
131 } 134 }
132 rect = m_pProperties->m_rtWidget; 135 rect = m_pProperties->m_rtWidget;
133 rect.Offset(-rect.left, -rect.top); 136 rect.Offset(-rect.left, -rect.top);
134 rect.Deflate(x, t, x, y); 137 rect.Deflate(x, t, x, y);
135 #endif 138 #endif
136 } 139 }
140
137 void IFWL_Form::Update() { 141 void IFWL_Form::Update() {
138 if (m_iLock > 0) { 142 if (m_iLock > 0)
139 return; 143 return;
140 } 144 if (!m_pProperties->m_pThemeProvider)
141 if (!m_pProperties->m_pThemeProvider) {
142 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 145 m_pProperties->m_pThemeProvider = GetAvailableTheme();
143 } 146
144 #ifdef FWL_UseMacSystemBorder 147 #ifndef FWL_UseMacSystemBorder
145 #else
146 SetThemeData(); 148 SetThemeData();
147 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { 149 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon)
148 UpdateIcon(); 150 UpdateIcon();
149 }
150 #endif 151 #endif
152
151 UpdateCaption(); 153 UpdateCaption();
152 Layout(); 154 Layout();
153 } 155 }
156
154 FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 157 FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
155 GetAvailableTheme(); 158 GetAvailableTheme();
159
156 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) 160 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
157 return FWL_WidgetHit::CloseBox; 161 return FWL_WidgetHit::CloseBox;
158 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) 162 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
159 return FWL_WidgetHit::MaxBox; 163 return FWL_WidgetHit::MaxBox;
160 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) 164 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
161 return FWL_WidgetHit::MinBox; 165 return FWL_WidgetHit::MinBox;
166
162 CFX_RectF rtCap; 167 CFX_RectF rtCap;
163 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, 168 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
164 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, 169 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder,
165 m_rtCaption.height - m_fCXBorder); 170 m_rtCaption.height - m_fCXBorder);
166 if (rtCap.Contains(fx, fy)) 171 if (rtCap.Contains(fx, fy))
167 return FWL_WidgetHit::Titlebar; 172 return FWL_WidgetHit::Titlebar;
168 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) && 173 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) &&
169 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) { 174 (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) {
170 FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge); 175 FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge);
171 FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge); 176 FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge);
177
172 CFX_RectF rt; 178 CFX_RectF rt;
173 rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); 179 rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight);
174 if (rt.Contains(fx, fy)) 180 if (rt.Contains(fx, fy))
175 return FWL_WidgetHit::Left; 181 return FWL_WidgetHit::Left;
182
176 rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge, 183 rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge,
177 m_fCYBorder, fHeight); 184 m_fCYBorder, fHeight);
178 if (rt.Contains(fx, fy)) 185 if (rt.Contains(fx, fy))
179 return FWL_WidgetHit::Right; 186 return FWL_WidgetHit::Right;
187
180 rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder); 188 rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder);
181 if (rt.Contains(fx, fy)) 189 if (rt.Contains(fx, fy))
182 return FWL_WidgetHit::Top; 190 return FWL_WidgetHit::Top;
191
183 rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder, 192 rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder,
184 fWidth, m_fCXBorder); 193 fWidth, m_fCXBorder);
185 if (rt.Contains(fx, fy)) 194 if (rt.Contains(fx, fy))
186 return FWL_WidgetHit::Bottom; 195 return FWL_WidgetHit::Bottom;
196
187 rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); 197 rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
188 if (rt.Contains(fx, fy)) 198 if (rt.Contains(fx, fy))
189 return FWL_WidgetHit::LeftTop; 199 return FWL_WidgetHit::LeftTop;
200
190 rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, 201 rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
191 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); 202 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
192 if (rt.Contains(fx, fy)) 203 if (rt.Contains(fx, fy))
193 return FWL_WidgetHit::LeftBottom; 204 return FWL_WidgetHit::LeftBottom;
205
194 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0, 206 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0,
195 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); 207 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
196 if (rt.Contains(fx, fy)) 208 if (rt.Contains(fx, fy))
197 return FWL_WidgetHit::RightTop; 209 return FWL_WidgetHit::RightTop;
210
198 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 211 rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge,
199 m_rtRelative.height - m_fCXBorder - kCornerEnlarge, 212 m_rtRelative.height - m_fCXBorder - kCornerEnlarge,
200 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); 213 m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge);
201 if (rt.Contains(fx, fy)) 214 if (rt.Contains(fx, fy))
202 return FWL_WidgetHit::RightBottom; 215 return FWL_WidgetHit::RightBottom;
203 } 216 }
204 return FWL_WidgetHit::Client; 217 return FWL_WidgetHit::Client;
205 } 218 }
219
206 void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { 220 void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) {
207 if (!pGraphics) 221 if (!pGraphics)
208 return; 222 return;
209 if (!m_pProperties->m_pThemeProvider) 223 if (!m_pProperties->m_pThemeProvider)
210 return; 224 return;
225
211 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 226 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
212 bool bInactive = !IsActive(); 227 bool bInactive = !IsActive();
213 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; 228 int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal;
214 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { 229 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0)
215 DrawBackground(pGraphics, pTheme); 230 DrawBackground(pGraphics, pTheme);
216 } 231
217 #ifdef FWL_UseMacSystemBorder 232 #ifdef FWL_UseMacSystemBorder
218 return; 233 return;
219 #endif 234 #endif
220 CFWL_ThemeBackground param; 235 CFWL_ThemeBackground param;
221 param.m_pWidget = this; 236 param.m_pWidget = this;
222 param.m_dwStates = iState; 237 param.m_dwStates = iState;
223 param.m_pGraphics = pGraphics; 238 param.m_pGraphics = pGraphics;
224 param.m_rtPart = m_rtRelative; 239 param.m_rtPart = m_rtRelative;
225 if (pMatrix) { 240 if (pMatrix)
226 param.m_matrix.Concat(*pMatrix); 241 param.m_matrix.Concat(*pMatrix);
227 }
228 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { 242 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
229 param.m_iPart = CFWL_Part::Border; 243 param.m_iPart = CFWL_Part::Border;
230 pTheme->DrawBackground(&param); 244 pTheme->DrawBackground(&param);
231 } 245 }
232 if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) != 246 if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) !=
233 FWL_WGTSTYLE_EdgeNone) { 247 FWL_WGTSTYLE_EdgeNone) {
234 CFX_RectF rtEdge; 248 CFX_RectF rtEdge;
235 GetEdgeRect(rtEdge); 249 GetEdgeRect(rtEdge);
236 param.m_iPart = CFWL_Part::Edge; 250 param.m_iPart = CFWL_Part::Edge;
237 param.m_rtPart = rtEdge; 251 param.m_rtPart = rtEdge;
238 param.m_dwStates = iState; 252 param.m_dwStates = iState;
239 pTheme->DrawBackground(&param); 253 pTheme->DrawBackground(&param);
240 } 254 }
241 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { 255 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) {
242 param.m_iPart = CFWL_Part::Caption; 256 param.m_iPart = CFWL_Part::Caption;
243 param.m_dwStates = iState; 257 param.m_dwStates = iState;
244 param.m_rtPart = m_rtCaption; 258 param.m_rtPart = m_rtCaption;
245 pTheme->DrawBackground(&param); 259 pTheme->DrawBackground(&param);
246 DrawCaptionText(pGraphics, pTheme, pMatrix); 260 DrawCaptionText(pGraphics, pTheme, pMatrix);
247 } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { 261 } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) {
248 param.m_iPart = CFWL_Part::NarrowCaption; 262 param.m_iPart = CFWL_Part::NarrowCaption;
249 param.m_dwStates = iState; 263 param.m_dwStates = iState;
250 param.m_rtPart = m_rtCaption; 264 param.m_rtPart = m_rtCaption;
251 pTheme->DrawBackground(&param); 265 pTheme->DrawBackground(&param);
252 DrawCaptionText(pGraphics, pTheme, pMatrix); 266 DrawCaptionText(pGraphics, pTheme, pMatrix);
253 } 267 }
254 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { 268 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) {
255 param.m_iPart = CFWL_Part::Icon; 269 param.m_iPart = CFWL_Part::Icon;
256 if (HasIcon()) { 270 if (HasIcon())
257 DrawIconImage(pGraphics, pTheme, pMatrix); 271 DrawIconImage(pGraphics, pTheme, pMatrix);
258 }
259 } 272 }
273
260 #if (_FX_OS_ == _FX_MACOSX_) 274 #if (_FX_OS_ == _FX_MACOSX_)
261 { 275 {
262 if (m_pCloseBox) { 276 if (m_pCloseBox) {
263 param.m_iPart = CFWL_Part::CloseBox; 277 param.m_iPart = CFWL_Part::CloseBox;
264 param.m_dwStates = m_pCloseBox->GetPartState(); 278 param.m_dwStates = m_pCloseBox->GetPartState();
265 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { 279 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
266 param.m_dwStates = CFWL_PartState_Disabled; 280 param.m_dwStates = CFWL_PartState_Disabled;
267 } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { 281 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
268 param.m_dwStates = CFWL_PartState_Hovered; 282 param.m_dwStates = CFWL_PartState_Hovered;
269 }
270 param.m_rtPart = m_pCloseBox->m_rtBtn; 283 param.m_rtPart = m_pCloseBox->m_rtBtn;
271 pTheme->DrawBackground(&param); 284 pTheme->DrawBackground(&param);
272 } 285 }
273 if (m_pMaxBox) { 286 if (m_pMaxBox) {
274 param.m_iPart = CFWL_Part::MaximizeBox; 287 param.m_iPart = CFWL_Part::MaximizeBox;
275 param.m_dwStates = m_pMaxBox->GetPartState(); 288 param.m_dwStates = m_pMaxBox->GetPartState();
276 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { 289 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
277 param.m_dwStates = CFWL_PartState_Disabled; 290 param.m_dwStates = CFWL_PartState_Disabled;
278 } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { 291 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
279 param.m_dwStates = CFWL_PartState_Hovered; 292 param.m_dwStates = CFWL_PartState_Hovered;
280 }
281 param.m_rtPart = m_pMaxBox->m_rtBtn; 293 param.m_rtPart = m_pMaxBox->m_rtBtn;
282 param.m_bMaximize = m_bMaximized; 294 param.m_bMaximize = m_bMaximized;
283 pTheme->DrawBackground(&param); 295 pTheme->DrawBackground(&param);
284 } 296 }
285 if (m_pMinBox) { 297 if (m_pMinBox) {
286 param.m_iPart = CFWL_Part::MinimizeBox; 298 param.m_iPart = CFWL_Part::MinimizeBox;
287 param.m_dwStates = m_pMinBox->GetPartState(); 299 param.m_dwStates = m_pMinBox->GetPartState();
288 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { 300 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
289 param.m_dwStates = CFWL_PartState_Disabled; 301 param.m_dwStates = CFWL_PartState_Disabled;
290 } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { 302 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
291 param.m_dwStates = CFWL_PartState_Hovered; 303 param.m_dwStates = CFWL_PartState_Hovered;
292 }
293 param.m_rtPart = m_pMinBox->m_rtBtn; 304 param.m_rtPart = m_pMinBox->m_rtBtn;
294 pTheme->DrawBackground(&param); 305 pTheme->DrawBackground(&param);
295 } 306 }
296 m_bMouseIn = false; 307 m_bMouseIn = false;
297 } 308 }
298 #else 309 #else
299 { 310 {
300 if (m_pCloseBox) { 311 if (m_pCloseBox) {
301 param.m_iPart = CFWL_Part::CloseBox; 312 param.m_iPart = CFWL_Part::CloseBox;
302 param.m_dwStates = m_pCloseBox->GetPartState(); 313 param.m_dwStates = m_pCloseBox->GetPartState();
(...skipping 26 matching lines...) Expand all
329 if (!pDriver) 340 if (!pDriver)
330 return nullptr; 341 return nullptr;
331 342
332 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>(); 343 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>();
333 m_pNoteLoop->SetMainForm(this); 344 m_pNoteLoop->SetMainForm(this);
334 345
335 pDriver->PushNoteLoop(m_pNoteLoop.get()); 346 pDriver->PushNoteLoop(m_pNoteLoop.get());
336 m_bDoModalFlag = true; 347 m_bDoModalFlag = true;
337 SetStates(FWL_WGTSTATE_Invisible, false); 348 SetStates(FWL_WGTSTATE_Invisible, false);
338 pDriver->Run(); 349 pDriver->Run();
339 #if (_FX_OS_ == _FX_MACOSX_) 350
340 #else 351 #if _FX_OS_ != _FX_MACOSX_
341 pDriver->PopNoteLoop(); 352 pDriver->PopNoteLoop();
342 #endif 353 #endif
354
343 m_pNoteLoop.reset(); 355 m_pNoteLoop.reset();
344 return nullptr; 356 return nullptr;
345 } 357 }
346 358
347 void IFWL_Form::EndDoModal() { 359 void IFWL_Form::EndDoModal() {
348 if (!m_pNoteLoop) 360 if (!m_pNoteLoop)
349 return; 361 return;
362
350 m_bDoModalFlag = false; 363 m_bDoModalFlag = false;
364
351 #if (_FX_OS_ == _FX_MACOSX_) 365 #if (_FX_OS_ == _FX_MACOSX_)
352 m_pNoteLoop->EndModalLoop(); 366 m_pNoteLoop->EndModalLoop();
353 const IFWL_App* pApp = GetOwnerApp(); 367 const IFWL_App* pApp = GetOwnerApp();
354 if (!pApp) 368 if (!pApp)
355 return; 369 return;
356 370
357 CFWL_NoteDriver* pDriver = 371 CFWL_NoteDriver* pDriver =
358 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 372 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
359 if (!pDriver) 373 if (!pDriver)
360 return; 374 return;
(...skipping 24 matching lines...) Expand all
385 m_pCloseBox = nullptr; 399 m_pCloseBox = nullptr;
386 delete m_pMinBox; 400 delete m_pMinBox;
387 m_pMinBox = nullptr; 401 m_pMinBox = nullptr;
388 delete m_pMaxBox; 402 delete m_pMaxBox;
389 m_pMaxBox = nullptr; 403 m_pMaxBox = nullptr;
390 delete m_pCaptionBox; 404 delete m_pCaptionBox;
391 m_pCaptionBox = nullptr; 405 m_pCaptionBox = nullptr;
392 } 406 }
393 407
394 CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { 408 CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
395 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { 409 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
396 return m_pCloseBox; 410 return m_pCloseBox;
397 } 411 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
398 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) {
399 return m_pMaxBox; 412 return m_pMaxBox;
400 } 413 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
401 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) {
402 return m_pMinBox; 414 return m_pMinBox;
403 } 415 if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy))
404 if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) {
405 return m_pCaptionBox; 416 return m_pCaptionBox;
406 }
407 return nullptr; 417 return nullptr;
408 } 418 }
419
409 CFWL_SysBtn* IFWL_Form::GetSysBtnByState(uint32_t dwState) { 420 CFWL_SysBtn* IFWL_Form::GetSysBtnByState(uint32_t dwState) {
410 if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) { 421 if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState))
411 return m_pCloseBox; 422 return m_pCloseBox;
412 } 423 if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState))
413 if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) {
414 return m_pMaxBox; 424 return m_pMaxBox;
415 } 425 if (m_pMinBox && (m_pMinBox->m_dwState & dwState))
416 if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) {
417 return m_pMinBox; 426 return m_pMinBox;
418 } 427 if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState))
419 if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) {
420 return m_pCaptionBox; 428 return m_pCaptionBox;
421 }
422 return nullptr; 429 return nullptr;
423 } 430 }
431
424 CFWL_SysBtn* IFWL_Form::GetSysBtnByIndex(int32_t nIndex) { 432 CFWL_SysBtn* IFWL_Form::GetSysBtnByIndex(int32_t nIndex) {
425 if (nIndex < 0) 433 if (nIndex < 0)
426 return nullptr; 434 return nullptr;
427 435
428 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; 436 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
429 if (m_pMinBox) 437 if (m_pMinBox)
430 arrBtn.Add(m_pMinBox); 438 arrBtn.Add(m_pMinBox);
431
432 if (m_pMaxBox) 439 if (m_pMaxBox)
433 arrBtn.Add(m_pMaxBox); 440 arrBtn.Add(m_pMaxBox);
434
435 if (m_pCloseBox) 441 if (m_pCloseBox)
436 arrBtn.Add(m_pCloseBox); 442 arrBtn.Add(m_pCloseBox);
437
438 return arrBtn[nIndex]; 443 return arrBtn[nIndex];
439 } 444 }
445
440 int32_t IFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { 446 int32_t IFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) {
441 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; 447 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
442 if (m_pMinBox) 448 if (m_pMinBox)
443 arrBtn.Add(m_pMinBox); 449 arrBtn.Add(m_pMinBox);
444
445 if (m_pMaxBox) 450 if (m_pMaxBox)
446 arrBtn.Add(m_pMaxBox); 451 arrBtn.Add(m_pMaxBox);
447
448 if (m_pCloseBox) 452 if (m_pCloseBox)
449 arrBtn.Add(m_pCloseBox); 453 arrBtn.Add(m_pCloseBox);
450
451 return arrBtn.Find(pBtn); 454 return arrBtn.Find(pBtn);
452 } 455 }
456
453 FX_FLOAT IFWL_Form::GetCaptionHeight() { 457 FX_FLOAT IFWL_Form::GetCaptionHeight() {
454 CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None; 458 CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None;
455 459
456 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { 460 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption)
457 dwCapacity = CFWL_WidgetCapacity::CYCaption; 461 dwCapacity = CFWL_WidgetCapacity::CYCaption;
458 } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { 462 else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption)
459 dwCapacity = CFWL_WidgetCapacity::CYNarrowCaption; 463 dwCapacity = CFWL_WidgetCapacity::CYNarrowCaption;
460 } 464
461 if (dwCapacity != CFWL_WidgetCapacity::None) { 465 if (dwCapacity != CFWL_WidgetCapacity::None) {
462 FX_FLOAT* pfCapHeight = 466 FX_FLOAT* pfCapHeight =
463 static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); 467 static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity));
464 return pfCapHeight ? *pfCapHeight : 0; 468 return pfCapHeight ? *pfCapHeight : 0;
465 } 469 }
466 return 0; 470 return 0;
467 } 471 }
472
468 void IFWL_Form::DrawCaptionText(CFX_Graphics* pGs, 473 void IFWL_Form::DrawCaptionText(CFX_Graphics* pGs,
469 IFWL_ThemeProvider* pTheme, 474 IFWL_ThemeProvider* pTheme,
470 const CFX_Matrix* pMatrix) { 475 const CFX_Matrix* pMatrix) {
471 CFX_WideString wsText; 476 CFX_WideString wsText;
472 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; 477 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider;
473 pData->GetCaption(this, wsText); 478 pData->GetCaption(this, wsText);
474 if (wsText.IsEmpty()) { 479 if (wsText.IsEmpty())
475 return; 480 return;
476 } 481
477 CFWL_ThemeText textParam; 482 CFWL_ThemeText textParam;
478 textParam.m_pWidget = this; 483 textParam.m_pWidget = this;
479 textParam.m_iPart = CFWL_Part::Caption; 484 textParam.m_iPart = CFWL_Part::Caption;
480 textParam.m_dwStates = CFWL_PartState_Normal; 485 textParam.m_dwStates = CFWL_PartState_Normal;
481 textParam.m_pGraphics = pGs; 486 textParam.m_pGraphics = pGs;
482 if (pMatrix) { 487 if (pMatrix)
483 textParam.m_matrix.Concat(*pMatrix); 488 textParam.m_matrix.Concat(*pMatrix);
484 } 489
485 CFX_RectF rtText; 490 CFX_RectF rtText;
486 if (m_bCustomizeLayout) { 491 if (m_bCustomizeLayout) {
487 rtText = m_rtCaptionText; 492 rtText = m_rtCaptionText;
488 rtText.top -= 5; 493 rtText.top -= 5;
489 } else { 494 } else {
490 rtText = m_rtCaption; 495 rtText = m_rtCaption;
491 FX_FLOAT fpos; 496 FX_FLOAT fpos;
492 fpos = HasIcon() ? 29.0f : 13.0f; 497 fpos = HasIcon() ? 29.0f : 13.0f;
493 rtText.left += fpos; 498 rtText.left += fpos;
494 } 499 }
495 textParam.m_rtPart = rtText; 500 textParam.m_rtPart = rtText;
496 textParam.m_wsText = wsText; 501 textParam.m_wsText = wsText;
497 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis; 502 textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine | FDE_TTOSTYLE_Ellipsis;
498 textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center 503 textParam.m_iTTOAlign = m_bCustomizeLayout ? FDE_TTOALIGNMENT_Center
499 : FDE_TTOALIGNMENT_CenterLeft; 504 : FDE_TTOALIGNMENT_CenterLeft;
500 pTheme->DrawText(&textParam); 505 pTheme->DrawText(&textParam);
501 } 506 }
507
502 void IFWL_Form::DrawIconImage(CFX_Graphics* pGs, 508 void IFWL_Form::DrawIconImage(CFX_Graphics* pGs,
503 IFWL_ThemeProvider* pTheme, 509 IFWL_ThemeProvider* pTheme,
504 const CFX_Matrix* pMatrix) { 510 const CFX_Matrix* pMatrix) {
505 IFWL_FormDP* pData = 511 IFWL_FormDP* pData =
506 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); 512 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
507 CFWL_ThemeBackground param; 513 CFWL_ThemeBackground param;
508 param.m_pWidget = this; 514 param.m_pWidget = this;
509 param.m_iPart = CFWL_Part::Icon; 515 param.m_iPart = CFWL_Part::Icon;
510 param.m_pGraphics = pGs; 516 param.m_pGraphics = pGs;
511 param.m_pImage = pData->GetIcon(this, false); 517 param.m_pImage = pData->GetIcon(this, false);
512 param.m_rtPart = m_rtIcon; 518 param.m_rtPart = m_rtIcon;
513 if (pMatrix) { 519 if (pMatrix)
514 param.m_matrix.Concat(*pMatrix); 520 param.m_matrix.Concat(*pMatrix);
515 }
516 pTheme->DrawBackground(&param); 521 pTheme->DrawBackground(&param);
517 } 522 }
523
518 void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { 524 void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) {
519 rtEdge = m_rtRelative; 525 rtEdge = m_rtRelative;
520 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { 526 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
521 FX_FLOAT fCX = GetBorderSize(); 527 FX_FLOAT fCX = GetBorderSize();
522 FX_FLOAT fCY = GetBorderSize(false); 528 FX_FLOAT fCY = GetBorderSize(false);
523 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); 529 rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY);
524 } 530 }
525 } 531 }
532
526 void IFWL_Form::SetWorkAreaRect() { 533 void IFWL_Form::SetWorkAreaRect() {
527 m_rtRestore = m_pProperties->m_rtWidget; 534 m_rtRestore = m_pProperties->m_rtWidget;
528 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 535 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
529 if (!pWidgetMgr) 536 if (!pWidgetMgr)
530 return; 537 return;
538
531 m_bSetMaximize = true; 539 m_bSetMaximize = true;
532 Repaint(&m_rtRelative); 540 Repaint(&m_rtRelative);
533 } 541 }
534 542
535 void IFWL_Form::Layout() { 543 void IFWL_Form::Layout() {
536 GetRelativeRect(m_rtRelative); 544 GetRelativeRect(m_rtRelative);
545
537 #ifndef FWL_UseMacSystemBorder 546 #ifndef FWL_UseMacSystemBorder
538 ResetSysBtn(); 547 ResetSysBtn();
539 #endif 548 #endif
540 } 549 }
550
541 void IFWL_Form::ResetSysBtn() { 551 void IFWL_Form::ResetSysBtn() {
542 m_fCXBorder = 552 m_fCXBorder =
543 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); 553 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder));
544 m_fCYBorder = 554 m_fCYBorder =
545 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); 555 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder));
546 RemoveSysButtons(); 556 RemoveSysButtons();
557
547 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 558 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
548 m_bCustomizeLayout = pTheme->IsCustomizedLayout(this); 559 m_bCustomizeLayout = pTheme->IsCustomizedLayout(this);
549 FX_FLOAT fCapHeight = GetCaptionHeight(); 560 FX_FLOAT fCapHeight = GetCaptionHeight();
550 if (fCapHeight > 0) { 561 if (fCapHeight > 0) {
551 m_rtCaption = m_rtRelative; 562 m_rtCaption = m_rtRelative;
552 m_rtCaption.height = fCapHeight; 563 m_rtCaption.height = fCapHeight;
553 } 564 }
565
554 m_iSysBox = 0; 566 m_iSysBox = 0;
555 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { 567 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) {
556 m_pCloseBox = new CFWL_SysBtn; 568 m_pCloseBox = new CFWL_SysBtn;
557 if (!m_bCustomizeLayout) { 569 if (!m_bCustomizeLayout) {
558 m_pCloseBox->m_rtBtn.Set( 570 m_pCloseBox->m_rtBtn.Set(
559 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, 571 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
560 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); 572 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
561 } 573 }
562 m_iSysBox++; 574 m_iSysBox++;
563 } 575 }
(...skipping 24 matching lines...) Expand all
588 m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize, 600 m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
589 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize); 601 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
590 } else { 602 } else {
591 m_pMinBox->m_rtBtn.Set( 603 m_pMinBox->m_rtBtn.Set(
592 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize, 604 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
593 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize); 605 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
594 } 606 }
595 } 607 }
596 m_iSysBox++; 608 m_iSysBox++;
597 } 609 }
610
598 IFWL_FormDP* pData = 611 IFWL_FormDP* pData =
599 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); 612 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
600 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && 613 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon &&
601 pData->GetIcon(this, false)) { 614 pData->GetIcon(this, false)) {
602 if (!m_bCustomizeLayout) { 615 if (!m_bCustomizeLayout) {
603 m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz, 616 m_rtIcon.Set(5, (m_rtCaption.height - m_fSmallIconSz) / 2, m_fSmallIconSz,
604 m_fSmallIconSz); 617 m_fSmallIconSz);
605 } 618 }
606 } 619 }
607 } 620 }
621
608 void IFWL_Form::RegisterForm() { 622 void IFWL_Form::RegisterForm() {
609 const IFWL_App* pApp = GetOwnerApp(); 623 const IFWL_App* pApp = GetOwnerApp();
610 if (!pApp) 624 if (!pApp)
611 return; 625 return;
612 626
613 CFWL_NoteDriver* pDriver = 627 CFWL_NoteDriver* pDriver =
614 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 628 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
615 if (!pDriver) 629 if (!pDriver)
616 return; 630 return;
617 631
618 pDriver->RegisterForm(this); 632 pDriver->RegisterForm(this);
619 } 633 }
634
620 void IFWL_Form::UnRegisterForm() { 635 void IFWL_Form::UnRegisterForm() {
621 const IFWL_App* pApp = GetOwnerApp(); 636 const IFWL_App* pApp = GetOwnerApp();
622 if (!pApp) 637 if (!pApp)
623 return; 638 return;
624 639
625 CFWL_NoteDriver* pDriver = 640 CFWL_NoteDriver* pDriver =
626 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 641 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
627 if (!pDriver) 642 if (!pDriver)
628 return; 643 return;
629 644
630 pDriver->UnRegisterForm(this); 645 pDriver->UnRegisterForm(this);
631 } 646 }
632 647
633 void IFWL_Form::SetThemeData() { 648 void IFWL_Form::SetThemeData() {
634 m_fSmallIconSz = 649 m_fSmallIconSz =
635 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon)); 650 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::SmallIcon));
636 m_fBigIconSz = 651 m_fBigIconSz =
637 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); 652 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon));
638 } 653 }
654
639 bool IFWL_Form::HasIcon() { 655 bool IFWL_Form::HasIcon() {
640 IFWL_FormDP* pData = 656 IFWL_FormDP* pData =
641 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); 657 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
642 return !!pData->GetIcon(this, false); 658 return !!pData->GetIcon(this, false);
643 } 659 }
660
644 void IFWL_Form::UpdateIcon() { 661 void IFWL_Form::UpdateIcon() {
645 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 662 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
646 if (!pWidgetMgr) 663 if (!pWidgetMgr)
647 return; 664 return;
665
648 IFWL_FormDP* pData = 666 IFWL_FormDP* pData =
649 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); 667 static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider);
650 CFX_DIBitmap* pBigIcon = pData->GetIcon(this, true); 668 CFX_DIBitmap* pBigIcon = pData->GetIcon(this, true);
651 CFX_DIBitmap* pSmallIcon = pData->GetIcon(this, false); 669 CFX_DIBitmap* pSmallIcon = pData->GetIcon(this, false);
652 if (pBigIcon) 670 if (pBigIcon)
653 m_pBigIcon = pBigIcon; 671 m_pBigIcon = pBigIcon;
654 if (pSmallIcon) 672 if (pSmallIcon)
655 m_pSmallIcon = pSmallIcon; 673 m_pSmallIcon = pSmallIcon;
656 } 674 }
675
657 void IFWL_Form::UpdateCaption() { 676 void IFWL_Form::UpdateCaption() {
658 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 677 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
659 if (!pWidgetMgr) 678 if (!pWidgetMgr)
660 return; 679 return;
680
661 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; 681 IFWL_DataProvider* pData = m_pProperties->m_pDataProvider;
662 if (!pData) 682 if (!pData)
663 return; 683 return;
684
664 CFX_WideString text; 685 CFX_WideString text;
665 pData->GetCaption(this, text); 686 pData->GetCaption(this, text);
666 } 687 }
667 688
668 #ifdef FWL_UseMacSystemBorder
669 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) {}
670 #else
671 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { 689 void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) {
690 #ifndef FWL_UseMacSystemBorder
672 if (!pMessage) 691 if (!pMessage)
673 return; 692 return;
674 693
675 switch (pMessage->GetClassID()) { 694 switch (pMessage->GetClassID()) {
676 case CFWL_MessageType::Mouse: { 695 case CFWL_MessageType::Mouse: {
677 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 696 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
678 switch (pMsg->m_dwCmd) { 697 switch (pMsg->m_dwCmd) {
679 case FWL_MouseCommand::LeftButtonDown: 698 case FWL_MouseCommand::LeftButtonDown:
680 OnLButtonDown(pMsg); 699 OnLButtonDown(pMsg);
681 break; 700 break;
(...skipping 10 matching lines...) Expand all
692 OnLButtonDblClk(pMsg); 711 OnLButtonDblClk(pMsg);
693 break; 712 break;
694 default: 713 default:
695 break; 714 break;
696 } 715 }
697 break; 716 break;
698 } 717 }
699 default: 718 default:
700 break; 719 break;
701 } 720 }
721 #endif // FWL_UseMacSystemBorder
702 } 722 }
703 #endif // FWL_UseMacSystemBorder
704 723
705 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, 724 void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics,
706 const CFX_Matrix* pMatrix) { 725 const CFX_Matrix* pMatrix) {
707 DrawWidget(pGraphics, pMatrix); 726 DrawWidget(pGraphics, pMatrix);
708 } 727 }
709 728
710 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { 729 void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) {
711 SetGrab(true); 730 SetGrab(true);
712 m_bLButtonDown = true; 731 m_bLButtonDown = true;
713 m_eResizeType = FORM_RESIZETYPE_None; 732 m_eResizeType = FORM_RESIZETYPE_None;
733
714 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); 734 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
715 m_iCaptureBtn = GetSysBtnIndex(pPressBtn); 735 m_iCaptureBtn = GetSysBtnIndex(pPressBtn);
736
716 CFX_RectF rtCap; 737 CFX_RectF rtCap;
717 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, 738 rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder,
718 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, 739 m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder,
719 m_rtCaption.height - m_fCXBorder); 740 m_rtCaption.height - m_fCXBorder);
720 741
721 if (pPressBtn) { 742 if (pPressBtn) {
722 pPressBtn->SetPressed(); 743 pPressBtn->SetPressed();
723 Repaint(&pPressBtn->m_rtBtn); 744 Repaint(&pPressBtn->m_rtBtn);
724 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { 745 } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) {
725 m_eResizeType = FORM_RESIZETYPE_Cap; 746 m_eResizeType = FORM_RESIZETYPE_Cap;
726 } 747 }
748
727 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); 749 m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy);
728 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, 750 m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width,
729 m_pProperties->m_rtWidget.height); 751 m_pProperties->m_rtWidget.height);
730 } 752 }
731 753
732 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) { 754 void IFWL_Form::OnLButtonUp(CFWL_MsgMouse* pMsg) {
733 SetGrab(false); 755 SetGrab(false);
734 m_bLButtonDown = false; 756 m_bLButtonDown = false;
735 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); 757 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
736 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn); 758 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn);
(...skipping 19 matching lines...) Expand all
756 } 778 }
757 779
758 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { 780 void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) {
759 if (m_bLButtonDown) 781 if (m_bLButtonDown)
760 return; 782 return;
761 783
762 CFX_RectF rtInvalidate; 784 CFX_RectF rtInvalidate;
763 rtInvalidate.Reset(); 785 rtInvalidate.Reset();
764 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); 786 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
765 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); 787 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
766 #if (_FX_OS_ == _FX_MACOSX_) 788
789 #if _FX_OS_ == _FX_MACOSX_
767 { 790 {
768 if (pOldHover && pPointBtn != pOldHover) 791 if (pOldHover && pPointBtn != pOldHover)
769 pOldHover->SetNormal(); 792 pOldHover->SetNormal();
770 if (pPointBtn && pPointBtn != pOldHover) 793 if (pPointBtn && pPointBtn != pOldHover)
771 pPointBtn->SetHover(); 794 pPointBtn->SetHover();
772 if (m_pCloseBox) 795 if (m_pCloseBox)
773 rtInvalidate = m_pCloseBox->m_rtBtn; 796 rtInvalidate = m_pCloseBox->m_rtBtn;
774 if (m_pMaxBox) { 797 if (m_pMaxBox) {
775 if (rtInvalidate.IsEmpty()) 798 if (rtInvalidate.IsEmpty())
776 rtInvalidate = m_pMaxBox->m_rtBtn; 799 rtInvalidate = m_pMaxBox->m_rtBtn;
(...skipping 19 matching lines...) Expand all
796 } 819 }
797 if (pPointBtn && pPointBtn != pOldHover) { 820 if (pPointBtn && pPointBtn != pOldHover) {
798 pPointBtn->SetHover(); 821 pPointBtn->SetHover();
799 if (rtInvalidate.IsEmpty()) 822 if (rtInvalidate.IsEmpty())
800 rtInvalidate = pPointBtn->m_rtBtn; 823 rtInvalidate = pPointBtn->m_rtBtn;
801 else 824 else
802 rtInvalidate.Union(pPointBtn->m_rtBtn); 825 rtInvalidate.Union(pPointBtn->m_rtBtn);
803 } 826 }
804 } 827 }
805 #endif 828 #endif
829
806 if (!rtInvalidate.IsEmpty()) 830 if (!rtInvalidate.IsEmpty())
807 Repaint(&rtInvalidate); 831 Repaint(&rtInvalidate);
808 } 832 }
809 833
810 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { 834 void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) {
811 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); 835 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
812 if (pHover) { 836 if (!pHover)
813 pHover->SetNormal(); 837 return;
814 Repaint(&pHover->m_rtBtn); 838
815 } 839 pHover->SetNormal();
840 Repaint(&pHover->m_rtBtn);
816 } 841 }
817 842
818 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { 843 void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) {
819 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) && 844 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize) &&
820 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) { 845 HitTest(pMsg->m_fx, pMsg->m_fy) == FWL_WidgetHit::Titlebar) {
821 if (m_bMaximized) 846 if (m_bMaximized)
822 SetWidgetRect(m_rtRestore); 847 SetWidgetRect(m_rtRestore);
823 else 848 else
824 SetWorkAreaRect(); 849 SetWorkAreaRect();
825 850
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 883
859 uint32_t CFWL_SysBtn::GetPartState() const { 884 uint32_t CFWL_SysBtn::GetPartState() const {
860 if (IsDisabled()) 885 if (IsDisabled())
861 return CFWL_PartState_Disabled; 886 return CFWL_PartState_Disabled;
862 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed) 887 if (m_dwState & FWL_SYSBUTTONSTATE_Pressed)
863 return CFWL_PartState_Pressed; 888 return CFWL_PartState_Pressed;
864 if (m_dwState & FWL_SYSBUTTONSTATE_Hover) 889 if (m_dwState & FWL_SYSBUTTONSTATE_Hover)
865 return CFWL_PartState_Hovered; 890 return CFWL_PartState_Hovered;
866 return CFWL_PartState_Normal; 891 return CFWL_PartState_Normal;
867 } 892 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698