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