1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/bmpbutton.h
3 // Purpose: wxBitmapButton class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_BMPBUTTON_H_BASE_
13 #define _WX_BMPBUTTON_H_BASE_
19 #include "wx/button.h"
21 // FIXME: right now only wxMSW and wxGTK implement bitmap support in wxButton
22 // itself, this shouldn't be used for the other platforms neither
23 // when all of them do it
24 #if (defined(__WXMSW__) || defined(__WXGTK__)) && !defined(__WXUNIVERSAL__)
25 #define wxHAS_BUTTON_BITMAP
28 // ----------------------------------------------------------------------------
29 // wxBitmapButton: a button which shows bitmaps instead of the usual string.
30 // It has different bitmaps for different states (focused/disabled/pressed)
31 // ----------------------------------------------------------------------------
33 class WXDLLIMPEXP_CORE wxBitmapButtonBase
: public wxButton
38 #ifndef wxHAS_BUTTON_BITMAP
41 #endif // wxHAS_BUTTON_BITMAP
44 // set/get the margins around the button
45 virtual void SetMargins(int x
, int y
)
47 DoSetBitmapMargins(x
, y
);
50 int GetMarginX() const { return DoGetBitmapMargins().x
; }
51 int GetMarginY() const { return DoGetBitmapMargins().y
; }
53 // deprecated synonym for SetBitmapLabel()
54 #if WXWIN_COMPATIBILITY_2_6
55 wxDEPRECATED_INLINE( void SetLabel(const wxBitmap
& bitmap
),
56 SetBitmapLabel(bitmap
); )
58 // prevent virtual function hiding
59 virtual void SetLabel(const wxString
& label
)
60 { wxWindow::SetLabel(label
); }
61 #endif // WXWIN_COMPATIBILITY_2_6
64 #ifndef wxHAS_BUTTON_BITMAP
65 // function called when any of the bitmaps changes
66 virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); }
68 virtual wxBitmap
DoGetBitmap(State which
) const { return m_bitmaps
[which
]; }
69 virtual void DoSetBitmap(const wxBitmap
& bitmap
, State which
)
70 { m_bitmaps
[which
] = bitmap
; OnSetBitmap(); }
72 virtual wxSize
DoGetBitmapMargins() const
74 return wxSize(m_marginX
, m_marginY
);
77 virtual void DoSetBitmapMargins(int x
, int y
)
83 // the bitmaps for various states
84 wxBitmap m_bitmaps
[State_Max
];
86 // the margins around the bitmap
89 #endif // !wxHAS_BUTTON_BITMAP
91 wxDECLARE_NO_COPY_CLASS(wxBitmapButtonBase
);
94 #if defined(__WXUNIVERSAL__)
95 #include "wx/univ/bmpbuttn.h"
96 #elif defined(__WXMSW__)
97 #include "wx/msw/bmpbuttn.h"
98 #elif defined(__WXMOTIF__)
99 #include "wx/motif/bmpbuttn.h"
100 #elif defined(__WXGTK20__)
101 #include "wx/gtk/bmpbuttn.h"
102 #elif defined(__WXGTK__)
103 #include "wx/gtk1/bmpbuttn.h"
104 #elif defined(__WXMAC__)
105 #include "wx/osx/bmpbuttn.h"
106 #elif defined(__WXCOCOA__)
107 #include "wx/cocoa/bmpbuttn.h"
108 #elif defined(__WXPM__)
109 #include "wx/os2/bmpbuttn.h"
110 #elif defined(__WXPALMOS__)
111 #include "wx/palmos/bmpbuttn.h"
114 #endif // wxUSE_BMPBUTTON
116 #endif // _WX_BMPBUTTON_H_BASE_