From f75b1bd31cd26232b750615e6a3d18f69e844866 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 31 Mar 2013 01:12:27 +0000 Subject: [PATCH] Make wxToolBar styles consistent and add wxTB_DEFAULT_STYLE. Don't include wxBORDER_NONE in neither wxToolBar ctor and Create() nor wxFrame::CreateToolBar() flags parameter, override GetDefaultBorder() in wxToolBar itself instead to use the border style appropriate for the current platform by default. This has the same effect -- the default border style is used unless another one is explicitly specified -- but is more clear and consistent. Also add wxTB_DEFAULT_STYLE for consistency with the other classes. Closes #15037. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73757 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/toolbar.h | 3 +++ include/wx/gtk1/toolbar.h | 3 +++ include/wx/motif/toolbar.h | 4 ++-- include/wx/msw/toolbar.h | 4 ++-- include/wx/msw/wince/tbarwce.h | 8 ++++---- include/wx/os2/toolbar.h | 4 ++-- include/wx/osx/toolbar.h | 4 ++-- include/wx/tbarbase.h | 3 +++ include/wx/toolbar.h | 4 +++- interface/wx/frame.h | 2 +- interface/wx/toolbar.h | 18 ++++++++++++------ src/common/framecmn.cpp | 2 +- 12 files changed, 38 insertions(+), 21 deletions(-) diff --git a/include/wx/gtk/toolbar.h b/include/wx/gtk/toolbar.h index 8326870f49..e099dbb93c 100644 --- a/include/wx/gtk/toolbar.h +++ b/include/wx/gtk/toolbar.h @@ -73,6 +73,9 @@ public: // -------------------------- protected: + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const { return wxBORDER_DEFAULT; } + virtual wxSize DoGetBestSize() const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; diff --git a/include/wx/gtk1/toolbar.h b/include/wx/gtk1/toolbar.h index 616fba913f..87ec63db31 100644 --- a/include/wx/gtk1/toolbar.h +++ b/include/wx/gtk1/toolbar.h @@ -68,6 +68,9 @@ protected: // common part of all ctors void Init(); + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const { return wxBORDER_DEFAULT; } + // set the GTK toolbar style and orientation void GtkSetStyle(); diff --git a/include/wx/motif/toolbar.h b/include/wx/motif/toolbar.h index 6407334fce..486bfa4c86 100644 --- a/include/wx/motif/toolbar.h +++ b/include/wx/motif/toolbar.h @@ -22,7 +22,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr) { Init(); @@ -34,7 +34,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr); virtual ~wxToolBar(); diff --git a/include/wx/msw/toolbar.h b/include/wx/msw/toolbar.h index bf02037ca3..5e4383f0a0 100644 --- a/include/wx/msw/toolbar.h +++ b/include/wx/msw/toolbar.h @@ -27,7 +27,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr) { Init(); @@ -39,7 +39,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr); virtual ~wxToolBar(); diff --git a/include/wx/msw/wince/tbarwce.h b/include/wx/msw/wince/tbarwce.h index 8b4618e2a4..9e7eb0cc27 100644 --- a/include/wx/msw/wince/tbarwce.h +++ b/include/wx/msw/wince/tbarwce.h @@ -29,7 +29,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr) { Create(parent, id, pos, size, style, name); @@ -39,7 +39,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr); // override/implement base class virtuals @@ -88,7 +88,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr, wxMenuBar* menuBar = NULL) { @@ -101,7 +101,7 @@ public: wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER | wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr, wxMenuBar* menuBar = NULL); diff --git a/include/wx/os2/toolbar.h b/include/wx/os2/toolbar.h index b38fb1579a..acb2ec8fbd 100644 --- a/include/wx/os2/toolbar.h +++ b/include/wx/os2/toolbar.h @@ -35,7 +35,7 @@ public: ,wxWindowID vId ,const wxPoint& rPos = wxDefaultPosition ,const wxSize& rSize = wxDefaultSize - ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL + ,long lStyle = wxTB_HORIZONTAL ,const wxString& rName = wxToolBarNameStr ) : m_vToolTimer(this, ID_TOOLTIMER) , m_vToolExpTimer(this, ID_TOOLEXPTIMER) @@ -55,7 +55,7 @@ public: ,wxWindowID vId ,const wxPoint& rPos = wxDefaultPosition ,const wxSize& rSize = wxDefaultSize - ,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL + ,long lStyle = wxTB_HORIZONTAL ,const wxString& rName = wxToolBarNameStr ); diff --git a/include/wx/osx/toolbar.h b/include/wx/osx/toolbar.h index c40b709e05..3189049f0f 100644 --- a/include/wx/osx/toolbar.h +++ b/include/wx/osx/toolbar.h @@ -29,7 +29,7 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase inline wxToolBar(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER|wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr) { Init(); @@ -38,7 +38,7 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase virtual ~wxToolBar(); bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxNO_BORDER|wxTB_HORIZONTAL, + long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr); virtual void SetWindowStyleFlag(long style); diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index b368ff8c9e..709b7c53ea 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -609,6 +609,9 @@ public: #endif protected: + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; } + // to implement in derived classes // ------------------------------- diff --git a/include/wx/toolbar.h b/include/wx/toolbar.h index 8d316c2a45..3a495576dc 100644 --- a/include/wx/toolbar.h +++ b/include/wx/toolbar.h @@ -60,7 +60,9 @@ enum wxTB_BOTTOM = 0x2000, // lay out toolbar at the right edge of the window - wxTB_RIGHT = 0x4000 + wxTB_RIGHT = 0x4000, + + wxTB_DEFAULT_STYLE = wxTB_HORIZONTAL | wxTB_FLAT }; #if wxUSE_TOOLBAR diff --git a/interface/wx/frame.h b/interface/wx/frame.h index 9fda5c534e..1bf4589e14 100644 --- a/interface/wx/frame.h +++ b/interface/wx/frame.h @@ -274,7 +274,7 @@ public: @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar() */ - virtual wxToolBar* CreateToolBar(long style = wxBORDER_NONE | wxTB_HORIZONTAL, + virtual wxToolBar* CreateToolBar(long style = wxTB_DEFAULT_STYLE, wxWindowID id = wxID_ANY, const wxString& name = wxToolBarNameStr); diff --git a/interface/wx/toolbar.h b/interface/wx/toolbar.h index 9f0f8674ce..c94cb9c985 100644 --- a/interface/wx/toolbar.h +++ b/interface/wx/toolbar.h @@ -18,12 +18,12 @@ enum wxToolBarToolStyle enum { /** lay out the toolbar horizontally */ - wxTB_HORIZONTAL, - wxTB_TOP, + wxTB_HORIZONTAL = wxHORIZONTAL, + wxTB_TOP = wxTB_HORIZONTAL, /** lay out the toolbar vertically */ - wxTB_VERTICAL, - wxTB_LEFT, + wxTB_VERTICAL = wxVERTICAL, + wxTB_LEFT = wxTB_VERTICAL, /** show 3D buttons (wxToolBarSimple only) */ wxTB_3DBUTTONS, @@ -48,7 +48,7 @@ enum /** show the text and the icons alongside, not vertically stacked (Win32/GTK) */ wxTB_HORZ_LAYOUT, - wxTB_HORZ_TEXT, + wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT, /** don't show the toolbar short help tooltips */ wxTB_NO_TOOLTIPS, @@ -57,7 +57,10 @@ enum wxTB_BOTTOM, /** lay out toolbar at the right edge of the window */ - wxTB_RIGHT + wxTB_RIGHT, + + /** flags that are closest to the native look*/ + wxTB_DEFAULT_STYLE = wxTB_HORIZONTAL | wxTB_FLAT }; @@ -216,6 +219,9 @@ public: Align the toolbar at the bottom of parent window. @style{wxTB_RIGHT} Align the toolbar at the right side of parent window. + @style{wxTB_DEFAULT_STYLE} + Combination of @c wxTB_HORIZONTAL and @c wxTB_FLAT. This style is new + since wxWidgets 2.9.5. @endStyleTable See also @ref overview_windowstyles. Note that the wxMSW native toolbar diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index 3e96a8291b..45349869f3 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -562,7 +562,7 @@ wxToolBar* wxFrameBase::CreateToolBar(long style, // a) this allows us to have different defaults for different // platforms (even if we don't have them right now) // b) we don't need to include wx/toolbar.h in the header then - style = wxBORDER_NONE | wxTB_HORIZONTAL | wxTB_FLAT; + style = wxTB_DEFAULT_STYLE; } SetToolBar(OnCreateToolBar(style, id, name)); -- 2.45.2