]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/grid/griddemo.cpp
Fix duplicate symbol link errors in wxMSW wxTextEntry code.
[wxWidgets.git] / samples / grid / griddemo.cpp
index f10c12a51c52d8a8a7ecec5d22e103e02a29bfd8..31e27af2406b28dbe79352e200fff7863d2f5fc2 100644 (file)
@@ -226,6 +226,7 @@ BEGIN_EVENT_TABLE( GridFrame, wxFrame )
     EVT_GRID_CELL_LEFT_CLICK( GridFrame::OnCellLeftClick )
     EVT_GRID_ROW_SIZE( GridFrame::OnRowSize )
     EVT_GRID_COL_SIZE( GridFrame::OnColSize )
+    EVT_GRID_COL_AUTO_SIZE( GridFrame::OnColAutoSize )
     EVT_GRID_SELECT_CELL( GridFrame::OnSelectCell )
     EVT_GRID_RANGE_SELECT( GridFrame::OnRangeSelected )
     EVT_GRID_CELL_CHANGING( GridFrame::OnCellValueChanging )
@@ -449,6 +450,21 @@ GridFrame::GridFrame()
 
     grid->SetCellValue( 0, 4, wxT("Can veto edit this cell") );
 
+    grid->SetColSize(10, 150);
+    wxString longtext = wxT("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\n");
+    longtext += wxT("With tabs :\n");
+    longtext += wxT("Home,\t\thome\t\t\tagain\n");
+    longtext += wxT("Long word at start :\n");
+    longtext += wxT("ILikeToBeHereWhen I can\n");
+    longtext += wxT("Long word in the middle :\n");
+    longtext += wxT("When IComeHome,ColdAnd tired\n");
+    longtext += wxT("Long last word :\n");
+    longtext += wxT("It's GoodToWarmMyBonesBesideTheFire");
+    grid->SetCellValue( 0, 10, longtext );
+    grid->SetCellRenderer(0 , 10, new wxGridCellAutoWrapStringRenderer);
+    grid->SetCellEditor( 0,  10 , new wxGridCellAutoWrapStringEditor);
+    grid->SetCellValue( 0, 11, wxT("K1 cell editor blocker") );
+
     grid->SetCellValue( 0, 5, wxT("Press\nCtrl+arrow\nto skip over\ncells") );
 
     grid->SetRowSize( 99, 60 );
@@ -1174,6 +1190,21 @@ void GridFrame::OnColSize( wxGridSizeEvent& ev )
     ev.Skip();
 }
 
+void GridFrame::OnColAutoSize( wxGridSizeEvent &event )
+{
+    // Fit even-numbered columns to their contents while using the default
+    // behaviour for the odd-numbered ones to be able to see the difference.
+    int col = event.GetRowOrCol();
+    if ( col % 2 )
+    {
+        wxLogMessage("Auto-sizing column %d to fit its contents", col);
+        grid->AutoSizeColumn(col);
+    }
+    else
+    {
+        event.Skip();
+    }
+}
 
 void GridFrame::OnSelectCell( wxGridEvent& ev )
 {