Lay out various wxPG dialogs based on the current system screen design.

Currently, customizing some dialogs for small screen environment is done statically on the build stage by setting wxPG_SMALL_SCREEN to 1 (what is done for WXWINCE only).
Instead, we can do this for all platforms in a dynamic manner, based on the classification provided by wxSystemSettings::GetScreenType() function.
In order to do so there is introduced a static helper function wxPropertyGrid::IsSmallScreen() which is used to select right parameters (size, position) for several dialogs in order to display them correctly on the small screen.
This commit is contained in:
Artur Wieczorek 2015-06-08 21:46:03 +02:00
parent 8367c3c0ca
commit cb6efbd3c3
4 changed files with 45 additions and 45 deletions

View File

@ -1556,6 +1556,12 @@ public:
static wxString& CreateEscapeSequences( wxString& dst_str,
wxString& src_str );
// Checks system screen design used for laying out various dialogs.
static bool IsSmallScreen()
{
return wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA;
}
/**
Returns rectangle that fully contains properties between and including
p1 and p2. Rectangle is in virtual scrolled window coordinates.

View File

@ -177,14 +177,6 @@
// Use this macro to generate standard custom image height from
#define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3)
#if defined(__WXWINCE__)
#define wxPG_SMALL_SCREEN 1
#else
#define wxPG_SMALL_SCREEN 0
#endif
// Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
// (for tree buttons)
//#undef wxPG_ICON_WIDTH

View File

@ -1696,10 +1696,12 @@ void wxPropertyGrid::SetCurControlBoldFont()
wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p,
const wxSize& sz )
{
#if wxPG_SMALL_SCREEN
// On small-screen devices, always show dialogs with default position and size.
return wxDefaultPosition;
#else
if ( IsSmallScreen() )
{
// On small-screen devices, always show dialogs with default position and size.
return wxDefaultPosition;
}
int splitterX = GetSplitterPosition();
int x = splitterX;
int y = p->GetY();
@ -1729,7 +1731,6 @@ wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p,
new_y = y + m_lineHeight;
return wxPoint(new_x,new_y);
#endif
}
// -----------------------------------------------------------------------

View File

@ -1833,7 +1833,19 @@ wxValidator* wxDirProperty::DoGetValidator() const
bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
{
// Update property value from editor, if necessary
wxSize dlg_sz(300,400);
wxSize dlg_sz;
wxPoint dlg_pos;
if ( wxPropertyGrid::IsSmallScreen() )
{
dlg_sz = wxDefaultSize;
dlg_pos = wxDefaultPosition;
}
else
{
dlg_sz.Set(300, 400);
dlg_pos = propGrid->GetGoodEditorDialogPosition(this, dlg_sz);
}
wxString dlgMessage(m_dlgMessage);
if ( dlgMessage.empty() )
@ -1842,13 +1854,7 @@ bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value )
dlgMessage,
value,
0,
#if !wxPG_SMALL_SCREEN
propGrid->GetGoodEditorDialogPosition(this,dlg_sz),
dlg_sz
#else
wxDefaultPosition,
wxDefaultSize
#endif
dlg_pos, dlg_sz
);
if ( dlg.ShowModal() == wxID_OK )
@ -2225,11 +2231,7 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr
dlg->SetFont(propGrid->GetFont()); // To allow entering chars of the same set as the propGrid
// Multi-line text editor dialog.
#if !wxPG_SMALL_SCREEN
const int spacing = 8;
#else
const int spacing = 4;
#endif
const int spacing = wxPropertyGrid::IsSmallScreen()? 4 : 8;
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
long edStyle = wxTE_MULTILINE;
@ -2251,11 +2253,12 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr
dlg->SetSizer( topsizer );
topsizer->SetSizeHints( dlg );
#if !wxPG_SMALL_SCREEN
dlg->SetSize(400,300);
if ( !wxPropertyGrid::IsSmallScreen())
{
dlg->SetSize(400,300);
dlg->Move( propGrid->GetGoodEditorDialogPosition(prop,dlg->GetSize()) );
#endif
dlg->Move( propGrid->GetGoodEditorDialogPosition(prop,dlg->GetSize()) );
}
int res = dlg->ShowModal();
@ -2372,11 +2375,7 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent,
SetFont(parent->GetFont()); // To allow entering chars of the same set as the propGrid
#if !wxPG_SMALL_SCREEN
const int spacing = 4;
#else
const int spacing = 3;
#endif
const int spacing = wxPropertyGrid::IsSmallScreen()? 3: 4;
m_modified = false;
@ -2447,13 +2446,14 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent,
SetSizer( topsizer );
topsizer->SetSizeHints( this );
#if !wxPG_SMALL_SCREEN
if ( sz.x == wxDefaultSize.x &&
sz.y == wxDefaultSize.y )
SetSize( wxSize(275,360) );
else
SetSize(sz);
#endif
if ( !wxPropertyGrid::IsSmallScreen() )
{
if ( sz.x == wxDefaultSize.x &&
sz.y == wxDefaultSize.y )
SetSize(275, 360);
else
SetSize(sz);
}
return res;
}
@ -2821,9 +2821,10 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid,
dlg->SetDialogValue( useValue );
dlg->Create(propGrid, wxEmptyString, m_label);
#if !wxPG_SMALL_SCREEN
dlg->Move( propGrid->GetGoodEditorDialogPosition(this,dlg->GetSize()) );
#endif
if ( !wxPropertyGrid::IsSmallScreen() )
{
dlg->Move( propGrid->GetGoodEditorDialogPosition(this,dlg->GetSize()) );
}
bool retVal;