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
|
||||
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()
|
||||
};
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -96,7 +96,6 @@ 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);
|
||||
}
|
||||
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user