]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/grid/test.cpp
Added the forgotten file txtstrm.tex
[wxWidgets.git] / samples / grid / test.cpp
index 1f48aeec8772f9d6ec2704d92440d032d79f2df8..f7cf501a1b8153e227cc2789d5cd55d3f8174b42 100644 (file)
@@ -34,15 +34,15 @@ class MyApp: public wxApp
     bool OnInit(void);
 };
 
+
 // Define a new frame type
 class MyFrame: public wxFrame
 { public:
     wxGrid *grid;
     MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
 
-    bool OnClose(void) { return TRUE; }
-
     void ToggleEditable(wxCommandEvent& event);
+    void ToggleEditInPlace(wxCommandEvent& event);
     void ToggleRowLabel(wxCommandEvent& event);
     void ToggleColLabel(wxCommandEvent& event);
     void ToggleDividers(wxCommandEvent& event);
@@ -62,12 +62,13 @@ class MyFrame: public wxFrame
 DECLARE_EVENT_TABLE()
 };
 
-wxBitmap *cellBitmap1 = NULL;
-wxBitmap *cellBitmap2 = NULL;
+wxBitmap *cellBitmap1 = (wxBitmap *) NULL;
+wxBitmap *cellBitmap2 = (wxBitmap *) NULL;
 
 // ID for the menu quit command
 #define GRID_QUIT 1
 #define GRID_TOGGLE_EDITABLE 2
+#define GRID_TOGGLE_EDITINPLACE 22
 #define GRID_LEFT_CELL       3
 #define GRID_CENTRE_CELL     4
 #define GRID_RIGHT_CELL      5
@@ -94,15 +95,12 @@ bool MyApp::OnInit(void)
 #endif
 
   // Create the main frame window
-  MyFrame *frame = new MyFrame(NULL, "wxGrid Sample", wxPoint(50, 50), wxSize(450, 300));
+  MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxGrid Sample", wxPoint(50, 50), wxSize(450, 300));
   
   // Give it an icon
 #ifdef __WXMSW__
   frame->SetIcon(wxIcon("mondrian"));
 #endif
-#ifdef __X__
-  frame->SetIcon(wxIcon("aiai.xbm"));
-#endif
 
   // Make a menubar
   wxMenu *file_menu = new wxMenu;
@@ -110,6 +108,7 @@ bool MyApp::OnInit(void)
 
   wxMenu *settings_menu = new wxMenu;
   settings_menu->Append(GRID_TOGGLE_EDITABLE, "&Toggle editable");
+  settings_menu->Append(GRID_TOGGLE_EDITINPLACE, "&Toggle edit in place");
   settings_menu->Append(GRID_TOGGLE_ROW_LABEL, "Toggle ro&w label");
   settings_menu->Append(GRID_TOGGLE_COL_LABEL, "Toggle co&l label");
   settings_menu->Append(GRID_TOGGLE_DIVIDERS, "Toggle &dividers");
@@ -140,7 +139,7 @@ bool MyApp::OnInit(void)
   frame->grid->SetCellValue("First cell", 0, 0);
   frame->grid->SetCellValue("Another cell", 1, 1);
   frame->grid->SetCellValue("Yet another cell", 2, 2);
-  frame->grid->SetCellTextFont(wxTheFontList->FindOrCreateFont(10, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
+  frame->grid->SetCellTextFont(wxTheFontList->FindOrCreateFont(10, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
   frame->grid->SetCellTextColour(*wxRED, 1, 1);
   frame->grid->SetCellBackgroundColour(*wxCYAN, 2, 2);
   if (cellBitmap1 && cellBitmap2)
@@ -164,11 +163,12 @@ bool MyApp::OnInit(void)
 MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
   wxFrame(frame, -1, title, pos, size)
 {
-  grid = NULL;
+  grid = (wxGenericGrid *) NULL;
 }
 
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
   EVT_MENU(GRID_TOGGLE_EDITABLE, MyFrame::ToggleEditable)
+  EVT_MENU(GRID_TOGGLE_EDITINPLACE, MyFrame::ToggleEditInPlace)
   EVT_MENU(GRID_TOGGLE_ROW_LABEL, MyFrame::ToggleRowLabel)
   EVT_MENU(GRID_TOGGLE_COL_LABEL, MyFrame::ToggleColLabel)
   EVT_MENU(GRID_TOGGLE_DIVIDERS, MyFrame::ToggleDividers)
@@ -190,6 +190,12 @@ void MyFrame::ToggleEditable(wxCommandEvent& WXUNUSED(event))
       grid->Refresh();
 }
 
+void MyFrame::ToggleEditInPlace(wxCommandEvent& WXUNUSED(event))
+{
+      grid->SetEditInPlace(!grid->GetEditInPlace());
+      grid->Refresh();
+}
+
 void MyFrame::ToggleRowLabel(wxCommandEvent& WXUNUSED(event))
 {
       if (grid->GetLabelSize(wxVERTICAL) > 0)
@@ -210,10 +216,10 @@ void MyFrame::ToggleColLabel(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::ToggleDividers(wxCommandEvent& WXUNUSED(event))
 {
-      if (!grid->GetDividerPen())
-        grid->SetDividerPen(wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID));
+      if (!grid->GetDividerPen().Ok())
+        grid->SetDividerPen(wxThePenList->FindOrCreatePen("LIGHT GREY", 1, wxSOLID));
       else
-        grid->SetDividerPen(NULL);
+        grid->SetDividerPen(wxNullPen);
       grid->Refresh();
 }