motifdeveloper.com
Sponsored by IST Limited
Formerly MW3: Motif on the World Wide Web [MW3 Logo]
Last Updated
November 18, 2002
 


X-Designer - The Leading X/Motif GUI Builder - Click to download a FREE evaluation
 

motifdeveloper.com
Home
About the site
Bulletin Board
News Archive
OpenGroup News
Events
Search
Frequently Asked Questions
The Motif FAQ
X/Motif FAQs
General FAQs
Ask Antony
Latest Q & A
All Q & As
Submit Question
Tips & Pointers
Code Examples
Software
OpenMotif
Widget Sets
GUI Toolkits & Libraries
Motif suppliers
Non-commercial S/W
Commercial Software
Multimedia
Miscellaneous
Organizations
Docs & Pubs
X/Motif Newsgroups
Security
Internationalization
Feedback
Feedback Form
Contributors
 

Why does a MainWindow display the command area poorly in some Motif 2.1 environments?

9-Apr-02 15:35 GMT

Question: A MainWindow with automatic scrolling, using XmMainWindowSetAreas() to set the locations of command area, menu bar and message area, has the command area located correctly, but its contents are blank on Solaris and Linux. Why is this ?

The Cause

In common with various other Scrolled components in Motif, the MainWindow had something of a work over at the Motif 2.0 stage. The widget was internally reworked so that the roles which children adopt in the MainWindow can be specified by the constraint resource XmNscrolledWindowChildType.

The MainWindow itself keeps track of the child roles through XmNmenuBar, XmNworkWindow, XmNmessageWindow, XmNcommandWindow resources, which can be specified through a standard XtSetValues() call. This was true in Motif 1.2.x, except that here the developers took the view that the specification of role by resource was cleaner than through the convenience function XmMainWindowSetAreas(), which is now considered deprecated. In part this was because XmMainWindowSetAreas() was insufficient in specifying all child roles of the MainWindow: it would not handle the message window by parameter.

There was one side effect. There used to be some optimisation code in XmMainWindowSetAreas() which would behave in different ways depending on whether the MainWindow was realized; this has now gone, and so the Motif 2.x XmMainWindowSetAreas() does not quite have the same geometry management chain as that of Motif 1.2.x.

The Solution

You should explicitly program the XmNscrolledWindowChildType resource when adding children to the MainWindow, as well as use XtSetValues() on the MainWindow to specify the work/command/menu/message components. The combination of setting explicit constraints per child and thererafter applying those roles into the MainWindow ought to be strictly redundant, but it does the trick.

For example:

    Arg      argv[...] ;
    Cardinal argc = 0;
    ...

    Widget mainWindow ;
    Widget workArea ;
    Widget messageArea ;
    Widget commandArea ;
    Widget menuBar ;

    /* Create the MainWindow */

    mainWindow = XmCreateMainWindow(...) ;

    /* Specify the Work Area, explicitly by constraint */
    argc = 0 ;
    ...
    XtSetArg(argv[argc], XmNscrolledWindowChildType, XmWORK_AREA) ; argc++ ;
    workArea = XmCreate...(mainWindow, "work", argv, argc) ;

    /* Specify the Command Area, explicitly by constraint */
    argc = 0 ;
    ...
    XtSetArg(argv[argc], XmNscrolledWindowChildType, XmCOMMAND_WINDOW) ; argc++ ;
    commandArea = XmCreate...(mainWindow, "command", argv, argc) ;

    /* Specify the MenuBar, explicitly by constraint */
    argc = 0 ;
    ...
    XtSetArg(argv[argc], XmNscrolledWindowChildType, XmMENU_BAR) ; argc++ ;
    menuBar = XmCreateMenuBar(mainWindow, "menu", argv, argc) ;

    /* Specify the Message Area, explicitly by constraint */
    argc = 0 ;
    ...
    XtSetArg(argv[argc], XmNscrolledWindowChildType, XmMESSAGE_WINDOW) ; argc++ ;
    messageArea = XmCreateMenuBar(mainWindow, "message", argv, argc) ;

    ...

    /* Now apply the roles to the MainWindow */
    /* Strictly, this ought now be redundant */
    /* Dont use XmMainWindowSetAreas()       */
    XtVaSetValues(mainWindow,
		  XmNworkWindow,    workArea,
		  XmNcommandWindow, commandArea,
		  XmNmenuBar,       menuBar,
		  XmNmessageWindow, messageArea,
		  NULL);

Notes

The MainWindow, and its geometry management, is somewhat notorious for behaving differently across platforms in what nominally are equivalent versions of the Motif toolkit. The HP MainWindow is something of a law unto itself.

Lastly, also note that at the Motif 2.0 stage, the MainWindow was modified so that it would accept the addition of a MessageBox child, which it would immediately recognise as the message component. However, the component does not immediately recognise a Label as the message area - this must be programmed. I therefore think this whole area is faulty in two respects:

  • Adding a MessageBox as a recognised message component is rather a heavyweight solution
  • If the component is to deduce message components automatically, it ought to also automatically recognise a Label, which is the more natural choice.

 



Sponsored by X-Designer - The Leading X/Motif GUI Builder - Click to download a FREE evaluation

 

Goto top of page

 

[IST Limited]
IST Limited is the
proud sponsor of motifdeveloper.com.
 

Thanks to all the contributors to these pages.

Privacy Policy

 
"Motif" is a registered trademark of The Open Group. All other trademarks are the property of their respective owners.

Some articles/papers here have their own copyright notice. All other information is copyright ©1999-2008 IST Limited

[CommerceOne] MW3 site originally by Ken Sall of Commerce One (formerly Century Computing).