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, static wxString& CreateEscapeSequences( wxString& dst_str,
wxString& src_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 Returns rectangle that fully contains properties between and including
p1 and p2. Rectangle is in virtual scrolled window coordinates. 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 // Use this macro to generate standard custom image height from
#define wxPG_STD_CUST_IMAGE_HEIGHT(LINEHEIGHT) (LINEHEIGHT-3) #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 // Undefine wxPG_ICON_WIDTH to use supplied xpm bitmaps instead
// (for tree buttons) // (for tree buttons)
//#undef wxPG_ICON_WIDTH //#undef wxPG_ICON_WIDTH

View File

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

View File

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