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
This commit is contained in:
Vadim Zeitlin
1999-11-15 01:19:46 +00:00
parent ba0e7d4111
commit 222594ead7
5 changed files with 64 additions and 42 deletions

View 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)

View 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

View 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))

View 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

View File

@@ -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
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);
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;
// 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);