anybutton.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/anybutton.h
  3. // Purpose: wxGTK wxAnyButton class declaration
  4. // Author: Robert Roebling
  5. // Created: 1998-05-20 (extracted from button.h)
  6. // Copyright: (c) 1998 Robert Roebling
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_GTK_ANYBUTTON_H_
  10. #define _WX_GTK_ANYBUTTON_H_
  11. //-----------------------------------------------------------------------------
  12. // wxAnyButton
  13. //-----------------------------------------------------------------------------
  14. class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
  15. {
  16. public:
  17. wxAnyButton()
  18. {
  19. m_isCurrent =
  20. m_isPressed = false;
  21. }
  22. virtual bool Enable( bool enable = true );
  23. // implementation
  24. // --------------
  25. static wxVisualAttributes
  26. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  27. // called from GTK callbacks: they update the button state and call
  28. // GTKUpdateBitmap()
  29. void GTKMouseEnters();
  30. void GTKMouseLeaves();
  31. void GTKPressed();
  32. void GTKReleased();
  33. protected:
  34. virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
  35. virtual wxBitmap DoGetBitmap(State which) const;
  36. virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
  37. virtual void DoSetBitmapPosition(wxDirection dir);
  38. private:
  39. typedef wxAnyButtonBase base_type;
  40. // focus event handler: calls GTKUpdateBitmap()
  41. void GTKOnFocus(wxFocusEvent& event);
  42. // update the bitmap to correspond to the current button state
  43. void GTKUpdateBitmap();
  44. // return the current button state from m_isXXX flags (which means that it
  45. // might not correspond to the real current state as e.g. m_isCurrent will
  46. // never be true if we don't have a valid current bitmap)
  47. State GTKGetCurrentState() const;
  48. // show the given bitmap (must be valid)
  49. void GTKDoShowBitmap(const wxBitmap& bitmap);
  50. // the bitmaps for the different state of the buttons, all of them may be
  51. // invalid and the button only shows a bitmap at all if State_Normal bitmap
  52. // is valid
  53. wxBitmap m_bitmaps[State_Max];
  54. // true iff mouse is currently over the button
  55. bool m_isCurrent;
  56. // true iff the button is in pressed state
  57. bool m_isPressed;
  58. wxDECLARE_NO_COPY_CLASS(wxAnyButton);
  59. };
  60. #endif // _WX_GTK_ANYBUTTON_H_