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
This commit is contained in:
@@ -21,8 +21,6 @@
|
|||||||
// General item class
|
// General item class
|
||||||
class WXDLLEXPORT wxControl : public wxControlBase
|
class WXDLLEXPORT wxControl : public wxControlBase
|
||||||
{
|
{
|
||||||
DECLARE_ABSTRACT_CLASS(wxControl)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxControl();
|
wxControl();
|
||||||
wxControl(wxWindow *parent, wxWindowID id,
|
wxControl(wxWindow *parent, wxWindowID id,
|
||||||
@@ -78,9 +76,8 @@ public:
|
|||||||
#endif // WXWIN_COMPATIBILITY
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// for controls like radiobuttons which are really composite this array
|
// choose the default border for this window
|
||||||
// holds the ids (not HWNDs!) of the sub controls
|
virtual wxBorder GetDefaultBorder() const;
|
||||||
wxArrayLong m_subControls;
|
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
@@ -117,7 +114,12 @@ protected:
|
|||||||
// default style for the control include WS_TABSTOP if it AcceptsFocus()
|
// default style for the control include WS_TABSTOP if it AcceptsFocus()
|
||||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
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:
|
private:
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxControl)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -80,6 +80,7 @@ public:
|
|||||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual wxBorder GetDefaultBorder() const;
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ 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;
|
||||||
|
@@ -96,9 +96,8 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
|
|||||||
// if no extended style given, determine it ourselves
|
// if no extended style given, determine it ourselves
|
||||||
if ( exstyle == (WXDWORD)-1 )
|
if ( exstyle == (WXDWORD)-1 )
|
||||||
{
|
{
|
||||||
// exstyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
|
|
||||||
exstyle = 0;
|
exstyle = 0;
|
||||||
(void) MSWGetStyle(GetWindowStyle(), & exstyle) ;
|
(void) MSWGetStyle(GetWindowStyle(), &exstyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all controls should have this style
|
// all controls should have this style
|
||||||
@@ -159,6 +158,14 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
|
|||||||
return TRUE;
|
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
|
wxSize wxControl::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
|
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
|
||||||
|
@@ -98,12 +98,6 @@ bool wxStaticBitmap::Create(wxWindow *parent,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
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) )
|
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -140,6 +134,11 @@ 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);
|
||||||
|
@@ -42,10 +42,6 @@ bool wxStaticText::Create(wxWindow *parent,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
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) )
|
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -55,6 +51,11 @@ 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);
|
||||||
|
@@ -355,12 +355,6 @@ void wxTextCtrl::AdoptAttributesFromHWND()
|
|||||||
|
|
||||||
WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
|
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);
|
long msStyle = wxControl::MSWGetStyle(style, exstyle);
|
||||||
|
|
||||||
// styles which we alaways add by default
|
// styles which we alaways add by default
|
||||||
@@ -424,9 +418,6 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
|
|
||||||
void wxTextCtrl::SetWindowStyleFlag(long style)
|
void wxTextCtrl::SetWindowStyleFlag(long style)
|
||||||
{
|
{
|
||||||
if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
|
|
||||||
style |= wxBORDER_SUNKEN;
|
|
||||||
|
|
||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
// we have to deal with some styles separately because they can't be
|
// we have to deal with some styles separately because they can't be
|
||||||
// changed by simply calling SetWindowLong(GWL_STYLE) but can be changed
|
// changed by simply calling SetWindowLong(GWL_STYLE) but can be changed
|
||||||
|
@@ -1028,23 +1028,10 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
|
|||||||
if ( flags & wxHSCROLL )
|
if ( flags & wxHSCROLL )
|
||||||
style |= WS_HSCROLL;
|
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.
|
// WS_BORDER is only required for wxBORDER_SIMPLE
|
||||||
// Note than because 'sunken' actually maps to WS_EX_CLIENTEDGE, which
|
if ( border == wxBORDER_SIMPLE )
|
||||||
// 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)
|
|
||||||
style |= WS_BORDER;
|
style |= WS_BORDER;
|
||||||
|
|
||||||
// now deal with ext style if the caller wants it
|
// now deal with ext style if the caller wants it
|
||||||
@@ -1058,12 +1045,12 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
|
|||||||
switch ( border )
|
switch ( border )
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
case wxBORDER_DEFAULT:
|
||||||
wxFAIL_MSG( _T("unknown border style") );
|
wxFAIL_MSG( _T("unknown border style") );
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case wxBORDER_NONE:
|
case wxBORDER_NONE:
|
||||||
case wxBORDER_SIMPLE:
|
case wxBORDER_SIMPLE:
|
||||||
case wxBORDER_DEFAULT:
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxBORDER_STATIC:
|
case wxBORDER_STATIC:
|
||||||
|
Reference in New Issue
Block a user