cso@rose.cis.ohio-state.edu (Dr. Conleth S. O'Connell Jr.) (10/03/90)
Hi there. I am basically trying to display an organizational-chart type of tree with label widgets containing strings connected by lines that show their dependencies. I have the line drawing stuff working just fine. I have 2 problems with the following scenario: The label widgets are placed in a form widget inside of a viewport widget inside of a toplevelShell widget. After the descriptions, I'll include the declarations of the resources for these widgets. When I first create/place a label widget, everything works okay, i.e., the scrollbars are correct. However, I am pretty printing the tree, e.g., root | ----------------------------- | | | child1 child2 child3 | ----------- | | child2.1 child2.2 Pretty printing takes place as such for child2.1 for example: I want to place myself relative to the rightmost widget that I've seen so far (in a postfix traversal), in this case - child1. I get the x and width values of child1 I get the x value of child2.1 if I need to change the x value of child2.1, I make it 10 pixels + the x and width values of child1. I move the child2.1 widget with XtMoveWidget. What I want to do is just reset the fromHoriz resource, but nothing happens when I do this. Any ideas? ANyway, because I am using XtMoveWidget one of two (or both) problems occur: 1) The scrollbars no longer display the correct percentage nor allow the user to get to the far right items, but they do before the pretty printing occurs. 2) The form widget is not resizing correctly because the resources of the children are not quite right, i.e., the fromHoriz resource. I've tried lots of combinations but nothing seems to quite work. Here are the resource declarations for everything but the label widgets: cnt = 0; Treeshell = XtAppCreateShell("Navigation_Tree", "tree", topLevelShellWidgetClass, XtDisplay(Toplevel), args, cnt); cnt = 0; XtSetArg(args[cnt], XtNallowHoriz, True); cnt++; XtSetArg(args[cnt], XtNallowVert, True); cnt++; XtSetArg(args[cnt], XtNforceBars, True); cnt++; XtSetArg(args[cnt], XtNwidth, 500); cnt++; XtSetArg(args[cnt], XtNheight, 250); cnt++; treeview = XtCreateManagedWidget("treeview", viewportWidgetClass, Treeshell, args, cnt); cnt = 0; XtSetArg(args[cnt], XtNdefaultDistance, 10); cnt++; treeframe = XtCreateManagedWidget("treeframe", formWidgetClass, treeview, args, cnt); Thanks for any explanation! Con -- Dr. Conleth S. O'Connell Jr. Department of Computer and Information Science The Ohio State University cso@cis.ohio-state.edu 2036 Neil Ave., Columbus, OH USA 43210-1277
converse@EXPO.LCS.MIT.EDU (10/04/90)
[ Within an Athena Form widget ] > What I want to do is just reset the fromHoriz resource, but nothing > happens when I do this. Any ideas? It is probably some bug. Try to unmanage the child(ren), reset the resource, and manage the child(ren) again. > ANyway, because I am using XtMoveWidget one of two (or both) problems > occur: When you use XtMoveWidget you are changing the arrangment of widgets without going through the Form widget, which manages the arrangement of widgets. You are circumventing the Form widget, so you can't expect it to respond correctly. > Thanks for any explanation! I have very little time to look at these problems. If anyone else on the net would care to take up the slack, it would be appreciated. Donna Converse "The only thing worse than voice mail is the Form widget." - anonymous Consortium advisory committee member
rlh2@ukc.ac.uk (Richard Hesketh) (10/04/90)
In article <84330@tut.cis.ohio-state.edu> Dr. Conleth S. O'Connell Jr. <cso@rose.cis.ohio-state.edu> writes: >Hi there. Hello. >The label widgets are placed in a form widget inside of a viewport >widget inside of a toplevelShell widget. After the descriptions, I'll >include the declarations of the resources for these widgets. >When I first create/place a label widget, everything works okay, i.e., the >scrollbars are correct. However, I am pretty printing the tree, e.g., > > root > | > ----------------------------- > | | | >child1 child2 child3 > | > ----------- > | | > child2.1 child2.2 > >Pretty printing takes place as such for child2.1 for example: >I want to place myself relative to the rightmost widget that I've seen >so far (in a postfix traversal), in this case - child1. > >I get the x and width values of child1 >I get the x value of child2.1 > >if I need to change the x value of child2.1, I make it 10 pixels + the >x and width values of child1. > >I move the child2.1 widget with XtMoveWidget. >What I want to do is just reset the fromHoriz resource, but nothing >happens when I do this. Any ideas? By using the XtMoveWidget() you are completely overriding any child layout performed by the Form widget. The from{Horiz|Vert} resources are widget id.s (not positions) and are used in conjunction with the other constraint resources to tell the form how to layout the individual child. The children should never be moved using the XtMoveWidget() directly in an application. XtMoveWidget() should only be used by a widget class itself to move its own children around. [ Ref: Athena Widget Set - C Language Interface Manual by Chris Peterson; Section 6.0.1: "Under no circumstances should an application programmer resort to XtMoveWidget() or XtResizeWidget(); these functions are excusively for the use of Composite widget implemetors." ] >ANyway, because I am using XtMoveWidget one of two (or both) problems >occur: Again, this is all because you are breaking the whole geometry management procedure implemented by the toolkit. All application geometry changes should be made through the SetValues interface which will then perform the necessary changes and inform the various parents involved. >Thanks for any explanation! I would suggest two possible solutions: 1) Use the constraint resources of the Form to position children relative to siblings. Such as: XtVaSetValues(child1, XtNfromVert, root, XtNfromHoriz, NULL, XtNvertDistance, Y_SEP_DIST, NULL); XtVaSetValues(child2, XtNfromVert, root, XtNfromHoriz, child1, XtNvertDistance, Y_SEP_DIST, XtNhorizDistance, X_SEP_DIST, NULL); followed by: XtUnmanageChild(child1); XtManageChild(child1); [ see notes below ] 2) Write your own constraint widget class that lays out its given children in a tree. Probably a good place to start for this is the Tree Widget in Doug Young's book "X Window Systems Programming and Applications with Xt" (there's also a Motif version) published by Prentice-Hall. You could implement the algorithm recently published in July's edition of IEEE Software: "Drawing Dynamic Trees" by Sven Moen. Then you could also give it away 8-}. --- A couple of common things to note: 1) The Form widget has a bug in it such that changes to constraint resources on children do not cause the parent to re-layout them immediately. This re-layout can be forced by unmanaging and them re-managing the changed child. 2) The Viewport widget will not let the child (in this case a Form) scroll itself. Thus changes in the x and y positions of the child are refused. --- Richard Hesketh : @nsfnet-relay.ac.uk:rlh2@ukc.ac.uk : rlh2@ukc.ac.uk ..!{mcsun|mcvax}!ukc!rlh2 Computing Officer, Computing Lab., University of Kent at Canterbury, Canterbury, Kent, CT2 7NF, United Kingdom. Tel: +44 227 764000 ext 7620/7590 Fax: +44 227 762811
rlh2@ukc.ac.uk (Richard Hesketh) (10/04/90)
In article <5601@harrier.ukc.ac.uk> I write: >1) The Form widget has a bug in it such that changes to constraint resources > on children do not cause the parent to re-layout them immediately. This > re-layout can be forced by unmanaging and them re-managing the changed > child. What I should have said really is that this is a *feature* of the Form and that an (in)convenience routine is available to force or defer a re-layout of the form; namely XawFormDoLayout(). IMHO this ought to be a *public* Boolean resource that can be toggled. Richard
cso@rose.cis.ohio-state.edu (Conleth S. O'Connell Jr.) (10/05/90)
In article <9010031853.AA28767@excess.lcs.mit.edu> converse@EXPO.LCS.MIT.EDU writes: >> What I want to do is just reset the fromHoriz resource, but nothing >> happens when I do this. Any ideas? >It is probably some bug. Try to unmanage the child(ren), reset the >resource, and manage the child(ren) again. This worked! I love it when a solution is this simple! >> [ I was using XtMoveWidget to force changes] >When you use XtMoveWidget you are changing the arrangment of widgets >without going through the Form widget, which manages the arrangement >of widgets. You are circumventing the Form widget, so you can't >expect it to respond correctly. This explained all of the problems actually, and now the problems no longer exist. >I have very little time to look at these problems. If anyone else >on the net would care to take up the slack, it would be appreciated. Thank you for your quick and insightful response despite your other distractions! >Donna Converse Thanks again, Con -- Dr. Conleth S. O'Connell Jr. Department of Computer and Information Science The Ohio State University cso@cis.ohio-state.edu 2036 Neil Ave., Columbus, OH USA 43210-1277