]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/tglbtn.h
account for scroll offset correctly in the mouse event handler
[wxWidgets.git] / include / wx / tglbtn.h
index 8796bd899357ba057175815fecfea2b5949f2bd2..ccb80dce96a6c20bf60ea0b0f229b583f0000d46 100644 (file)
@@ -7,7 +7,7 @@
 // Created:     08.02.01
 // RCS-ID:      $Id$
 // Copyright:   (c) 2000 Johnny C. Norris II
-// License:     Rocketeer license
+// License:     wxWindows Licence
 /////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_TOGGLEBUTTON_H_BASE_
 #include "wx/event.h"
 #include "wx/control.h"     // base class
 
-BEGIN_DECLARE_EVENT_TYPES()
-    DECLARE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, 19)
-END_DECLARE_EVENT_TYPES()
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOGGLEBUTTON_CLICKED;
 
-#define EVT_TOGGLEBUTTON(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction)  wxStaticCastEvent( wxCommandEventFunction, & fn ), (wxObject *) NULL ),
+// ----------------------------------------------------------------------------
+// wxToggleButtonBase
+// ----------------------------------------------------------------------------
 
-#if defined(__WXMSW__)
+class WXDLLIMPEXP_CORE wxToggleButtonBase : public wxControl
+{
+public:
+    wxToggleButtonBase() { }
+
+    // Get/set the value
+    virtual void SetValue(bool state) = 0;
+    virtual bool GetValue() const = 0;
+
+    void UpdateWindowUI(long flags)
+    {
+        wxControl::UpdateWindowUI(flags);
+
+        if ( !IsShown() )
+            return;
+
+        wxWindow *tlw = wxGetTopLevelParent( this );
+        if (tlw && wxPendingDelete.Member( tlw ))
+           return;
+
+        wxUpdateUIEvent event( GetId() );
+        event.SetEventObject(this);
+
+        if (GetEventHandler()->ProcessEvent(event) )
+        {
+            if ( event.GetSetChecked() )
+                SetValue( event.GetChecked() );
+        }
+    }
+
+    // Buttons on MSW can look bad if they are not native colours, because
+    // then they become owner-drawn and not theme-drawn.  Disable it here
+    // in wxToggleButtonBase to make it consistent.
+    virtual bool ShouldInheritColours() const { return false; }
+
+protected:
+    // choose the default border for this window
+    virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
+
+    DECLARE_NO_COPY_CLASS(wxToggleButtonBase)
+};
+
+
+#define EVT_TOGGLEBUTTON(id, fn) \
+    wx__DECLARE_EVT1(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, id, wxCommandEventHandler(fn))
+
+#if defined(__WXUNIVERSAL__)
+    #include "wx/univ/tglbtn.h"
+#elif defined(__WXMSW__)
     #include "wx/msw/tglbtn.h"
-#elif defined(__WXGTK__)
+#elif defined(__WXGTK20__)
     #include "wx/gtk/tglbtn.h"
+#elif defined(__WXGTK__)
+    #include "wx/gtk1/tglbtn.h"
 # elif defined(__WXMOTIF__)
     #include "wx/motif/tglbtn.h"
 #elif defined(__WXMAC__)
-    #include "wx/mac/tglbtn.h"
-/*
-# elif defined(__WXPM__)
-#  include "wx/os2/tglbtn.h"
-*/
+    #include "wx/osx/tglbtn.h"
+#elif defined(__WXPALMOS__)
+    #include "wx/palmos/tglbtn.h"
+#elif defined(__WXPM__)
+    #include "wx/os2/tglbtn.h"
 #endif
 
 #endif // wxUSE_TOGGLEBTN