gerolima@Neon.Stanford.EDU (Mark Gerolimatos) (03/28/91)
8< 8< 8< cut here >8 >8 >8 /* MOTIF V 1.1 MainWindow problem ** Crops up under SunOS 4.0.x, sun4's as well as 3's. Both standard ** and QUEST releases. ** Responses to gerolima@wdl34.wdl.loral.com or gerolima@neon.stanford.edu ** ** Compile with the standard ** "(g)cc -o button button.c -lXm -lX(m)t -lX11" ** to get the busted version, and ** "(g)cc -DFIXED -o button button.c -lXm -lX(m)t -lX11" ** to get the fixed version */ /* THIS PROGRAM *SHOULD* bring up a vertical array of 4 buttons, each ** representing an "area" of a main window. ** BUT IT DOESN'T!!!! Note the gap between the command window and the ** message window.Now,where did that pesky work area go?Pressing down on ** the "This would be the menu bar" button(causing it to unmanage itself ** reveals that the work window is in the upper left hand corner! ** WHAT A CROCK! ** ** What's even more of a CROCK is a fix for this. It has NOTHING to ** do with the type of child within the main window areas (ferinstence, ** I don't believe there's anything in the main window dox that say ** each area CAN'T be a button), or with the order of their creation. ** ** Turns out, if you explicity set the "area" of each widget immedeately ** after creating it, and before creating the other areas (i.e. call ** SetValues for "frame" four times) seems to fix it. ** WHAT A DOUBLE CROCK! ** ** ** Question 1: is this a bug, or is this the way it's *supposed* to ** happen? ** ** Question 2: if this IS a bug, is there a way to fix it so that ** a "lump" SetAreas may be done? ** ** Question 3: is the MainWindow layout going to break in a different ** way each time a new version of MOTIF(tm) comes out? Dammit, this ** stuff is pretending to be a STANDARD. But how much of a standard ** can it be if the guys who CREATED it can't get such basic stuff ** as MainWindows right after all this time?!? C'mon, guys, get on the ** ball! */ #include <stdio.h> #include <Xm/PushB.h> #include <Xm/MainW.h> static Widget toplevel_widget; Widget menu_bar, frame, work_window, box, mr_message; void remove_me () { XtUnmanageChild(menu_bar); } main(argc, argv) unsigned int argc; char *argv[]; { Arg list[40]; int n; static XtCallbackRec mycallbacks[2] = {{remove_me,0},{0,0}}; toplevel_widget = XtInitialize("MrProgram", "Class of 85", NULL, 0, &argc, argv); frame = XmCreateMainWindow(toplevel_widget,"hello",list,n); n = 0; XtSetArg(list[n],XmNactivateCallback,mycallbacks);n++; XtSetValues(frame,list,n); menu_bar = XmCreatePushButton(frame,"This would be the menu bar",list,n); #ifdef FIXED n = 0; XtSetArg(list[n],XmNmenuBar,menu_bar);n++; XtSetValues(frame,list,n); #endif FIXED box = XmCreatePushButton(frame,"This would be the command window",NULL,0); #ifdef FIXED n = 0; XtSetArg(list[n],XmNcommandWindow,box);n++; XtSetValues(frame,list,n); #endif FIXED work_window = XmCreatePushButton(frame,"This would be the work window",NULL,0); #ifdef FIXED n = 0; XtSetArg(list[n],XmNworkWindow,work_window);n++; XtSetValues(frame,list,n); #endif FIXED mr_message = XmCreatePushButton(frame,"This would be the message window",NULL,0); #ifdef FIXED n = 0; XtSetArg(list[n],XmNmessageWindow,mr_message);n++; XtSetValues(frame,list,n); #endif FIXED /* v---------- note! ifNdef! */ #ifndef FIXED n = 0; XtSetArg(list[n],XmNcommandWindow,box);n++; XtSetArg(list[n],XmNmenuBar,menu_bar);n++; XtSetArg(list[n],XmNmessageWindow,mr_message);n++; XtSetArg(list[n],XmNworkWindow,work_window);n++; XtSetValues(frame,list,n); #endif NOT_FIXED XtManageChild(work_window); XtManageChild(menu_bar); XtManageChild(box); XtManageChild(mr_message); XtManageChild(frame); XtRealizeWidget(toplevel_widget); XtMainLoop(); }