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

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

Issue 1943413002: Convert FWL_ERR into an enum class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@bcdattribute
Patch Set: Created 4 years, 7 months 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/core/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_sdadapterimp.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/core/fwl_noteimp.h" 7 #include "xfa/fwl/core/fwl_noteimp.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" 10 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h"
11 #include "xfa/fwl/basewidget/ifwl_tooltip.h" 11 #include "xfa/fwl/basewidget/ifwl_tooltip.h"
12 #include "xfa/fwl/core/cfwl_message.h" 12 #include "xfa/fwl/core/cfwl_message.h"
13 #include "xfa/fwl/core/fwl_appimp.h" 13 #include "xfa/fwl/core/fwl_appimp.h"
14 #include "xfa/fwl/core/fwl_formimp.h" 14 #include "xfa/fwl/core/fwl_formimp.h"
15 #include "xfa/fwl/core/fwl_widgetimp.h" 15 #include "xfa/fwl/core/fwl_widgetimp.h"
16 #include "xfa/fwl/core/fwl_widgetmgrimp.h" 16 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
17 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h" 17 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
18 #include "xfa/fwl/core/ifwl_app.h" 18 #include "xfa/fwl/core/ifwl_app.h"
19 #include "xfa/fwl/core/ifwl_tooltiptarget.h" 19 #include "xfa/fwl/core/ifwl_tooltiptarget.h"
20 20
21 CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm) 21 CFWL_NoteLoop::CFWL_NoteLoop(CFWL_WidgetImp* pForm)
22 : m_pForm(pForm), m_bContinueModal(TRUE) {} 22 : m_pForm(pForm), m_bContinueModal(TRUE) {}
23 23
24 FWL_ERR CFWL_NoteLoop::Idle(int32_t count) { 24 FWL_Error CFWL_NoteLoop::Idle(int32_t count) {
25 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) 25 #if (_FX_OS_ == _FX_WIN32_DESKTOP_)
26 if (count <= 0) { 26 if (count <= 0) {
27 #endif 27 #endif
28 CFWL_EvtIdle ev; 28 CFWL_EvtIdle ev;
29 IFWL_App* pApp = FWL_GetApp(); 29 IFWL_App* pApp = FWL_GetApp();
30 if (!pApp) 30 if (!pApp)
31 return FWL_ERR_Indefinite; 31 return FWL_Error::Indefinite;
32 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 32 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
33 if (!pDriver) 33 if (!pDriver)
34 return FWL_ERR_Indefinite; 34 return FWL_Error::Indefinite;
35 pDriver->SendEvent(&ev); 35 pDriver->SendEvent(&ev);
36 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) 36 #if (_FX_OS_ == _FX_WIN32_DESKTOP_)
37 } 37 }
38 #endif 38 #endif
39 return FWL_ERR_Indefinite; 39 return FWL_Error::Indefinite;
40 } 40 }
41 CFWL_WidgetImp* CFWL_NoteLoop::GetForm() { 41 CFWL_WidgetImp* CFWL_NoteLoop::GetForm() {
42 return m_pForm; 42 return m_pForm;
43 } 43 }
44 FX_BOOL CFWL_NoteLoop::ContinueModal() { 44 FX_BOOL CFWL_NoteLoop::ContinueModal() {
45 return m_bContinueModal; 45 return m_bContinueModal;
46 } 46 }
47 FWL_ERR CFWL_NoteLoop::EndModalLoop() { 47 FWL_Error CFWL_NoteLoop::EndModalLoop() {
48 m_bContinueModal = FALSE; 48 m_bContinueModal = FALSE;
49 #if (_FX_OS_ == _FX_MACOSX_) 49 #if (_FX_OS_ == _FX_MACOSX_)
50 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); 50 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
51 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr(); 51 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
52 adapterWidgetMgr->EndLoop(); 52 adapterWidgetMgr->EndLoop();
53 #endif 53 #endif
54 return FWL_ERR_Succeeded; 54 return FWL_Error::Succeeded;
55 } 55 }
56 56
57 FWL_ERR CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) { 57 FWL_Error CFWL_NoteLoop::SetMainForm(CFWL_WidgetImp* pForm) {
58 m_pForm = pForm; 58 m_pForm = pForm;
59 return FWL_ERR_Succeeded; 59 return FWL_Error::Succeeded;
60 } 60 }
61 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) { 61 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) {
62 CFWL_EvtMenuCommand ev; 62 CFWL_EvtMenuCommand ev;
63 ev.m_iCommand = dwCommand; 63 ev.m_iCommand = dwCommand;
64 IFWL_App* pApp = m_pForm->GetOwnerApp(); 64 IFWL_App* pApp = m_pForm->GetOwnerApp();
65 if (!pApp) 65 if (!pApp)
66 return; 66 return;
67 67
68 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); 68 CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
69 if (!pDriver) 69 if (!pDriver)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 CFWL_EventTarget* pEventTarget = static_cast<CFWL_EventTarget*>(value); 112 CFWL_EventTarget* pEventTarget = static_cast<CFWL_EventTarget*>(value);
113 if (pEventTarget && !pEventTarget->IsInvalid()) 113 if (pEventTarget && !pEventTarget->IsInvalid())
114 pEventTarget->ProcessEvent(pNote); 114 pEventTarget->ProcessEvent(pNote);
115 } 115 }
116 m_sendEventCalled--; 116 m_sendEventCalled--;
117 return TRUE; 117 return TRUE;
118 } 118 }
119 119
120 #define FWL_NoteDriver_EventKey 1100 120 #define FWL_NoteDriver_EventKey 1100
121 FWL_ERR CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, 121 FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
122 IFWL_Widget* pEventSource, 122 IFWL_Widget* pEventSource,
123 uint32_t dwFilter) { 123 uint32_t dwFilter) {
124 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData( 124 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData(
125 (void*)(uintptr_t)FWL_NoteDriver_EventKey); 125 (void*)(uintptr_t)FWL_NoteDriver_EventKey);
126 if (dwkey == 0) { 126 if (dwkey == 0) {
127 void* random = FX_Random_MT_Start(0); 127 void* random = FX_Random_MT_Start(0);
128 dwkey = rand(); 128 dwkey = rand();
129 FX_Random_MT_Close(random); 129 FX_Random_MT_Close(random);
130 pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, 130 pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey,
131 (void*)(uintptr_t)dwkey, NULL); 131 (void*)(uintptr_t)dwkey, NULL);
132 } 132 }
133 CFWL_EventTarget* value = NULL; 133 CFWL_EventTarget* value = NULL;
134 if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { 134 if (!m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
135 value = new CFWL_EventTarget(this, pListener); 135 value = new CFWL_EventTarget(this, pListener);
136 m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value); 136 m_eventTargets.SetAt((void*)(uintptr_t)dwkey, value);
137 } 137 }
138 value->SetEventSource(pEventSource, dwFilter); 138 value->SetEventSource(pEventSource, dwFilter);
139 return FWL_ERR_Succeeded; 139 return FWL_Error::Succeeded;
140 } 140 }
141 FWL_ERR CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { 141 FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
142 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData( 142 uint32_t dwkey = (uint32_t)(uintptr_t)pListener->GetPrivateData(
143 (void*)(uintptr_t)FWL_NoteDriver_EventKey); 143 (void*)(uintptr_t)FWL_NoteDriver_EventKey);
144 if (dwkey == 0) { 144 if (dwkey == 0) {
145 return FWL_ERR_Indefinite; 145 return FWL_Error::Indefinite;
146 } 146 }
147 CFWL_EventTarget* value = NULL; 147 CFWL_EventTarget* value = NULL;
148 if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) { 148 if (m_eventTargets.Lookup((void*)(uintptr_t)dwkey, (void*&)value)) {
149 value->FlagInvalid(); 149 value->FlagInvalid();
150 } 150 }
151 return FWL_ERR_Succeeded; 151 return FWL_Error::Succeeded;
152 } 152 }
153 void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) { 153 void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
154 ClearInvalidEventTargets(bRemoveAll); 154 ClearInvalidEventTargets(bRemoveAll);
155 } 155 }
156 IFWL_App* CFWL_NoteDriver::GetOwnerApp() const { 156 IFWL_App* CFWL_NoteDriver::GetOwnerApp() const {
157 return FWL_GetApp(); 157 return FWL_GetApp();
158 } 158 }
159 FWL_ERR CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) { 159 FWL_Error CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
160 m_noteLoopQueue.Add(pNoteLoop); 160 m_noteLoopQueue.Add(pNoteLoop);
161 return FWL_ERR_Succeeded; 161 return FWL_Error::Succeeded;
162 } 162 }
163 CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() { 163 CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
164 int32_t pos = m_noteLoopQueue.GetSize(); 164 int32_t pos = m_noteLoopQueue.GetSize();
165 if (pos <= 0) 165 if (pos <= 0)
166 return nullptr; 166 return nullptr;
167 167
168 CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1); 168 CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1);
169 m_noteLoopQueue.RemoveAt(pos - 1); 169 m_noteLoopQueue.RemoveAt(pos - 1);
170 return p; 170 return p;
171 } 171 }
(...skipping 30 matching lines...) Expand all
202 if (bNotify) { 202 if (bNotify) {
203 ms.m_dwExtend = 1; 203 ms.m_dwExtend = 1;
204 } 204 }
205 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL); 205 IFWL_WidgetDelegate* pDelegate = pFocus->SetDelegate(NULL);
206 if (pDelegate) { 206 if (pDelegate) {
207 pDelegate->OnProcessMessage(&ms); 207 pDelegate->OnProcessMessage(&ms);
208 } 208 }
209 } 209 }
210 return TRUE; 210 return TRUE;
211 } 211 }
212 FWL_ERR CFWL_NoteDriver::Run() { 212 FWL_Error CFWL_NoteDriver::Run() {
213 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr()); 213 CFWL_WidgetMgr* pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
214 if (!pWidgetMgr) 214 if (!pWidgetMgr)
215 return FWL_ERR_Indefinite; 215 return FWL_Error::Indefinite;
216 #if (_FX_OS_ == _FX_MACOSX_) 216 #if (_FX_OS_ == _FX_MACOSX_)
217 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr(); 217 IFWL_AdapterWidgetMgr* adapterWidgetMgr = pWidgetMgr->GetAdapterWidgetMgr();
218 CFWL_NoteLoop* pTopLoop = GetTopLoop(); 218 CFWL_NoteLoop* pTopLoop = GetTopLoop();
219 if (pTopLoop) { 219 if (pTopLoop) {
220 CFWL_WidgetImp* formImp = pTopLoop->GetForm(); 220 CFWL_WidgetImp* formImp = pTopLoop->GetForm();
221 if (formImp) { 221 if (formImp) {
222 IFWL_Widget* pForm = formImp->GetInterface(); 222 IFWL_Widget* pForm = formImp->GetInterface();
223 adapterWidgetMgr->RunLoop(pForm); 223 adapterWidgetMgr->RunLoop(pForm);
224 } 224 }
225 } 225 }
226 #elif(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) 226 #elif(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
227 FX_BOOL bIdle = TRUE; 227 FX_BOOL bIdle = TRUE;
228 int32_t iIdleCount = 0; 228 int32_t iIdleCount = 0;
229 CFWL_NoteLoop* pTopLoop = NULL; 229 CFWL_NoteLoop* pTopLoop = NULL;
230 for (;;) { 230 for (;;) {
231 pTopLoop = GetTopLoop(); 231 pTopLoop = GetTopLoop();
232 if (!pTopLoop || !pTopLoop->ContinueModal()) { 232 if (!pTopLoop || !pTopLoop->ContinueModal()) {
233 break; 233 break;
234 } 234 }
235 if (UnqueueMessage(pTopLoop)) { 235 if (UnqueueMessage(pTopLoop)) {
236 continue; 236 continue;
237 } 237 }
238 while (bIdle && !(pWidgetMgr->CheckMessage_Native())) { 238 while (bIdle && !(pWidgetMgr->CheckMessage_Native())) {
239 if (FWL_ERR_Indefinite == pTopLoop->Idle(iIdleCount++)) { 239 if (FWL_Error::Indefinite == pTopLoop->Idle(iIdleCount++)) {
240 bIdle = FALSE; 240 bIdle = FALSE;
241 } 241 }
242 } 242 }
243 do { 243 do {
244 if (FWL_ERR_Indefinite == pWidgetMgr->DispatchMessage_Native()) { 244 if (FWL_Error::Indefinite == pWidgetMgr->DispatchMessage_Native()) {
245 break; 245 break;
246 } 246 }
247 if (pWidgetMgr->IsIdleMessage_Native()) { 247 if (pWidgetMgr->IsIdleMessage_Native()) {
248 bIdle = TRUE; 248 bIdle = TRUE;
249 iIdleCount = 0; 249 iIdleCount = 0;
250 } 250 }
251 } while (pWidgetMgr->CheckMessage_Native()); 251 } while (pWidgetMgr->CheckMessage_Native());
252 } 252 }
253 #elif(_FX_OS_ == _FX_LINUX_DESKTOP_) 253 #elif(_FX_OS_ == _FX_LINUX_DESKTOP_)
254 CFWL_NoteLoop* pTopLoop = NULL; 254 CFWL_NoteLoop* pTopLoop = NULL;
255 for (;;) { 255 for (;;) {
256 pTopLoop = GetTopLoop(); 256 pTopLoop = GetTopLoop();
257 if (!pTopLoop || !pTopLoop->ContinueModal()) { 257 if (!pTopLoop || !pTopLoop->ContinueModal()) {
258 break; 258 break;
259 } 259 }
260 if (UnqueueMessage(pTopLoop)) { 260 if (UnqueueMessage(pTopLoop)) {
261 continue; 261 continue;
262 } 262 }
263 if (pWidgetMgr->CheckMessage_Native()) { 263 if (pWidgetMgr->CheckMessage_Native()) {
264 pWidgetMgr->DispatchMessage_Native(); 264 pWidgetMgr->DispatchMessage_Native();
265 } 265 }
266 } 266 }
267 #endif 267 #endif
268 return FWL_ERR_Succeeded; 268 return FWL_Error::Succeeded;
269 } 269 }
270 IFWL_Widget* CFWL_NoteDriver::GetFocus() { 270 IFWL_Widget* CFWL_NoteDriver::GetFocus() {
271 return m_pFocus; 271 return m_pFocus;
272 } 272 }
273 IFWL_Widget* CFWL_NoteDriver::GetHover() { 273 IFWL_Widget* CFWL_NoteDriver::GetHover() {
274 return m_pHover; 274 return m_pHover;
275 } 275 }
276 void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) { 276 void CFWL_NoteDriver::SetHover(IFWL_Widget* pHover) {
277 m_pHover = pHover; 277 m_pHover = pHover;
278 } 278 }
(...skipping 30 matching lines...) Expand all
309 } 309 }
310 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus(); 310 CFWL_WidgetImp* pSubFocus = pForm->GetSubFocus();
311 if (!pSubFocus) 311 if (!pSubFocus)
312 return; 312 return;
313 if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) { 313 if (pSubFocus && pSubFocus->GetInterface() == pNoteTarget) {
314 pForm->SetSubFocus(NULL); 314 pForm->SetSubFocus(NULL);
315 } 315 }
316 } 316 }
317 } 317 }
318 318
319 FWL_ERR CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) { 319 FWL_Error CFWL_NoteDriver::RegisterForm(CFWL_WidgetImp* pForm) {
320 if (!pForm) 320 if (!pForm)
321 return FWL_ERR_Indefinite; 321 return FWL_Error::Indefinite;
322 if (m_forms.Find(pForm) >= 0) { 322 if (m_forms.Find(pForm) >= 0) {
323 return FWL_ERR_Indefinite; 323 return FWL_Error::Indefinite;
324 } 324 }
325 m_forms.Add(pForm); 325 m_forms.Add(pForm);
326 if (m_forms.GetSize() == 1) { 326 if (m_forms.GetSize() == 1) {
327 CFWL_NoteLoop* pLoop = 327 CFWL_NoteLoop* pLoop =
328 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0)); 328 static_cast<CFWL_NoteLoop*>(m_noteLoopQueue.GetAt(0));
329 if (!pLoop) 329 if (!pLoop)
330 return FWL_ERR_Indefinite; 330 return FWL_Error::Indefinite;
331 pLoop->SetMainForm(pForm); 331 pLoop->SetMainForm(pForm);
332 } 332 }
333 return FWL_ERR_Succeeded; 333 return FWL_Error::Succeeded;
334 } 334 }
335 FWL_ERR CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) { 335 FWL_Error CFWL_NoteDriver::UnRegisterForm(CFWL_WidgetImp* pForm) {
336 if (!pForm) 336 if (!pForm)
337 return FWL_ERR_Indefinite; 337 return FWL_Error::Indefinite;
338 int32_t nIndex = m_forms.Find(pForm); 338 int32_t nIndex = m_forms.Find(pForm);
339 if (nIndex < 0) { 339 if (nIndex < 0) {
340 return FWL_ERR_Indefinite; 340 return FWL_Error::Indefinite;
341 } 341 }
342 m_forms.RemoveAt(nIndex); 342 m_forms.RemoveAt(nIndex);
343 return FWL_ERR_Succeeded; 343 return FWL_Error::Succeeded;
344 } 344 }
345 FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) { 345 FX_BOOL CFWL_NoteDriver::QueueMessage(CFWL_Message* pMessage) {
346 pMessage->Retain(); 346 pMessage->Retain();
347 m_noteQueue.Add(pMessage); 347 m_noteQueue.Add(pMessage);
348 return TRUE; 348 return TRUE;
349 } 349 }
350 FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) { 350 FX_BOOL CFWL_NoteDriver::UnqueueMessage(CFWL_NoteLoop* pNoteLoop) {
351 if (m_noteQueue.GetSize() < 1) { 351 if (m_noteQueue.GetSize() < 1) {
352 return FALSE; 352 return FALSE;
353 } 353 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 CFWL_EventTarget* pEventTarget = NULL; 725 CFWL_EventTarget* pEventTarget = NULL;
726 m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget); 726 m_eventTargets.GetNextAssoc(pos, key, (void*&)pEventTarget);
727 if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) { 727 if (pEventTarget && (bRemoveAll || pEventTarget->IsInvalid())) {
728 m_eventTargets.RemoveKey(key); 728 m_eventTargets.RemoveKey(key);
729 delete pEventTarget; 729 delete pEventTarget;
730 } 730 }
731 } 731 }
732 } 732 }
733 class CFWL_CoreToolTipDP : public IFWL_ToolTipDP { 733 class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
734 public: 734 public:
735 FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); 735 FWL_Error GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption);
736 int32_t GetInitialDelay(IFWL_Widget* pWidget); 736 int32_t GetInitialDelay(IFWL_Widget* pWidget);
737 int32_t GetAutoPopDelay(IFWL_Widget* pWidget); 737 int32_t GetAutoPopDelay(IFWL_Widget* pWidget);
738 CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget); 738 CFX_DIBitmap* GetToolTipIcon(IFWL_Widget* pWidget);
739 CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget); 739 CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget);
740 CFX_RectF GetAnchor(); 740 CFX_RectF GetAnchor();
741 CFWL_CoreToolTipDP(); 741 CFWL_CoreToolTipDP();
742 742
743 CFX_WideString m_wsCaption; 743 CFX_WideString m_wsCaption;
744 int32_t m_nInitDelayTime; 744 int32_t m_nInitDelayTime;
745 int32_t m_nAutoPopDelayTime; 745 int32_t m_nAutoPopDelayTime;
746 CFX_RectF m_fAnchor; 746 CFX_RectF m_fAnchor;
747 }; 747 };
748 CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() { 748 CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() {
749 m_nInitDelayTime = 500; 749 m_nInitDelayTime = 500;
750 m_nAutoPopDelayTime = 50000; 750 m_nAutoPopDelayTime = 50000;
751 m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); 751 m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
752 } 752 }
753 FWL_ERR CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget, 753 FWL_Error CFWL_CoreToolTipDP::GetCaption(IFWL_Widget* pWidget,
754 CFX_WideString& wsCaption) { 754 CFX_WideString& wsCaption) {
755 wsCaption = m_wsCaption; 755 wsCaption = m_wsCaption;
756 return FWL_ERR_Succeeded; 756 return FWL_Error::Succeeded;
757 } 757 }
758 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { 758 int32_t CFWL_CoreToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) {
759 return m_nInitDelayTime; 759 return m_nInitDelayTime;
760 } 760 }
761 int32_t CFWL_CoreToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { 761 int32_t CFWL_CoreToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) {
762 return m_nAutoPopDelayTime; 762 return m_nAutoPopDelayTime;
763 } 763 }
764 CFX_DIBitmap* CFWL_CoreToolTipDP::GetToolTipIcon(IFWL_Widget* pWidget) { 764 CFX_DIBitmap* CFWL_CoreToolTipDP::GetToolTipIcon(IFWL_Widget* pWidget) {
765 return NULL; 765 return NULL;
766 } 766 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 s_pInstance = new CFWL_ToolTipContainer; 857 s_pInstance = new CFWL_ToolTipContainer;
858 return s_pInstance; 858 return s_pInstance;
859 } 859 }
860 860
861 // static 861 // static
862 void CFWL_ToolTipContainer::DeleteInstance() { 862 void CFWL_ToolTipContainer::DeleteInstance() {
863 delete s_pInstance; 863 delete s_pInstance;
864 s_pInstance = NULL; 864 s_pInstance = NULL;
865 } 865 }
866 866
867 FX_ERR CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) { 867 FWL_Error CFWL_ToolTipContainer::AddToolTipTarget(IFWL_ToolTipTarget* pTarget) {
868 if (m_arrWidget.Find(pTarget) < 0) { 868 if (m_arrWidget.Find(pTarget) < 0) {
869 m_arrWidget.Add(pTarget); 869 m_arrWidget.Add(pTarget);
870 return FWL_ERR_Succeeded; 870 return FWL_Error::Succeeded;
871 } 871 }
872 return FWL_ERR_Indefinite; 872 return FWL_Error::Indefinite;
873 } 873 }
874 FX_ERR CFWL_ToolTipContainer::RemoveToolTipTarget(IFWL_ToolTipTarget* pTarget) { 874 FWL_Error CFWL_ToolTipContainer::RemoveToolTipTarget(
875 IFWL_ToolTipTarget* pTarget) {
875 int index = m_arrWidget.Find(pTarget); 876 int index = m_arrWidget.Find(pTarget);
876 if (index >= 0) { 877 if (index >= 0) {
877 m_arrWidget.RemoveAt(index); 878 m_arrWidget.RemoveAt(index);
878 return FWL_ERR_Succeeded; 879 return FWL_Error::Succeeded;
879 } 880 }
880 return FWL_ERR_Indefinite; 881 return FWL_Error::Indefinite;
881 } 882 }
882 FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget* pWedget) { 883 FX_BOOL CFWL_ToolTipContainer::HasToolTip(IFWL_Widget* pWedget) {
883 int32_t iCount = m_arrWidget.GetSize(); 884 int32_t iCount = m_arrWidget.GetSize();
884 for (int32_t i = 0; i < iCount; i++) { 885 for (int32_t i = 0; i < iCount; i++) {
885 IFWL_ToolTipTarget* p = m_arrWidget[i]; 886 IFWL_ToolTipTarget* p = m_arrWidget[i];
886 if (p->GetWidget() == pWedget) { 887 if (p->GetWidget() == pWedget) {
887 pCurTarget = p; 888 pCurTarget = p;
888 return TRUE; 889 return TRUE;
889 } 890 }
890 } 891 }
(...skipping 27 matching lines...) Expand all
918 if (sz.x > 0 && sz.y > 0) { 919 if (sz.x > 0 && sz.y > 0) {
919 rt.width = sz.x; 920 rt.width = sz.x;
920 rt.height = sz.y; 921 rt.height = sz.y;
921 } else { 922 } else {
922 CFX_RectF r; 923 CFX_RectF r;
923 m_pToolTipImp->GetWidgetRect(r, TRUE); 924 m_pToolTipImp->GetWidgetRect(r, TRUE);
924 rt.width = r.width; 925 rt.width = r.width;
925 rt.height = r.height; 926 rt.height = r.height;
926 } 927 }
927 CFX_PointF pt(pEvt->m_fx, pEvt->m_fy); 928 CFX_PointF pt(pEvt->m_fx, pEvt->m_fy);
928 if (pCurTarget->GetToolTipPos(pt) == FWL_ERR_Succeeded) { 929 if (pCurTarget->GetToolTipPos(pt) == FWL_Error::Succeeded) {
929 rt.left = pt.x; 930 rt.left = pt.x;
930 rt.top = pt.y; 931 rt.top = pt.y;
931 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0); 932 m_pToolTipImp->ModifyStylesEx(FWL_STYLEEXT_TTP_NoAnchor, 0);
932 } else { 933 } else {
933 CFX_RectF rtAnchor; 934 CFX_RectF rtAnchor;
934 pCurTarget->GetWidget()->GetClientRect(rtAnchor); 935 pCurTarget->GetWidget()->GetClientRect(rtAnchor);
935 pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top); 936 pCurTarget->GetWidget()->TransformTo(NULL, rtAnchor.left, rtAnchor.top);
936 m_pToolTipImp->SetAnchor(rtAnchor); 937 m_pToolTipImp->SetAnchor(rtAnchor);
937 m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor); 938 m_pToolTipImp->ModifyStylesEx(0, FWL_STYLEEXT_TTP_NoAnchor);
938 } 939 }
939 m_pToolTipImp->SetWidgetRect(rt); 940 m_pToolTipImp->SetWidgetRect(rt);
940 m_pToolTipImp->Update(); 941 m_pToolTipImp->Update();
941 m_pToolTipImp->Show(); 942 m_pToolTipImp->Show();
942 } 943 }
943 return TRUE; 944 return TRUE;
944 } 945 }
945 return FALSE; 946 return FALSE;
946 } 947 }
947 FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) { 948 FX_BOOL CFWL_ToolTipContainer::ProcessLeave(CFWL_EvtMouse* pEvt) {
948 if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { 949 if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) {
949 m_pToolTipImp->Hide(); 950 m_pToolTipImp->Hide();
950 pCurTarget = NULL; 951 pCurTarget = NULL;
951 return TRUE; 952 return TRUE;
952 } 953 }
953 return FALSE; 954 return FALSE;
954 } 955 }
955 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() { 956 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() {
956 return pCurTarget; 957 return pCurTarget;
957 } 958 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/fwl_noteimp.h ('k') | xfa/fwl/core/fwl_sdadapterimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698