]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listctrl.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
0208334d RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
bd8289c1 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | #ifdef __GNUG__ | |
510fc784 RR |
11 | #pragma implementation "listctrl.h" |
12 | #pragma implementation "listctrlbase.h" | |
c801d85f KB |
13 | #endif |
14 | ||
1e6d9499 JS |
15 | // For compilers that support precompilation, includes "wx.h". |
16 | #include "wx/wxprec.h" | |
17 | ||
18 | #ifdef __BORLANDC__ | |
19 | #pragma hdrstop | |
20 | #endif | |
21 | ||
0208334d RR |
22 | #include "wx/dcscreen.h" |
23 | #include "wx/app.h" | |
02527779 | 24 | #include "wx/listctrl.h" |
f60d0f94 | 25 | #include "wx/generic/imaglist.h" |
f6bcfd97 | 26 | #include "wx/dynarray.h" |
c801d85f | 27 | |
3fb435df RR |
28 | #ifdef __WXGTK__ |
29 | #include <gtk/gtk.h> | |
30 | #include "wx/gtk/win_gtk.h" | |
31 | #endif | |
32 | ||
7c74e7fe | 33 | #ifndef wxUSE_GENERIC_LIST_EXTENSIONS |
d6d26e04 | 34 | #define wxUSE_GENERIC_LIST_EXTENSIONS 1 |
7c74e7fe SC |
35 | #endif |
36 | ||
2e4df4bf VZ |
37 | // ---------------------------------------------------------------------------- |
38 | // events | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
41 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG) | |
42 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG) | |
43 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT) | |
44 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT) | |
45 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM) | |
46 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS) | |
47 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO) | |
48 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO) | |
49 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED) | |
50 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED) | |
51 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN) | |
52 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM) | |
53 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK) | |
54 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK) | |
55 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK) | |
56 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED) | |
57 | ||
efbb7287 VZ |
58 | // ============================================================================ |
59 | // private classes | |
60 | // ============================================================================ | |
61 | ||
62 | //----------------------------------------------------------------------------- | |
63 | // wxListItemData (internal) | |
64 | //----------------------------------------------------------------------------- | |
65 | ||
66 | class WXDLLEXPORT wxListItemData : public wxObject | |
67 | { | |
68 | public: | |
69 | wxString m_text; | |
70 | int m_image; | |
71 | long m_data; | |
72 | int m_xpos,m_ypos; | |
73 | int m_width,m_height; | |
74 | ||
75 | wxListItemAttr *m_attr; | |
76 | ||
77 | public: | |
78 | wxListItemData(); | |
79 | ~wxListItemData() { delete m_attr; } | |
80 | ||
81 | wxListItemData( const wxListItem &info ); | |
82 | void SetItem( const wxListItem &info ); | |
83 | void SetText( const wxString &s ); | |
84 | void SetImage( int image ); | |
85 | void SetData( long data ); | |
86 | void SetPosition( int x, int y ); | |
87 | void SetSize( int width, int height ); | |
88 | bool HasImage() const; | |
89 | bool HasText() const; | |
90 | bool IsHit( int x, int y ) const; | |
91 | void GetText( wxString &s ); | |
92 | const wxString& GetText() { return m_text; } | |
93 | int GetX( void ) const; | |
94 | int GetY( void ) const; | |
95 | int GetWidth() const; | |
96 | int GetHeight() const; | |
97 | int GetImage() const; | |
98 | void GetItem( wxListItem &info ) const; | |
99 | ||
100 | wxListItemAttr *GetAttributes() const { return m_attr; } | |
101 | ||
102 | private: | |
103 | DECLARE_DYNAMIC_CLASS(wxListItemData); | |
104 | }; | |
105 | ||
106 | //----------------------------------------------------------------------------- | |
107 | // wxListHeaderData (internal) | |
108 | //----------------------------------------------------------------------------- | |
109 | ||
110 | class WXDLLEXPORT wxListHeaderData : public wxObject | |
111 | { | |
112 | protected: | |
113 | long m_mask; | |
114 | int m_image; | |
115 | wxString m_text; | |
116 | int m_format; | |
117 | int m_width; | |
118 | int m_xpos,m_ypos; | |
119 | int m_height; | |
120 | ||
121 | public: | |
122 | wxListHeaderData(); | |
123 | wxListHeaderData( const wxListItem &info ); | |
124 | void SetItem( const wxListItem &item ); | |
125 | void SetPosition( int x, int y ); | |
126 | void SetWidth( int w ); | |
127 | void SetFormat( int format ); | |
128 | void SetHeight( int h ); | |
129 | bool HasImage() const; | |
130 | bool HasText() const; | |
131 | bool IsHit( int x, int y ) const; | |
132 | void GetItem( wxListItem &item ); | |
133 | void GetText( wxString &s ); | |
134 | int GetImage() const; | |
135 | int GetWidth() const; | |
136 | int GetFormat() const; | |
f6bcfd97 | 137 | |
efbb7287 VZ |
138 | private: |
139 | DECLARE_DYNAMIC_CLASS(wxListHeaderData); | |
140 | }; | |
141 | ||
142 | //----------------------------------------------------------------------------- | |
143 | // wxListLineData (internal) | |
144 | //----------------------------------------------------------------------------- | |
145 | ||
146 | class WXDLLEXPORT wxListLineData : public wxObject | |
147 | { | |
148 | public: | |
149 | wxList m_items; | |
150 | wxRect m_bound_all; | |
151 | wxRect m_bound_label; | |
152 | wxRect m_bound_icon; | |
153 | wxRect m_bound_hilight; | |
154 | int m_mode; | |
155 | bool m_hilighted; | |
156 | wxBrush *m_hilightBrush; | |
157 | int m_spacing; | |
158 | wxListMainWindow *m_owner; | |
159 | ||
160 | void DoDraw( wxDC *dc, bool hilight, bool paintBG ); | |
161 | ||
162 | public: | |
163 | wxListLineData() {} | |
164 | wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush ); | |
165 | void CalculateSize( wxDC *dc, int spacing ); | |
166 | void SetPosition( wxDC *dc, int x, int y, int window_width ); | |
167 | void SetColumnPosition( int index, int x ); | |
168 | void GetSize( int &width, int &height ); | |
169 | void GetExtent( int &x, int &y, int &width, int &height ); | |
170 | void GetLabelExtent( int &x, int &y, int &width, int &height ); | |
171 | long IsHit( int x, int y ); | |
172 | void InitItems( int num ); | |
173 | void SetItem( int index, const wxListItem &info ); | |
174 | void GetItem( int index, wxListItem &info ); | |
175 | void GetText( int index, wxString &s ); | |
176 | void SetText( int index, const wxString s ); | |
177 | int GetImage( int index ); | |
178 | void GetRect( wxRect &rect ); | |
179 | void Hilight( bool on ); | |
180 | void ReverseHilight(); | |
181 | void DrawRubberBand( wxDC *dc, bool on ); | |
182 | void Draw( wxDC *dc ); | |
183 | bool IsInRect( int x, int y, const wxRect &rect ); | |
184 | bool IsHilighted(); | |
185 | void AssignRect( wxRect &dest, int x, int y, int width, int height ); | |
186 | void AssignRect( wxRect &dest, const wxRect &source ); | |
f6bcfd97 | 187 | |
efbb7287 VZ |
188 | private: |
189 | void SetAttributes(wxDC *dc, | |
190 | const wxListItemAttr *attr, | |
191 | const wxColour& colText, const wxFont& font, | |
192 | bool hilight); | |
193 | ||
194 | DECLARE_DYNAMIC_CLASS(wxListLineData); | |
195 | }; | |
196 | ||
f6bcfd97 BP |
197 | |
198 | WX_DECLARE_EXPORTED_OBJARRAY(wxListLineData, wxListLineDataArray); | |
199 | #include "wx/arrimpl.cpp" | |
200 | WX_DEFINE_OBJARRAY(wxListLineDataArray); | |
201 | ||
efbb7287 VZ |
202 | //----------------------------------------------------------------------------- |
203 | // wxListHeaderWindow (internal) | |
204 | //----------------------------------------------------------------------------- | |
205 | ||
206 | class WXDLLEXPORT wxListHeaderWindow : public wxWindow | |
207 | { | |
208 | protected: | |
209 | wxListMainWindow *m_owner; | |
210 | wxCursor *m_currentCursor; | |
211 | wxCursor *m_resizeCursor; | |
212 | bool m_isDragging; | |
f6bcfd97 BP |
213 | |
214 | // column being resized | |
215 | int m_column; | |
216 | ||
217 | // divider line position in logical (unscrolled) coords | |
218 | int m_currentX; | |
219 | ||
220 | // minimal position beyond which the divider line can't be dragged in | |
221 | // logical coords | |
222 | int m_minX; | |
efbb7287 VZ |
223 | |
224 | public: | |
225 | wxListHeaderWindow(); | |
f6bcfd97 BP |
226 | virtual ~wxListHeaderWindow(); |
227 | ||
228 | wxListHeaderWindow( wxWindow *win, | |
229 | wxWindowID id, | |
230 | wxListMainWindow *owner, | |
231 | const wxPoint &pos = wxDefaultPosition, | |
232 | const wxSize &size = wxDefaultSize, | |
233 | long style = 0, | |
234 | const wxString &name = "wxlistctrlcolumntitles" ); | |
235 | ||
efbb7287 | 236 | void DoDrawRect( wxDC *dc, int x, int y, int w, int h ); |
efbb7287 | 237 | void DrawCurrent(); |
f6bcfd97 BP |
238 | void AdjustDC(wxDC& dc); |
239 | ||
240 | void OnPaint( wxPaintEvent &event ); | |
efbb7287 VZ |
241 | void OnMouse( wxMouseEvent &event ); |
242 | void OnSetFocus( wxFocusEvent &event ); | |
243 | ||
f6bcfd97 BP |
244 | // needs refresh |
245 | bool m_dirty; | |
246 | ||
efbb7287 VZ |
247 | private: |
248 | DECLARE_DYNAMIC_CLASS(wxListHeaderWindow) | |
249 | DECLARE_EVENT_TABLE() | |
250 | }; | |
251 | ||
252 | //----------------------------------------------------------------------------- | |
253 | // wxListRenameTimer (internal) | |
254 | //----------------------------------------------------------------------------- | |
255 | ||
256 | class WXDLLEXPORT wxListRenameTimer: public wxTimer | |
257 | { | |
258 | private: | |
259 | wxListMainWindow *m_owner; | |
260 | ||
261 | public: | |
262 | wxListRenameTimer( wxListMainWindow *owner ); | |
263 | void Notify(); | |
264 | }; | |
265 | ||
266 | //----------------------------------------------------------------------------- | |
267 | // wxListTextCtrl (internal) | |
268 | //----------------------------------------------------------------------------- | |
269 | ||
270 | class WXDLLEXPORT wxListTextCtrl: public wxTextCtrl | |
271 | { | |
272 | private: | |
273 | bool *m_accept; | |
274 | wxString *m_res; | |
275 | wxListMainWindow *m_owner; | |
276 | wxString m_startValue; | |
277 | ||
278 | public: | |
279 | wxListTextCtrl() {} | |
280 | wxListTextCtrl( wxWindow *parent, const wxWindowID id, | |
281 | bool *accept, wxString *res, wxListMainWindow *owner, | |
282 | const wxString &value = "", | |
283 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, | |
284 | int style = 0, | |
285 | const wxValidator& validator = wxDefaultValidator, | |
809934d2 | 286 | const wxString &name = "listctrltextctrl" ); |
efbb7287 | 287 | void OnChar( wxKeyEvent &event ); |
c13cace1 | 288 | void OnKeyUp( wxKeyEvent &event ); |
efbb7287 VZ |
289 | void OnKillFocus( wxFocusEvent &event ); |
290 | ||
291 | private: | |
292 | DECLARE_DYNAMIC_CLASS(wxListTextCtrl); | |
293 | DECLARE_EVENT_TABLE() | |
294 | }; | |
295 | ||
296 | //----------------------------------------------------------------------------- | |
297 | // wxListMainWindow (internal) | |
298 | //----------------------------------------------------------------------------- | |
299 | ||
300 | class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow | |
301 | { | |
302 | public: | |
303 | long m_mode; | |
f6bcfd97 | 304 | wxListLineDataArray m_lines; |
efbb7287 VZ |
305 | wxList m_columns; |
306 | wxListLineData *m_current; | |
307 | wxListLineData *m_currentEdit; | |
308 | int m_visibleLines; | |
309 | wxBrush *m_hilightBrush; | |
310 | wxColour *m_hilightColour; | |
311 | int m_xScroll,m_yScroll; | |
312 | bool m_dirty; | |
313 | wxImageList *m_small_image_list; | |
314 | wxImageList *m_normal_image_list; | |
315 | int m_small_spacing; | |
316 | int m_normal_spacing; | |
317 | bool m_hasFocus; | |
318 | bool m_usedKeys; | |
319 | bool m_lastOnSame; | |
320 | wxTimer *m_renameTimer; | |
321 | bool m_renameAccept; | |
322 | wxString m_renameRes; | |
323 | bool m_isCreated; | |
324 | int m_dragCount; | |
325 | wxPoint m_dragStart; | |
326 | ||
327 | // for double click logic | |
328 | wxListLineData *m_lineLastClicked, | |
329 | *m_lineBeforeLastClicked; | |
330 | ||
331 | public: | |
332 | wxListMainWindow(); | |
333 | wxListMainWindow( wxWindow *parent, wxWindowID id, | |
334 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, | |
809934d2 | 335 | long style = 0, const wxString &name = "listctrlmainwindow" ); |
efbb7287 VZ |
336 | ~wxListMainWindow(); |
337 | void RefreshLine( wxListLineData *line ); | |
338 | void OnPaint( wxPaintEvent &event ); | |
339 | void HilightAll( bool on ); | |
05a7f61d VZ |
340 | void SendNotify( wxListLineData *line, |
341 | wxEventType command, | |
342 | wxPoint point = wxDefaultPosition ); | |
efbb7287 VZ |
343 | void FocusLine( wxListLineData *line ); |
344 | void UnfocusLine( wxListLineData *line ); | |
345 | void SelectLine( wxListLineData *line ); | |
346 | void DeselectLine( wxListLineData *line ); | |
347 | void DeleteLine( wxListLineData *line ); | |
348 | ||
349 | void EditLabel( long item ); | |
350 | void Edit( long item ) { EditLabel(item); } // deprecated | |
351 | void OnRenameTimer(); | |
352 | void OnRenameAccept(); | |
353 | ||
354 | void OnMouse( wxMouseEvent &event ); | |
355 | void MoveToFocus(); | |
356 | void OnArrowChar( wxListLineData *newCurrent, bool shiftDown ); | |
357 | void OnChar( wxKeyEvent &event ); | |
358 | void OnKeyDown( wxKeyEvent &event ); | |
359 | void OnSetFocus( wxFocusEvent &event ); | |
360 | void OnKillFocus( wxFocusEvent &event ); | |
361 | void OnSize( wxSizeEvent &event ); | |
362 | void OnScroll(wxScrollWinEvent& event) ; | |
f6bcfd97 | 363 | |
efbb7287 VZ |
364 | void DrawImage( int index, wxDC *dc, int x, int y ); |
365 | void GetImageSize( int index, int &width, int &height ); | |
366 | int GetIndexOfLine( const wxListLineData *line ); | |
367 | int GetTextLength( wxString &s ); // should be const | |
368 | ||
369 | void SetImageList( wxImageList *imageList, int which ); | |
370 | void SetItemSpacing( int spacing, bool isSmall = FALSE ); | |
371 | int GetItemSpacing( bool isSmall = FALSE ); | |
372 | void SetColumn( int col, wxListItem &item ); | |
373 | void SetColumnWidth( int col, int width ); | |
374 | void GetColumn( int col, wxListItem &item ); | |
375 | int GetColumnWidth( int vol ); | |
376 | int GetColumnCount(); | |
377 | int GetCountPerPage(); | |
378 | void SetItem( wxListItem &item ); | |
379 | void GetItem( wxListItem &item ); | |
380 | void SetItemState( long item, long state, long stateMask ); | |
381 | int GetItemState( long item, long stateMask ); | |
382 | int GetItemCount(); | |
383 | void GetItemRect( long index, wxRect &rect ); | |
384 | bool GetItemPosition( long item, wxPoint& pos ); | |
385 | int GetSelectedItemCount(); | |
386 | void SetMode( long mode ); | |
387 | long GetMode() const; | |
388 | void CalculatePositions(); | |
389 | void RealizeChanges(); | |
390 | long GetNextItem( long item, int geometry, int state ); | |
391 | void DeleteItem( long index ); | |
392 | void DeleteAllItems(); | |
393 | void DeleteColumn( int col ); | |
394 | void DeleteEverything(); | |
395 | void EnsureVisible( long index ); | |
396 | long FindItem( long start, const wxString& str, bool partial = FALSE ); | |
397 | long FindItem( long start, long data); | |
398 | long HitTest( int x, int y, int &flags ); | |
399 | void InsertItem( wxListItem &item ); | |
400 | // void AddItem( wxListItem &item ); | |
401 | void InsertColumn( long col, wxListItem &item ); | |
402 | // void AddColumn( wxListItem &item ); | |
403 | void SortItems( wxListCtrlCompare fn, long data ); | |
404 | ||
405 | private: | |
406 | DECLARE_DYNAMIC_CLASS(wxListMainWindow); | |
407 | DECLARE_EVENT_TABLE() | |
408 | }; | |
409 | ||
410 | // ============================================================================ | |
411 | // implementation | |
412 | // ============================================================================ | |
413 | ||
c801d85f KB |
414 | //----------------------------------------------------------------------------- |
415 | // wxListItemData | |
416 | //----------------------------------------------------------------------------- | |
417 | ||
418 | IMPLEMENT_DYNAMIC_CLASS(wxListItemData,wxObject); | |
419 | ||
fd9811b1 | 420 | wxListItemData::wxListItemData() |
c801d85f | 421 | { |
92976ab6 RR |
422 | m_image = -1; |
423 | m_data = 0; | |
424 | m_xpos = 0; | |
425 | m_ypos = 0; | |
426 | m_width = 0; | |
427 | m_height = 0; | |
0530737d | 428 | m_attr = NULL; |
e1e955e1 | 429 | } |
c801d85f KB |
430 | |
431 | wxListItemData::wxListItemData( const wxListItem &info ) | |
432 | { | |
92976ab6 RR |
433 | m_image = -1; |
434 | m_data = 0; | |
0530737d VZ |
435 | m_attr = NULL; |
436 | ||
92976ab6 | 437 | SetItem( info ); |
e1e955e1 | 438 | } |
c801d85f KB |
439 | |
440 | void wxListItemData::SetItem( const wxListItem &info ) | |
441 | { | |
92976ab6 RR |
442 | if (info.m_mask & wxLIST_MASK_TEXT) m_text = info.m_text; |
443 | if (info.m_mask & wxLIST_MASK_IMAGE) m_image = info.m_image; | |
444 | if (info.m_mask & wxLIST_MASK_DATA) m_data = info.m_data; | |
0530737d VZ |
445 | |
446 | if ( info.HasAttributes() ) | |
447 | { | |
448 | if ( m_attr ) | |
449 | *m_attr = *info.GetAttributes(); | |
450 | else | |
451 | m_attr = new wxListItemAttr(*info.GetAttributes()); | |
452 | } | |
453 | ||
92976ab6 RR |
454 | m_xpos = 0; |
455 | m_ypos = 0; | |
456 | m_width = info.m_width; | |
457 | m_height = 0; | |
e1e955e1 | 458 | } |
c801d85f KB |
459 | |
460 | void wxListItemData::SetText( const wxString &s ) | |
461 | { | |
92976ab6 | 462 | m_text = s; |
e1e955e1 | 463 | } |
c801d85f | 464 | |
debe6624 | 465 | void wxListItemData::SetImage( int image ) |
c801d85f | 466 | { |
92976ab6 | 467 | m_image = image; |
e1e955e1 | 468 | } |
c801d85f | 469 | |
debe6624 | 470 | void wxListItemData::SetData( long data ) |
c801d85f | 471 | { |
92976ab6 | 472 | m_data = data; |
e1e955e1 | 473 | } |
c801d85f | 474 | |
debe6624 | 475 | void wxListItemData::SetPosition( int x, int y ) |
c801d85f | 476 | { |
92976ab6 RR |
477 | m_xpos = x; |
478 | m_ypos = y; | |
e1e955e1 | 479 | } |
c801d85f | 480 | |
1e6d9499 | 481 | void wxListItemData::SetSize( int width, int height ) |
c801d85f | 482 | { |
92976ab6 RR |
483 | if (width != -1) m_width = width; |
484 | if (height != -1) m_height = height; | |
e1e955e1 | 485 | } |
c801d85f | 486 | |
fd9811b1 | 487 | bool wxListItemData::HasImage() const |
c801d85f | 488 | { |
92976ab6 | 489 | return (m_image >= 0); |
e1e955e1 | 490 | } |
c801d85f | 491 | |
fd9811b1 | 492 | bool wxListItemData::HasText() const |
c801d85f | 493 | { |
92976ab6 | 494 | return (!m_text.IsNull()); |
e1e955e1 | 495 | } |
c801d85f | 496 | |
debe6624 | 497 | bool wxListItemData::IsHit( int x, int y ) const |
c801d85f | 498 | { |
92976ab6 | 499 | return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); |
e1e955e1 | 500 | } |
c801d85f KB |
501 | |
502 | void wxListItemData::GetText( wxString &s ) | |
503 | { | |
92976ab6 | 504 | s = m_text; |
e1e955e1 | 505 | } |
c801d85f | 506 | |
fd9811b1 | 507 | int wxListItemData::GetX() const |
c801d85f | 508 | { |
92976ab6 | 509 | return m_xpos; |
e1e955e1 | 510 | } |
c801d85f | 511 | |
fd9811b1 | 512 | int wxListItemData::GetY() const |
c801d85f | 513 | { |
92976ab6 | 514 | return m_ypos; |
e1e955e1 | 515 | } |
c801d85f | 516 | |
fd9811b1 | 517 | int wxListItemData::GetWidth() const |
c801d85f | 518 | { |
92976ab6 | 519 | return m_width; |
e1e955e1 | 520 | } |
c801d85f | 521 | |
fd9811b1 | 522 | int wxListItemData::GetHeight() const |
c801d85f | 523 | { |
92976ab6 | 524 | return m_height; |
e1e955e1 | 525 | } |
c801d85f | 526 | |
fd9811b1 | 527 | int wxListItemData::GetImage() const |
c801d85f | 528 | { |
92976ab6 | 529 | return m_image; |
e1e955e1 | 530 | } |
c801d85f | 531 | |
0530737d | 532 | void wxListItemData::GetItem( wxListItem &info ) const |
c801d85f | 533 | { |
92976ab6 RR |
534 | info.m_text = m_text; |
535 | info.m_image = m_image; | |
536 | info.m_data = m_data; | |
c801d85f | 537 | |
0530737d VZ |
538 | if ( m_attr ) |
539 | { | |
540 | if ( m_attr->HasTextColour() ) | |
541 | info.SetTextColour(m_attr->GetTextColour()); | |
542 | if ( m_attr->HasBackgroundColour() ) | |
543 | info.SetBackgroundColour(m_attr->GetBackgroundColour()); | |
544 | if ( m_attr->HasFont() ) | |
545 | info.SetFont(m_attr->GetFont()); | |
546 | } | |
e1e955e1 | 547 | } |
c801d85f KB |
548 | |
549 | //----------------------------------------------------------------------------- | |
550 | // wxListHeaderData | |
551 | //----------------------------------------------------------------------------- | |
552 | ||
553 | IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData,wxObject); | |
554 | ||
fd9811b1 | 555 | wxListHeaderData::wxListHeaderData() |
c801d85f | 556 | { |
92976ab6 RR |
557 | m_mask = 0; |
558 | m_image = 0; | |
559 | m_format = 0; | |
560 | m_width = 0; | |
561 | m_xpos = 0; | |
562 | m_ypos = 0; | |
563 | m_height = 0; | |
e1e955e1 | 564 | } |
c801d85f KB |
565 | |
566 | wxListHeaderData::wxListHeaderData( const wxListItem &item ) | |
567 | { | |
92976ab6 RR |
568 | SetItem( item ); |
569 | m_xpos = 0; | |
570 | m_ypos = 0; | |
571 | m_height = 0; | |
e1e955e1 | 572 | } |
c801d85f KB |
573 | |
574 | void wxListHeaderData::SetItem( const wxListItem &item ) | |
575 | { | |
92976ab6 RR |
576 | m_mask = item.m_mask; |
577 | m_text = item.m_text; | |
578 | m_image = item.m_image; | |
579 | m_format = item.m_format; | |
580 | m_width = item.m_width; | |
581 | if (m_width < 0) m_width = 80; | |
582 | if (m_width < 6) m_width = 6; | |
e1e955e1 | 583 | } |
c801d85f | 584 | |
debe6624 | 585 | void wxListHeaderData::SetPosition( int x, int y ) |
c801d85f | 586 | { |
92976ab6 RR |
587 | m_xpos = x; |
588 | m_ypos = y; | |
e1e955e1 | 589 | } |
c801d85f | 590 | |
debe6624 | 591 | void wxListHeaderData::SetHeight( int h ) |
c801d85f | 592 | { |
92976ab6 | 593 | m_height = h; |
e1e955e1 | 594 | } |
c801d85f | 595 | |
debe6624 | 596 | void wxListHeaderData::SetWidth( int w ) |
c801d85f | 597 | { |
92976ab6 RR |
598 | m_width = w; |
599 | if (m_width < 0) m_width = 80; | |
600 | if (m_width < 6) m_width = 6; | |
e1e955e1 | 601 | } |
c801d85f | 602 | |
debe6624 | 603 | void wxListHeaderData::SetFormat( int format ) |
c801d85f | 604 | { |
92976ab6 | 605 | m_format = format; |
e1e955e1 | 606 | } |
c801d85f | 607 | |
fd9811b1 | 608 | bool wxListHeaderData::HasImage() const |
c801d85f | 609 | { |
92976ab6 | 610 | return (m_image != 0); |
e1e955e1 | 611 | } |
c801d85f | 612 | |
fd9811b1 | 613 | bool wxListHeaderData::HasText() const |
c801d85f | 614 | { |
92976ab6 | 615 | return (m_text.Length() > 0); |
e1e955e1 | 616 | } |
c801d85f KB |
617 | |
618 | bool wxListHeaderData::IsHit( int x, int y ) const | |
619 | { | |
92976ab6 | 620 | return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); |
e1e955e1 | 621 | } |
c801d85f KB |
622 | |
623 | void wxListHeaderData::GetItem( wxListItem &item ) | |
624 | { | |
92976ab6 RR |
625 | item.m_mask = m_mask; |
626 | item.m_text = m_text; | |
627 | item.m_image = m_image; | |
628 | item.m_format = m_format; | |
629 | item.m_width = m_width; | |
e1e955e1 | 630 | } |
c801d85f KB |
631 | |
632 | void wxListHeaderData::GetText( wxString &s ) | |
633 | { | |
92976ab6 | 634 | s = m_text; |
e1e955e1 | 635 | } |
c801d85f | 636 | |
fd9811b1 | 637 | int wxListHeaderData::GetImage() const |
c801d85f | 638 | { |
92976ab6 | 639 | return m_image; |
e1e955e1 | 640 | } |
c801d85f | 641 | |
fd9811b1 | 642 | int wxListHeaderData::GetWidth() const |
c801d85f | 643 | { |
92976ab6 | 644 | return m_width; |
e1e955e1 | 645 | } |
c801d85f | 646 | |
fd9811b1 | 647 | int wxListHeaderData::GetFormat() const |
c801d85f | 648 | { |
92976ab6 | 649 | return m_format; |
e1e955e1 | 650 | } |
c801d85f KB |
651 | |
652 | //----------------------------------------------------------------------------- | |
653 | // wxListLineData | |
654 | //----------------------------------------------------------------------------- | |
655 | ||
656 | IMPLEMENT_DYNAMIC_CLASS(wxListLineData,wxObject); | |
657 | ||
debe6624 | 658 | wxListLineData::wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush ) |
c801d85f | 659 | { |
92976ab6 RR |
660 | m_mode = mode; |
661 | m_hilighted = FALSE; | |
662 | m_owner = owner; | |
663 | m_hilightBrush = hilightBrush; | |
664 | m_items.DeleteContents( TRUE ); | |
665 | m_spacing = 0; | |
e1e955e1 | 666 | } |
c801d85f | 667 | |
1e6d9499 | 668 | void wxListLineData::CalculateSize( wxDC *dc, int spacing ) |
c801d85f | 669 | { |
92976ab6 RR |
670 | m_spacing = spacing; |
671 | switch (m_mode) | |
c801d85f | 672 | { |
92976ab6 RR |
673 | case wxLC_ICON: |
674 | { | |
675 | m_bound_all.width = m_spacing; | |
92976ab6 RR |
676 | wxNode *node = m_items.First(); |
677 | if (node) | |
678 | { | |
679 | wxListItemData *item = (wxListItemData*)node->Data(); | |
0530737d | 680 | wxString s = item->GetText(); |
5d25c050 | 681 | if (s.IsEmpty()) s = wxT("H"); |
13111b2a | 682 | wxCoord lw,lh; |
92976ab6 | 683 | dc->GetTextExtent( s, &lw, &lh ); |
5d25c050 RR |
684 | if (lh < 15) lh = 15; |
685 | lw += 4; | |
686 | lh += 3; | |
f6bcfd97 | 687 | |
5d25c050 | 688 | m_bound_all.height = m_spacing+lh; |
92976ab6 | 689 | if (lw > m_spacing) m_bound_all.width = lw; |
5d25c050 RR |
690 | m_bound_label.width = lw; |
691 | m_bound_label.height = lh; | |
f6bcfd97 | 692 | |
5d25c050 RR |
693 | if (item->HasImage()) |
694 | { | |
695 | int w = 0; | |
696 | int h = 0; | |
697 | m_owner->GetImageSize( item->GetImage(), w, h ); | |
698 | m_bound_icon.width = w + 8; | |
699 | m_bound_icon.height = h + 8; | |
f6bcfd97 BP |
700 | |
701 | if ( m_bound_icon.width > m_bound_all.width ) | |
702 | m_bound_all.width = m_bound_icon.width; | |
703 | if ( h + lh > m_bound_all.height - 4 ) | |
704 | m_bound_all.height = h + lh + 4; | |
5d25c050 | 705 | } |
f6bcfd97 | 706 | |
5d25c050 RR |
707 | if (!item->HasText()) |
708 | { | |
709 | m_bound_hilight.width = m_bound_icon.width; | |
710 | m_bound_hilight.height = m_bound_icon.height; | |
711 | } | |
712 | else | |
713 | { | |
714 | m_bound_hilight.width = m_bound_label.width; | |
715 | m_bound_hilight.height = m_bound_label.height; | |
716 | } | |
92976ab6 RR |
717 | } |
718 | break; | |
719 | } | |
720 | case wxLC_LIST: | |
721 | { | |
722 | wxNode *node = m_items.First(); | |
723 | if (node) | |
724 | { | |
725 | wxListItemData *item = (wxListItemData*)node->Data(); | |
f6bcfd97 | 726 | |
0530737d | 727 | wxString s = item->GetText(); |
5d25c050 | 728 | if (s.IsEmpty()) s = wxT("H"); |
13111b2a | 729 | wxCoord lw,lh; |
92976ab6 | 730 | dc->GetTextExtent( s, &lw, &lh ); |
5d25c050 RR |
731 | if (lh < 15) lh = 15; |
732 | lw += 4; | |
733 | lh += 3; | |
734 | m_bound_label.width = lw; | |
735 | m_bound_label.height = lh; | |
f6bcfd97 | 736 | |
92976ab6 RR |
737 | m_bound_all.width = lw; |
738 | m_bound_all.height = lh; | |
f6bcfd97 | 739 | |
0b855868 RR |
740 | if (item->HasImage()) |
741 | { | |
5dd26b08 JS |
742 | int w = 0; |
743 | int h = 0; | |
0b855868 | 744 | m_owner->GetImageSize( item->GetImage(), w, h ); |
5d25c050 RR |
745 | m_bound_icon.width = w; |
746 | m_bound_icon.height = h; | |
f6bcfd97 | 747 | |
bffa1c77 VZ |
748 | m_bound_all.width += 4 + w; |
749 | if (h > m_bound_all.height) m_bound_all.height = h; | |
750 | } | |
f6bcfd97 | 751 | |
5d25c050 RR |
752 | m_bound_hilight.width = m_bound_all.width; |
753 | m_bound_hilight.height = m_bound_all.height; | |
92976ab6 RR |
754 | } |
755 | break; | |
756 | } | |
757 | case wxLC_REPORT: | |
758 | { | |
759 | m_bound_all.width = 0; | |
760 | m_bound_all.height = 0; | |
761 | wxNode *node = m_items.First(); | |
efad36b8 RR |
762 | if (node) |
763 | { | |
764 | wxListItemData *item = (wxListItemData*)node->Data(); | |
765 | if (item->HasImage()) | |
766 | { | |
767 | int w = 0; | |
768 | int h = 0; | |
769 | m_owner->GetImageSize( item->GetImage(), w, h ); | |
770 | m_bound_icon.width = w; | |
771 | m_bound_icon.height = h; | |
772 | } | |
773 | else | |
774 | { | |
775 | m_bound_icon.width = 0; | |
776 | m_bound_icon.height = 0; | |
777 | } | |
778 | } | |
92976ab6 RR |
779 | while (node) |
780 | { | |
781 | wxListItemData *item = (wxListItemData*)node->Data(); | |
5d25c050 RR |
782 | wxString s = item->GetText(); |
783 | if (s.IsEmpty()) s = wxT("H"); | |
13111b2a | 784 | wxCoord lw,lh; |
7c74e7fe | 785 | dc->GetTextExtent( s, &lw, &lh ); |
40c70187 | 786 | if (lh < 15) lh = 15; |
5d25c050 RR |
787 | lw += 4; |
788 | lh += 3; | |
f6bcfd97 | 789 | |
92976ab6 | 790 | item->SetSize( item->GetWidth(), lh ); |
7c74e7fe | 791 | m_bound_all.width += lw; |
92976ab6 RR |
792 | m_bound_all.height = lh; |
793 | node = node->Next(); | |
794 | } | |
d7ace8a9 VS |
795 | m_bound_label.width = m_bound_all.width; |
796 | m_bound_label.height = m_bound_all.height; | |
92976ab6 RR |
797 | break; |
798 | } | |
e1e955e1 | 799 | } |
e1e955e1 | 800 | } |
c801d85f | 801 | |
bc1dcfc1 VZ |
802 | void wxListLineData::SetPosition( wxDC * WXUNUSED(dc), |
803 | int x, int y, int window_width ) | |
c801d85f | 804 | { |
0b855868 RR |
805 | m_bound_all.x = x; |
806 | m_bound_all.y = y; | |
807 | switch (m_mode) | |
808 | { | |
809 | case wxLC_ICON: | |
c801d85f | 810 | { |
0b855868 RR |
811 | wxNode *node = m_items.First(); |
812 | if (node) | |
813 | { | |
814 | wxListItemData *item = (wxListItemData*)node->Data(); | |
815 | if (item->HasImage()) | |
816 | { | |
f6bcfd97 BP |
817 | m_bound_icon.x = m_bound_all.x + 4 |
818 | + (m_spacing - m_bound_icon.width)/2; | |
5d25c050 | 819 | m_bound_icon.y = m_bound_all.y + 4; |
0b855868 RR |
820 | } |
821 | if (item->HasText()) | |
822 | { | |
0b855868 | 823 | if (m_bound_all.width > m_spacing) |
5d25c050 | 824 | m_bound_label.x = m_bound_all.x + 2; |
0b855868 | 825 | else |
5d25c050 RR |
826 | m_bound_label.x = m_bound_all.x + 2 + (m_spacing/2) - (m_bound_label.width/2); |
827 | m_bound_label.y = m_bound_all.y + m_bound_all.height + 2 - m_bound_label.height; | |
828 | m_bound_hilight.x = m_bound_label.x - 2; | |
829 | m_bound_hilight.y = m_bound_label.y - 2; | |
830 | } | |
831 | else | |
832 | { | |
833 | m_bound_hilight.x = m_bound_icon.x - 4; | |
834 | m_bound_hilight.y = m_bound_icon.y - 4; | |
0b855868 RR |
835 | } |
836 | } | |
837 | break; | |
e1e955e1 | 838 | } |
0b855868 | 839 | case wxLC_LIST: |
c801d85f | 840 | { |
5d25c050 RR |
841 | m_bound_hilight.x = m_bound_all.x; |
842 | m_bound_hilight.y = m_bound_all.y; | |
843 | m_bound_label.y = m_bound_all.y + 2; | |
0b855868 RR |
844 | wxNode *node = m_items.First(); |
845 | if (node) | |
846 | { | |
847 | wxListItemData *item = (wxListItemData*)node->Data(); | |
848 | if (item->HasImage()) | |
bffa1c77 | 849 | { |
0b855868 RR |
850 | m_bound_icon.x = m_bound_all.x + 2; |
851 | m_bound_icon.y = m_bound_all.y + 2; | |
5d25c050 RR |
852 | m_bound_label.x = m_bound_all.x + 6 + m_bound_icon.width; |
853 | } | |
854 | else | |
855 | { | |
856 | m_bound_label.x = m_bound_all.x + 2; | |
bffa1c77 VZ |
857 | } |
858 | } | |
0b855868 RR |
859 | break; |
860 | } | |
861 | case wxLC_REPORT: | |
862 | { | |
0b855868 | 863 | m_bound_all.x = 0; |
0b855868 RR |
864 | m_bound_all.width = window_width; |
865 | AssignRect( m_bound_hilight, m_bound_all ); | |
5d25c050 RR |
866 | m_bound_label.x = m_bound_all.x + 2; |
867 | m_bound_label.y = m_bound_all.y + 2; | |
0b855868 RR |
868 | wxNode *node = m_items.First(); |
869 | if (node) | |
870 | { | |
871 | wxListItemData *item = (wxListItemData*)node->Data(); | |
bffa1c77 VZ |
872 | if (item->HasImage()) |
873 | { | |
0b855868 RR |
874 | m_bound_icon.x = m_bound_all.x + 2; |
875 | m_bound_icon.y = m_bound_all.y + 2; | |
5d25c050 | 876 | m_bound_label.x += 4 + m_bound_icon.width; |
bffa1c77 VZ |
877 | } |
878 | } | |
0b855868 | 879 | break; |
e1e955e1 | 880 | } |
e1e955e1 | 881 | } |
e1e955e1 | 882 | } |
c801d85f | 883 | |
debe6624 | 884 | void wxListLineData::SetColumnPosition( int index, int x ) |
c801d85f | 885 | { |
6f2a55e3 | 886 | wxNode *node = m_items.Nth( (size_t)index ); |
92976ab6 RR |
887 | if (node) |
888 | { | |
889 | wxListItemData *item = (wxListItemData*)node->Data(); | |
890 | item->SetPosition( x, m_bound_all.y+1 ); | |
891 | } | |
e1e955e1 | 892 | } |
c801d85f KB |
893 | |
894 | void wxListLineData::GetSize( int &width, int &height ) | |
895 | { | |
139adb6a RR |
896 | width = m_bound_all.width; |
897 | height = m_bound_all.height; | |
e1e955e1 | 898 | } |
c801d85f KB |
899 | |
900 | void wxListLineData::GetExtent( int &x, int &y, int &width, int &height ) | |
901 | { | |
139adb6a RR |
902 | x = m_bound_all.x; |
903 | y = m_bound_all.y; | |
904 | width = m_bound_all.width; | |
905 | height = m_bound_all.height; | |
e1e955e1 | 906 | } |
c801d85f KB |
907 | |
908 | void wxListLineData::GetLabelExtent( int &x, int &y, int &width, int &height ) | |
909 | { | |
139adb6a RR |
910 | x = m_bound_label.x; |
911 | y = m_bound_label.y; | |
912 | width = m_bound_label.width; | |
913 | height = m_bound_label.height; | |
e1e955e1 | 914 | } |
c801d85f | 915 | |
0a240683 | 916 | void wxListLineData::GetRect( wxRect &rect ) |
c801d85f | 917 | { |
139adb6a | 918 | AssignRect( rect, m_bound_all ); |
e1e955e1 | 919 | } |
c801d85f | 920 | |
debe6624 | 921 | long wxListLineData::IsHit( int x, int y ) |
c801d85f | 922 | { |
139adb6a RR |
923 | wxNode *node = m_items.First(); |
924 | if (node) | |
925 | { | |
926 | wxListItemData *item = (wxListItemData*)node->Data(); | |
927 | if (item->HasImage() && IsInRect( x, y, m_bound_icon )) return wxLIST_HITTEST_ONITEMICON; | |
928 | if (item->HasText() && IsInRect( x, y, m_bound_label )) return wxLIST_HITTEST_ONITEMLABEL; | |
929 | // if (!(item->HasImage() || item->HasText())) return 0; | |
930 | } | |
931 | // if there is no icon or text = empty | |
932 | if (IsInRect( x, y, m_bound_all )) return wxLIST_HITTEST_ONITEMICON; | |
933 | return 0; | |
e1e955e1 | 934 | } |
c801d85f | 935 | |
debe6624 | 936 | void wxListLineData::InitItems( int num ) |
c801d85f | 937 | { |
139adb6a | 938 | for (int i = 0; i < num; i++) m_items.Append( new wxListItemData() ); |
e1e955e1 | 939 | } |
c801d85f | 940 | |
debe6624 | 941 | void wxListLineData::SetItem( int index, const wxListItem &info ) |
c801d85f | 942 | { |
139adb6a RR |
943 | wxNode *node = m_items.Nth( index ); |
944 | if (node) | |
945 | { | |
946 | wxListItemData *item = (wxListItemData*)node->Data(); | |
947 | item->SetItem( info ); | |
948 | } | |
e1e955e1 | 949 | } |
c801d85f | 950 | |
1e6d9499 | 951 | void wxListLineData::GetItem( int index, wxListItem &info ) |
c801d85f | 952 | { |
139adb6a RR |
953 | int i = index; |
954 | wxNode *node = m_items.Nth( i ); | |
955 | if (node) | |
956 | { | |
957 | wxListItemData *item = (wxListItemData*)node->Data(); | |
958 | item->GetItem( info ); | |
959 | } | |
e1e955e1 | 960 | } |
c801d85f | 961 | |
debe6624 | 962 | void wxListLineData::GetText( int index, wxString &s ) |
c801d85f | 963 | { |
139adb6a RR |
964 | int i = index; |
965 | wxNode *node = m_items.Nth( i ); | |
966 | s = ""; | |
967 | if (node) | |
968 | { | |
969 | wxListItemData *item = (wxListItemData*)node->Data(); | |
970 | item->GetText( s ); | |
971 | } | |
e1e955e1 | 972 | } |
c801d85f | 973 | |
debe6624 | 974 | void wxListLineData::SetText( int index, const wxString s ) |
c801d85f | 975 | { |
139adb6a RR |
976 | int i = index; |
977 | wxNode *node = m_items.Nth( i ); | |
978 | if (node) | |
979 | { | |
980 | wxListItemData *item = (wxListItemData*)node->Data(); | |
981 | item->SetText( s ); | |
982 | } | |
e1e955e1 | 983 | } |
c801d85f | 984 | |
debe6624 | 985 | int wxListLineData::GetImage( int index ) |
c801d85f | 986 | { |
139adb6a RR |
987 | int i = index; |
988 | wxNode *node = m_items.Nth( i ); | |
989 | if (node) | |
990 | { | |
991 | wxListItemData *item = (wxListItemData*)node->Data(); | |
992 | return item->GetImage(); | |
993 | } | |
994 | return -1; | |
e1e955e1 | 995 | } |
c801d85f | 996 | |
0530737d VZ |
997 | void wxListLineData::SetAttributes(wxDC *dc, |
998 | const wxListItemAttr *attr, | |
999 | const wxColour& colText, | |
470caaf9 VZ |
1000 | const wxFont& font, |
1001 | bool hilight) | |
0530737d | 1002 | { |
470caaf9 VZ |
1003 | // don't use foregroud colour for drawing highlighted items - this might |
1004 | // make them completely invisible (and there is no way to do bit | |
1005 | // arithmetics on wxColour, unfortunately) | |
1006 | if ( !hilight && attr && attr->HasTextColour() ) | |
0530737d VZ |
1007 | { |
1008 | dc->SetTextForeground(attr->GetTextColour()); | |
1009 | } | |
1010 | else | |
1011 | { | |
1012 | dc->SetTextForeground(colText); | |
1013 | } | |
1014 | ||
1015 | if ( attr && attr->HasFont() ) | |
1016 | { | |
1017 | dc->SetFont(attr->GetFont()); | |
1018 | } | |
1019 | else | |
1020 | { | |
1021 | dc->SetFont(font); | |
1022 | } | |
1023 | } | |
1024 | ||
1e6d9499 | 1025 | void wxListLineData::DoDraw( wxDC *dc, bool hilight, bool paintBG ) |
c801d85f | 1026 | { |
e06b9569 JS |
1027 | int dev_x = 0; |
1028 | int dev_y = 0; | |
3d2d8da1 RR |
1029 | m_owner->CalcScrolledPosition( m_bound_all.x, m_bound_all.y, &dev_x, &dev_y ); |
1030 | wxCoord dev_w = m_bound_all.width; | |
1031 | wxCoord dev_h = m_bound_all.height; | |
004fd0c8 | 1032 | |
139adb6a | 1033 | if (!m_owner->IsExposed( dev_x, dev_y, dev_w, dev_h )) |
139adb6a | 1034 | return; |
bd8289c1 | 1035 | |
0530737d VZ |
1036 | wxWindow *listctrl = m_owner->GetParent(); |
1037 | ||
1038 | // default foreground colour | |
1039 | wxColour colText; | |
1040 | if ( hilight ) | |
1041 | { | |
1042 | colText = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ); | |
1043 | } | |
1044 | else | |
1045 | { | |
1046 | colText = listctrl->GetForegroundColour(); | |
1047 | } | |
1048 | ||
1049 | // default font | |
1050 | wxFont font = listctrl->GetFont(); | |
1051 | ||
1052 | // VZ: currently we set the colours/fonts only once, but like this (i.e. | |
1053 | // using SetAttributes() inside the loop), it will be trivial to | |
1054 | // customize the subitems (in report mode) too. | |
1055 | wxListItemData *item = (wxListItemData*)m_items.First()->Data(); | |
1056 | wxListItemAttr *attr = item->GetAttributes(); | |
470caaf9 | 1057 | SetAttributes(dc, attr, colText, font, hilight); |
0530737d VZ |
1058 | |
1059 | bool hasBgCol = attr && attr->HasBackgroundColour(); | |
1060 | if ( paintBG || hasBgCol ) | |
c801d85f | 1061 | { |
63852e78 RR |
1062 | if (hilight) |
1063 | { | |
1064 | dc->SetBrush( * m_hilightBrush ); | |
63852e78 RR |
1065 | } |
1066 | else | |
1067 | { | |
0530737d VZ |
1068 | if ( hasBgCol ) |
1069 | dc->SetBrush(wxBrush(attr->GetBackgroundColour(), wxSOLID)); | |
1070 | else | |
1071 | dc->SetBrush( * wxWHITE_BRUSH ); | |
63852e78 | 1072 | } |
0530737d VZ |
1073 | |
1074 | dc->SetPen( * wxTRANSPARENT_PEN ); | |
63852e78 RR |
1075 | dc->DrawRectangle( m_bound_hilight.x, m_bound_hilight.y, |
1076 | m_bound_hilight.width, m_bound_hilight.height ); | |
e1e955e1 | 1077 | } |
004fd0c8 | 1078 | |
63852e78 | 1079 | if (m_mode == wxLC_REPORT) |
c801d85f | 1080 | { |
63852e78 RR |
1081 | wxNode *node = m_items.First(); |
1082 | while (node) | |
1083 | { | |
1084 | wxListItemData *item = (wxListItemData*)node->Data(); | |
63852e78 RR |
1085 | int x = item->GetX(); |
1086 | if (item->HasImage()) | |
1087 | { | |
1088 | int y = 0; | |
1089 | m_owner->DrawImage( item->GetImage(), dc, x, item->GetY() ); | |
1090 | m_owner->GetImageSize( item->GetImage(), x, y ); | |
1091 | x += item->GetX() + 5; | |
1092 | } | |
40c70187 | 1093 | dc->SetClippingRegion( item->GetX(), item->GetY(), item->GetWidth()-3, item->GetHeight() ); |
63852e78 RR |
1094 | if (item->HasText()) |
1095 | { | |
40c70187 | 1096 | dc->DrawText( item->GetText(), x, item->GetY()+1 ); |
63852e78 RR |
1097 | } |
1098 | dc->DestroyClippingRegion(); | |
1099 | node = node->Next(); | |
1100 | } | |
e1e955e1 | 1101 | } |
63852e78 | 1102 | else |
c801d85f | 1103 | { |
63852e78 RR |
1104 | wxNode *node = m_items.First(); |
1105 | if (node) | |
1106 | { | |
1107 | wxListItemData *item = (wxListItemData*)node->Data(); | |
1108 | if (item->HasImage()) | |
1109 | { | |
1110 | m_owner->DrawImage( item->GetImage(), dc, m_bound_icon.x, m_bound_icon.y ); | |
1111 | } | |
1112 | if (item->HasText()) | |
1113 | { | |
0530737d | 1114 | dc->DrawText( item->GetText(), m_bound_label.x, m_bound_label.y ); |
63852e78 RR |
1115 | } |
1116 | } | |
e1e955e1 | 1117 | } |
e1e955e1 | 1118 | } |
c801d85f | 1119 | |
debe6624 | 1120 | void wxListLineData::Hilight( bool on ) |
c801d85f | 1121 | { |
63852e78 | 1122 | if (on == m_hilighted) return; |
6e228e42 | 1123 | m_hilighted = on; |
63852e78 RR |
1124 | if (on) |
1125 | m_owner->SelectLine( this ); | |
1126 | else | |
1127 | m_owner->DeselectLine( this ); | |
e1e955e1 | 1128 | } |
c801d85f KB |
1129 | |
1130 | void wxListLineData::ReverseHilight( void ) | |
1131 | { | |
63852e78 RR |
1132 | m_hilighted = !m_hilighted; |
1133 | if (m_hilighted) | |
1134 | m_owner->SelectLine( this ); | |
1135 | else | |
1136 | m_owner->DeselectLine( this ); | |
e1e955e1 | 1137 | } |
c801d85f | 1138 | |
1e6d9499 | 1139 | void wxListLineData::DrawRubberBand( wxDC *dc, bool on ) |
c801d85f | 1140 | { |
63852e78 RR |
1141 | if (on) |
1142 | { | |
1143 | dc->SetPen( * wxBLACK_PEN ); | |
1144 | dc->SetBrush( * wxTRANSPARENT_BRUSH ); | |
1145 | dc->DrawRectangle( m_bound_hilight.x, m_bound_hilight.y, | |
1146 | m_bound_hilight.width, m_bound_hilight.height ); | |
1147 | } | |
e1e955e1 | 1148 | } |
c801d85f | 1149 | |
1e6d9499 | 1150 | void wxListLineData::Draw( wxDC *dc ) |
c801d85f | 1151 | { |
63852e78 | 1152 | DoDraw( dc, m_hilighted, m_hilighted ); |
e1e955e1 | 1153 | } |
c801d85f | 1154 | |
0a240683 | 1155 | bool wxListLineData::IsInRect( int x, int y, const wxRect &rect ) |
c801d85f | 1156 | { |
004fd0c8 | 1157 | return ((x >= rect.x) && (x <= rect.x+rect.width) && |
63852e78 | 1158 | (y >= rect.y) && (y <= rect.y+rect.height)); |
e1e955e1 | 1159 | } |
c801d85f KB |
1160 | |
1161 | bool wxListLineData::IsHilighted( void ) | |
1162 | { | |
63852e78 | 1163 | return m_hilighted; |
e1e955e1 | 1164 | } |
c801d85f | 1165 | |
0a240683 | 1166 | void wxListLineData::AssignRect( wxRect &dest, int x, int y, int width, int height ) |
c801d85f | 1167 | { |
63852e78 RR |
1168 | dest.x = x; |
1169 | dest.y = y; | |
1170 | dest.width = width; | |
1171 | dest.height = height; | |
e1e955e1 | 1172 | } |
c801d85f | 1173 | |
0a240683 | 1174 | void wxListLineData::AssignRect( wxRect &dest, const wxRect &source ) |
c801d85f | 1175 | { |
63852e78 RR |
1176 | dest.x = source.x; |
1177 | dest.y = source.y; | |
1178 | dest.width = source.width; | |
1179 | dest.height = source.height; | |
e1e955e1 | 1180 | } |
c801d85f KB |
1181 | |
1182 | //----------------------------------------------------------------------------- | |
1183 | // wxListHeaderWindow | |
1184 | //----------------------------------------------------------------------------- | |
1185 | ||
1186 | IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow,wxWindow); | |
1187 | ||
1188 | BEGIN_EVENT_TABLE(wxListHeaderWindow,wxWindow) | |
63852e78 RR |
1189 | EVT_PAINT (wxListHeaderWindow::OnPaint) |
1190 | EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse) | |
1191 | EVT_SET_FOCUS (wxListHeaderWindow::OnSetFocus) | |
c801d85f KB |
1192 | END_EVENT_TABLE() |
1193 | ||
1194 | wxListHeaderWindow::wxListHeaderWindow( void ) | |
1195 | { | |
63852e78 RR |
1196 | m_owner = (wxListMainWindow *) NULL; |
1197 | m_currentCursor = (wxCursor *) NULL; | |
1198 | m_resizeCursor = (wxCursor *) NULL; | |
cfb50f14 | 1199 | m_isDragging = FALSE; |
e1e955e1 | 1200 | } |
c801d85f | 1201 | |
bd8289c1 | 1202 | wxListHeaderWindow::wxListHeaderWindow( wxWindow *win, wxWindowID id, wxListMainWindow *owner, |
debe6624 JS |
1203 | const wxPoint &pos, const wxSize &size, |
1204 | long style, const wxString &name ) : | |
c801d85f KB |
1205 | wxWindow( win, id, pos, size, style, name ) |
1206 | { | |
63852e78 | 1207 | m_owner = owner; |
c801d85f | 1208 | // m_currentCursor = wxSTANDARD_CURSOR; |
63852e78 RR |
1209 | m_currentCursor = (wxCursor *) NULL; |
1210 | m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE ); | |
cfb50f14 | 1211 | m_isDragging = FALSE; |
f6bcfd97 BP |
1212 | m_dirty = FALSE; |
1213 | ||
cfb50f14 | 1214 | SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) ); |
e1e955e1 | 1215 | } |
c801d85f | 1216 | |
a367b9b3 JS |
1217 | wxListHeaderWindow::~wxListHeaderWindow( void ) |
1218 | { | |
63852e78 | 1219 | delete m_resizeCursor; |
a367b9b3 JS |
1220 | } |
1221 | ||
1e6d9499 | 1222 | void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h ) |
c801d85f | 1223 | { |
3fb435df RR |
1224 | #ifdef __WXGTK__ |
1225 | GtkStateType state = GTK_STATE_NORMAL; | |
1226 | if (!m_parent->IsEnabled()) state = GTK_STATE_INSENSITIVE; | |
1227 | ||
1228 | x = dc->XLOG2DEV( x ); | |
1229 | ||
05a7f61d VZ |
1230 | gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT, |
1231 | (GdkRectangle*) NULL, m_wxwindow, "button", x-1, y-1, w+2, h+2); | |
3fb435df | 1232 | #else |
63852e78 | 1233 | const int m_corner = 1; |
c801d85f | 1234 | |
63852e78 | 1235 | dc->SetBrush( *wxTRANSPARENT_BRUSH ); |
c801d85f | 1236 | |
63852e78 RR |
1237 | dc->SetPen( *wxBLACK_PEN ); |
1238 | dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer) | |
17867d61 | 1239 | dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer) |
bd8289c1 | 1240 | |
63852e78 | 1241 | wxPen pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID ); |
004fd0c8 | 1242 | |
63852e78 RR |
1243 | dc->SetPen( pen ); |
1244 | dc->DrawLine( x+w-m_corner, y, x+w-1, y+h ); // right (inner) | |
1245 | dc->DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner) | |
bd8289c1 | 1246 | |
63852e78 RR |
1247 | dc->SetPen( *wxWHITE_PEN ); |
1248 | dc->DrawRectangle( x, y, w-m_corner+1, 1 ); // top (outer) | |
1249 | dc->DrawRectangle( x, y, 1, h ); // left (outer) | |
1250 | dc->DrawLine( x, y+h-1, x+1, y+h-1 ); | |
1251 | dc->DrawLine( x+w-1, y, x+w-1, y+1 ); | |
3fb435df | 1252 | #endif |
e1e955e1 | 1253 | } |
c801d85f | 1254 | |
f6bcfd97 BP |
1255 | // shift the DC origin to match the position of the main window horz |
1256 | // scrollbar: this allows us to always use logical coords | |
1257 | void wxListHeaderWindow::AdjustDC(wxDC& dc) | |
1258 | { | |
1259 | #if wxUSE_GENERIC_LIST_EXTENSIONS | |
1260 | int xpix; | |
1261 | m_owner->GetScrollPixelsPerUnit( &xpix, NULL ); | |
1262 | ||
1263 | int x; | |
1264 | m_owner->GetViewStart( &x, NULL ); | |
1265 | ||
1266 | // account for the horz scrollbar offset | |
1267 | dc.SetDeviceOrigin( -x * xpix, 0 ); | |
1268 | #endif // wxUSE_GENERIC_LIST_EXTENSIONS | |
1269 | } | |
1270 | ||
c801d85f KB |
1271 | void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) |
1272 | { | |
10bd0724 JS |
1273 | #ifdef __WXGTK__ |
1274 | wxClientDC dc( this ); | |
1275 | #else | |
63852e78 | 1276 | wxPaintDC dc( this ); |
10bd0724 JS |
1277 | #endif |
1278 | ||
63852e78 | 1279 | PrepareDC( dc ); |
f6bcfd97 | 1280 | AdjustDC( dc ); |
bffa1c77 | 1281 | |
63852e78 | 1282 | dc.BeginDrawing(); |
bd8289c1 | 1283 | |
63852e78 | 1284 | dc.SetFont( GetFont() ); |
bd8289c1 | 1285 | |
f6bcfd97 BP |
1286 | // width and height of the entire header window |
1287 | int w, h; | |
63852e78 | 1288 | GetClientSize( &w, &h ); |
f6bcfd97 BP |
1289 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
1290 | m_owner->CalcUnscrolledPosition(w, 0, &w, NULL); | |
1291 | #endif // wxUSE_GENERIC_LIST_EXTENSIONS | |
c801d85f | 1292 | |
f60d0f94 | 1293 | dc.SetBackgroundMode(wxTRANSPARENT); |
70846f0a VZ |
1294 | |
1295 | // do *not* use the listctrl colour for headers - one day we will have a | |
1296 | // function to set it separately | |
37d403aa JS |
1297 | //dc.SetTextForeground( *wxBLACK ); |
1298 | dc.SetTextForeground(wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOWTEXT )); | |
c801d85f | 1299 | |
f6bcfd97 BP |
1300 | int x = 1; // left of the header rect |
1301 | const int y = 1; // top | |
63852e78 RR |
1302 | int numColumns = m_owner->GetColumnCount(); |
1303 | wxListItem item; | |
1304 | for (int i = 0; i < numColumns; i++) | |
1305 | { | |
1306 | m_owner->GetColumn( i, item ); | |
f6bcfd97 BP |
1307 | int wCol = item.m_width; |
1308 | int cw = wCol - 2; // the width of the rect to draw | |
1309 | ||
1310 | int xEnd = x + wCol; | |
1311 | ||
1312 | // VZ: no, draw it normally - this is better now as we allow resizing | |
1313 | // of the last column as well | |
1314 | #if 0 | |
1315 | // let the last column occupy all available space | |
1316 | if ( i == numColumns - 1 ) | |
470caaf9 | 1317 | cw = w-x-1; |
f6bcfd97 BP |
1318 | #endif // 0 |
1319 | ||
63852e78 | 1320 | dc.SetPen( *wxWHITE_PEN ); |
c801d85f | 1321 | |
63852e78 | 1322 | DoDrawRect( &dc, x, y, cw, h-2 ); |
40c70187 | 1323 | dc.SetClippingRegion( x, y, cw-5, h-4 ); |
63852e78 | 1324 | dc.DrawText( item.m_text, x+4, y+3 ); |
40c70187 | 1325 | dc.DestroyClippingRegion(); |
f6bcfd97 BP |
1326 | x += wCol; |
1327 | ||
1328 | if (xEnd > w+5) | |
1329 | break; | |
63852e78 RR |
1330 | } |
1331 | dc.EndDrawing(); | |
e1e955e1 | 1332 | } |
c801d85f | 1333 | |
0208334d RR |
1334 | void wxListHeaderWindow::DrawCurrent() |
1335 | { | |
63852e78 RR |
1336 | int x1 = m_currentX; |
1337 | int y1 = 0; | |
f6bcfd97 BP |
1338 | ClientToScreen( &x1, &y1 ); |
1339 | ||
63852e78 RR |
1340 | int x2 = m_currentX-1; |
1341 | int y2 = 0; | |
f6bcfd97 | 1342 | m_owner->GetClientSize( NULL, &y2 ); |
63852e78 | 1343 | m_owner->ClientToScreen( &x2, &y2 ); |
0208334d | 1344 | |
63852e78 | 1345 | wxScreenDC dc; |
3c679789 | 1346 | dc.SetLogicalFunction( wxINVERT ); |
63852e78 RR |
1347 | dc.SetPen( wxPen( *wxBLACK, 2, wxSOLID ) ); |
1348 | dc.SetBrush( *wxTRANSPARENT_BRUSH ); | |
0208334d | 1349 | |
f6bcfd97 BP |
1350 | AdjustDC(dc); |
1351 | ||
63852e78 | 1352 | dc.DrawLine( x1, y1, x2, y2 ); |
0208334d | 1353 | |
63852e78 | 1354 | dc.SetLogicalFunction( wxCOPY ); |
0208334d | 1355 | |
63852e78 RR |
1356 | dc.SetPen( wxNullPen ); |
1357 | dc.SetBrush( wxNullBrush ); | |
0208334d RR |
1358 | } |
1359 | ||
c801d85f KB |
1360 | void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) |
1361 | { | |
f6bcfd97 BP |
1362 | // we want to work with logical coords |
1363 | #if wxUSE_GENERIC_LIST_EXTENSIONS | |
3ca6a5f0 BP |
1364 | int x; |
1365 | m_owner->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL); | |
f6bcfd97 BP |
1366 | #else // !wxUSE_GENERIC_LIST_EXTENSIONS |
1367 | int x = event.GetX(); | |
f6bcfd97 | 1368 | #endif // wxUSE_GENERIC_LIST_EXTENSIONS |
3ca6a5f0 | 1369 | int y = event.GetY(); |
f6bcfd97 | 1370 | |
cfb50f14 | 1371 | if (m_isDragging) |
0208334d | 1372 | { |
f6bcfd97 BP |
1373 | // we don't draw the line beyond our window, but we allow dragging it |
1374 | // there | |
1375 | int w = 0; | |
1376 | GetClientSize( &w, NULL ); | |
1377 | #if wxUSE_GENERIC_LIST_EXTENSIONS | |
1378 | m_owner->CalcUnscrolledPosition(w, 0, &w, NULL); | |
1379 | #endif // wxUSE_GENERIC_LIST_EXTENSIONS | |
1380 | w -= 6; | |
1381 | ||
1382 | // erase the line if it was drawn | |
1383 | if ( m_currentX < w ) | |
1384 | DrawCurrent(); | |
1385 | ||
63852e78 RR |
1386 | if (event.ButtonUp()) |
1387 | { | |
1388 | ReleaseMouse(); | |
cfb50f14 | 1389 | m_isDragging = FALSE; |
f6bcfd97 BP |
1390 | m_dirty = TRUE; |
1391 | m_owner->SetColumnWidth( m_column, m_currentX - m_minX ); | |
63852e78 RR |
1392 | } |
1393 | else | |
1394 | { | |
f6bcfd97 | 1395 | if (x > m_minX + 7) |
63852e78 RR |
1396 | m_currentX = x; |
1397 | else | |
f6bcfd97 | 1398 | m_currentX = m_minX + 7; |
bd8289c1 | 1399 | |
f6bcfd97 BP |
1400 | // draw in the new location |
1401 | if ( m_currentX < w ) | |
1402 | DrawCurrent(); | |
bffa1c77 | 1403 | } |
0208334d | 1404 | } |
f6bcfd97 | 1405 | else // not dragging |
c801d85f | 1406 | { |
f6bcfd97 BP |
1407 | m_minX = 0; |
1408 | bool hit_border = FALSE; | |
1409 | ||
1410 | // end of the current column | |
1411 | int xpos = 0; | |
1412 | ||
1413 | // find the column where this event occured | |
1414 | int countCol = m_owner->GetColumnCount(); | |
1415 | for (int j = 0; j < countCol; j++) | |
bffa1c77 | 1416 | { |
f6bcfd97 BP |
1417 | xpos += m_owner->GetColumnWidth( j ); |
1418 | m_column = j; | |
1419 | ||
1420 | if ( (abs(x-xpos) < 3) && (y < 22) ) | |
1421 | { | |
1422 | // near the column border | |
1423 | hit_border = TRUE; | |
1424 | break; | |
1425 | } | |
1426 | ||
1427 | if ( x < xpos ) | |
1428 | { | |
1429 | // inside the column | |
1430 | break; | |
1431 | } | |
1432 | ||
1433 | m_minX = xpos; | |
bffa1c77 | 1434 | } |
63852e78 | 1435 | |
f6bcfd97 | 1436 | if (event.LeftDown()) |
63852e78 | 1437 | { |
f6bcfd97 BP |
1438 | if (hit_border) |
1439 | { | |
1440 | m_isDragging = TRUE; | |
1441 | m_currentX = x; | |
1442 | DrawCurrent(); | |
1443 | CaptureMouse(); | |
1444 | } | |
1445 | else | |
1446 | { | |
1447 | wxWindow *parent = GetParent(); | |
1448 | wxListEvent le( wxEVT_COMMAND_LIST_COL_CLICK, parent->GetId() ); | |
1449 | le.SetEventObject( parent ); | |
1450 | le.m_col = m_column; | |
1451 | parent->GetEventHandler()->ProcessEvent( le ); | |
1452 | } | |
63852e78 | 1453 | } |
f6bcfd97 | 1454 | else if (event.Moving()) |
63852e78 | 1455 | { |
f6bcfd97 BP |
1456 | bool setCursor; |
1457 | if (hit_border) | |
1458 | { | |
1459 | setCursor = m_currentCursor == wxSTANDARD_CURSOR; | |
1460 | m_currentCursor = m_resizeCursor; | |
1461 | } | |
1462 | else | |
1463 | { | |
1464 | setCursor = m_currentCursor != wxSTANDARD_CURSOR; | |
1465 | m_currentCursor = wxSTANDARD_CURSOR; | |
1466 | } | |
1467 | ||
1468 | if ( setCursor ) | |
1469 | SetCursor(*m_currentCursor); | |
63852e78 | 1470 | } |
e1e955e1 | 1471 | } |
e1e955e1 | 1472 | } |
c801d85f KB |
1473 | |
1474 | void wxListHeaderWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) | |
1475 | { | |
63852e78 | 1476 | m_owner->SetFocus(); |
e1e955e1 | 1477 | } |
c801d85f KB |
1478 | |
1479 | //----------------------------------------------------------------------------- | |
1480 | // wxListRenameTimer (internal) | |
1481 | //----------------------------------------------------------------------------- | |
1482 | ||
bd8289c1 VZ |
1483 | wxListRenameTimer::wxListRenameTimer( wxListMainWindow *owner ) |
1484 | { | |
63852e78 | 1485 | m_owner = owner; |
e1e955e1 | 1486 | } |
c801d85f | 1487 | |
bd8289c1 VZ |
1488 | void wxListRenameTimer::Notify() |
1489 | { | |
63852e78 | 1490 | m_owner->OnRenameTimer(); |
e1e955e1 | 1491 | } |
c801d85f | 1492 | |
ee7ee469 RR |
1493 | //----------------------------------------------------------------------------- |
1494 | // wxListTextCtrl (internal) | |
1495 | //----------------------------------------------------------------------------- | |
1496 | ||
1497 | IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl,wxTextCtrl); | |
bd8289c1 | 1498 | |
ee7ee469 | 1499 | BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl) |
63852e78 | 1500 | EVT_CHAR (wxListTextCtrl::OnChar) |
c13cace1 | 1501 | EVT_KEY_UP (wxListTextCtrl::OnKeyUp) |
63852e78 | 1502 | EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus) |
ee7ee469 RR |
1503 | END_EVENT_TABLE() |
1504 | ||
674ac8b9 VZ |
1505 | wxListTextCtrl::wxListTextCtrl( wxWindow *parent, |
1506 | const wxWindowID id, | |
1507 | bool *accept, | |
1508 | wxString *res, | |
1509 | wxListMainWindow *owner, | |
1510 | const wxString &value, | |
1511 | const wxPoint &pos, | |
1512 | const wxSize &size, | |
1513 | int style, | |
1514 | const wxValidator& validator, | |
1515 | const wxString &name ) | |
1516 | : wxTextCtrl( parent, id, value, pos, size, style, validator, name ) | |
ee7ee469 | 1517 | { |
63852e78 RR |
1518 | m_res = res; |
1519 | m_accept = accept; | |
1520 | m_owner = owner; | |
5f1ea0ee RR |
1521 | (*m_accept) = FALSE; |
1522 | (*m_res) = ""; | |
1523 | m_startValue = value; | |
ee7ee469 RR |
1524 | } |
1525 | ||
1526 | void wxListTextCtrl::OnChar( wxKeyEvent &event ) | |
1527 | { | |
63852e78 RR |
1528 | if (event.m_keyCode == WXK_RETURN) |
1529 | { | |
1530 | (*m_accept) = TRUE; | |
1531 | (*m_res) = GetValue(); | |
f6bcfd97 | 1532 | |
bce1406b RR |
1533 | if (!wxPendingDelete.Member(this)) |
1534 | wxPendingDelete.Append(this); | |
1535 | ||
1536 | if ((*m_accept) && ((*m_res) != m_startValue)) | |
1537 | m_owner->OnRenameAccept(); | |
f6bcfd97 | 1538 | |
63852e78 RR |
1539 | return; |
1540 | } | |
1541 | if (event.m_keyCode == WXK_ESCAPE) | |
1542 | { | |
1543 | (*m_accept) = FALSE; | |
1544 | (*m_res) = ""; | |
f6bcfd97 | 1545 | |
bce1406b RR |
1546 | if (!wxPendingDelete.Member(this)) |
1547 | wxPendingDelete.Append(this); | |
f6bcfd97 | 1548 | |
63852e78 RR |
1549 | return; |
1550 | } | |
f6bcfd97 | 1551 | |
63852e78 RR |
1552 | event.Skip(); |
1553 | } | |
1554 | ||
c13cace1 VS |
1555 | void wxListTextCtrl::OnKeyUp( wxKeyEvent &event ) |
1556 | { | |
1557 | // auto-grow the textctrl: | |
1558 | wxSize parentSize = m_owner->GetSize(); | |
1559 | wxPoint myPos = GetPosition(); | |
1560 | wxSize mySize = GetSize(); | |
1561 | int sx, sy; | |
1562 | GetTextExtent(GetValue() + _T("MM"), &sx, &sy); | |
1563 | if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x; | |
1564 | if (mySize.x > sx) sx = mySize.x; | |
1565 | SetSize(sx, -1); | |
1566 | ||
1567 | event.Skip(); | |
1568 | } | |
1569 | ||
63852e78 RR |
1570 | void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) |
1571 | { | |
bce1406b RR |
1572 | if (!wxPendingDelete.Member(this)) |
1573 | wxPendingDelete.Append(this); | |
004fd0c8 | 1574 | |
5f1ea0ee RR |
1575 | if ((*m_accept) && ((*m_res) != m_startValue)) |
1576 | m_owner->OnRenameAccept(); | |
ee7ee469 RR |
1577 | } |
1578 | ||
c801d85f KB |
1579 | //----------------------------------------------------------------------------- |
1580 | // wxListMainWindow | |
1581 | //----------------------------------------------------------------------------- | |
1582 | ||
1583 | IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow,wxScrolledWindow); | |
bd8289c1 | 1584 | |
c801d85f KB |
1585 | BEGIN_EVENT_TABLE(wxListMainWindow,wxScrolledWindow) |
1586 | EVT_PAINT (wxListMainWindow::OnPaint) | |
1587 | EVT_SIZE (wxListMainWindow::OnSize) | |
1588 | EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse) | |
1589 | EVT_CHAR (wxListMainWindow::OnChar) | |
3dfb93fd | 1590 | EVT_KEY_DOWN (wxListMainWindow::OnKeyDown) |
c801d85f KB |
1591 | EVT_SET_FOCUS (wxListMainWindow::OnSetFocus) |
1592 | EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus) | |
2fa7c206 | 1593 | EVT_SCROLLWIN (wxListMainWindow::OnScroll) |
c801d85f KB |
1594 | END_EVENT_TABLE() |
1595 | ||
fd9811b1 | 1596 | wxListMainWindow::wxListMainWindow() |
c801d85f | 1597 | { |
139adb6a | 1598 | m_mode = 0; |
139adb6a RR |
1599 | m_columns.DeleteContents( TRUE ); |
1600 | m_current = (wxListLineData *) NULL; | |
1601 | m_visibleLines = 0; | |
1602 | m_hilightBrush = (wxBrush *) NULL; | |
1603 | m_xScroll = 0; | |
1604 | m_yScroll = 0; | |
1605 | m_dirty = TRUE; | |
1606 | m_small_image_list = (wxImageList *) NULL; | |
1607 | m_normal_image_list = (wxImageList *) NULL; | |
1608 | m_small_spacing = 30; | |
1609 | m_normal_spacing = 40; | |
1610 | m_hasFocus = FALSE; | |
1611 | m_usedKeys = TRUE; | |
1612 | m_lastOnSame = FALSE; | |
1613 | m_renameTimer = new wxListRenameTimer( this ); | |
1614 | m_isCreated = FALSE; | |
1615 | m_dragCount = 0; | |
efbb7287 VZ |
1616 | |
1617 | m_lineLastClicked = | |
1618 | m_lineBeforeLastClicked = (wxListLineData *)NULL; | |
e1e955e1 | 1619 | } |
c801d85f | 1620 | |
bd8289c1 | 1621 | wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id, |
c801d85f | 1622 | const wxPoint &pos, const wxSize &size, |
debe6624 | 1623 | long style, const wxString &name ) : |
a367b9b3 | 1624 | wxScrolledWindow( parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name ) |
c801d85f | 1625 | { |
139adb6a | 1626 | m_mode = style; |
139adb6a RR |
1627 | m_columns.DeleteContents( TRUE ); |
1628 | m_current = (wxListLineData *) NULL; | |
1629 | m_dirty = TRUE; | |
1630 | m_visibleLines = 0; | |
1631 | m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID ); | |
1632 | m_small_image_list = (wxImageList *) NULL; | |
1633 | m_normal_image_list = (wxImageList *) NULL; | |
1634 | m_small_spacing = 30; | |
1635 | m_normal_spacing = 40; | |
1636 | m_hasFocus = FALSE; | |
1637 | m_dragCount = 0; | |
1638 | m_isCreated = FALSE; | |
1639 | wxSize sz = size; | |
1640 | sz.y = 25; | |
bd8289c1 | 1641 | |
139adb6a RR |
1642 | if (m_mode & wxLC_REPORT) |
1643 | { | |
7c74e7fe SC |
1644 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
1645 | m_xScroll = 15; | |
1646 | #else | |
139adb6a | 1647 | m_xScroll = 0; |
7c74e7fe | 1648 | #endif |
139adb6a RR |
1649 | m_yScroll = 15; |
1650 | } | |
1651 | else | |
1652 | { | |
1653 | m_xScroll = 15; | |
1654 | m_yScroll = 0; | |
1655 | } | |
1656 | SetScrollbars( m_xScroll, m_yScroll, 0, 0, 0, 0 ); | |
bd8289c1 | 1657 | |
139adb6a RR |
1658 | m_usedKeys = TRUE; |
1659 | m_lastOnSame = FALSE; | |
1660 | m_renameTimer = new wxListRenameTimer( this ); | |
1661 | m_renameAccept = FALSE; | |
c801d85f | 1662 | |
91fc2bdc | 1663 | SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) ); |
e1e955e1 | 1664 | } |
c801d85f | 1665 | |
fd9811b1 | 1666 | wxListMainWindow::~wxListMainWindow() |
c801d85f | 1667 | { |
12c1b46a RR |
1668 | DeleteEverything(); |
1669 | ||
139adb6a | 1670 | if (m_hilightBrush) delete m_hilightBrush; |
004fd0c8 | 1671 | |
139adb6a | 1672 | delete m_renameTimer; |
e1e955e1 | 1673 | } |
c801d85f KB |
1674 | |
1675 | void wxListMainWindow::RefreshLine( wxListLineData *line ) | |
1676 | { | |
e6527f9d | 1677 | if (m_dirty) return; |
25e3a937 | 1678 | |
3d2d8da1 | 1679 | if (!line) return; |
f6bcfd97 | 1680 | |
139adb6a RR |
1681 | int x = 0; |
1682 | int y = 0; | |
1683 | int w = 0; | |
1684 | int h = 0; | |
3d2d8da1 RR |
1685 | line->GetExtent( x, y, w, h ); |
1686 | CalcScrolledPosition( x, y, &x, &y ); | |
1687 | wxRect rect( x, y, w, h ); | |
1688 | Refresh( TRUE, &rect ); | |
e1e955e1 | 1689 | } |
c801d85f KB |
1690 | |
1691 | void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) | |
1692 | { | |
f60d0f94 JS |
1693 | // Note: a wxPaintDC must be constructed even if no drawing is |
1694 | // done (a Windows requirement). | |
1695 | wxPaintDC dc( this ); | |
1696 | PrepareDC( dc ); | |
1697 | ||
673dfcfa JS |
1698 | int dev_x = 0; |
1699 | int dev_y = 0; | |
1700 | CalcScrolledPosition( 0, 0, &dev_x, &dev_y ); | |
1701 | ||
139adb6a | 1702 | if (m_dirty) return; |
004fd0c8 | 1703 | |
139adb6a | 1704 | if (m_lines.GetCount() == 0) return; |
bd8289c1 | 1705 | |
139adb6a | 1706 | dc.BeginDrawing(); |
c801d85f | 1707 | |
139adb6a | 1708 | dc.SetFont( GetFont() ); |
004fd0c8 | 1709 | |
139adb6a RR |
1710 | if (m_mode & wxLC_REPORT) |
1711 | { | |
206b0a67 | 1712 | wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); |
206b0a67 | 1713 | wxSize clientSize = GetClientSize(); |
206b0a67 | 1714 | |
139adb6a | 1715 | int lineSpacing = 0; |
f6bcfd97 | 1716 | wxListLineData *line = &m_lines[0]; |
139adb6a RR |
1717 | int dummy = 0; |
1718 | line->GetSize( dummy, lineSpacing ); | |
1719 | lineSpacing += 1; | |
bffa1c77 | 1720 | |
139adb6a | 1721 | int y_s = m_yScroll*GetScrollPos( wxVERTICAL ); |
bffa1c77 | 1722 | |
f6bcfd97 BP |
1723 | size_t i_to = y_s / lineSpacing + m_visibleLines+2; |
1724 | if (i_to >= m_lines.GetCount()) i_to = m_lines.GetCount(); | |
206b0a67 JS |
1725 | size_t i; |
1726 | for (i = y_s / lineSpacing; i < i_to; i++) | |
bffa1c77 | 1727 | { |
f6bcfd97 | 1728 | m_lines[i].Draw( &dc ); |
206b0a67 JS |
1729 | // Draw horizontal rule if required |
1730 | if (GetWindowStyle() & wxLC_HRULES) | |
673dfcfa JS |
1731 | { |
1732 | dc.SetPen(pen); | |
1733 | dc.SetBrush(* wxTRANSPARENT_BRUSH); | |
1734 | dc.DrawLine(0 - dev_x , i*lineSpacing , clientSize.x - dev_x , i*lineSpacing ); | |
1735 | } | |
bffa1c77 | 1736 | } |
206b0a67 JS |
1737 | |
1738 | // Draw last horizontal rule | |
1739 | if ((i > (size_t) (y_s / lineSpacing)) && (GetWindowStyle() & wxLC_HRULES)) | |
673dfcfa JS |
1740 | { |
1741 | dc.SetPen(pen); | |
1742 | dc.SetBrush(* wxTRANSPARENT_BRUSH); | |
1743 | dc.DrawLine(0 - dev_x , i*lineSpacing , clientSize.x - dev_x , i*lineSpacing ); | |
1744 | } | |
206b0a67 JS |
1745 | |
1746 | // Draw vertical rules if required | |
1747 | if ((GetWindowStyle() & wxLC_VRULES) && (GetItemCount() > 0)) | |
1748 | { | |
1749 | int col = 0; | |
1750 | wxRect firstItemRect; | |
1751 | wxRect lastItemRect; | |
1752 | GetItemRect(0, firstItemRect); | |
1753 | GetItemRect(GetItemCount() - 1, lastItemRect); | |
1754 | int x = firstItemRect.GetX(); | |
673dfcfa JS |
1755 | dc.SetPen(pen); |
1756 | dc.SetBrush(* wxTRANSPARENT_BRUSH); | |
206b0a67 JS |
1757 | for (col = 0; col < GetColumnCount(); col++) |
1758 | { | |
1759 | int colWidth = GetColumnWidth(col); | |
1760 | x += colWidth ; | |
673dfcfa | 1761 | dc.DrawLine(x - dev_x, firstItemRect.GetY() - 1 - dev_y, x - dev_x, lastItemRect.GetBottom() + 1 - dev_y); |
206b0a67 | 1762 | } |
d786bf87 | 1763 | } |
139adb6a RR |
1764 | } |
1765 | else | |
1766 | { | |
f6bcfd97 BP |
1767 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
1768 | m_lines[i].Draw( &dc ); | |
139adb6a | 1769 | } |
004fd0c8 | 1770 | |
139adb6a | 1771 | if (m_current) m_current->DrawRubberBand( &dc, m_hasFocus ); |
c801d85f | 1772 | |
139adb6a | 1773 | dc.EndDrawing(); |
e1e955e1 | 1774 | } |
c801d85f | 1775 | |
debe6624 | 1776 | void wxListMainWindow::HilightAll( bool on ) |
c801d85f | 1777 | { |
f6bcfd97 | 1778 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
c801d85f | 1779 | { |
f6bcfd97 | 1780 | wxListLineData *line = &m_lines[i]; |
139adb6a RR |
1781 | if (line->IsHilighted() != on) |
1782 | { | |
1783 | line->Hilight( on ); | |
1784 | RefreshLine( line ); | |
1785 | } | |
e1e955e1 | 1786 | } |
e1e955e1 | 1787 | } |
c801d85f | 1788 | |
05a7f61d VZ |
1789 | void wxListMainWindow::SendNotify( wxListLineData *line, |
1790 | wxEventType command, | |
1791 | wxPoint point ) | |
c801d85f | 1792 | { |
139adb6a RR |
1793 | wxListEvent le( command, GetParent()->GetId() ); |
1794 | le.SetEventObject( GetParent() ); | |
1795 | le.m_itemIndex = GetIndexOfLine( line ); | |
05a7f61d VZ |
1796 | |
1797 | // set only for events which have position | |
1798 | if ( point != wxDefaultPosition ) | |
1799 | le.m_pointDrag = point; | |
1800 | ||
139adb6a | 1801 | line->GetItem( 0, le.m_item ); |
6e228e42 RR |
1802 | GetParent()->GetEventHandler()->ProcessEvent( le ); |
1803 | // GetParent()->GetEventHandler()->AddPendingEvent( le ); | |
e1e955e1 | 1804 | } |
c801d85f KB |
1805 | |
1806 | void wxListMainWindow::FocusLine( wxListLineData *WXUNUSED(line) ) | |
1807 | { | |
1808 | // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_FOCUSSED ); | |
e1e955e1 | 1809 | } |
c801d85f KB |
1810 | |
1811 | void wxListMainWindow::UnfocusLine( wxListLineData *WXUNUSED(line) ) | |
1812 | { | |
1813 | // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_UNFOCUSSED ); | |
e1e955e1 | 1814 | } |
c801d85f KB |
1815 | |
1816 | void wxListMainWindow::SelectLine( wxListLineData *line ) | |
1817 | { | |
139adb6a | 1818 | SendNotify( line, wxEVT_COMMAND_LIST_ITEM_SELECTED ); |
e1e955e1 | 1819 | } |
c801d85f KB |
1820 | |
1821 | void wxListMainWindow::DeselectLine( wxListLineData *line ) | |
1822 | { | |
139adb6a | 1823 | SendNotify( line, wxEVT_COMMAND_LIST_ITEM_DESELECTED ); |
e1e955e1 | 1824 | } |
c801d85f KB |
1825 | |
1826 | void wxListMainWindow::DeleteLine( wxListLineData *line ) | |
1827 | { | |
139adb6a | 1828 | SendNotify( line, wxEVT_COMMAND_LIST_DELETE_ITEM ); |
e1e955e1 | 1829 | } |
c801d85f | 1830 | |
e179bd65 | 1831 | /* *** */ |
ee7ee469 | 1832 | |
5f1ea0ee | 1833 | void wxListMainWindow::EditLabel( long item ) |
c801d85f | 1834 | { |
3e1c4e00 | 1835 | wxCHECK_RET( ((size_t)item < m_lines.GetCount()), |
f6bcfd97 | 1836 | wxT("wrong index in wxListCtrl::Edit()") ); |
004fd0c8 | 1837 | |
f6bcfd97 | 1838 | m_currentEdit = &m_lines[(size_t)item]; |
e179bd65 | 1839 | |
fd9811b1 | 1840 | wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, GetParent()->GetId() ); |
139adb6a | 1841 | le.SetEventObject( GetParent() ); |
e179bd65 RR |
1842 | le.m_itemIndex = GetIndexOfLine( m_currentEdit ); |
1843 | m_currentEdit->GetItem( 0, le.m_item ); | |
139adb6a | 1844 | GetParent()->GetEventHandler()->ProcessEvent( le ); |
004fd0c8 | 1845 | |
86f975a8 | 1846 | if (!le.IsAllowed()) |
5f1ea0ee | 1847 | return; |
004fd0c8 | 1848 | |
dc6c62a9 RR |
1849 | // We have to call this here because the label in |
1850 | // question might just have been added and no screen | |
1851 | // update taken place. | |
1852 | if (m_dirty) wxYield(); | |
1853 | ||
92976ab6 | 1854 | wxString s; |
e179bd65 | 1855 | m_currentEdit->GetText( 0, s ); |
92976ab6 RR |
1856 | int x = 0; |
1857 | int y = 0; | |
1858 | int w = 0; | |
1859 | int h = 0; | |
e179bd65 | 1860 | m_currentEdit->GetLabelExtent( x, y, w, h ); |
004fd0c8 | 1861 | |
92976ab6 RR |
1862 | wxClientDC dc(this); |
1863 | PrepareDC( dc ); | |
1864 | x = dc.LogicalToDeviceX( x ); | |
1865 | y = dc.LogicalToDeviceY( y ); | |
bd8289c1 | 1866 | |
92976ab6 RR |
1867 | wxListTextCtrl *text = new wxListTextCtrl( |
1868 | this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) ); | |
1869 | text->SetFocus(); | |
e1e955e1 | 1870 | } |
c801d85f | 1871 | |
e179bd65 RR |
1872 | void wxListMainWindow::OnRenameTimer() |
1873 | { | |
223d09f6 | 1874 | wxCHECK_RET( m_current, wxT("invalid m_current") ); |
004fd0c8 | 1875 | |
f6bcfd97 | 1876 | Edit( m_lines.Index( *m_current ) ); |
e179bd65 RR |
1877 | } |
1878 | ||
c801d85f KB |
1879 | void wxListMainWindow::OnRenameAccept() |
1880 | { | |
e179bd65 RR |
1881 | wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() ); |
1882 | le.SetEventObject( GetParent() ); | |
1883 | le.m_itemIndex = GetIndexOfLine( m_currentEdit ); | |
1884 | m_currentEdit->GetItem( 0, le.m_item ); | |
1885 | le.m_item.m_text = m_renameRes; | |
1886 | GetParent()->GetEventHandler()->ProcessEvent( le ); | |
004fd0c8 | 1887 | |
e179bd65 | 1888 | if (!le.IsAllowed()) return; |
004fd0c8 | 1889 | |
5f1ea0ee RR |
1890 | wxListItem info; |
1891 | info.m_mask = wxLIST_MASK_TEXT; | |
1892 | info.m_itemId = le.m_itemIndex; | |
1893 | info.m_text = m_renameRes; | |
aaa37c0d | 1894 | info.SetTextColour(le.m_item.GetTextColour()); |
5f1ea0ee | 1895 | SetItem( info ); |
e1e955e1 | 1896 | } |
c801d85f KB |
1897 | |
1898 | void wxListMainWindow::OnMouse( wxMouseEvent &event ) | |
1899 | { | |
3e1c4e00 | 1900 | event.SetEventObject( GetParent() ); |
92976ab6 | 1901 | if (GetParent()->GetEventHandler()->ProcessEvent( event)) return; |
e3e65dac | 1902 | |
92976ab6 RR |
1903 | if (!m_current) return; |
1904 | if (m_dirty) return; | |
0b855868 | 1905 | if ( !(event.Dragging() || event.ButtonDown() || event.LeftUp() || event.ButtonDClick()) ) return; |
c801d85f | 1906 | |
aaef15bf RR |
1907 | int x = event.GetX(); |
1908 | int y = event.GetY(); | |
1909 | CalcUnscrolledPosition( x, y, &x, &y ); | |
004fd0c8 | 1910 | |
51cc4dad | 1911 | /* Did we actually hit an item ? */ |
92976ab6 | 1912 | long hitResult = 0; |
92976ab6 | 1913 | wxListLineData *line = (wxListLineData *) NULL; |
f6bcfd97 | 1914 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
92976ab6 | 1915 | { |
f6bcfd97 | 1916 | line = &m_lines[i]; |
92976ab6 RR |
1917 | hitResult = line->IsHit( x, y ); |
1918 | if (hitResult) break; | |
1919 | line = (wxListLineData *) NULL; | |
92976ab6 | 1920 | } |
bd8289c1 | 1921 | |
fd9811b1 | 1922 | if (event.Dragging()) |
92976ab6 | 1923 | { |
fd9811b1 | 1924 | if (m_dragCount == 0) |
bffa1c77 VZ |
1925 | m_dragStart = wxPoint(x,y); |
1926 | ||
fd9811b1 | 1927 | m_dragCount++; |
bffa1c77 VZ |
1928 | |
1929 | if (m_dragCount != 3) return; | |
1930 | ||
05a7f61d VZ |
1931 | int command = event.RightIsDown() ? wxEVT_COMMAND_LIST_BEGIN_RDRAG |
1932 | : wxEVT_COMMAND_LIST_BEGIN_DRAG; | |
bffa1c77 | 1933 | |
fd9811b1 | 1934 | wxListEvent le( command, GetParent()->GetId() ); |
92976ab6 | 1935 | le.SetEventObject( GetParent() ); |
bffa1c77 VZ |
1936 | le.m_pointDrag = m_dragStart; |
1937 | GetParent()->GetEventHandler()->ProcessEvent( le ); | |
1938 | ||
1939 | return; | |
92976ab6 | 1940 | } |
fd9811b1 RR |
1941 | else |
1942 | { | |
1943 | m_dragCount = 0; | |
1944 | } | |
bd8289c1 | 1945 | |
92976ab6 | 1946 | if (!line) return; |
bd8289c1 | 1947 | |
efbb7287 | 1948 | bool forceClick = FALSE; |
92976ab6 RR |
1949 | if (event.ButtonDClick()) |
1950 | { | |
92976ab6 | 1951 | m_renameTimer->Stop(); |
efbb7287 VZ |
1952 | m_lastOnSame = FALSE; |
1953 | ||
1954 | if ( line == m_lineBeforeLastClicked ) | |
1955 | { | |
1956 | m_usedKeys = FALSE; | |
004fd0c8 | 1957 | |
efbb7287 | 1958 | SendNotify( line, wxEVT_COMMAND_LIST_ITEM_ACTIVATED ); |
004fd0c8 | 1959 | |
efbb7287 VZ |
1960 | return; |
1961 | } | |
1962 | else | |
1963 | { | |
1964 | // the first click was on another item, so don't interpret this as | |
1965 | // a double click, but as a simple click instead | |
1966 | forceClick = TRUE; | |
1967 | } | |
92976ab6 | 1968 | } |
bd8289c1 | 1969 | |
92976ab6 | 1970 | if (event.LeftUp() && m_lastOnSame) |
c801d85f | 1971 | { |
92976ab6 RR |
1972 | m_usedKeys = FALSE; |
1973 | if ((line == m_current) && | |
1974 | (hitResult == wxLIST_HITTEST_ONITEMLABEL) && | |
1975 | (m_mode & wxLC_EDIT_LABELS) ) | |
1976 | { | |
1977 | m_renameTimer->Start( 100, TRUE ); | |
1978 | } | |
1979 | m_lastOnSame = FALSE; | |
1980 | return; | |
e1e955e1 | 1981 | } |
bd8289c1 | 1982 | |
92976ab6 | 1983 | if (event.RightDown()) |
b204641e | 1984 | { |
05a7f61d VZ |
1985 | SendNotify( line, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, |
1986 | event.GetPosition() ); | |
92976ab6 | 1987 | return; |
b204641e | 1988 | } |
004fd0c8 | 1989 | |
92976ab6 | 1990 | if (event.MiddleDown()) |
b204641e | 1991 | { |
92976ab6 RR |
1992 | SendNotify( line, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK ); |
1993 | return; | |
1994 | } | |
004fd0c8 | 1995 | |
efbb7287 | 1996 | if ( event.LeftDown() || forceClick ) |
92976ab6 | 1997 | { |
efbb7287 VZ |
1998 | m_lineBeforeLastClicked = m_lineLastClicked; |
1999 | m_lineLastClicked = line; | |
2000 | ||
92976ab6 RR |
2001 | m_usedKeys = FALSE; |
2002 | wxListLineData *oldCurrent = m_current; | |
2003 | if (m_mode & wxLC_SINGLE_SEL) | |
b204641e | 2004 | { |
92976ab6 RR |
2005 | m_current = line; |
2006 | HilightAll( FALSE ); | |
2007 | m_current->ReverseHilight(); | |
2008 | RefreshLine( m_current ); | |
e1e955e1 | 2009 | } |
92976ab6 | 2010 | else |
b204641e | 2011 | { |
473d087e | 2012 | if (event.ControlDown()) |
92976ab6 RR |
2013 | { |
2014 | m_current = line; | |
2015 | m_current->ReverseHilight(); | |
2016 | RefreshLine( m_current ); | |
2017 | } | |
473d087e | 2018 | else if (event.ShiftDown()) |
92976ab6 | 2019 | { |
f6bcfd97 | 2020 | size_t j; |
3e1c4e00 | 2021 | |
92976ab6 | 2022 | m_current = line; |
bffa1c77 | 2023 | |
92976ab6 | 2024 | int numOfCurrent = -1; |
f6bcfd97 | 2025 | for (j = 0; j < m_lines.GetCount(); j++) |
92976ab6 | 2026 | { |
f6bcfd97 | 2027 | wxListLineData *test_line = &m_lines[j]; |
92976ab6 RR |
2028 | numOfCurrent++; |
2029 | if (test_line == oldCurrent) break; | |
92976ab6 | 2030 | } |
bffa1c77 | 2031 | |
92976ab6 | 2032 | int numOfLine = -1; |
f6bcfd97 BP |
2033 | |
2034 | for (j = 0; j < m_lines.GetCount(); j++) | |
92976ab6 | 2035 | { |
f6bcfd97 | 2036 | wxListLineData *test_line = &m_lines[j]; |
92976ab6 RR |
2037 | numOfLine++; |
2038 | if (test_line == line) break; | |
92976ab6 RR |
2039 | } |
2040 | ||
2041 | if (numOfLine < numOfCurrent) | |
004fd0c8 | 2042 | { |
bffa1c77 VZ |
2043 | int i = numOfLine; |
2044 | numOfLine = numOfCurrent; | |
2045 | numOfCurrent = i; | |
2046 | } | |
2047 | ||
92976ab6 RR |
2048 | for (int i = 0; i <= numOfLine-numOfCurrent; i++) |
2049 | { | |
f6bcfd97 | 2050 | wxListLineData *test_line= &m_lines[numOfCurrent + i]; |
92976ab6 RR |
2051 | test_line->Hilight(TRUE); |
2052 | RefreshLine( test_line ); | |
92976ab6 RR |
2053 | } |
2054 | } | |
2055 | else | |
2056 | { | |
2057 | m_current = line; | |
2058 | HilightAll( FALSE ); | |
2059 | m_current->ReverseHilight(); | |
2060 | RefreshLine( m_current ); | |
2061 | } | |
e1e955e1 | 2062 | } |
92976ab6 RR |
2063 | if (m_current != oldCurrent) |
2064 | { | |
2065 | RefreshLine( oldCurrent ); | |
2066 | UnfocusLine( oldCurrent ); | |
2067 | FocusLine( m_current ); | |
2068 | } | |
efbb7287 VZ |
2069 | |
2070 | // forceClick is only set if the previous click was on another item | |
2071 | m_lastOnSame = !forceClick && (m_current == oldCurrent); | |
2072 | ||
92976ab6 | 2073 | return; |
e1e955e1 | 2074 | } |
e1e955e1 | 2075 | } |
c801d85f | 2076 | |
e179bd65 | 2077 | void wxListMainWindow::MoveToFocus() |
c801d85f | 2078 | { |
92976ab6 | 2079 | if (!m_current) return; |
004fd0c8 | 2080 | |
cf3da716 RR |
2081 | int item_x = 0; |
2082 | int item_y = 0; | |
2083 | int item_w = 0; | |
2084 | int item_h = 0; | |
2085 | m_current->GetExtent( item_x, item_y, item_w, item_h ); | |
2086 | ||
2087 | int client_w = 0; | |
2088 | int client_h = 0; | |
2089 | GetClientSize( &client_w, &client_h ); | |
f6bcfd97 | 2090 | |
cf3da716 RR |
2091 | int view_x = m_xScroll*GetScrollPos( wxHORIZONTAL ); |
2092 | int view_y = m_yScroll*GetScrollPos( wxVERTICAL ); | |
004fd0c8 | 2093 | |
92976ab6 RR |
2094 | if (m_mode & wxLC_REPORT) |
2095 | { | |
08bf1d5d RR |
2096 | if (item_y < view_y ) |
2097 | Scroll( -1, (item_y)/m_yScroll ); | |
f6bcfd97 | 2098 | if (item_y+item_h+5 > view_y+client_h) |
cf3da716 | 2099 | Scroll( -1, (item_y+item_h-client_h+15)/m_yScroll ); |
92976ab6 RR |
2100 | } |
2101 | else | |
2102 | { | |
f6bcfd97 | 2103 | if (item_x-view_x < 5) |
cf3da716 | 2104 | Scroll( (item_x-5)/m_xScroll, -1 ); |
f6bcfd97 | 2105 | if (item_x+item_w-5 > view_x+client_w) |
cf3da716 | 2106 | Scroll( (item_x+item_w-client_w+15)/m_xScroll, -1 ); |
92976ab6 | 2107 | } |
e1e955e1 | 2108 | } |
c801d85f KB |
2109 | |
2110 | void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown ) | |
2111 | { | |
92976ab6 RR |
2112 | if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE ); |
2113 | wxListLineData *oldCurrent = m_current; | |
2114 | m_current = newCurrent; | |
92976ab6 RR |
2115 | if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE ); |
2116 | RefreshLine( m_current ); | |
2117 | RefreshLine( oldCurrent ); | |
2118 | FocusLine( m_current ); | |
2119 | UnfocusLine( oldCurrent ); | |
cf3da716 | 2120 | MoveToFocus(); |
e1e955e1 | 2121 | } |
c801d85f | 2122 | |
3dfb93fd RR |
2123 | void wxListMainWindow::OnKeyDown( wxKeyEvent &event ) |
2124 | { | |
2125 | wxWindow *parent = GetParent(); | |
004fd0c8 | 2126 | |
3dfb93fd RR |
2127 | /* we propagate the key event up */ |
2128 | wxKeyEvent ke( wxEVT_KEY_DOWN ); | |
2129 | ke.m_shiftDown = event.m_shiftDown; | |
2130 | ke.m_controlDown = event.m_controlDown; | |
2131 | ke.m_altDown = event.m_altDown; | |
2132 | ke.m_metaDown = event.m_metaDown; | |
2133 | ke.m_keyCode = event.m_keyCode; | |
2134 | ke.m_x = event.m_x; | |
2135 | ke.m_y = event.m_y; | |
2136 | ke.SetEventObject( parent ); | |
2137 | if (parent->GetEventHandler()->ProcessEvent( ke )) return; | |
004fd0c8 | 2138 | |
3dfb93fd RR |
2139 | event.Skip(); |
2140 | } | |
004fd0c8 | 2141 | |
c801d85f KB |
2142 | void wxListMainWindow::OnChar( wxKeyEvent &event ) |
2143 | { | |
51cc4dad | 2144 | wxWindow *parent = GetParent(); |
004fd0c8 | 2145 | |
51cc4dad | 2146 | /* we send a list_key event up */ |
f6bcfd97 BP |
2147 | if ( m_current ) |
2148 | { | |
2149 | wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); | |
2150 | le.m_itemIndex = GetIndexOfLine( m_current ); | |
2151 | m_current->GetItem( 0, le.m_item ); | |
2152 | le.m_code = (int)event.KeyCode(); | |
2153 | le.SetEventObject( parent ); | |
2154 | parent->GetEventHandler()->ProcessEvent( le ); | |
2155 | } | |
51cc4dad | 2156 | |
3dfb93fd RR |
2157 | /* we propagate the char event up */ |
2158 | wxKeyEvent ke( wxEVT_CHAR ); | |
51cc4dad RR |
2159 | ke.m_shiftDown = event.m_shiftDown; |
2160 | ke.m_controlDown = event.m_controlDown; | |
2161 | ke.m_altDown = event.m_altDown; | |
2162 | ke.m_metaDown = event.m_metaDown; | |
2163 | ke.m_keyCode = event.m_keyCode; | |
2164 | ke.m_x = event.m_x; | |
2165 | ke.m_y = event.m_y; | |
2166 | ke.SetEventObject( parent ); | |
2167 | if (parent->GetEventHandler()->ProcessEvent( ke )) return; | |
004fd0c8 | 2168 | |
012a03e0 RR |
2169 | if (event.KeyCode() == WXK_TAB) |
2170 | { | |
2171 | wxNavigationKeyEvent nevent; | |
c5145d41 | 2172 | nevent.SetWindowChange( event.ControlDown() ); |
012a03e0 | 2173 | nevent.SetDirection( !event.ShiftDown() ); |
8253c7fd | 2174 | nevent.SetEventObject( GetParent()->GetParent() ); |
012a03e0 | 2175 | nevent.SetCurrentFocus( m_parent ); |
8253c7fd | 2176 | if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent )) return; |
012a03e0 | 2177 | } |
004fd0c8 | 2178 | |
51cc4dad RR |
2179 | /* no item -> nothing to do */ |
2180 | if (!m_current) | |
c801d85f | 2181 | { |
51cc4dad RR |
2182 | event.Skip(); |
2183 | return; | |
e1e955e1 | 2184 | } |
51cc4dad RR |
2185 | |
2186 | switch (event.KeyCode()) | |
c801d85f | 2187 | { |
51cc4dad RR |
2188 | case WXK_UP: |
2189 | { | |
f6bcfd97 BP |
2190 | int index = m_lines.Index(*m_current); |
2191 | if (index != wxNOT_FOUND && index > 0) | |
2192 | OnArrowChar( &m_lines[index-1], event.ShiftDown() ); | |
51cc4dad RR |
2193 | break; |
2194 | } | |
2195 | case WXK_DOWN: | |
2196 | { | |
f6bcfd97 BP |
2197 | int index = m_lines.Index(*m_current); |
2198 | if (index != wxNOT_FOUND && (size_t)index < m_lines.GetCount()-1) | |
2199 | OnArrowChar( &m_lines[index+1], event.ShiftDown() ); | |
51cc4dad RR |
2200 | break; |
2201 | } | |
2202 | case WXK_END: | |
2203 | { | |
f6bcfd97 BP |
2204 | if (!m_lines.IsEmpty()) |
2205 | OnArrowChar( &m_lines.Last(), event.ShiftDown() ); | |
51cc4dad RR |
2206 | break; |
2207 | } | |
2208 | case WXK_HOME: | |
2209 | { | |
f6bcfd97 BP |
2210 | if (!m_lines.IsEmpty()) |
2211 | OnArrowChar( &m_lines[0], event.ShiftDown() ); | |
51cc4dad RR |
2212 | break; |
2213 | } | |
2214 | case WXK_PRIOR: | |
2215 | { | |
2216 | int steps = 0; | |
f6bcfd97 | 2217 | int index = m_lines.Index(*m_current); |
004fd0c8 | 2218 | if (m_mode & wxLC_REPORT) |
bffa1c77 VZ |
2219 | { |
2220 | steps = m_visibleLines-1; | |
2221 | } | |
51cc4dad RR |
2222 | else |
2223 | { | |
f6bcfd97 BP |
2224 | steps = index % m_visibleLines; |
2225 | } | |
2226 | if (index != wxNOT_FOUND) | |
2227 | { | |
2228 | index -= steps; | |
3e1c4e00 | 2229 | if (index < 0) index = 0; |
f6bcfd97 | 2230 | OnArrowChar( &m_lines[index], event.ShiftDown() ); |
51cc4dad | 2231 | } |
51cc4dad RR |
2232 | break; |
2233 | } | |
2234 | case WXK_NEXT: | |
2235 | { | |
2236 | int steps = 0; | |
f6bcfd97 | 2237 | int index = m_lines.Index(*m_current); |
004fd0c8 | 2238 | if (m_mode & wxLC_REPORT) |
bffa1c77 VZ |
2239 | { |
2240 | steps = m_visibleLines-1; | |
2241 | } | |
51cc4dad RR |
2242 | else |
2243 | { | |
f6bcfd97 BP |
2244 | steps = m_visibleLines-(index % m_visibleLines)-1; |
2245 | } | |
2246 | ||
2247 | if (index != wxNOT_FOUND) | |
2248 | { | |
2249 | index += steps; | |
3e1c4e00 | 2250 | if ((size_t)index >= m_lines.GetCount()) |
f6bcfd97 BP |
2251 | index = m_lines.GetCount()-1; |
2252 | OnArrowChar( &m_lines[index], event.ShiftDown() ); | |
51cc4dad | 2253 | } |
51cc4dad RR |
2254 | break; |
2255 | } | |
2256 | case WXK_LEFT: | |
2257 | { | |
2258 | if (!(m_mode & wxLC_REPORT)) | |
2259 | { | |
f6bcfd97 BP |
2260 | int index = m_lines.Index(*m_current); |
2261 | if (index != wxNOT_FOUND) | |
2262 | { | |
2263 | index -= m_visibleLines; | |
2264 | if (index < 0) index = 0; | |
2265 | OnArrowChar( &m_lines[index], event.ShiftDown() ); | |
2266 | } | |
51cc4dad RR |
2267 | } |
2268 | break; | |
2269 | } | |
2270 | case WXK_RIGHT: | |
2271 | { | |
2272 | if (!(m_mode & wxLC_REPORT)) | |
2273 | { | |
f6bcfd97 BP |
2274 | int index = m_lines.Index(*m_current); |
2275 | if (index != wxNOT_FOUND) | |
2276 | { | |
2277 | index += m_visibleLines; | |
3e1c4e00 | 2278 | if ((size_t)index >= m_lines.GetCount()) |
f6bcfd97 BP |
2279 | index = m_lines.GetCount()-1; |
2280 | OnArrowChar( &m_lines[index], event.ShiftDown() ); | |
2281 | } | |
51cc4dad RR |
2282 | } |
2283 | break; | |
2284 | } | |
2285 | case WXK_SPACE: | |
2286 | { | |
33d0e17c RR |
2287 | if (m_mode & wxLC_SINGLE_SEL) |
2288 | { | |
2289 | wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() ); | |
2290 | le.SetEventObject( GetParent() ); | |
2291 | le.m_itemIndex = GetIndexOfLine( m_current ); | |
2292 | m_current->GetItem( 0, le.m_item ); | |
2293 | GetParent()->GetEventHandler()->ProcessEvent( le ); | |
2294 | } | |
2295 | else | |
2296 | { | |
2297 | m_current->ReverseHilight(); | |
2298 | RefreshLine( m_current ); | |
2299 | } | |
51cc4dad RR |
2300 | break; |
2301 | } | |
2302 | case WXK_INSERT: | |
2303 | { | |
2304 | if (!(m_mode & wxLC_SINGLE_SEL)) | |
2305 | { | |
2306 | wxListLineData *oldCurrent = m_current; | |
2307 | m_current->ReverseHilight(); | |
f6bcfd97 BP |
2308 | int index = m_lines.Index( *m_current ) + 1; |
2309 | if ( (size_t)index < m_lines.GetCount() ) | |
2310 | m_current = &m_lines[index]; | |
51cc4dad RR |
2311 | RefreshLine( oldCurrent ); |
2312 | RefreshLine( m_current ); | |
2313 | UnfocusLine( oldCurrent ); | |
2314 | FocusLine( m_current ); | |
cf3da716 | 2315 | MoveToFocus(); |
51cc4dad RR |
2316 | } |
2317 | break; | |
2318 | } | |
2319 | case WXK_RETURN: | |
2320 | case WXK_EXECUTE: | |
2321 | { | |
2322 | wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() ); | |
2323 | le.SetEventObject( GetParent() ); | |
2324 | le.m_itemIndex = GetIndexOfLine( m_current ); | |
2325 | m_current->GetItem( 0, le.m_item ); | |
2326 | GetParent()->GetEventHandler()->ProcessEvent( le ); | |
2327 | break; | |
2328 | } | |
2329 | default: | |
2330 | { | |
2331 | event.Skip(); | |
2332 | return; | |
2333 | } | |
e1e955e1 | 2334 | } |
51cc4dad | 2335 | m_usedKeys = TRUE; |
e1e955e1 | 2336 | } |
c801d85f | 2337 | |
cae5359f RR |
2338 | #ifdef __WXGTK__ |
2339 | extern wxWindow *g_focusWindow; | |
2340 | #endif | |
2341 | ||
c801d85f KB |
2342 | void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) ) |
2343 | { | |
63852e78 RR |
2344 | m_hasFocus = TRUE; |
2345 | RefreshLine( m_current ); | |
bd8289c1 | 2346 | |
63852e78 | 2347 | if (!GetParent()) return; |
004fd0c8 | 2348 | |
cae5359f RR |
2349 | #ifdef __WXGTK__ |
2350 | g_focusWindow = GetParent(); | |
2351 | #endif | |
bd8289c1 | 2352 | |
63852e78 RR |
2353 | wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() ); |
2354 | event.SetEventObject( GetParent() ); | |
2355 | GetParent()->GetEventHandler()->ProcessEvent( event ); | |
e1e955e1 | 2356 | } |
c801d85f KB |
2357 | |
2358 | void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) ) | |
2359 | { | |
63852e78 RR |
2360 | m_hasFocus = FALSE; |
2361 | RefreshLine( m_current ); | |
e1e955e1 | 2362 | } |
c801d85f KB |
2363 | |
2364 | void wxListMainWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) | |
2365 | { | |
2366 | /* | |
2367 | We don't even allow the wxScrolledWindow::AdjustScrollbars() call | |
004fd0c8 | 2368 | |
c801d85f | 2369 | */ |
2035e10e | 2370 | m_dirty = TRUE; |
e1e955e1 | 2371 | } |
c801d85f | 2372 | |
1e6d9499 | 2373 | void wxListMainWindow::DrawImage( int index, wxDC *dc, int x, int y ) |
c801d85f | 2374 | { |
63852e78 RR |
2375 | if ((m_mode & wxLC_ICON) && (m_normal_image_list)) |
2376 | { | |
2377 | m_normal_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); | |
2378 | return; | |
2379 | } | |
2380 | if ((m_mode & wxLC_SMALL_ICON) && (m_small_image_list)) | |
2381 | { | |
2382 | m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); | |
2383 | } | |
0b855868 RR |
2384 | if ((m_mode & wxLC_LIST) && (m_small_image_list)) |
2385 | { | |
2386 | m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); | |
2387 | } | |
63852e78 RR |
2388 | if ((m_mode & wxLC_REPORT) && (m_small_image_list)) |
2389 | { | |
2390 | m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT ); | |
2391 | return; | |
2392 | } | |
e1e955e1 | 2393 | } |
c801d85f KB |
2394 | |
2395 | void wxListMainWindow::GetImageSize( int index, int &width, int &height ) | |
2396 | { | |
63852e78 RR |
2397 | if ((m_mode & wxLC_ICON) && (m_normal_image_list)) |
2398 | { | |
2399 | m_normal_image_list->GetSize( index, width, height ); | |
2400 | return; | |
2401 | } | |
2402 | if ((m_mode & wxLC_SMALL_ICON) && (m_small_image_list)) | |
2403 | { | |
2404 | m_small_image_list->GetSize( index, width, height ); | |
2405 | return; | |
2406 | } | |
0b855868 RR |
2407 | if ((m_mode & wxLC_LIST) && (m_small_image_list)) |
2408 | { | |
2409 | m_small_image_list->GetSize( index, width, height ); | |
2410 | return; | |
2411 | } | |
63852e78 RR |
2412 | if ((m_mode & wxLC_REPORT) && (m_small_image_list)) |
2413 | { | |
2414 | m_small_image_list->GetSize( index, width, height ); | |
2415 | return; | |
2416 | } | |
2417 | width = 0; | |
2418 | height = 0; | |
e1e955e1 | 2419 | } |
c801d85f KB |
2420 | |
2421 | int wxListMainWindow::GetTextLength( wxString &s ) | |
2422 | { | |
1e6d9499 | 2423 | wxClientDC dc( this ); |
13111b2a VZ |
2424 | wxCoord lw = 0; |
2425 | wxCoord lh = 0; | |
139adb6a RR |
2426 | dc.GetTextExtent( s, &lw, &lh ); |
2427 | return lw + 6; | |
e1e955e1 | 2428 | } |
c801d85f KB |
2429 | |
2430 | int wxListMainWindow::GetIndexOfLine( const wxListLineData *line ) | |
2431 | { | |
f6bcfd97 BP |
2432 | int i = m_lines.Index(*line); |
2433 | if (i == wxNOT_FOUND) return -1; | |
2434 | else return i; | |
e1e955e1 | 2435 | } |
c801d85f | 2436 | |
debe6624 | 2437 | void wxListMainWindow::SetImageList( wxImageList *imageList, int which ) |
c801d85f | 2438 | { |
139adb6a | 2439 | m_dirty = TRUE; |
f6bcfd97 BP |
2440 | |
2441 | // calc the spacing from the icon size | |
2442 | int width = 0, | |
2443 | height = 0; | |
2444 | if ((imageList) && (imageList->GetImageCount()) ) | |
2445 | { | |
2446 | imageList->GetSize(0, width, height); | |
2447 | } | |
2448 | ||
2449 | if (which == wxIMAGE_LIST_NORMAL) | |
2450 | { | |
2451 | m_normal_image_list = imageList; | |
2452 | m_normal_spacing = width + 8; | |
2453 | } | |
2454 | ||
2455 | if (which == wxIMAGE_LIST_SMALL) | |
2456 | { | |
2457 | m_small_image_list = imageList; | |
2458 | m_small_spacing = width + 14; | |
2459 | } | |
e1e955e1 | 2460 | } |
c801d85f | 2461 | |
debe6624 | 2462 | void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall ) |
c801d85f | 2463 | { |
139adb6a RR |
2464 | m_dirty = TRUE; |
2465 | if (isSmall) | |
2466 | { | |
2467 | m_small_spacing = spacing; | |
2468 | } | |
2469 | else | |
2470 | { | |
2471 | m_normal_spacing = spacing; | |
2472 | } | |
e1e955e1 | 2473 | } |
c801d85f | 2474 | |
debe6624 | 2475 | int wxListMainWindow::GetItemSpacing( bool isSmall ) |
c801d85f | 2476 | { |
f6bcfd97 | 2477 | return isSmall ? m_small_spacing : m_normal_spacing; |
e1e955e1 | 2478 | } |
c801d85f | 2479 | |
debe6624 | 2480 | void wxListMainWindow::SetColumn( int col, wxListItem &item ) |
c801d85f | 2481 | { |
63852e78 RR |
2482 | m_dirty = TRUE; |
2483 | wxNode *node = m_columns.Nth( col ); | |
2484 | if (node) | |
2485 | { | |
2486 | if (item.m_width == wxLIST_AUTOSIZE_USEHEADER) item.m_width = GetTextLength( item.m_text )+7; | |
2487 | wxListHeaderData *column = (wxListHeaderData*)node->Data(); | |
2488 | column->SetItem( item ); | |
2489 | } | |
f6bcfd97 BP |
2490 | |
2491 | wxListHeaderWindow *headerWin = ((wxListCtrl*) GetParent())->m_headerWin; | |
2492 | if ( headerWin ) | |
2493 | headerWin->m_dirty = TRUE; | |
e1e955e1 | 2494 | } |
c801d85f | 2495 | |
debe6624 | 2496 | void wxListMainWindow::SetColumnWidth( int col, int width ) |
c801d85f | 2497 | { |
f6bcfd97 BP |
2498 | wxCHECK_RET( m_mode & wxLC_REPORT, |
2499 | _T("SetColumnWidth() can only be called in report mode.") ); | |
0208334d | 2500 | |
63852e78 | 2501 | m_dirty = TRUE; |
bd8289c1 | 2502 | |
0180dad6 RR |
2503 | wxNode *node = (wxNode*) NULL; |
2504 | ||
f6bcfd97 BP |
2505 | if (width == wxLIST_AUTOSIZE_USEHEADER) |
2506 | { | |
2507 | // TODO do use the header | |
2508 | width = 80; | |
2509 | } | |
2510 | else if (width == wxLIST_AUTOSIZE) | |
0180dad6 RR |
2511 | { |
2512 | wxClientDC dc(this); | |
2513 | dc.SetFont( GetFont() ); | |
2514 | int max = 10; | |
3e1c4e00 | 2515 | |
f6bcfd97 | 2516 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
0180dad6 | 2517 | { |
f6bcfd97 | 2518 | wxListLineData *line = &m_lines[i]; |
0180dad6 RR |
2519 | wxNode *n = line->m_items.Nth( col ); |
2520 | if (n) | |
2521 | { | |
2522 | wxListItemData *item = (wxListItemData*)n->Data(); | |
bffa1c77 | 2523 | int current = 0, ix = 0, iy = 0; |
13111b2a | 2524 | wxCoord lx = 0, ly = 0; |
bffa1c77 VZ |
2525 | if (item->HasImage()) |
2526 | { | |
0180dad6 | 2527 | GetImageSize( item->GetImage(), ix, iy ); |
bffa1c77 VZ |
2528 | current = ix + 5; |
2529 | } | |
2530 | if (item->HasText()) | |
2531 | { | |
2532 | wxString str; | |
2533 | item->GetText( str ); | |
2534 | dc.GetTextExtent( str, &lx, &ly ); | |
2535 | current += lx; | |
2536 | } | |
2537 | if (current > max) max = current; | |
0180dad6 | 2538 | } |
0180dad6 | 2539 | } |
bffa1c77 | 2540 | width = max+10; |
0180dad6 RR |
2541 | } |
2542 | ||
2543 | node = m_columns.Nth( col ); | |
63852e78 RR |
2544 | if (node) |
2545 | { | |
2546 | wxListHeaderData *column = (wxListHeaderData*)node->Data(); | |
2547 | column->SetWidth( width ); | |
2548 | } | |
bd8289c1 | 2549 | |
f6bcfd97 | 2550 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
0208334d | 2551 | { |
f6bcfd97 | 2552 | wxListLineData *line = &m_lines[i]; |
63852e78 RR |
2553 | wxNode *n = line->m_items.Nth( col ); |
2554 | if (n) | |
2555 | { | |
2556 | wxListItemData *item = (wxListItemData*)n->Data(); | |
2557 | item->SetSize( width, -1 ); | |
2558 | } | |
0208334d | 2559 | } |
bd8289c1 | 2560 | |
f6bcfd97 BP |
2561 | wxListHeaderWindow *headerWin = ((wxListCtrl*) GetParent())->m_headerWin; |
2562 | if ( headerWin ) | |
2563 | headerWin->m_dirty = TRUE; | |
e1e955e1 | 2564 | } |
c801d85f | 2565 | |
debe6624 | 2566 | void wxListMainWindow::GetColumn( int col, wxListItem &item ) |
c801d85f | 2567 | { |
63852e78 RR |
2568 | wxNode *node = m_columns.Nth( col ); |
2569 | if (node) | |
2570 | { | |
2571 | wxListHeaderData *column = (wxListHeaderData*)node->Data(); | |
2572 | column->GetItem( item ); | |
2573 | } | |
2574 | else | |
2575 | { | |
2576 | item.m_format = 0; | |
2577 | item.m_width = 0; | |
2578 | item.m_text = ""; | |
2579 | item.m_image = 0; | |
2580 | item.m_data = 0; | |
2581 | } | |
e1e955e1 | 2582 | } |
c801d85f | 2583 | |
bd8289c1 | 2584 | int wxListMainWindow::GetColumnWidth( int col ) |
c801d85f | 2585 | { |
92976ab6 RR |
2586 | wxNode *node = m_columns.Nth( col ); |
2587 | if (node) | |
2588 | { | |
2589 | wxListHeaderData *column = (wxListHeaderData*)node->Data(); | |
2590 | return column->GetWidth(); | |
2591 | } | |
2592 | else | |
2593 | { | |
004fd0c8 | 2594 | return 0; |
92976ab6 | 2595 | } |
e1e955e1 | 2596 | } |
c801d85f | 2597 | |
e179bd65 | 2598 | int wxListMainWindow::GetColumnCount() |
c801d85f | 2599 | { |
92976ab6 | 2600 | return m_columns.Number(); |
e1e955e1 | 2601 | } |
c801d85f | 2602 | |
e179bd65 | 2603 | int wxListMainWindow::GetCountPerPage() |
c801d85f | 2604 | { |
92976ab6 | 2605 | return m_visibleLines; |
e1e955e1 | 2606 | } |
c801d85f KB |
2607 | |
2608 | void wxListMainWindow::SetItem( wxListItem &item ) | |
2609 | { | |
92976ab6 | 2610 | m_dirty = TRUE; |
f6bcfd97 | 2611 | if (item.m_itemId >= 0 && (size_t)item.m_itemId < m_lines.GetCount()) |
92976ab6 | 2612 | { |
f6bcfd97 | 2613 | wxListLineData *line = &m_lines[(size_t)item.m_itemId]; |
92976ab6 RR |
2614 | if (m_mode & wxLC_REPORT) item.m_width = GetColumnWidth( item.m_col )-3; |
2615 | line->SetItem( item.m_col, item ); | |
2616 | } | |
e1e955e1 | 2617 | } |
c801d85f | 2618 | |
debe6624 | 2619 | void wxListMainWindow::SetItemState( long item, long state, long stateMask ) |
c801d85f | 2620 | { |
92976ab6 | 2621 | // m_dirty = TRUE; no recalcs needed |
bd8289c1 | 2622 | |
92976ab6 | 2623 | wxListLineData *oldCurrent = m_current; |
bd8289c1 | 2624 | |
92976ab6 | 2625 | if (stateMask & wxLIST_STATE_FOCUSED) |
c801d85f | 2626 | { |
f6bcfd97 | 2627 | if (item >= 0 && (size_t)item < m_lines.GetCount()) |
92976ab6 | 2628 | { |
f6bcfd97 | 2629 | wxListLineData *line = &m_lines[(size_t)item]; |
92976ab6 RR |
2630 | UnfocusLine( m_current ); |
2631 | m_current = line; | |
2632 | FocusLine( m_current ); | |
4aefa363 | 2633 | if ((m_mode & wxLC_SINGLE_SEL) && oldCurrent) oldCurrent->Hilight( FALSE ); |
92976ab6 | 2634 | RefreshLine( m_current ); |
00a39542 | 2635 | if (oldCurrent) RefreshLine( oldCurrent ); |
92976ab6 | 2636 | } |
e1e955e1 | 2637 | } |
bd8289c1 | 2638 | |
92976ab6 | 2639 | if (stateMask & wxLIST_STATE_SELECTED) |
c801d85f | 2640 | { |
6f2a55e3 | 2641 | bool on = (state & wxLIST_STATE_SELECTED) != 0; |
92976ab6 RR |
2642 | if (!on && (m_mode & wxLC_SINGLE_SEL)) return; |
2643 | ||
f6bcfd97 | 2644 | if (item >= 0 && (size_t)item < m_lines.GetCount()) |
92976ab6 | 2645 | { |
f6bcfd97 | 2646 | wxListLineData *line = &m_lines[(size_t)item]; |
92976ab6 RR |
2647 | if (m_mode & wxLC_SINGLE_SEL) |
2648 | { | |
2649 | UnfocusLine( m_current ); | |
2650 | m_current = line; | |
2651 | FocusLine( m_current ); | |
00a39542 | 2652 | if (oldCurrent) oldCurrent->Hilight( FALSE ); |
92976ab6 | 2653 | RefreshLine( m_current ); |
00a39542 | 2654 | if (oldCurrent) RefreshLine( oldCurrent ); |
92976ab6 | 2655 | } |
6f2a55e3 | 2656 | bool on = (state & wxLIST_STATE_SELECTED) != 0; |
bffa1c77 VZ |
2657 | if (on != line->IsHilighted()) |
2658 | { | |
139adb6a RR |
2659 | line->Hilight( on ); |
2660 | RefreshLine( line ); | |
bffa1c77 | 2661 | } |
92976ab6 | 2662 | } |
e1e955e1 | 2663 | } |
e1e955e1 | 2664 | } |
c801d85f | 2665 | |
debe6624 | 2666 | int wxListMainWindow::GetItemState( long item, long stateMask ) |
c801d85f | 2667 | { |
92976ab6 RR |
2668 | int ret = wxLIST_STATE_DONTCARE; |
2669 | if (stateMask & wxLIST_STATE_FOCUSED) | |
c801d85f | 2670 | { |
f6bcfd97 | 2671 | if (item >= 0 && (size_t)item < m_lines.GetCount()) |
92976ab6 | 2672 | { |
f6bcfd97 | 2673 | wxListLineData *line = &m_lines[(size_t)item]; |
92976ab6 RR |
2674 | if (line == m_current) ret |= wxLIST_STATE_FOCUSED; |
2675 | } | |
e1e955e1 | 2676 | } |
92976ab6 | 2677 | if (stateMask & wxLIST_STATE_SELECTED) |
c801d85f | 2678 | { |
f6bcfd97 | 2679 | if (item >= 0 && (size_t)item < m_lines.GetCount()) |
92976ab6 | 2680 | { |
f6bcfd97 | 2681 | wxListLineData *line = &m_lines[(size_t)item]; |
c9c1c60f | 2682 | if (line->IsHilighted()) ret |= wxLIST_STATE_SELECTED; |
92976ab6 | 2683 | } |
e1e955e1 | 2684 | } |
92976ab6 | 2685 | return ret; |
e1e955e1 | 2686 | } |
c801d85f KB |
2687 | |
2688 | void wxListMainWindow::GetItem( wxListItem &item ) | |
2689 | { | |
f6bcfd97 | 2690 | if (item.m_itemId >= 0 && (size_t)item.m_itemId < m_lines.GetCount()) |
92976ab6 | 2691 | { |
f6bcfd97 | 2692 | wxListLineData *line = &m_lines[(size_t)item.m_itemId]; |
92976ab6 RR |
2693 | line->GetItem( item.m_col, item ); |
2694 | } | |
2695 | else | |
2696 | { | |
2697 | item.m_mask = 0; | |
2698 | item.m_text = ""; | |
2699 | item.m_image = 0; | |
2700 | item.m_data = 0; | |
2701 | } | |
e1e955e1 | 2702 | } |
c801d85f | 2703 | |
e179bd65 | 2704 | int wxListMainWindow::GetItemCount() |
c801d85f | 2705 | { |
f6bcfd97 | 2706 | return m_lines.GetCount(); |
e1e955e1 | 2707 | } |
c801d85f | 2708 | |
0a240683 | 2709 | void wxListMainWindow::GetItemRect( long index, wxRect &rect ) |
c801d85f | 2710 | { |
f6bcfd97 | 2711 | if (index >= 0 && (size_t)index < m_lines.GetCount()) |
92976ab6 | 2712 | { |
f6bcfd97 | 2713 | m_lines[(size_t)index].GetRect( rect ); |
ea5ac909 | 2714 | this->CalcScrolledPosition(rect.x,rect.y,&rect.x,&rect.y); |
92976ab6 RR |
2715 | } |
2716 | else | |
2717 | { | |
2718 | rect.x = 0; | |
2719 | rect.y = 0; | |
2720 | rect.width = 0; | |
2721 | rect.height = 0; | |
2722 | } | |
e1e955e1 | 2723 | } |
c801d85f | 2724 | |
e3e65dac RR |
2725 | bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) |
2726 | { | |
ea5ac909 VZ |
2727 | wxRect rect; |
2728 | this->GetItemRect(item,rect); | |
2729 | pos.x=rect.x; pos.y=rect.y; | |
92976ab6 | 2730 | return TRUE; |
e1e955e1 | 2731 | } |
e3e65dac | 2732 | |
e179bd65 | 2733 | int wxListMainWindow::GetSelectedItemCount() |
c801d85f | 2734 | { |
92976ab6 | 2735 | int ret = 0; |
f6bcfd97 | 2736 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
92976ab6 | 2737 | { |
f6bcfd97 | 2738 | if (m_lines[i].IsHilighted()) ret++; |
92976ab6 RR |
2739 | } |
2740 | return ret; | |
e1e955e1 | 2741 | } |
c801d85f | 2742 | |
debe6624 | 2743 | void wxListMainWindow::SetMode( long mode ) |
c801d85f | 2744 | { |
92976ab6 RR |
2745 | m_dirty = TRUE; |
2746 | m_mode = mode; | |
bd8289c1 | 2747 | |
92976ab6 | 2748 | DeleteEverything(); |
bd8289c1 | 2749 | |
92976ab6 RR |
2750 | if (m_mode & wxLC_REPORT) |
2751 | { | |
7c74e7fe SC |
2752 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
2753 | m_xScroll = 15; | |
2754 | #else | |
92976ab6 | 2755 | m_xScroll = 0; |
7c74e7fe | 2756 | #endif |
92976ab6 RR |
2757 | m_yScroll = 15; |
2758 | } | |
2759 | else | |
2760 | { | |
2761 | m_xScroll = 15; | |
2762 | m_yScroll = 0; | |
2763 | } | |
e1e955e1 | 2764 | } |
c801d85f | 2765 | |
e179bd65 | 2766 | long wxListMainWindow::GetMode() const |
c801d85f | 2767 | { |
63852e78 | 2768 | return m_mode; |
e1e955e1 | 2769 | } |
c801d85f | 2770 | |
e179bd65 | 2771 | void wxListMainWindow::CalculatePositions() |
c801d85f | 2772 | { |
f6bcfd97 | 2773 | if (m_lines.IsEmpty()) return; |
e487524e | 2774 | |
1e6d9499 | 2775 | wxClientDC dc( this ); |
92976ab6 | 2776 | dc.SetFont( GetFont() ); |
c801d85f | 2777 | |
92976ab6 RR |
2778 | int iconSpacing = 0; |
2779 | if (m_mode & wxLC_ICON) iconSpacing = m_normal_spacing; | |
2780 | if (m_mode & wxLC_SMALL_ICON) iconSpacing = m_small_spacing; | |
004fd0c8 | 2781 | |
92976ab6 RR |
2782 | // we take the first line (which also can be an icon or |
2783 | // an a text item in wxLC_ICON and wxLC_LIST modes) to | |
2784 | // measure the size of the line | |
004fd0c8 | 2785 | |
92976ab6 RR |
2786 | int lineWidth = 0; |
2787 | int lineHeight = 0; | |
2788 | int lineSpacing = 0; | |
c801d85f | 2789 | |
f6bcfd97 | 2790 | wxListLineData *line = &m_lines[0]; |
92976ab6 RR |
2791 | line->CalculateSize( &dc, iconSpacing ); |
2792 | int dummy = 0; | |
2793 | line->GetSize( dummy, lineSpacing ); | |
5d25c050 | 2794 | lineSpacing += 1; |
bd8289c1 | 2795 | |
92976ab6 RR |
2796 | int clientWidth = 0; |
2797 | int clientHeight = 0; | |
bd8289c1 | 2798 | |
92976ab6 | 2799 | if (m_mode & wxLC_REPORT) |
c801d85f | 2800 | { |
08bf1d5d RR |
2801 | // scroll one line per step |
2802 | m_yScroll = lineSpacing; | |
2803 | ||
92976ab6 RR |
2804 | int x = 4; |
2805 | int y = 1; | |
f6bcfd97 | 2806 | int entireHeight = m_lines.GetCount() * lineSpacing + 2; |
92976ab6 | 2807 | int scroll_pos = GetScrollPos( wxVERTICAL ); |
7c74e7fe | 2808 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
7c0ea335 | 2809 | int x_scroll_pos = GetScrollPos( wxHORIZONTAL ); |
7c74e7fe | 2810 | #else |
08bf1d5d | 2811 | SetScrollbars( m_xScroll, m_yScroll, 0, entireHeight/m_yScroll +1, 0, scroll_pos, TRUE ); |
7c74e7fe | 2812 | #endif |
92976ab6 RR |
2813 | GetClientSize( &clientWidth, &clientHeight ); |
2814 | ||
7c74e7fe | 2815 | int entireWidth = 0 ; |
f6bcfd97 | 2816 | for (size_t j = 0; j < m_lines.GetCount(); j++) |
92976ab6 | 2817 | { |
f6bcfd97 | 2818 | wxListLineData *line = &m_lines[j]; |
92976ab6 RR |
2819 | line->CalculateSize( &dc, iconSpacing ); |
2820 | line->SetPosition( &dc, x, y, clientWidth ); | |
2821 | int col_x = 2; | |
2822 | for (int i = 0; i < GetColumnCount(); i++) | |
2823 | { | |
2824 | line->SetColumnPosition( i, col_x ); | |
2825 | col_x += GetColumnWidth( i ); | |
2826 | } | |
7c74e7fe SC |
2827 | entireWidth = wxMax( entireWidth , col_x ) ; |
2828 | #if wxUSE_GENERIC_LIST_EXTENSIONS | |
2829 | line->SetPosition( &dc, x, y, col_x ); | |
2830 | #endif | |
92976ab6 | 2831 | y += lineSpacing; // one pixel blank line between items |
92976ab6 | 2832 | } |
08bf1d5d | 2833 | m_visibleLines = clientHeight / lineSpacing; |
7c74e7fe | 2834 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
08bf1d5d | 2835 | SetScrollbars( m_xScroll, m_yScroll, entireWidth/m_xScroll +1, entireHeight/m_yScroll +1, x_scroll_pos , scroll_pos, TRUE ); |
7c74e7fe | 2836 | #endif |
e1e955e1 | 2837 | } |
92976ab6 RR |
2838 | else |
2839 | { | |
2840 | // at first we try without any scrollbar. if the items don't | |
2841 | // fit into the window, we recalculate after subtracting an | |
2842 | // approximated 15 pt for the horizontal scrollbar | |
004fd0c8 | 2843 | |
92976ab6 | 2844 | GetSize( &clientWidth, &clientHeight ); |
bffa1c77 | 2845 | clientHeight -= 4; // sunken frame |
bd8289c1 | 2846 | |
92976ab6 | 2847 | int entireWidth = 0; |
bd8289c1 | 2848 | |
92976ab6 | 2849 | for (int tries = 0; tries < 2; tries++) |
e487524e | 2850 | { |
92976ab6 | 2851 | entireWidth = 0; |
5d25c050 RR |
2852 | int x = 2; |
2853 | int y = 2; | |
92976ab6 | 2854 | int maxWidth = 0; |
0b855868 | 2855 | m_visibleLines = 0; |
bffa1c77 | 2856 | int m_currentVisibleLines = 0; |
f6bcfd97 | 2857 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
92976ab6 | 2858 | { |
bffa1c77 | 2859 | m_currentVisibleLines++; |
f6bcfd97 | 2860 | wxListLineData *line = &m_lines[i]; |
92976ab6 RR |
2861 | line->CalculateSize( &dc, iconSpacing ); |
2862 | line->SetPosition( &dc, x, y, clientWidth ); | |
2863 | line->GetSize( lineWidth, lineHeight ); | |
2864 | if (lineWidth > maxWidth) maxWidth = lineWidth; | |
2865 | y += lineSpacing; | |
bffa1c77 VZ |
2866 | if (m_currentVisibleLines > m_visibleLines) |
2867 | m_visibleLines = m_currentVisibleLines; | |
8b53e5a2 | 2868 | if (y+lineSpacing-6 >= clientHeight) // -6 for earlier "line breaking" |
92976ab6 | 2869 | { |
bffa1c77 | 2870 | m_currentVisibleLines = 0; |
e1208c31 | 2871 | y = 2; |
8b53e5a2 RR |
2872 | x += maxWidth+6; |
2873 | entireWidth += maxWidth+6; | |
92976ab6 RR |
2874 | maxWidth = 0; |
2875 | } | |
f6bcfd97 | 2876 | if (i == m_lines.GetCount()-1) entireWidth += maxWidth; |
92976ab6 RR |
2877 | if ((tries == 0) && (entireWidth > clientWidth)) |
2878 | { | |
2879 | clientHeight -= 15; // scrollbar height | |
0b855868 | 2880 | m_visibleLines = 0; |
bffa1c77 | 2881 | m_currentVisibleLines = 0; |
92976ab6 RR |
2882 | break; |
2883 | } | |
f6bcfd97 | 2884 | if (i == m_lines.GetCount()-1) tries = 1; // everything fits, no second try required |
92976ab6 | 2885 | } |
e487524e | 2886 | } |
bffa1c77 | 2887 | |
92976ab6 RR |
2888 | int scroll_pos = GetScrollPos( wxHORIZONTAL ); |
2889 | SetScrollbars( m_xScroll, m_yScroll, (entireWidth+15) / m_xScroll, 0, scroll_pos, 0, TRUE ); | |
e1e955e1 | 2890 | } |
e1e955e1 | 2891 | } |
c801d85f | 2892 | |
f6bcfd97 | 2893 | void wxListMainWindow::RealizeChanges() |
c801d85f | 2894 | { |
92976ab6 RR |
2895 | if (!m_current) |
2896 | { | |
f6bcfd97 BP |
2897 | if (!m_lines.IsEmpty()) |
2898 | m_current = &m_lines[0]; | |
92976ab6 RR |
2899 | } |
2900 | if (m_current) | |
2901 | { | |
2902 | FocusLine( m_current ); | |
f6bcfd97 BP |
2903 | // TODO: MSW doesn't automatically hilight the |
2904 | // first item. | |
2905 | // if (m_mode & wxLC_SINGLE_SEL) m_current->Hilight( TRUE ); | |
92976ab6 | 2906 | } |
e1e955e1 | 2907 | } |
c801d85f | 2908 | |
19695fbd VZ |
2909 | long wxListMainWindow::GetNextItem( long item, |
2910 | int WXUNUSED(geometry), | |
2911 | int state ) | |
c801d85f | 2912 | { |
d1022fd6 VZ |
2913 | long ret = item, |
2914 | max = GetItemCount(); | |
2915 | wxCHECK_MSG( (ret == -1) || (ret < max), -1, | |
13771c08 | 2916 | _T("invalid listctrl index in GetNextItem()") ); |
19695fbd VZ |
2917 | |
2918 | // notice that we start with the next item (or the first one if item == -1) | |
2919 | // and this is intentional to allow writing a simple loop to iterate over | |
2920 | // all selected items | |
d1022fd6 VZ |
2921 | ret++; |
2922 | if ( ret == max ) | |
2923 | { | |
2924 | // this is not an error because the index was ok initially, just no | |
2925 | // such item | |
2926 | return -1; | |
2927 | } | |
2928 | ||
f6bcfd97 | 2929 | for (size_t i = (size_t)ret; i < m_lines.GetCount(); i++) |
63852e78 | 2930 | { |
f6bcfd97 | 2931 | wxListLineData *line = &m_lines[i]; |
19695fbd VZ |
2932 | if ((state & wxLIST_STATE_FOCUSED) && (line == m_current)) |
2933 | return ret; | |
2934 | if ((state & wxLIST_STATE_SELECTED) && (line->IsHilighted())) | |
2935 | return ret; | |
2936 | if (!state) | |
2937 | return ret; | |
63852e78 | 2938 | ret++; |
63852e78 | 2939 | } |
19695fbd | 2940 | |
63852e78 | 2941 | return -1; |
e1e955e1 | 2942 | } |
c801d85f | 2943 | |
debe6624 | 2944 | void wxListMainWindow::DeleteItem( long index ) |
c801d85f | 2945 | { |
63852e78 | 2946 | m_dirty = TRUE; |
f6bcfd97 | 2947 | if (index >= 0 && (size_t)index < m_lines.GetCount()) |
63852e78 | 2948 | { |
f6bcfd97 | 2949 | wxListLineData *line = &m_lines[(size_t)index]; |
63852e78 RR |
2950 | if (m_current == line) m_current = (wxListLineData *) NULL; |
2951 | DeleteLine( line ); | |
f6bcfd97 | 2952 | m_lines.RemoveAt( (size_t)index ); |
63852e78 | 2953 | } |
e1e955e1 | 2954 | } |
c801d85f | 2955 | |
debe6624 | 2956 | void wxListMainWindow::DeleteColumn( int col ) |
c801d85f | 2957 | { |
5b077d48 | 2958 | wxCHECK_RET( col < (int)m_columns.GetCount(), |
223d09f6 | 2959 | wxT("attempting to delete inexistent column in wxListView") ); |
bd8289c1 | 2960 | |
5b077d48 RR |
2961 | m_dirty = TRUE; |
2962 | wxNode *node = m_columns.Nth( col ); | |
2963 | if (node) m_columns.DeleteNode( node ); | |
e1e955e1 | 2964 | } |
c801d85f | 2965 | |
12c1b46a | 2966 | void wxListMainWindow::DeleteAllItems() |
c801d85f | 2967 | { |
5b077d48 RR |
2968 | m_dirty = TRUE; |
2969 | m_current = (wxListLineData *) NULL; | |
7c0ea335 VZ |
2970 | |
2971 | // to make the deletion of all items faster, we don't send the | |
2972 | // notifications in this case: this is compatible with wxMSW and | |
2973 | // documented in DeleteAllItems() description | |
bffa1c77 | 2974 | |
12c1b46a RR |
2975 | wxListEvent event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, GetParent()->GetId() ); |
2976 | event.SetEventObject( GetParent() ); | |
2977 | GetParent()->GetEventHandler()->ProcessEvent( event ); | |
7c0ea335 | 2978 | |
5b077d48 | 2979 | m_lines.Clear(); |
e1e955e1 | 2980 | } |
c801d85f | 2981 | |
12c1b46a | 2982 | void wxListMainWindow::DeleteEverything() |
c801d85f | 2983 | { |
12c1b46a | 2984 | DeleteAllItems(); |
f6bcfd97 | 2985 | |
5b077d48 | 2986 | m_columns.Clear(); |
e1e955e1 | 2987 | } |
c801d85f | 2988 | |
debe6624 | 2989 | void wxListMainWindow::EnsureVisible( long index ) |
c801d85f | 2990 | { |
dc6c62a9 RR |
2991 | // We have to call this here because the label in |
2992 | // question might just have been added and no screen | |
2993 | // update taken place. | |
2994 | if (m_dirty) wxYield(); | |
2995 | ||
5b077d48 RR |
2996 | wxListLineData *oldCurrent = m_current; |
2997 | m_current = (wxListLineData *) NULL; | |
f6bcfd97 BP |
2998 | if (index >= 0 && (size_t)index < m_lines.GetCount()) |
2999 | m_current = &m_lines[(size_t)index]; | |
5b077d48 RR |
3000 | if (m_current) MoveToFocus(); |
3001 | m_current = oldCurrent; | |
e1e955e1 | 3002 | } |
c801d85f | 3003 | |
debe6624 | 3004 | long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(partial) ) |
c801d85f | 3005 | { |
5b077d48 RR |
3006 | long pos = start; |
3007 | wxString tmp = str; | |
3008 | if (pos < 0) pos = 0; | |
3ca6a5f0 | 3009 | for (size_t i = (size_t)pos; i < m_lines.GetCount(); i++) |
5b077d48 | 3010 | { |
f6bcfd97 | 3011 | wxListLineData *line = &m_lines[i]; |
5b077d48 RR |
3012 | wxString s = ""; |
3013 | line->GetText( 0, s ); | |
3014 | if (s == tmp) return pos; | |
5b077d48 RR |
3015 | pos++; |
3016 | } | |
3017 | return -1; | |
e1e955e1 | 3018 | } |
c801d85f | 3019 | |
debe6624 | 3020 | long wxListMainWindow::FindItem(long start, long data) |
c801d85f | 3021 | { |
5b077d48 RR |
3022 | long pos = start; |
3023 | if (pos < 0) pos = 0; | |
3ca6a5f0 | 3024 | for (size_t i = (size_t)pos; i < m_lines.GetCount(); i++) |
5b077d48 | 3025 | { |
f6bcfd97 | 3026 | wxListLineData *line = &m_lines[i]; |
5b077d48 RR |
3027 | wxListItem item; |
3028 | line->GetItem( 0, item ); | |
3029 | if (item.m_data == data) return pos; | |
5b077d48 RR |
3030 | pos++; |
3031 | } | |
3032 | return -1; | |
e1e955e1 | 3033 | } |
c801d85f | 3034 | |
debe6624 | 3035 | long wxListMainWindow::HitTest( int x, int y, int &flags ) |
c801d85f | 3036 | { |
aaef15bf | 3037 | CalcUnscrolledPosition( x, y, &x, &y ); |
e8741cca | 3038 | |
5b077d48 | 3039 | int count = 0; |
f6bcfd97 | 3040 | for (size_t i = 0; i < m_lines.GetCount(); i++) |
c801d85f | 3041 | { |
f6bcfd97 | 3042 | wxListLineData *line = &m_lines[i]; |
aaef15bf | 3043 | long ret = line->IsHit( x, y ); |
191ebf4d | 3044 | if (ret) // & flags) // No: flags is output-only so may be garbage at this point |
5b077d48 | 3045 | { |
6f2a55e3 | 3046 | flags = (int)ret; |
5b077d48 RR |
3047 | return count; |
3048 | } | |
5b077d48 | 3049 | count++; |
e1e955e1 | 3050 | } |
5b077d48 | 3051 | return -1; |
e1e955e1 | 3052 | } |
c801d85f KB |
3053 | |
3054 | void wxListMainWindow::InsertItem( wxListItem &item ) | |
3055 | { | |
5b077d48 RR |
3056 | m_dirty = TRUE; |
3057 | int mode = 0; | |
3058 | if (m_mode & wxLC_REPORT) mode = wxLC_REPORT; | |
3059 | else if (m_mode & wxLC_LIST) mode = wxLC_LIST; | |
3060 | else if (m_mode & wxLC_ICON) mode = wxLC_ICON; | |
3061 | else if (m_mode & wxLC_SMALL_ICON) mode = wxLC_ICON; // no typo | |
004fd0c8 | 3062 | |
5b077d48 | 3063 | wxListLineData *line = new wxListLineData( this, mode, m_hilightBrush ); |
004fd0c8 | 3064 | |
5b077d48 RR |
3065 | if (m_mode & wxLC_REPORT) |
3066 | { | |
3067 | line->InitItems( GetColumnCount() ); | |
3068 | item.m_width = GetColumnWidth( 0 )-3; | |
3069 | } | |
3070 | else | |
3071 | { | |
3072 | line->InitItems( 1 ); | |
3073 | } | |
004fd0c8 | 3074 | |
5b077d48 | 3075 | line->SetItem( 0, item ); |
f6bcfd97 | 3076 | if ((item.m_itemId >= 0) && ((size_t)item.m_itemId < m_lines.GetCount())) |
5b077d48 | 3077 | { |
f6bcfd97 | 3078 | m_lines.Insert( line, (size_t)item.m_itemId ); |
5b077d48 RR |
3079 | } |
3080 | else | |
3081 | { | |
f6bcfd97 | 3082 | m_lines.Add( line ); |
300aaa8f | 3083 | item.m_itemId = m_lines.GetCount()-1; |
5b077d48 | 3084 | } |
e1e955e1 | 3085 | } |
c801d85f | 3086 | |
debe6624 | 3087 | void wxListMainWindow::InsertColumn( long col, wxListItem &item ) |
c801d85f | 3088 | { |
5b077d48 RR |
3089 | m_dirty = TRUE; |
3090 | if (m_mode & wxLC_REPORT) | |
3db7be80 | 3091 | { |
5b077d48 RR |
3092 | if (item.m_width == wxLIST_AUTOSIZE_USEHEADER) item.m_width = GetTextLength( item.m_text ); |
3093 | wxListHeaderData *column = new wxListHeaderData( item ); | |
3094 | if ((col >= 0) && (col < (int)m_columns.GetCount())) | |
3095 | { | |
6f2a55e3 | 3096 | wxNode *node = m_columns.Nth( (size_t)col ); |
5b077d48 RR |
3097 | if (node) |
3098 | m_columns.Insert( node, column ); | |
3099 | } | |
3100 | else | |
3101 | { | |
3102 | m_columns.Append( column ); | |
3103 | } | |
3db7be80 | 3104 | } |
e1e955e1 | 3105 | } |
c801d85f KB |
3106 | |
3107 | wxListCtrlCompare list_ctrl_compare_func_2; | |
3108 | long list_ctrl_compare_data; | |
3109 | ||
f6bcfd97 | 3110 | int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData **arg2 ) |
c801d85f | 3111 | { |
f6bcfd97 BP |
3112 | wxListLineData *line1 = *arg1; |
3113 | wxListLineData *line2 = *arg2; | |
5b077d48 RR |
3114 | wxListItem item; |
3115 | line1->GetItem( 0, item ); | |
3116 | long data1 = item.m_data; | |
3117 | line2->GetItem( 0, item ); | |
3118 | long data2 = item.m_data; | |
3119 | return list_ctrl_compare_func_2( data1, data2, list_ctrl_compare_data ); | |
e1e955e1 | 3120 | } |
c801d85f KB |
3121 | |
3122 | void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data ) | |
3123 | { | |
5b077d48 RR |
3124 | list_ctrl_compare_func_2 = fn; |
3125 | list_ctrl_compare_data = data; | |
3126 | m_lines.Sort( list_ctrl_compare_func_1 ); | |
af7c1052 | 3127 | m_dirty = TRUE; |
e1e955e1 | 3128 | } |
c801d85f | 3129 | |
7c74e7fe SC |
3130 | void wxListMainWindow::OnScroll(wxScrollWinEvent& event) |
3131 | { | |
bffa1c77 | 3132 | wxScrolledWindow::OnScroll( event ) ; |
7c74e7fe SC |
3133 | #if wxUSE_GENERIC_LIST_EXTENSIONS |
3134 | ||
3135 | if (event.GetOrientation() == wxHORIZONTAL && ( m_mode & wxLC_REPORT )) | |
3136 | { | |
bffa1c77 VZ |
3137 | wxListCtrl* lc = wxDynamicCast( GetParent() , wxListCtrl ) ; |
3138 | if ( lc ) | |
3139 | { | |
3140 | lc->m_headerWin->Refresh() ; | |
7c74e7fe | 3141 | #ifdef __WXMAC__ |
bffa1c77 | 3142 | lc->m_headerWin->MacUpdateImmediately() ; |
7c74e7fe | 3143 | #endif |
bffa1c77 | 3144 | } |
7c74e7fe SC |
3145 | } |
3146 | #endif | |
3147 | } | |
3148 | ||
c801d85f KB |
3149 | // ------------------------------------------------------------------------------------- |
3150 | // wxListItem | |
3151 | // ------------------------------------------------------------------------------------- | |
3152 | ||
3153 | IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject) | |
3154 | ||
fd9811b1 | 3155 | wxListItem::wxListItem() |
c801d85f | 3156 | { |
63852e78 RR |
3157 | m_mask = 0; |
3158 | m_itemId = 0; | |
3159 | m_col = 0; | |
3160 | m_state = 0; | |
3161 | m_stateMask = 0; | |
3162 | m_image = 0; | |
3163 | m_data = 0; | |
3164 | m_format = wxLIST_FORMAT_CENTRE; | |
3165 | m_width = 0; | |
aaa37c0d VZ |
3166 | |
3167 | m_attr = NULL; | |
c801d85f KB |
3168 | } |
3169 | ||
9b00bb16 RR |
3170 | void wxListItem::Clear() |
3171 | { | |
3172 | m_mask = 0; | |
3173 | m_itemId = 0; | |
3174 | m_col = 0; | |
3175 | m_state = 0; | |
3176 | m_stateMask = 0; | |
3177 | m_image = 0; | |
3178 | m_data = 0; | |
3179 | m_format = wxLIST_FORMAT_CENTRE; | |
3180 | m_width = 0; | |
3181 | m_text = wxEmptyString; | |
3182 | ||
3183 | if (m_attr) delete m_attr; | |
3184 | m_attr = NULL; | |
3185 | } | |
3186 | ||
3187 | void wxListItem::ClearAttributes() | |
3188 | { | |
3189 | if (m_attr) delete m_attr; | |
3190 | m_attr = NULL; | |
3191 | } | |
3192 | ||
c801d85f KB |
3193 | // ------------------------------------------------------------------------------------- |
3194 | // wxListEvent | |
3195 | // ------------------------------------------------------------------------------------- | |
3196 | ||
92976ab6 | 3197 | IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent) |
c801d85f | 3198 | |
8f79098a | 3199 | wxListEvent::wxListEvent( wxEventType commandType, int id ): |
92976ab6 | 3200 | wxNotifyEvent( commandType, id ) |
c801d85f | 3201 | { |
5b077d48 RR |
3202 | m_code = 0; |
3203 | m_itemIndex = 0; | |
3204 | m_oldItemIndex = 0; | |
3205 | m_col = 0; | |
3206 | m_cancelled = FALSE; | |
3207 | m_pointDrag.x = 0; | |
3208 | m_pointDrag.y = 0; | |
e1e955e1 | 3209 | } |
c801d85f | 3210 | |
72a7edf0 RR |
3211 | void wxListEvent::CopyObject(wxObject& object_dest) const |
3212 | { | |
3213 | wxListEvent *obj = (wxListEvent *)&object_dest; | |
3214 | ||
3215 | wxNotifyEvent::CopyObject(object_dest); | |
3216 | ||
3217 | obj->m_code = m_code; | |
3218 | obj->m_itemIndex = m_itemIndex; | |
3219 | obj->m_oldItemIndex = m_oldItemIndex; | |
3220 | obj->m_col = m_col; | |
3221 | obj->m_cancelled = m_cancelled; | |
3222 | obj->m_pointDrag = m_pointDrag; | |
3223 | obj->m_item.m_mask = m_item.m_mask; | |
3224 | obj->m_item.m_itemId = m_item.m_itemId; | |
3225 | obj->m_item.m_col = m_item.m_col; | |
3226 | obj->m_item.m_state = m_item.m_state; | |
3227 | obj->m_item.m_stateMask = m_item.m_stateMask; | |
3228 | obj->m_item.m_text = m_item.m_text; | |
3229 | obj->m_item.m_image = m_item.m_image; | |
3230 | obj->m_item.m_data = m_item.m_data; | |
3231 | obj->m_item.m_format = m_item.m_format; | |
3232 | obj->m_item.m_width = m_item.m_width; | |
aaa37c0d VZ |
3233 | |
3234 | if ( m_item.HasAttributes() ) | |
3235 | { | |
3236 | obj->m_item.SetTextColour(m_item.GetTextColour()); | |
3237 | } | |
72a7edf0 RR |
3238 | } |
3239 | ||
c801d85f KB |
3240 | // ------------------------------------------------------------------------------------- |
3241 | // wxListCtrl | |
3242 | // ------------------------------------------------------------------------------------- | |
3243 | ||
3244 | IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl) | |
3245 | ||
3246 | BEGIN_EVENT_TABLE(wxListCtrl,wxControl) | |
3247 | EVT_SIZE (wxListCtrl::OnSize) | |
53010e52 | 3248 | EVT_IDLE (wxListCtrl::OnIdle) |
c801d85f KB |
3249 | END_EVENT_TABLE() |
3250 | ||
fd9811b1 | 3251 | wxListCtrl::wxListCtrl() |
c801d85f | 3252 | { |
5b077d48 RR |
3253 | m_imageListNormal = (wxImageList *) NULL; |
3254 | m_imageListSmall = (wxImageList *) NULL; | |
3255 | m_imageListState = (wxImageList *) NULL; | |
2e12c11a | 3256 | m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE; |
5b077d48 RR |
3257 | m_mainWin = (wxListMainWindow*) NULL; |
3258 | m_headerWin = (wxListHeaderWindow*) NULL; | |
c801d85f KB |
3259 | } |
3260 | ||
fd9811b1 | 3261 | wxListCtrl::~wxListCtrl() |
c801d85f | 3262 | { |
2e12c11a VS |
3263 | if (m_ownsImageListNormal) delete m_imageListNormal; |
3264 | if (m_ownsImageListSmall) delete m_imageListSmall; | |
3265 | if (m_ownsImageListState) delete m_imageListState; | |
c801d85f KB |
3266 | } |
3267 | ||
25e3a937 VZ |
3268 | bool wxListCtrl::Create(wxWindow *parent, |
3269 | wxWindowID id, | |
3270 | const wxPoint &pos, | |
3271 | const wxSize &size, | |
3272 | long style, | |
25e3a937 | 3273 | const wxValidator &validator, |
25e3a937 | 3274 | const wxString &name) |
c801d85f | 3275 | { |
5b077d48 RR |
3276 | m_imageListNormal = (wxImageList *) NULL; |
3277 | m_imageListSmall = (wxImageList *) NULL; | |
3278 | m_imageListState = (wxImageList *) NULL; | |
2e12c11a | 3279 | m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE; |
5b077d48 RR |
3280 | m_mainWin = (wxListMainWindow*) NULL; |
3281 | m_headerWin = (wxListHeaderWindow*) NULL; | |
bd8289c1 | 3282 | |
25e3a937 | 3283 | if ( !(style & (wxLC_REPORT | wxLC_LIST | wxLC_ICON)) ) |
5b077d48 | 3284 | { |
25e3a937 | 3285 | style = style | wxLC_LIST; |
5b077d48 | 3286 | } |
f6bcfd97 | 3287 | |
098963c3 | 3288 | bool ret = wxControl::Create( parent, id, pos, size, style, validator, name ); |
f6bcfd97 BP |
3289 | |
3290 | ||
25e3a937 VZ |
3291 | if (style & wxSUNKEN_BORDER) |
3292 | style -= wxSUNKEN_BORDER; | |
bd8289c1 | 3293 | |
25e3a937 | 3294 | m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, style ); |
bd8289c1 | 3295 | |
f03fc89f | 3296 | if (HasFlag(wxLC_REPORT)) |
ea451729 | 3297 | { |
5b077d48 | 3298 | m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(size.x,23), wxTAB_TRAVERSAL ); |
ea451729 RR |
3299 | if (HasFlag(wxLC_NO_HEADER)) |
3300 | m_headerWin->Show( FALSE ); | |
3301 | } | |
5b077d48 | 3302 | else |
ea451729 | 3303 | { |
5b077d48 | 3304 | m_headerWin = (wxListHeaderWindow *) NULL; |
ea451729 | 3305 | } |
bd8289c1 | 3306 | |
5b077d48 | 3307 | return ret; |
e1e955e1 | 3308 | } |
c801d85f KB |
3309 | |
3310 | void wxListCtrl::OnSize( wxSizeEvent &WXUNUSED(event) ) | |
3311 | { | |
5b077d48 | 3312 | /* handled in OnIdle */ |
bd8289c1 | 3313 | |
5b077d48 | 3314 | if (m_mainWin) m_mainWin->m_dirty = TRUE; |
e1e955e1 | 3315 | } |
c801d85f | 3316 | |
debe6624 | 3317 | void wxListCtrl::SetSingleStyle( long style, bool add ) |
c801d85f | 3318 | { |
f03fc89f | 3319 | long flag = GetWindowStyle(); |
bd8289c1 | 3320 | |
5b077d48 RR |
3321 | if (add) |
3322 | { | |
3323 | if (style & wxLC_MASK_TYPE) flag = flag & ~wxLC_MASK_TYPE; | |
3324 | if (style & wxLC_MASK_ALIGN) flag = flag & ~wxLC_MASK_ALIGN; | |
3325 | if (style & wxLC_MASK_SORT) flag = flag & ~wxLC_MASK_SORT; | |
3326 | } | |
c801d85f | 3327 | |
5b077d48 RR |
3328 | if (add) |
3329 | { | |
3330 | flag |= style; | |
3331 | } | |
3332 | else | |
3333 | { | |
3334 | if (flag & style) flag -= style; | |
3335 | } | |
bd8289c1 | 3336 | |
5b077d48 | 3337 | SetWindowStyleFlag( flag ); |
e1e955e1 | 3338 | } |
c801d85f | 3339 | |
debe6624 | 3340 | void wxListCtrl::SetWindowStyleFlag( long flag ) |
c801d85f | 3341 | { |
121a3581 RR |
3342 | if (m_mainWin) |
3343 | { | |
3344 | m_mainWin->DeleteEverything(); | |
c801d85f | 3345 | |
121a3581 RR |
3346 | int width = 0; |
3347 | int height = 0; | |
3348 | GetClientSize( &width, &height ); | |
c801d85f | 3349 | |
121a3581 | 3350 | m_mainWin->SetMode( flag ); |
bd8289c1 | 3351 | |
121a3581 | 3352 | if (flag & wxLC_REPORT) |
5b077d48 | 3353 | { |
121a3581 | 3354 | if (!HasFlag(wxLC_REPORT)) |
5b077d48 | 3355 | { |
121a3581 RR |
3356 | if (!m_headerWin) |
3357 | { | |
004fd0c8 | 3358 | m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, |
bffa1c77 VZ |
3359 | wxPoint(0,0), wxSize(width,23), wxTAB_TRAVERSAL ); |
3360 | if (HasFlag(wxLC_NO_HEADER)) | |
3361 | m_headerWin->Show( FALSE ); | |
121a3581 RR |
3362 | } |
3363 | else | |
004fd0c8 | 3364 | { |
bffa1c77 VZ |
3365 | if (flag & wxLC_NO_HEADER) |
3366 | m_headerWin->Show( FALSE ); | |
3367 | else | |
8636aed8 | 3368 | m_headerWin->Show( TRUE ); |
004fd0c8 | 3369 | } |
5b077d48 RR |
3370 | } |
3371 | } | |
121a3581 | 3372 | else |
5b077d48 | 3373 | { |
8636aed8 | 3374 | if (HasFlag(wxLC_REPORT) && !(HasFlag(wxLC_NO_HEADER))) |
121a3581 RR |
3375 | { |
3376 | m_headerWin->Show( FALSE ); | |
3377 | } | |
bffa1c77 | 3378 | } |
e1e955e1 | 3379 | } |
004fd0c8 | 3380 | |
5b077d48 | 3381 | wxWindow::SetWindowStyleFlag( flag ); |
e1e955e1 | 3382 | } |
c801d85f | 3383 | |
e487524e | 3384 | bool wxListCtrl::GetColumn(int col, wxListItem &item) const |
c801d85f | 3385 | { |
5b077d48 RR |
3386 | m_mainWin->GetColumn( col, item ); |
3387 | return TRUE; | |
e1e955e1 | 3388 | } |
c801d85f | 3389 | |
debe6624 | 3390 | bool wxListCtrl::SetColumn( int col, wxListItem& item ) |
c801d85f | 3391 | { |
5b077d48 RR |
3392 | m_mainWin->SetColumn( col, item ); |
3393 | return TRUE; | |
e1e955e1 | 3394 | } |
c801d85f | 3395 | |
e487524e | 3396 | int wxListCtrl::GetColumnWidth( int col ) const |
c801d85f | 3397 | { |
5b077d48 | 3398 | return m_mainWin->GetColumnWidth( col ); |
e1e955e1 | 3399 | } |
c801d85f | 3400 | |
debe6624 | 3401 | bool wxListCtrl::SetColumnWidth( int col, int width ) |
c801d85f | 3402 | { |
5b077d48 RR |
3403 | m_mainWin->SetColumnWidth( col, width ); |
3404 | return TRUE; | |
e1e955e1 | 3405 | } |
c801d85f | 3406 | |
fd9811b1 | 3407 | int wxListCtrl::GetCountPerPage() const |
c801d85f KB |
3408 | { |
3409 | return m_mainWin->GetCountPerPage(); // different from Windows ? | |
e1e955e1 | 3410 | } |
c801d85f | 3411 | |
e487524e | 3412 | bool wxListCtrl::GetItem( wxListItem &info ) const |
c801d85f | 3413 | { |
5b077d48 RR |
3414 | m_mainWin->GetItem( info ); |
3415 | return TRUE; | |
e1e955e1 | 3416 | } |
c801d85f KB |
3417 | |
3418 | bool wxListCtrl::SetItem( wxListItem &info ) | |
3419 | { | |
5b077d48 RR |
3420 | m_mainWin->SetItem( info ); |
3421 | return TRUE; | |
e1e955e1 | 3422 | } |
c801d85f | 3423 | |
debe6624 | 3424 | long wxListCtrl::SetItem( long index, int col, const wxString& label, int imageId ) |
c801d85f | 3425 | { |
5b077d48 RR |
3426 | wxListItem info; |
3427 | info.m_text = label; | |
3428 | info.m_mask = wxLIST_MASK_TEXT; | |
3429 | info.m_itemId = index; | |
3430 | info.m_col = col; | |
3431 | if ( imageId > -1 ) | |
3432 | { | |
3433 | info.m_image = imageId; | |
3434 | info.m_mask |= wxLIST_MASK_IMAGE; | |
3435 | }; | |
3436 | m_mainWin->SetItem(info); | |
3437 | return TRUE; | |
e1e955e1 | 3438 | } |
c801d85f | 3439 | |
e487524e | 3440 | int wxListCtrl::GetItemState( long item, long stateMask ) const |
c801d85f | 3441 | { |
5b077d48 | 3442 | return m_mainWin->GetItemState( item, stateMask ); |
e1e955e1 | 3443 | } |
c801d85f | 3444 | |
debe6624 | 3445 | bool wxListCtrl::SetItemState( long item, long state, long stateMask ) |
c801d85f | 3446 | { |
5b077d48 RR |
3447 | m_mainWin->SetItemState( item, state, stateMask ); |
3448 | return TRUE; | |
e1e955e1 | 3449 | } |
c801d85f | 3450 | |
debe6624 | 3451 | bool wxListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) ) |
c801d85f | 3452 | { |
5b077d48 RR |
3453 | wxListItem info; |
3454 | info.m_image = image; | |
3455 | info.m_mask = wxLIST_MASK_IMAGE; | |
3456 | info.m_itemId = item; | |
3457 | m_mainWin->SetItem( info ); | |
3458 | return TRUE; | |
e1e955e1 | 3459 | } |
c801d85f | 3460 | |
e487524e | 3461 | wxString wxListCtrl::GetItemText( long item ) const |
c801d85f | 3462 | { |
5b077d48 RR |
3463 | wxListItem info; |
3464 | info.m_itemId = item; | |
3465 | m_mainWin->GetItem( info ); | |
3466 | return info.m_text; | |
e1e955e1 | 3467 | } |
c801d85f | 3468 | |
debe6624 | 3469 | void wxListCtrl::SetItemText( long item, const wxString &str ) |
c801d85f | 3470 | { |
5b077d48 RR |
3471 | wxListItem info; |
3472 | info.m_mask = wxLIST_MASK_TEXT; | |
3473 | info.m_itemId = item; | |
3474 | info.m_text = str; | |
3475 | m_mainWin->SetItem( info ); | |
e1e955e1 | 3476 | } |
c801d85f | 3477 | |
e487524e | 3478 | long wxListCtrl::GetItemData( long item ) const |
c801d85f | 3479 | { |
5b077d48 RR |
3480 | wxListItem info; |
3481 | info.m_itemId = item; | |
3482 | m_mainWin->GetItem( info ); | |
3483 | return info.m_data; | |
e1e955e1 | 3484 | } |
c801d85f | 3485 | |
debe6624 | 3486 | bool wxListCtrl::SetItemData( long item, long data ) |
c801d85f | 3487 | { |
5b077d48 RR |
3488 | wxListItem info; |
3489 | info.m_mask = wxLIST_MASK_DATA; | |
3490 | info.m_itemId = item; | |
3491 | info.m_data = data; | |
3492 | m_mainWin->SetItem( info ); | |
3493 | return TRUE; | |
e1e955e1 | 3494 | } |
c801d85f | 3495 | |
0a240683 | 3496 | bool wxListCtrl::GetItemRect( long item, wxRect &rect, int WXUNUSED(code) ) const |
c801d85f | 3497 | { |
5b077d48 RR |
3498 | m_mainWin->GetItemRect( item, rect ); |
3499 | return TRUE; | |
e1e955e1 | 3500 | } |
c801d85f | 3501 | |
e487524e | 3502 | bool wxListCtrl::GetItemPosition( long item, wxPoint& pos ) const |
c801d85f | 3503 | { |
5b077d48 RR |
3504 | m_mainWin->GetItemPosition( item, pos ); |
3505 | return TRUE; | |
e1e955e1 | 3506 | } |
c801d85f | 3507 | |
debe6624 | 3508 | bool wxListCtrl::SetItemPosition( long WXUNUSED(item), const wxPoint& WXUNUSED(pos) ) |
c801d85f | 3509 | { |
5b077d48 | 3510 | return 0; |
e1e955e1 | 3511 | } |
c801d85f | 3512 | |
fd9811b1 | 3513 | int wxListCtrl::GetItemCount() const |
c801d85f | 3514 | { |
5b077d48 | 3515 | return m_mainWin->GetItemCount(); |
e1e955e1 | 3516 | } |
c801d85f | 3517 | |
fd9811b1 | 3518 | int wxListCtrl::GetColumnCount() const |
92976ab6 | 3519 | { |
5b077d48 | 3520 | return m_mainWin->GetColumnCount(); |
92976ab6 RR |
3521 | } |
3522 | ||
33d0b396 RR |
3523 | void wxListCtrl::SetItemSpacing( int spacing, bool isSmall ) |
3524 | { | |
5b077d48 | 3525 | m_mainWin->SetItemSpacing( spacing, isSmall ); |
e1e955e1 | 3526 | } |
33d0b396 | 3527 | |
e487524e | 3528 | int wxListCtrl::GetItemSpacing( bool isSmall ) const |
c801d85f | 3529 | { |
5b077d48 | 3530 | return m_mainWin->GetItemSpacing( isSmall ); |
e1e955e1 | 3531 | } |
c801d85f | 3532 | |
fd9811b1 | 3533 | int wxListCtrl::GetSelectedItemCount() const |
c801d85f | 3534 | { |
5b077d48 | 3535 | return m_mainWin->GetSelectedItemCount(); |
e1e955e1 | 3536 | } |
c801d85f | 3537 | |
fd9811b1 | 3538 | wxColour wxListCtrl::GetTextColour() const |
c801d85f | 3539 | { |
0530737d | 3540 | return GetForegroundColour(); |
e1e955e1 | 3541 | } |
c801d85f | 3542 | |
0530737d | 3543 | void wxListCtrl::SetTextColour(const wxColour& col) |
c801d85f | 3544 | { |
0530737d | 3545 | SetForegroundColour(col); |
e1e955e1 | 3546 | } |
c801d85f | 3547 | |
fd9811b1 | 3548 | long wxListCtrl::GetTopItem() const |
c801d85f | 3549 | { |
5b077d48 | 3550 | return 0; |
e1e955e1 | 3551 | } |
c801d85f | 3552 | |
6de97a3b | 3553 | long wxListCtrl::GetNextItem( long item, int geom, int state ) const |
c801d85f | 3554 | { |
5b077d48 | 3555 | return m_mainWin->GetNextItem( item, geom, state ); |
e1e955e1 | 3556 | } |
c801d85f | 3557 | |
e487524e | 3558 | wxImageList *wxListCtrl::GetImageList(int which) const |
c801d85f | 3559 | { |
5b077d48 RR |
3560 | if (which == wxIMAGE_LIST_NORMAL) |
3561 | { | |
3562 | return m_imageListNormal; | |
3563 | } | |
3564 | else if (which == wxIMAGE_LIST_SMALL) | |
3565 | { | |
3566 | return m_imageListSmall; | |
3567 | } | |
3568 | else if (which == wxIMAGE_LIST_STATE) | |
3569 | { | |
3570 | return m_imageListState; | |
3571 | } | |
3572 | return (wxImageList *) NULL; | |
e1e955e1 | 3573 | } |
c801d85f | 3574 | |
debe6624 | 3575 | void wxListCtrl::SetImageList( wxImageList *imageList, int which ) |
c801d85f | 3576 | { |
2e12c11a VS |
3577 | if ( which == wxIMAGE_LIST_NORMAL ) |
3578 | { | |
3579 | if (m_ownsImageListNormal) delete m_imageListNormal; | |
3580 | m_imageListNormal = imageList; | |
3581 | m_ownsImageListNormal = FALSE; | |
3582 | } | |
3583 | else if ( which == wxIMAGE_LIST_SMALL ) | |
3584 | { | |
3585 | if (m_ownsImageListSmall) delete m_imageListSmall; | |
3586 | m_imageListSmall = imageList; | |
3587 | m_ownsImageListSmall = FALSE; | |
3588 | } | |
3589 | else if ( which == wxIMAGE_LIST_STATE ) | |
3590 | { | |
3591 | if (m_ownsImageListState) delete m_imageListState; | |
3592 | m_imageListState = imageList; | |
3593 | m_ownsImageListState = FALSE; | |
3594 | } | |
3595 | ||
5b077d48 | 3596 | m_mainWin->SetImageList( imageList, which ); |
e1e955e1 | 3597 | } |
c801d85f | 3598 | |
2e12c11a VS |
3599 | void wxListCtrl::AssignImageList(wxImageList *imageList, int which) |
3600 | { | |
3601 | SetImageList(imageList, which); | |
3602 | if ( which == wxIMAGE_LIST_NORMAL ) | |
3603 | m_ownsImageListNormal = TRUE; | |
3604 | else if ( which == wxIMAGE_LIST_SMALL ) | |
3605 | m_ownsImageListSmall = TRUE; | |
3606 | else if ( which == wxIMAGE_LIST_STATE ) | |
3607 | m_ownsImageListState = TRUE; | |
3608 | } | |
3609 | ||
debe6624 | 3610 | bool wxListCtrl::Arrange( int WXUNUSED(flag) ) |
c801d85f | 3611 | { |
5b077d48 | 3612 | return 0; |
e1e955e1 | 3613 | } |
c801d85f | 3614 | |
debe6624 | 3615 | bool wxListCtrl::DeleteItem( long item ) |
c801d85f | 3616 | { |
5b077d48 RR |
3617 | m_mainWin->DeleteItem( item ); |
3618 | return TRUE; | |
e1e955e1 | 3619 | } |
c801d85f | 3620 | |
fd9811b1 | 3621 | bool wxListCtrl::DeleteAllItems() |
c801d85f | 3622 | { |
5b077d48 RR |
3623 | m_mainWin->DeleteAllItems(); |
3624 | return TRUE; | |
e1e955e1 | 3625 | } |
c801d85f | 3626 | |
4f22cf8d | 3627 | bool wxListCtrl::DeleteAllColumns() |
bd8289c1 VZ |
3628 | { |
3629 | for ( size_t n = 0; n < m_mainWin->m_columns.GetCount(); n++ ) | |
3630 | DeleteColumn(n); | |
bffa1c77 | 3631 | |
5b077d48 | 3632 | return TRUE; |
4f22cf8d RR |
3633 | } |
3634 | ||
3635 | void wxListCtrl::ClearAll() | |
3636 | { | |
5b077d48 | 3637 | m_mainWin->DeleteEverything(); |
bd8289c1 VZ |
3638 | } |
3639 | ||
debe6624 | 3640 | bool wxListCtrl::DeleteColumn( int col ) |
c801d85f | 3641 | { |
5b077d48 RR |
3642 | m_mainWin->DeleteColumn( col ); |
3643 | return TRUE; | |
e1e955e1 | 3644 | } |
c801d85f | 3645 | |
e179bd65 | 3646 | void wxListCtrl::Edit( long item ) |
c801d85f | 3647 | { |
e179bd65 | 3648 | m_mainWin->Edit( item ); |
e1e955e1 | 3649 | } |
c801d85f | 3650 | |
debe6624 | 3651 | bool wxListCtrl::EnsureVisible( long item ) |
c801d85f | 3652 | { |
5b077d48 RR |
3653 | m_mainWin->EnsureVisible( item ); |
3654 | return TRUE; | |
e1e955e1 | 3655 | } |
c801d85f | 3656 | |
debe6624 | 3657 | long wxListCtrl::FindItem( long start, const wxString& str, bool partial ) |
c801d85f | 3658 | { |
5b077d48 | 3659 | return m_mainWin->FindItem( start, str, partial ); |
e1e955e1 | 3660 | } |
c801d85f | 3661 | |
debe6624 | 3662 | long wxListCtrl::FindItem( long start, long data ) |
c801d85f | 3663 | { |
5b077d48 | 3664 | return m_mainWin->FindItem( start, data ); |
e1e955e1 | 3665 | } |
c801d85f | 3666 | |
bd8289c1 | 3667 | long wxListCtrl::FindItem( long WXUNUSED(start), const wxPoint& WXUNUSED(pt), |
debe6624 | 3668 | int WXUNUSED(direction)) |
c801d85f | 3669 | { |
5b077d48 | 3670 | return 0; |
e1e955e1 | 3671 | } |
c801d85f KB |
3672 | |
3673 | long wxListCtrl::HitTest( const wxPoint &point, int &flags ) | |
3674 | { | |
5b077d48 | 3675 | return m_mainWin->HitTest( (int)point.x, (int)point.y, flags ); |
e1e955e1 | 3676 | } |
c801d85f KB |
3677 | |
3678 | long wxListCtrl::InsertItem( wxListItem& info ) | |
3679 | { | |
5b077d48 | 3680 | m_mainWin->InsertItem( info ); |
2ebcd5f5 | 3681 | return info.m_itemId; |
e1e955e1 | 3682 | } |
c801d85f | 3683 | |
debe6624 | 3684 | long wxListCtrl::InsertItem( long index, const wxString &label ) |
c801d85f | 3685 | { |
51cc4dad RR |
3686 | wxListItem info; |
3687 | info.m_text = label; | |
3688 | info.m_mask = wxLIST_MASK_TEXT; | |
3689 | info.m_itemId = index; | |
3690 | return InsertItem( info ); | |
e1e955e1 | 3691 | } |
c801d85f | 3692 | |
debe6624 | 3693 | long wxListCtrl::InsertItem( long index, int imageIndex ) |
c801d85f | 3694 | { |
51cc4dad RR |
3695 | wxListItem info; |
3696 | info.m_mask = wxLIST_MASK_IMAGE; | |
3697 | info.m_image = imageIndex; | |
3698 | info.m_itemId = index; | |
3699 | return InsertItem( info ); | |
e1e955e1 | 3700 | } |
c801d85f | 3701 | |
debe6624 | 3702 | long wxListCtrl::InsertItem( long index, const wxString &label, int imageIndex ) |
c801d85f | 3703 | { |
51cc4dad RR |
3704 | wxListItem info; |
3705 | info.m_text = label; | |
3706 | info.m_image = imageIndex; | |
3707 | info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE; | |
3708 | info.m_itemId = index; | |
3709 | return InsertItem( info ); | |
e1e955e1 | 3710 | } |
c801d85f | 3711 | |
debe6624 | 3712 | long wxListCtrl::InsertColumn( long col, wxListItem &item ) |
c801d85f | 3713 | { |
d3e90957 | 3714 | wxASSERT( m_headerWin ); |
51cc4dad | 3715 | m_mainWin->InsertColumn( col, item ); |
d3e90957 | 3716 | m_headerWin->Refresh(); |
25e3a937 | 3717 | |
51cc4dad | 3718 | return 0; |
e1e955e1 | 3719 | } |
c801d85f | 3720 | |
debe6624 JS |
3721 | long wxListCtrl::InsertColumn( long col, const wxString &heading, |
3722 | int format, int width ) | |
c801d85f | 3723 | { |
51cc4dad RR |
3724 | wxListItem item; |
3725 | item.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_FORMAT; | |
3726 | item.m_text = heading; | |
3727 | if (width >= -2) | |
3728 | { | |
3729 | item.m_mask |= wxLIST_MASK_WIDTH; | |
3730 | item.m_width = width; | |
3731 | } | |
3732 | item.m_format = format; | |
c801d85f | 3733 | |
51cc4dad | 3734 | return InsertColumn( col, item ); |
e1e955e1 | 3735 | } |
c801d85f | 3736 | |
debe6624 | 3737 | bool wxListCtrl::ScrollList( int WXUNUSED(dx), int WXUNUSED(dy) ) |
c801d85f | 3738 | { |
51cc4dad | 3739 | return 0; |
e1e955e1 | 3740 | } |
c801d85f KB |
3741 | |
3742 | // Sort items. | |
3743 | // fn is a function which takes 3 long arguments: item1, item2, data. | |
3744 | // item1 is the long data associated with a first item (NOT the index). | |
3745 | // item2 is the long data associated with a second item (NOT the index). | |
3746 | // data is the same value as passed to SortItems. | |
3747 | // The return value is a negative number if the first item should precede the second | |
3748 | // item, a positive number of the second item should precede the first, | |
3749 | // or zero if the two items are equivalent. | |
3750 | // data is arbitrary data to be passed to the sort function. | |
3751 | ||
3752 | bool wxListCtrl::SortItems( wxListCtrlCompare fn, long data ) | |
3753 | { | |
51cc4dad RR |
3754 | m_mainWin->SortItems( fn, data ); |
3755 | return TRUE; | |
e1e955e1 | 3756 | } |
c801d85f | 3757 | |
e3e65dac | 3758 | void wxListCtrl::OnIdle( wxIdleEvent &WXUNUSED(event) ) |
53010e52 | 3759 | { |
51cc4dad | 3760 | if (!m_mainWin->m_dirty) return; |
53010e52 | 3761 | |
51cc4dad RR |
3762 | int cw = 0; |
3763 | int ch = 0; | |
3764 | GetClientSize( &cw, &ch ); | |
bd8289c1 | 3765 | |
51cc4dad RR |
3766 | int x = 0; |
3767 | int y = 0; | |
3768 | int w = 0; | |
3769 | int h = 0; | |
bd8289c1 | 3770 | |
8636aed8 | 3771 | if (HasFlag(wxLC_REPORT) && !HasFlag(wxLC_NO_HEADER)) |
51cc4dad RR |
3772 | { |
3773 | m_headerWin->GetPosition( &x, &y ); | |
3774 | m_headerWin->GetSize( &w, &h ); | |
3775 | if ((x != 0) || (y != 0) || (w != cw) || (h != 23)) | |
3776 | m_headerWin->SetSize( 0, 0, cw, 23 ); | |
3777 | ||
3778 | m_mainWin->GetPosition( &x, &y ); | |
3779 | m_mainWin->GetSize( &w, &h ); | |
3780 | if ((x != 0) || (y != 24) || (w != cw) || (h != ch-24)) | |
3781 | m_mainWin->SetSize( 0, 24, cw, ch-24 ); | |
3782 | } | |
3783 | else | |
3784 | { | |
3785 | m_mainWin->GetPosition( &x, &y ); | |
3786 | m_mainWin->GetSize( &w, &h ); | |
3787 | if ((x != 0) || (y != 24) || (w != cw) || (h != ch)) | |
3788 | m_mainWin->SetSize( 0, 0, cw, ch ); | |
3789 | } | |
bd8289c1 | 3790 | |
51cc4dad RR |
3791 | m_mainWin->CalculatePositions(); |
3792 | m_mainWin->RealizeChanges(); | |
3793 | m_mainWin->m_dirty = FALSE; | |
3794 | m_mainWin->Refresh(); | |
f6bcfd97 BP |
3795 | |
3796 | if ( m_headerWin && m_headerWin->m_dirty ) | |
3797 | { | |
3798 | m_headerWin->m_dirty = FALSE; | |
3799 | m_headerWin->Refresh(); | |
3800 | } | |
e1e955e1 | 3801 | } |
53010e52 | 3802 | |
f03fc89f | 3803 | bool wxListCtrl::SetBackgroundColour( const wxColour &colour ) |
bd8289c1 | 3804 | { |
51cc4dad RR |
3805 | if (m_mainWin) |
3806 | { | |
3807 | m_mainWin->SetBackgroundColour( colour ); | |
3808 | m_mainWin->m_dirty = TRUE; | |
3809 | } | |
004fd0c8 | 3810 | |
f03fc89f | 3811 | return TRUE; |
e4d06860 RR |
3812 | } |
3813 | ||
f03fc89f | 3814 | bool wxListCtrl::SetForegroundColour( const wxColour &colour ) |
bd8289c1 | 3815 | { |
f03fc89f VZ |
3816 | if ( !wxWindow::SetForegroundColour( colour ) ) |
3817 | return FALSE; | |
004fd0c8 | 3818 | |
51cc4dad RR |
3819 | if (m_mainWin) |
3820 | { | |
3821 | m_mainWin->SetForegroundColour( colour ); | |
3822 | m_mainWin->m_dirty = TRUE; | |
3823 | } | |
004fd0c8 | 3824 | |
51cc4dad RR |
3825 | if (m_headerWin) |
3826 | { | |
3827 | m_headerWin->SetForegroundColour( colour ); | |
3828 | } | |
f03fc89f VZ |
3829 | |
3830 | return TRUE; | |
e4d06860 | 3831 | } |
bd8289c1 | 3832 | |
f03fc89f | 3833 | bool wxListCtrl::SetFont( const wxFont &font ) |
bd8289c1 | 3834 | { |
f03fc89f VZ |
3835 | if ( !wxWindow::SetFont( font ) ) |
3836 | return FALSE; | |
004fd0c8 | 3837 | |
51cc4dad RR |
3838 | if (m_mainWin) |
3839 | { | |
3840 | m_mainWin->SetFont( font ); | |
3841 | m_mainWin->m_dirty = TRUE; | |
3842 | } | |
004fd0c8 | 3843 | |
51cc4dad RR |
3844 | if (m_headerWin) |
3845 | { | |
3846 | m_headerWin->SetFont( font ); | |
3847 | } | |
f03fc89f VZ |
3848 | |
3849 | return TRUE; | |
e4d06860 | 3850 | } |
c801d85f | 3851 | |
efbb7287 VZ |
3852 | #if wxUSE_DRAG_AND_DROP |
3853 | ||
3854 | void wxListCtrl::SetDropTarget( wxDropTarget *dropTarget ) | |
3855 | { | |
3856 | m_mainWin->SetDropTarget( dropTarget ); | |
3857 | } | |
3858 | ||
3859 | wxDropTarget *wxListCtrl::GetDropTarget() const | |
3860 | { | |
3861 | return m_mainWin->GetDropTarget(); | |
3862 | } | |
3863 | ||
3864 | #endif // wxUSE_DRAG_AND_DROP | |
3865 | ||
3866 | bool wxListCtrl::SetCursor( const wxCursor &cursor ) | |
3867 | { | |
3868 | return m_mainWin ? m_mainWin->wxWindow::SetCursor(cursor) : FALSE; | |
3869 | } | |
3870 | ||
3871 | wxColour wxListCtrl::GetBackgroundColour() const | |
3872 | { | |
3873 | return m_mainWin ? m_mainWin->GetBackgroundColour() : wxColour(); | |
3874 | } | |
3875 | ||
3876 | wxColour wxListCtrl::GetForegroundColour() const | |
3877 | { | |
3878 | return m_mainWin ? m_mainWin->GetForegroundColour() : wxColour(); | |
3879 | } | |
3880 | ||
3881 | bool wxListCtrl::DoPopupMenu( wxMenu *menu, int x, int y ) | |
3882 | { | |
3883 | return m_mainWin->PopupMenu( menu, x, y ); | |
3884 | } | |
3885 | ||
3886 | void wxListCtrl::SetFocus() | |
3887 | { | |
3888 | /* The test in window.cpp fails as we are a composite | |
3889 | window, so it checks against "this", but not m_mainWin. */ | |
3890 | if ( FindFocus() != this ) | |
3891 | m_mainWin->SetFocus(); | |
3892 | } |