]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/grid/griddemo.cpp
include wx/arrstr.h as it's needed by wxImageHandler and may not be implicitly includ...
[wxWidgets.git] / samples / grid / griddemo.cpp
index e3cd8a30b4f81cd4cba1d29cbd20fa17d1cb7b89..37d438987e642434ec622e816ce010f562d6ed96 100644 (file)
 
 #include "griddemo.h"
 
+#ifndef __WXMSW__
+    #include "../sample.xpm"
+#endif
+
 // ----------------------------------------------------------------------------
 // wxWin macros
 // ----------------------------------------------------------------------------
@@ -135,7 +139,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
     EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
     EVT_GRID_CELL_CHANGING( GridFrame::OnCellValueChanging )
-    EVT_GRID_CELL_CHANGE( GridFrame::OnCellValueChanged )
+    EVT_GRID_CELL_CHANGED( GridFrame::OnCellValueChanged )
     EVT_GRID_CELL_BEGIN_DRAG( GridFrame::OnCellBeginDrag )
 
     EVT_GRID_EDITOR_SHOWN( GridFrame::OnEditorShown )
@@ -148,6 +152,8 @@ GridFrame::GridFrame()
                    wxDefaultPosition,
                    wxDefaultSize )
 {
+    SetIcon(wxICON(sample));
+
     wxMenu *fileMenu = new wxMenu;
     fileMenu->Append( ID_VTABLE, _T("&Virtual table test\tCtrl-V"));
     fileMenu->Append( ID_BUGS_TABLE, _T("&Bugs table test\tCtrl-B"));
@@ -371,6 +377,14 @@ GridFrame::GridFrame()
     grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
     grid->SetCellValue(7, 1, _T("Big box!"));
 
+    // create a separator-like row: it's grey and it's non-resizeable
+    grid->DisableRowResize(10);
+    grid->SetRowSize(10, 30);
+    attr = new wxGridCellAttr;
+    attr->SetBackgroundColour(*wxLIGHT_GREY);
+    grid->SetRowAttr(10, attr);
+    grid->SetCellValue(10, 0, "You can't resize this row interactively -- try it");
+
     // this does exactly nothing except testing that SetAttr() handles NULL
     // attributes and does reference counting correctly
     grid->SetAttr(11, 11, NULL);
@@ -926,7 +940,10 @@ void GridFrame::OnCellLeftClick( wxGridEvent& ev )
 
 void GridFrame::OnRowSize( wxGridSizeEvent& ev )
 {
-    wxLogMessage(_T("Resized row %d"), ev.GetRowOrCol());
+    const int row = ev.GetRowOrCol();
+
+    wxLogMessage("Resized row %d, new height = %d",
+                 row, grid->GetRowSize(row));
 
     ev.Skip();
 }
@@ -934,7 +951,10 @@ void GridFrame::OnRowSize( wxGridSizeEvent& ev )
 
 void GridFrame::OnColSize( wxGridSizeEvent& ev )
 {
-    wxLogMessage(_T("Resized col %d"), ev.GetRowOrCol());
+    const int col = ev.GetRowOrCol();
+
+    wxLogMessage("Resized column %d, new width = %d",
+                 col, grid->GetColSize(col));
 
     ev.Skip();
 }
@@ -1146,6 +1166,13 @@ void GridFrame::About(  wxCommandEvent& WXUNUSED(ev) )
     aboutInfo.AddDeveloper(wxT("Julian Smart"));
     aboutInfo.AddDeveloper(wxT("Vadim Zeitlin"));
 
+    // this is just to force the generic version of the about
+    // dialog under wxMSW so that it's easy to test if the grid
+    // repaints correctly when it has lost focus and a dialog
+    // (different from the Windows standard message box -- it doesn't
+    // work with it for some reason) is moved over it.
+    aboutInfo.SetWebSite(wxT("http://www.wxwidgets.org"));
+
     wxAboutBox(aboutInfo);
 }
 
@@ -1871,7 +1898,7 @@ private:
     // fla for EVT_IDLE handler
     bool m_shouldUpdateOrder;
 
-    DECLARE_NO_COPY_CLASS(TabularGridFrame)
+    wxDECLARE_NO_COPY_CLASS(TabularGridFrame);
     DECLARE_EVENT_TABLE()
 };