// Vertical Field Class struct VerticalField {} // constructor & destructor for VerticalField VerticalField createVerticalField_ () { DxlObject dx = new; VerticalField x = (addr_ dx) VerticalField; return x} DxlObject DxlObjectOf (VerticalField x) { return ((addr_ x) DxlObject) } void deleteVerticalField (VerticalField &x) { DxlObject dx = DxlObjectOf x; delete dx; x = null; } // Parent Property DB getParent (VerticalField x ) { return ((DxlObjectOf x)->"Parent") DB} void setParent_ (VerticalField x, DB val) { (DxlObjectOf x)->"Parent" = val } // LabelHandle Property DBE getLabelHandle (VerticalField x ) { return ((DxlObjectOf x)->"LabelHandle") DBE} void setLabelHandle_ (VerticalField x, DBE val) { (DxlObjectOf x)->"LabelHandle" = val } // FieldHandle Property DBE getFieldHandle (VerticalField x ) { return ((DxlObjectOf x)->"FieldHandle") DBE} void setFieldHandle_ (VerticalField x, DBE val) { (DxlObjectOf x)->"FieldHandle" = val } // Label Property string getLabel (VerticalField x ) { return ((DxlObjectOf x)->"Label") string} void setLabel (VerticalField x, string val) { (DxlObjectOf x)->"Label" = val } // ... add more properties as you like ... VerticalField createVerticalField (DB in_db, string in_Label, in_Initial, int in_Width, bool in_ReadOnly) { // Build a 'field' DBE such that the label is above the field rather than to the left. VerticalField result = createVerticalField_() DBE dbeField, dbeLabel // create the dialog elements do not glue them yet stuff dbeLabel = label(in_db, in_Label) dbeField = field(in_db, "", in_Initial, in_Width, in_ReadOnly) // set the field properties setLabel (result, in_Label) setFieldHandle_ (result, dbeField) setLabelHandle_ (result, dbeLabel) return result } // ************************** Vertical Field Glue Code *********************************** // this can probably be simplified and a stuff probably can be put to a library struct vfglueOn1__ {} struct vfglueOn2__ {} // some globals to store the glue parameters VerticalField gFieldToBeGlued = null string gsFieldGluePosition = null string gsFieldGlueConnection = null // we rebuild the glue lane with other types to not interfere with normal glue functions // // dbe -> "position" -> "connection" -> dbe VericalField -> "position" -> "connection" -> dbe // \--------|---------/ \------------|-----------/ // V V // glueOn1__ -> string ---now becomes---> vfglueOn1__ -> string // \---------|----------/ \-----------|-----------/ // V V // glueOn__2 -> dbe vfglueOn__2 -> dbe vfglueOn1__ ::-> (VerticalField this, string s) { print "Glue 1\n" gFieldToBeGlued = this gsFieldGluePosition = s gsFieldGlueConnection = null glueOn1__ result = (getLabelHandle this)->s return ((addr_ result) vfglueOn1__) } vfglueOn2__ ::-> (vfglueOn1__ x, string sConnection) { print "Glue 2\n" if (sConnection == "form") { glueOn1__ g = addr_ x print "Glueing field " (getLabel gFieldToBeGlued) "'s " gsFieldGluePosition " to form.\n" g -> sConnection // glue the label // glue the field if (lower gsFieldGluePosition == "top") (getFieldHandle gFieldToBeGlued)->"top"->"flush"->(getLabelHandle gFieldToBeGlued) if (lower gsFieldGluePosition == "left") (getFieldHandle gFieldToBeGlued)->"left"->"form" return } // store the glue connection gsFieldGlueConnection = sConnection glueOn1__ g = addr_ x glueOn2__ result = g->sConnection return ((addr_ result) vfglueOn2__) } // this one is executed last and makes the positioning ... void ::-> (vfglueOn2__ x, DBE y) { print "Glue 3b\n" glueOn2__ g = addr_ x g->y // glue the label print "Gluing " (getLabel gFieldToBeGlued) " " gsFieldGluePosition "\n" // now glue the field below the label if (lower gsFieldGluePosition == "top") (getFieldHandle gFieldToBeGlued)->"top"->"flush"->(getLabelHandle gFieldToBeGlued) if (lower gsFieldGluePosition == "left") (getFieldHandle gFieldToBeGlued)->"left"->gsFieldGlueConnection ->y } void ::-> (vfglueOn2__ x, VerticalField y) { print "Glue 3a\n" x->(getFieldHandle y) } // now we need to take care about other stuff we want to glue to our vertical field void ::-> (glueOn2__ x, VerticalField y) { x->(getFieldHandle y) // always glue that to the field } // ************** Test Dialog ************************ DB db = centered "Test" VerticalField dbe1 = createVerticalField(db, "Field1", "Field1Init", 20, true) // Adjacent is ignored for this first DBE dbe1 -> "top" -> "form" dbe1 -> "left" -> "form" VerticalField dbe2 = createVerticalField(db, "Field2", "Field2 Init", 30, false) dbe2 -> "top" -> "form" dbe2 -> "left" -> "spaced" -> dbe1 VerticalField dbe3 = createVerticalField(db, "Field3", "ddd", 40, false) dbe3 -> "top"->"spaced" -> dbe2 dbe3 -> "left" -> "spaced" -> dbe1 void myButtonCallback (DBE x) { ack "GLUED!" } DBE myButton = button (db, "Glue me to teh field!", myButtonCallback) myButton -> "top" -> "spaced" -> dbe3 myButton -> "left" -> "spaced" -> dbe1 // realize(db, 100, 700) show(db) // realize(db, 100, 700)