WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
protected:
+ // regardless how deeply we are in wxWidgets hierarchy always get correct form
+ FormType* GetParentForm() const;
+
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const;
+ // on/off-like controls
+ void SetBoolValue(bool value);
+ bool GetBoolValue() const;
+ void SetIntValue(int val);
+
// return default best size (doesn't really make any sense, override this)
virtual wxSize DoGetBestSize() const;
ControlType *m_control;
private:
+
+ // Label stores label in case of wxButton, wxCheckBox, wxToggleButton etc.
+ // We must ensure that it persists for as long as it is being displayed
+ // (that is, for as long as the control is displayed or until we call
+ // CtlSetLabel() with a new string), and we must free the string after
+ // it is no longer in use (typically after the form containing the
+ // control is freed).
+ wxString m_label;
+
DECLARE_DYNAMIC_CLASS_NO_COPY(wxControl)
DECLARE_EVENT_TABLE()
};
virtual bool PalmOnScroll(int orientation, WXWORD nSBCode,
WXWORD pos, WXHWND control);
- // child control notifications
-#ifdef __WIN95__
- virtual bool PalmOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
-#endif // __WIN95__
-
// owner-drawn controls need to process these messages
virtual bool PalmOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
virtual bool PalmOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
bool HandleMoving(wxRect& rect);
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
-#ifdef __WIN95__
- bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
-#endif // __WIN95__
-
// list of disabled children before last call to our Disable()
wxWindowList *m_childrenDisabled;
// static data
// ----------------------------------------------------------------------------
-#if defined(__WXPM__)
+#if defined(__WXPALMOS__)
+int wxWindowBase::ms_lastControlId = 65535;
+#elif defined(__WXPM__)
int wxWindowBase::ms_lastControlId = 2000;
#else
int wxWindowBase::ms_lastControlId = -200;
return (realChildCount > 0);
}
#endif
-
+
void wxWindowBase::InvalidateBestSize()
{
m_bestSizeCache = wxDefaultSize;
#endif
title = GetWindow()->GetName();
- if (!title.IsEmpty())
+ if (!title.empty())
{
*name = title;
return wxACC_OK;
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
- if (!ht.IsEmpty())
+ if (!ht.empty())
{
*description = ht;
return wxACC_OK;
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
- if (!ht.IsEmpty())
+ if (!ht.empty())
{
*helpText = ht;
return wxACC_OK;
void wxButton::SetDefault()
{
+ FormType* form = GetParentForm();
+ if(form==NULL)
+ return;
+ FrmSetDefaultButtonID(form,GetId());
}
void wxButton::SetTmpDefault()
void wxCheckBox::SetValue(bool val)
{
+ SetBoolValue(val);
}
bool wxCheckBox::GetValue() const
{
- return false;
+ return GetBoolValue();
}
void wxCheckBox::Command(wxCommandEvent& event)
const wxPoint& pos,
const wxSize& size)
{
- wxWindow* parentTLW = parent;
- while ( parentTLW && !parentTLW->IsTopLevel() )
- {
- parentTLW = parentTLW->GetParent();
- }
- wxTopLevelWindowPalm* tlw = wxDynamicCast(parentTLW, wxTopLevelWindowPalm);
- if(!tlw)
+ SetParent(parent);
+ SetId( id == wxID_ANY ? NewControlId() : id );
+ FormType* form = GetParentForm();
+ if(form==NULL)
return false;
- FormType* form = tlw->GetForm();
- SetParent(parent);
+ m_label = label;
m_control = CtlNewControl(
(void **)&form,
- id,
+ GetId(),
style,
- label.c_str(),
- pos.x,
- pos.y,
- size.x,
- size.y,
+ 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,
boldFont,
0,
false
// various accessors
// ----------------------------------------------------------------------------
+FormType* wxControl::GetParentForm() const
+{
+ wxWindow* parentTLW = GetParent();
+ while ( parentTLW && !parentTLW->IsTopLevel() )
+ {
+ parentTLW = parentTLW->GetParent();
+ }
+ wxTopLevelWindowPalm* tlw = wxDynamicCast(parentTLW, wxTopLevelWindowPalm);
+ if(!tlw)
+ return NULL;
+ return tlw->GetForm();
+}
+
wxBorder wxControl::GetDefaultBorder() const
{
// we want to automatically give controls a sunken style (confusingly,
return wxBORDER_SUNKEN;
}
+void wxControl::SetIntValue(int val)
+{
+ FormType* form = GetParentForm();
+ if(form==NULL)
+ return;
+ uint16_t index = FrmGetObjectIndex(form, GetId());
+ if(index==frmInvalidObjectId)
+ return;
+ FrmSetControlValue(form, index, val);
+}
+
+void wxControl::SetBoolValue(bool val)
+{
+ SetIntValue(val?1:0);
+}
+
+bool wxControl::GetBoolValue() const
+{
+ FormType* form = GetParentForm();
+ if(form==NULL)
+ return false;
+ uint16_t index = FrmGetObjectIndex(form, GetId());
+ if(index==frmInvalidObjectId)
+ return false;
+ return ( FrmGetControlValue(form, index) == 1 );
+}
+
wxSize wxControl::DoGetBestSize() const
{
return wxSize(16, 16);
bool wxControl::Show( bool show )
{
+ FormType* form = GetParentForm();
+ if(form==NULL)
+ return false;
+ uint16_t index = FrmGetObjectIndex(form,GetId());
+ if(index==frmInvalidObjectId)
+ return false;
if(show)
- CtlShowControl(m_control);
+ FrmShowObject(form,index);
else
- CtlHideControl(m_control);
+ FrmHideObject(form,index);
return true;
}
( wxDynamicCast(this,wxCheckBox) != NULL ) ||
( wxDynamicCast(this,wxToggleButton) != NULL ) )
{
- CtlSetLabel(m_control,label);
+ m_label = label;
+ // TODO: as manual states, it crashes here
+ // needs own manipulation on used string pointers
+ // CtlSetLabel(m_control,m_label);
}
}
wxDynamicCast(this,wxCheckBox) ||
wxDynamicCast(this,wxToggleButton) )
{
- return CtlGetLabel(m_control);
+ return m_label;
}
return wxEmptyString;
const wxValidator& validator,
const wxString& name)
{
- wxWindow* parentTLW = GetParent();
- while ( parentTLW && !parentTLW->IsTopLevel() )
- {
- parentTLW = parentTLW->GetParent();
- }
- wxTopLevelWindowPalm* tlw = wxDynamicCast(parentTLW, wxTopLevelWindowPalm);
- if(!tlw)
- return false;
- FormType* form = tlw->GetForm();
-
SetParent(parent);
+ SetId( id == wxID_ANY ? NewControlId() : id );
+ FormType* form = GetParentForm();
+ if(form==NULL)
+ return false;
SliderControlType *slider = CtlNewSliderControl (
(void **)&form,
- id,
+ GetId(),
feedbackSliderCtl,
NULL,
0,
value
);
- m_control = (ControlType*) slider;
-
- if(m_control==NULL)
+ if(slider==NULL)
return false;
Show();
void wxSlider::SetValue(int value)
{
+ SetIntValue(value);
}
void wxSlider::DoGetSize(int *width, int *height) const
SetName(name);
SetParent(parent);
+ SetId( id == wxID_ANY ? NewControlId() : id );
parent->AddChild(this);
- m_windowId = id == wxID_ANY ? NewControlId() : id;
-
SetFieldsCount(1);
SubclassWin(m_hWnd);
void wxToggleButton::SetValue(bool val)
{
+ SetBoolValue(val);
}
bool wxToggleButton::GetValue() const
{
- return false;
+ return GetBoolValue();
}
void wxToggleButton::Command(wxCommandEvent & event)
if ( parent )
parent->AddChild(this);
- m_windowId = id == wxID_ANY ? NewControlId() : id;
+ SetId( id == wxID_ANY ? NewControlId() : id );
WinConstraintsType constraints;
memset(&constraints, 0, sizeof(WinConstraintsType));
+ // position
constraints.x_pos = ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x;
constraints.y_pos = ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y;
+ // size
constraints.x_min = winUndefConstraint;
constraints.x_max = winMaxConstraint;
constraints.x_pref = ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x;
constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y;
FrameForm = FrmNewFormWithConstraints(
- m_windowId,
+ GetId(),
title.c_str(),
winFlagBackBuffer,
&constraints,
// Name: src/palmos/windows.cpp
// Purpose: wxWindow
// Author: William Osborne - minimal working wxPalmOS port
-// Modified by:
+// Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
// Created: 10/13/04
// RCS-ID: $Id$
-// Copyright: (c) William Osborne
+// Copyright: (c) William Osborne, Wlodzimierz Skiba
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/textctrl.h"
#include "wx/notebook.h"
#include "wx/listctrl.h"
-
-#include <string.h>
-
-#include "wx/palmos/window.h"
+#include "wx/window.h"
// ---------------------------------------------------------------------------
// global variables
wxMenu *wxCurrentPopupMenu = NULL;
#endif // wxUSE_MENUS_NATIVE
-#ifdef __WXWINCE__
-extern wxChar *wxCanvasClassName;
-#else
-extern const wxChar *wxCanvasClassName;
-#endif
-
// true if we had already created the std colour map, used by
// wxGetStdColourMap() and wxWindow::OnSysColourChanged() (FIXME-MT)
static bool gs_hasStdCmap = false;
// Palm message handlers
// ===========================================================================
-// ---------------------------------------------------------------------------
-// WM_NOTIFY
-// ---------------------------------------------------------------------------
-
-#ifdef __WIN95__
-
-bool wxWindowPalm::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
-{
- return false;
-}
-
-#if wxUSE_TOOLTIPS
-
-bool wxWindowPalm::HandleTooltipNotify(WXUINT code,
- WXLPARAM lParam,
- const wxString& ttip)
-{
- return false;
-}
-
-#endif // wxUSE_TOOLTIPS
-
-bool wxWindowPalm::PalmOnNotify(int WXUNUSED(idCtrl),
- WXLPARAM lParam,
- WXLPARAM* WXUNUSED(result))
-{
- return false;
-}
-
-#endif // __WIN95__
-
// ---------------------------------------------------------------------------
// end session messages
// ---------------------------------------------------------------------------