1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/bmpbutton.h 3 // Purpose: wxBitmapButton class interface 4 // Author: Vadim Zeitlin 5 // Modified by: 6 // Created: 25.08.00 7 // RCS-ID: $Id: bmpbuttn.h 45498 2007-04-16 13:03:05Z VZ $ 8 // Copyright: (c) 2000 Vadim Zeitlin 9 // Licence: wxWindows licence 10 ///////////////////////////////////////////////////////////////////////////// 11 12 #ifndef _WX_BMPBUTTON_H_BASE_ 13 #define _WX_BMPBUTTON_H_BASE_ 14 15 #include "wx/defs.h" 16 17 #if wxUSE_BMPBUTTON 18 19 #include "wx/bitmap.h" 20 #include "wx/button.h" 21 22 extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[]; 23 24 // ---------------------------------------------------------------------------- 25 // wxBitmapButton: a button which shows bitmaps instead of the usual string. 26 // It has different bitmaps for different states (focused/disabled/pressed) 27 // ---------------------------------------------------------------------------- 28 29 class WXDLLEXPORT wxBitmapButtonBase : public wxButton 30 { 31 public: wxBitmapButtonBase()32 wxBitmapButtonBase() 33 { 34 m_marginX = 35 m_marginY = 0; 36 } 37 38 // set the bitmaps SetBitmapLabel(const wxBitmap & bitmap)39 void SetBitmapLabel(const wxBitmap& bitmap) 40 { m_bmpNormal = bitmap; OnSetBitmap(); } SetBitmapSelected(const wxBitmap & sel)41 void SetBitmapSelected(const wxBitmap& sel) 42 { m_bmpSelected = sel; OnSetBitmap(); } SetBitmapFocus(const wxBitmap & focus)43 void SetBitmapFocus(const wxBitmap& focus) 44 { m_bmpFocus = focus; OnSetBitmap(); } SetBitmapDisabled(const wxBitmap & disabled)45 void SetBitmapDisabled(const wxBitmap& disabled) 46 { m_bmpDisabled = disabled; OnSetBitmap(); } SetBitmapHover(const wxBitmap & hover)47 void SetBitmapHover(const wxBitmap& hover) 48 { m_bmpHover = hover; OnSetBitmap(); } 49 50 // retrieve the bitmaps GetBitmapLabel()51 const wxBitmap& GetBitmapLabel() const { return m_bmpNormal; } GetBitmapSelected()52 const wxBitmap& GetBitmapSelected() const { return m_bmpSelected; } GetBitmapFocus()53 const wxBitmap& GetBitmapFocus() const { return m_bmpFocus; } GetBitmapDisabled()54 const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } GetBitmapHover()55 const wxBitmap& GetBitmapHover() const { return m_bmpHover; } GetBitmapLabel()56 wxBitmap& GetBitmapLabel() { return m_bmpNormal; } GetBitmapSelected()57 wxBitmap& GetBitmapSelected() { return m_bmpSelected; } GetBitmapFocus()58 wxBitmap& GetBitmapFocus() { return m_bmpFocus; } GetBitmapDisabled()59 wxBitmap& GetBitmapDisabled() { return m_bmpDisabled; } GetBitmapHover()60 wxBitmap& GetBitmapHover() { return m_bmpHover; } 61 62 // set/get the margins around the button SetMargins(int x,int y)63 virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; } GetMarginX()64 int GetMarginX() const { return m_marginX; } GetMarginY()65 int GetMarginY() const { return m_marginY; } 66 67 // deprecated synonym for SetBitmapLabel() 68 #if WXWIN_COMPATIBILITY_2_6 69 wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) ); 70 71 // prevent virtual function hiding SetLabel(const wxString & label)72 virtual void SetLabel(const wxString& label) 73 { wxWindow::SetLabel(label); } 74 #endif // WXWIN_COMPATIBILITY_2_6 75 76 protected: 77 // function called when any of the bitmaps changes OnSetBitmap()78 virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); } 79 80 // the bitmaps for various states 81 wxBitmap m_bmpNormal, 82 m_bmpSelected, 83 m_bmpFocus, 84 m_bmpDisabled, 85 m_bmpHover; 86 87 // the margins around the bitmap 88 int m_marginX, 89 m_marginY; 90 91 92 DECLARE_NO_COPY_CLASS(wxBitmapButtonBase) 93 }; 94 95 #if WXWIN_COMPATIBILITY_2_6 SetLabel(const wxBitmap & bitmap)96inline void wxBitmapButtonBase::SetLabel(const wxBitmap& bitmap) 97 { 98 SetBitmapLabel(bitmap); 99 } 100 #endif // WXWIN_COMPATIBILITY_2_6 101 102 #if defined(__WXUNIVERSAL__) 103 #include "wx/univ/bmpbuttn.h" 104 #elif defined(__WXMSW__) 105 #include "wx/msw/bmpbuttn.h" 106 #elif defined(__WXMOTIF__) 107 #include "wx/motif/bmpbuttn.h" 108 #elif defined(__WXGTK20__) 109 #include "wx/gtk/bmpbuttn.h" 110 #elif defined(__WXGTK__) 111 #include "wx/gtk1/bmpbuttn.h" 112 #elif defined(__WXMAC__) 113 #include "wx/mac/bmpbuttn.h" 114 #elif defined(__WXCOCOA__) 115 #include "wx/cocoa/bmpbuttn.h" 116 #elif defined(__WXPM__) 117 #include "wx/os2/bmpbuttn.h" 118 #endif 119 120 #endif // wxUSE_BMPBUTTON 121 122 #endif // _WX_BMPBUTTON_H_BASE_ 123