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

Side by Side Diff: xfa/fwl/cfwl_form.cpp

Issue 2578603002: Remove unused sysbtn code (Closed)
Patch Set: Rebase to master Created 4 years 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
« no previous file with comments | « xfa/fwl/cfwl_form.h ('k') | xfa/fwl/cfwl_sysbtn.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cfwl_form.h" 7 #include "xfa/fwl/cfwl_form.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "third_party/base/ptr_util.h" 11 #include "third_party/base/ptr_util.h"
12 #include "xfa/fde/tto/fde_textout.h" 12 #include "xfa/fde/tto/fde_textout.h"
13 #include "xfa/fwl/cfwl_app.h" 13 #include "xfa/fwl/cfwl_app.h"
14 #include "xfa/fwl/cfwl_event.h" 14 #include "xfa/fwl/cfwl_event.h"
15 #include "xfa/fwl/cfwl_formproxy.h" 15 #include "xfa/fwl/cfwl_formproxy.h"
16 #include "xfa/fwl/cfwl_messagemouse.h" 16 #include "xfa/fwl/cfwl_messagemouse.h"
17 #include "xfa/fwl/cfwl_notedriver.h" 17 #include "xfa/fwl/cfwl_notedriver.h"
18 #include "xfa/fwl/cfwl_noteloop.h" 18 #include "xfa/fwl/cfwl_noteloop.h"
19 #include "xfa/fwl/cfwl_sysbtn.h"
20 #include "xfa/fwl/cfwl_themebackground.h" 19 #include "xfa/fwl/cfwl_themebackground.h"
21 #include "xfa/fwl/cfwl_themepart.h" 20 #include "xfa/fwl/cfwl_themepart.h"
22 #include "xfa/fwl/cfwl_themetext.h" 21 #include "xfa/fwl/cfwl_themetext.h"
23 #include "xfa/fwl/cfwl_widgetmgr.h" 22 #include "xfa/fwl/cfwl_widgetmgr.h"
24 #include "xfa/fwl/ifwl_themeprovider.h" 23 #include "xfa/fwl/ifwl_themeprovider.h"
25 #include "xfa/fwl/theme/cfwl_widgettp.h" 24 #include "xfa/fwl/theme/cfwl_widgettp.h"
26 25
27 namespace {
28
29 const int kSystemButtonSize = 21;
30 const int kSystemButtonMargin = 5;
31 const int kSystemButtonSpan = 2;
32
33 } // namespace
34
35 CFWL_Form::CFWL_Form(const CFWL_App* app, 26 CFWL_Form::CFWL_Form(const CFWL_App* app,
36 std::unique_ptr<CFWL_WidgetProperties> properties, 27 std::unique_ptr<CFWL_WidgetProperties> properties,
37 CFWL_Widget* pOuter) 28 CFWL_Widget* pOuter)
38 : CFWL_Widget(app, std::move(properties), pOuter), 29 : CFWL_Widget(app, std::move(properties), pOuter),
39 #if (_FX_OS_ == _FX_MACOSX_)
40 m_bMouseIn(false),
41 #endif
42 m_pCloseBox(nullptr),
43 m_pMinBox(nullptr),
44 m_pMaxBox(nullptr),
45 m_pSubFocus(nullptr), 30 m_pSubFocus(nullptr),
46 m_fCXBorder(0), 31 m_fCXBorder(0),
47 m_fCYBorder(0), 32 m_fCYBorder(0) {
48 m_iCaptureBtn(-1),
49 m_iSysBox(0),
50 m_bLButtonDown(false),
51 m_bMaximized(false),
52 m_bSetMaximize(false),
53 m_bDoModalFlag(false) {
54 m_rtRelative.Reset(); 33 m_rtRelative.Reset();
55 m_rtRestore.Reset(); 34 m_rtRestore.Reset();
56 35
57 RegisterForm(); 36 RegisterForm();
58 RegisterEventTarget(nullptr); 37 RegisterEventTarget(nullptr);
59 } 38 }
60 39
61 CFWL_Form::~CFWL_Form() { 40 CFWL_Form::~CFWL_Form() {
62 UnregisterEventTarget(); 41 UnregisterEventTarget();
63 UnRegisterForm(); 42 UnRegisterForm();
64 RemoveSysButtons();
65 } 43 }
66 44
67 FWL_Type CFWL_Form::GetClassID() const { 45 FWL_Type CFWL_Form::GetClassID() const {
68 return FWL_Type::Form; 46 return FWL_Type::Form;
69 } 47 }
70 48
71 bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { 49 bool CFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const {
72 if (wsClass == CFX_WideStringC(FWL_CLASS_Form)) 50 if (wsClass == CFX_WideStringC(FWL_CLASS_Form))
73 return true; 51 return true;
74 return CFWL_Widget::IsInstance(wsClass); 52 return CFWL_Widget::IsInstance(wsClass);
(...skipping 10 matching lines...) Expand all
85 return; 63 return;
86 if (!m_pProperties->m_pThemeProvider) 64 if (!m_pProperties->m_pThemeProvider)
87 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 65 m_pProperties->m_pThemeProvider = GetAvailableTheme();
88 66
89 Layout(); 67 Layout();
90 } 68 }
91 69
92 FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 70 FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
93 GetAvailableTheme(); 71 GetAvailableTheme();
94 72
95 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
96 return FWL_WidgetHit::CloseBox;
97 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
98 return FWL_WidgetHit::MaxBox;
99 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
100 return FWL_WidgetHit::MinBox;
101
102 CFX_RectF rtCap; 73 CFX_RectF rtCap;
103 rtCap.Set(m_fCYBorder, m_fCXBorder, 74 rtCap.Set(m_fCYBorder, m_fCXBorder, -2 * m_fCYBorder, 0 - m_fCXBorder);
104 0 - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder,
105 0 - m_fCXBorder);
106 return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar 75 return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar
107 : FWL_WidgetHit::Client; 76 : FWL_WidgetHit::Client;
108 } 77 }
109 78
110 void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { 79 void CFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) {
111 if (!pGraphics) 80 if (!pGraphics)
112 return; 81 return;
113 if (!m_pProperties->m_pThemeProvider) 82 if (!m_pProperties->m_pThemeProvider)
114 return; 83 return;
115 84
(...skipping 16 matching lines...) Expand all
132 param.m_iPart = CFWL_Part::Border; 101 param.m_iPart = CFWL_Part::Border;
133 pTheme->DrawBackground(&param); 102 pTheme->DrawBackground(&param);
134 } 103 }
135 if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) != 104 if ((m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_EdgeMask) !=
136 FWL_WGTSTYLE_EdgeNone) { 105 FWL_WGTSTYLE_EdgeNone) {
137 param.m_iPart = CFWL_Part::Edge; 106 param.m_iPart = CFWL_Part::Edge;
138 param.m_rtPart = GetEdgeRect(); 107 param.m_rtPart = GetEdgeRect();
139 param.m_dwStates = iState; 108 param.m_dwStates = iState;
140 pTheme->DrawBackground(&param); 109 pTheme->DrawBackground(&param);
141 } 110 }
142
143 #if (_FX_OS_ == _FX_MACOSX_)
144 {
145 if (m_pCloseBox) {
146 param.m_iPart = CFWL_Part::CloseBox;
147 param.m_dwStates = m_pCloseBox->GetPartState();
148 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
149 param.m_dwStates = CFWL_PartState_Disabled;
150 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
151 param.m_dwStates = CFWL_PartState_Hovered;
152 param.m_rtPart = m_pCloseBox->m_rtBtn;
153 pTheme->DrawBackground(&param);
154 }
155 if (m_pMaxBox) {
156 param.m_iPart = CFWL_Part::MaximizeBox;
157 param.m_dwStates = m_pMaxBox->GetPartState();
158 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
159 param.m_dwStates = CFWL_PartState_Disabled;
160 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
161 param.m_dwStates = CFWL_PartState_Hovered;
162 param.m_rtPart = m_pMaxBox->m_rtBtn;
163 param.m_bMaximize = m_bMaximized;
164 pTheme->DrawBackground(&param);
165 }
166 if (m_pMinBox) {
167 param.m_iPart = CFWL_Part::MinimizeBox;
168 param.m_dwStates = m_pMinBox->GetPartState();
169 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated)
170 param.m_dwStates = CFWL_PartState_Disabled;
171 else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn)
172 param.m_dwStates = CFWL_PartState_Hovered;
173 param.m_rtPart = m_pMinBox->m_rtBtn;
174 pTheme->DrawBackground(&param);
175 }
176 m_bMouseIn = false;
177 }
178 #else
179 {
180 if (m_pCloseBox) {
181 param.m_iPart = CFWL_Part::CloseBox;
182 param.m_dwStates = m_pCloseBox->GetPartState();
183 param.m_rtPart = m_pCloseBox->m_rtBtn;
184 pTheme->DrawBackground(&param);
185 }
186 if (m_pMaxBox) {
187 param.m_iPart = CFWL_Part::MaximizeBox;
188 param.m_dwStates = m_pMaxBox->GetPartState();
189 param.m_rtPart = m_pMaxBox->m_rtBtn;
190 param.m_bMaximize = m_bMaximized;
191 pTheme->DrawBackground(&param);
192 }
193 if (m_pMinBox) {
194 param.m_iPart = CFWL_Part::MinimizeBox;
195 param.m_dwStates = m_pMinBox->GetPartState();
196 param.m_rtPart = m_pMinBox->m_rtBtn;
197 pTheme->DrawBackground(&param);
198 }
199 }
200 #endif
201 } 111 }
202 112
203 CFWL_Widget* CFWL_Form::DoModal() { 113 CFWL_Widget* CFWL_Form::DoModal() {
204 const CFWL_App* pApp = GetOwnerApp(); 114 const CFWL_App* pApp = GetOwnerApp();
205 if (!pApp) 115 if (!pApp)
206 return nullptr; 116 return nullptr;
207 117
208 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 118 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
209 if (!pDriver) 119 if (!pDriver)
210 return nullptr; 120 return nullptr;
211 121
212 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>(); 122 m_pNoteLoop = pdfium::MakeUnique<CFWL_NoteLoop>();
213 m_pNoteLoop->SetMainForm(this); 123 m_pNoteLoop->SetMainForm(this);
214 124
215 pDriver->PushNoteLoop(m_pNoteLoop.get()); 125 pDriver->PushNoteLoop(m_pNoteLoop.get());
216 m_bDoModalFlag = true;
217 RemoveStates(FWL_WGTSTATE_Invisible); 126 RemoveStates(FWL_WGTSTATE_Invisible);
218 pDriver->Run(); 127 pDriver->Run();
219 128
220 #if _FX_OS_ != _FX_MACOSX_ 129 #if _FX_OS_ != _FX_MACOSX_
221 pDriver->PopNoteLoop(); 130 pDriver->PopNoteLoop();
222 #endif 131 #endif
223 132
224 m_pNoteLoop.reset(); 133 m_pNoteLoop.reset();
225 return nullptr; 134 return nullptr;
226 } 135 }
227 136
228 void CFWL_Form::EndDoModal() { 137 void CFWL_Form::EndDoModal() {
229 if (!m_pNoteLoop) 138 if (!m_pNoteLoop)
230 return; 139 return;
231 140
232 m_bDoModalFlag = false;
233
234 #if (_FX_OS_ == _FX_MACOSX_) 141 #if (_FX_OS_ == _FX_MACOSX_)
235 m_pNoteLoop->EndModalLoop(); 142 m_pNoteLoop->EndModalLoop();
236 const CFWL_App* pApp = GetOwnerApp(); 143 const CFWL_App* pApp = GetOwnerApp();
237 if (!pApp) 144 if (!pApp)
238 return; 145 return;
239 146
240 CFWL_NoteDriver* pDriver = 147 CFWL_NoteDriver* pDriver =
241 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 148 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
242 if (!pDriver) 149 if (!pDriver)
243 return; 150 return;
(...skipping 10 matching lines...) Expand all
254 IFWL_ThemeProvider* pTheme) { 161 IFWL_ThemeProvider* pTheme) {
255 CFWL_ThemeBackground param; 162 CFWL_ThemeBackground param;
256 param.m_pWidget = this; 163 param.m_pWidget = this;
257 param.m_iPart = CFWL_Part::Background; 164 param.m_iPart = CFWL_Part::Background;
258 param.m_pGraphics = pGraphics; 165 param.m_pGraphics = pGraphics;
259 param.m_rtPart = m_rtRelative; 166 param.m_rtPart = m_rtRelative;
260 param.m_rtPart.Deflate(m_fCYBorder, m_fCXBorder, m_fCYBorder, m_fCXBorder); 167 param.m_rtPart.Deflate(m_fCYBorder, m_fCXBorder, m_fCYBorder, m_fCXBorder);
261 pTheme->DrawBackground(&param); 168 pTheme->DrawBackground(&param);
262 } 169 }
263 170
264 void CFWL_Form::RemoveSysButtons() {
265 delete m_pCloseBox;
266 m_pCloseBox = nullptr;
267 delete m_pMinBox;
268 m_pMinBox = nullptr;
269 delete m_pMaxBox;
270 m_pMaxBox = nullptr;
271 }
272
273 CFWL_SysBtn* CFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) {
274 if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy))
275 return m_pCloseBox;
276 if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy))
277 return m_pMaxBox;
278 if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy))
279 return m_pMinBox;
280 return nullptr;
281 }
282
283 CFWL_SysBtn* CFWL_Form::GetSysBtnByState(uint32_t dwState) {
284 if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState))
285 return m_pCloseBox;
286 if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState))
287 return m_pMaxBox;
288 if (m_pMinBox && (m_pMinBox->m_dwState & dwState))
289 return m_pMinBox;
290 return nullptr;
291 }
292
293 CFWL_SysBtn* CFWL_Form::GetSysBtnByIndex(int32_t nIndex) {
294 if (nIndex < 0)
295 return nullptr;
296
297 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
298 if (m_pMinBox)
299 arrBtn.Add(m_pMinBox);
300 if (m_pMaxBox)
301 arrBtn.Add(m_pMaxBox);
302 if (m_pCloseBox)
303 arrBtn.Add(m_pCloseBox);
304 return arrBtn[nIndex];
305 }
306
307 int32_t CFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) {
308 CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn;
309 if (m_pMinBox)
310 arrBtn.Add(m_pMinBox);
311 if (m_pMaxBox)
312 arrBtn.Add(m_pMaxBox);
313 if (m_pCloseBox)
314 arrBtn.Add(m_pCloseBox);
315 return arrBtn.Find(pBtn);
316 }
317
318 CFX_RectF CFWL_Form::GetEdgeRect() { 171 CFX_RectF CFWL_Form::GetEdgeRect() {
319 CFX_RectF rtEdge = m_rtRelative; 172 CFX_RectF rtEdge = m_rtRelative;
320 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { 173 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) {
321 FX_FLOAT fCX = GetBorderSize(true); 174 FX_FLOAT fCX = GetBorderSize(true);
322 FX_FLOAT fCY = GetBorderSize(false); 175 FX_FLOAT fCY = GetBorderSize(false);
323 rtEdge.Deflate(fCX, fCY, fCX, fCY); 176 rtEdge.Deflate(fCX, fCY, fCX, fCY);
324 } 177 }
325 return rtEdge; 178 return rtEdge;
326 } 179 }
327 180
328 void CFWL_Form::SetWorkAreaRect() { 181 void CFWL_Form::SetWorkAreaRect() {
329 m_rtRestore = m_pProperties->m_rtWidget; 182 m_rtRestore = m_pProperties->m_rtWidget;
330 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); 183 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr();
331 if (!pWidgetMgr) 184 if (!pWidgetMgr)
332 return; 185 return;
333
334 m_bSetMaximize = true;
335 RepaintRect(m_rtRelative); 186 RepaintRect(m_rtRelative);
336 } 187 }
337 188
338 void CFWL_Form::Layout() { 189 void CFWL_Form::Layout() {
339 m_rtRelative = GetRelativeRect(); 190 m_rtRelative = GetRelativeRect();
340 191
341 #ifndef FWL_UseMacSystemBorder 192 #ifndef FWL_UseMacSystemBorder
342 ResetSysBtn();
343 #endif
344 }
345
346 void CFWL_Form::ResetSysBtn() {
347 m_fCXBorder = 193 m_fCXBorder =
348 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); 194 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder));
349 m_fCYBorder = 195 m_fCYBorder =
350 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); 196 *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder));
351 RemoveSysButtons(); 197 #endif
352
353 m_iSysBox = 0;
354 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) {
355 m_pCloseBox = new CFWL_SysBtn;
356 m_pCloseBox->m_rtBtn.Set(
357 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
358 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
359 m_iSysBox++;
360 }
361 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MaximizeBox) {
362 m_pMaxBox = new CFWL_SysBtn;
363 if (m_pCloseBox) {
364 m_pMaxBox->m_rtBtn.Set(
365 m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
366 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
367 } else {
368 m_pMaxBox->m_rtBtn.Set(
369 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
370 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
371 }
372 m_iSysBox++;
373 }
374 if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_MinimizeBox) {
375 m_pMinBox = new CFWL_SysBtn;
376 if (m_pMaxBox) {
377 m_pMinBox->m_rtBtn.Set(
378 m_pMaxBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
379 m_pMaxBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
380 } else if (m_pCloseBox) {
381 m_pMinBox->m_rtBtn.Set(
382 m_pCloseBox->m_rtBtn.left - kSystemButtonSpan - kSystemButtonSize,
383 m_pCloseBox->m_rtBtn.top, kSystemButtonSize, kSystemButtonSize);
384 } else {
385 m_pMinBox->m_rtBtn.Set(
386 m_rtRelative.right() - kSystemButtonMargin - kSystemButtonSize,
387 kSystemButtonMargin, kSystemButtonSize, kSystemButtonSize);
388 }
389 m_iSysBox++;
390 }
391 } 198 }
392 199
393 void CFWL_Form::RegisterForm() { 200 void CFWL_Form::RegisterForm() {
394 const CFWL_App* pApp = GetOwnerApp(); 201 const CFWL_App* pApp = GetOwnerApp();
395 if (!pApp) 202 if (!pApp)
396 return; 203 return;
397 204
398 CFWL_NoteDriver* pDriver = 205 CFWL_NoteDriver* pDriver =
399 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 206 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
400 if (!pDriver) 207 if (!pDriver)
(...skipping 23 matching lines...) Expand all
424 switch (pMessage->GetType()) { 231 switch (pMessage->GetType()) {
425 case CFWL_Message::Type::Mouse: { 232 case CFWL_Message::Type::Mouse: {
426 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); 233 CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage);
427 switch (pMsg->m_dwCmd) { 234 switch (pMsg->m_dwCmd) {
428 case FWL_MouseCommand::LeftButtonDown: 235 case FWL_MouseCommand::LeftButtonDown:
429 OnLButtonDown(pMsg); 236 OnLButtonDown(pMsg);
430 break; 237 break;
431 case FWL_MouseCommand::LeftButtonUp: 238 case FWL_MouseCommand::LeftButtonUp:
432 OnLButtonUp(pMsg); 239 OnLButtonUp(pMsg);
433 break; 240 break;
434 case FWL_MouseCommand::Move:
435 OnMouseMove(pMsg);
436 break;
437 case FWL_MouseCommand::Leave:
438 OnMouseLeave(pMsg);
439 break;
440 default: 241 default:
441 break; 242 break;
442 } 243 }
443 break; 244 break;
444 } 245 }
445 default: 246 default:
446 break; 247 break;
447 } 248 }
448 #endif // FWL_UseMacSystemBorder 249 #endif // FWL_UseMacSystemBorder
449 } 250 }
450 251
451 void CFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, 252 void CFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics,
452 const CFX_Matrix* pMatrix) { 253 const CFX_Matrix* pMatrix) {
453 DrawWidget(pGraphics, pMatrix); 254 DrawWidget(pGraphics, pMatrix);
454 } 255 }
455 256
456 void CFWL_Form::OnLButtonDown(CFWL_MessageMouse* pMsg) { 257 void CFWL_Form::OnLButtonDown(CFWL_MessageMouse* pMsg) {
457 SetGrab(true); 258 SetGrab(true);
458 m_bLButtonDown = true;
459
460 CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
461 m_iCaptureBtn = GetSysBtnIndex(pPressBtn);
462
463 if (!pPressBtn)
464 return;
465
466 pPressBtn->SetPressed();
467 RepaintRect(pPressBtn->m_rtBtn);
468 } 259 }
469 260
470 void CFWL_Form::OnLButtonUp(CFWL_MessageMouse* pMsg) { 261 void CFWL_Form::OnLButtonUp(CFWL_MessageMouse* pMsg) {
471 SetGrab(false); 262 SetGrab(false);
472 m_bLButtonDown = false;
473 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
474 CFWL_SysBtn* pPressedBtn = GetSysBtnByIndex(m_iCaptureBtn);
475 if (!pPressedBtn || pPointBtn != pPressedBtn)
476 return;
477 if (pPressedBtn == GetSysBtnByState(FWL_SYSBUTTONSTATE_Pressed))
478 pPressedBtn->SetNormal();
479 if (pPressedBtn == m_pMaxBox) {
480 if (m_bMaximized) {
481 SetWidgetRect(m_rtRestore);
482 Update();
483 Repaint();
484 } else {
485 SetWorkAreaRect();
486 Update();
487 }
488 m_bMaximized = !m_bMaximized;
489 } else if (pPressedBtn != m_pMinBox) {
490 CFWL_Event eClose(CFWL_Event::Type::Close, this);
491 DispatchEvent(&eClose);
492 }
493 } 263 }
494
495 void CFWL_Form::OnMouseMove(CFWL_MessageMouse* pMsg) {
496 if (m_bLButtonDown)
497 return;
498
499 CFX_RectF rtInvalidate;
500 rtInvalidate.Reset();
501 CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy);
502 CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
503
504 #if _FX_OS_ == _FX_MACOSX_
505 {
506 if (pOldHover && pPointBtn != pOldHover)
507 pOldHover->SetNormal();
508 if (pPointBtn && pPointBtn != pOldHover)
509 pPointBtn->SetHover();
510 if (m_pCloseBox)
511 rtInvalidate = m_pCloseBox->m_rtBtn;
512 if (m_pMaxBox) {
513 if (rtInvalidate.IsEmpty())
514 rtInvalidate = m_pMaxBox->m_rtBtn;
515 else
516 rtInvalidate.Union(m_pMaxBox->m_rtBtn);
517 }
518 if (m_pMinBox) {
519 if (rtInvalidate.IsEmpty())
520 rtInvalidate = m_pMinBox->m_rtBtn;
521 else
522 rtInvalidate.Union(m_pMinBox->m_rtBtn);
523 }
524 if (!rtInvalidate.IsEmpty() &&
525 rtInvalidate.Contains(pMsg->m_fx, pMsg->m_fy)) {
526 m_bMouseIn = true;
527 }
528 }
529 #else
530 {
531 if (pOldHover && pPointBtn != pOldHover) {
532 pOldHover->SetNormal();
533 rtInvalidate = pOldHover->m_rtBtn;
534 }
535 if (pPointBtn && pPointBtn != pOldHover) {
536 pPointBtn->SetHover();
537 if (rtInvalidate.IsEmpty())
538 rtInvalidate = pPointBtn->m_rtBtn;
539 else
540 rtInvalidate.Union(pPointBtn->m_rtBtn);
541 }
542 }
543 #endif
544
545 if (!rtInvalidate.IsEmpty())
546 RepaintRect(rtInvalidate);
547 }
548
549 void CFWL_Form::OnMouseLeave(CFWL_MessageMouse* pMsg) {
550 CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover);
551 if (!pHover)
552 return;
553
554 pHover->SetNormal();
555 RepaintRect(pHover->m_rtBtn);
556 }
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_form.h ('k') | xfa/fwl/cfwl_sysbtn.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698