Native wxStaticText. Cleaning of wxRadioBox code before native implementation. Events for wxButton, wxCheckBox, wxToggleButton, wxRadioButton sended from within wxTLW. Internal improvements in structure of wxControl. Pass full palm event to handlers (instead of ID only). Last palm control ID with value which allow portable IDs with wxMSW (according to comment in msw code).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-01-31 08:04:44 +00:00
parent 9cc311d32c
commit a152561c76
26 changed files with 345 additions and 149 deletions

View File

@@ -119,6 +119,7 @@ wxPalmOS:
- native wxSlider implementation - native wxSlider implementation
- native wxToggleButton implementation - native wxToggleButton implementation
- native wxRadioButton implementation - native wxRadioButton implementation
- native wxStaticText implementation
2.5.3 2.5.3

View File

@@ -52,6 +52,9 @@ public:
// implementation from now on // implementation from now on
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
// send a notification event, return true if processed
bool SendClickEvent();
virtual void ApplyParentThemeBackground(const wxColour& bg) virtual void ApplyParentThemeBackground(const wxColour& bg)
{ {
// avoide switching into owner-drawn mode // avoide switching into owner-drawn mode
@@ -59,8 +62,6 @@ public:
} }
protected: protected:
// send a notification event, return true if processed
bool SendClickEvent();
// default button handling // default button handling
void SetTmpDefault(); void SetTmpDefault();

View File

@@ -47,6 +47,9 @@ public:
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
// send a notification event, return true if processed
bool SendClickEvent();
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;

View File

@@ -22,7 +22,7 @@
class WXDLLEXPORT wxControl : public wxControlBase class WXDLLEXPORT wxControl : public wxControlBase
{ {
public: public:
wxControl() { } wxControl() { Init(); }
wxControl(wxWindow *parent, wxWindowID id, wxControl(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -30,6 +30,7 @@ public:
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr) const wxString& name = wxControlNameStr)
{ {
Init();
Create(parent, id, pos, size, style, validator, name); Create(parent, id, pos, size, style, validator, name);
} }
@@ -77,6 +78,8 @@ public:
protected: protected:
// regardless how deeply we are in wxWidgets hierarchy always get correct form // regardless how deeply we are in wxWidgets hierarchy always get correct form
FormType* GetParentForm() const; FormType* GetParentForm() const;
uint16_t GetObjectIndex() const;
void* GetObjectPtr() const;
// choose the default border for this window // choose the default border for this window
virtual wxBorder GetDefaultBorder() const; virtual wxBorder GetDefaultBorder() const;
@@ -86,6 +89,12 @@ protected:
bool GetBoolValue() const; bool GetBoolValue() const;
void SetIntValue(int val); 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) // return default best size (doesn't really make any sense, override this)
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
@@ -99,11 +108,19 @@ protected:
// supposed to had been already set and so is used instead when this // supposed to had been already set and so is used instead when this
// function is called) // function is called)
bool PalmCreateControl(ControlStyleType style, bool PalmCreateControl(ControlStyleType style,
wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, 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() // this is a helper for the derived class GetClassDefaultAttributes()
// implementation: it returns the right colours for the classes which // implementation: it returns the right colours for the classes which
@@ -117,10 +134,14 @@ protected:
// holds the ids (not HWNDs!) of the sub controls // holds the ids (not HWNDs!) of the sub controls
wxArrayLong m_subControls; wxArrayLong m_subControls;
ControlType *m_control;
private: private:
bool m_palmControl:1;
bool m_palmField:1;
// common part of all ctors
void Init();
virtual void DoGetBounds( RectangleType &rect ) const; virtual void DoGetBounds( RectangleType &rect ) const;
// m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc. // m_label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.

View File

@@ -86,7 +86,7 @@ public:
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
bool HandleMenuOpen(); bool HandleMenuOpen();
bool HandleMenuSelect(int ItemID); bool HandleMenuSelect(EventType* event);
#endif // wxUSE_MENUS_NATIVE #endif // wxUSE_MENUS_NATIVE
protected: protected:
@@ -118,7 +118,7 @@ protected:
// handle WM_INITMENUPOPUP message // handle WM_INITMENUPOPUP message
bool HandleInitMenuPopup(WXHMENU hMenu); bool HandleInitMenuPopup(WXHMENU hMenu);
virtual bool IsMDIChild() const { return FALSE; } virtual bool IsMDIChild() const { return false; }
// get default (wxWidgets) icon for the frame // get default (wxWidgets) icon for the frame
virtual WXHICON GetDefaultIcon() const; virtual WXHICON GetDefaultIcon() const;

View File

@@ -2,10 +2,10 @@
// Name: wx/palmos/radiobox.h // Name: wx/palmos/radiobox.h
// Purpose: wxRadioBox class // Purpose: wxRadioBox class
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -85,14 +85,14 @@ public:
virtual int GetCount() const; virtual int GetCount() const;
virtual wxString GetString(int n) const; virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label); virtual void SetString(int n, const wxString& label);
virtual void Enable(int n, bool enable = TRUE); virtual void Enable(int n, bool enable = true);
virtual void Show(int n, bool show = TRUE); virtual void Show(int n, bool show = true);
virtual int GetColumnCount() const; virtual int GetColumnCount() const;
virtual int GetRowCount() const; virtual int GetRowCount() const;
virtual bool Show(bool show = TRUE); virtual bool Show(bool show = true);
void SetFocus(); void SetFocus();
virtual bool Enable(bool enable = TRUE); virtual bool Enable(bool enable = true);
void SetLabelFont(const wxFont& WXUNUSED(font)) {}; void SetLabelFont(const wxFont& WXUNUSED(font)) {};
void SetButtonFont(const wxFont& font) { SetFont(font); } void SetButtonFont(const wxFont& font) { SetFont(font); }
@@ -104,15 +104,12 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
virtual bool MSWCommand(WXUINT param, WXWORD id);
// FIXME: are they used? missing "Do" prefix? // FIXME: are they used? missing "Do" prefix?
void GetSize(int *x, int *y) const; void GetSize(int *x, int *y) const;
void GetPosition(int *x, int *y) const; void GetPosition(int *x, int *y) const;
virtual bool SetFont(const wxFont& font); virtual bool SetFont(const wxFont& font);
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXUINT message,
WXWPARAM wParam, WXLPARAM lParam); WXWPARAM wParam, WXLPARAM lParam);

View File

@@ -51,6 +51,10 @@ public:
// implementation only from now on // implementation only from now on
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
// send a notification event, return true if processed
bool SendClickEvent();
virtual void ApplyParentThemeBackground(const wxColour& bg) virtual void ApplyParentThemeBackground(const wxColour& bg)
{ SetBackgroundColour(bg); } { SetBackgroundColour(bg); }
@@ -62,6 +66,8 @@ private:
// common part of all ctors // common part of all ctors
void Init(); void Init();
// pushButtonCtl or checkboxCtl
ControlStyleType m_radioStyle;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton) DECLARE_DYNAMIC_CLASS_NO_COPY(wxRadioButton)
}; };

View File

@@ -528,7 +528,7 @@
#define wxUSE_SPINCTRL 0 // wxSpinCtrl #define wxUSE_SPINCTRL 0 // wxSpinCtrl
#define wxUSE_STATBOX 0 // wxStaticBox #define wxUSE_STATBOX 0 // wxStaticBox
#define wxUSE_STATLINE 0 // wxStaticLine #define wxUSE_STATLINE 0 // wxStaticLine
#define wxUSE_STATTEXT 0 // wxStaticText #define wxUSE_STATTEXT 1 // wxStaticText
#define wxUSE_STATBMP 0 // wxStaticBitmap #define wxUSE_STATBMP 0 // wxStaticBitmap
#define wxUSE_TEXTCTRL 0 // wxTextCtrl #define wxUSE_TEXTCTRL 0 // wxTextCtrl
#define wxUSE_TOGGLEBTN 1 // requires wxButton #define wxUSE_TOGGLEBTN 1 // requires wxButton

View File

@@ -46,8 +46,6 @@ public:
virtual int GetValue() const; virtual int GetValue() const;
virtual void SetValue(int); virtual void SetValue(int);
void GetPosition(int *x, int *y) const;
void SetRange(int minValue, int maxValue); void SetRange(int minValue, int maxValue);
int GetMin() const; int GetMin() const;
@@ -73,12 +71,6 @@ public:
void Command(wxCommandEvent& event); void Command(wxCommandEvent& event);
protected: 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; virtual wxSize DoGetBestSize() const;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider) DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider)

View File

@@ -2,10 +2,10 @@
// Name: wx/palmos/stattext.h // Name: wx/palmos/stattext.h
// Purpose: wxStaticText class // Purpose: wxStaticText class
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxStaticText implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -41,16 +41,12 @@ public:
const wxString& name = wxStaticTextNameStr); const wxString& name = wxStaticTextNameStr);
// override some methods to resize the window properly // override some methods to resize the window properly
virtual void SetLabel(const wxString& label);
virtual bool SetFont( const wxFont &font ); virtual bool SetFont( const wxFont &font );
protected: protected:
// implement/override some base class virtuals // implement/override some base class virtuals
virtual wxBorder GetDefaultBorder() const; virtual wxBorder GetDefaultBorder() const;
virtual void DoSetSize(int x, int y, int w, int h,
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText) DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText)
}; };

View File

@@ -46,6 +46,9 @@ public:
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
// send a notification event, return true if processed
bool SendClickEvent();
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual wxBorder GetDefaultBorder() const; virtual wxBorder GetDefaultBorder() const;

View File

@@ -84,6 +84,9 @@ public:
// interface to native frame structure // interface to native frame structure
FormType *GetForm() const; FormType *GetForm() const;
// handle controls
bool HandleControlSelect(EventType* event);
protected: protected:
// common part of all ctors // common part of all ctors
void Init(); void Init();

View File

@@ -117,6 +117,8 @@ public:
#include "wx/cocoa/radiobox.h" #include "wx/cocoa/radiobox.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/radiobox.h" #include "wx/os2/radiobox.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/radiobox.h"
#endif #endif
#endif // wxUSE_RADIOBOX #endif // wxUSE_RADIOBOX

View File

@@ -34,6 +34,8 @@ private:
#include "wx/cocoa/stattext.h" #include "wx/cocoa/stattext.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/stattext.h" #include "wx/os2/stattext.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/stattext.h"
#endif #endif
#endif // wxUSE_STATTEXT #endif // wxUSE_STATTEXT

View File

@@ -86,7 +86,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
int wxWindowBase::ms_lastControlId = 65535; int wxWindowBase::ms_lastControlId = 32767;
#elif defined(__WXPM__) #elif defined(__WXPM__)
int wxWindowBase::ms_lastControlId = 2000; int wxWindowBase::ms_lastControlId = 2000;
#else #else

View File

@@ -170,8 +170,10 @@ bool wxButton::Create(wxWindow *parent,
if( palmLabel.empty() && wxIsStockID(id) ) if( palmLabel.empty() && wxIsStockID(id) )
palmLabel = wxGetStockLabel(id); palmLabel = wxGetStockLabel(id);
wxControl::PalmCreateControl(buttonCtl, parent, id, palmLabel, palmPos, palmSize); if(!wxControl::Create(parent, id, palmPos, palmSize, style, validator, name))
return true; return false;
return wxControl::PalmCreateControl(buttonCtl, palmLabel, palmPos, palmSize);
} }
wxButton::~wxButton() wxButton::~wxButton()
@@ -221,11 +223,14 @@ wxButton::SetDefaultStyle(wxButton *btn, bool on)
bool wxButton::SendClickEvent() bool wxButton::SendClickEvent()
{ {
return false; wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
event.SetEventObject(this);
return ProcessCommand(event);
} }
void wxButton::Command(wxCommandEvent &event) void wxButton::Command(wxCommandEvent &event)
{ {
ProcessCommand(event);
} }
#endif // wxUSE_BUTTON #endif // wxUSE_BUTTON

View File

@@ -106,8 +106,10 @@ bool wxCheckBox::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
wxControl::PalmCreateControl(checkboxCtl, parent, id, label, pos, size); if(!wxControl::Create(parent, id, pos, size, style, validator, name))
return true; return false;
return wxControl::PalmCreateControl(checkboxCtl, label, pos, size);
} }
wxSize wxCheckBox::DoGetBestSize() const wxSize wxCheckBox::DoGetBestSize() const
@@ -125,6 +127,14 @@ bool wxCheckBox::GetValue() const
return GetBoolValue(); 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) void wxCheckBox::Command(wxCommandEvent& event)
{ {
} }

View File

@@ -44,6 +44,7 @@
#include "wx/checkbox.h" #include "wx/checkbox.h"
#include "wx/tglbtn.h" #include "wx/tglbtn.h"
#include "wx/radiobut.h" #include "wx/radiobut.h"
#include "wx/slider.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxWin macros // wxWin macros
@@ -63,6 +64,12 @@ END_EVENT_TABLE()
// wxControl ctor/dtor // wxControl ctor/dtor
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxControl::Init()
{
m_palmControl = false;
m_palmField = false;
}
wxControl::~wxControl() wxControl::~wxControl()
{ {
m_isBeingDeleted = true; m_isBeingDeleted = true;
@@ -91,41 +98,82 @@ bool wxControl::Create(wxWindow *parent,
} }
bool wxControl::PalmCreateControl(ControlStyleType style, bool wxControl::PalmCreateControl(ControlStyleType style,
wxWindow *parent,
wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size) const wxSize& size,
int groupID)
{ {
SetParent(parent);
SetId( id == wxID_ANY ? NewControlId() : id );
FormType* form = GetParentForm(); FormType* form = GetParentForm();
if(form==NULL) if(form==NULL)
return false; return false;
m_label = label; m_label = label;
m_control = CtlNewControl( ControlType *control = CtlNewControl(
(void **)&form, (void **)&form,
GetId(), GetId(),
style, style,
m_label.c_str(), m_label.c_str(),
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x,
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y,
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x,
( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y,
stdFont, stdFont,
0, groupID,
false false
); );
if(m_control==NULL) if(control==NULL)
return false; return false;
m_palmControl = true;
Show(); Show();
return true; 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 // various accessors
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -143,6 +191,22 @@ FormType* wxControl::GetParentForm() const
return tlw->GetForm(); 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 wxBorder wxControl::GetDefaultBorder() const
{ {
// we want to automatically give controls a sunken style (confusingly, // 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) bool wxControl::Enable(bool enable)
{ {
if( m_control == NULL ) ControlType *control = (ControlType *)GetObjectPtr();
if( (IsPalmControl()) || (control == NULL))
return false; return false;
if( IsEnabled() == enable) if( CtlEnabled(control) == enable)
return false; return false;
CtlSetEnabled( m_control, enable); CtlSetEnabled( control, enable);
return true; return true;
} }
bool wxControl::IsEnabled() const bool wxControl::IsEnabled() const
{ {
if( m_control == NULL ) ControlType *control = (ControlType *)GetObjectPtr();
if( (IsPalmControl()) || (control == NULL))
return false; return false;
return CtlEnabled(m_control); return CtlEnabled(control);
} }
bool wxControl::IsShown() const bool wxControl::IsShown() const
@@ -251,31 +317,75 @@ bool wxControl::Show( bool show )
return true; 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) void wxControl::SetLabel(const wxString& label)
{ {
// setting in wrong control causes crash if(IsPalmField())
if ( ( wxDynamicCast(this,wxButton) != NULL ) || SetFieldLabel(label);
( wxDynamicCast(this,wxCheckBox) != NULL ) ||
( wxDynamicCast(this,wxRadioButton) != NULL ) || // unlike other native controls, slider has no label
( wxDynamicCast(this,wxToggleButton) != NULL ) ) if(IsPalmControl() && !wxDynamicCast(this,wxSlider))
{ SetControlLabel(label);
m_label = label; }
// TODO: as manual states, it crashes here
// needs own manipulation on used string pointers wxString wxControl::GetFieldLabel()
// CtlSetLabel(m_control,m_label); {
} 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() wxString wxControl::GetLabel()
{ {
// setting in wrong control causes crash if(IsPalmField())
if ( wxDynamicCast(this,wxButton) || return GetFieldLabel();
wxDynamicCast(this,wxCheckBox) ||
wxDynamicCast(this,wxRadioButton) || // unlike other native controls, slider has no label
wxDynamicCast(this,wxToggleButton) ) if(IsPalmControl() && !wxDynamicCast(this,wxSlider))
{ return GetControlLabel();
return m_label;
}
return wxEmptyString; return wxEmptyString;
} }

View File

@@ -224,8 +224,10 @@ bool wxFrame::HandleMenuOpen()
return true; return true;
} }
bool wxFrame::HandleMenuSelect(int ItemID) bool wxFrame::HandleMenuSelect(EventType* event)
{ {
int ItemID = event->data.menu.itemID;
if (!m_frameMenuBar) if (!m_frameMenuBar)
return false; return false;

View File

@@ -2,10 +2,10 @@
// Name: src/palmos/radiobox.cpp // Name: src/palmos/radiobox.cpp
// Purpose: wxRadioBox implementation // Purpose: wxRadioBox implementation
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxRadioBox implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -150,11 +150,6 @@ int wxRadioBox::GetNumHor() const
return 0; return 0;
} }
bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id)
{
return FALSE;
}
// Radio box item // Radio box item
wxRadioBox::wxRadioBox() wxRadioBox::wxRadioBox()
{ {
@@ -298,11 +293,6 @@ bool wxRadioBox::SetFont(const wxFont& font)
// our window proc // 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), WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
WXUINT WXUNUSED(message), WXUINT WXUNUSED(message),
WXWPARAM WXUNUSED(wParam), WXWPARAM WXUNUSED(wParam),

View File

@@ -102,6 +102,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
void wxRadioButton::Init() void wxRadioButton::Init()
{ {
m_radioStyle = pushButtonCtl;
} }
bool wxRadioButton::Create(wxWindow *parent, bool wxRadioButton::Create(wxWindow *parent,
@@ -113,8 +114,16 @@ bool wxRadioButton::Create(wxWindow *parent,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
wxControl::PalmCreateControl(pushButtonCtl, parent, id, label, pos, size); if(!wxControl::Create(parent, id, pos, size, style, validator, name))
return true; 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 // 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) void wxRadioButton::Command (wxCommandEvent& event)
{ {
} }

View File

@@ -109,8 +109,9 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetParent(parent); if(!wxControl::Create(parent, id, pos, size, style, validator, name))
SetId( id == wxID_ANY ? NewControlId() : id ); return false;
FormType* form = GetParentForm(); FormType* form = GetParentForm();
if(form==NULL) if(form==NULL)
return false; return false;
@@ -145,29 +146,41 @@ wxSlider::~wxSlider()
int wxSlider::GetMin() const int wxSlider::GetMin() const
{ {
ControlType *control = (ControlType *)GetObjectPtr();
if(control==NULL)
return 0;
uint16_t ret; uint16_t ret;
CtlGetSliderValues(m_control, &ret, NULL, NULL, NULL); CtlGetSliderValues(control, &ret, NULL, NULL, NULL);
return ret; return ret;
} }
int wxSlider::GetMax() const int wxSlider::GetMax() const
{ {
ControlType *control = (ControlType *)GetObjectPtr();
if(control==NULL)
return 0;
uint16_t ret; uint16_t ret;
CtlGetSliderValues(m_control, NULL, &ret, NULL, NULL); CtlGetSliderValues(control, NULL, &ret, NULL, NULL);
return ret; return ret;
} }
int wxSlider::GetPageSize() const int wxSlider::GetPageSize() const
{ {
ControlType *control = (ControlType *)GetObjectPtr();
if(control==NULL)
return 0;
uint16_t ret; uint16_t ret;
CtlGetSliderValues(m_control, NULL, NULL, &ret, NULL); CtlGetSliderValues(control, NULL, NULL, &ret, NULL);
return ret; return ret;
} }
int wxSlider::GetValue() const int wxSlider::GetValue() const
{ {
ControlType *control = (ControlType *)GetObjectPtr();
if(control==NULL)
return 0;
uint16_t ret; uint16_t ret;
CtlGetSliderValues(m_control, NULL, NULL, NULL, &ret); CtlGetSliderValues(control, NULL, NULL, NULL, &ret);
return ret; return ret;
} }
@@ -176,19 +189,6 @@ void wxSlider::SetValue(int value)
SetIntValue(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 wxSize wxSlider::DoGetBestSize() const
{ {
return wxSize(0,0); return wxSize(0,0);

View File

@@ -2,10 +2,10 @@
// Name: src/palmos/stattext.cpp // Name: src/palmos/stattext.cpp
// Purpose: wxStaticText // Purpose: wxStaticText
// Author: William Osborne - minimal working wxPalmOS port // Author: William Osborne - minimal working wxPalmOS port
// Modified by: // Modified by: Wlodzimierz ABX Skiba - native wxStaticText implementation
// Created: 10/13/04 // Created: 10/13/04
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) William Osborne // Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -29,7 +29,6 @@
#endif #endif
#include "wx/stattext.h" #include "wx/stattext.h"
#include "wx/palmos/private.h"
#if wxUSE_EXTENDED_RTTI #if wxUSE_EXTENDED_RTTI
WX_DEFINE_FLAGS( wxStaticTextStyle ) WX_DEFINE_FLAGS( wxStaticTextStyle )
@@ -92,7 +91,10 @@ bool wxStaticText::Create(wxWindow *parent,
long style, long style,
const wxString& name) 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 wxBorder wxStaticText::GetDefaultBorder() const
@@ -100,25 +102,11 @@ wxBorder wxStaticText::GetDefaultBorder() const
return wxBORDER_NONE; return wxBORDER_NONE;
} }
WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const
{
return 0;
}
wxSize wxStaticText::DoGetBestSize() const wxSize wxStaticText::DoGetBestSize() const
{ {
return wxSize(0,0); 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) bool wxStaticText::SetFont(const wxFont& font)
{ {
return false; return false;

View File

@@ -60,8 +60,10 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
wxControl::PalmCreateControl(pushButtonCtl, parent, id, label, pos, size); if(!wxControl::Create(parent, id, pos, size, style, validator, name))
return true; return false;
return wxControl::PalmCreateControl(pushButtonCtl, label, pos, size);
} }
wxBorder wxToggleButton::GetDefaultBorder() const wxBorder wxToggleButton::GetDefaultBorder() const
@@ -84,6 +86,14 @@ bool wxToggleButton::GetValue() const
return GetBoolValue(); 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) void wxToggleButton::Command(wxCommandEvent & event)
{ {
} }

View File

@@ -40,9 +40,14 @@
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/module.h" #include "wx/module.h"
#include "wx/display.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 // globals
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -240,6 +245,32 @@ bool wxTopLevelWindowPalm::SetShape(const wxRegion& region)
// wxTopLevelWindow event handling // 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) 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 * finds a better solution, please let me know. My email address is
* wbo@freeshell.org * wbo@freeshell.org
*/ */
static Boolean FrameFormHandleEvent(EventType* pEvent) static Boolean FrameFormHandleEvent(EventType* event)
{ {
wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame); wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame);
Boolean fHandled = false; Boolean handled = false;
FormType* pForm;
WinHandle hWindow;
int ItemID=0;
switch (pEvent->eType) { switch (event->eType) {
case ctlSelectEvent: case ctlSelectEvent:
handled = frame->HandleControlSelect(event);
break; break;
#if wxUSE_MENUS_NATIVE #if wxUSE_MENUS_NATIVE
case menuOpenEvent: case menuOpenEvent:
fHandled = frame->HandleMenuOpen(); handled = frame->HandleMenuOpen();
break; break;
case menuEvent: case menuEvent:
ItemID = pEvent->data.menu.itemID; handled = frame->HandleMenuSelect(event);
fHandled = frame->HandleMenuSelect(ItemID);
break; break;
#endif #endif
default: default:
break; break;
} }
return fHandled; return handled;
} }

View File

@@ -269,7 +269,16 @@ bool wxWindowPalm::Create(wxWindow *parent,
long style, long style,
const wxString& name) 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() FormType *wxWindowPalm::GetFormPtr()