X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c3732409acc7a1e0b3cdb1f0a5dec7cc49a4b28b..3db799025def6081154db09b3ba3d771f741d91b:/src/msw/statbox.cpp?ds=sidebyside diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index beb2797300..88e485e64b 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -40,8 +40,10 @@ #include "wx/sysopt.h" #include "wx/image.h" #include "wx/dcmemory.h" +#include "wx/sysopt.h" #include "wx/msw/private.h" +#include "wx/msw/missing.h" // ---------------------------------------------------------------------------- // wxWin macros @@ -122,7 +124,8 @@ bool wxStaticBox::Create(wxWindow *parent, return false; #ifndef __WXWINCE__ - Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBox::OnPaint)); + if (!wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint"))) + Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBox::OnPaint)); #endif // !__WXWINCE__ return true; @@ -142,7 +145,12 @@ WXDWORD wxStaticBox::MSWGetStyle(long style, WXDWORD *exstyle) const styleWin &= ~WS_CLIPCHILDREN; if ( exstyle ) - *exstyle = 0; + { + if (wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint"))) + *exstyle = WS_EX_TRANSPARENT; + else + *exstyle = 0; + } return styleWin | BS_GROUPBOX; } @@ -257,35 +265,44 @@ WXHRGN wxStaticBox::MSWGetRegionWithoutChildren() child; child = ::GetWindow(child, GW_HWNDNEXT) ) { - wxWindow *childWindow = wxGetWindowFromHWND((WXHWND) child); - - // can't just test for (this != child) here since if a wxStaticBox - // overlaps another wxStaticBox then neither are drawn. The overlapping - // region will flicker but we shouldn't have overlapping windows anyway. - if ( !childWindow || !wxDynamicCast(childWindow, wxStaticBox) ) + if ( ! ::IsWindowVisible(child) ) + { + // if the window isn't visible then it doesn't need clipped + continue; + } + + LONG style = ::GetWindowLong(child, GWL_STYLE); + wxString str(wxGetWindowClass(child)); + str.UpperCase(); + if ( str == wxT("BUTTON") && (style & BS_GROUPBOX) == BS_GROUPBOX ) { - ::GetWindowRect(child, &rc); - if ( ::RectInRegion(hrgn, &rc) ) + // Don't clip any static boxes, not just this one. This will + // result in flicker in overlapping static boxes, but at least + // they will all be drawn correctly and we shouldn't have + // overlapping windows anyway. + continue; + } + + ::GetWindowRect(child, &rc); + if ( ::RectInRegion(hrgn, &rc) ) + { + // need to remove WS_CLIPSIBLINGS from all sibling windows + // that are within this staticbox if set + if ( style & WS_CLIPSIBLINGS ) { - // need to remove WS_CLIPSIBLINGS from all sibling windows - // that are within this staticbox if set - LONG style = ::GetWindowLong(child, GWL_STYLE); - if ( style & WS_CLIPSIBLINGS ) - { - style &= ~WS_CLIPSIBLINGS; - ::SetWindowLong(child, GWL_STYLE, style); - - // MSDN: "If you have changed certain window data using - // SetWindowLong, you must call SetWindowPos to have the - // changes take effect." - ::SetWindowPos(child, NULL, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | - SWP_FRAMECHANGED); - } - - AutoHRGN hrgnChild(::CreateRectRgnIndirect(&rc)); - ::CombineRgn(hrgn, hrgn, hrgnChild, RGN_DIFF); + style &= ~WS_CLIPSIBLINGS; + ::SetWindowLong(child, GWL_STYLE, style); + + // MSDN: "If you have changed certain window data using + // SetWindowLong, you must call SetWindowPos to have the + // changes take effect." + ::SetWindowPos(child, NULL, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_FRAMECHANGED); } + + AutoHRGN hrgnChild(::CreateRectRgnIndirect(&rc)); + ::CombineRgn(hrgn, hrgn, hrgnChild, RGN_DIFF); } } @@ -306,7 +323,7 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc) // 3. this is backwards compatible behaviour and some people rely on it, // see http://groups.google.com/groups?selm=4252E932.3080801%40able.es wxWindow *parent = GetParent(); - HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(dc.GetHDC(), this); + HBRUSH hbr = (HBRUSH)parent->MSWGetBgBrush(dc.GetHDC(), GetHWND()); // if there is no special brush for painting this control, just use the // solid background colour @@ -320,6 +337,15 @@ void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc) ::FillRect(GetHdcOf(dc), &rc, hbr); } +void wxStaticBox::PaintForeground(wxDC& dc, const RECT& WXUNUSED(rc)) +{ + // NB: neither setting the text colour nor transparent background mode + // doesn't change anything: the static box def window proc still + // draws the label in its own colours, so if we want to have control + // over this we really have to draw everything ourselves + MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0); +} + void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event)) { RECT rc; @@ -331,13 +357,7 @@ void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event)) memdc.SelectObject(bitmap); PaintBackground(memdc, rc); - - // NB: neither setting the text colour nor transparent background mode - // doesn't change anything: the static box def window proc still - // draws the label in its own colours, so if we want to have control - // over this we really have to draw everything ourselves - MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(memdc), 0); - + PaintForeground(memdc, rc); // now only blit the static box border itself, not the interior, to avoid // flicker when background is drawn below