X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a152561c76dbed50d23f28d6e5761b4ece968156..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/palmos/control.cpp diff --git a/src/palmos/control.cpp b/src/palmos/control.cpp index 54b61fd862..3b9b881995 100644 --- a/src/palmos/control.cpp +++ b/src/palmos/control.cpp @@ -72,7 +72,17 @@ void wxControl::Init() wxControl::~wxControl() { + SetLabel(wxEmptyString); m_isBeingDeleted = true; + + DestroyChildren(); + + uint16_t index; + FormType* form = GetObjectFormIndex(index); + if(form!=NULL && index!=frmInvalidObjectId) + { + FrmRemoveObject((FormType **)&form,index); + } } // ---------------------------------------------------------------------------- @@ -101,26 +111,39 @@ bool wxControl::PalmCreateControl(ControlStyleType style, const wxString& label, const wxPoint& pos, const wxSize& size, - int groupID) + uint8_t groupID) { FormType* form = GetParentForm(); if(form==NULL) return false; - m_label = label; + + wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x, + y = pos.y == wxDefaultCoord ? 0 : pos.y, + w = size.x == wxDefaultCoord ? 1 : size.x, + h = size.y == wxDefaultCoord ? 1 : size.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, - 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, + wxEmptyString, + x, + y, + w, + h, stdFont, groupID, - false + true ); if(control==NULL) @@ -128,6 +151,8 @@ bool wxControl::PalmCreateControl(ControlStyleType style, m_palmControl = true; + SetInitialBestSize(size); + SetLabel(label); Show(); return true; } @@ -145,13 +170,20 @@ bool wxControl::PalmCreateField(const wxString& label, m_label = label; + wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x, + y = pos.y == wxDefaultCoord ? 0 : pos.y, + w = size.x == wxDefaultCoord ? 1 : size.x, + h = size.y == wxDefaultCoord ? 1 : size.y; + + AdjustForParentClientOrigin(x, y); + 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, + x, + y, + w, + h, stdFont, 10, editable, @@ -169,8 +201,9 @@ bool wxControl::PalmCreateField(const wxString& label, m_palmField = true; - Show(); + SetInitialBestSize(size); SetLabel(label); + Show(); return true; } @@ -191,19 +224,21 @@ FormType* wxControl::GetParentForm() const return tlw->GetForm(); } -uint16_t wxControl::GetObjectIndex() const +FormType* wxControl::GetObjectFormIndex(uint16_t& index) const { FormType* form = GetParentForm(); - if(form==NULL)return frmInvalidObjectId; - return FrmGetObjectIndex(form, GetId()); + if(form!=NULL) + index = FrmGetObjectIndex(form, GetId()); + else + index = frmInvalidObjectId; + return form; } void* wxControl::GetObjectPtr() const { - FormType* form = GetParentForm(); - if(form==NULL)return NULL; - uint16_t index = FrmGetObjectIndex(form, GetId()); - if(index==frmInvalidObjectId)return NULL; + uint16_t index; + FormType* form = GetObjectFormIndex(index); + if(form==NULL || index==frmInvalidObjectId)return NULL; return FrmGetObjectPtr(form,index); } @@ -258,30 +293,58 @@ void wxControl::DoGetBounds( RectangleType &rect ) const FrmGetObjectBounds(form,index,&rect); } +void wxControl::DoSetBounds( RectangleType &rect ) +{ + FormType* form = GetParentForm(); + if(form==NULL) + return; + uint16_t index = FrmGetObjectIndex(form,GetId()); + if(index==frmInvalidObjectId) + return; + FrmSetObjectBounds(form,index,&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; + *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); + 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)) + if( !IsPalmControl() || (control == NULL)) return false; if( CtlEnabled(control) == enable) return false; @@ -292,7 +355,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); } @@ -350,6 +413,13 @@ void wxControl::SetFieldLabel(const wxString& label) 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) @@ -433,17 +503,4 @@ void wxControl::OnEraseBackground(wxEraseEvent& event) { } -WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor), - WXUINT WXUNUSED(message), - WXWPARAM WXUNUSED(wParam), - WXLPARAM WXUNUSED(lParam) - ) -{ - return (WXHBRUSH)0; -} - -// --------------------------------------------------------------------------- -// global functions -// --------------------------------------------------------------------------- - #endif // wxUSE_CONTROLS