lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 3c3d0c0 36/46: Explain grid customizations in


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3c3d0c0 36/46: Explain grid customizations in the function creating it
Date: Wed, 22 Jul 2020 11:05:15 -0400 (EDT)

branch: master
commit 3c3d0c0c69f26b06f2075730798f7feaea56c805
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>

    Explain grid customizations in the function creating it
    
    Also group all the methods configuring wxGrid together instead of
    calling some of them before creating the grid table and some of them
    after doing it.
---
 census_view.cpp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/census_view.cpp b/census_view.cpp
index e88802c..c213144 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1965,21 +1965,28 @@ wxWindow* CensusDVCView::CreateChildWindow()
 
 wxWindow* CensusGridView::CreateChildWindow()
 {
+    // Create and customize the grid window: we want to hide its row labels
+    // because we show our own row number column, tweak its alignment slightly
+    // and, importantly, use ellipsis in the overlong cell values rather than
+    // silently truncating them. We also prefer to use the native column header
+    // for a better appearance under MSW and disable the operations which are
+    // either not supported or are not useful.
     grid_window_ = new(wx) wxGrid(GetFrame(), wxID_ANY);
     grid_window_->HideRowLabels();
     grid_window_->SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
     grid_window_->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTRE);
     
grid_window_->SetDefaultCellFitMode(wxGridFitMode::Ellipsize(wxELLIPSIZE_MIDDLE));
-
-    // Grid must be already created when we create the table because we use
-    // the default cell background color to determine the alternating color.
-    grid_table_ = new(wx) CensusViewGridTable(*this);
-    grid_window_->AssignTable(grid_table_, wxGrid::wxGridSelectRows);
-
     grid_window_->UseNativeColHeader();
     grid_window_->DisableHidingColumns();
     grid_window_->DisableDragRowSize();
 
+    // Create the table, providing the grid window with its data, now: notice
+    // that it must be done after creating the grid, as the table attribute
+    // provider uses the default grid cell background color to determine the
+    // alternating rows color.
+    grid_table_ = new(wx) CensusViewGridTable(*this);
+    grid_window_->AssignTable(grid_table_, wxGrid::wxGridSelectRows);
+
     // We could implement some kind of automatic registration, but it doesn't
     // seem to be worth it for now, as we only have a few custom converters,
     // all of which defined in this single file, so it's simpler to just list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]