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
This commit is contained in:
Vadim Zeitlin
2013-03-31 01:12:27 +00:00
parent 00a399c062
commit f75b1bd31c
12 changed files with 38 additions and 21 deletions

View File

@@ -73,6 +73,9 @@ public:
// -------------------------- // --------------------------
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_DEFAULT; }
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;

View File

@@ -68,6 +68,9 @@ protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_DEFAULT; }
// set the GTK toolbar style and orientation // set the GTK toolbar style and orientation
void GtkSetStyle(); void GtkSetStyle();

View File

@@ -22,7 +22,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr) const wxString& name = wxToolBarNameStr)
{ {
Init(); Init();
@@ -34,7 +34,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual ~wxToolBar(); virtual ~wxToolBar();

View File

@@ -27,7 +27,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr) const wxString& name = wxToolBarNameStr)
{ {
Init(); Init();
@@ -39,7 +39,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
virtual ~wxToolBar(); virtual ~wxToolBar();

View File

@@ -29,7 +29,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr) const wxString& name = wxToolBarNameStr)
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
@@ -39,7 +39,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);
// override/implement base class virtuals // override/implement base class virtuals
@@ -88,7 +88,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr, const wxString& name = wxToolBarNameStr,
wxMenuBar* menuBar = NULL) wxMenuBar* menuBar = NULL)
{ {
@@ -101,7 +101,7 @@ public:
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr, const wxString& name = wxToolBarNameStr,
wxMenuBar* menuBar = NULL); wxMenuBar* menuBar = NULL);

View File

@@ -35,7 +35,7 @@ public:
,wxWindowID vId ,wxWindowID vId
,const wxPoint& rPos = wxDefaultPosition ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize ,const wxSize& rSize = wxDefaultSize
,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL ,long lStyle = wxTB_HORIZONTAL
,const wxString& rName = wxToolBarNameStr ,const wxString& rName = wxToolBarNameStr
) : m_vToolTimer(this, ID_TOOLTIMER) ) : m_vToolTimer(this, ID_TOOLTIMER)
, m_vToolExpTimer(this, ID_TOOLEXPTIMER) , m_vToolExpTimer(this, ID_TOOLEXPTIMER)
@@ -55,7 +55,7 @@ public:
,wxWindowID vId ,wxWindowID vId
,const wxPoint& rPos = wxDefaultPosition ,const wxPoint& rPos = wxDefaultPosition
,const wxSize& rSize = wxDefaultSize ,const wxSize& rSize = wxDefaultSize
,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL ,long lStyle = wxTB_HORIZONTAL
,const wxString& rName = wxToolBarNameStr ,const wxString& rName = wxToolBarNameStr
); );

View File

@@ -29,7 +29,7 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase
inline wxToolBar(wxWindow *parent, wxWindowID id, inline wxToolBar(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL, long style = wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr) const wxString& name = wxToolBarNameStr)
{ {
Init(); Init();
@@ -38,7 +38,7 @@ class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase
virtual ~wxToolBar(); virtual ~wxToolBar();
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, 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); const wxString& name = wxToolBarNameStr);
virtual void SetWindowStyleFlag(long style); virtual void SetWindowStyleFlag(long style);

View File

@@ -609,6 +609,9 @@ public:
#endif #endif
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// to implement in derived classes // to implement in derived classes
// ------------------------------- // -------------------------------

View File

@@ -60,7 +60,9 @@ enum
wxTB_BOTTOM = 0x2000, wxTB_BOTTOM = 0x2000,
// lay out toolbar at the right edge of the window // 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 #if wxUSE_TOOLBAR

View File

@@ -274,7 +274,7 @@ public:
@see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar() @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, wxWindowID id = wxID_ANY,
const wxString& name = wxToolBarNameStr); const wxString& name = wxToolBarNameStr);

View File

@@ -18,12 +18,12 @@ enum wxToolBarToolStyle
enum enum
{ {
/** lay out the toolbar horizontally */ /** lay out the toolbar horizontally */
wxTB_HORIZONTAL, wxTB_HORIZONTAL = wxHORIZONTAL,
wxTB_TOP, wxTB_TOP = wxTB_HORIZONTAL,
/** lay out the toolbar vertically */ /** lay out the toolbar vertically */
wxTB_VERTICAL, wxTB_VERTICAL = wxVERTICAL,
wxTB_LEFT, wxTB_LEFT = wxTB_VERTICAL,
/** show 3D buttons (wxToolBarSimple only) */ /** show 3D buttons (wxToolBarSimple only) */
wxTB_3DBUTTONS, wxTB_3DBUTTONS,
@@ -48,7 +48,7 @@ enum
/** show the text and the icons alongside, not vertically stacked (Win32/GTK) */ /** show the text and the icons alongside, not vertically stacked (Win32/GTK) */
wxTB_HORZ_LAYOUT, wxTB_HORZ_LAYOUT,
wxTB_HORZ_TEXT, wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT,
/** don't show the toolbar short help tooltips */ /** don't show the toolbar short help tooltips */
wxTB_NO_TOOLTIPS, wxTB_NO_TOOLTIPS,
@@ -57,7 +57,10 @@ enum
wxTB_BOTTOM, wxTB_BOTTOM,
/** lay out toolbar at the right edge of the window */ /** 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. Align the toolbar at the bottom of parent window.
@style{wxTB_RIGHT} @style{wxTB_RIGHT}
Align the toolbar at the right side of parent window. 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 @endStyleTable
See also @ref overview_windowstyles. Note that the wxMSW native toolbar See also @ref overview_windowstyles. Note that the wxMSW native toolbar

View File

@@ -562,7 +562,7 @@ wxToolBar* wxFrameBase::CreateToolBar(long style,
// a) this allows us to have different defaults for different // a) this allows us to have different defaults for different
// platforms (even if we don't have them right now) // platforms (even if we don't have them right now)
// b) we don't need to include wx/toolbar.h in the header then // 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)); SetToolBar(OnCreateToolBar(style, id, name));