]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bmpbuttn.h | |
3 | // Purpose: wxBitmapButton class | |
37f214d5 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
37f214d5 | 6 | // Created: 10/13/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
37f214d5 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_BMPBUTTN_H_ | |
13 | #define _WX_BMPBUTTN_H_ | |
14 | ||
0e320a79 DW |
15 | #include "wx/button.h" |
16 | ||
17 | WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; | |
18 | ||
19 | #define wxDEFAULT_BUTTON_MARGIN 4 | |
20 | ||
21 | class WXDLLEXPORT wxBitmapButton: public wxButton | |
22 | { | |
23 | DECLARE_DYNAMIC_CLASS(wxBitmapButton) | |
24 | public: | |
25 | inline wxBitmapButton() { m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; } | |
26 | inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, | |
27 | const wxPoint& pos = wxDefaultPosition, | |
28 | const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, | |
57c4d796 | 29 | #if wxUSE_VALIDATORS |
0e320a79 | 30 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 | 31 | #endif |
0e320a79 DW |
32 | const wxString& name = wxButtonNameStr) |
33 | { | |
34 | Create(parent, id, bitmap, pos, size, style, validator, name); | |
35 | } | |
36 | ||
37 | bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, | |
38 | const wxPoint& pos = wxDefaultPosition, | |
39 | const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW, | |
57c4d796 | 40 | #if wxUSE_VALIDATORS |
0e320a79 | 41 | const wxValidator& validator = wxDefaultValidator, |
57c4d796 | 42 | #endif |
0e320a79 DW |
43 | const wxString& name = wxButtonNameStr); |
44 | ||
45 | virtual void SetLabel(const wxBitmap& bitmap) | |
46 | { | |
47 | SetBitmapLabel(bitmap); | |
48 | } | |
49 | ||
50 | virtual void SetBitmapLabel(const wxBitmap& bitmap); | |
51 | ||
37f214d5 DW |
52 | #if WXWIN_COMPATIBILITY |
53 | wxBitmap *GetBitmap() const { return (wxBitmap *) & m_buttonBitmap; } | |
54 | #endif | |
55 | ||
0e320a79 DW |
56 | inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; } |
57 | inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; } | |
58 | inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; } | |
59 | inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; } | |
60 | ||
61 | inline void SetBitmapSelected(const wxBitmap& sel) { m_buttonBitmapSelected = sel; }; | |
62 | inline void SetBitmapFocus(const wxBitmap& focus) { m_buttonBitmapFocus = focus; }; | |
63 | inline void SetBitmapDisabled(const wxBitmap& disabled) { m_buttonBitmapDisabled = disabled; }; | |
64 | ||
65 | inline void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } | |
66 | inline int GetMarginX() { return m_marginX; } | |
67 | inline int GetMarginY() { return m_marginY; } | |
68 | ||
37f214d5 DW |
69 | virtual void SetDefault(); |
70 | // virtual bool OS2OnDraw(WXDRAWITEMSTRUCT *item); | |
0e320a79 DW |
71 | virtual void DrawFace( WXHDC dc, int left, int top, int right, int bottom, bool sel ); |
72 | virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel ); | |
73 | virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg ); | |
0e320a79 DW |
74 | |
75 | protected: | |
76 | wxBitmap m_buttonBitmap; | |
77 | wxBitmap m_buttonBitmapSelected; | |
78 | wxBitmap m_buttonBitmapFocus; | |
79 | wxBitmap m_buttonBitmapDisabled; | |
80 | int m_marginX; | |
81 | int m_marginY; | |
82 | private: | |
54da4255 DW |
83 | virtual void SetLabel(const wxString& string) |
84 | { wxButton::SetLabel(string); }; | |
0e320a79 DW |
85 | }; |
86 | ||
87 | #endif | |
88 | // _WX_BMPBUTTN_H_ |