More border rationalisation. GetDefaultBorder is now mostly defined in base class files.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-11-13 12:10:34 +00:00
parent fba05595e6
commit dc797d8e1b
31 changed files with 104 additions and 39 deletions

View File

@@ -455,6 +455,8 @@ public:
bool IsDragging() const { return m_is_dragging; } bool IsDragging() const { return m_is_dragging; }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
void OnPaint(wxPaintEvent& evt); void OnPaint(wxPaintEvent& evt);
void OnEraseBackground(wxEraseEvent& evt); void OnEraseBackground(wxEraseEvent& evt);
@@ -580,6 +582,8 @@ public:
// virtual bool AcceptsFocus() const { return false; } // virtual bool AcceptsFocus() const { return false; }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// these can be overridden // these can be overridden
virtual void UpdateTabCtrlHeight(); virtual void UpdateTabCtrlHeight();

View File

@@ -243,6 +243,9 @@ protected:
SetSelection_SendEvent = 1 SetSelection_SendEvent = 1
}; };
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// set the selection to the given page, sending the events (which can // set the selection to the given page, sending the events (which can
// possibly prevent the page change from taking place) if SendEvent flag is // possibly prevent the page change from taking place) if SendEvent flag is
// included // included

View File

@@ -78,6 +78,9 @@ public:
static wxSize GetDefaultSize(); static wxSize GetDefaultSize();
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
DECLARE_NO_COPY_CLASS(wxButtonBase) DECLARE_NO_COPY_CLASS(wxButtonBase)
}; };

View File

@@ -118,6 +118,9 @@ public:
} }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; } virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
virtual wxCheckBoxState DoGet3StateValue() const virtual wxCheckBoxState DoGet3StateValue() const

View File

@@ -92,6 +92,9 @@ public:
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const;
// creates the control (calls wxWindowBase::CreateBase inside) and adds it // creates the control (calls wxWindowBase::CreateBase inside) and adds it
// to the list of parents children // to the list of parents children
bool CreateControl(wxWindowBase *parent, bool CreateControl(wxWindowBase *parent,

View File

@@ -88,6 +88,8 @@ public:
virtual bool AcceptsFocus() const { return false; } virtual bool AcceptsFocus() const { return false; }
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// the max position // the max position
int m_rangeMax; int m_rangeMax;

View File

@@ -69,6 +69,8 @@ public:
// wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important ! // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// checks for validity some of the ctor/Create() function parameters // checks for validity some of the ctor/Create() function parameters
void CheckParams(const wxString& label, const wxString& url, long style); void CheckParams(const wxString& label, const wxString& url, long style);

View File

@@ -49,6 +49,7 @@ public:
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
private: private:

View File

@@ -37,6 +37,10 @@ public:
long style = 0, long style = 0,
const wxValidator& val = wxDefaultValidator, const wxValidator& val = wxDefaultValidator,
const wxString &name = wxCheckBoxNameStr ); const wxString &name = wxCheckBoxNameStr );
protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
private: private:
DECLARE_DYNAMIC_CLASS(wxToggleButton) DECLARE_DYNAMIC_CLASS(wxToggleButton)

View File

@@ -86,6 +86,9 @@ public:
virtual bool CanApplyThemeBorder() const { return false; } virtual bool CanApplyThemeBorder() const { return false; }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// common part of all ctors // common part of all ctors
void Init() { m_lastAcceptedSelection = wxID_NONE; } void Init() { m_lastAcceptedSelection = wxID_NONE; }

View File

@@ -61,6 +61,7 @@ public:
virtual bool CanApplyThemeBorder() const { return false; } virtual bool CanApplyThemeBorder() const { return false; }
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
// the date currently shown by the control, may be invalid // the date currently shown by the control, may be invalid

View File

@@ -116,9 +116,6 @@ protected:
virtual void DoMoveWindow(int x, int y, int width, int height); virtual void DoMoveWindow(int x, int y, int width, int height);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// the labels windows, if any // the labels windows, if any
wxSubwindows *m_labels; wxSubwindows *m_labels;

View File

@@ -58,7 +58,6 @@ public:
virtual bool CanApplyThemeBorder() const { return false; } virtual bool CanApplyThemeBorder() const { return false; }
protected: protected:
virtual wxBorder GetDefaultBorder() const;
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
// ctor/dtor helpers // ctor/dtor helpers

View File

@@ -46,9 +46,6 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const;
#ifndef __WXWINCE__ #ifndef __WXWINCE__
public: public:
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);

View File

@@ -44,7 +44,6 @@ public:
protected: protected:
// implement/override some base class virtuals // implement/override some base class virtuals
virtual wxBorder GetDefaultBorder() const;
virtual void DoSetSize(int x, int y, int w, int h, virtual void DoSetSize(int x, int y, int w, int h,
int sizeFlags = wxSIZE_AUTO); int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;

View File

@@ -52,8 +52,8 @@ public:
virtual bool CanApplyThemeBorder() const { return false; } virtual bool CanApplyThemeBorder() const { return false; }
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual wxBorder GetDefaultBorder() const;
private: private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton) DECLARE_DYNAMIC_CLASS_NO_COPY(wxToggleButton)

View File

@@ -448,6 +448,10 @@ protected:
// choose the default border for this window // choose the default border for this window
virtual wxBorder GetDefaultBorder() const; virtual wxBorder GetDefaultBorder() const;
// Translate wxBORDER_THEME (and other border styles if necessary to the value
// that makes most sense for this Windows environment
virtual wxBorder TranslateBorder(wxBorder border) const;
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE

View File

@@ -105,6 +105,9 @@ public:
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// adjust value according to wxSL_INVERSE style // adjust value according to wxSL_INVERSE style
virtual int ValueInvertOrNot(int value) const virtual int ValueInvertOrNot(int value) const
{ {

View File

@@ -45,6 +45,9 @@ public:
virtual bool HasTransparentBackground() { return true; } virtual bool HasTransparentBackground() { return true; }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
DECLARE_NO_COPY_CLASS(wxStaticBitmapBase) DECLARE_NO_COPY_CLASS(wxStaticBitmapBase)

View File

@@ -47,6 +47,9 @@ public:
} }
private: private:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
DECLARE_NO_COPY_CLASS(wxStaticBoxBase) DECLARE_NO_COPY_CLASS(wxStaticBoxBase)
}; };

View File

@@ -50,6 +50,9 @@ public:
virtual bool AcceptsFocus() const { return false; } virtual bool AcceptsFocus() const { return false; }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// set the right size for the right dimension // set the right size for the right dimension
wxSize AdjustSize(const wxSize& size) const wxSize AdjustSize(const wxSize& size) const
{ {

View File

@@ -72,6 +72,9 @@ public:
protected: // functions required for wxST_ELLIPSIZE_* support protected: // functions required for wxST_ELLIPSIZE_* support
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// just calls RemoveMarkup & Ellipsize on the original label. // just calls RemoveMarkup & Ellipsize on the original label.
virtual wxString GetEllipsizedLabelWithoutMarkup() const; virtual wxString GetEllipsizedLabelWithoutMarkup() const;

View File

@@ -57,6 +57,8 @@ public:
bool GetValue() const { return m_value; } bool GetValue() const { return m_value; }
protected: protected:
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
// the current value // the current value
bool m_value; bool m_value;

View File

@@ -1244,7 +1244,8 @@ public:
// area (normal windows can't, but e.g. menubar or statusbar can): // area (normal windows can't, but e.g. menubar or statusbar can):
virtual bool CanBeOutsideClientArea() const { return false; } virtual bool CanBeOutsideClientArea() const { return false; }
// returns true if the platform should explicitly apply a theme border // returns true if the platform should explicitly apply a theme border. Currently
// used only by Windows
virtual bool CanApplyThemeBorder() const { return true; } virtual bool CanApplyThemeBorder() const { return true; }
protected: protected:
@@ -1409,7 +1410,7 @@ protected:
// this allows you to implement standard control borders without // this allows you to implement standard control borders without
// repeating the code in different classes that are not derived from // repeating the code in different classes that are not derived from
// wxControl // wxControl
virtual wxBorder GetDefaultBorderForControl() const { return wxBORDER_SUNKEN; } virtual wxBorder GetDefaultBorderForControl() const { return wxBORDER_THEME; }
// Get the default size for the new window if no explicit size given. TLWs // Get the default size for the new window if no explicit size given. TLWs
// have their own default size so this is just for non top-level windows. // have their own default size so this is just for non top-level windows.

View File

@@ -158,6 +158,12 @@ wxString wxControlBase::RemoveMnemonics(const wxString& str)
return wxStripMenuCodes(str, wxStrip_Mnemonics); return wxStripMenuCodes(str, wxStrip_Mnemonics);
} }
wxBorder wxControlBase::GetDefaultBorder() const
{
return wxBORDER_THEME;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStaticBitmap // wxStaticBitmap
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -245,7 +245,9 @@ wxSize wxControl::DoGetBestSize() const
wxBorder wxControl::GetDefaultBorder() const wxBorder wxControl::GetDefaultBorder() const
{ {
return GetDefaultBorderForControl(); return wxControlBase::GetDefaultBorder();
// return GetDefaultBorderForControl();
} }
// This is a helper for all wxControls made with UPDOWN native control. // This is a helper for all wxControls made with UPDOWN native control.

View File

@@ -171,11 +171,6 @@ bool wxStaticBitmap::Create(wxWindow *parent,
return true; return true;
} }
wxBorder wxStaticBitmap::GetDefaultBorder() const
{
return wxBORDER_NONE;
}
WXDWORD wxStaticBitmap::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxStaticBitmap::MSWGetStyle(long style, WXDWORD *exstyle) const
{ {
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);

View File

@@ -138,11 +138,6 @@ bool wxStaticBox::Create(wxWindow *parent,
return true; return true;
} }
wxBorder wxStaticBox::GetDefaultBorder() const
{
return wxBORDER_NONE;
}
WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const
{ {
long styleWin = wxStaticBoxBase::MSWGetStyle(style, exstyle); long styleWin = wxStaticBoxBase::MSWGetStyle(style, exstyle);

View File

@@ -100,11 +100,6 @@ bool wxStaticText::Create(wxWindow *parent,
return true; return true;
} }
wxBorder wxStaticText::GetDefaultBorder() const
{
return wxBORDER_NONE;
}
WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
{ {
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);

View File

@@ -83,11 +83,6 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
return true; return true;
} }
wxBorder wxToggleButton::GetDefaultBorder() const
{
return wxBORDER_NONE;
}
WXDWORD wxToggleButton::MSWGetStyle(long style, WXDWORD *exstyle) const WXDWORD wxToggleButton::MSWGetStyle(long style, WXDWORD *exstyle) const
{ {
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);

View File

@@ -1309,9 +1309,38 @@ wxBorder wxWindowMSW::GetDefaultBorderForControl() const
wxBorder wxWindowMSW::GetDefaultBorder() const wxBorder wxWindowMSW::GetDefaultBorder() const
{ {
return GetDefaultBorderForControl(); // return GetDefaultBorderForControl();
return wxWindowBase::GetDefaultBorder();
} }
// Translate wxBORDER_THEME (and other border styles if necessary to the value
// that makes most sense for this Windows environment
wxBorder wxWindowMSW::TranslateBorder(wxBorder border) const
{
#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
if (border == wxBORDER_THEME || border == wxBORDER_SUNKEN || border == wxBORDER_SIMPLE)
return wxBORDER_SIMPLE;
else
return wxBORDER_NONE;
#else
#if wxUSE_UXTHEME
if (border == wxBORDER_THEME)
{
if (CanApplyThemeBorder())
{
wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
if (theme)
return wxBORDER_THEME;
}
}
#endif
return border;
#endif
return border;
}
WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
{ {
// translate common wxWidgets styles to Windows ones // translate common wxWidgets styles to Windows ones
@@ -1341,7 +1370,10 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
if ( flags & wxHSCROLL ) if ( flags & wxHSCROLL )
style |= WS_HSCROLL; style |= WS_HSCROLL;
const wxBorder border = GetBorder(flags); const wxBorder border = TranslateBorder(GetBorder(flags));
// After translation, border is now optimized for the specific version of Windows
// and theme engine presence.
// WS_BORDER is only required for wxBORDER_SIMPLE // WS_BORDER is only required for wxBORDER_SIMPLE
if ( border == wxBORDER_SIMPLE ) if ( border == wxBORDER_SIMPLE )
@@ -3260,7 +3292,8 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
case WM_NCCALCSIZE: case WM_NCCALCSIZE:
{ {
wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
if (theme && GetBorder() == wxBORDER_THEME) const wxBorder border = TranslateBorder(GetBorder());
if (theme && border == wxBORDER_THEME)
{ {
// first ask the widget to calculate the border size // first ask the widget to calculate the border size
rc.result = MSWDefWindowProc(message, wParam, lParam); rc.result = MSWDefWindowProc(message, wParam, lParam);
@@ -3300,7 +3333,8 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
case WM_NCPAINT: case WM_NCPAINT:
{ {
wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive(); wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
if (theme && GetBorder() == wxBORDER_THEME) const wxBorder border = TranslateBorder(GetBorder());
if (theme && border == wxBORDER_THEME)
{ {
// first ask the widget to paint its non-client area, such as scrollbars, etc. // first ask the widget to paint its non-client area, such as scrollbars, etc.
rc.result = MSWDefWindowProc(message, wParam, lParam); rc.result = MSWDefWindowProc(message, wParam, lParam);