]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/ownerdrw/ownerdrw.cpp
make sure mouse moved events are always delivered, see #15008
[wxWidgets.git] / samples / ownerdrw / ownerdrw.cpp
index f7c3a5d32ba65ab88c481bf5f9ce710880a1b7c1..104dd7ea00faa4004c9a7fdecf9d7bd138ee0b59 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     13.11.97
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -69,6 +69,8 @@ enum
     Menu_Bitmap, Menu_Bitmap2,
     Menu_Submenu, Menu_Sub1, Menu_Sub2, Menu_Sub3,
     Menu_Toggle, Menu_About,
+    Menu_Drawn1, Menu_Drawn2, Menu_Drawn3, Menu_Drawn4, Menu_Drawn5,
+    Menu_Native1, Menu_Native2, Menu_Native3, Menu_Native4, Menu_Native5,
     Control_First = 1000,
     Control_Listbox, Control_Listbox2
 };
@@ -79,7 +81,7 @@ BEGIN_EVENT_TABLE(OwnerDrawnFrame, wxFrame)
     EVT_MENU(Menu_Quit, OwnerDrawnFrame::OnQuit)
     EVT_LISTBOX(Control_Listbox, OwnerDrawnFrame::OnListboxSelect)
     EVT_CHECKLISTBOX(Control_Listbox, OwnerDrawnFrame::OnCheckboxToggle)
-    EVT_COMMAND(Control_Listbox, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
+    EVT_COMMAND(Control_Listbox, wxEVT_LISTBOX_DCLICK,
                 OwnerDrawnFrame::OnListboxDblClick)
 END_EVENT_TABLE()
 
@@ -95,8 +97,6 @@ bool OwnerDrawnApp::OnInit(void)
         = new OwnerDrawnFrame(NULL, wxT("wxWidgets Ownerdraw Sample"),
                               50, 50, 450, 340);
 
-    SetTopWindow(pFrame);
-
     return true;
 }
 
@@ -198,9 +198,62 @@ void OwnerDrawnFrame::InitMenu()
                            wxITEM_NORMAL);
     file_menu->Append(pItem);
 
+    wxMenu* drawn_menu = new wxMenu;
+    pItem = new wxMenuItem(drawn_menu, Menu_Drawn1, wxT("&Menu item\tCtrl+K"));
+    drawn_menu->Append(pItem);
+
+    drawn_menu->AppendSeparator();
+
+    pItem = new wxMenuItem(drawn_menu, Menu_Drawn2, wxT("&Checked item"),
+        wxT("check/uncheck me!"), wxITEM_CHECK);
+    drawn_menu->Append(pItem);
+    drawn_menu->Check(Menu_Drawn2, true);
+
+    pItem = new wxMenuItem(drawn_menu, Menu_Drawn3, wxT("&Radio item"),
+        wxT("check/uncheck me!"), wxITEM_RADIO);
+    drawn_menu->Append(pItem);
+
+    drawn_menu->AppendSeparator();
+
+    pItem = new wxMenuItem(drawn_menu, Menu_Drawn4, wxT("&Disabled item\tCtrl+RatherLongAccel"),
+        wxT("disabled item"));
+    pItem->Enable(false);
+    drawn_menu->Append(pItem);
+
+    pItem = new wxMenuItem(drawn_menu, Menu_Drawn5, wxT("&Other\tCtrl+O"), wxT("other item"));
+    pItem->SetTextColour(*wxRED);
+    drawn_menu->Append(pItem);
+
+    wxMenu* native_menu = new wxMenu;
+    pItem = new wxMenuItem(native_menu, Menu_Native1, wxT("&Menu item\tCtrl+K"));
+    native_menu->Append(pItem);
+
+    native_menu->AppendSeparator();
+
+    pItem = new wxMenuItem(native_menu, Menu_Native2, wxT("&Checked item"),
+        wxT("check/uncheck me!"), wxITEM_CHECK);
+    native_menu->Append(pItem);
+    native_menu->Check(Menu_Native2, true);
+
+    pItem = new wxMenuItem(native_menu, Menu_Native3, wxT("&Radio item"),
+        wxT("check/uncheck me!"), wxITEM_RADIO);
+    native_menu->Append(pItem);
+
+    native_menu->AppendSeparator();
+
+    pItem = new wxMenuItem(native_menu, Menu_Native4, wxT("&Disabled item\tCtrl+RatherLongAccel"),
+        wxT("disabled item"));
+    pItem->Enable(false);
+    native_menu->Append(pItem);
+
+    pItem = new wxMenuItem(native_menu, Menu_Native5, wxT("&Other\tCtrl+O"), wxT("other item"));
+    native_menu->Append(pItem);
+
     wxMenuBar *menu_bar = new wxMenuBar;
 
     menu_bar->Append(file_menu, wxT("&File"));
+    menu_bar->Append(drawn_menu, wxT("&Drawn"));
+    menu_bar->Append(native_menu, wxT("&Native"));
     SetMenuBar(menu_bar);
 }
 
@@ -210,7 +263,7 @@ OwnerDrawnFrame::OwnerDrawnFrame(wxFrame *frame, const wxChar *title,
          : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
 {
     // set the icon
-    SetIcon(wxIcon(wxT("mondrian")));
+    SetIcon(wxICON(sample));
 
     // create the menu
     InitMenu();