From 222594ead7a8ed85cb0c709850b2eed07fc3ac86 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 15 Nov 1999 01:19:46 +0000 Subject: [PATCH] 1. fixed wxStaticBox background erasing (or, rather, restored the old bug) 2. fixed the mask code in wxBitmap(const wxIcon&) - now it really works (Win32) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/control.h | 13 +++++++++- include/wx/msw/statbox.h | 9 ++----- src/msw/bitmap.cpp | 12 ++++----- src/msw/control.cpp | 20 +++++++++++--- src/msw/statbox.cpp | 56 +++++++++++++++++++++------------------- 5 files changed, 66 insertions(+), 44 deletions(-) diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index da27f5ac32..9f3b15938b 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -73,7 +73,18 @@ protected: // create the control of the given class with the given style, returns FALSE // if creation failed - bool MSWCreateControl(const wxChar *classname, WXDWORD style); + // + // All parameters except classname and style are optional, if the + // size/position are not given, they should be set later with SetSize() and, + // label (the title of the window), of course, is left empty. The extended + // style is determined from the style and the app 3D settings automatically + // if it's not specified explicitly. + bool MSWCreateControl(const wxChar *classname, + WXDWORD style, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const wxString& label = wxEmptyString, + WXDWORD exstyle = (WXDWORD)-1); // determine the extended styles combination for this window (may slightly // modify style parameter, this is why it's non const) diff --git a/include/wx/msw/statbox.h b/include/wx/msw/statbox.h index acd5511c8c..e1d5f2e85a 100644 --- a/include/wx/msw/statbox.h +++ b/include/wx/msw/statbox.h @@ -6,14 +6,14 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_STATBOX_H_ #define _WX_STATBOX_H_ #ifdef __GNUG__ -#pragma interface "statbox.h" + #pragma interface "statbox.h" #endif #include "wx/control.h" @@ -48,8 +48,6 @@ public: // implementation from now on // -------------------------- - void OnEraseBackground(wxEraseEvent& event); - virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, @@ -60,9 +58,6 @@ public: protected: virtual wxSize DoGetBestSize(); - -private: - DECLARE_EVENT_TABLE() }; #endif diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 4ac9166ef9..6cd926cc5f 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -140,10 +140,8 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon) HBITMAP hbitmap = iconInfo.hbmColor; - wxBitmap bmpMask(width, height, 1); - bmpMask.SetHBITMAP((WXHBITMAP)iconInfo.hbmMask); - - SetMask(new wxMask(bmpMask)); + wxMask *mask = new wxMask; + mask->SetMaskBitmap((WXHBITMAP)iconInfo.hbmMask); #endif // Win16/32 m_refData = new wxBitmapRefData; @@ -155,6 +153,10 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon) M_BITMAPDATA->m_hBitmap = (WXHBITMAP)hbitmap; M_BITMAPDATA->m_ok = TRUE; +#ifndef __WIN16__ + SetMask(mask); +#endif // !Win16 + return TRUE; } @@ -162,8 +164,6 @@ wxBitmap::~wxBitmap() { if (wxTheBitmapList) wxTheBitmapList->DeleteObject(this); - - delete GetMask(); } bool wxBitmap::FreeResource(bool WXUNUSED(force)) diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 652b4929f7..17c62f087c 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -58,23 +58,35 @@ wxControl::~wxControl() m_isBeingDeleted = TRUE; } -bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style) +bool wxControl::MSWCreateControl(const wxChar *classname, + WXDWORD style, + const wxPoint& pos, + const wxSize& size, + const wxString& label, + WXDWORD exstyle) { // VZ: if someone could put a comment here explaining what exactly this is // needed for, it would be nice... bool want3D; + // if no extended style given, determine it ourselves + if ( exstyle == (WXDWORD)-1 ) + { + exstyle = GetExStyle(style, &want3D); + } + // all controls have these childs (wxWindows creates all controls visible // by default) style |= WS_CHILD | WS_VISIBLE; m_hWnd = (WXHWND)::CreateWindowEx ( - GetExStyle(style, &want3D), // extended style + exstyle, // extended style classname, // the kind of control to create - NULL, // the window name + label, // the window name style, // the window style - 0, 0, 0, 0, // the window position and size + pos.x, pos.y, // the window position + size.x, size.y, // and size GetHwndOf(GetParent()), // parent (HMENU)GetId(), // child id wxGetInstance(), // app instance diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 1e70d4c60e..3607bf7d72 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -42,12 +42,7 @@ // ---------------------------------------------------------------------------- #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) - -BEGIN_EVENT_TABLE(wxStaticBox, wxControl) - EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground) -END_EVENT_TABLE() - + IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) #endif // ============================================================================ @@ -69,11 +64,9 @@ bool wxStaticBox::Create(wxWindow *parent, if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) return FALSE; - if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX) ) + if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) ) return FALSE; - SetSize(pos.x, pos.y, size.x, size.y); - return TRUE; } @@ -119,26 +112,37 @@ WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, return (WXHBRUSH)brush->GetResourceHandle(); } -void wxStaticBox::OnEraseBackground(wxEraseEvent& event) -{ - // do nothing - the aim of having this function is to prevent - // wxControl::OnEraseBackground() to paint over the control inside the - // static box -} - long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - if ( nMsg == WM_NCHITTEST) + switch ( nMsg ) { - int xPos = LOWORD(lParam); // horizontal position of cursor - int yPos = HIWORD(lParam); // vertical position of cursor - - ScreenToClient(&xPos, &yPos); - - // Make sure you can drag by the top of the groupbox, but let - // other (enclosed) controls get mouse events also - if (yPos < 10) - return (long)HTCLIENT; + case WM_NCHITTEST: + // FIXME: this hack is specific to dialog ed, shouldn't it be + // somehow disabled during normal operation? + { + int xPos = LOWORD(lParam); // horizontal position of cursor + int yPos = HIWORD(lParam); // vertical position of cursor + + ScreenToClient(&xPos, &yPos); + + // Make sure you can drag by the top of the groupbox, but let + // other (enclosed) controls get mouse events also + if ( yPos < 10 ) + return (long)HTCLIENT; + } + break; + + // VZ: I will remove (or change) this soon... (15.11.99) +#if 0 + case WM_ERASEBKGND: + // prevent wxControl from processing this message because it will + // erase the background incorrectly and there is no way for us to + // override this at wxWin event level (if we do process the event, + // we don't know how to do it properly - paint the background + // without painting over other controls - and if we don't, + // wxControl still gets it) + return MSWDefWindowProc(nMsg, wParam, lParam); +#endif } return wxControl::MSWWindowProc(nMsg, wParam, lParam); -- 2.45.2