1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #ifndef wxHAS_IMAGES_IN_RESOURCES
24 #include "../sample.xpm"
27 #ifndef wxHAS_IMAGES_IN_RESOURCES
28 #include "bitmaps/toolbrai.xpm"
29 #include "bitmaps/toolchar.xpm"
30 #include "bitmaps/tooldata.xpm"
31 #include "bitmaps/toolnote.xpm"
32 #include "bitmaps/tooltodo.xpm"
33 #include "bitmaps/toolchec.xpm"
34 #include "bitmaps/toolgame.xpm"
35 #include "bitmaps/tooltime.xpm"
36 #include "bitmaps/toolword.xpm"
37 #include "bitmaps/small1.xpm"
40 #include "wx/imaglist.h"
41 #include "wx/listctrl.h"
42 #include "wx/timer.h" // for wxStopWatch
43 #include "wx/colordlg.h" // for wxGetColourFromUser
44 #include "wx/settings.h"
45 #include "wx/sysopt.h"
46 #include "wx/numdlg.h"
51 // ----------------------------------------------------------------------------
52 // Constants and globals
53 // ----------------------------------------------------------------------------
55 const wxChar
*SMALL_VIRTUAL_VIEW_ITEMS
[][2] =
57 { wxT("Cat"), wxT("meow") },
58 { wxT("Cow"), wxT("moo") },
59 { wxT("Crow"), wxT("caw") },
60 { wxT("Dog"), wxT("woof") },
61 { wxT("Duck"), wxT("quack") },
62 { wxT("Mouse"), wxT("squeak") },
63 { wxT("Owl"), wxT("hoo") },
64 { wxT("Pig"), wxT("oink") },
65 { wxT("Pigeon"), wxT("coo") },
66 { wxT("Sheep"), wxT("baaah") },
69 // number of items in icon/small icon view
70 static const int NUM_ICONS
= 9;
73 MyCompareFunction(wxIntPtr item1
, wxIntPtr item2
, wxIntPtr
WXUNUSED(sortData
))
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
91 // `Main program' equivalent, creating windows and returning main app frame
94 if ( !wxApp::OnInit() )
97 // Create the main frame window
98 MyFrame
*frame
= new MyFrame(wxT("wxListCtrl Test"));
108 // ----------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------
112 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
113 EVT_SIZE(MyFrame::OnSize
)
115 EVT_MENU(LIST_QUIT
, MyFrame::OnQuit
)
116 EVT_MENU(LIST_ABOUT
, MyFrame::OnAbout
)
117 EVT_MENU(LIST_LIST_VIEW
, MyFrame::OnListView
)
118 EVT_MENU(LIST_REPORT_VIEW
, MyFrame::OnReportView
)
119 EVT_MENU(LIST_ICON_VIEW
, MyFrame::OnIconView
)
120 EVT_MENU(LIST_ICON_TEXT_VIEW
, MyFrame::OnIconTextView
)
121 EVT_MENU(LIST_SMALL_ICON_VIEW
, MyFrame::OnSmallIconView
)
122 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW
, MyFrame::OnSmallIconTextView
)
123 EVT_MENU(LIST_VIRTUAL_VIEW
, MyFrame::OnVirtualView
)
124 EVT_MENU(LIST_SMALL_VIRTUAL_VIEW
, MyFrame::OnSmallVirtualView
)
126 EVT_MENU(LIST_SET_ITEMS_COUNT
, MyFrame::OnSetItemsCount
)
128 EVT_MENU(LIST_GOTO
, MyFrame::OnGoTo
)
129 EVT_MENU(LIST_FOCUS_LAST
, MyFrame::OnFocusLast
)
130 EVT_MENU(LIST_TOGGLE_FIRST
, MyFrame::OnToggleFirstSel
)
131 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
132 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
133 EVT_MENU(LIST_DELETE
, MyFrame::OnDelete
)
134 EVT_MENU(LIST_ADD
, MyFrame::OnAdd
)
135 EVT_MENU(LIST_EDIT
, MyFrame::OnEdit
)
136 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
137 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
138 EVT_MENU(LIST_SET_FG_COL
, MyFrame::OnSetFgColour
)
139 EVT_MENU(LIST_SET_BG_COL
, MyFrame::OnSetBgColour
)
140 EVT_MENU(LIST_ROW_LINES
, MyFrame::OnSetRowLines
)
141 EVT_MENU(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnToggleMultiSel
)
142 EVT_MENU(LIST_SHOW_COL_INFO
, MyFrame::OnShowColInfo
)
143 EVT_MENU(LIST_SHOW_SEL_INFO
, MyFrame::OnShowSelInfo
)
144 EVT_MENU(LIST_SHOW_VIEW_RECT
, MyFrame::OnShowViewRect
)
145 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
146 EVT_MENU(LIST_SET_COL_ORDER
, MyFrame::OnSetColOrder
)
147 EVT_MENU(LIST_GET_COL_ORDER
, MyFrame::OnGetColOrder
)
148 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
149 EVT_MENU(LIST_FREEZE
, MyFrame::OnFreeze
)
150 EVT_MENU(LIST_THAW
, MyFrame::OnThaw
)
151 EVT_MENU(LIST_TOGGLE_LINES
, MyFrame::OnToggleLines
)
152 EVT_MENU(LIST_TOGGLE_HEADER
, MyFrame::OnToggleHeader
)
153 EVT_MENU(LIST_TOGGLE_BELL
, MyFrame::OnToggleBell
)
155 EVT_MENU(LIST_MAC_USE_GENERIC
, MyFrame::OnToggleMacUseGeneric
)
157 EVT_MENU(LIST_FIND
, MyFrame::OnFind
)
159 EVT_UPDATE_UI(LIST_SHOW_COL_INFO
, MyFrame::OnUpdateUIEnableInReport
)
160 EVT_UPDATE_UI(LIST_TOGGLE_HEADER
, MyFrame::OnUpdateUIEnableInReport
)
162 EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnUpdateToggleMultiSel
)
163 EVT_UPDATE_UI(LIST_TOGGLE_HEADER
, MyFrame::OnUpdateToggleHeader
)
164 EVT_UPDATE_UI(LIST_ROW_LINES
, MyFrame::OnUpdateRowLines
)
167 // My frame constructor
168 MyFrame::MyFrame(const wxChar
*title
)
169 : wxFrame(NULL
, wxID_ANY
, title
, wxDefaultPosition
, wxSize(600, 500))
173 m_smallVirtual
= false;
177 SetIcon(wxICON(sample
));
179 // Make an image list containing large icons
180 m_imageListNormal
= new wxImageList(32, 32, true);
181 m_imageListSmall
= new wxImageList(16, 16, true);
183 #ifdef wxHAS_IMAGES_IN_RESOURCES
184 m_imageListNormal
->Add( wxIcon(wxT("icon1"), wxBITMAP_TYPE_ICO_RESOURCE
) );
185 m_imageListNormal
->Add( wxIcon(wxT("icon2"), wxBITMAP_TYPE_ICO_RESOURCE
) );
186 m_imageListNormal
->Add( wxIcon(wxT("icon3"), wxBITMAP_TYPE_ICO_RESOURCE
) );
187 m_imageListNormal
->Add( wxIcon(wxT("icon4"), wxBITMAP_TYPE_ICO_RESOURCE
) );
188 m_imageListNormal
->Add( wxIcon(wxT("icon5"), wxBITMAP_TYPE_ICO_RESOURCE
) );
189 m_imageListNormal
->Add( wxIcon(wxT("icon6"), wxBITMAP_TYPE_ICO_RESOURCE
) );
190 m_imageListNormal
->Add( wxIcon(wxT("icon7"), wxBITMAP_TYPE_ICO_RESOURCE
) );
191 m_imageListNormal
->Add( wxIcon(wxT("icon8"), wxBITMAP_TYPE_ICO_RESOURCE
) );
192 m_imageListNormal
->Add( wxIcon(wxT("icon9"), wxBITMAP_TYPE_ICO_RESOURCE
) );
194 m_imageListSmall
->Add( wxIcon(wxT("iconsmall"), wxBITMAP_TYPE_ICO_RESOURCE
) );
197 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
198 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
199 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
200 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
201 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
202 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
203 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
204 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
205 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
207 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
211 wxMenu
*menuFile
= new wxMenu
;
212 menuFile
->Append(LIST_ABOUT
, wxT("&About"));
213 menuFile
->AppendSeparator();
214 menuFile
->Append(LIST_QUIT
, wxT("E&xit\tAlt-X"));
216 wxMenu
*menuView
= new wxMenu
;
217 menuView
->Append(LIST_LIST_VIEW
, wxT("&List view\tF1"));
218 menuView
->Append(LIST_REPORT_VIEW
, wxT("&Report view\tF2"));
219 menuView
->Append(LIST_ICON_VIEW
, wxT("&Icon view\tF3"));
220 menuView
->Append(LIST_ICON_TEXT_VIEW
, wxT("Icon view with &text\tF4"));
221 menuView
->Append(LIST_SMALL_ICON_VIEW
, wxT("&Small icon view\tF5"));
222 menuView
->Append(LIST_SMALL_ICON_TEXT_VIEW
, wxT("Small icon &view with text\tF6"));
223 menuView
->Append(LIST_VIRTUAL_VIEW
, wxT("&Virtual view\tF7"));
224 menuView
->Append(LIST_SMALL_VIRTUAL_VIEW
, wxT("Small virtual vie&w\tF8"));
225 menuView
->AppendSeparator();
226 menuView
->Append(LIST_SET_ITEMS_COUNT
, "Set &number of items");
228 menuView
->AppendSeparator();
229 menuView
->AppendCheckItem(LIST_MAC_USE_GENERIC
, wxT("Mac: Use Generic Control"));
232 wxMenu
*menuList
= new wxMenu
;
233 menuList
->Append(LIST_GOTO
, wxT("&Go to item #3\tCtrl-3"));
234 menuList
->Append(LIST_FOCUS_LAST
, wxT("&Make last item current\tCtrl-L"));
235 menuList
->Append(LIST_TOGGLE_FIRST
, wxT("To&ggle first item\tCtrl-G"));
236 menuList
->Append(LIST_DESELECT_ALL
, wxT("&Deselect All\tCtrl-D"));
237 menuList
->Append(LIST_SELECT_ALL
, wxT("S&elect All\tCtrl-A"));
238 menuList
->AppendSeparator();
239 menuList
->Append(LIST_SHOW_COL_INFO
, wxT("Show &column info\tCtrl-C"));
240 menuList
->Append(LIST_SHOW_SEL_INFO
, wxT("Show &selected items\tCtrl-S"));
241 menuList
->Append(LIST_SHOW_VIEW_RECT
, wxT("Show &view rect"));
242 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
243 menuList
->Append(LIST_SET_COL_ORDER
, wxT("Se&t columns order\tShift-Ctrl-O"));
244 menuList
->Append(LIST_GET_COL_ORDER
, wxT("Sho&w columns order\tCtrl-O"));
245 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
246 menuList
->AppendSeparator();
247 menuList
->Append(LIST_SORT
, wxT("Sor&t\tCtrl-T"));
248 menuList
->Append(LIST_FIND
, "Test Find() performance");
249 menuList
->AppendSeparator();
250 menuList
->Append(LIST_ADD
, wxT("&Append an item\tCtrl-P"));
251 menuList
->Append(LIST_EDIT
, wxT("&Edit the item\tCtrl-E"));
252 menuList
->Append(LIST_DELETE
, wxT("&Delete first item\tCtrl-X"));
253 menuList
->Append(LIST_DELETE_ALL
, wxT("Delete &all items"));
254 menuList
->AppendSeparator();
255 menuList
->Append(LIST_FREEZE
, wxT("Free&ze\tCtrl-Z"));
256 menuList
->Append(LIST_THAW
, wxT("Tha&w\tCtrl-W"));
257 menuList
->AppendSeparator();
258 menuList
->AppendCheckItem(LIST_TOGGLE_LINES
, wxT("Toggle &lines\tCtrl-I"));
259 menuList
->AppendCheckItem(LIST_TOGGLE_MULTI_SEL
,
260 wxT("&Multiple selection\tCtrl-M"));
261 menuList
->Check(LIST_TOGGLE_MULTI_SEL
, true);
262 menuList
->AppendCheckItem(LIST_TOGGLE_HEADER
, "Toggle &header\tCtrl-H");
263 menuList
->Check(LIST_TOGGLE_HEADER
, true);
264 menuList
->AppendCheckItem(LIST_TOGGLE_BELL
, "Toggle &bell on no match");
266 wxMenu
*menuCol
= new wxMenu
;
267 menuCol
->Append(LIST_SET_FG_COL
, wxT("&Foreground colour..."));
268 menuCol
->Append(LIST_SET_BG_COL
, wxT("&Background colour..."));
269 menuCol
->AppendCheckItem(LIST_ROW_LINES
, wxT("Alternating colours"));
271 wxMenuBar
*menubar
= new wxMenuBar
;
272 menubar
->Append(menuFile
, wxT("&File"));
273 menubar
->Append(menuView
, wxT("&View"));
274 menubar
->Append(menuList
, wxT("&List"));
275 menubar
->Append(menuCol
, wxT("&Colour"));
278 m_panel
= new wxPanel(this, wxID_ANY
);
279 m_logWindow
= new wxTextCtrl(m_panel
, wxID_ANY
, wxEmptyString
,
280 wxDefaultPosition
, wxDefaultSize
,
281 wxTE_READONLY
| wxTE_MULTILINE
| wxSUNKEN_BORDER
);
283 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow
));
285 RecreateList(wxLC_REPORT
| wxLC_SINGLE_SEL
);
288 // this is useful to know specially when debugging :)
289 wxLogMessage("Your version of comctl32.dll is: %d",
290 wxApp::GetComCtl32Version());
295 #endif // wxUSE_STATUSBAR
300 delete wxLog::SetActiveTarget(m_logOld
);
302 delete m_imageListNormal
;
303 delete m_imageListSmall
;
306 void MyFrame::OnSize(wxSizeEvent
& event
)
313 void MyFrame::DoSize()
318 wxSize size
= GetClientSize();
319 wxCoord y
= (2*size
.y
)/3;
320 m_listCtrl
->SetSize(0, 0, size
.x
, y
);
321 m_logWindow
->SetSize(0, y
+ 1, size
.x
, size
.y
- y
-1);
324 bool MyFrame::CheckNonVirtual() const
326 if ( !m_listCtrl
->HasFlag(wxLC_VIRTUAL
) )
329 // "this" == whatever
330 wxLogWarning(wxT("Can't do this in virtual view, sorry."));
335 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
340 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
342 wxMessageDialog
dialog(this, wxT("List test sample\nJulian Smart (c) 1997"),
343 wxT("About list test"));
348 void MyFrame::OnFreeze(wxCommandEvent
& WXUNUSED(event
))
350 wxLogMessage(wxT("Freezing the control"));
352 m_listCtrl
->Freeze();
355 void MyFrame::OnThaw(wxCommandEvent
& WXUNUSED(event
))
357 wxLogMessage(wxT("Thawing the control"));
362 void MyFrame::OnToggleLines(wxCommandEvent
& event
)
364 m_listCtrl
->SetSingleStyle(wxLC_HRULES
| wxLC_VRULES
, event
.IsChecked());
367 void MyFrame::OnToggleHeader(wxCommandEvent
& event
)
369 wxLogMessage("%s the header", event
.IsChecked() ? "Showing" : "Hiding");
371 m_listCtrl
->ToggleWindowStyle(wxLC_NO_HEADER
);
374 void MyFrame::OnToggleBell(wxCommandEvent
& event
)
376 m_listCtrl
->EnableBellOnNoMatch(event
.IsChecked());
381 void MyFrame::OnToggleMacUseGeneric(wxCommandEvent
& event
)
383 wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), event
.IsChecked());
388 void MyFrame::OnGoTo(wxCommandEvent
& WXUNUSED(event
))
391 m_listCtrl
->SetItemState(index
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
393 long sel
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
394 wxLIST_STATE_SELECTED
);
396 m_listCtrl
->SetItemState(sel
, 0, wxLIST_STATE_SELECTED
);
397 m_listCtrl
->SetItemState(index
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
400 void MyFrame::OnFocusLast(wxCommandEvent
& WXUNUSED(event
))
402 long index
= m_listCtrl
->GetItemCount() - 1;
408 m_listCtrl
->SetItemState(index
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
409 m_listCtrl
->EnsureVisible(index
);
412 void MyFrame::OnToggleFirstSel(wxCommandEvent
& WXUNUSED(event
))
414 m_listCtrl
->SetItemState(0, (~m_listCtrl
->GetItemState(0, wxLIST_STATE_SELECTED
) ) & wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
417 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
419 if ( !CheckNonVirtual() )
422 int n
= m_listCtrl
->GetItemCount();
423 for (int i
= 0; i
< n
; i
++)
424 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
427 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
429 if ( !CheckNonVirtual() )
432 int n
= m_listCtrl
->GetItemCount();
433 for (int i
= 0; i
< n
; i
++)
434 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
437 // ----------------------------------------------------------------------------
438 // changing listctrl modes
439 // ----------------------------------------------------------------------------
441 void MyFrame::RecreateList(long flags
, bool withText
)
443 // we could avoid recreating it if we don't set/clear the wxLC_VIRTUAL
444 // style, but it is more trouble to do it than not
446 if ( !m_listCtrl
|| ((flags
& wxLC_VIRTUAL
) !=
447 (m_listCtrl
->GetWindowStyleFlag() & wxLC_VIRTUAL
)) )
452 m_listCtrl
= new MyListCtrl(m_panel
, LIST_CTRL
,
453 wxDefaultPosition
, wxDefaultSize
,
455 wxBORDER_THEME
| wxLC_EDIT_LABELS
);
457 switch ( flags
& wxLC_MASK_TYPE
)
464 InitWithIconItems(withText
);
467 case wxLC_SMALL_ICON
:
468 InitWithIconItems(withText
, true);
472 if ( flags
& wxLC_VIRTUAL
)
473 InitWithVirtualItems();
475 InitWithReportItems();
479 wxFAIL_MSG( wxT("unknown listctrl mode") );
482 wxMenuBar
* const mb
= GetMenuBar();
484 m_listCtrl
->EnableBellOnNoMatch(mb
->IsChecked(LIST_TOGGLE_BELL
));
489 GetMenuBar()->Check(LIST_ROW_LINES
, false);
491 m_logWindow
->Clear();
494 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
496 RecreateList(wxLC_LIST
);
499 void MyFrame::InitWithListItems()
501 for ( int i
= 0; i
< m_numListItems
; i
++ )
503 m_listCtrl
->InsertItem(i
, wxString::Format(wxT("Item %d"), i
));
507 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
509 RecreateList(wxLC_REPORT
);
512 void MyFrame::InitWithReportItems()
514 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
516 // note that under MSW for SetColumnWidth() to work we need to create the
517 // items with images initially even if we specify dummy image id
519 itemCol
.SetText(wxT("Column 1"));
520 itemCol
.SetImage(-1);
521 m_listCtrl
->InsertColumn(0, itemCol
);
523 itemCol
.SetText(wxT("Column 2"));
524 itemCol
.SetAlign(wxLIST_FORMAT_CENTRE
);
525 m_listCtrl
->InsertColumn(1, itemCol
);
527 itemCol
.SetText(wxT("Column 3"));
528 itemCol
.SetAlign(wxLIST_FORMAT_RIGHT
);
529 m_listCtrl
->InsertColumn(2, itemCol
);
531 // to speed up inserting we hide the control temporarily
536 for ( int i
= 0; i
< m_numListItems
; i
++ )
538 m_listCtrl
->InsertItemInReportView(i
);
541 m_logWindow
->WriteText(wxString::Format(wxT("%d items inserted in %ldms\n"),
542 m_numListItems
, sw
.Time()));
545 // we leave all mask fields to 0 and only change the colour
548 item
.SetTextColour(*wxRED
);
549 m_listCtrl
->SetItem( item
);
552 item
.SetTextColour(*wxGREEN
);
553 m_listCtrl
->SetItem( item
);
555 item
.SetTextColour(*wxLIGHT_GREY
);
556 item
.SetFont(*wxITALIC_FONT
);
557 item
.SetBackgroundColour(*wxRED
);
558 m_listCtrl
->SetItem( item
);
560 m_listCtrl
->SetTextColour(*wxBLUE
);
562 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
563 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
564 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
566 // Set images in columns
567 m_listCtrl
->SetItemColumnImage(1, 1, 0);
573 m_listCtrl
->SetItem(info
);
575 // test SetItemFont too
576 m_listCtrl
->SetItemFont(0, *wxITALIC_FONT
);
579 void MyFrame::InitWithIconItems(bool withText
, bool sameIcon
)
581 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
582 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
584 for ( int i
= 0; i
< NUM_ICONS
; i
++ )
586 int image
= sameIcon
? 0 : i
;
590 // Make labels of different widths to test the layout.
593 label
.Printf("Longer label %d", i
);
595 label
.Printf("Label %d", i
);
597 m_listCtrl
->InsertItem(i
, label
, image
);
601 m_listCtrl
->InsertItem(i
, image
);
606 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
608 RecreateList(wxLC_ICON
, false);
611 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
613 RecreateList(wxLC_ICON
);
616 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
618 RecreateList(wxLC_SMALL_ICON
, false);
621 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
623 RecreateList(wxLC_SMALL_ICON
);
626 void MyFrame::OnVirtualView(wxCommandEvent
& WXUNUSED(event
))
628 m_smallVirtual
= false;
629 RecreateList(wxLC_REPORT
| wxLC_VIRTUAL
);
632 void MyFrame::OnSmallVirtualView(wxCommandEvent
& WXUNUSED(event
))
634 m_smallVirtual
= true;
635 RecreateList(wxLC_REPORT
| wxLC_VIRTUAL
);
638 void MyFrame::OnSetItemsCount(wxCommandEvent
& WXUNUSED(event
))
640 int numItems
= wxGetNumberFromUser
642 "Enter the initial number of items for "
643 "the list and report views",
645 "wxWidgets wxListCtrl sample",
651 if ( numItems
== -1 || numItems
== m_numListItems
)
654 m_numListItems
= numItems
;
656 if ( m_listCtrl
->HasFlag(wxLC_REPORT
) &&
657 !m_listCtrl
->HasFlag(wxLC_VIRTUAL
) )
658 RecreateList(wxLC_REPORT
);
659 else if ( m_listCtrl
->HasFlag(wxLC_LIST
) )
660 RecreateList(wxLC_LIST
);
663 void MyFrame::InitWithVirtualItems()
665 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
667 if ( m_smallVirtual
)
669 m_listCtrl
->AppendColumn(wxT("Animal"));
670 m_listCtrl
->AppendColumn(wxT("Sound"));
671 m_listCtrl
->SetItemCount(WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS
));
675 m_listCtrl
->AppendColumn(wxT("First Column"));
676 m_listCtrl
->AppendColumn(wxT("Second Column"));
677 m_listCtrl
->SetColumnWidth(0, 150);
678 m_listCtrl
->SetColumnWidth(1, 150);
679 m_listCtrl
->SetItemCount(1000000);
683 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
687 m_listCtrl
->SortItems(MyCompareFunction
, 0);
689 m_logWindow
->WriteText(wxString::Format(wxT("Sorting %d items took %ld ms\n"),
690 m_listCtrl
->GetItemCount(),
694 void MyFrame::OnFind(wxCommandEvent
& WXUNUSED(event
))
698 const int itemCount
= m_listCtrl
->GetItemCount();
699 for ( int i
= 0; i
< itemCount
; i
++ )
700 m_listCtrl
->FindItem(-1, i
);
702 wxLogMessage("Calling Find() for all %d items took %ld ms",
703 itemCount
, sw
.Time());
706 void MyFrame::OnShowSelInfo(wxCommandEvent
& WXUNUSED(event
))
708 int selCount
= m_listCtrl
->GetSelectedItemCount();
709 wxLogMessage(wxT("%d items selected:"), selCount
);
711 // don't show too many items
712 size_t shownCount
= 0;
714 long item
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
715 wxLIST_STATE_SELECTED
);
718 wxLogMessage(wxT("\t%ld (%s)"),
719 item
, m_listCtrl
->GetItemText(item
).c_str());
721 if ( ++shownCount
> 10 )
723 wxLogMessage(wxT("\t... more selected items snipped..."));
727 item
= m_listCtrl
->GetNextItem(item
, wxLIST_NEXT_ALL
,
728 wxLIST_STATE_SELECTED
);
732 void MyFrame::OnShowViewRect(wxCommandEvent
& WXUNUSED(event
))
734 const wxRect r
= m_listCtrl
->GetViewRect();
735 wxLogMessage("View rect: (%d, %d)-(%d, %d)",
736 r
.GetLeft(), r
.GetTop(), r
.GetRight(), r
.GetBottom());
739 // ----------------------------------------------------------------------------
740 // column order tests
741 // ----------------------------------------------------------------------------
743 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
745 static wxString
DumpIntArray(const wxArrayInt
& a
)
748 const size_t count
= a
.size();
749 for ( size_t n
= 0; n
< count
; n
++ )
753 s
+= wxString::Format("%lu", (unsigned long)a
[n
]);
761 void MyFrame::OnSetColOrder(wxCommandEvent
& WXUNUSED(event
))
767 if ( m_listCtrl
->SetColumnsOrder(order
) )
769 wxLogMessage("Column order set to %s", DumpIntArray(order
));
773 void MyFrame::OnGetColOrder(wxCommandEvent
& WXUNUSED(event
))
775 // show what GetColumnsOrder() returns
776 const wxArrayInt order
= m_listCtrl
->GetColumnsOrder();
777 wxString msg
= "Columns order: " +
778 DumpIntArray(m_listCtrl
->GetColumnsOrder()) + "\n";
781 const int count
= m_listCtrl
->GetColumnCount();
783 // show the results of GetColumnOrder() for each column
784 msg
+= "GetColumnOrder() results:\n";
785 for ( n
= 0; n
< count
; n
++ )
787 msg
+= wxString::Format(" %2d -> %2d\n",
788 n
, m_listCtrl
->GetColumnOrder(n
));
791 // and the results of GetColumnIndexFromOrder() too
792 msg
+= "GetColumnIndexFromOrder() results:\n";
793 for ( n
= 0; n
< count
; n
++ )
795 msg
+= wxString::Format(" %2d -> %2d\n",
796 n
, m_listCtrl
->GetColumnIndexFromOrder(n
));
799 wxLogMessage("%s", msg
);
802 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
804 void MyFrame::OnShowColInfo(wxCommandEvent
& WXUNUSED(event
))
806 int count
= m_listCtrl
->GetColumnCount();
807 wxLogMessage(wxT("%d columns:"), count
);
808 for ( int c
= 0; c
< count
; c
++ )
810 wxLogMessage(wxT("\tcolumn %d has width %d"), c
,
811 m_listCtrl
->GetColumnWidth(c
));
815 void MyFrame::OnUpdateUIEnableInReport(wxUpdateUIEvent
& event
)
817 event
.Enable( (m_listCtrl
->GetWindowStyleFlag() & wxLC_REPORT
) != 0 );
820 void MyFrame::OnToggleMultiSel(wxCommandEvent
& WXUNUSED(event
))
822 long flags
= m_listCtrl
->GetWindowStyleFlag();
823 if ( flags
& wxLC_SINGLE_SEL
)
824 flags
&= ~wxLC_SINGLE_SEL
;
826 flags
|= wxLC_SINGLE_SEL
;
828 m_logWindow
->WriteText(wxString::Format(wxT("Current selection mode: %sle\n"),
829 (flags
& wxLC_SINGLE_SEL
) ? wxT("sing") : wxT("multip")));
834 void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent
& event
)
836 event
.Check(!m_listCtrl
->HasFlag(wxLC_SINGLE_SEL
));
839 void MyFrame::OnUpdateToggleHeader(wxUpdateUIEvent
& event
)
841 event
.Check(!m_listCtrl
->HasFlag(wxLC_NO_HEADER
));
844 void MyFrame::OnUpdateRowLines(wxUpdateUIEvent
& event
)
846 event
.Enable(m_listCtrl
->HasFlag(wxLC_VIRTUAL
));
849 void MyFrame::OnSetFgColour(wxCommandEvent
& WXUNUSED(event
))
851 m_listCtrl
->SetForegroundColour(wxGetColourFromUser(this));
852 m_listCtrl
->Refresh();
855 void MyFrame::OnSetBgColour(wxCommandEvent
& WXUNUSED(event
))
857 m_listCtrl
->SetBackgroundColour(wxGetColourFromUser(this));
858 m_listCtrl
->Refresh();
861 void MyFrame::OnSetRowLines(wxCommandEvent
& event
)
863 m_listCtrl
->EnableAlternateRowColours(event
.IsChecked());
864 m_listCtrl
->Refresh();
867 void MyFrame::OnAdd(wxCommandEvent
& WXUNUSED(event
))
869 m_listCtrl
->InsertItem(m_listCtrl
->GetItemCount(), wxT("Appended item"));
872 void MyFrame::OnEdit(wxCommandEvent
& WXUNUSED(event
))
874 // demonstrate cancelling editing: this currently is wxMSW-only
875 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
876 if ( m_listCtrl
->GetEditControl() )
878 m_listCtrl
->EndEditLabel(true);
880 else // start editing
883 long itemCur
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
884 wxLIST_STATE_FOCUSED
);
888 m_listCtrl
->EditLabel(itemCur
);
892 m_logWindow
->WriteText(wxT("No item to edit"));
897 void MyFrame::OnDelete(wxCommandEvent
& WXUNUSED(event
))
899 if ( m_listCtrl
->GetItemCount() )
901 m_listCtrl
->DeleteItem(0);
905 m_logWindow
->WriteText(wxT("Nothing to delete"));
909 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
913 int itemCount
= m_listCtrl
->GetItemCount();
915 m_listCtrl
->DeleteAllItems();
917 m_logWindow
->WriteText(wxString::Format(wxT("Deleting %d items took %ld ms\n"),
923 // ----------------------------------------------------------------------------
925 // ----------------------------------------------------------------------------
927 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
928 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
929 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
930 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
931 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
932 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
933 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
934 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
935 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
936 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
937 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
938 EVT_LIST_ITEM_FOCUSED(LIST_CTRL
, MyListCtrl::OnFocused
)
940 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
941 EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL
, MyListCtrl::OnColRightClick
)
942 EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnColBeginDrag
)
943 EVT_LIST_COL_DRAGGING(LIST_CTRL
, MyListCtrl::OnColDragging
)
944 EVT_LIST_COL_END_DRAG(LIST_CTRL
, MyListCtrl::OnColEndDrag
)
946 EVT_LIST_CACHE_HINT(LIST_CTRL
, MyListCtrl::OnCacheHint
)
949 EVT_CONTEXT_MENU(MyListCtrl::OnContextMenu
)
951 EVT_CHAR(MyListCtrl::OnChar
)
953 EVT_RIGHT_DOWN(MyListCtrl::OnRightClick
)
956 void MyListCtrl::OnCacheHint(wxListEvent
& event
)
958 wxLogMessage( wxT("OnCacheHint: cache items %ld..%ld"),
959 event
.GetCacheFrom(), event
.GetCacheTo() );
962 void MyListCtrl::SetColumnImage(int col
, int image
)
965 item
.SetMask(wxLIST_MASK_IMAGE
);
966 item
.SetImage(image
);
967 SetColumn(col
, item
);
970 void MyListCtrl::OnColClick(wxListEvent
& event
)
972 int col
= event
.GetColumn();
974 // set or unset image
975 static bool x
= false;
977 SetColumnImage(col
, x
? 0 : -1);
979 wxLogMessage( wxT("OnColumnClick at %d."), col
);
982 void MyListCtrl::OnColRightClick(wxListEvent
& event
)
984 int col
= event
.GetColumn();
987 SetColumnImage(col
, -1);
990 // Show popupmenu at position
991 wxMenu
menu(wxT("Test"));
992 menu
.Append(LIST_ABOUT
, wxT("&About"));
993 PopupMenu(&menu
, event
.GetPoint());
995 wxLogMessage( wxT("OnColumnRightClick at %d."), event
.GetColumn() );
998 void MyListCtrl::LogColEvent(const wxListEvent
& event
, const wxChar
*name
)
1000 const int col
= event
.GetColumn();
1002 wxLogMessage(wxT("%s: column %d (width = %d or %d)."),
1005 event
.GetItem().GetWidth(),
1006 GetColumnWidth(col
));
1009 void MyListCtrl::OnColBeginDrag(wxListEvent
& event
)
1011 LogColEvent( event
, wxT("OnColBeginDrag") );
1013 if ( event
.GetColumn() == 0 )
1015 wxLogMessage(wxT("Resizing this column shouldn't work."));
1021 void MyListCtrl::OnColDragging(wxListEvent
& event
)
1023 LogColEvent( event
, wxT("OnColDragging") );
1026 void MyListCtrl::OnColEndDrag(wxListEvent
& event
)
1028 LogColEvent( event
, wxT("OnColEndDrag") );
1031 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
1033 const wxPoint
& pt
= event
.m_pointDrag
;
1036 wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
1037 pt
.x
, pt
.y
, HitTest(pt
, flags
) );
1040 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
1042 wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
1043 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
1046 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
1048 wxLogMessage( wxT("OnBeginLabelEdit: %s"), event
.m_item
.m_text
.c_str());
1050 wxTextCtrl
* const text
= GetEditControl();
1053 wxLogMessage("BUG: started to edit but no edit control");
1057 wxLogMessage("Edit control value: \"%s\"", text
->GetValue());
1061 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
1063 wxLogMessage( wxT("OnEndLabelEdit: %s"),
1065 event
.IsEditCancelled() ?
1066 wxString("[cancelled]") :
1072 void MyListCtrl::OnDeleteItem(wxListEvent
& event
)
1074 LogEvent(event
, wxT("OnDeleteItem"));
1075 wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
1078 void MyListCtrl::OnDeleteAllItems(wxListEvent
& event
)
1080 LogEvent(event
, wxT("OnDeleteAllItems"));
1083 void MyListCtrl::OnSelected(wxListEvent
& event
)
1085 LogEvent(event
, wxT("OnSelected"));
1087 if ( GetWindowStyle() & wxLC_REPORT
)
1090 info
.m_itemId
= event
.m_itemIndex
;
1092 info
.m_mask
= wxLIST_MASK_TEXT
;
1093 if ( GetItem(info
) )
1095 wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
1096 info
.m_text
.c_str());
1100 wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
1105 void MyListCtrl::OnDeselected(wxListEvent
& event
)
1107 LogEvent(event
, wxT("OnDeselected"));
1110 void MyListCtrl::OnActivated(wxListEvent
& event
)
1112 LogEvent(event
, wxT("OnActivated"));
1115 void MyListCtrl::OnFocused(wxListEvent
& event
)
1117 LogEvent(event
, wxT("OnFocused"));
1122 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
1126 if ( !wxGetKeyState(WXK_SHIFT
) )
1128 LogEvent(event
, wxT("OnListKeyDown"));
1133 switch ( event
.GetKeyCode() )
1135 case 'C': // colorize
1138 info
.m_itemId
= event
.GetIndex();
1139 if ( info
.m_itemId
== -1 )
1147 wxListItemAttr
*attr
= info
.GetAttributes();
1148 if ( !attr
|| !attr
->HasTextColour() )
1150 info
.SetTextColour(*wxCYAN
);
1154 RefreshItem(info
.m_itemId
);
1160 item
= GetNextItem(-1, wxLIST_NEXT_ALL
, wxLIST_STATE_FOCUSED
);
1161 if ( item
++ == GetItemCount() - 1 )
1166 wxLogMessage(wxT("Focusing item %ld"), item
);
1168 SetItemState(item
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
1169 EnsureVisible(item
);
1172 case 'R': // show bounding rectangle
1174 item
= event
.GetIndex();
1176 if ( !GetItemRect(item
, r
) )
1178 wxLogError(wxT("Failed to retrieve rect of item %ld"), item
);
1182 wxLogMessage(wxT("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
1183 item
, r
.x
, r
.y
, r
.x
+ r
.width
, r
.y
+ r
.height
);
1187 case '1': // show sub item bounding rectangle for the given column
1188 case '2': // (and icon/label rectangle if Shift/Ctrl is pressed)
1190 case '4': // this column is invalid but we want to test it too
1191 if ( InReportView() )
1193 int subItem
= event
.GetKeyCode() - '1';
1194 item
= event
.GetIndex();
1197 int code
= wxLIST_RECT_BOUNDS
;
1198 if ( wxGetKeyState(WXK_SHIFT
) )
1199 code
= wxLIST_RECT_ICON
;
1200 else if ( wxGetKeyState(WXK_CONTROL
) )
1201 code
= wxLIST_RECT_LABEL
;
1203 if ( !GetSubItemRect(item
, subItem
, r
, code
) )
1205 wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item
, subItem
+ 1);
1209 wxLogMessage(wxT("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)"),
1211 r
.x
, r
.y
, r
.x
+ r
.width
, r
.y
+ r
.height
);
1219 if ( m_updated
!= -1 )
1220 RefreshItem(m_updated
);
1222 m_updated
= event
.GetIndex();
1223 if ( m_updated
!= -1 )
1225 // we won't see changes to this item as it's selected, update
1226 // the next one (or the first one if we're on the last item)
1227 if ( ++m_updated
== GetItemCount() )
1230 wxLogMessage("Updating colour of the item %ld", m_updated
);
1231 RefreshItem(m_updated
);
1236 item
= GetNextItem(-1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1237 while ( item
!= -1 )
1241 wxLogMessage(wxT("Item %ld deleted"), item
);
1243 // -1 because the indices were shifted by DeleteItem()
1244 item
= GetNextItem(item
- 1,
1245 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1250 if ( GetWindowStyle() & wxLC_REPORT
)
1252 if ( GetWindowStyle() & wxLC_VIRTUAL
)
1254 SetItemCount(GetItemCount() + 1);
1258 InsertItemInReportView(event
.GetIndex());
1261 //else: fall through
1264 LogEvent(event
, wxT("OnListKeyDown"));
1270 void MyListCtrl::OnChar(wxKeyEvent
& event
)
1272 wxLogMessage(wxT("Got char event."));
1277 void MyListCtrl::OnRightClick(wxMouseEvent
& event
)
1279 if ( !event
.ControlDown() )
1287 long item
= HitTest(event
.GetPosition(), flags
, &subitem
);
1292 case wxLIST_HITTEST_ABOVE
: where
= wxT("above"); break;
1293 case wxLIST_HITTEST_BELOW
: where
= wxT("below"); break;
1294 case wxLIST_HITTEST_NOWHERE
: where
= wxT("nowhere near"); break;
1295 case wxLIST_HITTEST_ONITEMICON
: where
= wxT("on icon of"); break;
1296 case wxLIST_HITTEST_ONITEMLABEL
: where
= wxT("on label of"); break;
1297 case wxLIST_HITTEST_ONITEMRIGHT
: where
= wxT("right on"); break;
1298 case wxLIST_HITTEST_TOLEFT
: where
= wxT("to the left of"); break;
1299 case wxLIST_HITTEST_TORIGHT
: where
= wxT("to the right of"); break;
1300 default: where
= wxT("not clear exactly where on"); break;
1303 wxLogMessage(wxT("Right double click %s item %ld, subitem %ld"),
1304 where
.c_str(), item
, subitem
);
1307 void MyListCtrl::LogEvent(const wxListEvent
& event
, const wxChar
*eventName
)
1309 wxLogMessage(wxT("Item %ld: %s (item text = %s, data = %ld)"),
1310 event
.GetIndex(), eventName
,
1311 event
.GetText().c_str(), event
.GetData());
1314 wxString
MyListCtrl::OnGetItemText(long item
, long column
) const
1316 if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS
) )
1318 return SMALL_VIRTUAL_VIEW_ITEMS
[item
][column
];
1320 else // "big" virtual control
1322 return wxString::Format(wxT("Column %ld of item %ld"), column
, item
);
1326 int MyListCtrl::OnGetItemColumnImage(long item
, long column
) const
1331 if (!(item
% 3) && column
== 1)
1337 wxListItemAttr
*MyListCtrl::OnGetItemAttr(long item
) const
1339 // test to check that RefreshItem() works correctly: when m_updated is
1340 // set to some item and it is refreshed, we highlight the item
1341 if ( item
== m_updated
)
1343 static wxListItemAttr
s_attrHighlight(*wxRED
, wxNullColour
, wxNullFont
);
1344 return &s_attrHighlight
;
1347 return wxListCtrl::OnGetItemAttr(item
);
1350 void MyListCtrl::InsertItemInReportView(int i
)
1353 buf
.Printf(wxT("This is item %d"), i
);
1354 long tmp
= InsertItem(i
, buf
, 0);
1355 SetItemData(tmp
, i
);
1357 buf
.Printf(wxT("Col 1, item %d"), i
);
1358 SetItem(tmp
, 1, buf
);
1360 buf
.Printf(wxT("Item %d in column 2"), i
);
1361 SetItem(tmp
, 2, buf
);
1364 #if USE_CONTEXT_MENU
1365 void MyListCtrl::OnContextMenu(wxContextMenuEvent
& event
)
1367 if (GetEditControl() == NULL
)
1369 wxPoint point
= event
.GetPosition();
1371 if ( (point
.x
== -1) && (point
.y
== -1) )
1373 wxSize size
= GetSize();
1374 point
.x
= size
.x
/ 2;
1375 point
.y
= size
.y
/ 2;
1379 point
= ScreenToClient(point
);
1381 ShowContextMenu(point
);
1385 // the user is editing:
1386 // allow the text control to display its context menu
1387 // if it has one (it has on Windows) rather than display our one
1393 void MyListCtrl::ShowContextMenu(const wxPoint
& pos
)
1397 menu
.Append(wxID_ABOUT
, wxT("&About"));
1398 menu
.AppendSeparator();
1399 menu
.Append(wxID_EXIT
, wxT("E&xit"));
1401 PopupMenu(&menu
, pos
.x
, pos
.y
);