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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_IconList.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_ListCtrl.h" 9 #include "../../include/pdfwindow/PWL_ListCtrl.h"
10 #include "../../include/pdfwindow/PWL_IconList.h" 10 #include "../../include/pdfwindow/PWL_IconList.h"
11 #include "../../include/pdfwindow/PWL_Utils.h" 11 #include "../../include/pdfwindow/PWL_Utils.h"
12 #include "../../include/pdfwindow/PWL_ScrollBar.h" 12 #include "../../include/pdfwindow/PWL_ScrollBar.h"
13 #include "../../include/pdfwindow/PWL_Label.h" 13 #include "../../include/pdfwindow/PWL_Label.h"
14 14
15 #define PWL_IconList_ITEM_ICON_LEFTMARGIN» » 10.0f 15 #define PWL_IconList_ITEM_ICON_LEFTMARGIN 10.0f
16 #define PWL_IconList_ITEM_WIDTH»» » » » 20.0f 16 #define PWL_IconList_ITEM_WIDTH 20.0f
17 #define PWL_IconList_ITEM_HEIGHT» » » » 20.0f 17 #define PWL_IconList_ITEM_HEIGHT 20.0f
18 #define PWL_IconList_ITEM_SPACE»» » » » 4.0f 18 #define PWL_IconList_ITEM_SPACE 4.0f
19 19
20 /* ------------------ CPWL_IconList_Item ------------------- */ 20 /* ------------------ CPWL_IconList_Item ------------------- */
21 21
22 CPWL_IconList_Item::CPWL_IconList_Item() : 22 CPWL_IconList_Item::CPWL_IconList_Item()
23 » m_nIconIndex(-1), 23 : m_nIconIndex(-1), m_pData(NULL), m_bSelected(FALSE), m_pText(NULL) {
24 » m_pData(NULL), 24 }
25 » m_bSelected(FALSE), 25
26 » m_pText(NULL) 26 CPWL_IconList_Item::~CPWL_IconList_Item() {
27 { 27 }
28 } 28
29 29 CFX_ByteString CPWL_IconList_Item::GetClassName() const {
30 CPWL_IconList_Item::~CPWL_IconList_Item() 30 return "CPWL_IconList_Item";
31 { 31 }
32 } 32
33 33 FX_FLOAT CPWL_IconList_Item::GetItemHeight(FX_FLOAT fLimitWidth) {
34 CFX_ByteString CPWL_IconList_Item::GetClassName() const 34 return PWL_IconList_ITEM_HEIGHT;
35 { 35 }
36 » return "CPWL_IconList_Item"; 36
37 } 37 void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice,
38 38 CPDF_Matrix* pUser2Device) {
39 FX_FLOAT CPWL_IconList_Item::GetItemHeight(FX_FLOAT fLimitWidth) 39 CPDF_Rect rcClient = GetClientRect();
40 { 40
41 » return PWL_IconList_ITEM_HEIGHT; 41 if (m_bSelected) {
42 } 42 if (this->IsEnabled()) {
43 43 CPWL_Utils::DrawFillRect(
44 void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matr ix* pUser2Device) 44 pDevice,
45 { 45 pUser2Device,
46 » CPDF_Rect rcClient = GetClientRect(); 46 rcClient,
47 47 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR,
48 » if (m_bSelected) 48 this->GetTransparency()));
49 » { 49 } else {
50 » » if (this->IsEnabled()) 50 CPWL_Utils::DrawFillRect(
51 » » { 51 pDevice,
52 » » » CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient , 52 pUser2Device,
53 » » » » CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBAC KCOLOR,this->GetTransparency())); 53 rcClient,
54 » » } 54 CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR,
55 » » else 55 this->GetTransparency()));
56 » » { 56 }
57 » » » CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient , 57 }
58 » » » » CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTG RAYCOLOR,this->GetTransparency())); 58
59 » » } 59 CPDF_Rect rcIcon = rcClient;
60 » } 60 rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN;
61 61 rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH;
62 » CPDF_Rect rcIcon = rcClient; 62
63 » rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN; 63 CPWL_Utils::DrawIconAppStream(pDevice,
64 » rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH; 64 pUser2Device,
65 65 m_nIconIndex,
66 » CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nIconIndex, rcIco n, 66 rcIcon,
67 » » m_crIcon, m_pText->GetTextColor(), this->GetTransparency()); 67 m_crIcon,
68 } 68 m_pText->GetTextColor(),
69 69 this->GetTransparency());
70 void CPWL_IconList_Item::SetSelect(FX_BOOL bSelected) 70 }
71 { 71
72 » m_bSelected = bSelected; 72 void CPWL_IconList_Item::SetSelect(FX_BOOL bSelected) {
73 73 m_bSelected = bSelected;
74 » if (bSelected) 74
75 » » m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR); 75 if (bSelected)
76 » else 76 m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
77 » » m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR); 77 else
78 78 m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
79 } 79 }
80 80
81 FX_BOOL»CPWL_IconList_Item::IsSelected() const 81 FX_BOOL CPWL_IconList_Item::IsSelected() const {
82 { 82 return m_bSelected;
83 » return m_bSelected; 83 }
84 } 84
85 85 void CPWL_IconList_Item::CreateChildWnd(const PWL_CREATEPARAM& cp) {
86 void CPWL_IconList_Item::CreateChildWnd(const PWL_CREATEPARAM & cp) 86 m_pText = new CPWL_Label;
87 { 87
88 » m_pText = new CPWL_Label; 88 PWL_CREATEPARAM lcp = cp;
89 89 lcp.pParentWnd = this;
90 » PWL_CREATEPARAM lcp = cp; 90 lcp.dwFlags = PWS_CHILD | PWS_VISIBLE | PES_LEFT | PES_CENTER;
91 » lcp.pParentWnd = this; 91 lcp.sTextColor = PWL_DEFAULT_BLACKCOLOR;
92 » lcp.dwFlags = PWS_CHILD | PWS_VISIBLE | PES_LEFT | PES_CENTER; 92 lcp.fFontSize = 12;
93 » lcp.sTextColor = PWL_DEFAULT_BLACKCOLOR; 93 m_pText->Create(lcp);
94 » lcp.fFontSize = 12; 94 }
95 » m_pText->Create(lcp); 95
96 } 96 void CPWL_IconList_Item::SetData(void* pData) {
97 97 m_pData = pData;
98 void CPWL_IconList_Item::SetData(void* pData) 98 }
99 { 99
100 » m_pData = pData; 100 void CPWL_IconList_Item::SetIcon(FX_INT32 nIconIndex) {
101 } 101 m_nIconIndex = nIconIndex;
102 102 }
103 void CPWL_IconList_Item::SetIcon(FX_INT32 nIconIndex) 103
104 { 104 void CPWL_IconList_Item::SetText(const CFX_WideString& str) {
105 » m_nIconIndex = nIconIndex; 105 m_pText->SetText(str);
106 } 106 }
107 107
108 void CPWL_IconList_Item::SetText(const CFX_WideString& str) 108 CFX_WideString CPWL_IconList_Item::GetText() const {
109 { 109 return m_pText->GetText();
110 » m_pText->SetText(str); 110 }
111 } 111
112 112 void CPWL_IconList_Item::RePosChildWnd() {
113 CFX_WideString CPWL_IconList_Item::GetText() const 113 CPDF_Rect rcClient = GetClientRect();
114 { 114
115 » return m_pText->GetText(); 115 rcClient.left +=
116 } 116 (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_WIDTH +
117 117 PWL_IconList_ITEM_ICON_LEFTMARGIN);
118 void CPWL_IconList_Item::RePosChildWnd() 118
119 { 119 m_pText->Move(rcClient, TRUE, FALSE);
120 » CPDF_Rect rcClient = GetClientRect(); 120 }
121 121
122 » rcClient.left += (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_ WIDTH + PWL_IconList_ITEM_ICON_LEFTMARGIN); 122 void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) {
123 123 m_crIcon = color;
124 » m_pText->Move(rcClient, TRUE, FALSE); 124 }
125 } 125
126 126 void CPWL_IconList_Item::OnEnabled() {
127 void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) 127 if (m_bSelected)
128 { 128 m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
129 » m_crIcon = color; 129 else
130 } 130 m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
131 131
132 void CPWL_IconList_Item::OnEnabled() 132 this->InvalidateRect();
133 { 133 }
134 » if (m_bSelected) 134
135 » » m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR); 135 void CPWL_IconList_Item::OnDisabled() {
136 » else 136 m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
137 » » m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR); 137
138 138 this->InvalidateRect();
139 » this->InvalidateRect();
140 }
141
142 void CPWL_IconList_Item::OnDisabled()
143 {
144 » m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
145
146 » this->InvalidateRect();
147 } 139 }
148 140
149 /* ----------------- CPWL_IconList_Content ----------------- */ 141 /* ----------------- CPWL_IconList_Content ----------------- */
150 142
151 CPWL_IconList_Content::CPWL_IconList_Content(FX_INT32 nListCount) : 143 CPWL_IconList_Content::CPWL_IconList_Content(FX_INT32 nListCount)
152 m_nSelectIndex(-1), 144 : m_nSelectIndex(-1),
153 m_pNotify(NULL), 145 m_pNotify(NULL),
154 m_bEnableNotify(TRUE), 146 m_bEnableNotify(TRUE),
155 m_bMouseDown(FALSE), 147 m_bMouseDown(FALSE),
156 m_nListCount(nListCount) 148 m_nListCount(nListCount) {
157 { 149 }
158 } 150
159 151 CPWL_IconList_Content::~CPWL_IconList_Content() {
160 CPWL_IconList_Content::~CPWL_IconList_Content() 152 }
161 { 153
162 } 154 void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM& cp) {
163 155 for (FX_INT32 i = 0; i < m_nListCount; i++) {
164 void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM & cp) 156 CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item();
165 { 157
166 for (FX_INT32 i=0; i<m_nListCount; i++) 158 PWL_CREATEPARAM icp = cp;
167 { 159 icp.pParentWnd = this;
168 CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item(); 160 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP;
169 161 pNewItem->Create(icp);
170 PWL_CREATEPARAM icp = cp; 162 }
171 icp.pParentWnd = this; 163
172 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP; 164 this->SetItemSpace(PWL_IconList_ITEM_SPACE);
173 pNewItem->Create(icp); 165 this->ResetContent(0);
174 } 166
175 167 if (CPWL_Wnd* pParent = this->GetParentWindow()) {
176 this->SetItemSpace(PWL_IconList_ITEM_SPACE); 168 CPDF_Rect rcScroll = this->GetScrollArea();
177 this->ResetContent(0); 169 this->GetScrollPos();
178 170
179 if (CPWL_Wnd * pParent = this->GetParentWindow()) 171 PWL_SCROLL_INFO sInfo;
180 { 172 sInfo.fContentMin = rcScroll.bottom;
181 CPDF_Rect rcScroll = this->GetScrollArea(); 173 sInfo.fContentMax = rcScroll.top;
182 this->GetScrollPos(); 174 sInfo.fPlateWidth = GetClientRect().Height();
183 175 sInfo.fSmallStep = 13.0f;
184 PWL_SCROLL_INFO sInfo; 176 sInfo.fBigStep = sInfo.fPlateWidth;
185 sInfo.fContentMin = rcScroll.bottom; 177
186 sInfo.fContentMax = rcScroll.top; 178 pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo);
187 sInfo.fPlateWidth = GetClientRect().Height(); 179 }
188 sInfo.fSmallStep = 13.0f; 180 }
189 sInfo.fBigStep = sInfo.fPlateWidth; 181
190 182 FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point& point,
191 pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTP TR)&sInfo); 183 FX_DWORD nFlag) {
192 } 184 SetFocus();
193 } 185
194 186 SetCapture();
195 FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 187 m_bMouseDown = TRUE;
196 { 188
197 SetFocus(); 189 FX_INT32 nItemIndex = FindItemIndex(point);
198 190 SetSelect(nItemIndex);
199 SetCapture(); 191 ScrollToItem(nItemIndex);
200 m_bMouseDown = TRUE; 192
201 193 return TRUE;
202 FX_INT32 nItemIndex = FindItemIndex(point); 194 }
203 SetSelect(nItemIndex); 195
204 ScrollToItem(nItemIndex); 196 FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point& point,
205 197 FX_DWORD nFlag) {
206 return TRUE; 198 m_bMouseDown = FALSE;
207 } 199 ReleaseCapture();
208 200
209 FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point & point, FX_DWORD nF lag) 201 return TRUE;
210 { 202 }
211 m_bMouseDown = FALSE; 203
212 ReleaseCapture(); 204 FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point& point,
213 205 FX_DWORD nFlag) {
214 return TRUE; 206 if (m_bMouseDown) {
215 } 207 FX_INT32 nItemIndex = FindItemIndex(point);
216 208 SetSelect(nItemIndex);
217 FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point & point, FX_DWORD nF lag) 209 ScrollToItem(nItemIndex);
218 { 210 }
219 if (m_bMouseDown) 211
220 { 212 return TRUE;
221 FX_INT32 nItemIndex = FindItemIndex(point); 213 }
222 SetSelect(nItemIndex); 214
223 ScrollToItem(nItemIndex); 215 FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
224 } 216 switch (nChar) {
225 217 case FWL_VKEY_Up:
226 return TRUE; 218 if (m_nSelectIndex > 0) {
227 } 219 FX_INT32 nItemIndex = m_nSelectIndex - 1;
228 220 SetSelect(nItemIndex);
229 FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) 221 ScrollToItem(nItemIndex);
230 { 222 }
231 switch (nChar) 223 return TRUE;
232 { 224 case FWL_VKEY_Down:
233 case FWL_VKEY_Up: 225 if (m_nSelectIndex < m_nListCount - 1) {
234 if (m_nSelectIndex > 0) 226 FX_INT32 nItemIndex = m_nSelectIndex + 1;
235 { 227 SetSelect(nItemIndex);
236 FX_INT32 nItemIndex = m_nSelectIndex - 1; 228 ScrollToItem(nItemIndex);
237 SetSelect(nItemIndex); 229 }
238 ScrollToItem(nItemIndex); 230 return TRUE;
239 } 231 }
240 return TRUE; 232
241 case FWL_VKEY_Down: 233 return FALSE;
242 if (m_nSelectIndex < m_nListCount-1) 234 }
243 { 235
244 FX_INT32 nItemIndex = m_nSelectIndex + 1; 236 FX_INT32 CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point) {
245 SetSelect(nItemIndex); 237 FX_INT32 nIndex = 0;
246 ScrollToItem(nItemIndex); 238 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
247 } 239 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
248 return TRUE; 240 CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
249 } 241
250 242 if (point.y < rcWnd.top) {
251 return FALSE; 243 nIndex = i;
252 } 244 }
253 245 }
254 FX_INT32 CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point) 246 }
255 { 247
256 FX_INT32 nIndex = 0; 248 return nIndex;
257 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) 249 }
258 { 250
259 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) 251 void CPWL_IconList_Content::ScrollToItem(FX_INT32 nItemIndex) {
260 { 252 CPDF_Rect rcClient = GetClientRect();
261 CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindo wRect()); 253
262 254 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
263 if (point.y < rcWnd.top) 255 CPDF_Rect rcOrigin = pItem->GetWindowRect();
264 { 256 CPDF_Rect rcWnd = pItem->ChildToParent(rcOrigin);
265 nIndex = i; 257
266 } 258 if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top)) {
267 } 259 CPDF_Point ptScroll = GetScrollPos();
268 } 260
269 261 if (rcWnd.top > rcClient.top) {
270 return nIndex; 262 ptScroll.y = rcOrigin.top;
271 } 263 } else if (rcWnd.bottom < rcClient.bottom) {
272 264 ptScroll.y = rcOrigin.bottom + rcClient.Height();
273 void CPWL_IconList_Content::ScrollToItem(FX_INT32 nItemIndex) 265 }
274 { 266
275 CPDF_Rect rcClient = GetClientRect(); 267 this->SetScrollPos(ptScroll);
276 268 this->ResetFace();
277 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) 269 this->InvalidateRect();
278 { 270 if (CPWL_Wnd* pParent = this->GetParentWindow()) {
279 CPDF_Rect rcOrigin = pItem->GetWindowRect(); 271 pParent->OnNotify(
280 CPDF_Rect rcWnd = pItem->ChildToParent(rcOrigin); 272 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y);
281 273 }
282 if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top )) 274 }
283 { 275 }
284 CPDF_Point ptScroll = GetScrollPos(); 276 }
285 277
286 if (rcWnd.top > rcClient.top) 278 void CPWL_IconList_Content::SetSelect(FX_INT32 nIndex) {
287 { 279 if (m_nSelectIndex != nIndex) {
288 ptScroll.y = rcOrigin.top; 280 SelectItem(m_nSelectIndex, FALSE);
289 } 281 SelectItem(nIndex, TRUE);
290 else if (rcWnd.bottom < rcClient.bottom) 282 m_nSelectIndex = nIndex;
291 { 283
292 ptScroll.y = rcOrigin.bottom + rcClient.Height() ; 284 if (IPWL_IconList_Notify* pNotify = GetNotify())
293 } 285 pNotify->OnNoteListSelChanged(nIndex);
294 286 }
295 this->SetScrollPos(ptScroll); 287 }
296 this->ResetFace(); 288
297 this->InvalidateRect(); 289 FX_INT32 CPWL_IconList_Content::GetSelect() const {
298 if (CPWL_Wnd* pParent = this->GetParentWindow()) 290 return m_nSelectIndex;
299 { 291 }
300 pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VS CROLL, (FX_INTPTR)&ptScroll.y); 292
301 } 293 IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const {
302 } 294 if (m_bEnableNotify)
303 } 295 return m_pNotify;
304 } 296 return NULL;
305 297 }
306 void CPWL_IconList_Content::SetSelect(FX_INT32 nIndex) 298
307 { 299 void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) {
308 if (m_nSelectIndex != nIndex) 300 m_pNotify = pNotify;
309 { 301 }
310 SelectItem(m_nSelectIndex, FALSE); 302
311 SelectItem(nIndex, TRUE); 303 void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) {
312 m_nSelectIndex = nIndex; 304 m_bEnableNotify = bNotify;
313 305 }
314 if (IPWL_IconList_Notify* pNotify = GetNotify()) 306
315 pNotify->OnNoteListSelChanged(nIndex); 307 void CPWL_IconList_Content::SelectItem(FX_INT32 nItemIndex, FX_BOOL bSelect) {
316 } 308 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
317 } 309 pItem->SetSelect(bSelect);
318 310 pItem->InvalidateRect();
319 FX_INT32 CPWL_IconList_Content::GetSelect() const 311 }
320 { 312 }
321 return m_nSelectIndex; 313
322 } 314 CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(
323 315 FX_INT32 nItemIndex) const {
324 IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const 316 if (nItemIndex >= 0 && nItemIndex < m_aChildren.GetSize()) {
325 { 317 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nItemIndex)) {
326 if (m_bEnableNotify) 318 if (pChild->GetClassName() == "CPWL_IconList_Item") {
327 return m_pNotify; 319 return (CPWL_IconList_Item*)pChild;
328 return NULL; 320 }
329 } 321 }
330 322 }
331 void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) 323
332 { 324 return NULL;
333 m_pNotify = pNotify; 325 }
334 } 326
335 327 void CPWL_IconList_Content::SetListData(FX_INT32 nItemIndex, void* pData) {
336 void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) 328 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
337 { 329 pItem->SetData(pData);
338 m_bEnableNotify = bNotify; 330 }
339 } 331
340 332 void CPWL_IconList_Content::SetListIcon(FX_INT32 nItemIndex,
341 void CPWL_IconList_Content::SelectItem(FX_INT32 nItemIndex, FX_BOOL bSelect) 333 FX_INT32 nIconIndex) {
342 { 334 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
343 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) 335 pItem->SetIcon(nIconIndex);
344 { 336 }
345 pItem->SetSelect(bSelect); 337
346 pItem->InvalidateRect(); 338 void CPWL_IconList_Content::SetListString(FX_INT32 nItemIndex,
347 } 339 const CFX_WideString& str) {
348 } 340 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
349 341 pItem->SetText(str);
350 CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(FX_INT32 nItemIndex) cons t 342 }
351 { 343
352 if (nItemIndex >= 0 && nItemIndex<m_aChildren.GetSize()) 344 CFX_WideString CPWL_IconList_Content::GetListString(FX_INT32 nItemIndex) const {
353 { 345 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
354 if (CPWL_Wnd * pChild = m_aChildren.GetAt(nItemIndex)) 346 return pItem->GetText();
355 { 347
356 if (pChild->GetClassName() == "CPWL_IconList_Item") 348 return L"";
357 { 349 }
358 return (CPWL_IconList_Item*)pChild; 350
359 } 351 void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color) {
360 } 352 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
361 } 353 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
362 354 if (pChild->GetClassName() == "CPWL_IconList_Item") {
363 return NULL; 355 CPWL_IconList_Item* pItem = (CPWL_IconList_Item*)pChild;
364 } 356 pItem->SetIconFillColor(color);
365 357 pItem->InvalidateRect();
366 void CPWL_IconList_Content::SetListData(FX_INT32 nItemIndex, void* pData) 358 }
367 { 359 }
368 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) 360 }
369 pItem->SetData(pData);
370 }
371
372 void CPWL_IconList_Content::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex )
373 {
374 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
375 pItem->SetIcon(nIconIndex);
376 }
377
378 void CPWL_IconList_Content::SetListString(FX_INT32 nItemIndex, const CFX_WideStr ing& str)
379 {
380 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
381 pItem->SetText(str);
382 }
383
384 CFX_WideString CPWL_IconList_Content::GetListString(FX_INT32 nItemIndex) const
385 {
386 if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
387 return pItem->GetText();
388
389 return L"";
390 }
391
392 void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color)
393 {
394 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
395 {
396 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
397 {
398 if (pChild->GetClassName() == "CPWL_IconList_Item")
399 {
400 CPWL_IconList_Item* pItem = (CPWL_IconList_Item* )pChild;
401 pItem->SetIconFillColor(color);
402 pItem->InvalidateRect();
403 }
404 }
405 }
406
407 } 361 }
408 362
409 /* -------------------- CPWL_IconList --------------------- */ 363 /* -------------------- CPWL_IconList --------------------- */
410 364
411 CPWL_IconList::CPWL_IconList(FX_INT32 nListCount) : 365 CPWL_IconList::CPWL_IconList(FX_INT32 nListCount)
412 » m_pListContent(NULL), 366 : m_pListContent(NULL), m_nListCount(nListCount) {
413 » m_nListCount(nListCount) 367 }
414 { 368
415 } 369 CPWL_IconList::~CPWL_IconList() {
416 370 }
417 CPWL_IconList::~CPWL_IconList() 371
418 { 372 void CPWL_IconList::RePosChildWnd() {
419 } 373 CPWL_Wnd::RePosChildWnd();
420 374
421 void CPWL_IconList::RePosChildWnd() 375 if (m_pListContent)
422 { 376 m_pListContent->Move(GetClientRect(), TRUE, FALSE);
423 » CPWL_Wnd::RePosChildWnd(); 377 }
424 378
425 » if (m_pListContent) 379 void CPWL_IconList::CreateChildWnd(const PWL_CREATEPARAM& cp) {
426 » » m_pListContent->Move(GetClientRect(), TRUE, FALSE); 380 m_pListContent = new CPWL_IconList_Content(m_nListCount);
427 } 381
428 382 PWL_CREATEPARAM ccp = cp;
429 void CPWL_IconList::CreateChildWnd(const PWL_CREATEPARAM & cp) 383 ccp.pParentWnd = this;
430 { 384 ccp.dwFlags = PWS_CHILD | PWS_VISIBLE;
431 » m_pListContent = new CPWL_IconList_Content(m_nListCount); 385 m_pListContent->Create(ccp);
432 386 }
433 » PWL_CREATEPARAM ccp = cp; 387
434 » ccp.pParentWnd = this; 388 void CPWL_IconList::OnCreated() {
435 » ccp.dwFlags = PWS_CHILD | PWS_VISIBLE; 389 if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar()) {
436 » m_pListContent->Create(ccp); 390 pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
437 } 391 pScrollBar->SetTransparency(255);
438 392 pScrollBar->SetNotifyForever(TRUE);
439 void CPWL_IconList::OnCreated() 393 }
440 { 394 }
441 » if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar()) 395
442 » { 396 void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd,
443 » » pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT); 397 FX_DWORD msg,
444 » » pScrollBar->SetTransparency(255); 398 FX_INTPTR wParam,
445 » » pScrollBar->SetNotifyForever(TRUE); 399 FX_INTPTR lParam) {
446 » } 400 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
447 } 401
448 402 if (wParam == SBT_VSCROLL) {
449 void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_ INTPTR lParam) 403 switch (msg) {
450 { 404 case PNM_SETSCROLLINFO:
451 » CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); 405 if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
452 406 if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar()) {
453 » if (wParam == SBT_VSCROLL) 407 if (pInfo->fContentMax - pInfo->fContentMin > pInfo->fPlateWidth) {
454 » {» » 408 if (!pScrollBar->IsVisible()) {
455 » » switch (msg) 409 pScrollBar->SetVisible(TRUE);
456 » » { 410 RePosChildWnd();
457 » » case PNM_SETSCROLLINFO: 411 } else {
458 » » » if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) 412 }
459 » » » { 413 } else {
460 » » » » if (CPWL_ScrollBar* pScrollBar = this->GetVScrol lBar()) 414 if (pScrollBar->IsVisible()) {
461 » » » » { 415 pScrollBar->SetVisible(FALSE);
462 » » » » » if (pInfo->fContentMax - pInfo->fContent Min > pInfo->fPlateWidth) 416 RePosChildWnd();
463 » » » » » { 417 }
464 » » » » » » if (!pScrollBar->IsVisible()) 418
465 » » » » » » { 419 if (m_pListContent)
466 » » » » » » » pScrollBar->SetVisible(T RUE); 420 m_pListContent->SetScrollPos(CPDF_Point(0.0f, 0.0f));
467 » » » » » » » RePosChildWnd();» » » 421 }
468 » » » » » » } 422
469 » » » » » » else 423 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
470 » » » » » » { 424 }
471 » » » » » » } 425 }
472 » » » » » } 426 return;
473 » » » » » else 427 case PNM_SCROLLWINDOW:
474 » » » » » { 428 if (m_pListContent) {
475 » » » » » » if (pScrollBar->IsVisible()) 429 m_pListContent->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
476 » » » » » » { 430 m_pListContent->ResetFace();
477 » » » » » » » pScrollBar->SetVisible(F ALSE); 431 m_pListContent->InvalidateRect(NULL);
478 » » » » » » » RePosChildWnd(); 432 }
479 » » » » » » } 433 return;
480 434 case PNM_SETSCROLLPOS:
481 » » » » » » if (m_pListContent) 435 if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar())
482 » » » » » » » m_pListContent->SetScrol lPos(CPDF_Point(0.0f,0.0f)); 436 pScrollBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
483 » » » » » } 437 return;
484 » » » » » 438 }
485 » » » » » pScrollBar->OnNotify(pWnd,PNM_SETSCROLLI NFO,wParam,lParam); 439 }
486 » » » » } 440 }
487 » » » } 441
488 » » » return; 442 void CPWL_IconList::SetSelect(FX_INT32 nIndex) {
489 » » case PNM_SCROLLWINDOW: 443 m_pListContent->SetSelect(nIndex);
490 » » » if (m_pListContent) 444 }
491 » » » { 445
492 » » » » m_pListContent->SetScrollPos(CPDF_Point(0.0f, *( FX_FLOAT*)lParam)); 446 void CPWL_IconList::SetTopItem(FX_INT32 nIndex) {
493 » » » » m_pListContent->ResetFace(); 447 m_pListContent->ScrollToItem(nIndex);
494 » » » » m_pListContent->InvalidateRect(NULL); 448 }
495 » » » } 449
496 » » » return; 450 FX_INT32 CPWL_IconList::GetSelect() const {
497 » » case PNM_SETSCROLLPOS: 451 return m_pListContent->GetSelect();
498 » » » if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar()) 452 }
499 » » » » pScrollBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wPara m,lParam); 453
500 » » » return; 454 void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) {
501 » » } 455 m_pListContent->SetNotify(pNotify);
502 » } 456 }
503 } 457
504 458 void CPWL_IconList::EnableNotify(FX_BOOL bNotify) {
505 void CPWL_IconList::SetSelect(FX_INT32 nIndex) 459 m_pListContent->EnableNotify(bNotify);
506 { 460 }
507 » m_pListContent->SetSelect(nIndex); 461
508 } 462 void CPWL_IconList::SetListData(FX_INT32 nItemIndex, void* pData) {
509 463 m_pListContent->SetListData(nItemIndex, pData);
510 void CPWL_IconList::SetTopItem(FX_INT32 nIndex) 464 }
511 { 465
512 » m_pListContent->ScrollToItem(nIndex); 466 void CPWL_IconList::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex) {
513 } 467 m_pListContent->SetListIcon(nItemIndex, nIconIndex);
514 468 }
515 FX_INT32 CPWL_IconList::GetSelect() const 469
516 { 470 void CPWL_IconList::SetListString(FX_INT32 nItemIndex,
517 » return m_pListContent->GetSelect(); 471 const CFX_WideString& str) {
518 } 472 m_pListContent->SetListString(nItemIndex, str);
519 473 }
520 void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) 474
521 { 475 CFX_WideString CPWL_IconList::GetListString(FX_INT32 nItemIndex) const {
522 » m_pListContent->SetNotify(pNotify); 476 return m_pListContent->GetListString(nItemIndex);
523 } 477 }
524 478
525 void CPWL_IconList::EnableNotify(FX_BOOL bNotify) 479 void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) {
526 { 480 m_pListContent->SetIconFillColor(color);
527 » m_pListContent->EnableNotify(bNotify); 481 }
528 } 482
529 483 FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta,
530 void CPWL_IconList::SetListData(FX_INT32 nItemIndex, void* pData) 484 const CPDF_Point& point,
531 { 485 FX_DWORD nFlag) {
532 » m_pListContent->SetListData(nItemIndex, pData); 486 CPDF_Point ptScroll = m_pListContent->GetScrollPos();
533 } 487 CPDF_Rect rcScroll = m_pListContent->GetScrollArea();
534 488 CPDF_Rect rcContents = m_pListContent->GetClientRect();
535 void CPWL_IconList::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex) 489
536 { 490 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
537 » m_pListContent->SetListIcon(nItemIndex, nIconIndex); 491 CPDF_Point ptNew = ptScroll;
538 } 492
539 493 if (zDelta > 0)
540 void CPWL_IconList::SetListString(FX_INT32 nItemIndex, const CFX_WideString& str ) 494 ptNew.y += 30;
541 { 495 else
542 » m_pListContent->SetListString(nItemIndex, str); 496 ptNew.y -= 30;
543 } 497
544 498 if (ptNew.y > rcScroll.top)
545 CFX_WideString CPWL_IconList::GetListString(FX_INT32 nItemIndex) const 499 ptNew.y = rcScroll.top;
546 { 500 if (ptNew.y < rcScroll.bottom + rcContents.Height())
547 » return m_pListContent->GetListString(nItemIndex); 501 ptNew.y = rcScroll.bottom + rcContents.Height();
548 } 502 if (ptNew.y < rcScroll.bottom)
549 503 ptNew.y = rcScroll.bottom;
550 void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) 504
551 { 505 if (ptNew.y != ptScroll.y) {
552 » m_pListContent->SetIconFillColor(color); 506 m_pListContent->SetScrollPos(ptNew);
553 } 507 m_pListContent->ResetFace();
554 508 m_pListContent->InvalidateRect(NULL);
555 FX_BOOL»CPWL_IconList::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_D WORD nFlag) 509
556 { 510 if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar())
557 » CPDF_Point ptScroll = m_pListContent->GetScrollPos(); 511 pScrollBar->OnNotify(
558 » CPDF_Rect rcScroll = m_pListContent->GetScrollArea(); 512 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
559 » CPDF_Rect rcContents = m_pListContent->GetClientRect(); 513
560 514 return TRUE;
561 » if (rcScroll.top - rcScroll.bottom > rcContents.Height()) 515 }
562 » { 516 }
563 » » CPDF_Point ptNew = ptScroll; 517
564 518 return FALSE;
565 » » if (zDelta > 0) 519 }
566 » » » ptNew.y += 30;
567 » » else
568 » » » ptNew.y -= 30;
569
570 » » if (ptNew.y > rcScroll.top)
571 » » » ptNew.y = rcScroll.top;
572 » » if (ptNew.y < rcScroll.bottom + rcContents.Height())
573 » » » ptNew.y = rcScroll.bottom + rcContents.Height();
574 » » if (ptNew.y < rcScroll.bottom)
575 » » » ptNew.y = rcScroll.bottom;
576
577 » » if (ptNew.y != ptScroll.y)
578 » » {
579 » » » m_pListContent->SetScrollPos(ptNew);
580 » » » m_pListContent->ResetFace();
581 » » » m_pListContent->InvalidateRect(NULL);
582 » » »
583 » » » if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar())
584 » » » » pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT _VSCROLL, (FX_INTPTR)&ptNew.y);
585
586 » » » return TRUE;
587 » » }
588 » }
589
590 » return FALSE;
591 }
592
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698