]> git.saurik.com Git - wxWidgets.git/blobdiff - src/palmos/control.cpp
Applied patch [ 1120683 ] Fix for wxDateTime::Format() under Windows CE
[wxWidgets.git] / src / palmos / control.cpp
index 88fd6fac820c5682ec30647b14fc3f7827d4f53d..5dd719b4c3666e67afc93993f611c1973f69cc60 100644 (file)
@@ -74,6 +74,15 @@ wxControl::~wxControl()
 {
     SetLabel(wxEmptyString);
     m_isBeingDeleted = true;
+
+    DestroyChildren();
+
+    uint16_t index;
+    FormType* form = GetObjectFormIndex(index);
+    if(form!=NULL && index!=frmInvalidObjectId)
+    {
+        FrmRemoveObject((FormType **)&form,index);
+    }
 }
 
 // ----------------------------------------------------------------------------
@@ -102,24 +111,32 @@ 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;
 
+
+    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);
+
     ControlType *control = CtlNewControl(
                                (void **)&form,
                                GetId(),
                                style,
                                wxEmptyString,
-                               ( 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,
                                groupID,
-                               false
+                               true
                            );
 
     if(control==NULL)
@@ -127,6 +144,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
 
     m_palmControl = true;
 
+    SetInitialBestSize(size);
     SetLabel(label);
     Show();
     return true;
@@ -145,13 +163,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 +194,9 @@ bool wxControl::PalmCreateField(const wxString& label,
 
     m_palmField = true;
 
-    Show();
+    SetInitialBestSize(size);
     SetLabel(label);
+    Show();
     return true;
 }
 
@@ -191,19 +217,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);
 }