Remove no-op uses of wxNO_FULL_REPAINT_ON_RESIZE
This behaviour has been the default and this constant 0 since
e441e1f4e8 which was over 16 years ago.
Closes https://github.com/wxWidgets/wxWidgets/pull/1601
			
			
This commit is contained in:
		
				
					committed by
					
						 Vadim Zeitlin
						Vadim Zeitlin
					
				
			
			
				
	
			
			
			
						parent
						
							bf4640f1d8
						
					
				
				
					commit
					18e05aeeee
				
			| @@ -115,8 +115,7 @@ MyFrame::MyFrame(wxWindow *parent, | |||||||
|                  const wxPoint& pos, |                  const wxPoint& pos, | ||||||
|                  const wxSize& size, |                  const wxSize& size, | ||||||
|                  const long style) |                  const long style) | ||||||
|        : wxFrame(parent, id, title, pos, size, |        : wxFrame(parent, id, title, pos, size, style) | ||||||
|                           style | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -172,8 +172,7 @@ wxEND_EVENT_TABLE() | |||||||
| // My frame constructor | // My frame constructor | ||||||
| MyFrame::MyFrame() | MyFrame::MyFrame() | ||||||
|        : wxFrame(NULL, wxID_ANY, "wxCollapsiblePane sample", |        : wxFrame(NULL, wxID_ANY, "wxCollapsiblePane sample", | ||||||
|                  wxDefaultPosition, wxSize(420, 300), |                  wxDefaultPosition, wxSize(420, 300)) | ||||||
|                  wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -524,7 +524,7 @@ wxEND_EVENT_TABLE() | |||||||
|  |  | ||||||
| MyCanvas::MyCanvas(MyFrame *parent) | MyCanvas::MyCanvas(MyFrame *parent) | ||||||
|         : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, |         : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, | ||||||
|                            wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE) |                            wxHSCROLL | wxVSCROLL) | ||||||
| { | { | ||||||
|     m_owner = parent; |     m_owner = parent; | ||||||
|     m_show = File_ShowDefault; |     m_show = File_ShowDefault; | ||||||
| @@ -2162,8 +2162,7 @@ wxEND_EVENT_TABLE() | |||||||
|  |  | ||||||
| // frame constructor | // frame constructor | ||||||
| MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) | MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) | ||||||
|        : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size, |        : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) | ||||||
|                  wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     // set the frame icon |     // set the frame icon | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|   | |||||||
| @@ -363,9 +363,7 @@ void MyFrame::InitToolBar(wxToolBar* toolBar) | |||||||
| // Define a constructor for my canvas | // Define a constructor for my canvas | ||||||
| MyCanvas::MyCanvas(wxFrame *parent, const wxPoint& pos, const wxSize& size) | MyCanvas::MyCanvas(wxFrame *parent, const wxPoint& pos, const wxSize& size) | ||||||
|         : wxScrolledWindow(parent, wxID_ANY, pos, size, |         : wxScrolledWindow(parent, wxID_ANY, pos, size, | ||||||
|                            wxSUNKEN_BORDER | |                            wxSUNKEN_BORDER | wxVSCROLL | wxHSCROLL), | ||||||
|                            wxNO_FULL_REPAINT_ON_RESIZE | |  | ||||||
|                            wxVSCROLL | wxHSCROLL), |  | ||||||
|           MenuEventLogger("canvas", parent) |           MenuEventLogger("canvas", parent) | ||||||
|  |  | ||||||
| { | { | ||||||
|   | |||||||
| @@ -954,15 +954,10 @@ static const wxString _fs_windowstyle_labels[] = { | |||||||
|     "wxTRANSPARENT_WINDOW", |     "wxTRANSPARENT_WINDOW", | ||||||
|     "wxTAB_TRAVERSAL", |     "wxTAB_TRAVERSAL", | ||||||
|     "wxWANTS_CHARS", |     "wxWANTS_CHARS", | ||||||
| #if wxNO_FULL_REPAINT_ON_RESIZE |  | ||||||
|     "wxNO_FULL_REPAINT_ON_RESIZE", |  | ||||||
| #endif |  | ||||||
|     "wxVSCROLL", |     "wxVSCROLL", | ||||||
|     "wxALWAYS_SHOW_SB", |     "wxALWAYS_SHOW_SB", | ||||||
|     "wxCLIP_CHILDREN", |     "wxCLIP_CHILDREN", | ||||||
| #if wxFULL_REPAINT_ON_RESIZE |  | ||||||
|     "wxFULL_REPAINT_ON_RESIZE", |     "wxFULL_REPAINT_ON_RESIZE", | ||||||
| #endif |  | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
| static const long _fs_windowstyle_values[] = { | static const long _fs_windowstyle_values[] = { | ||||||
| @@ -974,15 +969,10 @@ static const long _fs_windowstyle_values[] = { | |||||||
|     wxTRANSPARENT_WINDOW, |     wxTRANSPARENT_WINDOW, | ||||||
|     wxTAB_TRAVERSAL, |     wxTAB_TRAVERSAL, | ||||||
|     wxWANTS_CHARS, |     wxWANTS_CHARS, | ||||||
| #if wxNO_FULL_REPAINT_ON_RESIZE |  | ||||||
|     wxNO_FULL_REPAINT_ON_RESIZE, |  | ||||||
| #endif |  | ||||||
|     wxVSCROLL, |     wxVSCROLL, | ||||||
|     wxALWAYS_SHOW_SB, |     wxALWAYS_SHOW_SB, | ||||||
|     wxCLIP_CHILDREN, |     wxCLIP_CHILDREN, | ||||||
| #if wxFULL_REPAINT_ON_RESIZE |  | ||||||
|     wxFULL_REPAINT_ON_RESIZE |     wxFULL_REPAINT_ON_RESIZE | ||||||
| #endif |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static const wxString _fs_framestyle_labels[] = { | static const wxString _fs_framestyle_labels[] = { | ||||||
| @@ -1982,7 +1972,7 @@ void FormMain::CreateGrid( int style, int extraStyle ) | |||||||
| FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size) : | FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size) : | ||||||
|            wxFrame((wxFrame *)NULL, -1, title, pos, size, |            wxFrame((wxFrame *)NULL, -1, title, pos, size, | ||||||
|                (wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCAPTION| |                (wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCAPTION| | ||||||
|                 wxTAB_TRAVERSAL|wxCLOSE_BOX|wxNO_FULL_REPAINT_ON_RESIZE) ) |                 wxTAB_TRAVERSAL|wxCLOSE_BOX) ) | ||||||
| { | { | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -46,7 +46,6 @@ bool MyApp::OnInit(void) | |||||||
|  |  | ||||||
|   frame = new MyFrame(NULL, wxID_ANY, "Sash Demo", wxPoint(0, 0), wxSize(500, 400), |   frame = new MyFrame(NULL, wxID_ANY, "Sash Demo", wxPoint(0, 0), wxSize(500, 400), | ||||||
|                       wxDEFAULT_FRAME_STYLE | |                       wxDEFAULT_FRAME_STYLE | | ||||||
|                       wxNO_FULL_REPAINT_ON_RESIZE | |  | ||||||
|                       wxHSCROLL | wxVSCROLL); |                       wxHSCROLL | wxVSCROLL); | ||||||
|  |  | ||||||
|   // Give it an icon (this is ignored in MDI mode: uses resources) |   // Give it an icon (this is ignored in MDI mode: uses resources) | ||||||
| @@ -223,9 +222,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) | |||||||
| { | { | ||||||
|       // Make another frame, containing a canvas |       // Make another frame, containing a canvas | ||||||
|       MyChild *subframe = new MyChild(frame, "Canvas Frame", |       MyChild *subframe = new MyChild(frame, "Canvas Frame", | ||||||
|                                       wxPoint(10, 10), wxSize(300, 300), |                                       wxPoint(10, 10), wxSize(300, 300)); | ||||||
|                                       wxDEFAULT_FRAME_STYLE | |  | ||||||
|                                       wxNO_FULL_REPAINT_ON_RESIZE); |  | ||||||
|  |  | ||||||
|       subframe->SetTitle(wxString::Format("Canvas Frame %d", winNumber)); |       subframe->SetTitle(wxString::Format("Canvas Frame %d", winNumber)); | ||||||
|       winNumber ++; |       winNumber ++; | ||||||
| @@ -282,8 +279,7 @@ wxEND_EVENT_TABLE() | |||||||
|  |  | ||||||
| // Define a constructor for my canvas | // Define a constructor for my canvas | ||||||
| MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size) | MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size) | ||||||
|         : wxScrolledWindow(parent, wxID_ANY, pos, size, |         : wxScrolledWindow(parent, wxID_ANY, pos, size, wxSUNKEN_BORDER) | ||||||
|                            wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     SetBackgroundColour(* wxWHITE); |     SetBackgroundColour(* wxWHITE); | ||||||
| } | } | ||||||
| @@ -350,9 +346,8 @@ wxBEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame) | |||||||
|   EVT_MENU(SASHTEST_CHILD_QUIT, MyChild::OnQuit) |   EVT_MENU(SASHTEST_CHILD_QUIT, MyChild::OnQuit) | ||||||
| wxEND_EVENT_TABLE() | wxEND_EVENT_TABLE() | ||||||
|  |  | ||||||
| MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, | MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size): | ||||||
| const long style): |   wxMDIChildFrame(parent, wxID_ANY, title, pos, size) | ||||||
|   wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style) |  | ||||||
| { | { | ||||||
|   canvas = NULL; |   canvas = NULL; | ||||||
|   my_children.Append(this); |   my_children.Append(this); | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ class MyChild: public wxMDIChildFrame | |||||||
| { | { | ||||||
|   public: |   public: | ||||||
|     MyCanvas *canvas; |     MyCanvas *canvas; | ||||||
|     MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); |     MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size); | ||||||
|     ~MyChild(void); |     ~MyChild(void); | ||||||
|     void OnActivate(wxActivateEvent& event); |     void OnActivate(wxActivateEvent& event); | ||||||
|     void OnQuit(wxCommandEvent& event); |     void OnQuit(wxCommandEvent& event); | ||||||
|   | |||||||
| @@ -214,8 +214,7 @@ wxEND_EVENT_TABLE() | |||||||
| // My frame constructor | // My frame constructor | ||||||
| MyFrame::MyFrame() | MyFrame::MyFrame() | ||||||
|        : wxFrame(NULL, wxID_ANY, "wxSplitterWindow sample", |        : wxFrame(NULL, wxID_ANY, "wxSplitterWindow sample", | ||||||
|                  wxDefaultPosition, wxSize(420, 300), |                  wxDefaultPosition, wxSize(420, 300)) | ||||||
|                  wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|  |  | ||||||
| @@ -551,7 +550,7 @@ void MySplitterWindow::OnUnsplitEvent(wxSplitterEvent& event) | |||||||
|  |  | ||||||
| MyCanvas::MyCanvas(wxWindow* parent, bool mirror) | MyCanvas::MyCanvas(wxWindow* parent, bool mirror) | ||||||
|         : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, |         : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, | ||||||
|                            wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE) |                            wxHSCROLL | wxVSCROLL) | ||||||
| { | { | ||||||
|     m_mirror = mirror; |     m_mirror = mirror; | ||||||
|     SetScrollbars(20, 20, 5, 5); |     SetScrollbars(20, 20, 5, 5); | ||||||
|   | |||||||
| @@ -291,8 +291,7 @@ wxBEGIN_EVENT_TABLE (AppFrame, wxFrame) | |||||||
| wxEND_EVENT_TABLE () | wxEND_EVENT_TABLE () | ||||||
|  |  | ||||||
| AppFrame::AppFrame (const wxString &title) | AppFrame::AppFrame (const wxString &title) | ||||||
|         : wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550), |         : wxFrame ((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(750,550)) | ||||||
|                     wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) |  | ||||||
| { | { | ||||||
|     SetIcon(wxICON(sample)); |     SetIcon(wxICON(sample)); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ public: | |||||||
|             const wxString& title = "wxToolBar Sample", |             const wxString& title = "wxToolBar Sample", | ||||||
|             const wxPoint& pos = wxDefaultPosition, |             const wxPoint& pos = wxDefaultPosition, | ||||||
|             const wxSize& size = wxDefaultSize, |             const wxSize& size = wxDefaultSize, | ||||||
|             long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); |             long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN); | ||||||
|     virtual ~MyFrame(); |     virtual ~MyFrame(); | ||||||
|  |  | ||||||
|     void PopulateToolbar(wxToolBarBase* toolBar); |     void PopulateToolbar(wxToolBarBase* toolBar); | ||||||
|   | |||||||
| @@ -1311,7 +1311,6 @@ WidgetsPage::WidgetsPage(WidgetsBookCtrl *book, | |||||||
|                          const char *const icon[]) |                          const char *const icon[]) | ||||||
|            : wxPanel(book, wxID_ANY, |            : wxPanel(book, wxID_ANY, | ||||||
|                      wxDefaultPosition, wxDefaultSize, |                      wxDefaultPosition, wxDefaultSize, | ||||||
|                      wxNO_FULL_REPAINT_ON_RESIZE | |  | ||||||
|                      wxCLIP_CHILDREN | |                      wxCLIP_CHILDREN | | ||||||
|                      wxTAB_TRAVERSAL) |                      wxTAB_TRAVERSAL) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -9400,47 +9400,65 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction) | |||||||
|     wxCoord w, h; |     wxCoord w, h; | ||||||
|     dc.SetFont( GetLabelFont() ); |     dc.SetFont( GetLabelFont() ); | ||||||
|  |  | ||||||
|  |     bool noContent = (extentMax == 0); | ||||||
|     bool addMargin = true; |     bool addMargin = true; | ||||||
|  |  | ||||||
|     if ( column ) |     if ( column ) | ||||||
|     { |     { | ||||||
|         if ( m_useNativeHeader ) |         if ( m_useNativeHeader ) | ||||||
|         { |         { | ||||||
|             w = GetGridColHeader()->GetColumnTitleWidth(colOrRow); |             wxHeaderCtrl* header = GetGridColHeader(); | ||||||
|  |             w = header->GetColumnTitleWidth(colOrRow); | ||||||
|  |  | ||||||
|             // GetColumnTitleWidth already adds margins internally. |             // GetColumnTitleWidth already adds margins internally. | ||||||
|             addMargin = false; |             addMargin = false; | ||||||
|             h = 0; |             h = 0; | ||||||
|  |  | ||||||
|  |             // GetColumnTitleWidth uses GetTextExtent and not | ||||||
|  |             // GetMultiLineTextExtent so use the same funtion. | ||||||
|  |             if ( header->GetTextExtent(GetColLabelValue(colOrRow)).x > 0 ) | ||||||
|  |                 noContent = false; | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             dc.GetMultiLineTextExtent( GetColLabelValue(colOrRow), &w, &h ); |             dc.GetMultiLineTextExtent( GetColLabelValue(colOrRow), &w, &h ); | ||||||
|             if ( GetColLabelTextOrientation() == wxVERTICAL ) |             if ( GetColLabelTextOrientation() == wxVERTICAL ) | ||||||
|                 w = h; |                 w = h; | ||||||
|  |  | ||||||
|  |             noContent = noContent && (w == 0); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         dc.GetMultiLineTextExtent( GetRowLabelValue(colOrRow), &w, &h ); |         dc.GetMultiLineTextExtent( GetRowLabelValue(colOrRow), &w, &h ); | ||||||
|  |         noContent = noContent && (h == 0); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     extent = column ? w : h; |     if ( noContent ) | ||||||
|     if ( extent > extentMax ) |  | ||||||
|         extentMax = extent; |  | ||||||
|  |  | ||||||
|     if ( !extentMax ) |  | ||||||
|     { |     { | ||||||
|         // empty column - give default extent (notice that if extentMax is less |         // empty column - give default extent (notice that if extentMax is less | ||||||
|         // than default extent but != 0, it's OK) |         // than default extent but != 0, it's OK) | ||||||
|         extentMax = column ? m_defaultColWidth : m_defaultRowHeight; |         extentMax = column ? m_defaultColWidth : m_defaultRowHeight; | ||||||
|     } |     } | ||||||
|     else if ( addMargin ) |     else | ||||||
|     { |     { | ||||||
|         // leave some space around text |         const int margin = column ? 10 : 6; | ||||||
|         if ( column ) |  | ||||||
|             extentMax += 10; |         // The current extentMax is the max extent of columns/rows values | ||||||
|         else |         // so always add margin. | ||||||
|             extentMax += 6; |         extentMax += margin; | ||||||
|  |  | ||||||
|  |         // The current extent is the extent of the column/row title. | ||||||
|  |         extent = column ? w : h; | ||||||
|  |  | ||||||
|  |         // Add the margin to the current extent only if needed. | ||||||
|  |         if ( addMargin ) | ||||||
|  |             extent += margin; | ||||||
|  |  | ||||||
|  |         // Find out the final max extent when the margin affected to the max extent | ||||||
|  |         // and the current extent. | ||||||
|  |         if ( extent > extentMax ) | ||||||
|  |             extentMax = extent; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if ( column ) |     if ( column ) | ||||||
|   | |||||||
| @@ -505,7 +505,6 @@ void wxPropertyGridManager::Init1() | |||||||
|  |  | ||||||
| // These flags are always used in wxPropertyGrid integrated in wxPropertyGridManager. | // These flags are always used in wxPropertyGrid integrated in wxPropertyGridManager. | ||||||
| #define wxPG_MAN_PROPGRID_FORCED_FLAGS (  wxBORDER_THEME | \ | #define wxPG_MAN_PROPGRID_FORCED_FLAGS (  wxBORDER_THEME | \ | ||||||
|                                           wxNO_FULL_REPAINT_ON_RESIZE| \ |  | ||||||
|                                           wxCLIP_CHILDREN) |                                           wxCLIP_CHILDREN) | ||||||
|  |  | ||||||
| // Which flags can be passed to underlying wxPropertyGrid. | // Which flags can be passed to underlying wxPropertyGrid. | ||||||
|   | |||||||
| @@ -16,9 +16,11 @@ | |||||||
|  |  | ||||||
| #ifndef WX_PRECOMP | #ifndef WX_PRECOMP | ||||||
|     #include "wx/app.h" |     #include "wx/app.h" | ||||||
|  |     #include "wx/dcclient.h" | ||||||
| #endif // WX_PRECOMP | #endif // WX_PRECOMP | ||||||
|  |  | ||||||
| #include "wx/grid.h" | #include "wx/grid.h" | ||||||
|  | #include "wx/headerctrl.h" | ||||||
| #include "testableframe.h" | #include "testableframe.h" | ||||||
| #include "asserthelper.h" | #include "asserthelper.h" | ||||||
| #include "wx/uiaction.h" | #include "wx/uiaction.h" | ||||||
| @@ -70,18 +72,21 @@ private: | |||||||
|         WXUISIM_TEST( ReadOnly ); |         WXUISIM_TEST( ReadOnly ); | ||||||
|         WXUISIM_TEST( ResizeScrolledHeader ); |         WXUISIM_TEST( ResizeScrolledHeader ); | ||||||
|         WXUISIM_TEST( ColumnMinWidth ); |         WXUISIM_TEST( ColumnMinWidth ); | ||||||
|  |         WXUISIM_TEST( AutoSizeColumn ); | ||||||
|         CPPUNIT_TEST( PseudoTest_NativeHeader ); |         CPPUNIT_TEST( PseudoTest_NativeHeader ); | ||||||
|         NONGTK_TEST( LabelClick ); |         NONGTK_TEST( LabelClick ); | ||||||
|         NONGTK_TEST( SortClick ); |         NONGTK_TEST( SortClick ); | ||||||
|         CPPUNIT_TEST( ColumnOrder ); |         CPPUNIT_TEST( ColumnOrder ); | ||||||
|         WXUISIM_TEST( ResizeScrolledHeader ); |         WXUISIM_TEST( ResizeScrolledHeader ); | ||||||
|         WXUISIM_TEST( ColumnMinWidth ); |         WXUISIM_TEST( ColumnMinWidth ); | ||||||
|  |         WXUISIM_TEST( AutoSizeColumn ); | ||||||
|         CPPUNIT_TEST( DeleteAndAddRowCol ); |         CPPUNIT_TEST( DeleteAndAddRowCol ); | ||||||
|         CPPUNIT_TEST( PseudoTest_NativeLabels ); |         CPPUNIT_TEST( PseudoTest_NativeLabels ); | ||||||
|         NONGTK_TEST( LabelClick ); |         NONGTK_TEST( LabelClick ); | ||||||
|         NONGTK_TEST( SortClick ); |         NONGTK_TEST( SortClick ); | ||||||
|         CPPUNIT_TEST( ColumnOrder ); |         CPPUNIT_TEST( ColumnOrder ); | ||||||
|         WXUISIM_TEST( WindowAsEditorControl ); |         WXUISIM_TEST( WindowAsEditorControl ); | ||||||
|  |         WXUISIM_TEST( AutoSizeColumn ); | ||||||
|     CPPUNIT_TEST_SUITE_END(); |     CPPUNIT_TEST_SUITE_END(); | ||||||
|  |  | ||||||
|     void CellEdit(); |     void CellEdit(); | ||||||
| @@ -108,10 +113,23 @@ private: | |||||||
|     void WindowAsEditorControl(); |     void WindowAsEditorControl(); | ||||||
|     void ResizeScrolledHeader(); |     void ResizeScrolledHeader(); | ||||||
|     void ColumnMinWidth(); |     void ColumnMinWidth(); | ||||||
|  |     void AutoSizeColumn(); | ||||||
|     void PseudoTest_NativeHeader() { ms_nativeheader = true; } |     void PseudoTest_NativeHeader() { ms_nativeheader = true; } | ||||||
|     void PseudoTest_NativeLabels() { ms_nativeheader = false; |     void PseudoTest_NativeLabels() { ms_nativeheader = false; | ||||||
|                                      ms_nativelabels = true; } |                                      ms_nativelabels = true; } | ||||||
|  |  | ||||||
|  |     // The helper function to determine the width of the column label depending | ||||||
|  |     // on whether the native column is used. | ||||||
|  |     int GetColumnLabelWidth(wxClientDC& dc, int col, int margin) const | ||||||
|  |     { | ||||||
|  |         if (ms_nativeheader) | ||||||
|  |             return m_grid->GetGridColHeader()->GetColumnTitleWidth(col); | ||||||
|  |  | ||||||
|  |         int w, h; | ||||||
|  |         dc.GetMultiLineTextExtent(m_grid->GetColLabelValue(col), &w, &h); | ||||||
|  |         return w + margin; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     static bool ms_nativeheader; |     static bool ms_nativeheader; | ||||||
|     static bool ms_nativelabels; |     static bool ms_nativelabels; | ||||||
|  |  | ||||||
| @@ -950,4 +968,91 @@ void GridTestCase::ColumnMinWidth() | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void GridTestCase::AutoSizeColumn() | ||||||
|  | { | ||||||
|  |     // Hardcoded margin for columns. | ||||||
|  |     const int margin = 10; | ||||||
|  |     int maxWidth; | ||||||
|  |  | ||||||
|  |     wxGridCellAttr *attr = m_grid->GetOrCreateCellAttr(0, 0); | ||||||
|  |     wxGridCellRenderer *renderer = attr->GetRenderer(m_grid, 0, 0); | ||||||
|  |     REQUIRE(renderer != NULL); | ||||||
|  |  | ||||||
|  |     wxClientDC dcCell(m_grid->GetGridWindow()); | ||||||
|  |  | ||||||
|  |     wxClientDC dcLabel(m_grid->GetGridWindow()); | ||||||
|  |     dcLabel.SetFont(m_grid->GetLabelFont()); | ||||||
|  |  | ||||||
|  |     const wxString shortStr     = "W"; | ||||||
|  |     const wxString mediumStr    = "WWWW"; | ||||||
|  |     const wxString longStr      = "WWWWWWWW"; | ||||||
|  |     const wxString multilineStr = mediumStr + "\n" + longStr; | ||||||
|  |  | ||||||
|  |     SECTION("Empty column") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, wxEmptyString); | ||||||
|  |         maxWidth = m_grid->GetDefaultColSize(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     SECTION("Autosize by the title") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, mediumStr); | ||||||
|  |         maxWidth = GetColumnLabelWidth(dcLabel, 0, margin); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     SECTION("Autosize by cells") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, wxEmptyString); | ||||||
|  |         m_grid->SetCellValue(0, 0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(1, 0, shortStr); | ||||||
|  |         m_grid->SetCellValue(3, 0, longStr); | ||||||
|  |         maxWidth = renderer->GetBestWidth(*m_grid, *attr, dcCell, 3, 0, | ||||||
|  |                                           m_grid->GetRowHeight(3)) | ||||||
|  |                    + margin; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     SECTION("Autosize with the longest title") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, multilineStr); | ||||||
|  |         m_grid->SetCellValue(0, 0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(1, 0, shortStr); | ||||||
|  |         maxWidth = GetColumnLabelWidth(dcLabel, 0, margin); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     SECTION("Autosize with the longest cell") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(0, 0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(1, 0, shortStr); | ||||||
|  |         m_grid->SetCellValue(3, 0, multilineStr); | ||||||
|  |         maxWidth = renderer->GetBestWidth(*m_grid, *attr, dcCell, 3, 0, | ||||||
|  |                                           m_grid->GetRowHeight(3)) | ||||||
|  |                    + margin; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     SECTION("Autosize with the same values") | ||||||
|  |     { | ||||||
|  |         m_grid->SetColLabelValue(0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(0, 0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(1, 0, mediumStr); | ||||||
|  |         m_grid->SetCellValue(3, 0, mediumStr); | ||||||
|  |  | ||||||
|  |         const int labelWidth = GetColumnLabelWidth(dcLabel, 0, margin); | ||||||
|  |  | ||||||
|  |         const int cellWidth = | ||||||
|  |             renderer->GetBestWidth(*m_grid, *attr, dcCell, 3, 0, | ||||||
|  |                                    m_grid->GetRowHeight(3)) | ||||||
|  |             + margin; | ||||||
|  |  | ||||||
|  |         // We can't be sure which size will be greater because of different fonts | ||||||
|  |         // so just calculate the maximum width. | ||||||
|  |         maxWidth = wxMax(labelWidth, cellWidth); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     m_grid->AutoSizeColumn(0); | ||||||
|  |  | ||||||
|  |     wxYield(); | ||||||
|  |     CHECK(m_grid->GetColSize(0) == maxWidth); | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif //wxUSE_GRID | #endif //wxUSE_GRID | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user