anybutton.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/anybutton.h
  3. // Purpose: wxAnyButton class
  4. // Author: Julian Smart
  5. // Created: 1997-02-01 (extracted from button.h)
  6. // Copyright: (c) Julian Smart
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_MSW_ANYBUTTON_H_
  10. #define _WX_MSW_ANYBUTTON_H_
  11. // ----------------------------------------------------------------------------
  12. // Common button functionality
  13. // ----------------------------------------------------------------------------
  14. class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
  15. {
  16. public:
  17. wxAnyButton()
  18. {
  19. m_imageData = NULL;
  20. #if wxUSE_MARKUP
  21. m_markupText = NULL;
  22. #endif // wxUSE_MARKUP
  23. }
  24. virtual ~wxAnyButton();
  25. // overridden base class methods
  26. virtual void SetLabel(const wxString& label);
  27. virtual bool SetBackgroundColour(const wxColour &colour);
  28. virtual bool SetForegroundColour(const wxColour &colour);
  29. // implementation from now on
  30. virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
  31. virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
  32. virtual State GetNormalState() const { return State_Normal; }
  33. // returns true if the platform should explicitly apply a theme border
  34. virtual bool CanApplyThemeBorder() const { return false; }
  35. protected:
  36. // usually overridden base class virtuals
  37. virtual wxSize DoGetBestSize() const;
  38. virtual wxBitmap DoGetBitmap(State which) const;
  39. virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
  40. virtual wxSize DoGetBitmapMargins() const;
  41. virtual void DoSetBitmapMargins(wxCoord x, wxCoord y);
  42. virtual void DoSetBitmapPosition(wxDirection dir);
  43. #if wxUSE_MARKUP
  44. virtual bool DoSetLabelMarkup(const wxString& markup);
  45. #endif // wxUSE_MARKUP
  46. // Increases the passed in size to account for the button image.
  47. //
  48. // Should only be called if we do have a button, i.e. if m_imageData is
  49. // non-NULL.
  50. void AdjustForBitmapSize(wxSize& size) const;
  51. class wxButtonImageData *m_imageData;
  52. #if wxUSE_MARKUP
  53. class wxMarkupText *m_markupText;
  54. #endif // wxUSE_MARKUP
  55. // Switches button into owner-drawn mode: this is used if we need to draw
  56. // something not supported by the native control, such as using non default
  57. // colours or a bitmap on pre-XP systems.
  58. void MakeOwnerDrawn();
  59. bool IsOwnerDrawn() const;
  60. private:
  61. wxDECLARE_NO_COPY_CLASS(wxAnyButton);
  62. };
  63. #endif // _WX_MSW_ANYBUTTON_H_