1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListCtrl sample
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
22 #ifndef wxHAS_IMAGES_IN_RESOURCES
23 #include "../sample.xpm"
26 #ifndef wxHAS_IMAGES_IN_RESOURCES
27 #include "bitmaps/toolbrai.xpm"
28 #include "bitmaps/toolchar.xpm"
29 #include "bitmaps/tooldata.xpm"
30 #include "bitmaps/toolnote.xpm"
31 #include "bitmaps/tooltodo.xpm"
32 #include "bitmaps/toolchec.xpm"
33 #include "bitmaps/toolgame.xpm"
34 #include "bitmaps/tooltime.xpm"
35 #include "bitmaps/toolword.xpm"
36 #include "bitmaps/small1.xpm"
39 #include "wx/imaglist.h"
40 #include "wx/listctrl.h"
41 #include "wx/timer.h" // for wxStopWatch
42 #include "wx/colordlg.h" // for wxGetColourFromUser
43 #include "wx/settings.h"
44 #include "wx/sysopt.h"
45 #include "wx/numdlg.h"
50 // ----------------------------------------------------------------------------
51 // Constants and globals
52 // ----------------------------------------------------------------------------
54 const wxChar
*SMALL_VIRTUAL_VIEW_ITEMS
[][2] =
56 { wxT("Cat"), wxT("meow") },
57 { wxT("Cow"), wxT("moo") },
58 { wxT("Crow"), wxT("caw") },
59 { wxT("Dog"), wxT("woof") },
60 { wxT("Duck"), wxT("quack") },
61 { wxT("Mouse"), wxT("squeak") },
62 { wxT("Owl"), wxT("hoo") },
63 { wxT("Pig"), wxT("oink") },
64 { wxT("Pigeon"), wxT("coo") },
65 { wxT("Sheep"), wxT("baaah") },
68 // number of items in icon/small icon view
69 static const int NUM_ICONS
= 9;
72 MyCompareFunction(wxIntPtr item1
, wxIntPtr item2
, wxIntPtr
WXUNUSED(sortData
))
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
90 // `Main program' equivalent, creating windows and returning main app frame
93 if ( !wxApp::OnInit() )
96 // Create the main frame window
97 MyFrame
*frame
= new MyFrame(wxT("wxListCtrl Test"));
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
112 EVT_SIZE(MyFrame::OnSize
)
114 EVT_MENU(LIST_QUIT
, MyFrame::OnQuit
)
115 EVT_MENU(LIST_ABOUT
, MyFrame::OnAbout
)
116 EVT_MENU(LIST_LIST_VIEW
, MyFrame::OnListView
)
117 EVT_MENU(LIST_REPORT_VIEW
, MyFrame::OnReportView
)
118 EVT_MENU(LIST_ICON_VIEW
, MyFrame::OnIconView
)
119 EVT_MENU(LIST_ICON_TEXT_VIEW
, MyFrame::OnIconTextView
)
120 EVT_MENU(LIST_SMALL_ICON_VIEW
, MyFrame::OnSmallIconView
)
121 EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW
, MyFrame::OnSmallIconTextView
)
122 EVT_MENU(LIST_VIRTUAL_VIEW
, MyFrame::OnVirtualView
)
123 EVT_MENU(LIST_SMALL_VIRTUAL_VIEW
, MyFrame::OnSmallVirtualView
)
125 EVT_MENU(LIST_SET_ITEMS_COUNT
, MyFrame::OnSetItemsCount
)
127 EVT_MENU(LIST_GOTO
, MyFrame::OnGoTo
)
128 EVT_MENU(LIST_FOCUS_LAST
, MyFrame::OnFocusLast
)
129 EVT_MENU(LIST_TOGGLE_FIRST
, MyFrame::OnToggleFirstSel
)
130 EVT_MENU(LIST_DESELECT_ALL
, MyFrame::OnDeselectAll
)
131 EVT_MENU(LIST_SELECT_ALL
, MyFrame::OnSelectAll
)
132 EVT_MENU(LIST_DELETE
, MyFrame::OnDelete
)
133 EVT_MENU(LIST_ADD
, MyFrame::OnAdd
)
134 EVT_MENU(LIST_EDIT
, MyFrame::OnEdit
)
135 EVT_MENU(LIST_DELETE_ALL
, MyFrame::OnDeleteAll
)
136 EVT_MENU(LIST_SORT
, MyFrame::OnSort
)
137 EVT_MENU(LIST_SET_FG_COL
, MyFrame::OnSetFgColour
)
138 EVT_MENU(LIST_SET_BG_COL
, MyFrame::OnSetBgColour
)
139 EVT_MENU(LIST_ROW_LINES
, MyFrame::OnSetRowLines
)
140 EVT_MENU(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnToggleMultiSel
)
141 EVT_MENU(LIST_SHOW_COL_INFO
, MyFrame::OnShowColInfo
)
142 EVT_MENU(LIST_SHOW_SEL_INFO
, MyFrame::OnShowSelInfo
)
143 EVT_MENU(LIST_SHOW_VIEW_RECT
, MyFrame::OnShowViewRect
)
144 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
145 EVT_MENU(LIST_SET_COL_ORDER
, MyFrame::OnSetColOrder
)
146 EVT_MENU(LIST_GET_COL_ORDER
, MyFrame::OnGetColOrder
)
147 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
148 EVT_MENU(LIST_FREEZE
, MyFrame::OnFreeze
)
149 EVT_MENU(LIST_THAW
, MyFrame::OnThaw
)
150 EVT_MENU(LIST_TOGGLE_LINES
, MyFrame::OnToggleLines
)
151 EVT_MENU(LIST_TOGGLE_HEADER
, MyFrame::OnToggleHeader
)
152 EVT_MENU(LIST_TOGGLE_BELL
, MyFrame::OnToggleBell
)
154 EVT_MENU(LIST_MAC_USE_GENERIC
, MyFrame::OnToggleMacUseGeneric
)
156 EVT_MENU(LIST_FIND
, MyFrame::OnFind
)
158 EVT_UPDATE_UI(LIST_SHOW_COL_INFO
, MyFrame::OnUpdateUIEnableInReport
)
159 EVT_UPDATE_UI(LIST_TOGGLE_HEADER
, MyFrame::OnUpdateUIEnableInReport
)
161 EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL
, MyFrame::OnUpdateToggleMultiSel
)
162 EVT_UPDATE_UI(LIST_TOGGLE_HEADER
, MyFrame::OnUpdateToggleHeader
)
163 EVT_UPDATE_UI(LIST_ROW_LINES
, MyFrame::OnUpdateRowLines
)
166 // My frame constructor
167 MyFrame::MyFrame(const wxChar
*title
)
168 : wxFrame(NULL
, wxID_ANY
, title
, wxDefaultPosition
, wxSize(600, 500))
172 m_smallVirtual
= false;
176 SetIcon(wxICON(sample
));
178 // Make an image list containing large icons
179 m_imageListNormal
= new wxImageList(32, 32, true);
180 m_imageListSmall
= new wxImageList(16, 16, true);
182 #ifdef wxHAS_IMAGES_IN_RESOURCES
183 m_imageListNormal
->Add( wxIcon(wxT("icon1"), wxBITMAP_TYPE_ICO_RESOURCE
) );
184 m_imageListNormal
->Add( wxIcon(wxT("icon2"), wxBITMAP_TYPE_ICO_RESOURCE
) );
185 m_imageListNormal
->Add( wxIcon(wxT("icon3"), wxBITMAP_TYPE_ICO_RESOURCE
) );
186 m_imageListNormal
->Add( wxIcon(wxT("icon4"), wxBITMAP_TYPE_ICO_RESOURCE
) );
187 m_imageListNormal
->Add( wxIcon(wxT("icon5"), wxBITMAP_TYPE_ICO_RESOURCE
) );
188 m_imageListNormal
->Add( wxIcon(wxT("icon6"), wxBITMAP_TYPE_ICO_RESOURCE
) );
189 m_imageListNormal
->Add( wxIcon(wxT("icon7"), wxBITMAP_TYPE_ICO_RESOURCE
) );
190 m_imageListNormal
->Add( wxIcon(wxT("icon8"), wxBITMAP_TYPE_ICO_RESOURCE
) );
191 m_imageListNormal
->Add( wxIcon(wxT("icon9"), wxBITMAP_TYPE_ICO_RESOURCE
) );
193 m_imageListSmall
->Add( wxIcon(wxT("iconsmall"), wxBITMAP_TYPE_ICO_RESOURCE
) );
196 m_imageListNormal
->Add( wxIcon( toolbrai_xpm
) );
197 m_imageListNormal
->Add( wxIcon( toolchar_xpm
) );
198 m_imageListNormal
->Add( wxIcon( tooldata_xpm
) );
199 m_imageListNormal
->Add( wxIcon( toolnote_xpm
) );
200 m_imageListNormal
->Add( wxIcon( tooltodo_xpm
) );
201 m_imageListNormal
->Add( wxIcon( toolchec_xpm
) );
202 m_imageListNormal
->Add( wxIcon( toolgame_xpm
) );
203 m_imageListNormal
->Add( wxIcon( tooltime_xpm
) );
204 m_imageListNormal
->Add( wxIcon( toolword_xpm
) );
206 m_imageListSmall
->Add( wxIcon( small1_xpm
) );
210 wxMenu
*menuFile
= new wxMenu
;
211 menuFile
->Append(LIST_ABOUT
, wxT("&About"));
212 menuFile
->AppendSeparator();
213 menuFile
->Append(LIST_QUIT
, wxT("E&xit\tAlt-X"));
215 wxMenu
*menuView
= new wxMenu
;
216 menuView
->Append(LIST_LIST_VIEW
, wxT("&List view\tF1"));
217 menuView
->Append(LIST_REPORT_VIEW
, wxT("&Report view\tF2"));
218 menuView
->Append(LIST_ICON_VIEW
, wxT("&Icon view\tF3"));
219 menuView
->Append(LIST_ICON_TEXT_VIEW
, wxT("Icon view with &text\tF4"));
220 menuView
->Append(LIST_SMALL_ICON_VIEW
, wxT("&Small icon view\tF5"));
221 menuView
->Append(LIST_SMALL_ICON_TEXT_VIEW
, wxT("Small icon &view with text\tF6"));
222 menuView
->Append(LIST_VIRTUAL_VIEW
, wxT("&Virtual view\tF7"));
223 menuView
->Append(LIST_SMALL_VIRTUAL_VIEW
, wxT("Small virtual vie&w\tF8"));
224 menuView
->AppendSeparator();
225 menuView
->Append(LIST_SET_ITEMS_COUNT
, "Set &number of items");
227 menuView
->AppendSeparator();
228 menuView
->AppendCheckItem(LIST_MAC_USE_GENERIC
, wxT("Mac: Use Generic Control"));
231 wxMenu
*menuList
= new wxMenu
;
232 menuList
->Append(LIST_GOTO
, wxT("&Go to item #3\tCtrl-3"));
233 menuList
->Append(LIST_FOCUS_LAST
, wxT("&Make last item current\tCtrl-L"));
234 menuList
->Append(LIST_TOGGLE_FIRST
, wxT("To&ggle first item\tCtrl-G"));
235 menuList
->Append(LIST_DESELECT_ALL
, wxT("&Deselect All\tCtrl-D"));
236 menuList
->Append(LIST_SELECT_ALL
, wxT("S&elect All\tCtrl-A"));
237 menuList
->AppendSeparator();
238 menuList
->Append(LIST_SHOW_COL_INFO
, wxT("Show &column info\tCtrl-C"));
239 menuList
->Append(LIST_SHOW_SEL_INFO
, wxT("Show &selected items\tCtrl-S"));
240 menuList
->Append(LIST_SHOW_VIEW_RECT
, wxT("Show &view rect"));
241 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
242 menuList
->Append(LIST_SET_COL_ORDER
, wxT("Se&t columns order\tShift-Ctrl-O"));
243 menuList
->Append(LIST_GET_COL_ORDER
, wxT("Sho&w columns order\tCtrl-O"));
244 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
245 menuList
->AppendSeparator();
246 menuList
->Append(LIST_SORT
, wxT("Sor&t\tCtrl-T"));
247 menuList
->Append(LIST_FIND
, "Test Find() performance");
248 menuList
->AppendSeparator();
249 menuList
->Append(LIST_ADD
, wxT("&Append an item\tCtrl-P"));
250 menuList
->Append(LIST_EDIT
, wxT("&Edit the item\tCtrl-E"));
251 menuList
->Append(LIST_DELETE
, wxT("&Delete first item\tCtrl-X"));
252 menuList
->Append(LIST_DELETE_ALL
, wxT("Delete &all items"));
253 menuList
->AppendSeparator();
254 menuList
->Append(LIST_FREEZE
, wxT("Free&ze\tCtrl-Z"));
255 menuList
->Append(LIST_THAW
, wxT("Tha&w\tCtrl-W"));
256 menuList
->AppendSeparator();
257 menuList
->AppendCheckItem(LIST_TOGGLE_LINES
, wxT("Toggle &lines\tCtrl-I"));
258 menuList
->AppendCheckItem(LIST_TOGGLE_MULTI_SEL
,
259 wxT("&Multiple selection\tCtrl-M"));
260 menuList
->Check(LIST_TOGGLE_MULTI_SEL
, true);
261 menuList
->AppendCheckItem(LIST_TOGGLE_HEADER
, "Toggle &header\tCtrl-H");
262 menuList
->Check(LIST_TOGGLE_HEADER
, true);
263 menuList
->AppendCheckItem(LIST_TOGGLE_BELL
, "Toggle &bell on no match");
265 wxMenu
*menuCol
= new wxMenu
;
266 menuCol
->Append(LIST_SET_FG_COL
, wxT("&Foreground colour..."));
267 menuCol
->Append(LIST_SET_BG_COL
, wxT("&Background colour..."));
268 menuCol
->AppendCheckItem(LIST_ROW_LINES
, wxT("Alternating colours"));
270 wxMenuBar
*menubar
= new wxMenuBar
;
271 menubar
->Append(menuFile
, wxT("&File"));
272 menubar
->Append(menuView
, wxT("&View"));
273 menubar
->Append(menuList
, wxT("&List"));
274 menubar
->Append(menuCol
, wxT("&Colour"));
277 m_panel
= new wxPanel(this, wxID_ANY
);
278 m_logWindow
= new wxTextCtrl(m_panel
, wxID_ANY
, wxEmptyString
,
279 wxDefaultPosition
, wxDefaultSize
,
280 wxTE_READONLY
| wxTE_MULTILINE
| wxSUNKEN_BORDER
);
282 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_logWindow
));
284 RecreateList(wxLC_REPORT
| wxLC_SINGLE_SEL
);
287 // this is useful to know specially when debugging :)
288 wxLogMessage("Your version of comctl32.dll is: %d",
289 wxApp::GetComCtl32Version());
294 #endif // wxUSE_STATUSBAR
299 delete wxLog::SetActiveTarget(m_logOld
);
301 delete m_imageListNormal
;
302 delete m_imageListSmall
;
305 void MyFrame::OnSize(wxSizeEvent
& event
)
312 void MyFrame::DoSize()
317 wxSize size
= GetClientSize();
318 wxCoord y
= (2*size
.y
)/3;
319 m_listCtrl
->SetSize(0, 0, size
.x
, y
);
320 m_logWindow
->SetSize(0, y
+ 1, size
.x
, size
.y
- y
-1);
323 bool MyFrame::CheckNonVirtual() const
325 if ( !m_listCtrl
->HasFlag(wxLC_VIRTUAL
) )
328 // "this" == whatever
329 wxLogWarning(wxT("Can't do this in virtual view, sorry."));
334 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
339 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
341 wxMessageDialog
dialog(this, wxT("List test sample\nJulian Smart (c) 1997"),
342 wxT("About list test"));
347 void MyFrame::OnFreeze(wxCommandEvent
& WXUNUSED(event
))
349 wxLogMessage(wxT("Freezing the control"));
351 m_listCtrl
->Freeze();
354 void MyFrame::OnThaw(wxCommandEvent
& WXUNUSED(event
))
356 wxLogMessage(wxT("Thawing the control"));
361 void MyFrame::OnToggleLines(wxCommandEvent
& event
)
363 m_listCtrl
->SetSingleStyle(wxLC_HRULES
| wxLC_VRULES
, event
.IsChecked());
366 void MyFrame::OnToggleHeader(wxCommandEvent
& event
)
368 wxLogMessage("%s the header", event
.IsChecked() ? "Showing" : "Hiding");
370 m_listCtrl
->ToggleWindowStyle(wxLC_NO_HEADER
);
373 void MyFrame::OnToggleBell(wxCommandEvent
& event
)
375 m_listCtrl
->EnableBellOnNoMatch(event
.IsChecked());
380 void MyFrame::OnToggleMacUseGeneric(wxCommandEvent
& event
)
382 wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), event
.IsChecked());
387 void MyFrame::OnGoTo(wxCommandEvent
& WXUNUSED(event
))
390 m_listCtrl
->SetItemState(index
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
392 long sel
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
393 wxLIST_STATE_SELECTED
);
395 m_listCtrl
->SetItemState(sel
, 0, wxLIST_STATE_SELECTED
);
396 m_listCtrl
->SetItemState(index
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
399 void MyFrame::OnFocusLast(wxCommandEvent
& WXUNUSED(event
))
401 long index
= m_listCtrl
->GetItemCount() - 1;
407 m_listCtrl
->SetItemState(index
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
408 m_listCtrl
->EnsureVisible(index
);
411 void MyFrame::OnToggleFirstSel(wxCommandEvent
& WXUNUSED(event
))
413 m_listCtrl
->SetItemState(0, (~m_listCtrl
->GetItemState(0, wxLIST_STATE_SELECTED
) ) & wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
416 void MyFrame::OnDeselectAll(wxCommandEvent
& WXUNUSED(event
))
418 if ( !CheckNonVirtual() )
421 int n
= m_listCtrl
->GetItemCount();
422 for (int i
= 0; i
< n
; i
++)
423 m_listCtrl
->SetItemState(i
,0,wxLIST_STATE_SELECTED
);
426 void MyFrame::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
428 if ( !CheckNonVirtual() )
431 int n
= m_listCtrl
->GetItemCount();
432 for (int i
= 0; i
< n
; i
++)
433 m_listCtrl
->SetItemState(i
,wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
436 // ----------------------------------------------------------------------------
437 // changing listctrl modes
438 // ----------------------------------------------------------------------------
440 void MyFrame::RecreateList(long flags
, bool withText
)
442 // we could avoid recreating it if we don't set/clear the wxLC_VIRTUAL
443 // style, but it is more trouble to do it than not
445 if ( !m_listCtrl
|| ((flags
& wxLC_VIRTUAL
) !=
446 (m_listCtrl
->GetWindowStyleFlag() & wxLC_VIRTUAL
)) )
451 m_listCtrl
= new MyListCtrl(m_panel
, LIST_CTRL
,
452 wxDefaultPosition
, wxDefaultSize
,
454 wxBORDER_THEME
| wxLC_EDIT_LABELS
);
456 switch ( flags
& wxLC_MASK_TYPE
)
463 InitWithIconItems(withText
);
466 case wxLC_SMALL_ICON
:
467 InitWithIconItems(withText
, true);
471 if ( flags
& wxLC_VIRTUAL
)
472 InitWithVirtualItems();
474 InitWithReportItems();
478 wxFAIL_MSG( wxT("unknown listctrl mode") );
481 wxMenuBar
* const mb
= GetMenuBar();
483 m_listCtrl
->EnableBellOnNoMatch(mb
->IsChecked(LIST_TOGGLE_BELL
));
488 GetMenuBar()->Check(LIST_ROW_LINES
, false);
490 m_logWindow
->Clear();
493 void MyFrame::OnListView(wxCommandEvent
& WXUNUSED(event
))
495 RecreateList(wxLC_LIST
);
498 void MyFrame::InitWithListItems()
500 for ( int i
= 0; i
< m_numListItems
; i
++ )
502 m_listCtrl
->InsertItem(i
, wxString::Format(wxT("Item %d"), i
));
506 void MyFrame::OnReportView(wxCommandEvent
& WXUNUSED(event
))
508 RecreateList(wxLC_REPORT
);
511 void MyFrame::InitWithReportItems()
513 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
515 // note that under MSW for SetColumnWidth() to work we need to create the
516 // items with images initially even if we specify dummy image id
518 itemCol
.SetText(wxT("Column 1"));
519 itemCol
.SetImage(-1);
520 m_listCtrl
->InsertColumn(0, itemCol
);
522 itemCol
.SetText(wxT("Column 2"));
523 itemCol
.SetAlign(wxLIST_FORMAT_CENTRE
);
524 m_listCtrl
->InsertColumn(1, itemCol
);
526 itemCol
.SetText(wxT("Column 3"));
527 itemCol
.SetAlign(wxLIST_FORMAT_RIGHT
);
528 m_listCtrl
->InsertColumn(2, itemCol
);
530 // to speed up inserting we hide the control temporarily
535 for ( int i
= 0; i
< m_numListItems
; i
++ )
537 m_listCtrl
->InsertItemInReportView(i
);
540 m_logWindow
->WriteText(wxString::Format(wxT("%d items inserted in %ldms\n"),
541 m_numListItems
, sw
.Time()));
544 // we leave all mask fields to 0 and only change the colour
547 item
.SetTextColour(*wxRED
);
548 m_listCtrl
->SetItem( item
);
551 item
.SetTextColour(*wxGREEN
);
552 m_listCtrl
->SetItem( item
);
554 item
.SetTextColour(*wxLIGHT_GREY
);
555 item
.SetFont(*wxITALIC_FONT
);
556 item
.SetBackgroundColour(*wxRED
);
557 m_listCtrl
->SetItem( item
);
559 m_listCtrl
->SetTextColour(*wxBLUE
);
561 m_listCtrl
->SetColumnWidth( 0, wxLIST_AUTOSIZE
);
562 m_listCtrl
->SetColumnWidth( 1, wxLIST_AUTOSIZE
);
563 m_listCtrl
->SetColumnWidth( 2, wxLIST_AUTOSIZE
);
565 // Set images in columns
566 m_listCtrl
->SetItemColumnImage(1, 1, 0);
572 m_listCtrl
->SetItem(info
);
574 // test SetItemFont too
575 m_listCtrl
->SetItemFont(0, *wxITALIC_FONT
);
578 void MyFrame::InitWithIconItems(bool withText
, bool sameIcon
)
580 m_listCtrl
->SetImageList(m_imageListNormal
, wxIMAGE_LIST_NORMAL
);
581 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
583 for ( int i
= 0; i
< NUM_ICONS
; i
++ )
585 int image
= sameIcon
? 0 : i
;
589 // Make labels of different widths to test the layout.
592 label
.Printf("Longer label %d", i
);
594 label
.Printf("Label %d", i
);
596 m_listCtrl
->InsertItem(i
, label
, image
);
600 m_listCtrl
->InsertItem(i
, image
);
605 void MyFrame::OnIconView(wxCommandEvent
& WXUNUSED(event
))
607 RecreateList(wxLC_ICON
, false);
610 void MyFrame::OnIconTextView(wxCommandEvent
& WXUNUSED(event
))
612 RecreateList(wxLC_ICON
);
615 void MyFrame::OnSmallIconView(wxCommandEvent
& WXUNUSED(event
))
617 RecreateList(wxLC_SMALL_ICON
, false);
620 void MyFrame::OnSmallIconTextView(wxCommandEvent
& WXUNUSED(event
))
622 RecreateList(wxLC_SMALL_ICON
);
625 void MyFrame::OnVirtualView(wxCommandEvent
& WXUNUSED(event
))
627 m_smallVirtual
= false;
628 RecreateList(wxLC_REPORT
| wxLC_VIRTUAL
);
631 void MyFrame::OnSmallVirtualView(wxCommandEvent
& WXUNUSED(event
))
633 m_smallVirtual
= true;
634 RecreateList(wxLC_REPORT
| wxLC_VIRTUAL
);
637 void MyFrame::OnSetItemsCount(wxCommandEvent
& WXUNUSED(event
))
639 int numItems
= wxGetNumberFromUser
641 "Enter the initial number of items for "
642 "the list and report views",
644 "wxWidgets wxListCtrl sample",
650 if ( numItems
== -1 || numItems
== m_numListItems
)
653 m_numListItems
= numItems
;
655 if ( m_listCtrl
->HasFlag(wxLC_REPORT
) &&
656 !m_listCtrl
->HasFlag(wxLC_VIRTUAL
) )
657 RecreateList(wxLC_REPORT
);
658 else if ( m_listCtrl
->HasFlag(wxLC_LIST
) )
659 RecreateList(wxLC_LIST
);
662 void MyFrame::InitWithVirtualItems()
664 m_listCtrl
->SetImageList(m_imageListSmall
, wxIMAGE_LIST_SMALL
);
666 if ( m_smallVirtual
)
668 m_listCtrl
->AppendColumn(wxT("Animal"));
669 m_listCtrl
->AppendColumn(wxT("Sound"));
670 m_listCtrl
->SetItemCount(WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS
));
674 m_listCtrl
->AppendColumn(wxT("First Column"));
675 m_listCtrl
->AppendColumn(wxT("Second Column"));
676 m_listCtrl
->SetColumnWidth(0, 150);
677 m_listCtrl
->SetColumnWidth(1, 150);
678 m_listCtrl
->SetItemCount(1000000);
682 void MyFrame::OnSort(wxCommandEvent
& WXUNUSED(event
))
686 m_listCtrl
->SortItems(MyCompareFunction
, 0);
688 m_logWindow
->WriteText(wxString::Format(wxT("Sorting %d items took %ld ms\n"),
689 m_listCtrl
->GetItemCount(),
693 void MyFrame::OnFind(wxCommandEvent
& WXUNUSED(event
))
697 const int itemCount
= m_listCtrl
->GetItemCount();
698 for ( int i
= 0; i
< itemCount
; i
++ )
699 m_listCtrl
->FindItem(-1, i
);
701 wxLogMessage("Calling Find() for all %d items took %ld ms",
702 itemCount
, sw
.Time());
705 void MyFrame::OnShowSelInfo(wxCommandEvent
& WXUNUSED(event
))
707 int selCount
= m_listCtrl
->GetSelectedItemCount();
708 wxLogMessage(wxT("%d items selected:"), selCount
);
710 // don't show too many items
711 size_t shownCount
= 0;
713 long item
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
714 wxLIST_STATE_SELECTED
);
717 wxLogMessage(wxT("\t%ld (%s)"),
718 item
, m_listCtrl
->GetItemText(item
).c_str());
720 if ( ++shownCount
> 10 )
722 wxLogMessage(wxT("\t... more selected items snipped..."));
726 item
= m_listCtrl
->GetNextItem(item
, wxLIST_NEXT_ALL
,
727 wxLIST_STATE_SELECTED
);
731 void MyFrame::OnShowViewRect(wxCommandEvent
& WXUNUSED(event
))
733 const wxRect r
= m_listCtrl
->GetViewRect();
734 wxLogMessage("View rect: (%d, %d)-(%d, %d)",
735 r
.GetLeft(), r
.GetTop(), r
.GetRight(), r
.GetBottom());
738 // ----------------------------------------------------------------------------
739 // column order tests
740 // ----------------------------------------------------------------------------
742 #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
744 static wxString
DumpIntArray(const wxArrayInt
& a
)
747 const size_t count
= a
.size();
748 for ( size_t n
= 0; n
< count
; n
++ )
752 s
+= wxString::Format("%lu", (unsigned long)a
[n
]);
760 void MyFrame::OnSetColOrder(wxCommandEvent
& WXUNUSED(event
))
766 if ( m_listCtrl
->SetColumnsOrder(order
) )
768 wxLogMessage("Column order set to %s", DumpIntArray(order
));
772 void MyFrame::OnGetColOrder(wxCommandEvent
& WXUNUSED(event
))
774 // show what GetColumnsOrder() returns
775 const wxArrayInt order
= m_listCtrl
->GetColumnsOrder();
776 wxString msg
= "Columns order: " +
777 DumpIntArray(m_listCtrl
->GetColumnsOrder()) + "\n";
780 const int count
= m_listCtrl
->GetColumnCount();
782 // show the results of GetColumnOrder() for each column
783 msg
+= "GetColumnOrder() results:\n";
784 for ( n
= 0; n
< count
; n
++ )
786 msg
+= wxString::Format(" %2d -> %2d\n",
787 n
, m_listCtrl
->GetColumnOrder(n
));
790 // and the results of GetColumnIndexFromOrder() too
791 msg
+= "GetColumnIndexFromOrder() results:\n";
792 for ( n
= 0; n
< count
; n
++ )
794 msg
+= wxString::Format(" %2d -> %2d\n",
795 n
, m_listCtrl
->GetColumnIndexFromOrder(n
));
798 wxLogMessage("%s", msg
);
801 #endif // wxHAS_LISTCTRL_COLUMN_ORDER
803 void MyFrame::OnShowColInfo(wxCommandEvent
& WXUNUSED(event
))
805 int count
= m_listCtrl
->GetColumnCount();
806 wxLogMessage(wxT("%d columns:"), count
);
807 for ( int c
= 0; c
< count
; c
++ )
809 wxLogMessage(wxT("\tcolumn %d has width %d"), c
,
810 m_listCtrl
->GetColumnWidth(c
));
814 void MyFrame::OnUpdateUIEnableInReport(wxUpdateUIEvent
& event
)
816 event
.Enable( (m_listCtrl
->GetWindowStyleFlag() & wxLC_REPORT
) != 0 );
819 void MyFrame::OnToggleMultiSel(wxCommandEvent
& WXUNUSED(event
))
821 long flags
= m_listCtrl
->GetWindowStyleFlag();
822 if ( flags
& wxLC_SINGLE_SEL
)
823 flags
&= ~wxLC_SINGLE_SEL
;
825 flags
|= wxLC_SINGLE_SEL
;
827 m_logWindow
->WriteText(wxString::Format(wxT("Current selection mode: %sle\n"),
828 (flags
& wxLC_SINGLE_SEL
) ? wxT("sing") : wxT("multip")));
833 void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent
& event
)
835 event
.Check(!m_listCtrl
->HasFlag(wxLC_SINGLE_SEL
));
838 void MyFrame::OnUpdateToggleHeader(wxUpdateUIEvent
& event
)
840 event
.Check(!m_listCtrl
->HasFlag(wxLC_NO_HEADER
));
843 void MyFrame::OnUpdateRowLines(wxUpdateUIEvent
& event
)
845 event
.Enable(m_listCtrl
->HasFlag(wxLC_VIRTUAL
));
848 void MyFrame::OnSetFgColour(wxCommandEvent
& WXUNUSED(event
))
850 m_listCtrl
->SetForegroundColour(wxGetColourFromUser(this));
851 m_listCtrl
->Refresh();
854 void MyFrame::OnSetBgColour(wxCommandEvent
& WXUNUSED(event
))
856 m_listCtrl
->SetBackgroundColour(wxGetColourFromUser(this));
857 m_listCtrl
->Refresh();
860 void MyFrame::OnSetRowLines(wxCommandEvent
& event
)
862 m_listCtrl
->EnableAlternateRowColours(event
.IsChecked());
863 m_listCtrl
->Refresh();
866 void MyFrame::OnAdd(wxCommandEvent
& WXUNUSED(event
))
868 m_listCtrl
->InsertItem(m_listCtrl
->GetItemCount(), wxT("Appended item"));
871 void MyFrame::OnEdit(wxCommandEvent
& WXUNUSED(event
))
873 // demonstrate cancelling editing: this currently is wxMSW-only
874 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
875 if ( m_listCtrl
->GetEditControl() )
877 m_listCtrl
->EndEditLabel(true);
879 else // start editing
882 long itemCur
= m_listCtrl
->GetNextItem(-1, wxLIST_NEXT_ALL
,
883 wxLIST_STATE_FOCUSED
);
887 m_listCtrl
->EditLabel(itemCur
);
891 m_logWindow
->WriteText(wxT("No item to edit"));
896 void MyFrame::OnDelete(wxCommandEvent
& WXUNUSED(event
))
898 if ( m_listCtrl
->GetItemCount() )
900 m_listCtrl
->DeleteItem(0);
904 m_logWindow
->WriteText(wxT("Nothing to delete"));
908 void MyFrame::OnDeleteAll(wxCommandEvent
& WXUNUSED(event
))
912 int itemCount
= m_listCtrl
->GetItemCount();
914 m_listCtrl
->DeleteAllItems();
916 m_logWindow
->WriteText(wxString::Format(wxT("Deleting %d items took %ld ms\n"),
922 // ----------------------------------------------------------------------------
924 // ----------------------------------------------------------------------------
926 BEGIN_EVENT_TABLE(MyListCtrl
, wxListCtrl
)
927 EVT_LIST_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnBeginDrag
)
928 EVT_LIST_BEGIN_RDRAG(LIST_CTRL
, MyListCtrl::OnBeginRDrag
)
929 EVT_LIST_BEGIN_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnBeginLabelEdit
)
930 EVT_LIST_END_LABEL_EDIT(LIST_CTRL
, MyListCtrl::OnEndLabelEdit
)
931 EVT_LIST_DELETE_ITEM(LIST_CTRL
, MyListCtrl::OnDeleteItem
)
932 EVT_LIST_DELETE_ALL_ITEMS(LIST_CTRL
, MyListCtrl::OnDeleteAllItems
)
933 EVT_LIST_ITEM_SELECTED(LIST_CTRL
, MyListCtrl::OnSelected
)
934 EVT_LIST_ITEM_DESELECTED(LIST_CTRL
, MyListCtrl::OnDeselected
)
935 EVT_LIST_KEY_DOWN(LIST_CTRL
, MyListCtrl::OnListKeyDown
)
936 EVT_LIST_ITEM_ACTIVATED(LIST_CTRL
, MyListCtrl::OnActivated
)
937 EVT_LIST_ITEM_FOCUSED(LIST_CTRL
, MyListCtrl::OnFocused
)
939 EVT_LIST_COL_CLICK(LIST_CTRL
, MyListCtrl::OnColClick
)
940 EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL
, MyListCtrl::OnColRightClick
)
941 EVT_LIST_COL_BEGIN_DRAG(LIST_CTRL
, MyListCtrl::OnColBeginDrag
)
942 EVT_LIST_COL_DRAGGING(LIST_CTRL
, MyListCtrl::OnColDragging
)
943 EVT_LIST_COL_END_DRAG(LIST_CTRL
, MyListCtrl::OnColEndDrag
)
945 EVT_LIST_CACHE_HINT(LIST_CTRL
, MyListCtrl::OnCacheHint
)
948 EVT_CONTEXT_MENU(MyListCtrl::OnContextMenu
)
950 EVT_CHAR(MyListCtrl::OnChar
)
952 EVT_RIGHT_DOWN(MyListCtrl::OnRightClick
)
955 void MyListCtrl::OnCacheHint(wxListEvent
& event
)
957 wxLogMessage( wxT("OnCacheHint: cache items %ld..%ld"),
958 event
.GetCacheFrom(), event
.GetCacheTo() );
961 void MyListCtrl::SetColumnImage(int col
, int image
)
964 item
.SetMask(wxLIST_MASK_IMAGE
);
965 item
.SetImage(image
);
966 SetColumn(col
, item
);
969 void MyListCtrl::OnColClick(wxListEvent
& event
)
971 int col
= event
.GetColumn();
973 // set or unset image
974 static bool x
= false;
976 SetColumnImage(col
, x
? 0 : -1);
978 wxLogMessage( wxT("OnColumnClick at %d."), col
);
981 void MyListCtrl::OnColRightClick(wxListEvent
& event
)
983 int col
= event
.GetColumn();
986 SetColumnImage(col
, -1);
989 // Show popupmenu at position
990 wxMenu
menu(wxT("Test"));
991 menu
.Append(LIST_ABOUT
, wxT("&About"));
992 PopupMenu(&menu
, event
.GetPoint());
994 wxLogMessage( wxT("OnColumnRightClick at %d."), event
.GetColumn() );
997 void MyListCtrl::LogColEvent(const wxListEvent
& event
, const wxChar
*name
)
999 const int col
= event
.GetColumn();
1001 wxLogMessage(wxT("%s: column %d (width = %d or %d)."),
1004 event
.GetItem().GetWidth(),
1005 GetColumnWidth(col
));
1008 void MyListCtrl::OnColBeginDrag(wxListEvent
& event
)
1010 LogColEvent( event
, wxT("OnColBeginDrag") );
1012 if ( event
.GetColumn() == 0 )
1014 wxLogMessage(wxT("Resizing this column shouldn't work."));
1020 void MyListCtrl::OnColDragging(wxListEvent
& event
)
1022 LogColEvent( event
, wxT("OnColDragging") );
1025 void MyListCtrl::OnColEndDrag(wxListEvent
& event
)
1027 LogColEvent( event
, wxT("OnColEndDrag") );
1030 void MyListCtrl::OnBeginDrag(wxListEvent
& event
)
1032 const wxPoint
& pt
= event
.m_pointDrag
;
1035 wxLogMessage( wxT("OnBeginDrag at (%d, %d), item %ld."),
1036 pt
.x
, pt
.y
, HitTest(pt
, flags
) );
1039 void MyListCtrl::OnBeginRDrag(wxListEvent
& event
)
1041 wxLogMessage( wxT("OnBeginRDrag at %d,%d."),
1042 event
.m_pointDrag
.x
, event
.m_pointDrag
.y
);
1045 void MyListCtrl::OnBeginLabelEdit(wxListEvent
& event
)
1047 wxLogMessage( wxT("OnBeginLabelEdit: %s"), event
.m_item
.m_text
.c_str());
1049 wxTextCtrl
* const text
= GetEditControl();
1052 wxLogMessage("BUG: started to edit but no edit control");
1056 wxLogMessage("Edit control value: \"%s\"", text
->GetValue());
1060 void MyListCtrl::OnEndLabelEdit(wxListEvent
& event
)
1062 wxLogMessage( wxT("OnEndLabelEdit: %s"),
1064 event
.IsEditCancelled() ?
1065 wxString("[cancelled]") :
1071 void MyListCtrl::OnDeleteItem(wxListEvent
& event
)
1073 LogEvent(event
, wxT("OnDeleteItem"));
1074 wxLogMessage( wxT("Number of items when delete event is sent: %d"), GetItemCount() );
1077 void MyListCtrl::OnDeleteAllItems(wxListEvent
& event
)
1079 LogEvent(event
, wxT("OnDeleteAllItems"));
1082 void MyListCtrl::OnSelected(wxListEvent
& event
)
1084 LogEvent(event
, wxT("OnSelected"));
1086 if ( GetWindowStyle() & wxLC_REPORT
)
1089 info
.m_itemId
= event
.m_itemIndex
;
1091 info
.m_mask
= wxLIST_MASK_TEXT
;
1092 if ( GetItem(info
) )
1094 wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
1095 info
.m_text
.c_str());
1099 wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
1104 void MyListCtrl::OnDeselected(wxListEvent
& event
)
1106 LogEvent(event
, wxT("OnDeselected"));
1109 void MyListCtrl::OnActivated(wxListEvent
& event
)
1111 LogEvent(event
, wxT("OnActivated"));
1114 void MyListCtrl::OnFocused(wxListEvent
& event
)
1116 LogEvent(event
, wxT("OnFocused"));
1121 void MyListCtrl::OnListKeyDown(wxListEvent
& event
)
1125 if ( !wxGetKeyState(WXK_SHIFT
) )
1127 LogEvent(event
, wxT("OnListKeyDown"));
1132 switch ( event
.GetKeyCode() )
1134 case 'C': // colorize
1137 info
.m_itemId
= event
.GetIndex();
1138 if ( info
.m_itemId
== -1 )
1146 wxListItemAttr
*attr
= info
.GetAttributes();
1147 if ( !attr
|| !attr
->HasTextColour() )
1149 info
.SetTextColour(*wxCYAN
);
1153 RefreshItem(info
.m_itemId
);
1159 item
= GetNextItem(-1, wxLIST_NEXT_ALL
, wxLIST_STATE_FOCUSED
);
1160 if ( item
++ == GetItemCount() - 1 )
1165 wxLogMessage(wxT("Focusing item %ld"), item
);
1167 SetItemState(item
, wxLIST_STATE_FOCUSED
, wxLIST_STATE_FOCUSED
);
1168 EnsureVisible(item
);
1171 case 'R': // show bounding rectangle
1173 item
= event
.GetIndex();
1175 if ( !GetItemRect(item
, r
) )
1177 wxLogError(wxT("Failed to retrieve rect of item %ld"), item
);
1181 wxLogMessage(wxT("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
1182 item
, r
.x
, r
.y
, r
.x
+ r
.width
, r
.y
+ r
.height
);
1186 case '1': // show sub item bounding rectangle for the given column
1187 case '2': // (and icon/label rectangle if Shift/Ctrl is pressed)
1189 case '4': // this column is invalid but we want to test it too
1190 if ( InReportView() )
1192 int subItem
= event
.GetKeyCode() - '1';
1193 item
= event
.GetIndex();
1196 int code
= wxLIST_RECT_BOUNDS
;
1197 if ( wxGetKeyState(WXK_SHIFT
) )
1198 code
= wxLIST_RECT_ICON
;
1199 else if ( wxGetKeyState(WXK_CONTROL
) )
1200 code
= wxLIST_RECT_LABEL
;
1202 if ( !GetSubItemRect(item
, subItem
, r
, code
) )
1204 wxLogError(wxT("Failed to retrieve rect of item %ld column %d"), item
, subItem
+ 1);
1208 wxLogMessage(wxT("Bounding rect of item %ld column %d is (%d, %d)-(%d, %d)"),
1210 r
.x
, r
.y
, r
.x
+ r
.width
, r
.y
+ r
.height
);
1218 if ( m_updated
!= -1 )
1219 RefreshItem(m_updated
);
1221 m_updated
= event
.GetIndex();
1222 if ( m_updated
!= -1 )
1224 // we won't see changes to this item as it's selected, update
1225 // the next one (or the first one if we're on the last item)
1226 if ( ++m_updated
== GetItemCount() )
1229 wxLogMessage("Updating colour of the item %ld", m_updated
);
1230 RefreshItem(m_updated
);
1235 item
= GetNextItem(-1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1236 while ( item
!= -1 )
1240 wxLogMessage(wxT("Item %ld deleted"), item
);
1242 // -1 because the indices were shifted by DeleteItem()
1243 item
= GetNextItem(item
- 1,
1244 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1249 if ( GetWindowStyle() & wxLC_REPORT
)
1251 if ( GetWindowStyle() & wxLC_VIRTUAL
)
1253 SetItemCount(GetItemCount() + 1);
1257 InsertItemInReportView(event
.GetIndex());
1260 //else: fall through
1263 LogEvent(event
, wxT("OnListKeyDown"));
1269 void MyListCtrl::OnChar(wxKeyEvent
& event
)
1271 wxLogMessage(wxT("Got char event."));
1276 void MyListCtrl::OnRightClick(wxMouseEvent
& event
)
1278 if ( !event
.ControlDown() )
1286 long item
= HitTest(event
.GetPosition(), flags
, &subitem
);
1291 case wxLIST_HITTEST_ABOVE
: where
= wxT("above"); break;
1292 case wxLIST_HITTEST_BELOW
: where
= wxT("below"); break;
1293 case wxLIST_HITTEST_NOWHERE
: where
= wxT("nowhere near"); break;
1294 case wxLIST_HITTEST_ONITEMICON
: where
= wxT("on icon of"); break;
1295 case wxLIST_HITTEST_ONITEMLABEL
: where
= wxT("on label of"); break;
1296 case wxLIST_HITTEST_ONITEMRIGHT
: where
= wxT("right on"); break;
1297 case wxLIST_HITTEST_TOLEFT
: where
= wxT("to the left of"); break;
1298 case wxLIST_HITTEST_TORIGHT
: where
= wxT("to the right of"); break;
1299 default: where
= wxT("not clear exactly where on"); break;
1302 wxLogMessage(wxT("Right double click %s item %ld, subitem %ld"),
1303 where
.c_str(), item
, subitem
);
1306 void MyListCtrl::LogEvent(const wxListEvent
& event
, const wxChar
*eventName
)
1308 wxLogMessage(wxT("Item %ld: %s (item text = %s, data = %ld)"),
1309 event
.GetIndex(), eventName
,
1310 event
.GetText().c_str(), event
.GetData());
1313 wxString
MyListCtrl::OnGetItemText(long item
, long column
) const
1315 if ( GetItemCount() == WXSIZEOF(SMALL_VIRTUAL_VIEW_ITEMS
) )
1317 return SMALL_VIRTUAL_VIEW_ITEMS
[item
][column
];
1319 else // "big" virtual control
1321 return wxString::Format(wxT("Column %ld of item %ld"), column
, item
);
1325 int MyListCtrl::OnGetItemColumnImage(long item
, long column
) const
1330 if (!(item
% 3) && column
== 1)
1336 wxListItemAttr
*MyListCtrl::OnGetItemAttr(long item
) const
1338 // test to check that RefreshItem() works correctly: when m_updated is
1339 // set to some item and it is refreshed, we highlight the item
1340 if ( item
== m_updated
)
1342 static wxListItemAttr
s_attrHighlight(*wxRED
, wxNullColour
, wxNullFont
);
1343 return &s_attrHighlight
;
1346 return wxListCtrl::OnGetItemAttr(item
);
1349 void MyListCtrl::InsertItemInReportView(int i
)
1352 buf
.Printf(wxT("This is item %d"), i
);
1353 long tmp
= InsertItem(i
, buf
, 0);
1354 SetItemData(tmp
, i
);
1356 buf
.Printf(wxT("Col 1, item %d"), i
);
1357 SetItem(tmp
, 1, buf
);
1359 buf
.Printf(wxT("Item %d in column 2"), i
);
1360 SetItem(tmp
, 2, buf
);
1363 #if USE_CONTEXT_MENU
1364 void MyListCtrl::OnContextMenu(wxContextMenuEvent
& event
)
1366 if (GetEditControl() == NULL
)
1368 wxPoint point
= event
.GetPosition();
1370 if ( (point
.x
== -1) && (point
.y
== -1) )
1372 wxSize size
= GetSize();
1373 point
.x
= size
.x
/ 2;
1374 point
.y
= size
.y
/ 2;
1378 point
= ScreenToClient(point
);
1380 ShowContextMenu(point
);
1384 // the user is editing:
1385 // allow the text control to display its context menu
1386 // if it has one (it has on Windows) rather than display our one
1392 void MyListCtrl::ShowContextMenu(const wxPoint
& pos
)
1396 menu
.Append(wxID_ABOUT
, wxT("&About"));
1397 menu
.AppendSeparator();
1398 menu
.Append(wxID_EXIT
, wxT("E&xit"));
1400 PopupMenu(&menu
, pos
.x
, pos
.y
);