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

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

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 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/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_comboedit.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/basewidget/fwl_comboboximp.h" 7 #include "xfa/fwl/core/ifwl_combobox.h"
8 8
9 #include "xfa/fde/cfde_txtedtengine.h" 9 #include "xfa/fde/cfde_txtedtengine.h"
10 #include "xfa/fde/tto/fde_textout.h" 10 #include "xfa/fde/tto/fde_textout.h"
11 #include "xfa/fwl/basewidget/fwl_editimp.h"
12 #include "xfa/fwl/basewidget/fwl_formproxyimp.h"
13 #include "xfa/fwl/basewidget/fwl_listboximp.h"
14 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h"
15 #include "xfa/fwl/core/cfwl_message.h" 11 #include "xfa/fwl/core/cfwl_message.h"
16 #include "xfa/fwl/core/cfwl_themebackground.h" 12 #include "xfa/fwl/core/cfwl_themebackground.h"
17 #include "xfa/fwl/core/cfwl_themepart.h" 13 #include "xfa/fwl/core/cfwl_themepart.h"
18 #include "xfa/fwl/core/cfwl_themetext.h" 14 #include "xfa/fwl/core/cfwl_themetext.h"
19 #include "xfa/fwl/core/cfwl_widgetmgr.h" 15 #include "xfa/fwl/core/cfwl_widgetmgr.h"
20 #include "xfa/fwl/core/fwl_formimp.h"
21 #include "xfa/fwl/core/fwl_noteimp.h" 16 #include "xfa/fwl/core/fwl_noteimp.h"
22 #include "xfa/fwl/core/fwl_widgetimp.h"
23 #include "xfa/fwl/core/ifwl_app.h" 17 #include "xfa/fwl/core/ifwl_app.h"
18 #include "xfa/fwl/core/ifwl_comboedit.h"
19 #include "xfa/fwl/core/ifwl_combolist.h"
20 #include "xfa/fwl/core/ifwl_formproxy.h"
24 #include "xfa/fwl/core/ifwl_themeprovider.h" 21 #include "xfa/fwl/core/ifwl_themeprovider.h"
25 22
26 // static 23 // static
27 IFWL_ComboBox* IFWL_ComboBox::Create( 24 IFWL_ComboBox* IFWL_ComboBox::Create(
28 const CFWL_WidgetImpProperties& properties) { 25 const CFWL_WidgetImpProperties& properties) {
29 IFWL_ComboBox* pComboBox = new IFWL_ComboBox; 26 return new IFWL_ComboBox(properties, nullptr);
30 CFWL_ComboBoxImp* pComboBoxImpl = new CFWL_ComboBoxImp(properties, nullptr);
31 pComboBox->SetImpl(pComboBoxImpl);
32 pComboBoxImpl->SetInterface(pComboBox);
33 return pComboBox;
34 }
35 IFWL_ComboBox::IFWL_ComboBox() {}
36 int32_t IFWL_ComboBox::GetCurSel() {
37 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetCurSel();
38 }
39 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) {
40 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetCurSel(iSel);
41 }
42 FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
43 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditText(wsText);
44 }
45 int32_t IFWL_ComboBox::GetEditTextLength() const {
46 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditTextLength();
47 }
48 FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
49 int32_t nStart,
50 int32_t nCount) const {
51 return static_cast<CFWL_ComboBoxImp*>(GetImpl())
52 ->GetEditText(wsText, nStart, nCount);
53 }
54 FWL_Error IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
55 return static_cast<CFWL_ComboBoxImp*>(GetImpl())
56 ->SetEditSelRange(nStart, nCount);
57 }
58 int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
59 return static_cast<CFWL_ComboBoxImp*>(GetImpl())
60 ->GetEditSelRange(nIndex, nStart);
61 }
62 int32_t IFWL_ComboBox::GetEditLimit() {
63 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetEditLimit();
64 }
65 FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
66 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->SetEditLimit(nLimit);
67 }
68 FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
69 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDoClipboard(iCmd);
70 }
71 FX_BOOL IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
72 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo(pRecord);
73 }
74 FX_BOOL IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
75 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo(pRecord);
76 }
77 IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
78 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetListBoxt();
79 }
80 FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() {
81 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->AfterFocusShowDropList();
82 }
83 FWL_Error IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
84 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->OpenDropDownList(bActivate);
85 }
86 FX_BOOL IFWL_ComboBox::EditCanUndo() {
87 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanUndo();
88 }
89 FX_BOOL IFWL_ComboBox::EditCanRedo() {
90 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanRedo();
91 }
92 FX_BOOL IFWL_ComboBox::EditUndo() {
93 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditUndo();
94 }
95 FX_BOOL IFWL_ComboBox::EditRedo() {
96 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditRedo();
97 }
98 FX_BOOL IFWL_ComboBox::EditCanCopy() {
99 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCopy();
100 }
101 FX_BOOL IFWL_ComboBox::EditCanCut() {
102 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanCut();
103 }
104 FX_BOOL IFWL_ComboBox::EditCanSelectAll() {
105 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCanSelectAll();
106 }
107 FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
108 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCopy(wsCopy);
109 }
110 FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
111 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditCut(wsCut);
112 }
113 FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
114 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditPaste(wsPaste);
115 }
116 FX_BOOL IFWL_ComboBox::EditSelectAll() {
117 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditSelectAll();
118 }
119 FX_BOOL IFWL_ComboBox::EditDelete() {
120 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDelete();
121 }
122 FX_BOOL IFWL_ComboBox::EditDeSelect() {
123 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->EditDeSelect();
124 }
125 FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
126 return static_cast<CFWL_ComboBoxImp*>(GetImpl())->GetBBox(rect);
127 }
128 FWL_Error IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
129 uint32_t dwStylesExRemoved) {
130 return static_cast<CFWL_ComboBoxImp*>(GetImpl())
131 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
132 } 27 }
133 28
134 CFWL_ComboEditImp::CFWL_ComboEditImp(const CFWL_WidgetImpProperties& properties, 29 IFWL_ComboBox::IFWL_ComboBox(const CFWL_WidgetImpProperties& properties,
135 IFWL_Widget* pOuter) 30 IFWL_Widget* pOuter)
136 : CFWL_EditImp(properties, pOuter) { 31 : IFWL_Widget(properties, pOuter),
137 m_pOuter = static_cast<CFWL_ComboBoxImp*>(pOuter->GetImpl());
138 }
139
140 CFWL_ComboEditImpDelegate::CFWL_ComboEditImpDelegate(CFWL_ComboEditImp* pOwner)
141 : CFWL_EditImpDelegate(pOwner), m_pOwner(pOwner) {}
142
143 void CFWL_ComboEditImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
144 if (!pMessage)
145 return;
146
147 FX_BOOL backDefault = TRUE;
148 switch (pMessage->GetClassID()) {
149 case CFWL_MessageType::SetFocus: {
150 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
151 backDefault = FALSE;
152 break;
153 }
154 case CFWL_MessageType::KillFocus: {
155 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
156 backDefault = FALSE;
157 break;
158 }
159 case CFWL_MessageType::Mouse: {
160 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
161 if ((pMsg->m_dwCmd == FWL_MouseCommand::LeftButtonDown) &&
162 ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0)) {
163 m_pOwner->SetSelected();
164 m_pOwner->SetComboBoxFocus(TRUE);
165 }
166 break;
167 }
168 default:
169 break;
170 }
171 if (backDefault)
172 CFWL_EditImpDelegate::OnProcessMessage(pMessage);
173 }
174
175 void CFWL_ComboEditImp::ClearSelected() {
176 ClearSelections();
177 Repaint(&m_rtClient);
178 }
179 void CFWL_ComboEditImp::SetSelected() {
180 FlagFocus(TRUE);
181 EndCaret();
182 AddSelRange(0);
183 }
184 void CFWL_ComboEditImp::EndCaret() {
185 m_pEdtEngine->MoveCaretPos(MC_End);
186 }
187 void CFWL_ComboEditImp::FlagFocus(FX_BOOL bSet) {
188 if (bSet) {
189 m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
190 } else {
191 m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
192 ShowCaret(FALSE);
193 }
194 }
195 void CFWL_ComboEditImp::SetComboBoxFocus(FX_BOOL bSet) {
196 m_pOuter->SetFocus(bSet);
197 }
198 CFWL_ComboListImp::CFWL_ComboListImp(const CFWL_WidgetImpProperties& properties,
199 IFWL_Widget* pOuter)
200 : CFWL_ListBoxImp(properties, pOuter), m_bNotifyOwner(TRUE) {
201 ASSERT(pOuter);
202 }
203 FWL_Error CFWL_ComboListImp::Initialize() {
204 if (CFWL_ListBoxImp::Initialize() != FWL_Error::Succeeded)
205 return FWL_Error::Indefinite;
206 delete m_pDelegate;
207 m_pDelegate = new CFWL_ComboListImpDelegate(this);
208 return FWL_Error::Succeeded;
209 }
210 FWL_Error CFWL_ComboListImp::Finalize() {
211 delete m_pDelegate;
212 m_pDelegate = nullptr;
213 return CFWL_ListBoxImp::Finalize();
214 }
215 int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) {
216 if (wsMatch.IsEmpty()) {
217 return -1;
218 }
219 if (!m_pProperties->m_pDataProvider)
220 return -1;
221 IFWL_ListBoxDP* pData =
222 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
223 int32_t iCount = pData->CountItems(m_pInterface);
224 for (int32_t i = 0; i < iCount; i++) {
225 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i);
226 CFX_WideString wsText;
227 pData->GetItemText(m_pInterface, hItem, wsText);
228 FX_STRSIZE pos = wsText.Find(wsMatch.c_str());
229 if (!pos) {
230 return i;
231 }
232 }
233 return -1;
234 }
235 void CFWL_ComboListImp::ChangeSelected(int32_t iSel) {
236 if (!m_pProperties->m_pDataProvider)
237 return;
238 IFWL_ListBoxDP* pData =
239 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
240 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iSel);
241 CFX_RectF rtInvalidate;
242 rtInvalidate.Reset();
243 IFWL_ListItem* hOld = GetSelItem(0);
244 int32_t iOld = pData->GetItemIndex(m_pInterface, hOld);
245 if (iOld == iSel) {
246 return;
247 } else if (iOld > -1) {
248 GetItemRect(iOld, rtInvalidate);
249 SetSelItem(hOld, FALSE);
250 }
251 if (hItem) {
252 CFX_RectF rect;
253 GetItemRect(iSel, rect);
254 rtInvalidate.Union(rect);
255 IFWL_ListItem* hSel = pData->GetItem(m_pInterface, iSel);
256 SetSelItem(hSel, TRUE);
257 }
258 if (!rtInvalidate.IsEmpty()) {
259 Repaint(&rtInvalidate);
260 }
261 }
262 int32_t CFWL_ComboListImp::CountItems() {
263 IFWL_ListBoxDP* pData =
264 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
265 return pData ? pData->CountItems(m_pInterface) : 0;
266 }
267 void CFWL_ComboListImp::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) {
268 IFWL_ListBoxDP* pData =
269 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
270 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, nIndex);
271 pData->GetItemRect(m_pInterface, hItem, rtItem);
272 }
273 void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
274 fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
275 IFWL_Widget* pOwner = GetOwner();
276 if (!pOwner)
277 return;
278 pOwner->TransformTo(m_pOuter, fx, fy);
279 }
280 void CFWL_ComboListImp::SetFocus(FX_BOOL bSet) {
281 CFWL_WidgetImp::SetFocus(bSet);
282 }
283
284 CFWL_ComboListImpDelegate::CFWL_ComboListImpDelegate(CFWL_ComboListImp* pOwner)
285 : CFWL_ListBoxImpDelegate(pOwner), m_pOwner(pOwner) {}
286
287 void CFWL_ComboListImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
288 if (!pMessage)
289 return;
290
291 CFWL_MessageType dwHashCode = pMessage->GetClassID();
292 FX_BOOL backDefault = TRUE;
293 if (dwHashCode == CFWL_MessageType::SetFocus ||
294 dwHashCode == CFWL_MessageType::KillFocus) {
295 OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus);
296 } else if (dwHashCode == CFWL_MessageType::Mouse) {
297 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
298 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
299 CFX_RectF rect;
300 m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
301 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
302 pMsg->m_fx -= rect.left;
303 pMsg->m_fy -= rect.top;
304 IFWL_WidgetDelegate* pDelegate =
305 m_pOwner->m_pVertScrollBar->SetDelegate(nullptr);
306 pDelegate->OnProcessMessage(pMsg);
307 return;
308 }
309 }
310 switch (pMsg->m_dwCmd) {
311 case FWL_MouseCommand::Move: {
312 backDefault = FALSE;
313 OnDropListMouseMove(pMsg);
314 break;
315 }
316 case FWL_MouseCommand::LeftButtonDown: {
317 backDefault = FALSE;
318 OnDropListLButtonDown(pMsg);
319 break;
320 }
321 case FWL_MouseCommand::LeftButtonUp: {
322 backDefault = FALSE;
323 OnDropListLButtonUp(pMsg);
324 break;
325 }
326 default:
327 break;
328 }
329 } else if (dwHashCode == CFWL_MessageType::Key) {
330 backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage));
331 }
332 if (backDefault)
333 CFWL_ListBoxImpDelegate::OnProcessMessage(pMessage);
334 }
335
336 void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg,
337 FX_BOOL bSet) {
338 if (!bSet) {
339 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg);
340 CFWL_ComboBoxImp* pOuter =
341 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
342 if (pKill->m_pSetFocus == m_pOwner->m_pOuter ||
343 pKill->m_pSetFocus == pOuter->m_pEdit.get()) {
344 pOuter->ShowDropList(FALSE);
345 }
346 }
347 }
348 int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
349 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
350 if (m_pOwner->m_bNotifyOwner) {
351 m_pOwner->m_bNotifyOwner = FALSE;
352 }
353 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
354 CFX_RectF rect;
355 m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
356 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
357 return 1;
358 }
359 }
360 IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
361 if (hItem) {
362 if (!m_pOwner->m_pProperties->m_pDataProvider)
363 return 0;
364 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(
365 m_pOwner->m_pProperties->m_pDataProvider);
366 int32_t iSel = pData->GetItemIndex(m_pOwner->m_pInterface, hItem);
367 CFWL_EvtCmbHoverChanged event;
368 event.m_pSrcTarget = m_pOwner->m_pOuter;
369 event.m_iCurHover = iSel;
370 m_pOwner->DispatchEvent(&event);
371 m_pOwner->ChangeSelected(iSel);
372 }
373 } else if (m_pOwner->m_bNotifyOwner) {
374 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
375 CFWL_ComboBoxImp* pOuter =
376 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
377 pOuter->m_pDelegate->OnProcessMessage(pMsg);
378 }
379 return 1;
380 }
381 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
382 if (m_pOwner->m_rtClient.Contains(pMsg->m_fx, pMsg->m_fy)) {
383 return 0;
384 }
385 CFWL_ComboBoxImp* pOuter =
386 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
387 pOuter->ShowDropList(FALSE);
388 return 1;
389 }
390 int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
391 CFWL_ComboBoxImp* pOuter =
392 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
393 if (m_pOwner->m_bNotifyOwner) {
394 m_pOwner->ClientToOuter(pMsg->m_fx, pMsg->m_fy);
395 pOuter->m_pDelegate->OnProcessMessage(pMsg);
396 } else {
397 if (m_pOwner->IsShowScrollBar(TRUE) && m_pOwner->m_pVertScrollBar) {
398 CFX_RectF rect;
399 m_pOwner->m_pVertScrollBar->GetWidgetRect(rect);
400 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
401 return 1;
402 }
403 }
404 pOuter->ShowDropList(FALSE);
405 IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
406 if (hItem) {
407 pOuter->ProcessSelChanged(TRUE);
408 }
409 }
410 return 1;
411 }
412 int32_t CFWL_ComboListImpDelegate::OnDropListKey(CFWL_MsgKey* pKey) {
413 CFWL_ComboBoxImp* pOuter =
414 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
415 FX_BOOL bPropagate = FALSE;
416 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
417 uint32_t dwKeyCode = pKey->m_dwKeyCode;
418 switch (dwKeyCode) {
419 case FWL_VKEY_Return:
420 case FWL_VKEY_Escape: {
421 pOuter->ShowDropList(FALSE);
422 return 1;
423 }
424 case FWL_VKEY_Up:
425 case FWL_VKEY_Down: {
426 OnDropListKeyDown(pKey);
427 pOuter->SetDelegate(nullptr);
428 pOuter->ProcessSelChanged(FALSE);
429 return 1;
430 }
431 default: { bPropagate = TRUE; }
432 }
433 } else if (pKey->m_dwCmd == FWL_KeyCommand::Char) {
434 bPropagate = TRUE;
435 }
436 if (bPropagate) {
437 pKey->m_pDstTarget = m_pOwner->m_pOuter;
438 pOuter->m_pDelegate->OnProcessMessage(pKey);
439 return 1;
440 }
441 return 0;
442 }
443 void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) {
444 uint32_t dwKeyCode = pKey->m_dwKeyCode;
445 switch (dwKeyCode) {
446 case FWL_VKEY_Up:
447 case FWL_VKEY_Down:
448 case FWL_VKEY_Home:
449 case FWL_VKEY_End: {
450 CFWL_ComboBoxImp* pOuter =
451 static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl());
452 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(
453 m_pOwner->m_pProperties->m_pDataProvider);
454 IFWL_ListItem* hItem =
455 pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel);
456 hItem = m_pOwner->GetItem(hItem, dwKeyCode);
457 if (!hItem) {
458 break;
459 }
460 m_pOwner->SetSelection(hItem, hItem, TRUE);
461 m_pOwner->ScrollToVisible(hItem);
462 CFX_RectF rtInvalidate;
463 rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width,
464 m_pOwner->m_pProperties->m_rtWidget.height);
465 m_pOwner->Repaint(&rtInvalidate);
466 break;
467 }
468 default: {}
469 }
470 }
471 CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties,
472 IFWL_Widget* pOuter)
473 : CFWL_WidgetImp(properties, pOuter),
474 m_pForm(nullptr), 32 m_pForm(nullptr),
475 m_bLButtonDown(FALSE), 33 m_bLButtonDown(FALSE),
476 m_iCurSel(-1), 34 m_iCurSel(-1),
477 m_iBtnState(CFWL_PartState_Normal), 35 m_iBtnState(CFWL_PartState_Normal),
478 m_fComboFormHandler(0), 36 m_fComboFormHandler(0),
479 m_bNeedShowList(FALSE) { 37 m_bNeedShowList(FALSE) {
480 m_rtClient.Reset(); 38 m_rtClient.Reset();
481 m_rtBtn.Reset(); 39 m_rtBtn.Reset();
482 m_rtHandler.Reset(); 40 m_rtHandler.Reset();
483 } 41 }
484 42
485 CFWL_ComboBoxImp::~CFWL_ComboBoxImp() {} 43 IFWL_ComboBox::~IFWL_ComboBox() {}
486 44
487 FWL_Error CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const { 45 FWL_Error IFWL_ComboBox::GetClassName(CFX_WideString& wsClass) const {
488 wsClass = FWL_CLASS_ComboBox; 46 wsClass = FWL_CLASS_ComboBox;
489 return FWL_Error::Succeeded; 47 return FWL_Error::Succeeded;
490 } 48 }
491 49
492 FWL_Type CFWL_ComboBoxImp::GetClassID() const { 50 FWL_Type IFWL_ComboBox::GetClassID() const {
493 return FWL_Type::ComboBox; 51 return FWL_Type::ComboBox;
494 } 52 }
495 53
496 FWL_Error CFWL_ComboBoxImp::Initialize() { 54 FWL_Error IFWL_ComboBox::Initialize() {
497 if (m_pWidgetMgr->IsFormDisabled()) 55 if (m_pWidgetMgr->IsFormDisabled())
498 return DisForm_Initialize(); 56 return DisForm_Initialize();
499 57
500 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 58 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
501 return FWL_Error::Indefinite; 59 return FWL_Error::Indefinite;
502 60
503 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); 61 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
504 CFWL_WidgetImpProperties prop; 62 CFWL_WidgetImpProperties prop;
505 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 63 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
506 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 64 prop.m_dwStyles |= FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
507 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText) 65 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_ListItemIconText)
508 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon; 66 prop.m_dwStyleExes |= FWL_STYLEEXT_LTB_Icon;
509 67
510 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 68 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
511 m_pListBox.reset(IFWL_ListBox::CreateComboList(prop, m_pInterface)); 69 m_pListBox.reset(IFWL_ComboList::Create(prop, this));
512 m_pListBox->Initialize(); 70 m_pListBox->Initialize();
513 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { 71 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
514 CFWL_WidgetImpProperties prop2; 72 CFWL_WidgetImpProperties prop2;
515 m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop2, m_pInterface)); 73 m_pEdit.reset(IFWL_ComboEdit::Create(prop2, this));
516 m_pEdit->Initialize(); 74 m_pEdit->Initialize();
517 static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); 75 m_pEdit->SetOuter(this);
518 } 76 }
519 if (m_pEdit) 77 if (m_pEdit)
520 m_pEdit->SetParent(m_pInterface); 78 m_pEdit->SetParent(this);
521 79
522 SetStates(m_pProperties->m_dwStates); 80 SetStates(m_pProperties->m_dwStates);
523 return FWL_Error::Succeeded; 81 return FWL_Error::Succeeded;
524 } 82 }
525 83
526 FWL_Error CFWL_ComboBoxImp::Finalize() { 84 FWL_Error IFWL_ComboBox::Finalize() {
527 if (m_pEdit) { 85 if (m_pEdit) {
528 m_pEdit->Finalize(); 86 m_pEdit->Finalize();
529 } 87 }
530 m_pListBox->Finalize(); 88 m_pListBox->Finalize();
531 delete m_pDelegate; 89 delete m_pDelegate;
532 m_pDelegate = nullptr; 90 m_pDelegate = nullptr;
533 return CFWL_WidgetImp::Finalize(); 91 return IFWL_Widget::Finalize();
534 } 92 }
535 FWL_Error CFWL_ComboBoxImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 93
94 FWL_Error IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
536 if (bAutoSize) { 95 if (bAutoSize) {
537 rect.Reset(); 96 rect.Reset();
538 FX_BOOL bIsDropDown = IsDropDownStyle(); 97 FX_BOOL bIsDropDown = IsDropDownStyle();
539 if (bIsDropDown && m_pEdit) { 98 if (bIsDropDown && m_pEdit) {
540 m_pEdit->GetWidgetRect(rect, TRUE); 99 m_pEdit->GetWidgetRect(rect, TRUE);
541 } else { 100 } else {
542 rect.width = 100; 101 rect.width = 100;
543 rect.height = 16; 102 rect.height = 16;
544 } 103 }
545 if (!m_pProperties->m_pThemeProvider) { 104 if (!m_pProperties->m_pThemeProvider) {
546 ReSetTheme(); 105 ReSetTheme();
547 } 106 }
548 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 107 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
549 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 108 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
550 if (!pFWidth) 109 if (!pFWidth)
551 return FWL_Error::Indefinite; 110 return FWL_Error::Indefinite;
552 rect.Inflate(0, 0, *pFWidth, 0); 111 rect.Inflate(0, 0, *pFWidth, 0);
553 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); 112 IFWL_Widget::GetWidgetRect(rect, TRUE);
554 } else { 113 } else {
555 rect = m_pProperties->m_rtWidget; 114 rect = m_pProperties->m_rtWidget;
556 } 115 }
557 return FWL_Error::Succeeded; 116 return FWL_Error::Succeeded;
558 } 117 }
559 FWL_Error CFWL_ComboBoxImp::ModifyStylesEx(uint32_t dwStylesExAdded, 118
560 uint32_t dwStylesExRemoved) { 119 FWL_Error IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
120 uint32_t dwStylesExRemoved) {
561 if (m_pWidgetMgr->IsFormDisabled()) { 121 if (m_pWidgetMgr->IsFormDisabled()) {
562 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 122 return DisForm_ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
563 } 123 }
564 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 124 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
565 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 125 bool bRemoveDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
566 if (bAddDropDown && !m_pEdit) { 126 if (bAddDropDown && !m_pEdit) {
567 CFWL_WidgetImpProperties prop; 127 CFWL_WidgetImpProperties prop;
568 m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, nullptr)); 128 m_pEdit.reset(IFWL_ComboEdit::Create(prop, nullptr));
569 m_pEdit->Initialize(); 129 m_pEdit->Initialize();
570 static_cast<CFWL_EditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); 130 m_pEdit->SetOuter(this);
571 m_pEdit->SetParent(m_pInterface); 131 m_pEdit->SetParent(this);
572 } else if (bRemoveDropDown && m_pEdit) { 132 } else if (bRemoveDropDown && m_pEdit) {
573 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE); 133 m_pEdit->SetStates(FWL_WGTSTATE_Invisible, TRUE);
574 } 134 }
575 return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 135 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
576 } 136 }
577 FWL_Error CFWL_ComboBoxImp::Update() { 137
138 FWL_Error IFWL_ComboBox::Update() {
578 if (m_pWidgetMgr->IsFormDisabled()) { 139 if (m_pWidgetMgr->IsFormDisabled()) {
579 return DisForm_Update(); 140 return DisForm_Update();
580 } 141 }
581 if (IsLocked()) { 142 if (IsLocked()) {
582 return FWL_Error::Indefinite; 143 return FWL_Error::Indefinite;
583 } 144 }
584 ReSetTheme(); 145 ReSetTheme();
585 FX_BOOL bDropDown = IsDropDownStyle(); 146 FX_BOOL bDropDown = IsDropDownStyle();
586 if (bDropDown && m_pEdit) { 147 if (bDropDown && m_pEdit) {
587 ReSetEditAlignment(); 148 ReSetEditAlignment();
588 } 149 }
589 if (!m_pProperties->m_pThemeProvider) { 150 if (!m_pProperties->m_pThemeProvider) {
590 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 151 m_pProperties->m_pThemeProvider = GetAvailableTheme();
591 } 152 }
592 Layout(); 153 Layout();
593 CFWL_ThemePart part; 154 CFWL_ThemePart part;
594 part.m_pWidget = m_pInterface; 155 part.m_pWidget = this;
595 m_fComboFormHandler = 156 m_fComboFormHandler =
596 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity( 157 *static_cast<FX_FLOAT*>(m_pProperties->m_pThemeProvider->GetCapacity(
597 &part, CFWL_WidgetCapacity::ComboFormHandler)); 158 &part, CFWL_WidgetCapacity::ComboFormHandler));
598 return FWL_Error::Succeeded; 159 return FWL_Error::Succeeded;
599 } 160 }
600 FWL_WidgetHit CFWL_ComboBoxImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 161
162 FWL_WidgetHit IFWL_ComboBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
601 if (m_pWidgetMgr->IsFormDisabled()) { 163 if (m_pWidgetMgr->IsFormDisabled()) {
602 return DisForm_HitTest(fx, fy); 164 return DisForm_HitTest(fx, fy);
603 } 165 }
604 return CFWL_WidgetImp::HitTest(fx, fy); 166 return IFWL_Widget::HitTest(fx, fy);
605 } 167 }
606 FWL_Error CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics, 168
607 const CFX_Matrix* pMatrix) { 169 FWL_Error IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics,
170 const CFX_Matrix* pMatrix) {
608 if (m_pWidgetMgr->IsFormDisabled()) { 171 if (m_pWidgetMgr->IsFormDisabled()) {
609 return DisForm_DrawWidget(pGraphics, pMatrix); 172 return DisForm_DrawWidget(pGraphics, pMatrix);
610 } 173 }
611 if (!pGraphics) 174 if (!pGraphics)
612 return FWL_Error::Indefinite; 175 return FWL_Error::Indefinite;
613 if (!m_pProperties->m_pThemeProvider) 176 if (!m_pProperties->m_pThemeProvider)
614 return FWL_Error::Indefinite; 177 return FWL_Error::Indefinite;
615 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 178 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
616 FX_BOOL bIsDropDown = IsDropDownStyle(); 179 FX_BOOL bIsDropDown = IsDropDownStyle();
617 if (HasBorder()) { 180 if (HasBorder()) {
618 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 181 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
619 } 182 }
620 if (HasEdge()) { 183 if (HasEdge()) {
621 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 184 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
622 } 185 }
623 if (!bIsDropDown) { 186 if (!bIsDropDown) {
624 CFX_RectF rtTextBk(m_rtClient); 187 CFX_RectF rtTextBk(m_rtClient);
625 rtTextBk.width -= m_rtBtn.width; 188 rtTextBk.width -= m_rtBtn.width;
626 CFWL_ThemeBackground param; 189 CFWL_ThemeBackground param;
627 param.m_pWidget = m_pInterface; 190 param.m_pWidget = this;
628 param.m_iPart = CFWL_Part::Background; 191 param.m_iPart = CFWL_Part::Background;
629 param.m_pGraphics = pGraphics; 192 param.m_pGraphics = pGraphics;
630 if (pMatrix) { 193 if (pMatrix) {
631 param.m_matrix.Concat(*pMatrix); 194 param.m_matrix.Concat(*pMatrix);
632 } 195 }
633 param.m_rtPart = rtTextBk; 196 param.m_rtPart = rtTextBk;
634 if (m_iCurSel >= 0) { 197 if (m_iCurSel >= 0) {
635 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( 198 IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(
636 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 199 m_pListBox->m_pProperties->m_pDataProvider);
637 ->m_pProperties->m_pDataProvider);
638 void* p = pData->GetItemData(m_pListBox.get(), 200 void* p = pData->GetItemData(m_pListBox.get(),
639 pData->GetItem(m_pListBox.get(), m_iCurSel)); 201 pData->GetItem(m_pListBox.get(), m_iCurSel));
640 if (p) { 202 if (p) {
641 param.m_pData = p; 203 param.m_pData = p;
642 } 204 }
643 } 205 }
644 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 206 if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
645 param.m_dwStates = CFWL_PartState_Disabled; 207 param.m_dwStates = CFWL_PartState_Disabled;
646 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && 208 } else if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) &&
647 (m_iCurSel >= 0)) { 209 (m_iCurSel >= 0)) {
648 param.m_dwStates = CFWL_PartState_Selected; 210 param.m_dwStates = CFWL_PartState_Selected;
649 } else { 211 } else {
650 param.m_dwStates = CFWL_PartState_Normal; 212 param.m_dwStates = CFWL_PartState_Normal;
651 } 213 }
652 pTheme->DrawBackground(&param); 214 pTheme->DrawBackground(&param);
653 if (m_iCurSel >= 0) { 215 if (m_iCurSel >= 0) {
654 if (!m_pListBox) 216 if (!m_pListBox)
655 return FWL_Error::Indefinite; 217 return FWL_Error::Indefinite;
656 CFX_WideString wsText; 218 CFX_WideString wsText;
657 IFWL_ComboBoxDP* pData = 219 IFWL_ComboBoxDP* pData =
658 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 220 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
659 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); 221 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
660 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 222 m_pListBox->GetItemText(hItem, wsText);
661 ->GetItemText(hItem, wsText);
662 CFWL_ThemeText theme_text; 223 CFWL_ThemeText theme_text;
663 theme_text.m_pWidget = m_pInterface; 224 theme_text.m_pWidget = this;
664 theme_text.m_iPart = CFWL_Part::Caption; 225 theme_text.m_iPart = CFWL_Part::Caption;
665 theme_text.m_dwStates = m_iBtnState; 226 theme_text.m_dwStates = m_iBtnState;
666 theme_text.m_pGraphics = pGraphics; 227 theme_text.m_pGraphics = pGraphics;
667 theme_text.m_matrix.Concat(*pMatrix); 228 theme_text.m_matrix.Concat(*pMatrix);
668 theme_text.m_rtPart = rtTextBk; 229 theme_text.m_rtPart = rtTextBk;
669 theme_text.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) 230 theme_text.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
670 ? CFWL_PartState_Selected 231 ? CFWL_PartState_Selected
671 : CFWL_PartState_Normal; 232 : CFWL_PartState_Normal;
672 theme_text.m_wsText = wsText; 233 theme_text.m_wsText = wsText;
673 theme_text.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; 234 theme_text.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine;
674 theme_text.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; 235 theme_text.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft;
675 pTheme->DrawText(&theme_text); 236 pTheme->DrawText(&theme_text);
676 } 237 }
677 } 238 }
678 { 239 {
679 CFWL_ThemeBackground param; 240 CFWL_ThemeBackground param;
680 param.m_pWidget = m_pInterface; 241 param.m_pWidget = this;
681 param.m_iPart = CFWL_Part::DropDownButton; 242 param.m_iPart = CFWL_Part::DropDownButton;
682 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) 243 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)
683 ? CFWL_PartState_Disabled 244 ? CFWL_PartState_Disabled
684 : m_iBtnState; 245 : m_iBtnState;
685 param.m_pGraphics = pGraphics; 246 param.m_pGraphics = pGraphics;
686 param.m_matrix.Concat(*pMatrix); 247 param.m_matrix.Concat(*pMatrix);
687 param.m_rtPart = m_rtBtn; 248 param.m_rtPart = m_rtBtn;
688 pTheme->DrawBackground(&param); 249 pTheme->DrawBackground(&param);
689 } 250 }
690 return FWL_Error::Succeeded; 251 return FWL_Error::Succeeded;
691 } 252 }
692 FWL_Error CFWL_ComboBoxImp::SetThemeProvider( 253
693 IFWL_ThemeProvider* pThemeProvider) { 254 FWL_Error IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
694 if (!pThemeProvider) 255 if (!pThemeProvider)
695 return FWL_Error::Indefinite; 256 return FWL_Error::Indefinite;
696 m_pProperties->m_pThemeProvider = pThemeProvider; 257 m_pProperties->m_pThemeProvider = pThemeProvider;
697 if (m_pListBox) 258 if (m_pListBox)
698 m_pListBox->SetThemeProvider(pThemeProvider); 259 m_pListBox->SetThemeProvider(pThemeProvider);
699 if (m_pEdit) 260 if (m_pEdit)
700 m_pEdit->SetThemeProvider(pThemeProvider); 261 m_pEdit->SetThemeProvider(pThemeProvider);
701 return FWL_Error::Succeeded; 262 return FWL_Error::Succeeded;
702 } 263 }
703 int32_t CFWL_ComboBoxImp::GetCurSel() { 264
265 int32_t IFWL_ComboBox::GetCurSel() {
704 return m_iCurSel; 266 return m_iCurSel;
705 } 267 }
706 FWL_Error CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { 268
707 int32_t iCount = 269 FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) {
708 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->CountItems(); 270 int32_t iCount = m_pListBox->CountItems();
709 FX_BOOL bClearSel = iSel < 0 || iSel >= iCount; 271 FX_BOOL bClearSel = iSel < 0 || iSel >= iCount;
710 FX_BOOL bDropDown = IsDropDownStyle(); 272 FX_BOOL bDropDown = IsDropDownStyle();
711 if (bDropDown && m_pEdit) { 273 if (bDropDown && m_pEdit) {
712 if (bClearSel) { 274 if (bClearSel) {
713 m_pEdit->SetText(CFX_WideString()); 275 m_pEdit->SetText(CFX_WideString());
714 } else { 276 } else {
715 CFX_WideString wsText; 277 CFX_WideString wsText;
716 IFWL_ComboBoxDP* pData = 278 IFWL_ComboBoxDP* pData =
717 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 279 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
718 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iSel); 280 IFWL_ListItem* hItem = pData->GetItem(this, iSel);
719 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 281 m_pListBox->GetItemText(hItem, wsText);
720 ->GetItemText(hItem, wsText);
721 m_pEdit->SetText(wsText); 282 m_pEdit->SetText(wsText);
722 } 283 }
723 m_pEdit->Update(); 284 m_pEdit->Update();
724 } 285 }
725 m_iCurSel = bClearSel ? -1 : iSel; 286 m_iCurSel = bClearSel ? -1 : iSel;
726 return FWL_Error::Succeeded; 287 return FWL_Error::Succeeded;
727 } 288 }
728 289
729 void CFWL_ComboBoxImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { 290 void IFWL_ComboBox::SetStates(uint32_t dwStates, FX_BOOL bSet) {
730 FX_BOOL bIsDropDown = IsDropDownStyle(); 291 FX_BOOL bIsDropDown = IsDropDownStyle();
731 if (bIsDropDown && m_pEdit) 292 if (bIsDropDown && m_pEdit)
732 m_pEdit->SetStates(dwStates, bSet); 293 m_pEdit->SetStates(dwStates, bSet);
733 if (m_pListBox) 294 if (m_pListBox)
734 m_pListBox->SetStates(dwStates, bSet); 295 m_pListBox->SetStates(dwStates, bSet);
735 CFWL_WidgetImp::SetStates(dwStates, bSet); 296 IFWL_Widget::SetStates(dwStates, bSet);
736 } 297 }
737 298
738 FWL_Error CFWL_ComboBoxImp::SetEditText(const CFX_WideString& wsText) { 299 FWL_Error IFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
739 if (!m_pEdit) 300 if (!m_pEdit)
740 return FWL_Error::Indefinite; 301 return FWL_Error::Indefinite;
741 m_pEdit->SetText(wsText); 302 m_pEdit->SetText(wsText);
742 return m_pEdit->Update(); 303 return m_pEdit->Update();
743 } 304 }
744 int32_t CFWL_ComboBoxImp::GetEditTextLength() const { 305
306 int32_t IFWL_ComboBox::GetEditTextLength() const {
745 if (!m_pEdit) 307 if (!m_pEdit)
746 return -1; 308 return -1;
747 return m_pEdit->GetTextLength(); 309 return m_pEdit->GetTextLength();
748 } 310 }
749 FWL_Error CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText, 311
750 int32_t nStart, 312 FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
751 int32_t nCount) const { 313 int32_t nStart,
314 int32_t nCount) const {
752 if (m_pEdit) { 315 if (m_pEdit) {
753 return m_pEdit->GetText(wsText, nStart, nCount); 316 return m_pEdit->GetText(wsText, nStart, nCount);
754 } else if (m_pListBox) { 317 } else if (m_pListBox) {
755 IFWL_ComboBoxDP* pData = 318 IFWL_ComboBoxDP* pData =
756 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 319 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
757 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); 320 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
758 return m_pListBox->GetItemText(hItem, wsText); 321 return m_pListBox->GetItemText(hItem, wsText);
759 } 322 }
760 return FWL_Error::Indefinite; 323 return FWL_Error::Indefinite;
761 } 324 }
762 FWL_Error CFWL_ComboBoxImp::SetEditSelRange(int32_t nStart, int32_t nCount) { 325
326 FWL_Error IFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
763 if (!m_pEdit) 327 if (!m_pEdit)
764 return FWL_Error::Indefinite; 328 return FWL_Error::Indefinite;
765 static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->ClearSelected(); 329 m_pEdit->ClearSelected();
766 m_pEdit->AddSelRange(nStart, nCount); 330 m_pEdit->AddSelRange(nStart, nCount);
767 return FWL_Error::Succeeded; 331 return FWL_Error::Succeeded;
768 } 332 }
769 int32_t CFWL_ComboBoxImp::GetEditSelRange(int32_t nIndex, int32_t& nStart) { 333
334 int32_t IFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
770 if (!m_pEdit) 335 if (!m_pEdit)
771 return -1; 336 return -1;
772 return m_pEdit->GetSelRange(nIndex, nStart); 337 return m_pEdit->GetSelRange(nIndex, nStart);
773 } 338 }
774 int32_t CFWL_ComboBoxImp::GetEditLimit() { 339
340 int32_t IFWL_ComboBox::GetEditLimit() {
775 if (!m_pEdit) 341 if (!m_pEdit)
776 return -1; 342 return -1;
777 return m_pEdit->GetLimit(); 343 return m_pEdit->GetLimit();
778 } 344 }
779 FWL_Error CFWL_ComboBoxImp::SetEditLimit(int32_t nLimit) { 345
346 FWL_Error IFWL_ComboBox::SetEditLimit(int32_t nLimit) {
780 if (!m_pEdit) 347 if (!m_pEdit)
781 return FWL_Error::Indefinite; 348 return FWL_Error::Indefinite;
782 return m_pEdit->SetLimit(nLimit); 349 return m_pEdit->SetLimit(nLimit);
783 } 350 }
784 FWL_Error CFWL_ComboBoxImp::EditDoClipboard(int32_t iCmd) { 351
352 FWL_Error IFWL_ComboBox::EditDoClipboard(int32_t iCmd) {
785 if (!m_pEdit) 353 if (!m_pEdit)
786 return FWL_Error::Indefinite; 354 return FWL_Error::Indefinite;
787 return m_pEdit->DoClipboard(iCmd); 355 return m_pEdit->DoClipboard(iCmd);
788 } 356 }
789 357
790 FX_BOOL CFWL_ComboBoxImp::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) { 358 FX_BOOL IFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
791 return m_pEdit && m_pEdit->Redo(pRecord); 359 return m_pEdit && m_pEdit->Redo(pRecord);
792 } 360 }
793 361
794 FX_BOOL CFWL_ComboBoxImp::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) { 362 FX_BOOL IFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
795 return m_pEdit && m_pEdit->Undo(pRecord); 363 return m_pEdit && m_pEdit->Undo(pRecord);
796 } 364 }
797 365
798 IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { 366 IFWL_ListBox* IFWL_ComboBox::GetListBoxt() {
799 return m_pListBox.get(); 367 return m_pListBox.get();
800 } 368 }
801 FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { 369
370 FX_BOOL IFWL_ComboBox::AfterFocusShowDropList() {
802 if (!m_bNeedShowList) { 371 if (!m_bNeedShowList) {
803 return FALSE; 372 return FALSE;
804 } 373 }
805 if (m_pEdit) { 374 if (m_pEdit) {
806 MatchEditText(); 375 MatchEditText();
807 } 376 }
808 ShowDropList(TRUE); 377 ShowDropList(TRUE);
809 m_bNeedShowList = FALSE; 378 m_bNeedShowList = FALSE;
810 return TRUE; 379 return TRUE;
811 } 380 }
812 FWL_Error CFWL_ComboBoxImp::OpenDropDownList(FX_BOOL bActivate) { 381
382 FWL_Error IFWL_ComboBox::OpenDropDownList(FX_BOOL bActivate) {
813 ShowDropList(bActivate); 383 ShowDropList(bActivate);
814 return FWL_Error::Succeeded; 384 return FWL_Error::Succeeded;
815 } 385 }
816 FX_BOOL CFWL_ComboBoxImp::EditCanUndo() { 386
387 FX_BOOL IFWL_ComboBox::EditCanUndo() {
817 return m_pEdit->CanUndo(); 388 return m_pEdit->CanUndo();
818 } 389 }
819 FX_BOOL CFWL_ComboBoxImp::EditCanRedo() { 390
391 FX_BOOL IFWL_ComboBox::EditCanRedo() {
820 return m_pEdit->CanRedo(); 392 return m_pEdit->CanRedo();
821 } 393 }
822 FX_BOOL CFWL_ComboBoxImp::EditUndo() { 394
395 FX_BOOL IFWL_ComboBox::EditUndo() {
823 return m_pEdit->Undo(); 396 return m_pEdit->Undo();
824 } 397 }
825 FX_BOOL CFWL_ComboBoxImp::EditRedo() { 398
399 FX_BOOL IFWL_ComboBox::EditRedo() {
826 return m_pEdit->Redo(); 400 return m_pEdit->Redo();
827 } 401 }
828 FX_BOOL CFWL_ComboBoxImp::EditCanCopy() { 402
403 FX_BOOL IFWL_ComboBox::EditCanCopy() {
829 return m_pEdit->CountSelRanges() > 0; 404 return m_pEdit->CountSelRanges() > 0;
830 } 405 }
831 FX_BOOL CFWL_ComboBoxImp::EditCanCut() { 406
407 FX_BOOL IFWL_ComboBox::EditCanCut() {
832 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) { 408 if (m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
833 return FALSE; 409 return FALSE;
834 } 410 }
835 return m_pEdit->CountSelRanges() > 0; 411 return m_pEdit->CountSelRanges() > 0;
836 } 412 }
837 FX_BOOL CFWL_ComboBoxImp::EditCanSelectAll() { 413
414 FX_BOOL IFWL_ComboBox::EditCanSelectAll() {
838 return m_pEdit->GetTextLength() > 0; 415 return m_pEdit->GetTextLength() > 0;
839 } 416 }
840 FX_BOOL CFWL_ComboBoxImp::EditCopy(CFX_WideString& wsCopy) { 417
418 FX_BOOL IFWL_ComboBox::EditCopy(CFX_WideString& wsCopy) {
841 return m_pEdit->Copy(wsCopy); 419 return m_pEdit->Copy(wsCopy);
842 } 420 }
843 FX_BOOL CFWL_ComboBoxImp::EditCut(CFX_WideString& wsCut) { 421
422 FX_BOOL IFWL_ComboBox::EditCut(CFX_WideString& wsCut) {
844 return m_pEdit->Cut(wsCut); 423 return m_pEdit->Cut(wsCut);
845 } 424 }
846 FX_BOOL CFWL_ComboBoxImp::EditPaste(const CFX_WideString& wsPaste) { 425
426 FX_BOOL IFWL_ComboBox::EditPaste(const CFX_WideString& wsPaste) {
847 return m_pEdit->Paste(wsPaste); 427 return m_pEdit->Paste(wsPaste);
848 } 428 }
849 FX_BOOL CFWL_ComboBoxImp::EditSelectAll() { 429
430 FX_BOOL IFWL_ComboBox::EditSelectAll() {
850 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded; 431 return m_pEdit->AddSelRange(0) == FWL_Error::Succeeded;
851 } 432 }
852 FX_BOOL CFWL_ComboBoxImp::EditDelete() { 433
434 FX_BOOL IFWL_ComboBox::EditDelete() {
853 return m_pEdit->ClearText() == FWL_Error::Succeeded; 435 return m_pEdit->ClearText() == FWL_Error::Succeeded;
854 } 436 }
855 FX_BOOL CFWL_ComboBoxImp::EditDeSelect() { 437
438 FX_BOOL IFWL_ComboBox::EditDeSelect() {
856 return m_pEdit->ClearSelections() == FWL_Error::Succeeded; 439 return m_pEdit->ClearSelections() == FWL_Error::Succeeded;
857 } 440 }
858 FWL_Error CFWL_ComboBoxImp::GetBBox(CFX_RectF& rect) { 441
442 FWL_Error IFWL_ComboBox::GetBBox(CFX_RectF& rect) {
859 if (m_pWidgetMgr->IsFormDisabled()) { 443 if (m_pWidgetMgr->IsFormDisabled()) {
860 return DisForm_GetBBox(rect); 444 return DisForm_GetBBox(rect);
861 } 445 }
862 rect = m_pProperties->m_rtWidget; 446 rect = m_pProperties->m_rtWidget;
863 if (m_pListBox && IsDropListShowed()) { 447 if (m_pListBox && IsDropListShowed()) {
864 CFX_RectF rtList; 448 CFX_RectF rtList;
865 m_pListBox->GetWidgetRect(rtList); 449 m_pListBox->GetWidgetRect(rtList);
866 rtList.Offset(rect.left, rect.top); 450 rtList.Offset(rect.left, rect.top);
867 rect.Union(rtList); 451 rect.Union(rtList);
868 } 452 }
869 return FWL_Error::Succeeded; 453 return FWL_Error::Succeeded;
870 } 454 }
871 455
872 FWL_Error CFWL_ComboBoxImp::EditModifyStylesEx(uint32_t dwStylesExAdded, 456 FWL_Error IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
873 uint32_t dwStylesExRemoved) { 457 uint32_t dwStylesExRemoved) {
874 if (!m_pEdit) 458 if (!m_pEdit)
875 return FWL_Error::ParameterInvalid; 459 return FWL_Error::ParameterInvalid;
876 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 460 return m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
877 } 461 }
878 462
879 FX_FLOAT CFWL_ComboBoxImp::GetListHeight() { 463 FX_FLOAT IFWL_ComboBox::GetListHeight() {
880 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider) 464 return static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider)
881 ->GetListHeight(m_pInterface); 465 ->GetListHeight(this);
882 } 466 }
883 void CFWL_ComboBoxImp::DrawStretchHandler(CFX_Graphics* pGraphics, 467
884 const CFX_Matrix* pMatrix) { 468 void IFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics,
469 const CFX_Matrix* pMatrix) {
885 CFWL_ThemeBackground param; 470 CFWL_ThemeBackground param;
886 param.m_pGraphics = pGraphics; 471 param.m_pGraphics = pGraphics;
887 param.m_iPart = CFWL_Part::StretchHandler; 472 param.m_iPart = CFWL_Part::StretchHandler;
888 param.m_dwStates = CFWL_PartState_Normal; 473 param.m_dwStates = CFWL_PartState_Normal;
889 param.m_pWidget = m_pInterface; 474 param.m_pWidget = this;
890 if (pMatrix) { 475 if (pMatrix) {
891 param.m_matrix.Concat(*pMatrix); 476 param.m_matrix.Concat(*pMatrix);
892 } 477 }
893 param.m_rtPart = m_rtHandler; 478 param.m_rtPart = m_rtHandler;
894 m_pProperties->m_pThemeProvider->DrawBackground(&param); 479 m_pProperties->m_pThemeProvider->DrawBackground(&param);
895 } 480 }
896 void CFWL_ComboBoxImp::ShowDropList(FX_BOOL bActivate) { 481
482 void IFWL_ComboBox::ShowDropList(FX_BOOL bActivate) {
897 if (m_pWidgetMgr->IsFormDisabled()) { 483 if (m_pWidgetMgr->IsFormDisabled()) {
898 return DisForm_ShowDropList(bActivate); 484 return DisForm_ShowDropList(bActivate);
899 } 485 }
900 FX_BOOL bDropList = IsDropListShowed(); 486 FX_BOOL bDropList = IsDropListShowed();
901 if (bDropList == bActivate) { 487 if (bDropList == bActivate) {
902 return; 488 return;
903 } 489 }
904 if (!m_pForm) { 490 if (!m_pForm) {
905 InitProxyForm(); 491 InitProxyForm();
906 } 492 }
907 m_pListProxyDelegate->Reset(); 493 m_pListProxyDelegate->Reset();
908 if (bActivate) { 494 if (bActivate) {
909 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 495 m_pListBox->ChangeSelected(m_iCurSel);
910 ->ChangeSelected(m_iCurSel);
911 ReSetListItemAlignment(); 496 ReSetListItemAlignment();
912 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes & 497 uint32_t dwStyleAdd = m_pProperties->m_dwStyleExes &
913 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); 498 (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw);
914 m_pListBox->ModifyStylesEx(dwStyleAdd, 0); 499 m_pListBox->ModifyStylesEx(dwStyleAdd, 0);
915 m_pListBox->GetWidgetRect(m_rtList, TRUE); 500 m_pListBox->GetWidgetRect(m_rtList, TRUE);
916 FX_FLOAT fHeight = GetListHeight(); 501 FX_FLOAT fHeight = GetListHeight();
917 if (fHeight > 0) { 502 if (fHeight > 0) {
918 if (m_rtList.height > GetListHeight()) { 503 if (m_rtList.height > GetListHeight()) {
919 m_rtList.height = GetListHeight(); 504 m_rtList.height = GetListHeight();
920 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); 505 m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0);
(...skipping 22 matching lines...) Expand all
943 } else { 528 } else {
944 m_rtHandler.Set(0, m_rtList.height, m_rtList.width, 529 m_rtHandler.Set(0, m_rtList.height, m_rtList.width,
945 m_fComboFormHandler); 530 m_fComboFormHandler);
946 } 531 }
947 } 532 }
948 m_pForm->SetWidgetRect(m_rtProxy); 533 m_pForm->SetWidgetRect(m_rtProxy);
949 m_pForm->Update(); 534 m_pForm->Update();
950 m_pListBox->SetWidgetRect(m_rtList); 535 m_pListBox->SetWidgetRect(m_rtList);
951 m_pListBox->Update(); 536 m_pListBox->Update();
952 CFWL_EvtCmbPreDropDown ev; 537 CFWL_EvtCmbPreDropDown ev;
953 ev.m_pSrcTarget = m_pInterface; 538 ev.m_pSrcTarget = this;
954 DispatchEvent(&ev); 539 DispatchEvent(&ev);
955 m_fItemHeight = 540 m_fItemHeight = m_pListBox->m_fItemHeight;
956 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_fItemHeight; 541 m_pListBox->SetFocus(TRUE);
957 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(TRUE);
958 m_pForm->DoModal(); 542 m_pForm->DoModal();
959 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->SetFocus(FALSE); 543 m_pListBox->SetFocus(FALSE);
960 } else { 544 } else {
961 m_pForm->EndDoModal(); 545 m_pForm->EndDoModal();
962 CFWL_EvtCmbCloseUp ev; 546 CFWL_EvtCmbCloseUp ev;
963 ev.m_pSrcTarget = m_pInterface; 547 ev.m_pSrcTarget = this;
964 DispatchEvent(&ev); 548 DispatchEvent(&ev);
965 m_bLButtonDown = FALSE; 549 m_bLButtonDown = FALSE;
966 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->m_bNotifyOwner = 550 m_pListBox->m_bNotifyOwner = TRUE;
967 TRUE;
968 SetFocus(TRUE); 551 SetFocus(TRUE);
969 } 552 }
970 } 553 }
971 FX_BOOL CFWL_ComboBoxImp::IsDropListShowed() { 554
555 FX_BOOL IFWL_ComboBox::IsDropListShowed() {
972 return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible); 556 return m_pForm && !(m_pForm->GetStates() & FWL_WGTSTATE_Invisible);
973 } 557 }
974 FX_BOOL CFWL_ComboBoxImp::IsDropDownStyle() const { 558
559 FX_BOOL IFWL_ComboBox::IsDropDownStyle() const {
975 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown; 560 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown;
976 } 561 }
977 void CFWL_ComboBoxImp::MatchEditText() { 562
563 void IFWL_ComboBox::MatchEditText() {
978 CFX_WideString wsText; 564 CFX_WideString wsText;
979 m_pEdit->GetText(wsText); 565 m_pEdit->GetText(wsText);
980 int32_t iMatch = 566 int32_t iMatch = m_pListBox->MatchItem(wsText);
981 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl())->MatchItem(wsText);
982 if (iMatch != m_iCurSel) { 567 if (iMatch != m_iCurSel) {
983 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 568 m_pListBox->ChangeSelected(iMatch);
984 ->ChangeSelected(iMatch);
985 if (iMatch >= 0) { 569 if (iMatch >= 0) {
986 SynchrEditText(iMatch); 570 SynchrEditText(iMatch);
987 } 571 }
988 } else if (iMatch >= 0) { 572 } else if (iMatch >= 0) {
989 static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); 573 m_pEdit->SetSelected();
990 } 574 }
991 m_iCurSel = iMatch; 575 m_iCurSel = iMatch;
992 } 576 }
993 void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem) { 577
578 void IFWL_ComboBox::SynchrEditText(int32_t iListItem) {
994 CFX_WideString wsText; 579 CFX_WideString wsText;
995 IFWL_ComboBoxDP* pData = 580 IFWL_ComboBoxDP* pData =
996 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 581 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
997 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iListItem); 582 IFWL_ListItem* hItem = pData->GetItem(this, iListItem);
998 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 583 m_pListBox->GetItemText(hItem, wsText);
999 ->GetItemText(hItem, wsText);
1000 m_pEdit->SetText(wsText); 584 m_pEdit->SetText(wsText);
1001 m_pEdit->Update(); 585 m_pEdit->Update();
1002 static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); 586 m_pEdit->SetSelected();
1003 } 587 }
1004 void CFWL_ComboBoxImp::Layout() { 588
589 void IFWL_ComboBox::Layout() {
1005 if (m_pWidgetMgr->IsFormDisabled()) { 590 if (m_pWidgetMgr->IsFormDisabled()) {
1006 return DisForm_Layout(); 591 return DisForm_Layout();
1007 } 592 }
1008 GetClientRect(m_rtClient); 593 GetClientRect(m_rtClient);
1009 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 594 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
1010 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 595 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1011 if (!pFWidth) 596 if (!pFWidth)
1012 return; 597 return;
1013 FX_FLOAT fBtn = *pFWidth; 598 FX_FLOAT fBtn = *pFWidth;
1014 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, 599 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn,
1015 m_rtClient.height); 600 m_rtClient.height);
1016 FX_BOOL bIsDropDown = IsDropDownStyle(); 601 FX_BOOL bIsDropDown = IsDropDownStyle();
1017 if (bIsDropDown && m_pEdit) { 602 if (bIsDropDown && m_pEdit) {
1018 CFX_RectF rtEdit; 603 CFX_RectF rtEdit;
1019 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, 604 rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn,
1020 m_rtClient.height); 605 m_rtClient.height);
1021 m_pEdit->SetWidgetRect(rtEdit); 606 m_pEdit->SetWidgetRect(rtEdit);
1022 if (m_iCurSel >= 0) { 607 if (m_iCurSel >= 0) {
1023 CFX_WideString wsText; 608 CFX_WideString wsText;
1024 IFWL_ComboBoxDP* pData = 609 IFWL_ComboBoxDP* pData =
1025 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 610 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
1026 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); 611 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
1027 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 612 m_pListBox->GetItemText(hItem, wsText);
1028 ->GetItemText(hItem, wsText);
1029 m_pEdit->LockUpdate(); 613 m_pEdit->LockUpdate();
1030 m_pEdit->SetText(wsText); 614 m_pEdit->SetText(wsText);
1031 m_pEdit->UnlockUpdate(); 615 m_pEdit->UnlockUpdate();
1032 } 616 }
1033 m_pEdit->Update(); 617 m_pEdit->Update();
1034 } 618 }
1035 } 619 }
1036 void CFWL_ComboBoxImp::ReSetTheme() { 620
621 void IFWL_ComboBox::ReSetTheme() {
1037 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 622 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
1038 if (!pTheme) { 623 if (!pTheme) {
1039 pTheme = GetAvailableTheme(); 624 pTheme = GetAvailableTheme();
1040 m_pProperties->m_pThemeProvider = pTheme; 625 m_pProperties->m_pThemeProvider = pTheme;
1041 } 626 }
1042 if (m_pListBox && !m_pListBox->GetThemeProvider()) 627 if (m_pListBox && !m_pListBox->GetThemeProvider())
1043 m_pListBox->SetThemeProvider(pTheme); 628 m_pListBox->SetThemeProvider(pTheme);
1044 if (m_pEdit && !m_pEdit->GetThemeProvider()) 629 if (m_pEdit && !m_pEdit->GetThemeProvider())
1045 m_pEdit->SetThemeProvider(pTheme); 630 m_pEdit->SetThemeProvider(pTheme);
1046 } 631 }
1047 void CFWL_ComboBoxImp::ReSetEditAlignment() { 632
633 void IFWL_ComboBox::ReSetEditAlignment() {
1048 if (!m_pEdit) 634 if (!m_pEdit)
1049 return; 635 return;
1050 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; 636 uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
1051 uint32_t dwAdd = 0; 637 uint32_t dwAdd = 0;
1052 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) { 638 switch (dwStylExes & FWL_STYLEEXT_CMB_EditHAlignMask) {
1053 case FWL_STYLEEXT_CMB_EditHCenter: { 639 case FWL_STYLEEXT_CMB_EditHCenter: {
1054 dwAdd |= FWL_STYLEEXT_EDT_HCenter; 640 dwAdd |= FWL_STYLEEXT_EDT_HCenter;
1055 break; 641 break;
1056 } 642 }
1057 case FWL_STYLEEXT_CMB_EditHFar: { 643 case FWL_STYLEEXT_CMB_EditHFar: {
(...skipping 16 matching lines...) Expand all
1074 if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) { 660 if (dwStylExes & FWL_STYLEEXT_CMB_EditJustified) {
1075 dwAdd |= FWL_STYLEEXT_EDT_Justified; 661 dwAdd |= FWL_STYLEEXT_EDT_Justified;
1076 } 662 }
1077 if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) { 663 if (dwStylExes & FWL_STYLEEXT_CMB_EditDistributed) {
1078 dwAdd |= FWL_STYLEEXT_EDT_Distributed; 664 dwAdd |= FWL_STYLEEXT_EDT_Distributed;
1079 } 665 }
1080 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask | 666 m_pEdit->ModifyStylesEx(dwAdd, FWL_STYLEEXT_EDT_HAlignMask |
1081 FWL_STYLEEXT_EDT_HAlignModeMask | 667 FWL_STYLEEXT_EDT_HAlignModeMask |
1082 FWL_STYLEEXT_EDT_VAlignMask); 668 FWL_STYLEEXT_EDT_VAlignMask);
1083 } 669 }
1084 void CFWL_ComboBoxImp::ReSetListItemAlignment() { 670
671 void IFWL_ComboBox::ReSetListItemAlignment() {
1085 if (!m_pListBox) 672 if (!m_pListBox)
1086 return; 673 return;
1087 uint32_t dwStylExes = m_pProperties->m_dwStyleExes; 674 uint32_t dwStylExes = m_pProperties->m_dwStyleExes;
1088 uint32_t dwAdd = 0; 675 uint32_t dwAdd = 0;
1089 switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) { 676 switch (dwStylExes & FWL_STYLEEXT_CMB_ListItemAlignMask) {
1090 case FWL_STYLEEXT_CMB_ListItemCenterAlign: { 677 case FWL_STYLEEXT_CMB_ListItemCenterAlign: {
1091 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign; 678 dwAdd |= FWL_STYLEEXT_LTB_CenterAlign;
1092 } 679 }
1093 case FWL_STYLEEXT_CMB_ListItemRightAlign: { 680 case FWL_STYLEEXT_CMB_ListItemRightAlign: {
1094 dwAdd |= FWL_STYLEEXT_LTB_RightAlign; 681 dwAdd |= FWL_STYLEEXT_LTB_RightAlign;
1095 } 682 }
1096 default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; } 683 default: { dwAdd |= FWL_STYLEEXT_LTB_LeftAlign; }
1097 } 684 }
1098 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask); 685 m_pListBox->ModifyStylesEx(dwAdd, FWL_STYLEEXT_CMB_ListItemAlignMask);
1099 } 686 }
1100 void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) { 687
688 void IFWL_ComboBox::ProcessSelChanged(FX_BOOL bLButtonUp) {
1101 IFWL_ComboBoxDP* pDatas = 689 IFWL_ComboBoxDP* pDatas =
1102 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 690 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
1103 m_iCurSel = pDatas->GetItemIndex(m_pInterface, m_pListBox->GetSelItem(0)); 691 m_iCurSel = pDatas->GetItemIndex(this, m_pListBox->GetSelItem(0));
1104 FX_BOOL bDropDown = IsDropDownStyle(); 692 FX_BOOL bDropDown = IsDropDownStyle();
1105 if (bDropDown) { 693 if (bDropDown) {
1106 IFWL_ComboBoxDP* pData = 694 IFWL_ComboBoxDP* pData =
1107 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 695 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
1108 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); 696 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
1109 if (hItem) { 697 if (hItem) {
1110 CFX_WideString wsText; 698 CFX_WideString wsText;
1111 pData->GetItemText(m_pInterface, hItem, wsText); 699 pData->GetItemText(this, hItem, wsText);
1112 if (m_pEdit) { 700 if (m_pEdit) {
1113 m_pEdit->SetText(wsText); 701 m_pEdit->SetText(wsText);
1114 m_pEdit->Update(); 702 m_pEdit->Update();
1115 static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetSelected(); 703 m_pEdit->SetSelected();
1116 } 704 }
1117 CFWL_EvtCmbSelChanged ev; 705 CFWL_EvtCmbSelChanged ev;
1118 ev.bLButtonUp = bLButtonUp; 706 ev.bLButtonUp = bLButtonUp;
1119 ev.m_pSrcTarget = m_pInterface; 707 ev.m_pSrcTarget = this;
1120 ev.iArraySels.Add(m_iCurSel); 708 ev.iArraySels.Add(m_iCurSel);
1121 DispatchEvent(&ev); 709 DispatchEvent(&ev);
1122 } 710 }
1123 } else { 711 } else {
1124 Repaint(&m_rtClient); 712 Repaint(&m_rtClient);
1125 } 713 }
1126 } 714 }
1127 715
1128 void CFWL_ComboBoxImp::InitProxyForm() { 716 void IFWL_ComboBox::InitProxyForm() {
1129 if (m_pForm) 717 if (m_pForm)
1130 return; 718 return;
1131 if (!m_pListBox) 719 if (!m_pListBox)
1132 return; 720 return;
1133 721
1134 CFWL_WidgetImpProperties propForm; 722 CFWL_WidgetImpProperties propForm;
1135 propForm.m_pOwner = m_pInterface; 723 propForm.m_pOwner = this;
1136 propForm.m_dwStyles = FWL_WGTSTYLE_Popup; 724 propForm.m_dwStyles = FWL_WGTSTYLE_Popup;
1137 propForm.m_dwStates = FWL_WGTSTATE_Invisible; 725 propForm.m_dwStates = FWL_WGTSTATE_Invisible;
1138 CFX_WideString className; 726 m_pForm = IFWL_FormProxy::Create(propForm, m_pListBox.get());
1139 m_pForm = IFWL_Form::CreateFormProxy(propForm, &className, m_pListBox.get());
1140 m_pForm->Initialize(); 727 m_pForm->Initialize();
1141 m_pProxy = static_cast<CFWL_FormProxyImp*>(m_pForm->GetImpl());
1142 m_pListBox->SetParent(m_pForm); 728 m_pListBox->SetParent(m_pForm);
1143 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this); 729 m_pListProxyDelegate = new CFWL_ComboProxyImpDelegate(m_pForm, this);
1144 m_pProxy->SetDelegate(m_pListProxyDelegate); 730 m_pForm->SetDelegate(m_pListProxyDelegate);
1145 } 731 }
1146 732
1147 FWL_Error CFWL_ComboBoxImp::DisForm_Initialize() { 733 FWL_Error IFWL_ComboBox::DisForm_Initialize() {
1148 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) 734 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded)
1149 return FWL_Error::Indefinite; 735 return FWL_Error::Indefinite;
1150 736
1151 m_pDelegate = new CFWL_ComboBoxImpDelegate(this); 737 m_pDelegate = new CFWL_ComboBoxImpDelegate(this);
1152 DisForm_InitComboList(); 738 DisForm_InitComboList();
1153 DisForm_InitComboEdit(); 739 DisForm_InitComboEdit();
1154 return FWL_Error::Succeeded; 740 return FWL_Error::Succeeded;
1155 } 741 }
1156 742
1157 void CFWL_ComboBoxImp::DisForm_InitComboList() { 743 void IFWL_ComboBox::DisForm_InitComboList() {
1158 if (m_pListBox) 744 if (m_pListBox)
1159 return; 745 return;
1160 746
1161 CFWL_WidgetImpProperties prop; 747 CFWL_WidgetImpProperties prop;
1162 prop.m_pParent = m_pInterface; 748 prop.m_pParent = this;
1163 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; 749 prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll;
1164 prop.m_dwStates = FWL_WGTSTATE_Invisible; 750 prop.m_dwStates = FWL_WGTSTATE_Invisible;
1165 prop.m_pDataProvider = m_pProperties->m_pDataProvider; 751 prop.m_pDataProvider = m_pProperties->m_pDataProvider;
1166 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 752 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
1167 m_pListBox.reset(IFWL_ListBox::CreateComboList(prop, m_pInterface)); 753 m_pListBox.reset(IFWL_ComboList::Create(prop, this));
1168 m_pListBox->Initialize(); 754 m_pListBox->Initialize();
1169 } 755 }
1170 void CFWL_ComboBoxImp::DisForm_InitComboEdit() { 756
757 void IFWL_ComboBox::DisForm_InitComboEdit() {
1171 if (m_pEdit) { 758 if (m_pEdit) {
1172 return; 759 return;
1173 } 760 }
1174 CFWL_WidgetImpProperties prop; 761 CFWL_WidgetImpProperties prop;
1175 prop.m_pParent = m_pInterface; 762 prop.m_pParent = this;
1176 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; 763 prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
1177 m_pEdit.reset(IFWL_Edit::CreateComboEdit(prop, m_pInterface)); 764 m_pEdit.reset(IFWL_ComboEdit::Create(prop, this));
1178 m_pEdit->Initialize(); 765 m_pEdit->Initialize();
1179 static_cast<CFWL_ComboEditImp*>(m_pEdit->GetImpl())->SetOuter(m_pInterface); 766 m_pEdit->SetOuter(this);
1180 } 767 }
1181 void CFWL_ComboBoxImp::DisForm_ShowDropList(FX_BOOL bActivate) { 768
769 void IFWL_ComboBox::DisForm_ShowDropList(FX_BOOL bActivate) {
1182 FX_BOOL bDropList = DisForm_IsDropListShowed(); 770 FX_BOOL bDropList = DisForm_IsDropListShowed();
1183 if (bDropList == bActivate) { 771 if (bDropList == bActivate) {
1184 return; 772 return;
1185 } 773 }
1186 if (bActivate) { 774 if (bActivate) {
1187 CFWL_EvtCmbPreDropDown preEvent; 775 CFWL_EvtCmbPreDropDown preEvent;
1188 preEvent.m_pSrcTarget = m_pInterface; 776 preEvent.m_pSrcTarget = this;
1189 DispatchEvent(&preEvent); 777 DispatchEvent(&preEvent);
1190 CFWL_ComboListImp* pComboList = 778 IFWL_ComboList* pComboList = m_pListBox.get();
1191 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl());
1192 int32_t iItems = pComboList->CountItems(); 779 int32_t iItems = pComboList->CountItems();
1193 if (iItems < 1) { 780 if (iItems < 1) {
1194 return; 781 return;
1195 } 782 }
1196 ReSetListItemAlignment(); 783 ReSetListItemAlignment();
1197 pComboList->ChangeSelected(m_iCurSel); 784 pComboList->ChangeSelected(m_iCurSel);
1198 FX_FLOAT fItemHeight = pComboList->GetItemHeigt(); 785 FX_FLOAT fItemHeight = pComboList->GetItemHeigt();
1199 FX_FLOAT fBorder = GetBorderSize(); 786 FX_FLOAT fBorder = GetBorderSize();
1200 FX_FLOAT fPopupMin = 0.0f; 787 FX_FLOAT fPopupMin = 0.0f;
1201 if (iItems > 3) { 788 if (iItems > 3) {
1202 fPopupMin = fItemHeight * 3 + fBorder * 2; 789 fPopupMin = fItemHeight * 3 + fBorder * 2;
1203 } 790 }
1204 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; 791 FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2;
1205 CFX_RectF rtList; 792 CFX_RectF rtList;
1206 rtList.left = m_rtClient.left; 793 rtList.left = m_rtClient.left;
1207 rtList.width = m_pProperties->m_rtWidget.width; 794 rtList.width = m_pProperties->m_rtWidget.width;
1208 rtList.top = 0; 795 rtList.top = 0;
1209 rtList.height = 0; 796 rtList.height = 0;
1210 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); 797 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList);
1211 m_pListBox->SetWidgetRect(rtList); 798 m_pListBox->SetWidgetRect(rtList);
1212 m_pListBox->Update(); 799 m_pListBox->Update();
1213 } else { 800 } else {
1214 SetFocus(TRUE); 801 SetFocus(TRUE);
1215 } 802 }
1216 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); 803 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate);
1217 if (bActivate) { 804 if (bActivate) {
1218 CFWL_EvtCmbPostDropDown postEvent; 805 CFWL_EvtCmbPostDropDown postEvent;
1219 postEvent.m_pSrcTarget = m_pInterface; 806 postEvent.m_pSrcTarget = this;
1220 DispatchEvent(&postEvent); 807 DispatchEvent(&postEvent);
1221 } 808 }
1222 CFX_RectF rect; 809 CFX_RectF rect;
1223 m_pListBox->GetWidgetRect(rect); 810 m_pListBox->GetWidgetRect(rect);
1224 rect.Inflate(2, 2); 811 rect.Inflate(2, 2);
1225 Repaint(&rect); 812 Repaint(&rect);
1226 } 813 }
1227 FX_BOOL CFWL_ComboBoxImp::DisForm_IsDropListShowed() { 814
815 FX_BOOL IFWL_ComboBox::DisForm_IsDropListShowed() {
1228 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible); 816 return !(m_pListBox->GetStates() & FWL_WGTSTATE_Invisible);
1229 } 817 }
1230 FWL_Error CFWL_ComboBoxImp::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded, 818
1231 uint32_t dwStylesExRemoved) { 819 FWL_Error IFWL_ComboBox::DisForm_ModifyStylesEx(uint32_t dwStylesExAdded,
820 uint32_t dwStylesExRemoved) {
1232 if (!m_pEdit) { 821 if (!m_pEdit) {
1233 DisForm_InitComboEdit(); 822 DisForm_InitComboEdit();
1234 } 823 }
1235 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); 824 bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown);
1236 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); 825 bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown);
1237 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; 826 dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown;
1238 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; 827 m_pProperties->m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown;
1239 if (bAddDropDown) { 828 if (bAddDropDown) {
1240 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); 829 m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly);
1241 } else if (bDelDropDown) { 830 } else if (bDelDropDown) {
1242 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); 831 m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0);
1243 } 832 }
1244 return CFWL_WidgetImp::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 833 return IFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
1245 } 834 }
1246 FWL_Error CFWL_ComboBoxImp::DisForm_Update() { 835
836 FWL_Error IFWL_ComboBox::DisForm_Update() {
1247 if (m_iLock) { 837 if (m_iLock) {
1248 return FWL_Error::Indefinite; 838 return FWL_Error::Indefinite;
1249 } 839 }
1250 if (m_pEdit) { 840 if (m_pEdit) {
1251 ReSetEditAlignment(); 841 ReSetEditAlignment();
1252 } 842 }
1253 ReSetTheme(); 843 ReSetTheme();
1254 Layout(); 844 Layout();
1255 return FWL_Error::Succeeded; 845 return FWL_Error::Succeeded;
1256 } 846 }
1257 FWL_WidgetHit CFWL_ComboBoxImp::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { 847
848 FWL_WidgetHit IFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) {
1258 CFX_RectF rect; 849 CFX_RectF rect;
1259 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, 850 rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width,
1260 m_pProperties->m_rtWidget.height); 851 m_pProperties->m_rtWidget.height);
1261 if (rect.Contains(fx, fy)) 852 if (rect.Contains(fx, fy))
1262 return FWL_WidgetHit::Edit; 853 return FWL_WidgetHit::Edit;
1263 if (m_rtBtn.Contains(fx, fy)) 854 if (m_rtBtn.Contains(fx, fy))
1264 return FWL_WidgetHit::Client; 855 return FWL_WidgetHit::Client;
1265 if (DisForm_IsDropListShowed()) { 856 if (DisForm_IsDropListShowed()) {
1266 m_pListBox->GetWidgetRect(rect); 857 m_pListBox->GetWidgetRect(rect);
1267 if (rect.Contains(fx, fy)) 858 if (rect.Contains(fx, fy))
1268 return FWL_WidgetHit::Client; 859 return FWL_WidgetHit::Client;
1269 } 860 }
1270 return FWL_WidgetHit::Unknown; 861 return FWL_WidgetHit::Unknown;
1271 } 862 }
1272 FWL_Error CFWL_ComboBoxImp::DisForm_DrawWidget(CFX_Graphics* pGraphics, 863
1273 const CFX_Matrix* pMatrix) { 864 FWL_Error IFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics,
865 const CFX_Matrix* pMatrix) {
1274 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 866 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
1275 CFX_Matrix mtOrg; 867 CFX_Matrix mtOrg;
1276 mtOrg.Set(1, 0, 0, 1, 0, 0); 868 mtOrg.Set(1, 0, 0, 1, 0, 0);
1277 if (pMatrix) { 869 if (pMatrix) {
1278 mtOrg = *pMatrix; 870 mtOrg = *pMatrix;
1279 } 871 }
1280 FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed(); 872 FX_BOOL bListShowed = m_pListBox && DisForm_IsDropListShowed();
1281 pGraphics->SaveGraphState(); 873 pGraphics->SaveGraphState();
1282 pGraphics->ConcatMatrix(&mtOrg); 874 pGraphics->ConcatMatrix(&mtOrg);
1283 if (!m_rtBtn.IsEmpty(0.1f)) { 875 if (!m_rtBtn.IsEmpty(0.1f)) {
1284 CFWL_ThemeBackground param; 876 CFWL_ThemeBackground param;
1285 param.m_pWidget = m_pInterface; 877 param.m_pWidget = this;
1286 param.m_iPart = CFWL_Part::DropDownButton; 878 param.m_iPart = CFWL_Part::DropDownButton;
1287 param.m_dwStates = m_iBtnState; 879 param.m_dwStates = m_iBtnState;
1288 param.m_pGraphics = pGraphics; 880 param.m_pGraphics = pGraphics;
1289 param.m_rtPart = m_rtBtn; 881 param.m_rtPart = m_rtBtn;
1290 pTheme->DrawBackground(&param); 882 pTheme->DrawBackground(&param);
1291 } 883 }
1292 pGraphics->RestoreGraphState(); 884 pGraphics->RestoreGraphState();
1293 if (m_pEdit) { 885 if (m_pEdit) {
1294 CFX_RectF rtEdit; 886 CFX_RectF rtEdit;
1295 m_pEdit->GetWidgetRect(rtEdit); 887 m_pEdit->GetWidgetRect(rtEdit);
1296 CFX_Matrix mt; 888 CFX_Matrix mt;
1297 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); 889 mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top);
1298 mt.Concat(mtOrg); 890 mt.Concat(mtOrg);
1299 m_pEdit->DrawWidget(pGraphics, &mt); 891 m_pEdit->DrawWidget(pGraphics, &mt);
1300 } 892 }
1301 if (bListShowed) { 893 if (bListShowed) {
1302 CFX_RectF rtList; 894 CFX_RectF rtList;
1303 m_pListBox->GetWidgetRect(rtList); 895 m_pListBox->GetWidgetRect(rtList);
1304 CFX_Matrix mt; 896 CFX_Matrix mt;
1305 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); 897 mt.Set(1, 0, 0, 1, rtList.left, rtList.top);
1306 mt.Concat(mtOrg); 898 mt.Concat(mtOrg);
1307 m_pListBox->DrawWidget(pGraphics, &mt); 899 m_pListBox->DrawWidget(pGraphics, &mt);
1308 } 900 }
1309 return FWL_Error::Succeeded; 901 return FWL_Error::Succeeded;
1310 } 902 }
1311 FWL_Error CFWL_ComboBoxImp::DisForm_GetBBox(CFX_RectF& rect) { 903
904 FWL_Error IFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) {
1312 rect = m_pProperties->m_rtWidget; 905 rect = m_pProperties->m_rtWidget;
1313 if (m_pListBox && DisForm_IsDropListShowed()) { 906 if (m_pListBox && DisForm_IsDropListShowed()) {
1314 CFX_RectF rtList; 907 CFX_RectF rtList;
1315 m_pListBox->GetWidgetRect(rtList); 908 m_pListBox->GetWidgetRect(rtList);
1316 rtList.Offset(rect.left, rect.top); 909 rtList.Offset(rect.left, rect.top);
1317 rect.Union(rtList); 910 rect.Union(rtList);
1318 } 911 }
1319 return FWL_Error::Succeeded; 912 return FWL_Error::Succeeded;
1320 } 913 }
1321 void CFWL_ComboBoxImp::DisForm_Layout() { 914
915 void IFWL_ComboBox::DisForm_Layout() {
1322 GetClientRect(m_rtClient); 916 GetClientRect(m_rtClient);
1323 m_rtContent = m_rtClient; 917 m_rtContent = m_rtClient;
1324 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 918 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
1325 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 919 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
1326 if (!pFWidth) 920 if (!pFWidth)
1327 return; 921 return;
1328 FX_FLOAT borderWidth = 1; 922 FX_FLOAT borderWidth = 1;
1329 FX_FLOAT fBtn = *pFWidth; 923 FX_FLOAT fBtn = *pFWidth;
1330 if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) { 924 if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) {
1331 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth, 925 m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth,
1332 fBtn - borderWidth, m_rtClient.height - 2 * borderWidth); 926 fBtn - borderWidth, m_rtClient.height - 2 * borderWidth);
1333 } 927 }
1334 CFX_RectF* pUIMargin = 928 CFX_RectF* pUIMargin =
1335 static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin)); 929 static_cast<CFX_RectF*>(GetThemeCapacity(CFWL_WidgetCapacity::UIMargin));
1336 if (pUIMargin) { 930 if (pUIMargin) {
1337 m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width, 931 m_rtContent.Deflate(pUIMargin->left, pUIMargin->top, pUIMargin->width,
1338 pUIMargin->height); 932 pUIMargin->height);
1339 } 933 }
1340 FX_BOOL bIsDropDown = IsDropDownStyle(); 934 FX_BOOL bIsDropDown = IsDropDownStyle();
1341 if (bIsDropDown && m_pEdit) { 935 if (bIsDropDown && m_pEdit) {
1342 CFX_RectF rtEdit; 936 CFX_RectF rtEdit;
1343 rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, 937 rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn,
1344 m_rtContent.height); 938 m_rtContent.height);
1345 m_pEdit->SetWidgetRect(rtEdit); 939 m_pEdit->SetWidgetRect(rtEdit);
1346 if (m_iCurSel >= 0) { 940 if (m_iCurSel >= 0) {
1347 CFX_WideString wsText; 941 CFX_WideString wsText;
1348 IFWL_ComboBoxDP* pData = 942 IFWL_ComboBoxDP* pData =
1349 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); 943 static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider);
1350 IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); 944 IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
1351 static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) 945 m_pListBox->GetItemText(hItem, wsText);
1352 ->GetItemText(hItem, wsText);
1353 m_pEdit->LockUpdate(); 946 m_pEdit->LockUpdate();
1354 m_pEdit->SetText(wsText); 947 m_pEdit->SetText(wsText);
1355 m_pEdit->UnlockUpdate(); 948 m_pEdit->UnlockUpdate();
1356 } 949 }
1357 m_pEdit->Update(); 950 m_pEdit->Update();
1358 } 951 }
1359 } 952 }
1360 953
1361 CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(CFWL_ComboBoxImp* pOwner) 954 CFWL_ComboBoxImpDelegate::CFWL_ComboBoxImpDelegate(IFWL_ComboBox* pOwner)
1362 : m_pOwner(pOwner) {} 955 : m_pOwner(pOwner) {}
1363 956
1364 void CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 957 void CFWL_ComboBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
1365 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) { 958 if (m_pOwner->m_pWidgetMgr->IsFormDisabled()) {
1366 DisForm_OnProcessMessage(pMessage); 959 DisForm_OnProcessMessage(pMessage);
1367 return; 960 return;
1368 } 961 }
1369 if (!pMessage) 962 if (!pMessage)
1370 return; 963 return;
1371 964
(...skipping 27 matching lines...) Expand all
1399 } 992 }
1400 default: 993 default:
1401 break; 994 break;
1402 } 995 }
1403 break; 996 break;
1404 } 997 }
1405 case CFWL_MessageType::Key: { 998 case CFWL_MessageType::Key: {
1406 OnKey(static_cast<CFWL_MsgKey*>(pMessage)); 999 OnKey(static_cast<CFWL_MsgKey*>(pMessage));
1407 break; 1000 break;
1408 } 1001 }
1409 default: { 1002 default: { break; }
1410 break;
1411 }
1412 } 1003 }
1413 1004
1414 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 1005 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage);
1415 } 1006 }
1416 1007
1417 void CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { 1008 void CFWL_ComboBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {
1418 CFWL_EventType dwFlag = pEvent->GetClassID(); 1009 CFWL_EventType dwFlag = pEvent->GetClassID();
1419 if (dwFlag == CFWL_EventType::DrawItem) { 1010 if (dwFlag == CFWL_EventType::DrawItem) {
1420 CFWL_EvtLtbDrawItem* pDrawItemEvent = 1011 CFWL_EvtLtbDrawItem* pDrawItemEvent =
1421 static_cast<CFWL_EvtLtbDrawItem*>(pEvent); 1012 static_cast<CFWL_EvtLtbDrawItem*>(pEvent);
1422 CFWL_EvtCmbDrawItem pTemp; 1013 CFWL_EvtCmbDrawItem pTemp;
1423 pTemp.m_pSrcTarget = m_pOwner->m_pInterface; 1014 pTemp.m_pSrcTarget = m_pOwner;
1424 pTemp.m_pGraphics = pDrawItemEvent->m_pGraphics; 1015 pTemp.m_pGraphics = pDrawItemEvent->m_pGraphics;
1425 pTemp.m_index = pDrawItemEvent->m_index; 1016 pTemp.m_index = pDrawItemEvent->m_index;
1426 pTemp.m_rtItem = pDrawItemEvent->m_rect; 1017 pTemp.m_rtItem = pDrawItemEvent->m_rect;
1427 m_pOwner->DispatchEvent(&pTemp); 1018 m_pOwner->DispatchEvent(&pTemp);
1428 } else if (dwFlag == CFWL_EventType::Scroll) { 1019 } else if (dwFlag == CFWL_EventType::Scroll) {
1429 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); 1020 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent);
1430 CFWL_EvtScroll pScrollEv; 1021 CFWL_EvtScroll pScrollEv;
1431 pScrollEv.m_pSrcTarget = m_pOwner->m_pInterface; 1022 pScrollEv.m_pSrcTarget = m_pOwner;
1432 pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode; 1023 pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode;
1433 pScrollEv.m_fPos = pScrollEvent->m_fPos; 1024 pScrollEv.m_fPos = pScrollEvent->m_fPos;
1434 m_pOwner->DispatchEvent(&pScrollEv); 1025 m_pOwner->DispatchEvent(&pScrollEv);
1435 } else if (dwFlag == CFWL_EventType::TextChanged) { 1026 } else if (dwFlag == CFWL_EventType::TextChanged) {
1436 CFWL_EvtEdtTextChanged* pTextChangedEvent = 1027 CFWL_EvtEdtTextChanged* pTextChangedEvent =
1437 static_cast<CFWL_EvtEdtTextChanged*>(pEvent); 1028 static_cast<CFWL_EvtEdtTextChanged*>(pEvent);
1438 CFWL_EvtCmbEditChanged pTemp; 1029 CFWL_EvtCmbEditChanged pTemp;
1439 pTemp.m_pSrcTarget = m_pOwner->m_pInterface; 1030 pTemp.m_pSrcTarget = m_pOwner;
1440 pTemp.wsInsert = pTextChangedEvent->wsInsert; 1031 pTemp.wsInsert = pTextChangedEvent->wsInsert;
1441 pTemp.wsDelete = pTextChangedEvent->wsDelete; 1032 pTemp.wsDelete = pTextChangedEvent->wsDelete;
1442 pTemp.nChangeType = pTextChangedEvent->nChangeType; 1033 pTemp.nChangeType = pTextChangedEvent->nChangeType;
1443 m_pOwner->DispatchEvent(&pTemp); 1034 m_pOwner->DispatchEvent(&pTemp);
1444 } 1035 }
1445 } 1036 }
1446 1037
1447 void CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 1038 void CFWL_ComboBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics,
1448 const CFX_Matrix* pMatrix) { 1039 const CFX_Matrix* pMatrix) {
1449 m_pOwner->DrawWidget(pGraphics, pMatrix); 1040 m_pOwner->DrawWidget(pGraphics, pMatrix);
1450 } 1041 }
1451 1042
1452 void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 1043 void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
1453 FX_BOOL bSet) { 1044 FX_BOOL bSet) {
1454 IFWL_Widget* pDstTarget = pMsg->m_pDstTarget; 1045 IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
1455 IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget; 1046 IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
1456 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); 1047 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
1457 if (bSet) { 1048 if (bSet) {
1458 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1049 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1459 if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) { 1050 if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) {
1460 if (!m_pOwner->m_pEdit) 1051 if (!m_pOwner->m_pEdit)
1461 return; 1052 return;
1462 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) 1053 m_pOwner->m_pEdit->SetSelected();
1463 ->SetSelected();
1464 } else { 1054 } else {
1465 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1055 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1466 } 1056 }
1467 } else { 1057 } else {
1468 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1058 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1469 if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) { 1059 if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) {
1470 if (!m_pOwner->m_pEdit) 1060 if (!m_pOwner->m_pEdit)
1471 return; 1061 return;
1472 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl()) 1062 m_pOwner->m_pEdit->FlagFocus(FALSE);
1473 ->FlagFocus(FALSE); 1063 m_pOwner->m_pEdit->ClearSelected();
1474 static_cast<CFWL_ComboEditImp*>(m_pOwner->m_pEdit->GetImpl())
1475 ->ClearSelected();
1476 } else { 1064 } else {
1477 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1065 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1478 } 1066 }
1479 } 1067 }
1480 } 1068 }
1069
1481 void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 1070 void CFWL_ComboBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
1482 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { 1071 if (m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
1483 return; 1072 return;
1484 } 1073 }
1485 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); 1074 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
1486 CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient; 1075 CFX_RectF& rtBtn = bDropDown ? m_pOwner->m_rtBtn : m_pOwner->m_rtClient;
1487 FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy); 1076 FX_BOOL bClickBtn = rtBtn.Contains(pMsg->m_fx, pMsg->m_fy);
1488 if (bClickBtn) { 1077 if (bClickBtn) {
1489 if (bDropDown && m_pOwner->m_pEdit) { 1078 if (bDropDown && m_pOwner->m_pEdit) {
1490 m_pOwner->MatchEditText(); 1079 m_pOwner->MatchEditText();
1491 } 1080 }
1492 m_pOwner->m_bLButtonDown = TRUE; 1081 m_pOwner->m_bLButtonDown = TRUE;
1493 m_pOwner->m_iBtnState = CFWL_PartState_Pressed; 1082 m_pOwner->m_iBtnState = CFWL_PartState_Pressed;
1494 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1083 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1495 m_pOwner->ShowDropList(TRUE); 1084 m_pOwner->ShowDropList(TRUE);
1496 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 1085 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1497 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1086 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1498 } 1087 }
1499 } 1088 }
1089
1500 void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1090 void CFWL_ComboBoxImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1501 m_pOwner->m_bLButtonDown = FALSE; 1091 m_pOwner->m_bLButtonDown = FALSE;
1502 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1092 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1503 m_pOwner->m_iBtnState = CFWL_PartState_Hovered; 1093 m_pOwner->m_iBtnState = CFWL_PartState_Hovered;
1504 } else { 1094 } else {
1505 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 1095 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1506 } 1096 }
1507 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 1097 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1508 } 1098 }
1099
1509 void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 1100 void CFWL_ComboBoxImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {
1510 int32_t iOldState = m_pOwner->m_iBtnState; 1101 int32_t iOldState = m_pOwner->m_iBtnState;
1511 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) { 1102 if (m_pOwner->m_rtBtn.Contains(pMsg->m_fx, pMsg->m_fy)) {
1512 m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown ? CFWL_PartState_Pressed 1103 m_pOwner->m_iBtnState = m_pOwner->m_bLButtonDown ? CFWL_PartState_Pressed
1513 : CFWL_PartState_Hovered; 1104 : CFWL_PartState_Hovered;
1514 } else { 1105 } else {
1515 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 1106 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1516 } 1107 }
1517 if ((iOldState != m_pOwner->m_iBtnState) && 1108 if ((iOldState != m_pOwner->m_iBtnState) &&
1518 !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 1109 !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
1519 FWL_WGTSTATE_Disabled)) { 1110 FWL_WGTSTATE_Disabled)) {
1520 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 1111 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1521 } 1112 }
1522 } 1113 }
1114
1523 void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 1115 void CFWL_ComboBoxImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) {
1524 if (!m_pOwner->IsDropListShowed() && 1116 if (!m_pOwner->IsDropListShowed() &&
1525 !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 1117 !((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) ==
1526 FWL_WGTSTATE_Disabled)) { 1118 FWL_WGTSTATE_Disabled)) {
1527 m_pOwner->m_iBtnState = CFWL_PartState_Normal; 1119 m_pOwner->m_iBtnState = CFWL_PartState_Normal;
1528 m_pOwner->Repaint(&m_pOwner->m_rtBtn); 1120 m_pOwner->Repaint(&m_pOwner->m_rtBtn);
1529 } 1121 }
1530 } 1122 }
1123
1531 void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) { 1124 void CFWL_ComboBoxImpDelegate::OnKey(CFWL_MsgKey* pMsg) {
1532 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1125 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1533 if (dwKeyCode == FWL_VKEY_Tab) { 1126 if (dwKeyCode == FWL_VKEY_Tab) {
1534 m_pOwner->DispatchKeyEvent(pMsg); 1127 m_pOwner->DispatchKeyEvent(pMsg);
1535 return; 1128 return;
1536 } 1129 }
1537 if (pMsg->m_pDstTarget == m_pOwner->m_pInterface) 1130 if (pMsg->m_pDstTarget == m_pOwner)
1538 DoSubCtrlKey(pMsg); 1131 DoSubCtrlKey(pMsg);
1539 } 1132 }
1133
1540 void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) { 1134 void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
1541 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1135 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1542 const bool bUp = dwKeyCode == FWL_VKEY_Up; 1136 const bool bUp = dwKeyCode == FWL_VKEY_Up;
1543 const bool bDown = dwKeyCode == FWL_VKEY_Down; 1137 const bool bDown = dwKeyCode == FWL_VKEY_Down;
1544 if (bUp || bDown) { 1138 if (bUp || bDown) {
1545 int32_t iCount = 1139 int32_t iCount = m_pOwner->m_pListBox->CountItems();
1546 static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl())
1547 ->CountItems();
1548 if (iCount < 1) { 1140 if (iCount < 1) {
1549 return; 1141 return;
1550 } 1142 }
1551 FX_BOOL bMatchEqual = FALSE; 1143 FX_BOOL bMatchEqual = FALSE;
1552 int32_t iCurSel = m_pOwner->m_iCurSel; 1144 int32_t iCurSel = m_pOwner->m_iCurSel;
1553 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); 1145 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
1554 if (bDropDown && m_pOwner->m_pEdit) { 1146 if (bDropDown && m_pOwner->m_pEdit) {
1555 CFX_WideString wsText; 1147 CFX_WideString wsText;
1556 m_pOwner->m_pEdit->GetText(wsText); 1148 m_pOwner->m_pEdit->GetText(wsText);
1557 iCurSel = static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) 1149 iCurSel = m_pOwner->m_pListBox->MatchItem(wsText);
1558 ->MatchItem(wsText);
1559 if (iCurSel >= 0) { 1150 if (iCurSel >= 0) {
1560 CFX_WideString wsTemp; 1151 CFX_WideString wsTemp;
1561 IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>( 1152 IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(
1562 m_pOwner->m_pProperties->m_pDataProvider); 1153 m_pOwner->m_pProperties->m_pDataProvider);
1563 IFWL_ListItem* hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel); 1154 IFWL_ListItem* hItem = pData->GetItem(m_pOwner, iCurSel);
1564 static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) 1155 m_pOwner->m_pListBox->GetItemText(hItem, wsTemp);
1565 ->GetItemText(hItem, wsTemp);
1566 bMatchEqual = wsText == wsTemp; 1156 bMatchEqual = wsText == wsTemp;
1567 } 1157 }
1568 } 1158 }
1569 if (iCurSel < 0) { 1159 if (iCurSel < 0) {
1570 iCurSel = 0; 1160 iCurSel = 0;
1571 } else if (!bDropDown || bMatchEqual) { 1161 } else if (!bDropDown || bMatchEqual) {
1572 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) { 1162 if ((bUp && iCurSel == 0) || (bDown && iCurSel == iCount - 1)) {
1573 return; 1163 return;
1574 } 1164 }
1575 if (bUp) { 1165 if (bUp) {
1576 iCurSel--; 1166 iCurSel--;
1577 } else { 1167 } else {
1578 iCurSel++; 1168 iCurSel++;
1579 } 1169 }
1580 } 1170 }
1581 m_pOwner->m_iCurSel = iCurSel; 1171 m_pOwner->m_iCurSel = iCurSel;
1582 if (bDropDown && m_pOwner->m_pEdit) { 1172 if (bDropDown && m_pOwner->m_pEdit) {
1583 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); 1173 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
1584 } else { 1174 } else {
1585 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1175 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1586 } 1176 }
1587 return; 1177 return;
1588 } 1178 }
1589 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); 1179 FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
1590 if (bDropDown) { 1180 if (bDropDown) {
1591 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); 1181 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr);
1592 pDelegate->OnProcessMessage(pMsg); 1182 pDelegate->OnProcessMessage(pMsg);
1593 } 1183 }
1594 } 1184 }
1185
1595 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage( 1186 void CFWL_ComboBoxImpDelegate::DisForm_OnProcessMessage(
1596 CFWL_Message* pMessage) { 1187 CFWL_Message* pMessage) {
1597 if (!pMessage) 1188 if (!pMessage)
1598 return; 1189 return;
1599 1190
1600 FX_BOOL backDefault = TRUE; 1191 FX_BOOL backDefault = TRUE;
1601 switch (pMessage->GetClassID()) { 1192 switch (pMessage->GetClassID()) {
1602 case CFWL_MessageType::SetFocus: { 1193 case CFWL_MessageType::SetFocus: {
1603 backDefault = FALSE; 1194 backDefault = FALSE;
1604 DisForm_OnFocusChanged(pMessage, TRUE); 1195 DisForm_OnFocusChanged(pMessage, TRUE);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 return; 1255 return;
1665 } 1256 }
1666 { 1257 {
1667 if (m_pOwner->m_pEdit) { 1258 if (m_pOwner->m_pEdit) {
1668 m_pOwner->MatchEditText(); 1259 m_pOwner->MatchEditText();
1669 } 1260 }
1670 m_pOwner->DisForm_ShowDropList(TRUE); 1261 m_pOwner->DisForm_ShowDropList(TRUE);
1671 } 1262 }
1672 } 1263 }
1673 } 1264 }
1265
1674 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, 1266 void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg,
1675 FX_BOOL bSet) { 1267 FX_BOOL bSet) {
1676 if (bSet) { 1268 if (bSet) {
1677 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; 1269 m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
1678 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { 1270 if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) {
1679 CFWL_MsgSetFocus msg; 1271 CFWL_MsgSetFocus msg;
1680 msg.m_pDstTarget = m_pOwner->m_pEdit.get(); 1272 msg.m_pDstTarget = m_pOwner->m_pEdit.get();
1681 msg.m_pSrcTarget = nullptr; 1273 msg.m_pSrcTarget = nullptr;
1682 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); 1274 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr);
1683 pDelegate->OnProcessMessage(&msg); 1275 pDelegate->OnProcessMessage(&msg);
1684 } 1276 }
1685 } else { 1277 } else {
1686 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; 1278 m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused;
1687 m_pOwner->DisForm_ShowDropList(FALSE); 1279 m_pOwner->DisForm_ShowDropList(FALSE);
1688 CFWL_MsgKillFocus msg; 1280 CFWL_MsgKillFocus msg;
1689 msg.m_pDstTarget = nullptr; 1281 msg.m_pDstTarget = nullptr;
1690 msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); 1282 msg.m_pSrcTarget = m_pOwner->m_pEdit.get();
1691 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); 1283 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr);
1692 pDelegate->OnProcessMessage(&msg); 1284 pDelegate->OnProcessMessage(&msg);
1693 } 1285 }
1694 } 1286 }
1287
1695 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { 1288 void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) {
1696 uint32_t dwKeyCode = pMsg->m_dwKeyCode; 1289 uint32_t dwKeyCode = pMsg->m_dwKeyCode;
1697 const bool bUp = dwKeyCode == FWL_VKEY_Up; 1290 const bool bUp = dwKeyCode == FWL_VKEY_Up;
1698 const bool bDown = dwKeyCode == FWL_VKEY_Down; 1291 const bool bDown = dwKeyCode == FWL_VKEY_Down;
1699 if (bUp || bDown) { 1292 if (bUp || bDown) {
1700 CFWL_ComboListImp* pComboList = 1293 IFWL_ComboList* pComboList = m_pOwner->m_pListBox.get();
1701 static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl());
1702 int32_t iCount = pComboList->CountItems(); 1294 int32_t iCount = pComboList->CountItems();
1703 if (iCount < 1) { 1295 if (iCount < 1) {
1704 return; 1296 return;
1705 } 1297 }
1706 FX_BOOL bMatchEqual = FALSE; 1298 FX_BOOL bMatchEqual = FALSE;
1707 int32_t iCurSel = m_pOwner->m_iCurSel; 1299 int32_t iCurSel = m_pOwner->m_iCurSel;
1708 if (m_pOwner->m_pEdit) { 1300 if (m_pOwner->m_pEdit) {
1709 CFX_WideString wsText; 1301 CFX_WideString wsText;
1710 m_pOwner->m_pEdit->GetText(wsText); 1302 m_pOwner->m_pEdit->GetText(wsText);
1711 iCurSel = pComboList->MatchItem(wsText); 1303 iCurSel = pComboList->MatchItem(wsText);
(...skipping 19 matching lines...) Expand all
1731 m_pOwner->m_iCurSel = iCurSel; 1323 m_pOwner->m_iCurSel = iCurSel;
1732 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel); 1324 m_pOwner->SynchrEditText(m_pOwner->m_iCurSel);
1733 return; 1325 return;
1734 } 1326 }
1735 if (m_pOwner->m_pEdit) { 1327 if (m_pOwner->m_pEdit) {
1736 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr); 1328 IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(nullptr);
1737 pDelegate->OnProcessMessage(pMsg); 1329 pDelegate->OnProcessMessage(pMsg);
1738 } 1330 }
1739 } 1331 }
1740 1332
1741 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate( 1333 CFWL_ComboProxyImpDelegate::CFWL_ComboProxyImpDelegate(IFWL_Form* pForm,
1742 IFWL_Form* pForm, 1334 IFWL_ComboBox* pComboBox)
1743 CFWL_ComboBoxImp* pComboBox)
1744 : m_bLButtonDown(FALSE), 1335 : m_bLButtonDown(FALSE),
1745 m_bLButtonUpSelf(FALSE), 1336 m_bLButtonUpSelf(FALSE),
1746 m_fStartPos(0), 1337 m_fStartPos(0),
1747 m_pForm(pForm), 1338 m_pForm(pForm),
1748 m_pComboBox(pComboBox) {} 1339 m_pComboBox(pComboBox) {}
1749 1340
1750 void CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { 1341 void CFWL_ComboProxyImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
1751 if (!pMessage) 1342 if (!pMessage)
1752 return; 1343 return;
1753 1344
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 rtWidget.left = rtWidget.top = 0; 1398 rtWidget.left = rtWidget.top = 0;
1808 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { 1399 if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) {
1809 m_bLButtonDown = TRUE; 1400 m_bLButtonDown = TRUE;
1810 pDriver->SetGrab(m_pForm, TRUE); 1401 pDriver->SetGrab(m_pForm, TRUE);
1811 } else { 1402 } else {
1812 m_bLButtonDown = FALSE; 1403 m_bLButtonDown = FALSE;
1813 pDriver->SetGrab(m_pForm, FALSE); 1404 pDriver->SetGrab(m_pForm, FALSE);
1814 m_pComboBox->ShowDropList(FALSE); 1405 m_pComboBox->ShowDropList(FALSE);
1815 } 1406 }
1816 } 1407 }
1408
1817 void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 1409 void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
1818 m_bLButtonDown = FALSE; 1410 m_bLButtonDown = FALSE;
1819 IFWL_App* pApp = m_pForm->GetOwnerApp(); 1411 IFWL_App* pApp = m_pForm->GetOwnerApp();
1820 if (!pApp) 1412 if (!pApp)
1821 return; 1413 return;
1822 1414
1823 CFWL_NoteDriver* pDriver = 1415 CFWL_NoteDriver* pDriver =
1824 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 1416 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
1825 pDriver->SetGrab(m_pForm, FALSE); 1417 pDriver->SetGrab(m_pForm, FALSE);
1826 if (m_bLButtonUpSelf) { 1418 if (m_bLButtonUpSelf) {
1827 CFX_RectF rect; 1419 CFX_RectF rect;
1828 m_pForm->GetWidgetRect(rect); 1420 m_pForm->GetWidgetRect(rect);
1829 rect.left = rect.top = 0; 1421 rect.left = rect.top = 0;
1830 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && 1422 if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) &&
1831 m_pComboBox->IsDropListShowed()) { 1423 m_pComboBox->IsDropListShowed()) {
1832 m_pComboBox->ShowDropList(FALSE); 1424 m_pComboBox->ShowDropList(FALSE);
1833 } 1425 }
1834 } else { 1426 } else {
1835 m_bLButtonUpSelf = TRUE; 1427 m_bLButtonUpSelf = TRUE;
1836 } 1428 }
1837 } 1429 }
1430
1838 void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {} 1431 void CFWL_ComboProxyImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) {}
1432
1839 void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) { 1433 void CFWL_ComboProxyImpDelegate::OnDeactive(CFWL_MsgDeactivate* pMsg) {
1840 m_pComboBox->ShowDropList(FALSE); 1434 m_pComboBox->ShowDropList(FALSE);
1841 } 1435 }
1436
1842 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg, 1437 void CFWL_ComboProxyImpDelegate::OnFocusChanged(CFWL_MsgKillFocus* pMsg,
1843 FX_BOOL bSet) { 1438 FX_BOOL bSet) {
1844 if (!bSet) { 1439 if (!bSet) {
1845 if (!pMsg->m_pSetFocus) { 1440 if (!pMsg->m_pSetFocus) {
1846 m_pComboBox->ShowDropList(FALSE); 1441 m_pComboBox->ShowDropList(FALSE);
1847 } 1442 }
1848 } 1443 }
1849 } 1444 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_combobox.h ('k') | xfa/fwl/core/ifwl_comboedit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698