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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ListBox.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 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
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 "../../include/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_ListBox.h" 9 #include "../../include/pdfwindow/PWL_ListBox.h"
10 #include "../../include/pdfwindow/PWL_Utils.h" 10 #include "../../include/pdfwindow/PWL_Utils.h"
11 #include "../../include/pdfwindow/PWL_ScrollBar.h" 11 #include "../../include/pdfwindow/PWL_ScrollBar.h"
12 #include "../../include/pdfwindow/PWL_EditCtrl.h" 12 #include "../../include/pdfwindow/PWL_EditCtrl.h"
13 #include "../../include/pdfwindow/PWL_Edit.h" 13 #include "../../include/pdfwindow/PWL_Edit.h"
14 14
15 #define IsFloatZero(f)» » » » » » ((f) < 0.0001 && (f) > -0.0001) 15 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
16 #define IsFloatBigger(fa,fb)» » » » ((fa) > (fb) && !IsFloat Zero((fa) - (fb))) 16 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
17 #define IsFloatSmaller(fa,fb)» » » » ((fa) < (fb) && !IsFloat Zero((fa) - (fb))) 17 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
18 #define IsFloatEqual(fa,fb)» » » » » IsFloatZero((fa) -(fb)) 18 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
19 19
20 /* ------------------------ CPWL_List_Notify ----------------------- */ 20 /* ------------------------ CPWL_List_Notify ----------------------- */
21 21
22 CPWL_List_Notify::CPWL_List_Notify(CPWL_ListBox* pList) : m_pList(pList) 22 CPWL_List_Notify::CPWL_List_Notify(CPWL_ListBox* pList) : m_pList(pList) {
23 { 23 ASSERT(m_pList != NULL);
24 » ASSERT(m_pList != NULL); 24 }
25 } 25
26 26 CPWL_List_Notify::~CPWL_List_Notify() {}
27 CPWL_List_Notify::~CPWL_List_Notify() 27
28 { 28 void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin,
29 } 29 FX_FLOAT fPlateMax,
30 30 FX_FLOAT fContentMin,
31 void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, 31 FX_FLOAT fContentMax,
32 » » » » » » » » » » » » FX_FLOAT fContentMin, FX_FLOAT fContentMax, 32 FX_FLOAT fSmallStep,
33 » » » » » » » » » » » » FX_FLOAT fSmallStep, FX_FLOAT fBigStep) 33 FX_FLOAT fBigStep) {
34 { 34 PWL_SCROLL_INFO Info;
35 » PWL_SCROLL_INFO Info; 35
36 36 Info.fPlateWidth = fPlateMax - fPlateMin;
37 » Info.fPlateWidth = fPlateMax - fPlateMin; 37 Info.fContentMin = fContentMin;
38 » Info.fContentMin = fContentMin; 38 Info.fContentMax = fContentMax;
39 » Info.fContentMax = fContentMax; 39 Info.fSmallStep = fSmallStep;
40 » Info.fSmallStep = fSmallStep; 40 Info.fBigStep = fBigStep;
41 » Info.fBigStep = fBigStep; 41
42 42 m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
43 » m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info) ; 43
44 44 if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
45 » if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar()) 45 if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
46 » { 46 IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
47 » » if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fConten tMin) 47 if (pScroll->IsVisible()) {
48 » » » || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.f ContentMin)) 48 pScroll->SetVisible(FALSE);
49 » » { 49 m_pList->RePosChildWnd();
50 » » » if (pScroll->IsVisible()) 50 }
51 » » » { 51 } else {
52 » » » » pScroll->SetVisible(FALSE); 52 if (!pScroll->IsVisible()) {
53 » » » » m_pList->RePosChildWnd(); 53 pScroll->SetVisible(TRUE);
54 » » » } 54 m_pList->RePosChildWnd();
55 » » } 55 }
56 » » else 56 }
57 » » { 57 }
58 » » » if (!pScroll->IsVisible()) 58 }
59 » » » { 59
60 » » » » pScroll->SetVisible(TRUE); 60 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) {
61 » » » » m_pList->RePosChildWnd(); 61 m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
62 » » » } 62 }
63 » » } 63
64 » } 64 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect* pRect) {
65 } 65 m_pList->InvalidateRect(pRect);
66
67 void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy)
68 {
69 » m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy);
70 }
71
72 void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect)
73 {
74 » m_pList->InvalidateRect(pRect);
75 } 66 }
76 67
77 /* --------------------------- CPWL_ListBox ---------------------------- */ 68 /* --------------------------- CPWL_ListBox ---------------------------- */
78 69
79 CPWL_ListBox::CPWL_ListBox() : 70 CPWL_ListBox::CPWL_ListBox()
80 » m_pList(NULL), 71 : m_pList(NULL),
81 » m_pListNotify(NULL), 72 m_pListNotify(NULL),
82 » m_bMouseDown(FALSE), 73 m_bMouseDown(FALSE),
83 » m_bHoverSel(FALSE), 74 m_bHoverSel(FALSE),
84 » m_pFillerNotify(NULL) 75 m_pFillerNotify(NULL) {
85 { 76 m_pList = IFX_List::NewList();
86 » m_pList = IFX_List::NewList(); 77
87 78 ASSERT(m_pList != NULL);
88 » ASSERT(m_pList != NULL); 79 }
89 } 80
90 81 CPWL_ListBox::~CPWL_ListBox() {
91 CPWL_ListBox::~CPWL_ListBox() 82 IFX_List::DelList(m_pList);
92 { 83 delete m_pListNotify;
93 IFX_List::DelList(m_pList); 84 m_pListNotify = NULL;
85 }
86
87 CFX_ByteString CPWL_ListBox::GetClassName() const {
88 return "CPWL_ListBox";
89 }
90
91 void CPWL_ListBox::OnCreated() {
92 if (m_pList) {
94 delete m_pListNotify; 93 delete m_pListNotify;
95 m_pListNotify = NULL; 94
96 } 95 m_pList->SetFontMap(GetFontMap());
97 96 m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this));
98 CFX_ByteString CPWL_ListBox::GetClassName() const 97
99 { 98 SetHoverSel(HasFlag(PLBS_HOVERSEL));
100 return "CPWL_ListBox"; 99 m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL));
101 } 100 m_pList->SetFontSize(GetCreationParam().fFontSize);
102 101
103 void CPWL_ListBox::OnCreated() 102 m_bHoverSel = HasFlag(PLBS_HOVERSEL);
104 { 103 }
105 if (m_pList) 104 }
106 { 105
107 delete m_pListNotify; 106 void CPWL_ListBox::OnDestroy() {
108 107 delete m_pListNotify;
109 m_pList->SetFontMap(GetFontMap()); 108 m_pListNotify = NULL;
110 m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this)); 109 }
111 110
112 SetHoverSel(HasFlag(PLBS_HOVERSEL)); 111 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
113 m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL)); 112 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
114 m_pList->SetFontSize(GetCreationParam().fFontSize); 113
115 114 CFX_ByteTextBuf sListItems;
116 m_bHoverSel = HasFlag(PLBS_HOVERSEL); 115
117 } 116 if (m_pList) {
118 } 117 CPDF_Rect rcPlate = m_pList->GetPlateRect();
119 118 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
120 void CPWL_ListBox::OnDestroy() 119 CPDF_Rect rcItem = m_pList->GetItemRect(i);
121 { 120
122 delete m_pListNotify; 121 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
123 m_pListNotify = NULL; 122 continue;
124 } 123
125 124 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
126 void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) 125 if (m_pList->IsItemSelected(i)) {
127 { 126 sListItems << CPWL_Utils::GetRectFillAppStream(
128 CPWL_Wnd::GetThisAppearanceStream(sAppStream); 127 rcItem, PWL_DEFAULT_SELBACKCOLOR);
129 128 CFX_ByteString sItem =
130 CFX_ByteTextBuf sListItems; 129 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
131 130 if (sItem.GetLength() > 0) {
132 if (m_pList) 131 sListItems << "BT\n"
133 { 132 << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR)
134 CPDF_Rect rcPlate = m_pList->GetPlateRect(); 133 << sItem << "ET\n";
135 for (int32_t i=0,sz=m_pList->GetCount(); i<sz; i++) 134 }
136 { 135 } else {
137 CPDF_Rect rcItem = m_pList->GetItemRect(i); 136 CFX_ByteString sItem =
138 137 CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
139 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate. bottom) continue; 138 if (sItem.GetLength() > 0) {
140 139 sListItems << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
141 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo ttom) * 0.5f); 140 << sItem << "ET\n";
142 if (m_pList->IsItemSelected(i)) 141 }
143 { 142 }
144 sListItems << CPWL_Utils::GetRectFillAppStream(r cItem,PWL_DEFAULT_SELBACKCOLOR); 143 }
145 CFX_ByteString sItem = CPWL_Utils::GetEditAppStr eam(m_pList->GetItemEdit(i), ptOffset); 144 }
146 if (sItem.GetLength() > 0) 145
147 { 146 if (sListItems.GetLength() > 0) {
148 sListItems << "BT\n" << CPWL_Utils::GetC olorAppStream(PWL_DEFAULT_SELTEXTCOLOR) << sItem << "ET\n"; 147 CFX_ByteTextBuf sClip;
149 } 148 CPDF_Rect rcClient = GetClientRect();
150 } 149
151 else 150 sClip << "q\n";
152 { 151 sClip << rcClient.left << " " << rcClient.bottom << " "
153 CFX_ByteString sItem = CPWL_Utils::GetEditAppStr eam(m_pList->GetItemEdit(i), ptOffset); 152 << rcClient.right - rcClient.left << " "
154 if (sItem.GetLength() > 0) 153 << rcClient.top - rcClient.bottom << " re W n\n";
155 { 154
156 sListItems << "BT\n" << CPWL_Utils::GetC olorAppStream(GetTextColor()) << sItem << "ET\n"; 155 sClip << sListItems << "Q\n";
157 } 156
158 } 157 sAppStream << "/Tx BMC\n" << sClip << "EMC\n";
159 } 158 }
160 } 159 }
161 160
162 if (sListItems.GetLength() > 0) 161 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
163 { 162 CPDF_Matrix* pUser2Device) {
164 CFX_ByteTextBuf sClip; 163 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
165 CPDF_Rect rcClient = GetClientRect(); 164
166 165 if (m_pList) {
167 sClip << "q\n"; 166 CPDF_Rect rcPlate = m_pList->GetPlateRect();
168 sClip << rcClient.left << " " << rcClient.bottom << " " 167 CPDF_Rect rcList = GetListRect();
169 << rcClient.right - rcClient.left << " " << rcClient .top - rcClient.bottom << " re W n\n"; 168 CPDF_Rect rcClient = GetClientRect();
170 169
171 sClip << sListItems << "Q\n"; 170 for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
172 171 CPDF_Rect rcItem = m_pList->GetItemRect(i);
173 sAppStream << "/Tx BMC\n" << sClip << "EMC\n"; 172 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
174 } 173 continue;
175 } 174
176 175 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
177 void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pU ser2Device) 176 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) {
178 { 177 CPDF_Rect rcContent = pEdit->GetContentRect();
179 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); 178 if (rcContent.Width() > rcClient.Width())
180 179 rcItem.Intersect(rcList);
181 if (m_pList) 180 else
182 { 181 rcItem.Intersect(rcClient);
183 CPDF_Rect rcPlate = m_pList->GetPlateRect(); 182 }
184 CPDF_Rect rcList = GetListRect(); 183
185 CPDF_Rect rcClient = GetClientRect(); 184 if (m_pList->IsItemSelected(i)) {
186 185 // CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
187 for (int32_t i=0,sz=m_pList->GetCount(); i<sz; i++) 186 //ArgbEncode(255,0,51,113));
188 { 187 IFX_SystemHandler* pSysHandler = GetSystemHandler();
189 CPDF_Rect rcItem = m_pList->GetItemRect(i); 188 if (pSysHandler && pSysHandler->IsSelectionImplemented()) {
190 if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate. bottom) continue; 189 IFX_Edit::DrawEdit(
191 190 pDevice, pUser2Device, m_pList->GetItemEdit(i),
192 CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bo ttom) * 0.5f); 191 CPWL_Utils::PWLColorToFXColor(GetTextColor()),
193 if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) 192 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList,
194 { 193 ptOffset, NULL, pSysHandler, m_pFormFiller);
195 CPDF_Rect rcContent = pEdit->GetContentRect(); 194 pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem);
196 if (rcContent.Width() > rcClient.Width()) 195 } else {
197 rcItem.Intersect(rcList); 196 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
198 else 197 ArgbEncode(255, 0, 51, 113));
199 rcItem.Intersect(rcClient); 198 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
200 } 199 ArgbEncode(255, 255, 255, 255), 0, rcList,
201 200 ptOffset, NULL, pSysHandler, m_pFormFiller);
202 if (m_pList->IsItemSelected(i)) 201 }
203 { 202 } else {
204 // CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, ArgbEncode(255,0,51,113)); 203 IFX_SystemHandler* pSysHandler = GetSystemHandler();
205 IFX_SystemHandler* pSysHandler = GetSystemHandle r(); 204 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
206 if(pSysHandler && pSysHandler->IsSelectionImplem ented()) 205 CPWL_Utils::PWLColorToFXColor(GetTextColor()),
207 { 206 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()),
208 IFX_Edit::DrawEdit(pDevice, pUser2Device , m_pList->GetItemEdit(i), CPWL_Utils::PWLColorToFXColor(GetTextColor()), CPWL_U tils::PWLColorToFXColor(GetTextStrokeColor()), 207 rcList, ptOffset, NULL, pSysHandler, NULL);
209 rcList, ptOffset, NULL,pSysHandl er, m_pFormFiller); 208 }
210 pSysHandler->OutputSelectedRect(m_pFormF iller, rcItem); 209 }
211 } 210 }
212 else 211 }
213 { 212
214 CPWL_Utils::DrawFillRect(pDevice, pUser2 Device, rcItem, ArgbEncode(255,0,51,113)); 213 FX_BOOL CPWL_ListBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
215 IFX_Edit::DrawEdit(pDevice, pUser2Device , m_pList->GetItemEdit(i), ArgbEncode(255,255,255,255), 0, 214 CPWL_Wnd::OnKeyDown(nChar, nFlag);
216 rcList, ptOffset, NULL, pSysHand ler, m_pFormFiller); 215
217 } 216 if (!m_pList)
218 } 217 return FALSE;
219 else 218
220 { 219 switch (nChar) {
221 IFX_SystemHandler* pSysHandler = GetSystemHandle r(); 220 default:
222 IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pLis t->GetItemEdit(i), 221 return FALSE;
223 CPWL_Utils::PWLColorToFXColor(Ge tTextColor()), 222 case FWL_VKEY_Up:
224 CPWL_Utils::PWLColorToFXColor(Ge tTextStrokeColor()), 223 case FWL_VKEY_Down:
225 rcList, ptOffset, NULL,pSysHandl er, NULL); 224 case FWL_VKEY_Home:
226 225 case FWL_VKEY_Left:
227 } 226 case FWL_VKEY_End:
228 } 227 case FWL_VKEY_Right:
229 } 228 break;
230 } 229 }
231 230
232 FX_BOOL CPWL_ListBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) 231 switch (nChar) {
233 { 232 case FWL_VKEY_Up:
234 CPWL_Wnd::OnKeyDown(nChar, nFlag); 233 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
235 234 break;
236 if (!m_pList) return FALSE; 235 case FWL_VKEY_Down:
237 236 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
238 switch (nChar) 237 break;
239 { 238 case FWL_VKEY_Home:
240 default: 239 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
241 return FALSE; 240 break;
242 case FWL_VKEY_Up: 241 case FWL_VKEY_Left:
243 case FWL_VKEY_Down: 242 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
244 case FWL_VKEY_Home: 243 break;
245 case FWL_VKEY_Left: 244 case FWL_VKEY_End:
246 case FWL_VKEY_End: 245 m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
247 case FWL_VKEY_Right: 246 break;
248 break; 247 case FWL_VKEY_Right:
249 } 248 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
250 249 break;
251 switch (nChar) 250 case FWL_VKEY_Delete:
252 { 251 break;
253 case FWL_VKEY_Up: 252 }
254 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 253
255 break; 254 FX_BOOL bExit = FALSE;
256 case FWL_VKEY_Down: 255 OnNotifySelChanged(TRUE, bExit, nFlag);
257 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 256
258 break; 257 return TRUE;
259 case FWL_VKEY_Home: 258 }
260 m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 259
261 break; 260 FX_BOOL CPWL_ListBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
262 case FWL_VKEY_Left: 261 CPWL_Wnd::OnChar(nChar, nFlag);
263 m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 262
264 break; 263 if (!m_pList)
265 case FWL_VKEY_End: 264 return FALSE;
266 m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 265
267 break; 266 if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
268 case FWL_VKEY_Right: 267 return FALSE;
269 m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); 268
270 break; 269 FX_BOOL bExit = FALSE;
271 case FWL_VKEY_Delete: 270 OnNotifySelChanged(TRUE, bExit, nFlag);
272 break; 271
273 } 272 return TRUE;
274 273 }
275 FX_BOOL bExit = FALSE; 274
276 OnNotifySelChanged(TRUE,bExit,nFlag); 275 FX_BOOL CPWL_ListBox::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
277 276 CPWL_Wnd::OnLButtonDown(point, nFlag);
278 return TRUE; 277
279 } 278 if (ClientHitTest(point)) {
280 279 m_bMouseDown = TRUE;
281 FX_BOOL CPWL_ListBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) 280 SetFocus();
282 { 281 SetCapture();
283 CPWL_Wnd::OnChar(nChar,nFlag); 282
284 283 if (m_pList)
285 if (!m_pList) return FALSE; 284 m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
286 285 }
287 if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE; 286
288 287 return TRUE;
289 FX_BOOL bExit = FALSE; 288 }
290 OnNotifySelChanged(TRUE,bExit, nFlag); 289
291 290 FX_BOOL CPWL_ListBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
292 return TRUE; 291 CPWL_Wnd::OnLButtonUp(point, nFlag);
293 } 292
294 293 if (m_bMouseDown) {
295 FX_BOOL CPWL_ListBox::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 294 ReleaseCapture();
296 { 295 m_bMouseDown = FALSE;
297 CPWL_Wnd::OnLButtonDown(point,nFlag); 296 }
298 297
299 if (ClientHitTest(point)) 298 FX_BOOL bExit = FALSE;
300 { 299 OnNotifySelChanged(FALSE, bExit, nFlag);
301 m_bMouseDown = TRUE; 300
302 SetFocus(); 301 return TRUE;
303 SetCapture(); 302 }
304 303
305 if (m_pList) 304 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) {
306 m_pList->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag)); 305 m_bHoverSel = bHoverSel;
307 } 306 }
308 307
309 return TRUE; 308 FX_BOOL CPWL_ListBox::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) {
310 } 309 CPWL_Wnd::OnMouseMove(point, nFlag);
311 310
312 FX_BOOL CPWL_ListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 311 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) {
313 { 312 if (m_pList)
314 CPWL_Wnd::OnLButtonUp(point,nFlag); 313 m_pList->Select(m_pList->GetItemIndex(point));
315 314 }
316 if (m_bMouseDown) 315
317 { 316 if (m_bMouseDown) {
318 ReleaseCapture(); 317 if (m_pList)
319 m_bMouseDown = FALSE; 318 m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
320 } 319 }
321 320
322 FX_BOOL bExit = FALSE; 321 return TRUE;
323 OnNotifySelChanged(FALSE,bExit,nFlag); 322 }
324 323
325 return TRUE; 324 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd,
326 } 325 FX_DWORD msg,
327 326 intptr_t wParam,
328 void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) 327 intptr_t lParam) {
329 { 328 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
330 m_bHoverSel = bHoverSel; 329
331 } 330 FX_FLOAT fPos;
332 331
333 FX_BOOL CPWL_ListBox::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag) 332 switch (msg) {
334 { 333 case PNM_SETSCROLLINFO:
335 CPWL_Wnd::OnMouseMove(point, nFlag); 334 switch (wParam) {
336 335 case SBT_VSCROLL:
337 if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) 336 if (CPWL_Wnd* pChild = GetVScrollBar()) {
338 { 337 pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
339 if (m_pList) 338 }
340 m_pList->Select(m_pList->GetItemIndex(point)); 339 break;
341 } 340 }
342 341 break;
343 if (m_bMouseDown) 342 case PNM_SETSCROLLPOS:
344 { 343 switch (wParam) {
345 if (m_pList) 344 case SBT_VSCROLL:
346 m_pList->OnMouseMove(point,IsSHIFTpressed(nFlag),IsCTRLp ressed(nFlag)); 345 if (CPWL_Wnd* pChild = GetVScrollBar()) {
347 } 346 pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
348 347 }
349 return TRUE; 348 break;
350 } 349 }
351 350 break;
352 void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intpt r_t lParam) 351 case PNM_SCROLLWINDOW:
353 { 352 fPos = *(FX_FLOAT*)lParam;
354 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); 353 switch (wParam) {
355 354 case SBT_VSCROLL:
356 FX_FLOAT fPos; 355 if (m_pList)
357 356 m_pList->SetScrollPos(CPDF_Point(0, fPos));
358 switch (msg) 357 break;
359 { 358 }
360 case PNM_SETSCROLLINFO: 359 break;
361 switch (wParam) 360 }
362 { 361 }
363 case SBT_VSCROLL: 362
364 if (CPWL_Wnd * pChild = GetVScrollBar()) 363 void CPWL_ListBox::KillFocus() {
365 { 364 CPWL_Wnd::KillFocus();
366 pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,l Param); 365 }
367 } 366
368 break; 367 void CPWL_ListBox::RePosChildWnd() {
369 } 368 CPWL_Wnd::RePosChildWnd();
370 break; 369
371 case PNM_SETSCROLLPOS: 370 if (m_pList)
372 switch (wParam) 371 m_pList->SetPlateRect(GetListRect());
373 { 372 }
374 case SBT_VSCROLL: 373
375 if (CPWL_Wnd * pChild = GetVScrollBar()) 374 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown,
376 { 375 FX_BOOL& bExit,
377 pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lP aram); 376 FX_DWORD nFlag) {
378 } 377 if (m_pFillerNotify) {
379 break; 378 FX_BOOL bRC = TRUE;
380 } 379 CFX_WideString swChange = GetText();
381 break; 380 CFX_WideString strChangeEx;
382 case PNM_SCROLLWINDOW: 381 int nSelStart = 0;
383 fPos = *(FX_FLOAT*)lParam; 382 int nSelEnd = swChange.GetLength();
384 switch (wParam) 383 m_pFillerNotify->OnBeforeKeyStroke(FALSE, GetAttachedData(), 0, swChange,
385 { 384 strChangeEx, nSelStart, nSelEnd,
386 case SBT_VSCROLL: 385 bKeyDown, bRC, bExit, nFlag);
387 if (m_pList) 386 if (bExit)
388 m_pList->SetScrollPos(CPDF_Point(0,fPos)); 387 return;
389 break; 388
390 } 389 m_pFillerNotify->OnAfterKeyStroke(FALSE, GetAttachedData(), bExit, nFlag);
391 break; 390 }
392 } 391 }
393 } 392
394 393 CPDF_Rect CPWL_ListBox::GetFocusRect() const {
395 void CPWL_ListBox::KillFocus() 394 if (m_pList && m_pList->IsMultipleSel()) {
396 { 395 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
397 CPWL_Wnd::KillFocus(); 396 rcCaret.Intersect(GetClientRect());
398 } 397 return rcCaret;
399 398 }
400 void CPWL_ListBox::RePosChildWnd() 399
401 { 400 return CPWL_Wnd::GetFocusRect();
402 CPWL_Wnd::RePosChildWnd(); 401 }
403 402
404 if (m_pList) 403 void CPWL_ListBox::AddString(const FX_WCHAR* string) {
405 m_pList->SetPlateRect(GetListRect()); 404 if (m_pList) {
406 } 405 m_pList->AddString(string);
407 406 }
408 void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL & bExit, FX_DWO RD nFlag) 407 }
409 { 408
410 if (m_pFillerNotify) 409 CFX_WideString CPWL_ListBox::GetText() const {
411 { 410 if (m_pList)
412 FX_BOOL bRC = TRUE; 411 return m_pList->GetText();
413 CFX_WideString swChange = GetText(); 412
414 CFX_WideString strChangeEx; 413 return L"";
415 int nSelStart = 0; 414 }
416 int nSelEnd = swChange.GetLength(); 415
417 m_pFillerNotify->OnBeforeKeyStroke(FALSE, GetAttachedData(), 0, swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag); 416 void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize) {
418 if (bExit) return; 417 if (m_pList)
419 418 m_pList->SetFontSize(fFontSize);
420 m_pFillerNotify->OnAfterKeyStroke(FALSE, GetAttachedData(), bExi t,nFlag); 419 }
421 } 420
422 } 421 FX_FLOAT CPWL_ListBox::GetFontSize() const {
423 422 if (m_pList)
424 CPDF_Rect CPWL_ListBox::GetFocusRect() const 423 return m_pList->GetFontSize();
425 { 424 return 0.0f;
426 if (m_pList && m_pList->IsMultipleSel()) 425 }
427 { 426
428 CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret()); 427 void CPWL_ListBox::Select(int32_t nItemIndex) {
429 rcCaret.Intersect(GetClientRect()); 428 if (m_pList)
430 return rcCaret; 429 m_pList->Select(nItemIndex);
431 } 430 }
432 431
433 return CPWL_Wnd::GetFocusRect(); 432 void CPWL_ListBox::SetCaret(int32_t nItemIndex) {
434 } 433 if (m_pList)
435 434 m_pList->SetCaret(nItemIndex);
436 void CPWL_ListBox::AddString(const FX_WCHAR* string) 435 }
437 { 436
438 if (m_pList) 437 void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) {
439 { 438 if (m_pList)
440 m_pList->AddString(string); 439 m_pList->SetTopItem(nItemIndex);
441 } 440 }
442 } 441
443 442 void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) {
444 CFX_WideString CPWL_ListBox::GetText() const 443 if (m_pList)
445 { 444 m_pList->ScrollToListItem(nItemIndex);
446 if (m_pList) 445 }
447 return m_pList->GetText(); 446
448 447 void CPWL_ListBox::ResetContent() {
449 return L""; 448 if (m_pList)
450 } 449 m_pList->Empty();
451 450 }
452 void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize) 451
453 { 452 void CPWL_ListBox::Reset() {
454 if (m_pList) 453 if (m_pList)
455 m_pList->SetFontSize(fFontSize); 454 m_pList->Cancel();
456 } 455 }
457 456
458 FX_FLOAT CPWL_ListBox::GetFontSize() const 457 FX_BOOL CPWL_ListBox::IsMultipleSel() const {
459 { 458 if (m_pList)
460 if (m_pList) 459 return m_pList->IsMultipleSel();
461 return m_pList->GetFontSize(); 460
462 return 0.0f; 461 return FALSE;
463 } 462 }
464 463
465 void CPWL_ListBox::Select(int32_t nItemIndex) 464 int32_t CPWL_ListBox::GetCaretIndex() const {
466 { 465 if (m_pList)
467 if (m_pList) 466 return m_pList->GetCaret();
468 m_pList->Select(nItemIndex); 467
469 } 468 return -1;
470 469 }
471 void CPWL_ListBox::SetCaret(int32_t nItemIndex) 470
472 { 471 int32_t CPWL_ListBox::GetCurSel() const {
473 if (m_pList) 472 if (m_pList)
474 m_pList->SetCaret(nItemIndex); 473 return m_pList->GetSelect();
475 } 474
476 475 return -1;
477 void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) 476 }
478 { 477
479 if (m_pList) 478 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const {
480 m_pList->SetTopItem(nItemIndex); 479 if (m_pList)
481 } 480 return m_pList->IsItemSelected(nItemIndex);
482 481
483 void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) 482 return FALSE;
484 { 483 }
485 if (m_pList) 484
486 m_pList->ScrollToListItem(nItemIndex); 485 int32_t CPWL_ListBox::GetTopVisibleIndex() const {
487 } 486 if (m_pList) {
488 487 m_pList->ScrollToListItem(m_pList->GetFirstSelected());
489 void CPWL_ListBox::ResetContent() 488 return m_pList->GetTopItem();
490 { 489 }
491 if (m_pList) 490
492 m_pList->Empty(); 491 return -1;
493 } 492 }
494 493
495 void CPWL_ListBox::Reset() 494 int32_t CPWL_ListBox::GetCount() const {
496 { 495 if (m_pList)
497 if (m_pList) 496 return m_pList->GetCount();
498 m_pList->Cancel(); 497
499 } 498 return 0;
500 499 }
501 FX_BOOL CPWL_ListBox::IsMultipleSel() const 500
502 { 501 int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const {
503 if (m_pList) 502 if (m_pList)
504 return m_pList->IsMultipleSel(); 503 return m_pList->FindNext(nIndex, nChar);
505 504
506 return FALSE; 505 return nIndex;
507 } 506 }
508 507
509 int32_t CPWL_ListBox::GetCaretIndex() const 508 CPDF_Rect CPWL_ListBox::GetContentRect() const {
510 { 509 if (m_pList)
511 if (m_pList) 510 return m_pList->GetContentRect();
512 return m_pList->GetCaret(); 511
513 512 return CPDF_Rect();
514 return -1; 513 }
515 } 514
516 515 FX_FLOAT CPWL_ListBox::GetFirstHeight() const {
517 int32_t CPWL_ListBox::GetCurSel() const 516 if (m_pList)
518 { 517 return m_pList->GetFirstHeight();
519 if (m_pList) 518
520 return m_pList->GetSelect(); 519 return 0.0f;
521 520 }
522 return -1; 521
523 } 522 CPDF_Rect CPWL_ListBox::GetListRect() const {
524 523 return CPWL_Utils::DeflateRect(
525 FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const 524 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
526 { 525 }
527 if (m_pList) 526
528 return m_pList->IsItemSelected(nItemIndex); 527 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta,
529 528 const CPDF_Point& point,
530 return FALSE; 529 FX_DWORD nFlag) {
531 } 530 if (!m_pList)
532 531 return FALSE;
533 int32_t CPWL_ListBox::GetTopVisibleIndex() const 532
534 { 533 if (zDelta < 0) {
535 if (m_pList) 534 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
536 { 535 } else {
537 m_pList->ScrollToListItem(m_pList->GetFirstSelected()); 536 m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
538 return m_pList->GetTopItem(); 537 }
539 } 538
540 539 FX_BOOL bExit = FALSE;
541 return -1; 540 OnNotifySelChanged(FALSE, bExit, nFlag);
542 } 541 return TRUE;
543 542 }
544 int32_t CPWL_ListBox::GetCount() const
545 {
546 if (m_pList)
547 return m_pList->GetCount();
548
549 return 0;
550 }
551
552 int32_t CPWL_ListBox::FindNext(int32_t nIndex,FX_WCHAR nChar) const
553 {
554 if (m_pList)
555 return m_pList->FindNext(nIndex,nChar);
556
557 return nIndex;
558 }
559
560 CPDF_Rect CPWL_ListBox::GetContentRect() const
561 {
562 if (m_pList)
563 return m_pList->GetContentRect();
564
565 return CPDF_Rect();
566 }
567
568 FX_FLOAT CPWL_ListBox::GetFirstHeight() const
569 {
570 if (m_pList)
571 return m_pList->GetFirstHeight();
572
573 return 0.0f;
574 }
575
576 CPDF_Rect CPWL_ListBox::GetListRect() const
577 {
578 return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth ()+GetInnerBorderWidth()));
579 }
580
581 FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DW ORD nFlag)
582 {
583 if (!m_pList) return FALSE;
584
585 if (zDelta < 0)
586 {
587 m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
588 }
589 else
590 {
591 m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
592 }
593
594 FX_BOOL bExit = FALSE;
595 OnNotifySelChanged(FALSE,bExit, nFlag);
596 return TRUE;
597 }
598
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698