X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/324eeecb3cdc9522e136af6670443148772b412a..6bae67261c727ee5030abda0a5996e3f9fa6b6b2:/src/palmos/control.cpp diff --git a/src/palmos/control.cpp b/src/palmos/control.cpp index 5f60d345ca..ecd7a74c4a 100644 --- a/src/palmos/control.cpp +++ b/src/palmos/control.cpp @@ -46,6 +46,10 @@ #include "wx/radiobut.h" #include "wx/slider.h" +#include +#include +#include + // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- @@ -78,7 +82,7 @@ wxControl::~wxControl() DestroyChildren(); uint16_t index; - FormType* form = GetObjectFormIndex(index); + FormType* form = (FormType*)GetObjectFormIndex(index); if(form!=NULL && index!=frmInvalidObjectId) { FrmRemoveObject((FormType **)&form,index); @@ -107,13 +111,13 @@ bool wxControl::Create(wxWindow *parent, return true; } -bool wxControl::PalmCreateControl(ControlStyleType style, +bool wxControl::PalmCreateControl(int style, const wxString& label, const wxPoint& pos, const wxSize& size, uint8_t groupID) { - FormType* form = GetParentForm(); + FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; @@ -123,12 +127,19 @@ bool wxControl::PalmCreateControl(ControlStyleType style, w = size.x == wxDefaultCoord ? 1 : size.x, h = size.y == wxDefaultCoord ? 1 : size.y; - AdjustForParentClientOrigin(x, y); + wxWindow *win = this; + while(win->GetParent()) + { + win = win->GetParent(); + wxPoint pt(win->GetClientAreaOrigin()); + x += pt.x; + y += pt.y; + } ControlType *control = CtlNewControl( (void **)&form, GetId(), - style, + (ControlStyleType)style, wxEmptyString, x, y, @@ -155,9 +166,9 @@ bool wxControl::PalmCreateField(const wxString& label, const wxSize& size, bool editable, bool underlined, - JustificationType justification) + int justification) { - FormType* form = GetParentForm(); + FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; @@ -183,7 +194,7 @@ bool wxControl::PalmCreateField(const wxString& label, underlined, false, false, - justification, + (JustificationType)justification, false, false, false @@ -204,7 +215,7 @@ bool wxControl::PalmCreateField(const wxString& label, // various accessors // ---------------------------------------------------------------------------- -FormType* wxControl::GetParentForm() const +WXFORMPTR wxControl::GetParentForm() const { wxWindow* parentTLW = GetParent(); while ( parentTLW && !parentTLW->IsTopLevel() ) @@ -217,9 +228,9 @@ FormType* wxControl::GetParentForm() const return tlw->GetForm(); } -FormType* wxControl::GetObjectFormIndex(uint16_t& index) const +WXFORMPTR wxControl::GetObjectFormIndex(uint16_t& index) const { - FormType* form = GetParentForm(); + FormType* form = (FormType* )GetParentForm(); if(form!=NULL) index = FrmGetObjectIndex(form, GetId()); else @@ -230,7 +241,7 @@ FormType* wxControl::GetObjectFormIndex(uint16_t& index) const void* wxControl::GetObjectPtr() const { uint16_t index; - FormType* form = GetObjectFormIndex(index); + FormType* form = (FormType*)GetObjectFormIndex(index); if(form==NULL || index==frmInvalidObjectId)return NULL; return FrmGetObjectPtr(form,index); } @@ -245,7 +256,7 @@ wxBorder wxControl::GetDefaultBorder() const void wxControl::SetIntValue(int val) { - FormType* form = GetParentForm(); + FormType* form = (FormType*)GetParentForm(); if(form==NULL) return; uint16_t index = FrmGetObjectIndex(form, GetId()); @@ -261,7 +272,7 @@ void wxControl::SetBoolValue(bool val) bool wxControl::GetBoolValue() const { - FormType* form = GetParentForm(); + FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; uint16_t index = FrmGetObjectIndex(form, GetId()); @@ -275,42 +286,51 @@ wxSize wxControl::DoGetBestSize() const return wxSize(16, 16); } -void wxControl::DoGetBounds( RectangleType &rect ) const +void wxControl::DoGetBounds( WXRECTANGLEPTR rect ) const { - FormType* form = GetParentForm(); + 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,&rect); + FrmGetObjectBounds(form,index,(RectangleType*)rect); } -void wxControl::DoSetBounds( RectangleType &rect ) +void wxControl::DoSetBounds( WXRECTANGLEPTR rect ) { - FormType* form = GetParentForm(); + 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,&rect); + 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); + DoGetBounds(&rect); + if(x) - *x = rect.topLeft.x; + *x = rect.topLeft.x - ox; if(y) - *y = rect.topLeft.y; + *y = rect.topLeft.y - oy; } void wxControl::DoGetSize( int *width, int *height ) const { RectangleType rect; - DoGetBounds(rect); + DoGetBounds(&rect); + if(width) *width = rect.extent.x; if(height) @@ -325,14 +345,14 @@ void wxControl::DoMoveWindow(int x, int y, int width, int height) rect.topLeft.y = y; rect.extent.x = width; rect.extent.y = height; - DoSetBounds(rect); + DoSetBounds(&rect); GetParent()->Refresh(true, &area); } bool wxControl::Enable(bool enable) { ControlType *control = (ControlType *)GetObjectPtr(); - if( (IsPalmControl()) || (control == NULL)) + if( !IsPalmControl() || (control == NULL)) return false; if( CtlEnabled(control) == enable) return false; @@ -343,7 +363,7 @@ bool wxControl::Enable(bool enable) bool wxControl::IsEnabled() const { ControlType *control = (ControlType *)GetObjectPtr(); - if( (IsPalmControl()) || (control == NULL)) + if( !IsPalmControl() || (control == NULL)) return false; return CtlEnabled(control); } @@ -355,7 +375,7 @@ bool wxControl::IsShown() const bool wxControl::Show( bool show ) { - FormType* form = GetParentForm(); + FormType* form = (FormType*)GetParentForm(); if(form==NULL) return false; uint16_t index = FrmGetObjectIndex(form,GetId());