+void wxControl::DoGetBounds( WXRECTANGLEPTR rect ) const
+{
+ if(rect==NULL)
+ return;
+ FormType* form = (FormType*)GetParentForm();
+ if(form==NULL)
+ return;
+ uint16_t index = FrmGetObjectIndex(form,GetId());
+ if(index==frmInvalidObjectId)
+ return;
+ FrmGetObjectBounds(form,index,(RectangleType*)rect);
+}
+
+void wxControl::DoSetBounds( WXRECTANGLEPTR rect )
+{
+ if(rect==NULL)
+ return;
+ FormType* form = (FormType*)GetParentForm();
+ if(form==NULL)
+ return;
+ uint16_t index = FrmGetObjectIndex(form,GetId());
+ if(index==frmInvalidObjectId)
+ return;
+ FrmSetObjectBounds(form,index,(RectangleType*)rect);
+}
+
+void wxControl::DoGetPosition( int *x, int *y ) const
+{
+ int ox = 0, oy = 0;
+ AdjustForParentClientOrigin(ox, oy);
+
+ RectangleType rect;
+ DoGetBounds(&rect);
+
+ if(x)
+ *x = rect.topLeft.x - ox;
+ if(y)
+ *y = rect.topLeft.y - oy;
+}
+
+void wxControl::DoGetSize( int *width, int *height ) const
+{
+ RectangleType rect;
+ DoGetBounds(&rect);
+
+ if(width)
+ *width = rect.extent.x;
+ if(height)
+ *height = rect.extent.y;
+}
+
+void wxControl::DoMoveWindow(int x, int y, int width, int height)
+{
+ wxRect area = GetRect();
+ RectangleType rect;
+ rect.topLeft.x = x;
+ rect.topLeft.y = y;
+ rect.extent.x = width;
+ rect.extent.y = height;
+ DoSetBounds(&rect);
+ GetParent()->Refresh(true, &area);
+}
+
+bool wxControl::Enable(bool enable)
+{
+ ControlType *control = (ControlType *)GetObjectPtr();
+ if( !IsPalmControl() || (control == NULL))
+ return false;
+ if( CtlEnabled(control) == enable)
+ return false;
+ CtlSetEnabled( control, enable);
+ return true;
+}
+
+bool wxControl::IsEnabled() const
+{
+ ControlType *control = (ControlType *)GetObjectPtr();
+ if( !IsPalmControl() || (control == NULL))
+ return false;
+ return CtlEnabled(control);
+}
+
+bool wxControl::IsShown() const
+{
+ return StatGetAttribute ( statAttrBarVisible , NULL );
+}
+
+bool wxControl::Show( bool show )
+{
+ FormType* form = (FormType*)GetParentForm();
+ if(form==NULL)
+ return false;
+ uint16_t index = FrmGetObjectIndex(form,GetId());
+ if(index==frmInvalidObjectId)
+ return false;
+ if(show)
+ FrmShowObject(form,index);
+ else
+ FrmHideObject(form,index);
+ 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)
+{
+ 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)
+{
+ 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()
+{
+ if(IsPalmField())
+ return GetFieldLabel();
+
+ // unlike other native controls, slider has no label
+ if(IsPalmControl() && !wxDynamicCast(this,wxSlider))
+ return GetControlLabel();
+
+ return wxEmptyString;
+}
+