Top Document: Motif FAQ (Part 4 of 9) Previous Document: 68) Why does mwm 1.2 crash on startup? Next Document: 70) How can I create a shell widget with a non-default visual type? See reader questions & answers on this topic! - Help others by sharing your knowledge Answer: In the code below, use getsize() for widgets which have been managed, and getsize2() for newly created shell widgets which have not yet been managed. getsize2() takes two widget parameters because popup dialogs etc. _consist_ of two separate widgets - the parent shell and the child bulletin board, form, whatever. This important distinction (somewhat glossed over in the Motif manuals) is the cause of a large number of queries in comp.windows.x.motif. XmCreate...Dialog() functions return the (bulletin board, form, whatever) _child_ of the pair, not the parent shell. getsize2() takes the _shell_ widget as it's first parameter, and the shell's _child_ (the bulletin board, form, whatever) as it's second. Thus, if you are using code like widget = XmCreate...Dialog() to create your popup dialogs, use code like getsize2(XtParent(widget),widget,&width,&height) to get the width and height. If you use e.g. XmCreateDialogShell() or XtCreatePopupShell(), then you are creating the the shell widget and it's child explicitly, and can just pass them into getsize2() with no problem. Note: getsize2() calls getsize(). /* getsize(widget,width,height); * Widget widget; * int *width,*height; * * returns the width and height of a managed widget */ void getsize(l,w,h) Widget l; int *w,*h; { Dimension w_,h_,b_; static Arg size_args[] = { { XmNwidth,0 }, { XmNheight,0 }, { XmNborderWidth,0 }, }; size_args[0].value = (XtArgVal)&w_; size_args[1].value = (XtArgVal)&h_; size_args[2].value = (XtArgVal)&b_; XtGetValues(l,size_args,3); if (w) *w = w_ + b_; if (h) *h = h_ + b_; } /* getsize2(shell,child,width,height); * Widget shell,child; * int *width,*height; * * returns the width, height of an unmanaged shell widget */ void getsize2(p,c,w,h) Widget p,c; int *w,*h; { XtSetMappedWhenManaged(p,0); XtManageChild(c); getsize(p,w,h); XtUnmanageChild(c); XtSetMappedWhenManaged(p,-1); } submitted by: [ Huw Rogers Communications Software Engineer, NEC Corporation, Tokyo, Japan ] [ Email: rogersh@ccs.mt.nec.co.jp Fax: +81-3-5476-1005 Tel: +81-3-5476-1096 ] User Contributions:Top Document: Motif FAQ (Part 4 of 9) Previous Document: 68) Why does mwm 1.2 crash on startup? Next Document: 70) How can I create a shell widget with a non-default visual type? Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: kenton@rahul.net (Ken Lee)
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: