]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/bmpbuttn.h
no real changes, just refactor/simplify the code to remove duplication and unnecessar...
[wxWidgets.git] / include / wx / msw / bmpbuttn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/bmpbuttn.h
3 // Purpose: wxBitmapButton class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BMPBUTTN_H_
13 #define _WX_BMPBUTTN_H_
14
15 #include "wx/button.h"
16 #include "wx/bitmap.h"
17 #include "wx/brush.h"
18
19 class WXDLLEXPORT wxBitmapButton : public wxBitmapButtonBase
20 {
21 public:
22 wxBitmapButton() { Init(); }
23
24 wxBitmapButton(wxWindow *parent,
25 wxWindowID id,
26 const wxBitmap& bitmap,
27 const wxPoint& pos = wxDefaultPosition,
28 const wxSize& size = wxDefaultSize,
29 long style = wxBU_AUTODRAW,
30 const wxValidator& validator = wxDefaultValidator,
31 const wxString& name = wxButtonNameStr)
32 {
33 Init();
34
35 Create(parent, id, bitmap, pos, size, style, validator, name);
36 }
37
38 bool Create(wxWindow *parent,
39 wxWindowID id,
40 const wxBitmap& bitmap,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxBU_AUTODRAW,
44 const wxValidator& validator = wxDefaultValidator,
45 const wxString& name = wxButtonNameStr);
46
47 // override some base class methods to automatically synthesize the
48 // disabled bitmap if it wasn't set by the user
49 virtual void SetBitmapLabel(const wxBitmap& bitmap);
50 virtual void SetBitmapFocus(const wxBitmap& focus);
51 virtual void SetBitmapDisabled(const wxBitmap& disabled);
52 virtual void SetBitmapHover(const wxBitmap& hover);
53
54 // Implementation
55 virtual bool SetBackgroundColour(const wxColour& colour);
56 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
57 virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel );
58 virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
59 virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
60
61 protected:
62 // common part of all ctors
63 void Init()
64 {
65 m_disabledSetByUser =
66 m_hoverSetByUser = false;
67 }
68
69 // reimplement some base class virtuals
70 virtual wxSize DoGetBestSize() const;
71
72 // invalidate m_brushDisabled when system colours change
73 void OnSysColourChanged(wxSysColourChangedEvent& event);
74
75 // change the currently bitmap if we have a hover one
76 void OnMouseEnterOrLeave(wxMouseEvent& event);
77
78
79 // the brush we use to draw disabled buttons
80 wxBrush m_brushDisabled;
81
82 // true if m_bmpDisabled was set by user, false if we created it ourselves
83 // from m_bmpNormal
84 bool m_disabledSetByUser;
85
86 // true if m_bmpHover was set by user, false if it was set from m_bmpFocus
87 bool m_hoverSetByUser;
88
89
90 DECLARE_EVENT_TABLE()
91 DECLARE_DYNAMIC_CLASS_NO_COPY(wxBitmapButton)
92 };
93
94 #endif // _WX_BMPBUTTN_H_