Get/SetValue() and other improvements to the native PalmOS controls.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31604 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-01-27 11:01:06 +00:00
parent a8e9860d9f
commit ba88951339
11 changed files with 112 additions and 97 deletions

View File

@@ -75,9 +75,17 @@ public:
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;
@@ -108,6 +116,15 @@ protected:
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()
};

View File

@@ -252,11 +252,6 @@ public:
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);
@@ -431,10 +426,6 @@ private:
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;

View File

@@ -85,7 +85,9 @@
// 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;
@@ -2693,7 +2695,7 @@ wxAccStatus wxWindowAccessible::GetName(int childId, wxString* name)
#endif
title = GetWindow()->GetName();
if (!title.IsEmpty())
if (!title.empty())
{
*name = title;
return wxACC_OK;
@@ -2799,7 +2801,7 @@ wxAccStatus wxWindowAccessible::GetDescription(int WXUNUSED(childId), wxString*
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
if (!ht.IsEmpty())
if (!ht.empty())
{
*description = ht;
return wxACC_OK;
@@ -2815,7 +2817,7 @@ wxAccStatus wxWindowAccessible::GetHelpText(int WXUNUSED(childId), wxString* hel
return wxACC_FAIL;
wxString ht(GetWindow()->GetHelpText());
if (!ht.IsEmpty())
if (!ht.empty())
{
*helpText = ht;
return wxACC_OK;

View File

@@ -151,6 +151,10 @@ wxSize wxButtonBase::GetDefaultSize()
void wxButton::SetDefault()
{
FormType* form = GetParentForm();
if(form==NULL)
return;
FrmSetDefaultButtonID(form,GetId());
}
void wxButton::SetTmpDefault()

View File

@@ -117,11 +117,12 @@ wxSize wxCheckBox::DoGetBestSize() const
void wxCheckBox::SetValue(bool val)
{
SetBoolValue(val);
}
bool wxCheckBox::GetValue() const
{
return false;
return GetBoolValue();
}
void wxCheckBox::Command(wxCommandEvent& event)

View File

@@ -96,27 +96,23 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
const wxPoint& pos,
const wxSize& size)
{
wxWindow* parentTLW = parent;
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;
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
@@ -133,6 +129,19 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
// 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,
@@ -141,6 +150,33 @@ wxBorder wxControl::GetDefaultBorder() const
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);
@@ -170,10 +206,16 @@ bool wxControl::IsShown() const
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;
}
@@ -184,7 +226,10 @@ void wxControl::SetLabel(const wxString& label)
( 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);
}
}
@@ -195,7 +240,7 @@ wxString wxControl::GetLabel()
wxDynamicCast(this,wxCheckBox) ||
wxDynamicCast(this,wxToggleButton) )
{
return CtlGetLabel(m_control);
return m_label;
}
return wxEmptyString;

View File

@@ -109,21 +109,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
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,
@@ -138,9 +132,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
value
);
m_control = (ControlType*) slider;
if(m_control==NULL)
if(slider==NULL)
return false;
Show();
@@ -181,6 +173,7 @@ int wxSlider::GetValue() const
void wxSlider::SetValue(int value)
{
SetIntValue(value);
}
void wxSlider::DoGetSize(int *width, int *height) const

View File

@@ -63,11 +63,10 @@ bool wxStatusBarPalm::Create(wxWindow *parent,
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);

View File

@@ -76,11 +76,12 @@ wxSize wxToggleButton::DoGetBestSize() const
void wxToggleButton::SetValue(bool val)
{
SetBoolValue(val);
}
bool wxToggleButton::GetValue() const
{
return false;
return GetBoolValue();
}
void wxToggleButton::Command(wxCommandEvent & event)

View File

@@ -98,12 +98,14 @@ bool wxTopLevelWindowPalm::Create(wxWindow *parent,
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;
@@ -112,7 +114,7 @@ bool wxTopLevelWindowPalm::Create(wxWindow *parent,
constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y;
FrameForm = FrmNewFormWithConstraints(
m_windowId,
GetId(),
title.c_str(),
winFlagBackBuffer,
&constraints,

View File

@@ -2,10 +2,10 @@
// 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
/////////////////////////////////////////////////////////////////////////////
@@ -83,10 +83,7 @@
#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
@@ -96,12 +93,6 @@
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;
@@ -706,37 +697,6 @@ bool wxWindowPalm::PalmCreate(const wxChar *wclass,
// 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
// ---------------------------------------------------------------------------