Refactor setting main frame size in propgrid sample

Determine and set main frame size on creation.
This commit is contained in:
Artur Wieczorek
2020-04-18 22:40:50 +02:00
parent d9f8eec602
commit a39aff4018
3 changed files with 13 additions and 28 deletions

View File

@@ -1932,17 +1932,17 @@ void FormMain::ReplaceGrid(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) ) wxTAB_TRAVERSAL|wxCLOSE_BOX) )
, m_pPropGridManager(NULL)
, m_propGrid(NULL)
, m_hasHeader(false)
, m_labelEditingEnabled(false)
{ {
SetIcon(wxICON(sample)); SetIcon(wxICON(sample));
Centre();
m_propGrid = NULL;
m_pPropGridManager = NULL;
m_hasHeader = false;
m_labelEditingEnabled = false;
#ifdef __WXMAC__ #ifdef __WXMAC__
// we need this in order to allow the about menu relocation, since ABOUT is // we need this in order to allow the about menu relocation, since ABOUT is
@@ -2133,8 +2133,6 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
m_panel->Layout(); m_panel->Layout();
FinalizeFramePosition();
#if wxUSE_LOGWINDOW #if wxUSE_LOGWINDOW
// Create log window // Create log window
m_logWindow = new wxLogWindow(this, "Log Messages", false); m_logWindow = new wxLogWindow(this, "Log Messages", false);
@@ -2144,19 +2142,6 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
#endif #endif
} }
void FormMain::FinalizeFramePosition()
{
wxSize frameSize((wxSystemSettings::GetMetric(wxSYS_SCREEN_X)/10)*4,
(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)/10)*8);
if ( frameSize.x > 500 )
frameSize.x = 500;
SetSize(frameSize);
Centre();
}
// //
// Normally, wxPropertyGrid does not check whether item with identical // Normally, wxPropertyGrid does not check whether item with identical
// label already exists. However, since in this sample we use labels for // label already exists. However, since in this sample we use labels for
@@ -3134,7 +3119,12 @@ bool cxApplication::OnInit()
//wxLocale Locale; //wxLocale Locale;
//Locale.Init(wxLANGUAGE_FINNISH); //Locale.Init(wxLANGUAGE_FINNISH);
FormMain* frame = Form1 = new FormMain( "wxPropertyGrid Sample", wxPoint(0,0), wxSize(300,500) ); wxSize frameSize((wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 10) * 4,
(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 10) * 8);
if ( frameSize.x > 500 )
frameSize.x = 500;
FormMain* frame = Form1 = new FormMain( "wxPropertyGrid Sample", wxPoint(0,0), frameSize);
frame->Show(true); frame->Show(true);
// //

View File

@@ -159,7 +159,6 @@ public:
void CreateGrid( int style, int extraStyle ); void CreateGrid( int style, int extraStyle );
void ReplaceGrid(int style, int extraStyle); void ReplaceGrid(int style, int extraStyle);
void FinalizeFramePosition();
// These are used in CreateGrid(), and in tests to compose // These are used in CreateGrid(), and in tests to compose
// grids for testing purposes. // grids for testing purposes.

View File

@@ -1765,7 +1765,6 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
// Test with multiple columns // Test with multiple columns
ReplaceGrid( -1, -1 ); ReplaceGrid( -1, -1 );
FinalizeFramePosition();
pgman = m_pPropGridManager; pgman = m_pPropGridManager;
for ( i=3; i<12; i+=2 ) for ( i=3; i<12; i+=2 )
{ {
@@ -1811,9 +1810,6 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
pgman = m_pPropGridManager; pgman = m_pPropGridManager;
} }
// Restore original grid size
FinalizeFramePosition();
RT_START_TEST(none) RT_START_TEST(none)
bool retVal; bool retVal;