Why does a MainWindow display the command area poorly in some Motif 2.1 environments?
9-Apr-02 15:35 GMT
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 ?
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
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.
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.
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() */
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.
by X-Designer - The Leading X/Motif GUI Builder
- Click to download a FREE evaluation
Goto top of page