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

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

Issue 2525083002: Rename IFWL classes which do not have CFWL equivalents (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_combolist.h ('k') | xfa/fwl/core/cfwl_datetimeedit.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fwl/core/ifwl_combolist.h" 7 #include "xfa/fwl/core/cfwl_combolist.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "third_party/base/ptr_util.h" 12 #include "third_party/base/ptr_util.h"
13 #include "xfa/fwl/core/cfwl_comboedit.h"
13 #include "xfa/fwl/core/cfwl_msgkey.h" 14 #include "xfa/fwl/core/cfwl_msgkey.h"
14 #include "xfa/fwl/core/cfwl_msgkillfocus.h" 15 #include "xfa/fwl/core/cfwl_msgkillfocus.h"
15 #include "xfa/fwl/core/cfwl_msgmouse.h" 16 #include "xfa/fwl/core/cfwl_msgmouse.h"
16 #include "xfa/fwl/core/ifwl_combobox.h" 17 #include "xfa/fwl/core/ifwl_combobox.h"
17 #include "xfa/fwl/core/ifwl_comboedit.h"
18 #include "xfa/fwl/core/ifwl_listbox.h" 18 #include "xfa/fwl/core/ifwl_listbox.h"
19 19
20 IFWL_ComboList::IFWL_ComboList( 20 CFWL_ComboList::CFWL_ComboList(
21 const CFWL_App* app, 21 const CFWL_App* app,
22 std::unique_ptr<CFWL_WidgetProperties> properties, 22 std::unique_ptr<CFWL_WidgetProperties> properties,
23 IFWL_Widget* pOuter) 23 IFWL_Widget* pOuter)
24 : IFWL_ListBox(app, std::move(properties), pOuter), m_bNotifyOwner(true) { 24 : IFWL_ListBox(app, std::move(properties), pOuter), m_bNotifyOwner(true) {
25 ASSERT(pOuter); 25 ASSERT(pOuter);
26 } 26 }
27 27
28 int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { 28 int32_t CFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) {
29 if (wsMatch.IsEmpty()) 29 if (wsMatch.IsEmpty())
30 return -1; 30 return -1;
31 31
32 int32_t iCount = CountItems(this); 32 int32_t iCount = CountItems(this);
33 for (int32_t i = 0; i < iCount; i++) { 33 for (int32_t i = 0; i < iCount; i++) {
34 CFWL_ListItem* hItem = GetItem(this, i); 34 CFWL_ListItem* hItem = GetItem(this, i);
35 CFX_WideString wsText; 35 CFX_WideString wsText;
36 GetItemText(this, hItem, wsText); 36 GetItemText(this, hItem, wsText);
37 FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); 37 FX_STRSIZE pos = wsText.Find(wsMatch.c_str());
38 if (!pos) 38 if (!pos)
39 return i; 39 return i;
40 } 40 }
41 return -1; 41 return -1;
42 } 42 }
43 43
44 void IFWL_ComboList::ChangeSelected(int32_t iSel) { 44 void CFWL_ComboList::ChangeSelected(int32_t iSel) {
45 CFWL_ListItem* hItem = GetItem(this, iSel); 45 CFWL_ListItem* hItem = GetItem(this, iSel);
46 CFX_RectF rtInvalidate; 46 CFX_RectF rtInvalidate;
47 rtInvalidate.Reset(); 47 rtInvalidate.Reset();
48 CFWL_ListItem* hOld = GetSelItem(0); 48 CFWL_ListItem* hOld = GetSelItem(0);
49 int32_t iOld = GetItemIndex(this, hOld); 49 int32_t iOld = GetItemIndex(this, hOld);
50 if (iOld == iSel) 50 if (iOld == iSel)
51 return; 51 return;
52 if (iOld > -1) { 52 if (iOld > -1) {
53 CFWL_ListItem* hItem = GetItem(this, iOld); 53 CFWL_ListItem* hItem = GetItem(this, iOld);
54 GetItemRect(this, hItem, rtInvalidate); 54 GetItemRect(this, hItem, rtInvalidate);
55 SetSelItem(hOld, false); 55 SetSelItem(hOld, false);
56 } 56 }
57 if (hItem) { 57 if (hItem) {
58 CFX_RectF rect; 58 CFX_RectF rect;
59 CFWL_ListItem* hItem = GetItem(this, iSel); 59 CFWL_ListItem* hItem = GetItem(this, iSel);
60 GetItemRect(this, hItem, rect); 60 GetItemRect(this, hItem, rect);
61 rtInvalidate.Union(rect); 61 rtInvalidate.Union(rect);
62 CFWL_ListItem* hSel = GetItem(this, iSel); 62 CFWL_ListItem* hSel = GetItem(this, iSel);
63 SetSelItem(hSel, true); 63 SetSelItem(hSel, true);
64 } 64 }
65 if (!rtInvalidate.IsEmpty()) 65 if (!rtInvalidate.IsEmpty())
66 Repaint(&rtInvalidate); 66 Repaint(&rtInvalidate);
67 } 67 }
68 68
69 void IFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { 69 void CFWL_ComboList::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
70 fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top; 70 fx += m_pProperties->m_rtWidget.left, fy += m_pProperties->m_rtWidget.top;
71 IFWL_Widget* pOwner = GetOwner(); 71 IFWL_Widget* pOwner = GetOwner();
72 if (!pOwner) 72 if (!pOwner)
73 return; 73 return;
74 pOwner->TransformTo(m_pOuter, fx, fy); 74 pOwner->TransformTo(m_pOuter, fx, fy);
75 } 75 }
76 76
77 void IFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) { 77 void CFWL_ComboList::OnProcessMessage(CFWL_Message* pMessage) {
78 if (!pMessage) 78 if (!pMessage)
79 return; 79 return;
80 80
81 CFWL_MessageType dwHashCode = pMessage->GetClassID(); 81 CFWL_MessageType dwHashCode = pMessage->GetClassID();
82 bool backDefault = true; 82 bool backDefault = true;
83 if (dwHashCode == CFWL_MessageType::SetFocus || 83 if (dwHashCode == CFWL_MessageType::SetFocus ||
84 dwHashCode == CFWL_MessageType::KillFocus) { 84 dwHashCode == CFWL_MessageType::KillFocus) {
85 OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus); 85 OnDropListFocusChanged(pMessage, dwHashCode == CFWL_MessageType::SetFocus);
86 } else if (dwHashCode == CFWL_MessageType::Mouse) { 86 } else if (dwHashCode == CFWL_MessageType::Mouse) {
87 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 87 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
88 IFWL_ScrollBar* vertSB = GetVertScrollBar(); 88 CFWL_ScrollBar* vertSB = GetVertScrollBar();
89 if (IsShowScrollBar(true) && vertSB) { 89 if (IsShowScrollBar(true) && vertSB) {
90 CFX_RectF rect; 90 CFX_RectF rect;
91 vertSB->GetWidgetRect(rect); 91 vertSB->GetWidgetRect(rect);
92 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) { 92 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) {
93 pMsg->m_fx -= rect.left; 93 pMsg->m_fx -= rect.left;
94 pMsg->m_fy -= rect.top; 94 pMsg->m_fy -= rect.top;
95 vertSB->GetDelegate()->OnProcessMessage(pMsg); 95 vertSB->GetDelegate()->OnProcessMessage(pMsg);
96 return; 96 return;
97 } 97 }
98 } 98 }
(...skipping 16 matching lines...) Expand all
115 default: 115 default:
116 break; 116 break;
117 } 117 }
118 } else if (dwHashCode == CFWL_MessageType::Key) { 118 } else if (dwHashCode == CFWL_MessageType::Key) {
119 backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage)); 119 backDefault = !OnDropListKey(static_cast<CFWL_MsgKey*>(pMessage));
120 } 120 }
121 if (backDefault) 121 if (backDefault)
122 IFWL_ListBox::OnProcessMessage(pMessage); 122 IFWL_ListBox::OnProcessMessage(pMessage);
123 } 123 }
124 124
125 void IFWL_ComboList::OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet) { 125 void CFWL_ComboList::OnDropListFocusChanged(CFWL_Message* pMsg, bool bSet) {
126 if (bSet) 126 if (bSet)
127 return; 127 return;
128 128
129 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg); 129 CFWL_MsgKillFocus* pKill = static_cast<CFWL_MsgKillFocus*>(pMsg);
130 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 130 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
131 if (pKill->m_pSetFocus == m_pOuter || 131 if (pKill->m_pSetFocus == m_pOuter ||
132 pKill->m_pSetFocus == pOuter->GetComboEdit()) { 132 pKill->m_pSetFocus == pOuter->GetComboEdit()) {
133 pOuter->ShowDropList(false); 133 pOuter->ShowDropList(false);
134 } 134 }
135 } 135 }
136 136
137 void IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { 137 void CFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) {
138 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) { 138 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) {
139 if (m_bNotifyOwner) 139 if (m_bNotifyOwner)
140 m_bNotifyOwner = false; 140 m_bNotifyOwner = false;
141 141
142 IFWL_ScrollBar* vertSB = GetVertScrollBar(); 142 CFWL_ScrollBar* vertSB = GetVertScrollBar();
143 if (IsShowScrollBar(true) && vertSB) { 143 if (IsShowScrollBar(true) && vertSB) {
144 CFX_RectF rect; 144 CFX_RectF rect;
145 vertSB->GetWidgetRect(rect); 145 vertSB->GetWidgetRect(rect);
146 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) 146 if (rect.Contains(pMsg->m_fx, pMsg->m_fy))
147 return; 147 return;
148 } 148 }
149 149
150 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 150 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
151 if (!hItem) 151 if (!hItem)
152 return; 152 return;
153 153
154 ChangeSelected(GetItemIndex(this, hItem)); 154 ChangeSelected(GetItemIndex(this, hItem));
155 } else if (m_bNotifyOwner) { 155 } else if (m_bNotifyOwner) {
156 ClientToOuter(pMsg->m_fx, pMsg->m_fy); 156 ClientToOuter(pMsg->m_fx, pMsg->m_fy);
157 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 157 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
158 pOuter->GetDelegate()->OnProcessMessage(pMsg); 158 pOuter->GetDelegate()->OnProcessMessage(pMsg);
159 } 159 }
160 } 160 }
161 161
162 void IFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) { 162 void CFWL_ComboList::OnDropListLButtonDown(CFWL_MsgMouse* pMsg) {
163 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy)) 163 if (GetRTClient().Contains(pMsg->m_fx, pMsg->m_fy))
164 return; 164 return;
165 165
166 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 166 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
167 pOuter->ShowDropList(false); 167 pOuter->ShowDropList(false);
168 } 168 }
169 169
170 void IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { 170 void CFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) {
171 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 171 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
172 if (m_bNotifyOwner) { 172 if (m_bNotifyOwner) {
173 ClientToOuter(pMsg->m_fx, pMsg->m_fy); 173 ClientToOuter(pMsg->m_fx, pMsg->m_fy);
174 pOuter->GetDelegate()->OnProcessMessage(pMsg); 174 pOuter->GetDelegate()->OnProcessMessage(pMsg);
175 return; 175 return;
176 } 176 }
177 177
178 IFWL_ScrollBar* vertSB = GetVertScrollBar(); 178 CFWL_ScrollBar* vertSB = GetVertScrollBar();
179 if (IsShowScrollBar(true) && vertSB) { 179 if (IsShowScrollBar(true) && vertSB) {
180 CFX_RectF rect; 180 CFX_RectF rect;
181 vertSB->GetWidgetRect(rect); 181 vertSB->GetWidgetRect(rect);
182 if (rect.Contains(pMsg->m_fx, pMsg->m_fy)) 182 if (rect.Contains(pMsg->m_fx, pMsg->m_fy))
183 return; 183 return;
184 } 184 }
185 pOuter->ShowDropList(false); 185 pOuter->ShowDropList(false);
186 186
187 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); 187 CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy);
188 if (hItem) 188 if (hItem)
189 pOuter->ProcessSelChanged(true); 189 pOuter->ProcessSelChanged(true);
190 } 190 }
191 191
192 bool IFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) { 192 bool CFWL_ComboList::OnDropListKey(CFWL_MsgKey* pKey) {
193 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 193 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
194 bool bPropagate = false; 194 bool bPropagate = false;
195 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) { 195 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) {
196 uint32_t dwKeyCode = pKey->m_dwKeyCode; 196 uint32_t dwKeyCode = pKey->m_dwKeyCode;
197 switch (dwKeyCode) { 197 switch (dwKeyCode) {
198 case FWL_VKEY_Return: 198 case FWL_VKEY_Return:
199 case FWL_VKEY_Escape: { 199 case FWL_VKEY_Escape: {
200 pOuter->ShowDropList(false); 200 pOuter->ShowDropList(false);
201 return true; 201 return true;
202 } 202 }
(...skipping 12 matching lines...) Expand all
215 bPropagate = true; 215 bPropagate = true;
216 } 216 }
217 if (bPropagate) { 217 if (bPropagate) {
218 pKey->m_pDstTarget = m_pOuter; 218 pKey->m_pDstTarget = m_pOuter;
219 pOuter->GetDelegate()->OnProcessMessage(pKey); 219 pOuter->GetDelegate()->OnProcessMessage(pKey);
220 return true; 220 return true;
221 } 221 }
222 return false; 222 return false;
223 } 223 }
224 224
225 void IFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) { 225 void CFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) {
226 uint32_t dwKeyCode = pKey->m_dwKeyCode; 226 uint32_t dwKeyCode = pKey->m_dwKeyCode;
227 switch (dwKeyCode) { 227 switch (dwKeyCode) {
228 case FWL_VKEY_Up: 228 case FWL_VKEY_Up:
229 case FWL_VKEY_Down: 229 case FWL_VKEY_Down:
230 case FWL_VKEY_Home: 230 case FWL_VKEY_Home:
231 case FWL_VKEY_End: { 231 case FWL_VKEY_End: {
232 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter); 232 IFWL_ComboBox* pOuter = static_cast<IFWL_ComboBox*>(m_pOuter);
233 CFWL_ListItem* hItem = GetItem(this, pOuter->GetCurrentSelection()); 233 CFWL_ListItem* hItem = GetItem(this, pOuter->GetCurrentSelection());
234 hItem = GetListItem(hItem, dwKeyCode); 234 hItem = GetListItem(hItem, dwKeyCode);
235 if (!hItem) 235 if (!hItem)
236 break; 236 break;
237 237
238 SetSelection(hItem, hItem, true); 238 SetSelection(hItem, hItem, true);
239 ScrollToVisible(hItem); 239 ScrollToVisible(hItem);
240 CFX_RectF rtInvalidate; 240 CFX_RectF rtInvalidate;
241 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, 241 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width,
242 m_pProperties->m_rtWidget.height); 242 m_pProperties->m_rtWidget.height);
243 Repaint(&rtInvalidate); 243 Repaint(&rtInvalidate);
244 break; 244 break;
245 } 245 }
246 default: 246 default:
247 break; 247 break;
248 } 248 }
249 } 249 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_combolist.h ('k') | xfa/fwl/core/cfwl_datetimeedit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698