tglbtn.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/tglbtn.h
  3. // Purpose: This dummy header includes the proper header file for the
  4. // system we're compiling under.
  5. // Author: John Norris, minor changes by Axel Schlueter
  6. // Modified by:
  7. // Created: 08.02.01
  8. // Copyright: (c) 2000 Johnny C. Norris II
  9. // Licence: wxWindows Licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_TOGGLEBUTTON_H_BASE_
  12. #define _WX_TOGGLEBUTTON_H_BASE_
  13. #include "wx/defs.h"
  14. #if wxUSE_TOGGLEBTN
  15. #include "wx/event.h"
  16. #include "wx/anybutton.h" // base class
  17. extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr[];
  18. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOGGLEBUTTON, wxCommandEvent );
  19. // ----------------------------------------------------------------------------
  20. // wxToggleButtonBase
  21. // ----------------------------------------------------------------------------
  22. class WXDLLIMPEXP_CORE wxToggleButtonBase : public wxAnyButton
  23. {
  24. public:
  25. wxToggleButtonBase() { }
  26. // Get/set the value
  27. virtual void SetValue(bool state) = 0;
  28. virtual bool GetValue() const = 0;
  29. void UpdateWindowUI(long flags)
  30. {
  31. wxControl::UpdateWindowUI(flags);
  32. if ( !IsShown() )
  33. return;
  34. wxWindow *tlw = wxGetTopLevelParent( this );
  35. if (tlw && wxPendingDelete.Member( tlw ))
  36. return;
  37. wxUpdateUIEvent event( GetId() );
  38. event.SetEventObject(this);
  39. if (GetEventHandler()->ProcessEvent(event) )
  40. {
  41. if ( event.GetSetChecked() )
  42. SetValue( event.GetChecked() );
  43. }
  44. }
  45. // Buttons on MSW can look bad if they are not native colours, because
  46. // then they become owner-drawn and not theme-drawn. Disable it here
  47. // in wxToggleButtonBase to make it consistent.
  48. virtual bool ShouldInheritColours() const { return false; }
  49. protected:
  50. // choose the default border for this window
  51. virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
  52. wxDECLARE_NO_COPY_CLASS(wxToggleButtonBase);
  53. };
  54. #define EVT_TOGGLEBUTTON(id, fn) \
  55. wx__DECLARE_EVT1(wxEVT_TOGGLEBUTTON, id, wxCommandEventHandler(fn))
  56. #if defined(__WXUNIVERSAL__)
  57. #include "wx/univ/tglbtn.h"
  58. #elif defined(__WXMSW__)
  59. #include "wx/msw/tglbtn.h"
  60. #define wxHAS_BITMAPTOGGLEBUTTON
  61. #elif defined(__WXGTK20__)
  62. #include "wx/gtk/tglbtn.h"
  63. #define wxHAS_BITMAPTOGGLEBUTTON
  64. #elif defined(__WXGTK__)
  65. #include "wx/gtk1/tglbtn.h"
  66. # elif defined(__WXMOTIF__)
  67. #include "wx/motif/tglbtn.h"
  68. #elif defined(__WXMAC__)
  69. #include "wx/osx/tglbtn.h"
  70. #define wxHAS_BITMAPTOGGLEBUTTON
  71. #elif defined(__WXPM__)
  72. #include "wx/os2/tglbtn.h"
  73. #endif
  74. // old wxEVT_COMMAND_* constants
  75. #define wxEVT_COMMAND_TOGGLEBUTTON_CLICKED wxEVT_TOGGLEBUTTON
  76. #endif // wxUSE_TOGGLEBTN
  77. #endif // _WX_TOGGLEBUTTON_H_BASE_