From 65bc172c9776514d64ced1317709202ee4123cd8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 6 Jul 2003 21:35:32 +0000 Subject: [PATCH] implemented GetDefaultBorder() in wxControl, override it in some controls which don't want to have sunken style by default git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21719 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/control.h | 12 +++++++----- include/wx/msw/statbmp.h | 1 + include/wx/msw/stattext.h | 1 + src/msw/control.cpp | 11 +++++++++-- src/msw/statbmp.cpp | 11 +++++------ src/msw/stattext.cpp | 9 +++++---- src/msw/textctrl.cpp | 9 --------- src/msw/window.cpp | 21 ++++----------------- 8 files changed, 32 insertions(+), 43 deletions(-) diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index cba93a1609..8c2310844d 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -21,8 +21,6 @@ // General item class class WXDLLEXPORT wxControl : public wxControlBase { - DECLARE_ABSTRACT_CLASS(wxControl) - public: wxControl(); wxControl(wxWindow *parent, wxWindowID id, @@ -78,9 +76,8 @@ public: #endif // WXWIN_COMPATIBILITY protected: - // for controls like radiobuttons which are really composite this array - // holds the ids (not HWNDs!) of the sub controls - wxArrayLong m_subControls; + // choose the default border for this window + virtual wxBorder GetDefaultBorder() const; virtual wxSize DoGetBestSize() const; @@ -117,7 +114,12 @@ protected: // default style for the control include WS_TABSTOP if it AcceptsFocus() virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; + // for controls like radiobuttons which are really composite this array + // holds the ids (not HWNDs!) of the sub controls + wxArrayLong m_subControls; + private: + DECLARE_ABSTRACT_CLASS(wxControl) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/msw/statbmp.h b/include/wx/msw/statbmp.h index 38a12b3a55..55e2aa35b7 100644 --- a/include/wx/msw/statbmp.h +++ b/include/wx/msw/statbmp.h @@ -80,6 +80,7 @@ public: virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); protected: + virtual wxBorder GetDefaultBorder() const; virtual wxSize DoGetBestSize() const; virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index 27deb48390..311f731f55 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -46,6 +46,7 @@ public: protected: // implement/override some base class virtuals + virtual wxBorder GetDefaultBorder() const; virtual void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO); virtual wxSize DoGetBestSize() const; diff --git a/src/msw/control.cpp b/src/msw/control.cpp index bbb8d431dd..fc29f742cc 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -96,9 +96,8 @@ bool wxControl::MSWCreateControl(const wxChar *classname, // if no extended style given, determine it ourselves if ( exstyle == (WXDWORD)-1 ) { -// exstyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); exstyle = 0; - (void) MSWGetStyle(GetWindowStyle(), & exstyle) ; + (void) MSWGetStyle(GetWindowStyle(), &exstyle); } // all controls should have this style @@ -159,6 +158,14 @@ bool wxControl::MSWCreateControl(const wxChar *classname, return TRUE; } +wxBorder wxControl::GetDefaultBorder() const +{ + // we want to automatically give controls a sunken style (confusingly, + // it may not really mean sunken at all as we map it to WS_EX_CLIENTEDGE + // which is not sunken at all under Windows XP -- rather, just the default) + return wxBORDER_SUNKEN; +} + wxSize wxControl::DoGetBestSize() const { return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT); diff --git a/src/msw/statbmp.cpp b/src/msw/statbmp.cpp index db1d8b11d3..84857d996f 100644 --- a/src/msw/statbmp.cpp +++ b/src/msw/statbmp.cpp @@ -98,12 +98,6 @@ bool wxStaticBitmap::Create(wxWindow *parent, long style, const wxString& name) { - // default border for this control is none - if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) - { - style |= wxBORDER_NONE; - } - if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) return FALSE; @@ -140,6 +134,11 @@ bool wxStaticBitmap::Create(wxWindow *parent, return TRUE; } +wxBorder wxStaticBitmap::GetDefaultBorder() const +{ + return wxBORDER_NONE; +} + WXDWORD wxStaticBitmap::MSWGetStyle(long style, WXDWORD *exstyle) const { WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 5248292eea..5bfc2f0e92 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -42,10 +42,6 @@ bool wxStaticText::Create(wxWindow *parent, long style, const wxString& name) { - // By default, a static text should have no border. - if ((style & wxBORDER_MASK) == wxBORDER_DEFAULT) - style |= wxBORDER_NONE; - if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) return FALSE; @@ -55,6 +51,11 @@ bool wxStaticText::Create(wxWindow *parent, return TRUE; } +wxBorder wxStaticText::GetDefaultBorder() const +{ + return wxBORDER_NONE; +} + WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const { WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 2fa6394831..1c63618df5 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -355,12 +355,6 @@ void wxTextCtrl::AdoptAttributesFromHWND() WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const { - // default border for the text controls is the sunken one - if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) - { - style |= wxBORDER_SUNKEN; - } - long msStyle = wxControl::MSWGetStyle(style, exstyle); // styles which we alaways add by default @@ -424,9 +418,6 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const void wxTextCtrl::SetWindowStyleFlag(long style) { - if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) - style |= wxBORDER_SUNKEN; - #if wxUSE_RICHEDIT // we have to deal with some styles separately because they can't be // changed by simply calling SetWindowLong(GWL_STYLE) but can be changed diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 2f228c0709..eab831591d 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1028,23 +1028,10 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const if ( flags & wxHSCROLL ) style |= WS_HSCROLL; - wxBorder border = (wxBorder)(flags & wxBORDER_MASK); + const wxBorder border = GetBorder(flags); - // Check if we want to automatically give it a sunken style. - // Note than because 'sunken' actually maps to WS_EX_CLIENTEDGE, which - // is a more neutral term, we don't necessarily get a sunken effect in - // Windows XP. Instead we get the appropriate style for the theme. - - if (border == wxBORDER_DEFAULT && - IsKindOf(CLASSINFO(wxControl)) && - GetParent() && - ((GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS)) - { - border = (wxBorder)((flags & wxBORDER_MASK) | wxBORDER_SUNKEN); - } - - // Only give it WS_BORDER for wxBORDER_SIMPLE - if (border & wxBORDER_SIMPLE) + // WS_BORDER is only required for wxBORDER_SIMPLE + if ( border == wxBORDER_SIMPLE ) style |= WS_BORDER; // now deal with ext style if the caller wants it @@ -1058,12 +1045,12 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const switch ( border ) { default: + case wxBORDER_DEFAULT: wxFAIL_MSG( _T("unknown border style") ); // fall through case wxBORDER_NONE: case wxBORDER_SIMPLE: - case wxBORDER_DEFAULT: break; case wxBORDER_STATIC: -- 2.45.2