Use more FromDIP for hardcoded sizes

This commit is contained in:
Maarten Bent
2019-09-28 22:44:38 +02:00
parent 54d514489e
commit 370ae40b35
8 changed files with 22 additions and 21 deletions

View File

@@ -763,7 +763,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
wxDataViewTextRenderer *tr = wxDataViewTextRenderer *tr =
new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_INERT ); new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_INERT );
wxDataViewColumn *column0 = wxDataViewColumn *column0 =
new wxDataViewColumn( "title", tr, 0, 200, wxALIGN_LEFT, new wxDataViewColumn( "title", tr, 0, FromDIP(200), wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE ); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE );
m_ctrl[Page_Music]->AppendColumn( column0 ); m_ctrl[Page_Music]->AppendColumn( column0 );
#if 0 #if 0
@@ -776,10 +776,10 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
tr = new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_EDITABLE ); tr = new wxDataViewTextRenderer( "string", wxDATAVIEW_CELL_EDITABLE );
wxDataViewColumn *column1 = wxDataViewColumn *column1 =
new wxDataViewColumn( "artist", tr, 1, 150, wxALIGN_LEFT, new wxDataViewColumn( "artist", tr, 1, FromDIP(150), wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
wxDATAVIEW_COL_RESIZABLE ); wxDATAVIEW_COL_RESIZABLE );
column1->SetMinWidth(150); // this column can't be resized to be smaller column1->SetMinWidth(FromDIP(150)); // this column can't be resized to be smaller
m_ctrl[Page_Music]->AppendColumn( column1 ); m_ctrl[Page_Music]->AppendColumn( column1 );
// column 2 of the view control: // column 2 of the view control:
@@ -788,7 +788,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
new wxDataViewSpinRenderer( 0, 2010, wxDATAVIEW_CELL_EDITABLE, new wxDataViewSpinRenderer( 0, 2010, wxDATAVIEW_CELL_EDITABLE,
wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
wxDataViewColumn *column2 = wxDataViewColumn *column2 =
new wxDataViewColumn( "year", sr, 2, 60, wxALIGN_LEFT, new wxDataViewColumn( "year", sr, 2, FromDIP(60), wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE ); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE );
m_ctrl[Page_Music]->AppendColumn( column2 ); m_ctrl[Page_Music]->AppendColumn( column2 );
@@ -802,19 +802,19 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
new wxDataViewChoiceRenderer( choices, wxDATAVIEW_CELL_EDITABLE, new wxDataViewChoiceRenderer( choices, wxDATAVIEW_CELL_EDITABLE,
wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
wxDataViewColumn *column3 = wxDataViewColumn *column3 =
new wxDataViewColumn( "rating", c, 3, 100, wxALIGN_LEFT, new wxDataViewColumn( "rating", c, 3, FromDIP(100), wxALIGN_LEFT,
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE ); wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE );
m_ctrl[Page_Music]->AppendColumn( column3 ); m_ctrl[Page_Music]->AppendColumn( column3 );
// column 4 of the view control: // column 4 of the view control:
m_ctrl[Page_Music]->AppendProgressColumn( "popularity", 4, wxDATAVIEW_CELL_INERT, 80 ); m_ctrl[Page_Music]->AppendProgressColumn( "popularity", 4, wxDATAVIEW_CELL_INERT, FromDIP(80) );
// column 5 of the view control: // column 5 of the view control:
MyCustomRenderer *cr = new MyCustomRenderer(wxDATAVIEW_CELL_ACTIVATABLE); MyCustomRenderer *cr = new MyCustomRenderer(wxDATAVIEW_CELL_ACTIVATABLE);
wxDataViewColumn *column5 = wxDataViewColumn *column5 =
new wxDataViewColumn( "custom", cr, 5, -1, wxALIGN_LEFT, new wxDataViewColumn( "custom", cr, 5, wxCOL_WIDTH_DEFAULT, wxALIGN_LEFT,
wxDATAVIEW_COL_RESIZABLE ); wxDATAVIEW_COL_RESIZABLE );
column5->SetBitmap(wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MENU)); column5->SetBitmap(wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MENU));
m_ctrl[Page_Music]->AppendColumn( column5 ); m_ctrl[Page_Music]->AppendColumn( column5 );
@@ -900,7 +900,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
lc->AppendColumn(colRadio, "bool"); lc->AppendColumn(colRadio, "bool");
lc->AppendTextColumn( "Text" ); lc->AppendTextColumn( "Text" );
lc->AppendProgressColumn( "Progress" )->SetMinWidth(100); lc->AppendProgressColumn( "Progress" )->SetMinWidth(FromDIP(100));
wxVector<wxVariant> data; wxVector<wxVariant> data;
for (unsigned int i=0; i<10; i++) for (unsigned int i=0; i<10; i++)
@@ -957,17 +957,17 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
MultiLineCustomRenderer *tr = MultiLineCustomRenderer *tr =
new MultiLineCustomRenderer(); new MultiLineCustomRenderer();
wxDataViewColumn *column0 = wxDataViewColumn *column0 =
new wxDataViewColumn("title", tr, 0, 200, wxALIGN_LEFT, new wxDataViewColumn("title", tr, 0, FromDIP(200), wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
m_ctrl[Page_VarHeight]->AppendColumn(column0); m_ctrl[Page_VarHeight]->AppendColumn(column0);
// column 1 of the view control: // column 1 of the view control:
tr = new MultiLineCustomRenderer(); tr = new MultiLineCustomRenderer();
wxDataViewColumn *column1 = wxDataViewColumn *column1 =
new wxDataViewColumn("artist", tr, 1, 150, wxALIGN_LEFT, new wxDataViewColumn("artist", tr, 1, FromDIP(150), wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
wxDATAVIEW_COL_RESIZABLE); wxDATAVIEW_COL_RESIZABLE);
column1->SetMinWidth(150); // this column can't be resized to be smaller column1->SetMinWidth(FromDIP(150)); // this column can't be resized to be smaller
m_ctrl[Page_VarHeight]->AppendColumn(column1); m_ctrl[Page_VarHeight]->AppendColumn(column1);
} }
break; break;

View File

@@ -307,7 +307,8 @@ bool MyApp::OnInit()
// Create the main frame window // Create the main frame window
MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY,
"wxToolBar Sample", "wxToolBar Sample",
wxPoint(100, 100), wxSize(650, 350)); wxPoint(100, 100), wxDefaultSize);
frame->SetSize(frame->FromDIP(wxSize(650, 350)));
frame->Show(true); frame->Show(true);
@@ -440,7 +441,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
// adding a combo to a vertical toolbar is not very smart // adding a combo to a vertical toolbar is not very smart
if ( !toolBar->IsVertical() ) if ( !toolBar->IsVertical() )
{ {
wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, wxEmptyString, wxDefaultPosition, wxSize(100,-1) ); wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, wxEmptyString, wxDefaultPosition, FromDIP(wxSize(100,-1)) );
combo->Append("This"); combo->Append("This");
combo->Append("is a"); combo->Append("is a");
combo->Append("combobox with extremely, extremely, extremely, extremely long label"); combo->Append("combobox with extremely, extremely, extremely, extremely long label");
@@ -891,7 +892,7 @@ void MyFrame::OnToggleSearch(wxCommandEvent& WXUNUSED(event))
if ( !m_searchTool ) if ( !m_searchTool )
{ {
wxSearchCtrl * const srch = new wxSearchCtrl(tb, wxID_ANY, "needle"); wxSearchCtrl * const srch = new wxSearchCtrl(tb, wxID_ANY, "needle");
srch->SetMinSize(wxSize(80, -1)); srch->SetMinSize(FromDIP(wxSize(80, -1)));
m_searchTool = tb->AddControl(srch); m_searchTool = tb->AddControl(srch);
} }
else // tool already exists else // tool already exists

View File

@@ -107,7 +107,7 @@ wxChoiceBase::~wxChoiceBase()
wxSize wxChoiceBase::DoGetBestSize() const wxSize wxChoiceBase::DoGetBestSize() const
{ {
// a reasonable width for an empty choice list // a reasonable width for an empty choice list
wxSize best(80, -1); wxSize best(FromDIP(80), -1);
const unsigned int nItems = GetCount(); const unsigned int nItems = GetCount();
if ( nItems > 0 ) if ( nItems > 0 )

View File

@@ -1374,7 +1374,7 @@ void wxComboCtrlBase::PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust
wxSize wxComboCtrlBase::DoGetBestSize() const wxSize wxComboCtrlBase::DoGetBestSize() const
{ {
int width = m_text ? m_text->GetBestSize().x : 80; int width = m_text ? m_text->GetBestSize().x : FromDIP(80);
return GetSizeFromTextSize(width); return GetSizeFromTextSize(width);
} }

View File

@@ -327,7 +327,7 @@ wxSize wxAnimationCtrl::DoGetBestSize() const
if (m_animation.IsOk() && !this->HasFlag(wxAC_NO_AUTORESIZE)) if (m_animation.IsOk() && !this->HasFlag(wxAC_NO_AUTORESIZE))
return m_animation.GetSize(); return m_animation.GetSize();
return wxSize(100, 100); return FromDIP(wxSize(100, 100));
} }
void wxAnimationCtrl::SetAnimation(const wxAnimation& animation) void wxAnimationCtrl::SetAnimation(const wxAnimation& animation)

View File

@@ -431,7 +431,7 @@ wxSize wxMSWButton::IncreaseToStdSizeAndCache(wxControl *btn, const wxSize& size
// //
// Note that we intentionally don't use GetDefaultSize() here, because // Note that we intentionally don't use GetDefaultSize() here, because
// it's inexact -- dialog units depend on this dialog's font. // it's inexact -- dialog units depend on this dialog's font.
const wxSize sizeDef = btn->ConvertDialogToPixels(wxSize(50, 14)); const wxSize sizeDef = btn->ConvertDialogToPixels(btn->FromDIP(wxSize(50, 14)));
sizeBtn.IncTo(sizeDef); sizeBtn.IncTo(sizeDef);
} }

View File

@@ -122,9 +122,9 @@ wxSize wxGauge::DoGetBestSize() const
// the smaller one. // the smaller one.
if (HasFlag(wxGA_VERTICAL)) if (HasFlag(wxGA_VERTICAL))
return ConvertDialogToPixels(wxSize(8, 107)); return ConvertDialogToPixels(FromDIP(wxSize(8, 107)));
else else
return ConvertDialogToPixels(wxSize(107, 8)); return ConvertDialogToPixels(FromDIP(wxSize(107, 8)));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -3808,7 +3808,7 @@ void wxRichTextCtrl::OnDropFiles(wxDropFilesEvent& event)
wxSize wxRichTextCtrl::DoGetBestSize() const wxSize wxRichTextCtrl::DoGetBestSize() const
{ {
return wxSize(10, 10); return FromDIP(wxSize(10, 10));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------