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

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

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

Powered by Google App Engine
This is Rietveld 408576698