Backported the window border improvements to 2.4.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20521 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-05-07 08:36:40 +00:00
parent 7779af28db
commit c5d4a908ee
14 changed files with 69 additions and 105 deletions

View File

@@ -230,6 +230,8 @@ wxMSW:
- fix for multiple consecutive groups of radiobuttons - fix for multiple consecutive groups of radiobuttons
- fix for incorrect display of tooltips in non English locales (Niki Spahiev) - fix for incorrect display of tooltips in non English locales (Niki Spahiev)
- fixed memory leak when setting new wxMask for wxBitmap - fixed memory leak when setting new wxMask for wxBitmap
- improved border handling so it no longer shows a thin and
sunken border under XP
wxMotif: wxMotif:

View File

@@ -213,10 +213,12 @@ public:
wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const;
// Make a Windows extended style from the given wxWindows window style // Make a Windows extended style from the given wxWindows window style
// OBSOLETE: do not use. Use MSWGetStyle instead.
static WXDWORD MakeExtendedStyle(long style, static WXDWORD MakeExtendedStyle(long style,
bool eliminateBorders = FALSE); bool eliminateBorders = FALSE);
// Determine whether 3D effects are wanted // Determine whether 3D effects are wanted
// OBSOLETE: do not use. Use MSWGetStyle instead.
WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const;
// MSW only: TRUE if this control is part of the main control // MSW only: TRUE if this control is part of the main control

View File

@@ -94,16 +94,11 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
const wxString& label, const wxString& label,
WXDWORD exstyle) WXDWORD exstyle)
{ {
// want3D tells us whether or not the style specified a 3D border.
// If so, under WIN16 we can use Ctl3D to give it an appropriate style.
// Sometimes want3D is used to indicate that the non-extended style should have
// WS_BORDER.
bool want3D = TRUE;
// 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;
(void) MSWGetStyle(GetWindowStyle(), & exstyle) ;
} }
// all controls should have this style // all controls should have this style
@@ -141,14 +136,6 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
return FALSE; return FALSE;
} }
#if wxUSE_CTL3D
if ( want3D )
{
Ctl3dSubclassCtl(GetHwnd());
m_useCtl3D = TRUE;
}
#endif // wxUSE_CTL3D
// install wxWindows window proc for this window // install wxWindows window proc for this window
SubclassWin(m_hWnd); SubclassWin(m_hWnd);

View File

@@ -101,11 +101,8 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
int width = size.x; int width = size.x;
int height = size.y; int height = size.y;
long msFlags = WS_CHILD | WS_VISIBLE /* | WS_CLIPSIBLINGS */; WXDWORD exStyle = 0;
long msFlags = MSWGetStyle(style, & exStyle) ;
if ( m_windowStyle & wxCLIP_SIBLINGS )
msFlags |= WS_CLIPSIBLINGS;
if (m_windowStyle & wxGA_VERTICAL) if (m_windowStyle & wxGA_VERTICAL)
msFlags |= PBS_VERTICAL; msFlags |= PBS_VERTICAL;
@@ -114,7 +111,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
msFlags |= PBS_SMOOTH; msFlags |= PBS_SMOOTH;
HWND wx_button = HWND wx_button =
CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags, CreateWindowEx(exStyle, PROGRESS_CLASS, NULL, msFlags,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);

View File

@@ -293,10 +293,6 @@ bool wxGLCanvas::Create(wxWindow *parent,
parent->AddChild(this); parent->AddChild(this);
DWORD msflags = 0; DWORD msflags = 0;
if ( style & wxBORDER )
msflags |= WS_BORDER;
if ( style & wxTHICK_FRAME )
msflags |= WS_THICKFRAME;
/* /*
A general rule with OpenGL and Win32 is that any window that will have a A general rule with OpenGL and Win32 is that any window that will have a
@@ -305,18 +301,9 @@ bool wxGLCanvas::Create(wxWindow *parent,
books that contain the wgl function descriptions. books that contain the wgl function descriptions.
*/ */
WXDWORD exStyle = 0;
msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
msflags |= MSWGetStyle(style, & exStyle) ;
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
if ( want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER ) ||
(m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
{
msflags |= WS_BORDER;
}
return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle); return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle);
} }

View File

@@ -191,15 +191,8 @@ bool wxListBox::Create(wxWindow *parent,
// doesn't work properly // doesn't work properly
wstyle |= LBS_NOINTEGRALHEIGHT; wstyle |= LBS_NOINTEGRALHEIGHT;
bool want3D; WXDWORD exStyle = 0;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); (void) MSWGetStyle(style, & exStyle) ;
// Even with extended styles, need to combine with WS_BORDER for them to
// look right.
if ( want3D || wxStyleHasBorder(m_windowStyle) )
{
wstyle |= WS_BORDER;
}
m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("LISTBOX"), NULL, m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("LISTBOX"), NULL,
wstyle | WS_CHILD, wstyle | WS_CHILD,
@@ -209,14 +202,6 @@ bool wxListBox::Create(wxWindow *parent,
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create listbox") ); wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create listbox") );
#if wxUSE_CTL3D
if (want3D)
{
Ctl3dSubclassCtl(GetHwnd());
m_useCtl3D = TRUE;
}
#endif
// Subclass again to catch messages // Subclass again to catch messages
SubclassWin(m_hWnd); SubclassWin(m_hWnd);

View File

@@ -325,13 +325,8 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h)
{ {
DWORD wstyle = m_baseStyle; DWORD wstyle = m_baseStyle;
bool want3D; WXDWORD exStyle = 0;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); (void) MSWGetStyle(GetWindowStyle(), & exStyle) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
if ( want3D )
wstyle |= WS_BORDER;
long oldStyle = 0; // Dummy long oldStyle = 0; // Dummy
wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle); wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle);

View File

@@ -82,15 +82,13 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
height = 14; height = 14;
} }
DWORD wstyle = WS_VISIBLE | WS_CHILD; WXDWORD exStyle = 0;
WXDWORD wstyle = MSWGetStyle(style, & exStyle) ;
if ( m_windowStyle & wxCLIP_SIBLINGS )
wstyle |= WS_CLIPSIBLINGS;
// Now create scrollbar // Now create scrollbar
DWORD _direction = (style & wxHORIZONTAL) ? DWORD _direction = (style & wxHORIZONTAL) ?
SBS_HORZ: SBS_VERT; SBS_HORZ: SBS_VERT;
HWND scroll_bar = CreateWindowEx(MakeExtendedStyle(style), wxT("SCROLLBAR"), wxT("scrollbar"), HWND scroll_bar = CreateWindowEx(wstyle, wxT("SCROLLBAR"), wxT("scrollbar"),
_direction | wstyle, _direction | wstyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);

View File

@@ -59,6 +59,9 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
style |= wxBORDER_NONE;
SetName(name); SetName(name);
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator(validator); SetValidator(validator);
@@ -90,15 +93,12 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
long msStyle = 0; long msStyle = 0;
long wstyle = 0; long wstyle = 0;
if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS;
if ( m_windowStyle & wxSL_LABELS ) if ( m_windowStyle & wxSL_LABELS )
{ {
msStyle |= WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER; msStyle |= SS_CENTER;
bool want3D; WXDWORD exStyle = 0;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; msStyle |= MSWGetStyle(GetWindowStyle(), & exStyle) ;
m_staticValue = (WXHWND) CreateWindowEx m_staticValue = (WXHWND) CreateWindowEx
( (
@@ -123,7 +123,9 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
); );
} }
msStyle = 0; WXDWORD exStyle = 0;
msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS; msStyle |= WS_CLIPSIBLINGS;
@@ -154,7 +156,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id,
HWND scroll_bar = CreateWindowEx HWND scroll_bar = CreateWindowEx
( (
MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxT(""), exStyle, TRACKBAR_CLASS, wxT(""),
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL wxGetInstance(), NULL

View File

@@ -50,6 +50,9 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT )
style |= wxBORDER_NONE;
SetName(name); SetName(name);
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator(validator); SetValidator(validator);
@@ -78,13 +81,13 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id,
// non-Win95 implementation // non-Win95 implementation
long msStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER; long msStyle = SS_CENTER;
if ( m_windowStyle & wxCLIP_SIBLINGS ) if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS; msStyle |= WS_CLIPSIBLINGS;
bool want3D; WXDWORD exStyle = 0;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; msStyle |= MSWGetStyle(GetWindowStyle(), & exStyle) ;
m_staticValue = (WXHWND) CreateWindowEx(exStyle, wxT("STATIC"), NULL, m_staticValue = (WXHWND) CreateWindowEx(exStyle, wxT("STATIC"), NULL,
msStyle, msStyle,

View File

@@ -265,17 +265,8 @@ bool wxSpinCtrl::Create(wxWindow *parent,
// create the text window // create the text window
bool want3D; WXDWORD exStyle = 0;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
int msStyle = WS_CHILD;
// Even with extended styles, need to combine with WS_BORDER for them to
// look right.
if ( want3D || wxStyleHasBorder(style) )
msStyle |= WS_BORDER;
if ( style & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS;
m_hwndBuddy = (WXHWND)::CreateWindowEx m_hwndBuddy = (WXHWND)::CreateWindowEx
( (

View File

@@ -39,7 +39,12 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
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;
SetName(name); SetName(name);
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
@@ -58,10 +63,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
long msStyle = WS_CHILD | WS_VISIBLE; WXDWORD exStyle = 0;
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS;
if (m_windowStyle & wxALIGN_CENTRE) if (m_windowStyle & wxALIGN_CENTRE)
msStyle |= SS_CENTER; msStyle |= SS_CENTER;
else if (m_windowStyle & wxALIGN_RIGHT) else if (m_windowStyle & wxALIGN_RIGHT)
@@ -69,12 +73,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
else else
msStyle |= SS_LEFT; msStyle |= SS_LEFT;
// Even with extended styles, need to combine with WS_BORDER m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("STATIC"), (const wxChar *)label,
// for them to look right.
if ( wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
m_hWnd = (WXHWND)::CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("STATIC"), (const wxChar *)label,
msStyle, msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL); wxGetInstance(), NULL);

View File

@@ -85,10 +85,10 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
#define BS_PUSHLIKE 0x00001000L #define BS_PUSHLIKE 0x00001000L
#endif #endif
long msStyle = BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP | WS_CHILD | WS_VISIBLE; WXDWORD exStyle = 0;
long msStyle = MSWGetStyle(style, & exStyle) ;
if ( m_windowStyle & wxCLIP_SIBLINGS )
msStyle |= WS_CLIPSIBLINGS; msStyle |= BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP ;
#ifdef __WIN32__ #ifdef __WIN32__
if(m_windowStyle & wxBU_LEFT) if(m_windowStyle & wxBU_LEFT)
@@ -101,7 +101,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
msStyle |= BS_BOTTOM; msStyle |= BS_BOTTOM;
#endif #endif
m_hWnd = (WXHWND)CreateWindowEx(MakeExtendedStyle(m_windowStyle), m_hWnd = (WXHWND)CreateWindowEx(exStyle,
wxT("BUTTON"), label, wxT("BUTTON"), label,
msStyle, 0, 0, 0, 0, msStyle, 0, 0, 0, 0,
(HWND)parent->GetHWND(), (HWND)parent->GetHWND(),

View File

@@ -1155,9 +1155,22 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
style |= WS_CLIPSIBLINGS; style |= WS_CLIPSIBLINGS;
wxBorder border = (wxBorder)(flags & wxBORDER_MASK); wxBorder border = (wxBorder)(flags & wxBORDER_MASK);
if ( border != wxBORDER_NONE && border != wxBORDER_DEFAULT )
style |= WS_BORDER; // 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 && wxTheApp->GetAuto3D() && 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;
// now deal with ext style if the caller wants it // now deal with ext style if the caller wants it
if ( exstyle ) if ( exstyle )
{ {
@@ -1166,7 +1179,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
if ( flags & wxTRANSPARENT_WINDOW ) if ( flags & wxTRANSPARENT_WINDOW )
*exstyle |= WS_EX_TRANSPARENT; *exstyle |= WS_EX_TRANSPARENT;
switch ( flags & wxBORDER_MASK ) switch ( border )
{ {
default: default:
wxFAIL_MSG( _T("unknown border style") ); wxFAIL_MSG( _T("unknown border style") );
@@ -1187,6 +1200,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
case wxBORDER_SUNKEN: case wxBORDER_SUNKEN:
*exstyle |= WS_EX_CLIENTEDGE; *exstyle |= WS_EX_CLIENTEDGE;
style &= ~WS_BORDER;
break; break;
case wxBORDER_DOUBLE: case wxBORDER_DOUBLE:
@@ -1209,6 +1223,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const
} }
// Make a Windows extended style from the given wxWindows window style // Make a Windows extended style from the given wxWindows window style
// OBSOLETE! DO NOT USE. USE MSWGetStyle INSTEAD.
WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders) WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders)
{ {
WXDWORD exStyle = 0; WXDWORD exStyle = 0;
@@ -1236,6 +1251,7 @@ WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders)
// Determines whether native 3D effects or CTL3D should be used, // Determines whether native 3D effects or CTL3D should be used,
// applying a default border style if required, and returning an extended // applying a default border style if required, and returning an extended
// style to pass to CreateWindowEx. // style to pass to CreateWindowEx.
// OBSOLETE! DO NOT USE. USE MSWGetStyle INSTEAD.
WXDWORD wxWindowMSW::Determine3DEffects(WXDWORD defaultBorderStyle, WXDWORD wxWindowMSW::Determine3DEffects(WXDWORD defaultBorderStyle,
bool *want3D) const bool *want3D) const
{ {