]> git.saurik.com Git - wxWidgets.git/commitdiff
Further cleaning of the wxPalmOS radiobox code. Sending update event from slider...
authorWłodzimierz Skiba <abx@abx.art.pl>
Tue, 1 Feb 2005 09:58:58 +0000 (09:58 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Tue, 1 Feb 2005 09:58:58 +0000 (09:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31690 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/chkconf.h
include/wx/defs.h
include/wx/palmos/radiobox.h
include/wx/palmos/setup0.h
include/wx/palmos/slider.h
src/palmos/control.cpp
src/palmos/radiobox.cpp
src/palmos/radiobut.cpp
src/palmos/slider.cpp
src/palmos/toplevel.cpp

index 6a51a7ad714368b478fbce89501f70df6e170857..5ff16d4f32465ac3a0d518b8cbe4062ad888e4ff 100644 (file)
 #endif
 
 #if wxUSE_RADIOBOX
-#   if !wxUSE_RADIOBTN || !wxUSE_STATBOX
+#   if !wxUSE_RADIOBTN
 #        ifdef wxABORT_ON_CONFIG_ERROR
-#            error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN and wxUSE_STATBOX"
+#            error "wxUSE_RADIOBOX requires wxUSE_RADIOBTN"
 #        else
 #            undef wxUSE_RADIOBTN
-#            undef wxUSE_STATBOX
 #            define wxUSE_RADIOBTN 1
+#        endif
+#   endif
+#   if !wxUSE_STATBOX && !defined(__WXPALMOS__)
+#        ifdef wxABORT_ON_CONFIG_ERROR
+#            error "wxUSE_RADIOBOX requires wxUSE_STATBOX"
+#        else
+#            undef wxUSE_STATBOX
 #            define wxUSE_STATBOX 1
 #        endif
 #   endif
index 786b6af3cc5744501697d14e76363329e1861ffa..32572213e63dc4eeee0bdc3bdd7ad17d7c43872d 100644 (file)
@@ -1419,11 +1419,16 @@ enum wxBorder
 #define wxRA_HORIZONTAL     wxHORIZONTAL
 #define wxRA_VERTICAL       wxVERTICAL
 
+/*  Use alternative object for single control */
+
+#define wxRA_USE_SUBSTITUTE 0x0010
+
 /*
  * wxRadioButton style flag
  */
 #define wxRB_GROUP          0x0004
 #define wxRB_SINGLE         0x0008
+#define wxRB_USE_SUBSTITUTE 0x0010
 
 /*
  * wxSlider flags
index 043faa661f05d806fcb1ce0625c0ffcf354fa7cc..11eef5e47f1ddf98859a156ba9ce9b02d689c461 100644 (file)
@@ -68,6 +68,7 @@ public:
                 long style = wxRA_HORIZONTAL,
                 const wxValidator& val = wxDefaultValidator,
                 const wxString& name = wxRadioBoxNameStr);
+
     bool Create(wxWindow *parent,
                 wxWindowID id,
                 const wxString& title,
@@ -104,17 +105,8 @@ public:
     // implementation only from now on
     // -------------------------------
 
-    // FIXME: are they used? missing "Do" prefix?
-    void GetSize(int *x, int *y) const;
-    void GetPosition(int *x, int *y) const;
-
     virtual bool SetFont(const wxFont& font);
 
-    virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
-                                WXUINT message,
-                                WXWPARAM wParam, WXLPARAM lParam);
-    WXHWND *GetRadioButtons() const { return m_radioButtons; }
-    bool ContainsHWND(WXHWND hWnd) const;
     void SendNotificationEvent();
 
     // get the number of buttons per column/row
@@ -128,16 +120,12 @@ protected:
     // we can't compute our best size before the items are added to the control
     virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
 
-    // subclass one radio button
-    void SubclassRadioButton(WXHWND hWndBtn);
-
     // get the max size of radio buttons
     wxSize GetMaxButtonSize() const;
 
     // get the total size occupied by the radio box buttons
     wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
 
-    WXHWND *          m_radioButtons;
     int               m_majorDim;
     int *             m_radioWidth;  // for bitmaps
     int *             m_radioHeight;
index 70906e6031d31e8db0f3386b82ed26ddf90c0c85..6a2dd44c5c879dc0f80f2c3c5c97706506e5fa1f 100644 (file)
 #define wxUSE_GAUGE        0    // wxGauge
 #define wxUSE_LISTBOX      0    // wxListBox
 #define wxUSE_LISTCTRL     0    // wxListCtrl
-#define wxUSE_RADIOBOX     0    // wxRadioBox
+#define wxUSE_RADIOBOX     1    // wxRadioBox
 #define wxUSE_RADIOBTN     1    // wxRadioButton
 #define wxUSE_SCROLLBAR    0    // wxScrollBar
 #define wxUSE_SLIDER       1    // wxSlider
index 63d7b1ccdf1535a7e6a1bc5d955422643db15388..187e258d89f6937cc33fa5759953144bc59a027d 100644 (file)
@@ -70,6 +70,9 @@ public:
     // implementation
     void Command(wxCommandEvent& event);
 
+    // send a notification event, return true if processed
+    bool SendUpdatedEvent();
+
 protected:
     virtual wxSize DoGetBestSize() const;
 
index 54b61fd862cb6731dddd247758ebbd44488384b3..88fd6fac820c5682ec30647b14fc3f7827d4f53d 100644 (file)
@@ -72,6 +72,7 @@ void wxControl::Init()
 
 wxControl::~wxControl()
 {
+    SetLabel(wxEmptyString);
     m_isBeingDeleted = true;
 }
 
@@ -107,13 +108,11 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
     if(form==NULL)
         return false;
 
-    m_label = label;
-
     ControlType *control = CtlNewControl(
                                (void **)&form,
                                GetId(),
                                style,
-                               m_label.c_str(),
+                               wxEmptyString,
                                ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x,
                                ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
                                ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
@@ -128,6 +127,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
 
     m_palmControl = true;
 
+    SetLabel(label);
     Show();
     return true;
 }
@@ -350,6 +350,13 @@ void wxControl::SetFieldLabel(const wxString& label)
 
 void wxControl::SetControlLabel(const wxString& label)
 {
+    ControlType* control = (ControlType*)GetObjectPtr();
+    if(control==NULL)
+        return;
+    CtlSetLabel(control,wxEmptyString);
+    m_label = label;
+    if(!m_label.empty())
+        CtlSetLabel(control,m_label.c_str());
 }
 
 void wxControl::SetLabel(const wxString& label)
index d6ead07206db0855de30970fb68b3d19bccf8f96..adc3f453bbebe76b724717d3ba26d8e418311062 100644 (file)
@@ -38,8 +38,6 @@
     #include "wx/log.h"
 #endif
 
-#include "wx/palmos/private.h"
-
 #if wxUSE_TOOLTIPS
     #include "wx/tooltip.h"
 #endif // wxUSE_TOOLTIPS
@@ -102,19 +100,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
         item
 */
 
-#define RADIOBTN_PARENT_IS_RADIOBOX 0
-
-// ---------------------------------------------------------------------------
-// private functions
-// ---------------------------------------------------------------------------
-
-// ---------------------------------------------------------------------------
-// global vars
-// ---------------------------------------------------------------------------
-
-// the pointer to standard radio button wnd proc
-static WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL;
-
 // ===========================================================================
 // implementation
 // ===========================================================================
@@ -234,14 +219,6 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 {
 }
 
-void wxRadioBox::GetSize(int *width, int *height) const
-{
-}
-
-void wxRadioBox::GetPosition(int *x, int *y) const
-{
-}
-
 void wxRadioBox::SetFocus()
 {
 }
@@ -267,19 +244,10 @@ void wxRadioBox::Show(int item, bool show)
 {
 }
 
-bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
-{
-    return false;
-}
-
 void wxRadioBox::Command(wxCommandEvent & event)
 {
 }
 
-void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
-{
-}
-
 void wxRadioBox::SendNotificationEvent()
 {
 }
@@ -289,17 +257,4 @@ bool wxRadioBox::SetFont(const wxFont& font)
     return false;
 }
 
-// ----------------------------------------------------------------------------
-// our window proc
-// ----------------------------------------------------------------------------
-
-WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
-                               WXUINT WXUNUSED(message),
-                               WXWPARAM WXUNUSED(wParam),
-                               WXLPARAM WXUNUSED(lParam)
-    )
-{
-    return (WXHBRUSH)0;
-}
-
 #endif // wxUSE_RADIOBOX
index fe3a1845ee0c920b797aa84f0d7b4ba9f7c8fcdb..3a344102aaafacb7e4cdb0c1ea5920ad37027a9e 100644 (file)
@@ -114,6 +114,10 @@ bool wxRadioButton::Create(wxWindow *parent,
                            const wxValidator& validator,
                            const wxString& name)
 {
+    // replace native push button with native checkbox
+    if ( style & wxRB_USE_SUBSTITUTE )
+        m_radioStyle = checkboxCtl;
+
     if(!wxControl::Create(parent, id, pos, size, style, validator, name))
         return false;
 
index b638ca961e7fd10e1bcacb86590cd880e3780484..ccc69ab7d76eef9bfe4e2a725ad87a0d42910c07 100644 (file)
@@ -251,6 +251,18 @@ void wxSlider::SetTick(int tickPos)
 {
 }
 
+// ----------------------------------------------------------------------------
+// helpers
+// ----------------------------------------------------------------------------
+
+bool wxSlider::SendUpdatedEvent()
+{
+    wxCommandEvent event(wxEVT_COMMAND_SLIDER_UPDATED, GetId());
+    event.SetEventObject(this);
+    event.SetInt(GetValue());
+    return ProcessCommand(event);
+}
+
 void wxSlider::Command (wxCommandEvent & event)
 {
 }
index 78e34bc01f54028ea2dbe55863e59bebe931f466..2ff38362b723ee55f16176ebc8a138f170aedaef 100644 (file)
@@ -47,6 +47,7 @@
 #include "wx/checkbox.h"
 #include "wx/radiobut.h"
 #include "wx/tglbtn.h"
+#include "wx/slider.h"
 
 // ----------------------------------------------------------------------------
 // globals
@@ -268,6 +269,10 @@ bool wxTopLevelWindowPalm::HandleControlSelect(EventType* event)
     if(radio)
         return radio->SendClickEvent();
 
+    wxSlider* slider = wxDynamicCast(win,wxSlider);
+    if(slider)
+        return slider->SendUpdatedEvent();
+
     return false;
 }