]> git.saurik.com Git - wxWidgets.git/commitdiff
1. fixed wxStaticBox background erasing (or, rather, restored the old bug)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Nov 1999 01:19:46 +0000 (01:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 15 Nov 1999 01:19:46 +0000 (01:19 +0000)
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
include/wx/msw/statbox.h
src/msw/bitmap.cpp
src/msw/control.cpp
src/msw/statbox.cpp

index da27f5ac324ac444da4d24b2c11f34f6a10271ce..9f3b15938bee6b031f6a1ece035579d4611b29ff 100644 (file)
@@ -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)
index acd5511c8c2f250c7e684b590f65bf719932a823..e1d5f2e85aafdb24e7a02e60070e450525f3865c 100644 (file)
@@ -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
index 4ac9166ef96b1f7e7f7b762ccc24cf6554de9272..6cd926cc5f29b20cf8bd904618d3c2cafbfa578b 100644 (file)
@@ -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))
index 652b4929f78316da326e1e9bea2e7541d06ac083..17c62f087c86172660d6a3f259126663742f7284 100644 (file)
@@ -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
index 1e70d4c60ed89f4501342c4b8550dd35caf8047b..3607bf7d723280d4b3037c90823f700d3f2c684d 100644 (file)
 // ----------------------------------------------------------------------------
 
 #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);