From 18e2b58e5bf00cdc18c1be869fb222cd7ce4af52 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 3 Nov 2018 22:39:57 +0100 Subject: [PATCH 1/4] Remove unnecessary border around wxEditableListBox buttons This border was added under MSW for some reason, but doesn't seem to be necessary (any longer?). Closes #18265. --- src/generic/editlbox.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index 074fa5fac2..a2616297d3 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -123,45 +123,36 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, wxSizer *subsizer = new wxBoxSizer(wxHORIZONTAL); subsizer->Add(new wxStaticText(subp, wxID_ANY, label), 1, wxALIGN_CENTRE_VERTICAL | wxLEFT, 4); -#ifdef __WXMSW__ - #define BTN_BORDER 4 - // FIXME - why is this needed? There's some reason why sunken border is - // ignored by sizers in wxMSW but not in wxGTK that I can't - // figure out... -#else - #define BTN_BORDER 0 -#endif - if ( m_style & wxEL_ALLOW_EDIT ) { m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxArtProvider::GetBitmap(wxART_EDIT, wxART_BUTTON)); - subsizer->Add(m_bEdit, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + subsizer->Add(m_bEdit, 0, wxALIGN_CENTRE_VERTICAL); } if ( m_style & wxEL_ALLOW_NEW ) { m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_BUTTON)); - subsizer->Add(m_bNew, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + subsizer->Add(m_bNew, 0, wxALIGN_CENTRE_VERTICAL); } if ( m_style & wxEL_ALLOW_DELETE ) { m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxArtProvider::GetBitmap(wxART_DELETE, wxART_BUTTON)); - subsizer->Add(m_bDel, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + subsizer->Add(m_bDel, 0, wxALIGN_CENTRE_VERTICAL); } if (!(m_style & wxEL_NO_REORDER)) { m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxArtProvider::GetBitmap(wxART_GO_UP, wxART_BUTTON)); - subsizer->Add(m_bUp, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + subsizer->Add(m_bUp, 0, wxALIGN_CENTRE_VERTICAL); m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_BUTTON)); - subsizer->Add(m_bDown, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + subsizer->Add(m_bDown, 0, wxALIGN_CENTRE_VERTICAL); } #if wxUSE_TOOLTIPS From 397b5ff01e987736d938976026701de7d23af5a2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 3 Nov 2018 22:43:10 +0100 Subject: [PATCH 2/4] Use wxSizerFlags-based API in wxEditableListBox No real changes, just make the code more clear by using wxSizerFlags. --- src/generic/editlbox.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index a2616297d3..f8ab2b737f 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -121,38 +121,42 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, wxPanel *subp = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL); wxSizer *subsizer = new wxBoxSizer(wxHORIZONTAL); - subsizer->Add(new wxStaticText(subp, wxID_ANY, label), 1, wxALIGN_CENTRE_VERTICAL | wxLEFT, 4); + + subsizer->Add(new wxStaticText(subp, wxID_ANY, label), + wxSizerFlags(1).Center().Border(wxLEFT)); + + const wxSizerFlags centered = wxSizerFlags().Center(); if ( m_style & wxEL_ALLOW_EDIT ) { m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxArtProvider::GetBitmap(wxART_EDIT, wxART_BUTTON)); - subsizer->Add(m_bEdit, 0, wxALIGN_CENTRE_VERTICAL); + subsizer->Add(m_bEdit, centered); } if ( m_style & wxEL_ALLOW_NEW ) { m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_BUTTON)); - subsizer->Add(m_bNew, 0, wxALIGN_CENTRE_VERTICAL); + subsizer->Add(m_bNew, centered); } if ( m_style & wxEL_ALLOW_DELETE ) { m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxArtProvider::GetBitmap(wxART_DELETE, wxART_BUTTON)); - subsizer->Add(m_bDel, 0, wxALIGN_CENTRE_VERTICAL); + subsizer->Add(m_bDel, centered); } if (!(m_style & wxEL_NO_REORDER)) { m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxArtProvider::GetBitmap(wxART_GO_UP, wxART_BUTTON)); - subsizer->Add(m_bUp, 0, wxALIGN_CENTRE_VERTICAL); + subsizer->Add(m_bUp, centered); m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_BUTTON)); - subsizer->Add(m_bDown, 0, wxALIGN_CENTRE_VERTICAL); + subsizer->Add(m_bDown, centered); } #if wxUSE_TOOLTIPS @@ -166,7 +170,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, subp->SetSizer(subsizer); subsizer->Fit(subp); - sizer->Add(subp, 0, wxEXPAND); + sizer->Add(subp, wxSizerFlags().Expand()); long st = wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxSUNKEN_BORDER; if ( style & wxEL_ALLOW_EDIT ) @@ -176,7 +180,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, wxArrayString empty_ar; SetStrings(empty_ar); - sizer->Add(m_listCtrl, 1, wxEXPAND); + sizer->Add(m_listCtrl, wxSizerFlags(1).Expand()); SetSizer(sizer); Layout(); From f24892127dac0a8e7105f91fdb6c7e6391cd0a4d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 3 Nov 2018 22:45:37 +0100 Subject: [PATCH 3/4] Remove unnecessary wxUSE_TOOLTIPS check in wxEditableListBox code SetToolTip() is defined (as doing nothing) even if wxUSE_TOOLTIPS==0, so just call it directly as this allows to save on both the preprocessor check and the check for the button validity. --- src/generic/editlbox.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index f8ab2b737f..3ad94a4ce9 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -131,6 +131,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, { m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxArtProvider::GetBitmap(wxART_EDIT, wxART_BUTTON)); + m_bEdit->SetToolTip(_("Edit item")); subsizer->Add(m_bEdit, centered); } @@ -138,6 +139,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, { m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_BUTTON)); + m_bNew->SetToolTip(_("New item")); subsizer->Add(m_bNew, centered); } @@ -145,6 +147,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, { m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxArtProvider::GetBitmap(wxART_DELETE, wxART_BUTTON)); + m_bDel->SetToolTip(_("Delete item")); subsizer->Add(m_bDel, centered); } @@ -152,21 +155,15 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, { m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxArtProvider::GetBitmap(wxART_GO_UP, wxART_BUTTON)); + m_bUp->SetToolTip(_("Move up")); subsizer->Add(m_bUp, centered); m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_BUTTON)); + m_bDown->SetToolTip(_("Move down")); subsizer->Add(m_bDown, centered); } -#if wxUSE_TOOLTIPS - if ( m_bEdit ) m_bEdit->SetToolTip(_("Edit item")); - if ( m_bNew ) m_bNew->SetToolTip(_("New item")); - if ( m_bDel ) m_bDel->SetToolTip(_("Delete item")); - if ( m_bUp ) m_bUp->SetToolTip(_("Move up")); - if ( m_bDown ) m_bDown->SetToolTip(_("Move down")); -#endif - subp->SetSizer(subsizer); subsizer->Fit(subp); From 31f5f2dc08cf80d904241f03e892367c504c3456 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Nov 2018 17:54:52 +0100 Subject: [PATCH 4/4] Rename a variable in wxEditableListBox code for clarity Rename "centered" into "flagsCentered" to make it more obvious that this variable contains wxSizerFlags. --- src/generic/editlbox.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generic/editlbox.cpp b/src/generic/editlbox.cpp index 3ad94a4ce9..f472e79ec9 100644 --- a/src/generic/editlbox.cpp +++ b/src/generic/editlbox.cpp @@ -125,14 +125,14 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, subsizer->Add(new wxStaticText(subp, wxID_ANY, label), wxSizerFlags(1).Center().Border(wxLEFT)); - const wxSizerFlags centered = wxSizerFlags().Center(); + const wxSizerFlags flagsCentered = wxSizerFlags().Center(); if ( m_style & wxEL_ALLOW_EDIT ) { m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxArtProvider::GetBitmap(wxART_EDIT, wxART_BUTTON)); m_bEdit->SetToolTip(_("Edit item")); - subsizer->Add(m_bEdit, centered); + subsizer->Add(m_bEdit, flagsCentered); } if ( m_style & wxEL_ALLOW_NEW ) @@ -140,7 +140,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxArtProvider::GetBitmap(wxART_NEW, wxART_BUTTON)); m_bNew->SetToolTip(_("New item")); - subsizer->Add(m_bNew, centered); + subsizer->Add(m_bNew, flagsCentered); } if ( m_style & wxEL_ALLOW_DELETE ) @@ -148,7 +148,7 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxArtProvider::GetBitmap(wxART_DELETE, wxART_BUTTON)); m_bDel->SetToolTip(_("Delete item")); - subsizer->Add(m_bDel, centered); + subsizer->Add(m_bDel, flagsCentered); } if (!(m_style & wxEL_NO_REORDER)) @@ -156,12 +156,12 @@ bool wxEditableListBox::Create(wxWindow *parent, wxWindowID id, m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxArtProvider::GetBitmap(wxART_GO_UP, wxART_BUTTON)); m_bUp->SetToolTip(_("Move up")); - subsizer->Add(m_bUp, centered); + subsizer->Add(m_bUp, flagsCentered); m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_BUTTON)); m_bDown->SetToolTip(_("Move down")); - subsizer->Add(m_bDown, centered); + subsizer->Add(m_bDown, flagsCentered); } subp->SetSizer(subsizer);