construct brush used for painting disabled bitmap buttons dynamically (heavily modified patch 1027243)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,6 +48,7 @@ public:
|
|||||||
const wxString& name = wxButtonNameStr);
|
const wxString& name = wxButtonNameStr);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
|
virtual bool SetBackgroundColour(const wxColour& colour);
|
||||||
virtual void SetDefault();
|
virtual void SetDefault();
|
||||||
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
||||||
virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
|
virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
|
||||||
@@ -57,7 +58,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
private:
|
wxBrush m_brushDisabled;
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -111,8 +111,6 @@ const wxChar *wxMDIFrameClassNameNoRedraw = wxT("wxMDIFrameClassNR");
|
|||||||
const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass");
|
const wxChar *wxMDIChildFrameClassName = wxT("wxMDIChildFrameClass");
|
||||||
const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR");
|
const wxChar *wxMDIChildFrameClassNameNoRedraw = wxT("wxMDIChildFrameClassNR");
|
||||||
|
|
||||||
HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -325,20 +323,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
|
|
||||||
RegisterWindowClasses();
|
RegisterWindowClasses();
|
||||||
|
|
||||||
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
|
|
||||||
// Create the brush for disabling bitmap buttons
|
|
||||||
LOGBRUSH lb;
|
|
||||||
lb.lbStyle = BS_PATTERN;
|
|
||||||
lb.lbColor = 0;
|
|
||||||
lb.lbHatch = (int)LoadBitmap( wxhInstance, wxT("wxDISABLE_BUTTON_BITMAP") );
|
|
||||||
if ( lb.lbHatch )
|
|
||||||
{
|
|
||||||
wxDisableButtonBrush = ::CreateBrushIndirect( &lb );
|
|
||||||
::DeleteObject( (HGDIOBJ)lb.lbHatch );
|
|
||||||
}
|
|
||||||
//else: wxWidgets resources are probably not linked in
|
|
||||||
#endif // !__WXMICROWIN__ && !__WXWINCE__
|
|
||||||
|
|
||||||
#if wxUSE_PENWINDOWS
|
#if wxUSE_PENWINDOWS
|
||||||
wxRegisterPenWin();
|
wxRegisterPenWin();
|
||||||
#endif
|
#endif
|
||||||
@@ -512,9 +496,6 @@ void wxApp::CleanUp()
|
|||||||
wxCleanUpPenWin();
|
wxCleanUpPenWin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( wxDisableButtonBrush )
|
|
||||||
::DeleteObject( wxDisableButtonBrush );
|
|
||||||
|
|
||||||
#if wxUSE_OLE
|
#if wxUSE_OLE
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
::CoUninitialize();
|
::CoUninitialize();
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// macros
|
// macros
|
||||||
@@ -168,6 +169,20 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxBitmapButton::SetBackgroundColour(const wxColour& colour)
|
||||||
|
{
|
||||||
|
if ( !wxBitmapButtonBase::SetBackgroundColour(colour) )
|
||||||
|
{
|
||||||
|
// didn't change
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalidate the brush, it will be recreated the next time it's needed
|
||||||
|
m_brushDisabled = wxNullBrush;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// VZ: should be at the very least less than wxDEFAULT_BUTTON_MARGIN
|
// VZ: should be at the very least less than wxDEFAULT_BUTTON_MARGIN
|
||||||
#define FOCUS_MARGIN 3
|
#define FOCUS_MARGIN 3
|
||||||
|
|
||||||
@@ -415,11 +430,28 @@ void wxBitmapButton::DrawButtonFocus( WXHDC dc, int left, int top, int right,
|
|||||||
DrawFocusRect( (HDC) dc, &rect );
|
DrawFocusRect( (HDC) dc, &rect );
|
||||||
}
|
}
|
||||||
|
|
||||||
extern HBRUSH wxDisableButtonBrush;
|
void
|
||||||
void wxBitmapButton::DrawButtonDisable( WXHDC dc, int left, int top, int right,
|
wxBitmapButton::DrawButtonDisable( WXHDC dc,
|
||||||
int bottom, bool with_marg )
|
int left, int top, int right, int bottom,
|
||||||
|
bool with_marg )
|
||||||
{
|
{
|
||||||
HBRUSH old = (HBRUSH) SelectObject( (HDC) dc, wxDisableButtonBrush );
|
if ( !m_brushDisabled.Ok() )
|
||||||
|
{
|
||||||
|
// draw a bitmap with two black and two background colour pixels
|
||||||
|
wxBitmap bmp(2, 2);
|
||||||
|
wxMemoryDC dc;
|
||||||
|
dc.SelectObject(bmp);
|
||||||
|
dc.SetPen(*wxBLACK_PEN);
|
||||||
|
dc.DrawPoint(0, 0);
|
||||||
|
dc.DrawPoint(1, 1);
|
||||||
|
dc.SetPen(GetBackgroundColour());
|
||||||
|
dc.DrawPoint(0, 1);
|
||||||
|
dc.DrawPoint(1, 0);
|
||||||
|
|
||||||
|
m_brushDisabled = wxBrush(bmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectInHDC selectBrush((HDC)dc, GetHbrushOf(m_brushDisabled));
|
||||||
|
|
||||||
// ROP for "dest |= pattern" operation -- as it doesn't have a standard
|
// ROP for "dest |= pattern" operation -- as it doesn't have a standard
|
||||||
// name, give it our own
|
// name, give it our own
|
||||||
@@ -434,8 +466,6 @@ void wxBitmapButton::DrawButtonDisable( WXHDC dc, int left, int top, int right,
|
|||||||
}
|
}
|
||||||
|
|
||||||
::PatBlt( (HDC) dc, left, top, right, bottom, PATTERNPAINT);
|
::PatBlt( (HDC) dc, left, top, right, bottom, PATTERNPAINT);
|
||||||
|
|
||||||
::SelectObject( (HDC) dc, old );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::SetDefault()
|
void wxBitmapButton::SetDefault()
|
||||||
|
Reference in New Issue
Block a user