diff --git a/docs/changes.txt b/docs/changes.txt index f10bfdee64..4b721d0da3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -119,6 +119,7 @@ wxPalmOS: - native wxSlider implementation - native wxToggleButton implementation - native wxRadioButton implementation +- native wxStaticText implementation 2.5.3 diff --git a/include/wx/palmos/button.h b/include/wx/palmos/button.h index b94fb8731c..4c01bac899 100644 --- a/include/wx/palmos/button.h +++ b/include/wx/palmos/button.h @@ -52,6 +52,9 @@ public: // implementation from now on virtual void Command(wxCommandEvent& event); + // send a notification event, return true if processed + bool SendClickEvent(); + virtual void ApplyParentThemeBackground(const wxColour& bg) { // avoide switching into owner-drawn mode @@ -59,8 +62,6 @@ public: } protected: - // send a notification event, return true if processed - bool SendClickEvent(); // default button handling void SetTmpDefault(); diff --git a/include/wx/palmos/checkbox.h b/include/wx/palmos/checkbox.h index d2f7628a26..d98110bf68 100644 --- a/include/wx/palmos/checkbox.h +++ b/include/wx/palmos/checkbox.h @@ -47,6 +47,9 @@ public: virtual void Command(wxCommandEvent& event); + // send a notification event, return true if processed + bool SendClickEvent(); + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/palmos/control.h b/include/wx/palmos/control.h index 99db04e3e0..fb8b83cb57 100644 --- a/include/wx/palmos/control.h +++ b/include/wx/palmos/control.h @@ -22,7 +22,7 @@ class WXDLLEXPORT wxControl : public wxControlBase { public: - wxControl() { } + wxControl() { Init(); } wxControl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -30,6 +30,7 @@ public: const wxValidator& validator = wxDefaultValidator, const wxString& name = wxControlNameStr) { + Init(); Create(parent, id, pos, size, style, validator, name); } @@ -77,6 +78,8 @@ public: protected: // regardless how deeply we are in wxWidgets hierarchy always get correct form FormType* GetParentForm() const; + uint16_t GetObjectIndex() const; + void* GetObjectPtr() const; // choose the default border for this window virtual wxBorder GetDefaultBorder() const; @@ -86,6 +89,12 @@ protected: bool GetBoolValue() const; void SetIntValue(int val); + // native labels access + void SetFieldLabel(const wxString& label); + void SetControlLabel(const wxString& label); + wxString GetFieldLabel(); + wxString GetControlLabel(); + // return default best size (doesn't really make any sense, override this) virtual wxSize DoGetBestSize() const; @@ -99,11 +108,19 @@ protected: // supposed to had been already set and so is used instead when this // function is called) bool PalmCreateControl(ControlStyleType style, - wxWindow *parent, - wxWindowID id, const wxString& label, const wxPoint& pos, - const wxSize& size); + const wxSize& size, + int groupID = 0); + inline bool IsPalmControl() const { return m_palmControl; } + + bool PalmCreateField(const wxString& label, + const wxPoint& pos, + const wxSize& size, + bool editable, + bool underlined, + JustificationType justification); + inline bool IsPalmField() const { return m_palmField; } // this is a helper for the derived class GetClassDefaultAttributes() // implementation: it returns the right colours for the classes which @@ -117,10 +134,14 @@ protected: // holds the ids (not HWNDs!) of the sub controls wxArrayLong m_subControls; - ControlType *m_control; - private: + bool m_palmControl:1; + bool m_palmField:1; + + // common part of all ctors + void Init(); + virtual void DoGetBounds( RectangleType &rect ) const; // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc. diff --git a/include/wx/palmos/frame.h b/include/wx/palmos/frame.h index 93d890664c..920f3c5c6d 100644 --- a/include/wx/palmos/frame.h +++ b/include/wx/palmos/frame.h @@ -86,7 +86,7 @@ public: #if wxUSE_MENUS_NATIVE bool HandleMenuOpen(); - bool HandleMenuSelect(int ItemID); + bool HandleMenuSelect(EventType* event); #endif // wxUSE_MENUS_NATIVE protected: @@ -118,7 +118,7 @@ protected: // handle WM_INITMENUPOPUP message bool HandleInitMenuPopup(WXHMENU hMenu); - virtual bool IsMDIChild() const { return FALSE; } + virtual bool IsMDIChild() const { return false; } // get default (wxWidgets) icon for the frame virtual WXHICON GetDefaultIcon() const; diff --git a/include/wx/palmos/radiobox.h b/include/wx/palmos/radiobox.h index a2b37f2e18..043faa661f 100644 --- a/include/wx/palmos/radiobox.h +++ b/include/wx/palmos/radiobox.h @@ -2,10 +2,10 @@ // Name: wx/palmos/radiobox.h // Purpose: wxRadioBox class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation // Created: 10/13/04 // RCS-ID: $Id$ -// Copyright: (c) William Osborne +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -85,14 +85,14 @@ public: virtual int GetCount() const; virtual wxString GetString(int n) const; virtual void SetString(int n, const wxString& label); - virtual void Enable(int n, bool enable = TRUE); - virtual void Show(int n, bool show = TRUE); + virtual void Enable(int n, bool enable = true); + virtual void Show(int n, bool show = true); virtual int GetColumnCount() const; virtual int GetRowCount() const; - virtual bool Show(bool show = TRUE); + virtual bool Show(bool show = true); void SetFocus(); - virtual bool Enable(bool enable = TRUE); + virtual bool Enable(bool enable = true); void SetLabelFont(const wxFont& WXUNUSED(font)) {}; void SetButtonFont(const wxFont& font) { SetFont(font); } @@ -104,15 +104,12 @@ public: // implementation only from now on // ------------------------------- - virtual bool MSWCommand(WXUINT param, WXWORD id); - // 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); - WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); diff --git a/include/wx/palmos/radiobut.h b/include/wx/palmos/radiobut.h index 90ffc63c18..120e940d93 100644 --- a/include/wx/palmos/radiobut.h +++ b/include/wx/palmos/radiobut.h @@ -51,6 +51,10 @@ public: // implementation only from now on virtual void Command(wxCommandEvent& event); + + // send a notification event, return true if processed + bool SendClickEvent(); + virtual void ApplyParentThemeBackground(const wxColour& bg) { SetBackgroundColour(bg); } @@ -62,6 +66,8 @@ private: // common part of all ctors void Init(); + // pushButtonCtl or checkboxCtl + ControlStyleType m_radioStyle; DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton) }; diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index eafc44cfbb..70906e6031 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -528,7 +528,7 @@ #define wxUSE_SPINCTRL 0 // wxSpinCtrl #define wxUSE_STATBOX 0 // wxStaticBox #define wxUSE_STATLINE 0 // wxStaticLine -#define wxUSE_STATTEXT 0 // wxStaticText +#define wxUSE_STATTEXT 1 // wxStaticText #define wxUSE_STATBMP 0 // wxStaticBitmap #define wxUSE_TEXTCTRL 0 // wxTextCtrl #define wxUSE_TOGGLEBTN 1 // requires wxButton diff --git a/include/wx/palmos/slider.h b/include/wx/palmos/slider.h index 4433437a01..63d7b1ccdf 100644 --- a/include/wx/palmos/slider.h +++ b/include/wx/palmos/slider.h @@ -46,8 +46,6 @@ public: virtual int GetValue() const; virtual void SetValue(int); - void GetPosition(int *x, int *y) const; - void SetRange(int minValue, int maxValue); int GetMin() const; @@ -73,12 +71,6 @@ public: void Command(wxCommandEvent& event); protected: - virtual void DoGetSize(int *width, int *height) const; - - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - virtual wxSize DoGetBestSize() const; DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider) diff --git a/include/wx/palmos/stattext.h b/include/wx/palmos/stattext.h index 3a7a4d0410..cb3ca10170 100644 --- a/include/wx/palmos/stattext.h +++ b/include/wx/palmos/stattext.h @@ -2,10 +2,10 @@ // Name: wx/palmos/stattext.h // Purpose: wxStaticText class // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Wlodzimierz ABX Skiba - native wxStaticText implementation // Created: 10/13/04 // RCS-ID: $Id$ -// Copyright: (c) William Osborne +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -41,16 +41,12 @@ public: const wxString& name = wxStaticTextNameStr); // override some methods to resize the window properly - virtual void SetLabel(const wxString& label); virtual bool SetFont( const wxFont &font ); protected: // implement/override some base class virtuals virtual wxBorder GetDefaultBorder() const; - virtual void DoSetSize(int x, int y, int w, int h, - int sizeFlags = wxSIZE_AUTO); virtual wxSize DoGetBestSize() const; - virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText) }; diff --git a/include/wx/palmos/tglbtn.h b/include/wx/palmos/tglbtn.h index 4b8f99def8..1fd907bc17 100644 --- a/include/wx/palmos/tglbtn.h +++ b/include/wx/palmos/tglbtn.h @@ -46,6 +46,9 @@ public: virtual void Command(wxCommandEvent& event); + // send a notification event, return true if processed + bool SendClickEvent(); + protected: virtual wxSize DoGetBestSize() const; virtual wxBorder GetDefaultBorder() const; diff --git a/include/wx/palmos/toplevel.h b/include/wx/palmos/toplevel.h index 143863c62a..3db01b1fcd 100644 --- a/include/wx/palmos/toplevel.h +++ b/include/wx/palmos/toplevel.h @@ -84,6 +84,9 @@ public: // interface to native frame structure FormType *GetForm() const; + // handle controls + bool HandleControlSelect(EventType* event); + protected: // common part of all ctors void Init(); diff --git a/include/wx/radiobox.h b/include/wx/radiobox.h index fa3db009e4..3cf0635cfe 100644 --- a/include/wx/radiobox.h +++ b/include/wx/radiobox.h @@ -117,6 +117,8 @@ public: #include "wx/cocoa/radiobox.h" #elif defined(__WXPM__) #include "wx/os2/radiobox.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/radiobox.h" #endif #endif // wxUSE_RADIOBOX diff --git a/include/wx/stattext.h b/include/wx/stattext.h index 19d2e00182..ae85c17dad 100644 --- a/include/wx/stattext.h +++ b/include/wx/stattext.h @@ -34,6 +34,8 @@ private: #include "wx/cocoa/stattext.h" #elif defined(__WXPM__) #include "wx/os2/stattext.h" +#elif defined(__WXPALMOS__) + #include "wx/palmos/stattext.h" #endif #endif // wxUSE_STATTEXT diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index d109b28adf..1627e1723e 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -86,7 +86,7 @@ // ---------------------------------------------------------------------------- #if defined(__WXPALMOS__) -int wxWindowBase::ms_lastControlId = 65535; +int wxWindowBase::ms_lastControlId = 32767; #elif defined(__WXPM__) int wxWindowBase::ms_lastControlId = 2000; #else diff --git a/src/palmos/button.cpp b/src/palmos/button.cpp index 17baee2123..a0d0f088a5 100644 --- a/src/palmos/button.cpp +++ b/src/palmos/button.cpp @@ -170,8 +170,10 @@ bool wxButton::Create(wxWindow *parent, if( palmLabel.empty() && wxIsStockID(id) ) palmLabel = wxGetStockLabel(id); - wxControl::PalmCreateControl(buttonCtl, parent, id, palmLabel, palmPos, palmSize); - return true; + if(!wxControl::Create(parent, id, palmPos, palmSize, style, validator, name)) + return false; + + return wxControl::PalmCreateControl(buttonCtl, palmLabel, palmPos, palmSize); } wxButton::~wxButton() @@ -221,11 +223,14 @@ wxButton::SetDefaultStyle(wxButton *btn, bool on) bool wxButton::SendClickEvent() { - return false; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); + event.SetEventObject(this); + return ProcessCommand(event); } void wxButton::Command(wxCommandEvent &event) { + ProcessCommand(event); } #endif // wxUSE_BUTTON diff --git a/src/palmos/checkbox.cpp b/src/palmos/checkbox.cpp index 5b55dd7c00..e6ebf0bd09 100644 --- a/src/palmos/checkbox.cpp +++ b/src/palmos/checkbox.cpp @@ -106,8 +106,10 @@ bool wxCheckBox::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { - wxControl::PalmCreateControl(checkboxCtl, parent, id, label, pos, size); - return true; + if(!wxControl::Create(parent, id, pos, size, style, validator, name)) + return false; + + return wxControl::PalmCreateControl(checkboxCtl, label, pos, size); } wxSize wxCheckBox::DoGetBestSize() const @@ -125,6 +127,14 @@ bool wxCheckBox::GetValue() const return GetBoolValue(); } +bool wxCheckBox::SendClickEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, GetId()); + event.SetInt(GetValue()); + event.SetEventObject(this); + return ProcessCommand(event); +} + void wxCheckBox::Command(wxCommandEvent& event) { } diff --git a/src/palmos/control.cpp b/src/palmos/control.cpp index b5a89e8932..54b61fd862 100644 --- a/src/palmos/control.cpp +++ b/src/palmos/control.cpp @@ -44,6 +44,7 @@ #include "wx/checkbox.h" #include "wx/tglbtn.h" #include "wx/radiobut.h" +#include "wx/slider.h" // ---------------------------------------------------------------------------- // wxWin macros @@ -63,6 +64,12 @@ END_EVENT_TABLE() // wxControl ctor/dtor // ---------------------------------------------------------------------------- +void wxControl::Init() +{ + m_palmControl = false; + m_palmField = false; +} + wxControl::~wxControl() { m_isBeingDeleted = true; @@ -91,41 +98,82 @@ bool wxControl::Create(wxWindow *parent, } bool wxControl::PalmCreateControl(ControlStyleType style, - wxWindow *parent, - wxWindowID id, const wxString& label, const wxPoint& pos, - const wxSize& size) + const wxSize& size, + int groupID) { - SetParent(parent); - SetId( id == wxID_ANY ? NewControlId() : id ); FormType* form = GetParentForm(); if(form==NULL) return false; m_label = label; - m_control = CtlNewControl( - (void **)&form, - GetId(), - style, - m_label.c_str(), - ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, - ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, - ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, - ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, - stdFont, - 0, - false - ); + ControlType *control = CtlNewControl( + (void **)&form, + GetId(), + style, + m_label.c_str(), + ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, + ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, + ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, + ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, + stdFont, + groupID, + false + ); - if(m_control==NULL) + if(control==NULL) return false; + m_palmControl = true; + Show(); return true; } +bool wxControl::PalmCreateField(const wxString& label, + const wxPoint& pos, + const wxSize& size, + bool editable, + bool underlined, + JustificationType justification) +{ + FormType* form = GetParentForm(); + if(form==NULL) + return false; + + m_label = label; + + FieldType *field = FldNewField( + (void **)&form, + GetId(), + ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, + ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, + ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, + ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, + stdFont, + 10, + editable, + underlined, + false, + false, + justification, + false, + false, + false + ); + + if(field==NULL) + return false; + + m_palmField = true; + + Show(); + SetLabel(label); + return true; +} + // ---------------------------------------------------------------------------- // various accessors // ---------------------------------------------------------------------------- @@ -143,6 +191,22 @@ FormType* wxControl::GetParentForm() const return tlw->GetForm(); } +uint16_t wxControl::GetObjectIndex() const +{ + FormType* form = GetParentForm(); + if(form==NULL)return frmInvalidObjectId; + return FrmGetObjectIndex(form, GetId()); +} + +void* wxControl::GetObjectPtr() const +{ + FormType* form = GetParentForm(); + if(form==NULL)return NULL; + uint16_t index = FrmGetObjectIndex(form, GetId()); + if(index==frmInvalidObjectId)return NULL; + return FrmGetObjectPtr(form,index); +} + wxBorder wxControl::GetDefaultBorder() const { // we want to automatically give controls a sunken style (confusingly, @@ -216,19 +280,21 @@ void wxControl::DoGetSize( int *width, int *height ) const bool wxControl::Enable(bool enable) { - if( m_control == NULL ) + ControlType *control = (ControlType *)GetObjectPtr(); + if( (IsPalmControl()) || (control == NULL)) return false; - if( IsEnabled() == enable) + if( CtlEnabled(control) == enable) return false; - CtlSetEnabled( m_control, enable); + CtlSetEnabled( control, enable); return true; } bool wxControl::IsEnabled() const { - if( m_control == NULL ) + ControlType *control = (ControlType *)GetObjectPtr(); + if( (IsPalmControl()) || (control == NULL)) return false; - return CtlEnabled(m_control); + return CtlEnabled(control); } bool wxControl::IsShown() const @@ -251,31 +317,75 @@ bool wxControl::Show( bool show ) return true; } +void wxControl::SetFieldLabel(const wxString& label) +{ + FieldType* field = (FieldType*)GetObjectPtr(); + if(field==NULL) + return; + + uint16_t newSize = label.Length() + 1; + MemHandle strHandle = FldGetTextHandle(field); + FldSetTextHandle(field, NULL ); + if (strHandle) + { + if(MemHandleResize(strHandle, newSize)!=errNone) + strHandle = 0; + } + else + { + strHandle = MemHandleNew( newSize ); + } + if(!strHandle) + return; + + char* str = (char*) MemHandleLock( strHandle ); + if(str==NULL) + return; + + strcpy(str, label.c_str()); + MemHandleUnlock(strHandle); + FldSetTextHandle(field, strHandle); + FldRecalculateField(field, true); +} + +void wxControl::SetControlLabel(const wxString& label) +{ +} + void wxControl::SetLabel(const wxString& label) { - // setting in wrong control causes crash - if ( ( wxDynamicCast(this,wxButton) != NULL ) || - ( wxDynamicCast(this,wxCheckBox) != NULL ) || - ( wxDynamicCast(this,wxRadioButton) != NULL ) || - ( wxDynamicCast(this,wxToggleButton) != NULL ) ) - { - m_label = label; - // TODO: as manual states, it crashes here - // needs own manipulation on used string pointers - // CtlSetLabel(m_control,m_label); - } + if(IsPalmField()) + SetFieldLabel(label); + + // unlike other native controls, slider has no label + if(IsPalmControl() && !wxDynamicCast(this,wxSlider)) + SetControlLabel(label); +} + +wxString wxControl::GetFieldLabel() +{ + FieldType* field = (FieldType*)GetObjectPtr(); + if(field==NULL) + return wxEmptyString; + return FldGetTextPtr(field); +} + +wxString wxControl::GetControlLabel() +{ + ControlType* control = (ControlType*)GetObjectPtr(); + if(control==NULL) + return wxEmptyString; + return CtlGetLabel(control); } wxString wxControl::GetLabel() { - // setting in wrong control causes crash - if ( wxDynamicCast(this,wxButton) || - wxDynamicCast(this,wxCheckBox) || - wxDynamicCast(this,wxRadioButton) || - wxDynamicCast(this,wxToggleButton) ) - { - return m_label; - } + if(IsPalmField()) + return GetFieldLabel(); + + // unlike other native controls, slider has no label + if(IsPalmControl() && !wxDynamicCast(this,wxSlider)) + return GetControlLabel(); return wxEmptyString; } diff --git a/src/palmos/frame.cpp b/src/palmos/frame.cpp index b64d4da89b..44da88f268 100644 --- a/src/palmos/frame.cpp +++ b/src/palmos/frame.cpp @@ -224,8 +224,10 @@ bool wxFrame::HandleMenuOpen() return true; } -bool wxFrame::HandleMenuSelect(int ItemID) +bool wxFrame::HandleMenuSelect(EventType* event) { + int ItemID = event->data.menu.itemID; + if (!m_frameMenuBar) return false; diff --git a/src/palmos/radiobox.cpp b/src/palmos/radiobox.cpp index 152fbc7a31..d6ead07206 100644 --- a/src/palmos/radiobox.cpp +++ b/src/palmos/radiobox.cpp @@ -2,10 +2,10 @@ // Name: src/palmos/radiobox.cpp // Purpose: wxRadioBox implementation // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation // Created: 10/13/04 // RCS-ID: $Id$ -// Copyright: (c) William Osborne +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -150,11 +150,6 @@ int wxRadioBox::GetNumHor() const return 0; } -bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id) -{ - return FALSE; -} - // Radio box item wxRadioBox::wxRadioBox() { @@ -298,11 +293,6 @@ bool wxRadioBox::SetFont(const wxFont& font) // our window proc // ---------------------------------------------------------------------------- -WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) -{ - return 0; -} - WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), WXUINT WXUNUSED(message), WXWPARAM WXUNUSED(wParam), diff --git a/src/palmos/radiobut.cpp b/src/palmos/radiobut.cpp index d7c45e609b..fe3a1845ee 100644 --- a/src/palmos/radiobut.cpp +++ b/src/palmos/radiobut.cpp @@ -102,6 +102,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) void wxRadioButton::Init() { + m_radioStyle = pushButtonCtl; } bool wxRadioButton::Create(wxWindow *parent, @@ -113,8 +114,16 @@ bool wxRadioButton::Create(wxWindow *parent, const wxValidator& validator, const wxString& name) { - wxControl::PalmCreateControl(pushButtonCtl, parent, id, label, pos, size); - return true; + if(!wxControl::Create(parent, id, pos, size, style, validator, name)) + return false; + + return wxControl::PalmCreateControl( + // be sure only one of two possibilities was taken + m_radioStyle == checkboxCtl ? checkboxCtl : pushButtonCtl, + label, + pos, + size + ); } // ---------------------------------------------------------------------------- @@ -135,6 +144,14 @@ bool wxRadioButton::GetValue() const // wxRadioButton event processing // ---------------------------------------------------------------------------- +bool wxRadioButton::SendClickEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, GetId()); + event.SetInt(GetValue()); + event.SetEventObject(this); + return ProcessCommand(event); +} + void wxRadioButton::Command (wxCommandEvent& event) { } diff --git a/src/palmos/slider.cpp b/src/palmos/slider.cpp index 2604f0bce5..b638ca961e 100644 --- a/src/palmos/slider.cpp +++ b/src/palmos/slider.cpp @@ -109,8 +109,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetParent(parent); - SetId( id == wxID_ANY ? NewControlId() : id ); + if(!wxControl::Create(parent, id, pos, size, style, validator, name)) + return false; + FormType* form = GetParentForm(); if(form==NULL) return false; @@ -145,29 +146,41 @@ wxSlider::~wxSlider() int wxSlider::GetMin() const { + ControlType *control = (ControlType *)GetObjectPtr(); + if(control==NULL) + return 0; uint16_t ret; - CtlGetSliderValues(m_control, &ret, NULL, NULL, NULL); + CtlGetSliderValues(control, &ret, NULL, NULL, NULL); return ret; } int wxSlider::GetMax() const { + ControlType *control = (ControlType *)GetObjectPtr(); + if(control==NULL) + return 0; uint16_t ret; - CtlGetSliderValues(m_control, NULL, &ret, NULL, NULL); + CtlGetSliderValues(control, NULL, &ret, NULL, NULL); return ret; } int wxSlider::GetPageSize() const { + ControlType *control = (ControlType *)GetObjectPtr(); + if(control==NULL) + return 0; uint16_t ret; - CtlGetSliderValues(m_control, NULL, NULL, &ret, NULL); + CtlGetSliderValues(control, NULL, NULL, &ret, NULL); return ret; } int wxSlider::GetValue() const { + ControlType *control = (ControlType *)GetObjectPtr(); + if(control==NULL) + return 0; uint16_t ret; - CtlGetSliderValues(m_control, NULL, NULL, NULL, &ret); + CtlGetSliderValues(control, NULL, NULL, NULL, &ret); return ret; } @@ -176,19 +189,6 @@ void wxSlider::SetValue(int value) SetIntValue(value); } -void wxSlider::DoGetSize(int *width, int *height) const -{ -} - -void wxSlider::GetPosition(int *x, int *y) const -{ -} - -void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags) -{ -} - - wxSize wxSlider::DoGetBestSize() const { return wxSize(0,0); diff --git a/src/palmos/stattext.cpp b/src/palmos/stattext.cpp index 38626a5762..789e227e3f 100644 --- a/src/palmos/stattext.cpp +++ b/src/palmos/stattext.cpp @@ -2,10 +2,10 @@ // Name: src/palmos/stattext.cpp // Purpose: wxStaticText // Author: William Osborne - minimal working wxPalmOS port -// Modified by: +// Modified by: Wlodzimierz ABX Skiba - native wxStaticText implementation // Created: 10/13/04 // RCS-ID: $Id$ -// Copyright: (c) William Osborne +// Copyright: (c) William Osborne, Wlodzimierz Skiba // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -29,7 +29,6 @@ #endif #include "wx/stattext.h" -#include "wx/palmos/private.h" #if wxUSE_EXTENDED_RTTI WX_DEFINE_FLAGS( wxStaticTextStyle ) @@ -92,7 +91,10 @@ bool wxStaticText::Create(wxWindow *parent, long style, const wxString& name) { - return false; + if(!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name)) + return false; + + return wxControl::PalmCreateField(label, pos, size, false, false, leftAlign); } wxBorder wxStaticText::GetDefaultBorder() const @@ -100,25 +102,11 @@ wxBorder wxStaticText::GetDefaultBorder() const return wxBORDER_NONE; } -WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const -{ - return 0; -} - wxSize wxStaticText::DoGetBestSize() const { return wxSize(0,0); } -void wxStaticText::DoSetSize(int x, int y, int w, int h, int sizeFlags) -{ -} - -void wxStaticText::SetLabel(const wxString& label) -{ -} - - bool wxStaticText::SetFont(const wxFont& font) { return false; diff --git a/src/palmos/tglbtn.cpp b/src/palmos/tglbtn.cpp index e4b49b65ab..7412efaf5c 100644 --- a/src/palmos/tglbtn.cpp +++ b/src/palmos/tglbtn.cpp @@ -60,8 +60,10 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - wxControl::PalmCreateControl(pushButtonCtl, parent, id, label, pos, size); - return true; + if(!wxControl::Create(parent, id, pos, size, style, validator, name)) + return false; + + return wxControl::PalmCreateControl(pushButtonCtl, label, pos, size); } wxBorder wxToggleButton::GetDefaultBorder() const @@ -84,6 +86,14 @@ bool wxToggleButton::GetValue() const return GetBoolValue(); } +bool wxToggleButton::SendClickEvent() +{ + wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, GetId()); + event.SetInt(GetValue()); + event.SetEventObject(this); + return ProcessCommand(event); +} + void wxToggleButton::Command(wxCommandEvent & event) { } diff --git a/src/palmos/toplevel.cpp b/src/palmos/toplevel.cpp index 2a31a6b83e..78e34bc01f 100644 --- a/src/palmos/toplevel.cpp +++ b/src/palmos/toplevel.cpp @@ -40,9 +40,14 @@ #endif //WX_PRECOMP #include "wx/module.h" - #include "wx/display.h" +// controls for sending select event +#include "wx/button.h" +#include "wx/checkbox.h" +#include "wx/radiobut.h" +#include "wx/tglbtn.h" + // ---------------------------------------------------------------------------- // globals // ---------------------------------------------------------------------------- @@ -240,6 +245,32 @@ bool wxTopLevelWindowPalm::SetShape(const wxRegion& region) // wxTopLevelWindow event handling // ---------------------------------------------------------------------------- +bool wxTopLevelWindowPalm::HandleControlSelect(EventType* event) +{ + int id = event->data.ctlSelect.controlID; + wxWindow* win = FindWindowById(id,this); + if(win==NULL) + return false; + + wxButton* button = wxDynamicCast(win,wxButton); + if(button) + return button->SendClickEvent(); + + wxCheckBox* checkbox = wxDynamicCast(win,wxCheckBox); + if(checkbox) + return checkbox->SendClickEvent(); + + wxToggleButton* toggle = wxDynamicCast(win,wxToggleButton); + if(toggle) + return toggle->SendClickEvent(); + + wxRadioButton* radio = wxDynamicCast(win,wxRadioButton); + if(radio) + return radio->SendClickEvent(); + + return false; +} + void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event) { } @@ -258,29 +289,26 @@ void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event) * finds a better solution, please let me know. My email address is * wbo@freeshell.org */ -static Boolean FrameFormHandleEvent(EventType* pEvent) +static Boolean FrameFormHandleEvent(EventType* event) { wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame); - Boolean fHandled = false; - FormType* pForm; - WinHandle hWindow; - int ItemID=0; + Boolean handled = false; - switch (pEvent->eType) { + switch (event->eType) { case ctlSelectEvent: + handled = frame->HandleControlSelect(event); break; #if wxUSE_MENUS_NATIVE case menuOpenEvent: - fHandled = frame->HandleMenuOpen(); + handled = frame->HandleMenuOpen(); break; case menuEvent: - ItemID = pEvent->data.menu.itemID; - fHandled = frame->HandleMenuSelect(ItemID); + handled = frame->HandleMenuSelect(event); break; #endif default: break; } - return fHandled; + return handled; } diff --git a/src/palmos/window.cpp b/src/palmos/window.cpp index d908c96629..5eba9aed6a 100644 --- a/src/palmos/window.cpp +++ b/src/palmos/window.cpp @@ -269,7 +269,16 @@ bool wxWindowPalm::Create(wxWindow *parent, long style, const wxString& name) { - return false; + wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") ); + + if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) + return false; + + parent->AddChild(this); + + InheritAttributes(); + + return true; } FormType *wxWindowPalm::GetFormPtr()