diff --git a/docs/changes.txt b/docs/changes.txt index e364cd20cf..c1a84c22a5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -230,6 +230,8 @@ wxMSW: - fix for multiple consecutive groups of radiobuttons - fix for incorrect display of tooltips in non English locales (Niki Spahiev) - 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: diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index ff29093534..b80c993338 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -213,10 +213,12 @@ public: wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; // Make a Windows extended style from the given wxWindows window style + // OBSOLETE: do not use. Use MSWGetStyle instead. static WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = FALSE); // Determine whether 3D effects are wanted + // OBSOLETE: do not use. Use MSWGetStyle instead. WXDWORD Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const; // MSW only: TRUE if this control is part of the main control diff --git a/src/msw/control.cpp b/src/msw/control.cpp index ba76513c75..7a6f30fd61 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -94,16 +94,11 @@ bool wxControl::MSWCreateControl(const wxChar *classname, const wxString& label, 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 ( exstyle == (WXDWORD)-1 ) { - exstyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); + exstyle = 0; + (void) MSWGetStyle(GetWindowStyle(), & exstyle) ; } // all controls should have this style @@ -141,14 +136,6 @@ bool wxControl::MSWCreateControl(const wxChar *classname, return FALSE; } -#if wxUSE_CTL3D - if ( want3D ) - { - Ctl3dSubclassCtl(GetHwnd()); - m_useCtl3D = TRUE; - } -#endif // wxUSE_CTL3D - // install wxWindows window proc for this window SubclassWin(m_hWnd); diff --git a/src/msw/gauge95.cpp b/src/msw/gauge95.cpp index efcb6da297..520f0c096e 100644 --- a/src/msw/gauge95.cpp +++ b/src/msw/gauge95.cpp @@ -101,11 +101,8 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id, int width = size.x; int height = size.y; - long msFlags = WS_CHILD | WS_VISIBLE /* | WS_CLIPSIBLINGS */; - - if ( m_windowStyle & wxCLIP_SIBLINGS ) - msFlags |= WS_CLIPSIBLINGS; - + WXDWORD exStyle = 0; + long msFlags = MSWGetStyle(style, & exStyle) ; if (m_windowStyle & wxGA_VERTICAL) msFlags |= PBS_VERTICAL; @@ -114,7 +111,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id, msFlags |= PBS_SMOOTH; 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, wxGetInstance(), NULL); diff --git a/src/msw/glcanvas.cpp b/src/msw/glcanvas.cpp index 44ac48b0b9..2772f79ba4 100644 --- a/src/msw/glcanvas.cpp +++ b/src/msw/glcanvas.cpp @@ -293,10 +293,6 @@ bool wxGLCanvas::Create(wxWindow *parent, parent->AddChild(this); 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 @@ -305,18 +301,9 @@ bool wxGLCanvas::Create(wxWindow *parent, books that contain the wgl function descriptions. */ + WXDWORD exStyle = 0; msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - 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; - } + msflags |= MSWGetStyle(style, & exStyle) ; return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle); } diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index a274222a8a..00d24a6e71 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -191,15 +191,8 @@ bool wxListBox::Create(wxWindow *parent, // doesn't work properly wstyle |= LBS_NOINTEGRALHEIGHT; - 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 || wxStyleHasBorder(m_windowStyle) ) - { - wstyle |= WS_BORDER; - } + WXDWORD exStyle = 0; + (void) MSWGetStyle(style, & exStyle) ; m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("LISTBOX"), NULL, wstyle | WS_CHILD, @@ -209,14 +202,6 @@ bool wxListBox::Create(wxWindow *parent, 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 SubclassWin(m_hWnd); diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index a9605e380b..0b37e1f4ce 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -325,13 +325,8 @@ bool wxListCtrl::DoCreateControl(int x, int y, int w, int h) { DWORD wstyle = m_baseStyle; - 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 ) - wstyle |= WS_BORDER; + WXDWORD exStyle = 0; + (void) MSWGetStyle(GetWindowStyle(), & exStyle) ; long oldStyle = 0; // Dummy wstyle |= ConvertToMSWStyle(oldStyle, m_windowStyle); diff --git a/src/msw/scrolbar.cpp b/src/msw/scrolbar.cpp index 4823e54f29..d46bd8a5a1 100644 --- a/src/msw/scrolbar.cpp +++ b/src/msw/scrolbar.cpp @@ -82,15 +82,13 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, height = 14; } - DWORD wstyle = WS_VISIBLE | WS_CHILD; - - if ( m_windowStyle & wxCLIP_SIBLINGS ) - wstyle |= WS_CLIPSIBLINGS; + WXDWORD exStyle = 0; + WXDWORD wstyle = MSWGetStyle(style, & exStyle) ; // Now create scrollbar DWORD _direction = (style & wxHORIZONTAL) ? 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, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 61eb07927b..4c0b189c18 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -59,6 +59,9 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { + if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) + style |= wxBORDER_NONE; + SetName(name); #if wxUSE_VALIDATORS SetValidator(validator); @@ -90,15 +93,12 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, long msStyle = 0; long wstyle = 0; - if ( m_windowStyle & wxCLIP_SIBLINGS ) - msStyle |= WS_CLIPSIBLINGS; - if ( m_windowStyle & wxSL_LABELS ) { - msStyle |= WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER; + msStyle |= SS_CENTER; - bool want3D; - WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; + WXDWORD exStyle = 0; + msStyle |= MSWGetStyle(GetWindowStyle(), & exStyle) ; 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 ) msStyle |= WS_CLIPSIBLINGS; @@ -154,7 +156,7 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, HWND scroll_bar = CreateWindowEx ( - MakeExtendedStyle(m_windowStyle), TRACKBAR_CLASS, wxT(""), + exStyle, TRACKBAR_CLASS, wxT(""), msStyle, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL diff --git a/src/msw/slidrmsw.cpp b/src/msw/slidrmsw.cpp index af096e87f3..d7171c5702 100644 --- a/src/msw/slidrmsw.cpp +++ b/src/msw/slidrmsw.cpp @@ -50,6 +50,9 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { + if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) + style |= wxBORDER_NONE; + SetName(name); #if wxUSE_VALIDATORS SetValidator(validator); @@ -78,13 +81,13 @@ bool wxSliderMSW::Create(wxWindow *parent, wxWindowID id, // non-Win95 implementation - long msStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTER; + long msStyle = SS_CENTER; if ( m_windowStyle & wxCLIP_SIBLINGS ) msStyle |= WS_CLIPSIBLINGS; - bool want3D; - WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; + WXDWORD exStyle = 0; + msStyle |= MSWGetStyle(GetWindowStyle(), & exStyle) ; m_staticValue = (WXHWND) CreateWindowEx(exStyle, wxT("STATIC"), NULL, msStyle, diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 2a28c5358a..6cc42efe36 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -265,17 +265,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, // create the text window - bool want3D; - WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D); - 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; + WXDWORD exStyle = 0; + WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; m_hwndBuddy = (WXHWND)::CreateWindowEx ( diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 0e9911488d..11827a27d9 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -39,7 +39,12 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, 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); if (parent) parent->AddChild(this); @@ -58,10 +63,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, 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) msStyle |= SS_CENTER; else if (m_windowStyle & wxALIGN_RIGHT) @@ -69,12 +73,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, else msStyle |= SS_LEFT; - // Even with extended styles, need to combine with WS_BORDER - // for them to look right. - if ( wxStyleHasBorder(m_windowStyle) ) - msStyle |= WS_BORDER; - - m_hWnd = (WXHWND)::CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("STATIC"), (const wxChar *)label, + m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("STATIC"), (const wxChar *)label, msStyle, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); diff --git a/src/msw/tglbtn.cpp b/src/msw/tglbtn.cpp index 58889e0fb9..fd31e2c3cd 100644 --- a/src/msw/tglbtn.cpp +++ b/src/msw/tglbtn.cpp @@ -85,10 +85,10 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, #define BS_PUSHLIKE 0x00001000L #endif - long msStyle = BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP | WS_CHILD | WS_VISIBLE; - - if ( m_windowStyle & wxCLIP_SIBLINGS ) - msStyle |= WS_CLIPSIBLINGS; + WXDWORD exStyle = 0; + long msStyle = MSWGetStyle(style, & exStyle) ; + + msStyle |= BS_AUTOCHECKBOX | BS_PUSHLIKE | WS_TABSTOP ; #ifdef __WIN32__ if(m_windowStyle & wxBU_LEFT) @@ -101,7 +101,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, msStyle |= BS_BOTTOM; #endif - m_hWnd = (WXHWND)CreateWindowEx(MakeExtendedStyle(m_windowStyle), + m_hWnd = (WXHWND)CreateWindowEx(exStyle, wxT("BUTTON"), label, msStyle, 0, 0, 0, 0, (HWND)parent->GetHWND(), diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 4822d5b199..ecdc27546f 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1155,9 +1155,22 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const style |= WS_CLIPSIBLINGS; 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 if ( exstyle ) { @@ -1166,7 +1179,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const if ( flags & wxTRANSPARENT_WINDOW ) *exstyle |= WS_EX_TRANSPARENT; - switch ( flags & wxBORDER_MASK ) + switch ( border ) { default: wxFAIL_MSG( _T("unknown border style") ); @@ -1187,6 +1200,7 @@ WXDWORD wxWindowMSW::MSWGetStyle(long flags, WXDWORD *exstyle) const case wxBORDER_SUNKEN: *exstyle |= WS_EX_CLIENTEDGE; + style &= ~WS_BORDER; break; 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 +// OBSOLETE! DO NOT USE. USE MSWGetStyle INSTEAD. WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders) { WXDWORD exStyle = 0; @@ -1236,6 +1251,7 @@ WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders) // Determines whether native 3D effects or CTL3D should be used, // applying a default border style if required, and returning an extended // style to pass to CreateWindowEx. +// OBSOLETE! DO NOT USE. USE MSWGetStyle INSTEAD. WXDWORD wxWindowMSW::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) const {