+// ----------------------------------------------------------------------------
+// MyDialog
+// ----------------------------------------------------------------------------
+
+MyDialog::MyDialog(wxWindow* parent)
+ : wxDialog(parent, wxID_ANY, "Test Dialog")
+{
+#if USE_LOG_WINDOW
+ // create the log text window
+ m_textctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE);
+ m_textctrl->SetEditable(false);
+
+ m_textctrl->AppendText(wxT("Dialogs do not have menus, but popup menus should function the same\n\n")
+ wxT("Right click this text ctrl to test popup menus.\n"));
+#endif
+#ifdef __POCKETPC__
+ EnableContextMenu();
+#endif
+}
+
+#if USE_LOG_WINDOW
+void MyDialog::LogMenuOpenCloseOrHighlight(const wxMenuEvent& event, const wxChar *what)
+{
+ wxString msg;
+ msg << wxT("A ")
+ << ( event.IsPopup() ? wxT("popup ") : wxT("") )
+ << wxT("menu has been ")
+ << what;
+ if ( event.GetEventType() == wxEVT_MENU_HIGHLIGHT )
+ {
+ msg << wxT(" (id=") << event.GetId() << wxT(")");
+ }
+ msg << wxT(".\n");
+
+ m_textctrl->AppendText(msg);
+}
+#endif // USE_LOG_WINDOW
+#if USE_CONTEXT_MENU
+void MyDialog::OnContextMenu(wxContextMenuEvent& event)
+{
+ wxPoint point = event.GetPosition();
+ // If from keyboard
+ if (point.x == -1 && point.y == -1) {
+ wxSize size = GetSize();
+ point.x = size.x / 2;
+ point.y = size.y / 2;
+ } else {
+ point = ScreenToClient(point);
+ }
+ ShowContextMenu(point);
+}
+#endif
+
+void MyDialog::ShowContextMenu(const wxPoint& pos)
+{
+ wxMenu menu;
+
+ menu.Append(Menu_Help_About, wxT("&About"));
+ menu.Append(Menu_Popup_ToBeDeleted, wxT("To be &deleted"));
+ menu.AppendCheckItem(Menu_Popup_ToBeChecked, wxT("To be &checked"));
+ menu.Append(Menu_Popup_ToBeGreyed, wxT("To be &greyed"),
+ wxT("This menu item should be initially greyed out"));
+ menu.AppendSeparator();
+ menu.Append(Menu_File_Quit, wxT("E&xit"));
+
+ menu.Delete(Menu_Popup_ToBeDeleted);
+ menu.Check(Menu_Popup_ToBeChecked, true);
+ menu.Enable(Menu_Popup_ToBeGreyed, false);
+
+ PopupMenu(&menu, pos);
+}