]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/checklst/checklst.cpp
Some small corrections and setup.h additions
[wxWidgets.git] / samples / checklst / checklst.cpp
index a44be861b1870b2a9f01aca8649591065ec46694..8f26703e8a0b01c736d42bec700e20eb9087505e 100644 (file)
@@ -2,16 +2,16 @@
 // Name:        checklst.cpp
 // Purpose:     wxCheckListBox sample
 // Author:      Vadim Zeitlin
-// Modified by: 
+// Modified by:
 // Created:     13.11.97
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
 // Licence:     wxWindows license
 ///////////////////////////////////////////////////////////////////////////////
 
-// ============================================================================
-// headers & declarations
-// ============================================================================
+#ifdef __GNUG__
+//#pragma implementation
+#endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
   #include "wx/wx.h"
 #endif
 
+#ifdef __WXMSW__
 #include  "wx/ownerdrw.h"
+#endif
 #include  "wx/menuitem.h"
-#include  "wx/msw/checklst.h"
+#include  "wx/checklst.h"
 
 // Define a new application type
 class CheckListBoxApp: public wxApp
@@ -57,8 +59,8 @@ private:
   wxCheckListBox *m_pListBox;
 };
 
-enum 
-{ 
+enum
+{
   Menu_Quit = 1,
   Control_First = 1000,
   Control_Listbox, Control_Listbox2,
@@ -68,8 +70,7 @@ BEGIN_EVENT_TABLE(CheckListBoxFrame, wxFrame)
   EVT_MENU(Menu_Quit, CheckListBoxFrame::OnQuit)
   EVT_LISTBOX(Control_Listbox, CheckListBoxFrame::OnListboxSelect)
   EVT_CHECKLISTBOX(Control_Listbox, CheckListBoxFrame::OnCheckboxToggle)
-  EVT_COMMAND(Control_Listbox, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
-              CheckListBoxFrame::OnListboxDblClick)
+  EVT_LISTBOX_DCLICK(Control_Listbox, CheckListBoxFrame::OnListboxDblClick)
 END_EVENT_TABLE()
 
 IMPLEMENT_APP(CheckListBoxApp);
@@ -88,8 +89,11 @@ bool CheckListBoxApp::OnInit(void)
 CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
          : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
 {
-  // set the icon
-  SetIcon(wxIcon("mondrian"));
+  // create the status line
+  const int widths[] = { -1, 60 };
+  CreateStatusBar(2);
+  SetStatusWidths(2, widths);
+  SetStatusText("no selection", 0);
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
@@ -102,43 +106,40 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame, char *title, int x, int y,
   SetMenuBar(menu_bar);
 
   // make a panel with some controls
-  wxPanel *pPanel = new wxPanel(this, -1, wxPoint(0, 0), 
+  wxPanel *pPanel = new wxPanel(this, -1, wxPoint(0, 0),
                                 wxSize(400, 200), wxTAB_TRAVERSAL);
 
   // check list box
-  static const char* aszChoices[] = { "Hello", "world", "and", 
+  static const char* aszChoices[] = { "Hello", "world", "and",
                                       "goodbye", "cruel", "world",
                                       "-------", "owner-drawn", "listbox" };
 
   wxString *astrChoices = new wxString[WXSIZEOF(aszChoices)];
-  uint ui;
+  unsigned int ui;
   for ( ui = 0; ui < WXSIZEOF(aszChoices); ui++ )
     astrChoices[ui] = aszChoices[ui];
 
   m_pListBox = new wxCheckListBox
-                   (                                             
-                     pPanel,             // parent               
-                     Control_Listbox,    // control id           
-                     wxPoint(10, 10),    // listbox poistion     
+                   (
+                     pPanel,             // parent
+                     Control_Listbox,    // control id
+                     wxPoint(10, 10),    // listbox poistion
                      wxSize(400, 200),   // listbox size
-                     WXSIZEOF(aszChoices), // number of strings    
+                     WXSIZEOF(aszChoices), // number of strings
                      astrChoices         // array of strings
-                   );                                            
-                                                                            
+                   );
+
   delete [] astrChoices;
 
+  // not implemented in wxGTK yet
+#ifndef __WXGTK__
   for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) {
-    m_pListBox->GetItem(ui)->SetBackColor(wxColor(200, 200, 200));
+    m_pListBox->GetItem(ui)->SetBackgroundColour(wxColor(200, 200, 200));
   }
+#endif // wxGTK
 
   m_pListBox->Check(2);
 
-  // create the status line
-  const int widths[] = { -1, 60 };
-  CreateStatusBar(2);
-  SetStatusWidths(2, widths);
-  SetStatusText("no selection", 0);
-
   Show(TRUE);
 }
 
@@ -146,12 +147,12 @@ CheckListBoxFrame::~CheckListBoxFrame()
 {
 }
 
-void CheckListBoxFrame::OnQuit(wxCommandEvent& event)
+void CheckListBoxFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
   Close(TRUE);
 }
 
-void CheckListBoxFrame::OnAbout(wxCommandEvent& event)
+void CheckListBoxFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 {
   wxMessageDialog dialog(this, "Demo of wxCheckListBox control\n"
                          "About wxCheckListBox", wxYES_NO | wxCANCEL);
@@ -161,13 +162,13 @@ void CheckListBoxFrame::OnAbout(wxCommandEvent& event)
 void CheckListBoxFrame::OnListboxSelect(wxCommandEvent& event)
 {
   wxString strSelection;
-  uint nSel = event.GetSelection();
+  unsigned int nSel = event.GetSelection();
   strSelection.sprintf("item %d selected (%schecked)", nSel,
-                       m_pListBox->IsChecked(nSel) ? "" : "not ");
+                       m_pListBox->IsChecked((int)nSel) ? "" : "not ");
   SetStatusText(strSelection);
 }
 
-void CheckListBoxFrame::OnListboxDblClick(wxCommandEvent& event)
+void CheckListBoxFrame::OnListboxDblClick(wxCommandEvent& WXUNUSED(event))
 {
   wxString strSelection;
   strSelection.sprintf("item %d double clicked", m_pListBox->GetSelection());
@@ -178,8 +179,9 @@ void CheckListBoxFrame::OnListboxDblClick(wxCommandEvent& event)
 void CheckListBoxFrame::OnCheckboxToggle(wxCommandEvent& event)
 {
   wxString strSelection;
-  uint nItem = event.GetInt();
+  unsigned int nItem = event.GetInt();
+
   strSelection.sprintf("item %d was %schecked", nItem,
                        m_pListBox->IsChecked(nItem) ? "" : "un");
   SetStatusText(strSelection);
-}
\ No newline at end of file
+}