Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!apctrc!zjmw36 From: zjmw36@trc.amoco.com (Joe M. Wade) Newsgroups: comp.windows.x.motif Subject: Aligning side-by-side RowColumn widgets Keywords: RowColumn Message-ID: <2506@apctrc.UUCP> Date: 9 Jan 91 17:21:31 GMT Sender: news@trc.amoco.com Reply-To: zjmw36@trc.amoco.com (Joe M. Wade) Distribution: na Organization: Amoco Production Company Lines: 183 Originator: zjmw36@gpss36 O.K., I admit defeat. I have been trying for much too long to get fields in two side-by-side rowcolumn widgets inside a form dialog to line up. What I'm trying to do is this: label1 text label2 text label3 text label4 text label5 toggle etc.. The problem arises from the fact that the text widgets are larger than the label widgets. Using ATTACH_OPPOSITE_WIDGET on rowcol1 and rowcol2 didn't work appropriately, so I tried a new tack by computing the y offset of each label in rowcol1 based on the size of its corresponding entry in rowcol2. This works when packing is set to PACK_NONE, but I would like my labels to be on the right hand side of rowcol1. Using XmPACK_TIGHT breaks my horizontal layout even though the documentation I have says, "Each entry's position in the major dimension is left unaltered (for example, XmNy is left unchanged when XmNorientation is XmVertical); its position in the minor dimension is set to the same value as the greatest entry in that particular row or column. Am I missing something obvious? Below is a test program which I've been using to work on this problem. Is this just a bug in RowColumn or am I breaking (misinterpreting?) the rules ? Any help is more than appreciated. I may be willing to give up any future first-born male children...... Try changing the packing between XmPACK_TIGHT and XmPACK_NONE and you'll see my dilemma. ******** Warning: buggy code follows..... ************************** #include #include #include #include #include #include #include #include char *labels[] = { "labelA","labelB","labelC","labelD", "labelE - with this extra garbage" }; char *text[] = { "entryA","entryB","entryC","entryD" }; void popup(widget,client_data,call_data) Widget widget; caddr_t client_data; caddr_t call_data; { XtManageChild((Widget)client_data); } void popdown(widget,client_data,call_data) Widget widget; caddr_t client_data; caddr_t call_data; { XtUnmanageChild((Widget)client_data); } void killit(widget,client_data,call_data) Widget widget; caddr_t client_data; caddr_t call_data; { exit(0); } main (argc,argv) int argc; char *argv[]; { Arg args[5]; Widget root,trigger,dismiss,quit; Widget form,rowcol1,rowcol2,label_widget[5],text_widget[4],toggle; int i,nargs,spacing,height[5],y_offset; XmString item_label; root = XtInitialize(NULL, "TEst", NULL, 0, &argc, argv); trigger = XmCreatePushButton(root,"trigger",NULL,0); XtManageChild(trigger); nargs = 0; XtSetArg(args[nargs],XmNmappedWhenManaged,FALSE); nargs++; form = XmCreateFormDialog(root,"form",args,nargs); XtAddCallback(trigger, XmNactivateCallback, popup, (caddr_t) form); nargs = 0; /* According to documentation, this should work with PACK_TIGHT */ XtSetArg(args[nargs],XmNpacking,XmPACK_TIGHT); nargs++; /* Vertical spacing is correct with PACK_TIGHT; labels get hosed horizontally XtSetArg(args[nargs],XmNpacking,XmPACK_NONE); nargs++; */ XtSetArg(args[nargs],XmNorientation,XmVERTICAL); nargs++; XtSetArg(args[nargs],XmNentryAlignment,XmALIGNMENT_END); nargs++; XtSetArg(args[nargs],XmNisAligned,TRUE); nargs++; rowcol1 = XmCreateRowColumn(form,"rowcol1",args,nargs); nargs = 0; XtSetArg(args[nargs],XmNleftAttachment,XmATTACH_WIDGET); nargs++; XtSetArg(args[nargs],XmNleftWidget,rowcol1); nargs++; rowcol2 = XmCreateRowColumn(form,"rowcol1",args,nargs); for (i=0; i<4; i++) { nargs = 0; XtSetArg(args[nargs],XmNvalue,text[i]); nargs++; text_widget[i] = XmCreateText(rowcol2,text[i],args,nargs); XtManageChild(text_widget[i]); } nargs = 0; item_label = XmStringCreateLtoR("Yes",XmSTRING_DEFAULT_CHARSET); XtSetArg(args[nargs],XmNlabelString,item_label); nargs++; XtSetArg(args[nargs],XmNset,TRUE); nargs++; toggle = XmCreateToggleButton(rowcol2,"toggle",args,nargs); XtManageChild(toggle); XtManageChild(rowcol2); nargs = 0; XtSetArg(args[nargs],XmNmappedWhenManaged,TRUE); nargs++; XtSetValues(form,args,nargs); nargs = 0; XtSetArg(args[nargs],XmNspacing,&spacing); nargs++; XtGetValues(rowcol2,args,nargs); y_offset = spacing; for (i=0; i<4; i++) { nargs = 0; XtSetArg(args[nargs],XmNheight,&height[i]); nargs++; XtGetValues(text_widget[i],args,nargs); } nargs = 0; XtSetArg(args[nargs],XmNheight,&height[i]); nargs++; XtGetValues(toggle,args,nargs); for (i=0; i<5; i++) { nargs = 0; item_label = XmStringCreateLtoR(labels[i],XmSTRING_DEFAULT_CHARSET); XtSetArg(args[nargs],XmNlabelString,item_label); nargs++; XtSetArg(args[nargs],XmNy,y_offset); nargs++; XtSetArg(args[nargs],XmNheight,height[i]); nargs++; XtSetArg(args[nargs],XmNborderWidth,1); nargs++; label_widget[i] = XmCreateLabel(rowcol1,labels[i],args,nargs); XtManageChild(label_widget[i]); y_offset = y_offset + spacing + height[i]; } XtManageChild(rowcol1); nargs = 0; XtSetArg(args[nargs],XmNtopAttachment,XmATTACH_WIDGET); nargs++; XtSetArg(args[nargs],XmNtopWidget,rowcol2); nargs++; dismiss = XmCreatePushButton(form,"dismiss",args,nargs); XtAddCallback(dismiss, XmNactivateCallback, popdown, (caddr_t) form); XtManageChild(dismiss); nargs = 0; XtSetArg(args[nargs],XmNtopAttachment,XmATTACH_WIDGET); nargs++; XtSetArg(args[nargs],XmNtopWidget,rowcol2); nargs++; XtSetArg(args[nargs],XmNleftAttachment,XmATTACH_WIDGET); nargs++; XtSetArg(args[nargs],XmNleftWidget,dismiss); nargs++; quit = XmCreatePushButton(form,"quit",args,nargs); XtAddCallback(quit, XmNactivateCallback, killit, NULL); XtManageChild(quit); XtRealizeWidget(root); XtMainLoop(); } -- * * * * * * * * * * * * * * * * * * * * * * * Joe M. Wade (jwade@trc.amoco.com) (918) 660-4387 * * Amoco Research Center * 4502 E. 41st St. * Tulsa, OK 74102 * * * * * * * * * * * * * * * * * * * * * * *