DataSource * DSSelect :: FromXML( const ALib::XMLElement * e ) { AllowAttrs( e, AttrList( ORDER_ATTRIB, 0 ) ); RequireChildren( e ); CheckKids( e ); std::auto_ptr <DSSelect> sl( new DSSelect( GetOrder( e ) ) ); sl->AddChildSources( e ); return sl.release(); }
/************************************************************************ * * * ChangeManaged - called whenever there is a change in the managed * * set. * * * ************************************************************************/ static void ChangeManaged( Widget wid ) { XmMainWindowWidget mw = (XmMainWindowWidget) wid ; XtWidgetGeometry desired ; CompositeWidget cw = (CompositeWidget) mw->swindow.ClipWindow; Widget w; register int i; XtWidgetProc resize; if (mw->mwindow.ManagingSep || mw->swindow.FromResize) return; CheckKids(mw); /**************** * * This is an ugly bit of work... It's possible for the clip window to get * "extra" kids that really want to be mainwindow widgets. * ****************/ if ((mw->swindow.ScrollPolicy == XmAUTOMATIC) && (cw->composite.num_children > 1) && (mw->swindow.WorkWindow != NULL)) { /* loop over the clip window child list and treat the bogus */ for (i = 0; i < cw->composite.num_children; i++) { XmScrolledWindowConstraint swc ; int j ; w = cw->composite.children[i]; swc = GetSWConstraint(w); /* only those kind are allowed as clipwindow kids */ if ((((swc->child_type != XmWORK_AREA) && (swc->child_type != XmSCROLL_HOR) && (swc->child_type != XmSCROLL_VERT) && (swc->child_type != XmNO_SCROLL)) || (swc->child_type == NULL)) && /* Bug Id : 4127031, check for child_type of NULL */ (w != mw->swindow.WorkWindow) ) /* do not remove specified work_area widget from work_area*/ { /* add it to the main window child list. first increase the list if needed- Gee, I wish I remember what made me keep this hacky code around... */ if (mw->composite.num_children == mw->composite.num_slots) { mw->composite.num_slots += (mw->composite.num_slots / 2) + 2; mw->composite.children = (WidgetList) XtRealloc( (char *) mw->composite.children, (unsigned) (mw->composite.num_slots) * sizeof(Widget)); } mw->composite.children[mw->composite.num_children++] = w; w->core.parent = (Widget) mw; /* remove it from the clipwindow child list by moving all the siblings that comes after it one slot down */ /* Bug Id : 4127031, Major Bug Here, using i instead of j */ for (j = i+1; j < cw->composite.num_children; j++) { cw->composite.children[j-1] = cw->composite.children[j] ; } cw->composite.num_children -- ; } } } if (!XtIsRealized(wid)) { desired.width = XtWidth(wid) ; /* might be 0 */ desired.height = XtHeight(wid) ; /* might be 0 */ } else { desired.width = 0 ; desired.height = 0 ; } GetSize(mw, &desired.width, &desired.height); desired.request_mode = (CWWidth | CWHeight); (void) _XmMakeGeometryRequest(wid, &desired); _XmProcessLock(); resize = XtCoreProc(mw, resize); _XmProcessUnlock(); (*resize) (wid) ; XmeNavigChangeManaged(wid); }
/************************************************************************ * * * Layout - Layout the main window. * * * * * ************************************************************************/ static void Layout( XmMainWindowWidget mw ) { Position mbx,mby, cwx,cwy, swy, mwx, mwy, sepy, sep2y = 0; Dimension mbwidth, mbheight, cwwidth= 0, cwheight; Dimension MyXpad, MyYpad, mwwidth, mwheight; Dimension bw = 0, sep2h, sep3h; XtWidgetGeometry desired, preferred; int tmp ; /* used for checking negative Dimension value */ CheckKids(mw); /**************** * * Query the kids - and we have definite preferences as to their sizes. * The Menubar gets top billing - we tell it it how wide it is going to be , * and let it have whatever height it wants. The command box gets to stay * it's current height, but has to go to the new width. The scrolled window * gets the leftovers. * ****************/ MyXpad = mw->mwindow.margin_width; MyYpad = mw->mwindow.margin_height; mw->swindow.XOffset = MyXpad; mw->swindow.YOffset = MyYpad; mw->swindow.HeightPad = mw->mwindow.margin_height; mw->swindow.WidthPad = mw->mwindow.margin_width; cwx = MyXpad; cwy = swy = MyYpad; mw->mwindow.ManagingSep = True; if (ExistManaged(mw->mwindow.MenuBar)) { bw = mw->mwindow.MenuBar->core.border_width; mbx = MyXpad; mby = MyYpad; tmp = mw->core.width - (2 * (MyXpad + bw)); if (tmp <= 0) mbwidth = 10; else mbwidth = tmp ; mbheight = mw->mwindow.MenuBar->core.height; desired.x = mbx; desired.y = mby; desired.border_width = bw; desired.width = mbwidth; desired.height = mbheight; desired.request_mode = (CWWidth); if (XtQueryGeometry(mw->mwindow.MenuBar, &desired, &preferred) != XtGeometryYes) { bw = preferred.border_width; mbheight = preferred.height; } XmeConfigureObject(mw->mwindow.MenuBar, mbx, mby, mbwidth, mbheight,bw); if (mw->mwindow.ShowSep) { XtManageChild((Widget) mw->mwindow.Sep1); XmeConfigureObject( (Widget) mw->mwindow.Sep1, 0, mby + mbheight + (2 * bw), mw->core.width, mw->mwindow.Sep1->rectangle.height, 0); cwy = swy = mw->mwindow.Sep1->rectangle.y + mw->mwindow.Sep1->rectangle.height ; } else { XtUnmanageChild((Widget) mw->mwindow.Sep1); cwy = swy = mby + mbheight + (2 * bw); } } else { XtUnmanageChild((Widget) mw->mwindow.Sep1); } if (ExistManaged(mw->mwindow.CommandWindow)) { bw = mw->mwindow.CommandWindow->core.border_width; tmp = mw->core.width - (2 * (MyXpad + bw)); if (tmp <= 0) cwwidth = 10; else cwwidth = tmp ; cwheight = mw->mwindow.CommandWindow->core.height; desired.x = cwx; desired.y = cwy; desired.border_width = bw; desired.width = cwwidth; desired.height = cwheight; desired.request_mode = (CWWidth); if (XtQueryGeometry(mw->mwindow.CommandWindow, &desired, &preferred) != XtGeometryYes) { bw = preferred.border_width; cwheight = preferred.height; } if ((cwheight + cwy + (2 * bw)) > (mw->core.height - MyYpad)) { tmp = mw->core.height - (2 * bw) - MyYpad - cwy; if (tmp <= 0) cwheight = 10 ; else cwheight = tmp; } if (mw->mwindow.ShowSep) sep2h = mw->mwindow.Sep2->rectangle.height; else sep2h = 0; sep2y = (cwy + cwheight) + 2 * bw; swy = sep2y + sep2h ; if (mw->mwindow.CommandLoc == XmCOMMAND_BELOW_WORKSPACE) { mby = swy; sep2y = cwy + (mw->core.height - swy - MyYpad); swy = cwy; mw->swindow.HeightPad = sep2h + cwheight + mw->mwindow.margin_height; if (mw->mwindow.ShowSep) cwy = sep2y + mw->mwindow.Sep2->rectangle.height; else cwy = sep2y; } } else { XtUnmanageChild((Widget) mw->mwindow.Sep2); sep2h = 0; cwheight = 0; } if (ExistManaged(mw->mwindow.Message)) { bw = mw->mwindow.Message->core.border_width; mwx = MyXpad; tmp = mw->core.width - (2 * (MyXpad + bw)); if (tmp <= 0) mwwidth = 10 ; else mwwidth = tmp ; mwheight = mw->mwindow.Message->core.height; desired.x = mwx; desired.y = swy; desired.border_width = bw; desired.width = mwwidth; desired.height = mwheight; desired.request_mode = (CWWidth); if (XtQueryGeometry(mw->mwindow.Message, &desired, &preferred) != XtGeometryYes) { bw = preferred.border_width; mwheight = preferred.height; } if (mw->mwindow.ShowSep) sep3h = mw->mwindow.Sep3->rectangle.height; else sep3h = 0; sepy = mw->core.height - mwheight - (2 * bw) - mw->mwindow.margin_height - sep3h; mwy = sepy + sep3h; if (mw->mwindow.CommandLoc == XmCOMMAND_BELOW_WORKSPACE) { mw->swindow.HeightPad = sep2h + cwheight + sep3h + mwheight + mw->mwindow.margin_height; sep2y -= (sep3h + mwheight); cwy -= (sep3h + mwheight); } else mw->swindow.HeightPad = sep3h + mwheight + mw->mwindow.margin_height; XmeConfigureObject(mw->mwindow.Message, mwx, mwy, mwwidth, mwheight, bw); if (mw->mwindow.ShowSep) { XtManageChild((Widget) mw->mwindow.Sep3); XmeConfigureObject( (Widget) mw->mwindow.Sep3, 0, sepy, mw->core.width, mw->mwindow.Sep3->rectangle.height, 0); } else XtUnmanageChild((Widget) mw->mwindow.Sep3); } else { XtUnmanageChild((Widget) mw->mwindow.Sep3); } if (ExistManaged(mw->mwindow.CommandWindow)) { XmeConfigureObject( mw->mwindow.CommandWindow, cwx, cwy, cwwidth, cwheight, bw); if (mw->mwindow.ShowSep) { XtManageChild((Widget) mw->mwindow.Sep2); XmeConfigureObject((Widget) mw->mwindow.Sep2, 0, sep2y, mw->core.width, mw->mwindow.Sep2->rectangle.height, 0); } else XtUnmanageChild((Widget) mw->mwindow.Sep2); } mw->swindow.YOffset = swy; mw->mwindow.ManagingSep = False; }
/************************************************************************ * * * GeometryManager * * * ************************************************************************/ static XtGeometryResult GeometryManager( Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply ) { CompositeWidgetClass superclass = (CompositeWidgetClass) xmMainWindowClassRec.core_class.superclass ; XmMainWindowWidget mw = (XmMainWindowWidget ) w->core.parent; XtGeometryResult res; Dimension newWidth,newHeight, OldHeight; Dimension bw; XtWidgetGeometry parent_request ; XtWidgetGeometry desired, preferred; XtWidgetProc resize; CheckKids(mw); /**************** * * If it's not a mainwindow kid, let the scrolled window deal with it. * If it's from the workwindow, and the width changed, resize the menubar * and ask for a new height so my layout routine doesn't clip the workwindow. * ****************/ if (w != mw->mwindow.MenuBar && w != mw->mwindow.Message && w != mw->mwindow.CommandWindow && w != (Widget )mw->mwindow.Sep1 && w != (Widget) mw->mwindow.Sep2 && w != (Widget) mw->mwindow.Sep3) { /* this is the only case of geometry manager enveloping that I know of in Motif */ XtGeometryHandler geo_mgr; _XmProcessLock(); geo_mgr = superclass->composite_class.geometry_manager; _XmProcessUnlock(); res = (*geo_mgr)(w, request, reply); if (res == XtGeometryYes) { Widget mb = mw->mwindow.MenuBar; if ((w == mw->swindow.WorkWindow) && (request->request_mode & CWWidth) && mb && XtIsManaged(mb)) { desired.x = mb->core.x; desired.y = mb->core.y; desired.border_width = mb->core.border_width; desired.width = mw->core.width - (2 * mw->mwindow.margin_width); desired.height = mb->core.height; desired.request_mode = (CWWidth); XtQueryGeometry(mw->mwindow.MenuBar, &desired, &preferred); if (preferred.height != mb->core.height) { parent_request.request_mode = CWWidth | CWHeight; if (request->request_mode & XtCWQueryOnly) parent_request.request_mode |= XtCWQueryOnly; parent_request.width = mw->core.width ; parent_request.height = newHeight = mw->core.height - (mb->core.height - (2 * mb->core.border_width)) + preferred.height + (2 *preferred.border_width); if (XtMakeGeometryRequest((Widget) mw, &parent_request, NULL) == XtGeometryYes) { if (!(request->request_mode & XtCWQueryOnly)) XmeConfigureObject(mw->mwindow.MenuBar, mb->core.x, mb->core.y, preferred.width, preferred.height, preferred.border_width); else return XtGeometryYes ; } } } _XmProcessLock(); resize = XtCoreProc(mw, resize); _XmProcessUnlock(); (*resize)((Widget)mw) ; } return(res); } /** Disallow any X or Y changes for MainW children **/ if ((request -> request_mode & CWX || request -> request_mode & CWY)) return(XtGeometryNo); if(request->request_mode & CWBorderWidth) bw = request->border_width; else bw = w->core.border_width; if (request->request_mode & CWWidth) newWidth = request->width + 2 * (bw + mw->mwindow.margin_width); else newWidth = mw->core.width ; /* grow only in width */ if (newWidth <= mw->core.width) newWidth = mw->core.width; /**************** * * Margins are already included in the old width & height * ****************/ if(request->request_mode & CWHeight) newHeight = mw->core.height - (w->core.height - (2 * w->core.border_width)) + request->height + 2 * bw; else newHeight = mw->core.height; OldHeight = mw->core.height; parent_request.request_mode = CWWidth | CWHeight; if (request->request_mode & XtCWQueryOnly) parent_request.request_mode |= XtCWQueryOnly; parent_request.width = newWidth ; parent_request.height = newHeight; res = XtMakeGeometryRequest((Widget) mw, &parent_request, NULL) ; if (res == XtGeometryYes) { if (!(request->request_mode & XtCWQueryOnly)) { if(request->request_mode & CWWidth) w->core.width = request->width; if(request->request_mode & CWHeight) w->core.height = request->height; mw->swindow.YOffset = mw->swindow.YOffset + (newHeight - OldHeight); _XmProcessLock(); resize = XtCoreProc(mw, resize); _XmProcessUnlock(); (*resize) ((Widget)mw) ; } } return(res); }
/*ARGSUSED*/ static Boolean SetValues( Widget cw, Widget rw, /* unused */ Widget nw, ArgList args, /* unused */ Cardinal *num_args ) /* unused */ { XmMainWindowWidget current = (XmMainWindowWidget) cw ; XmMainWindowWidget new_w = (XmMainWindowWidget) nw ; Boolean flag = False; CheckKids(new_w); /* somehow, this used not to create problem in 1.2, some apps did setvalue of XmNmenubar to itself ? check that and change back */ if ((new_w->mwindow.MenuBar != current->mwindow.MenuBar) && (new_w->mwindow.MenuBar == nw)) { new_w->mwindow.MenuBar = current->mwindow.MenuBar; } /* fix for 8990: these warnings must be here for bc... */ if ((new_w->mwindow.MenuBar != current->mwindow.MenuBar) && (new_w->mwindow.MenuBar == NULL)) { XmeWarning( (Widget) new_w, MWMessage1); new_w->mwindow.MenuBar = current->mwindow.MenuBar; } if ((new_w->mwindow.CommandWindow != current->mwindow.CommandWindow) && (new_w->mwindow.CommandWindow == NULL)) { XmeWarning( (Widget) new_w, MWMessage2); new_w->mwindow.CommandWindow = current->mwindow.CommandWindow; } /* first deal with the layout attributes, and set up a flag */ /* There is a potential bug here: if the change in margin concur with a change on some other stuff, like separator or a new child, and the getSize call return the same size, no resize call will be generated by Xt. A way to fix that is to check this no change in size and to fake a request.. maybe not worth. */ if ((new_w->mwindow.margin_width != current->mwindow.margin_width) || (new_w->mwindow.margin_height != current->mwindow.margin_height) || (new_w->mwindow.ShowSep != current->mwindow.ShowSep)) { flag = True; } if ((new_w->mwindow.CommandLoc != current->mwindow.CommandLoc) && (XmRepTypeValidValue(XmRID_COMMAND_WINDOW_LOCATION, new_w->mwindow.CommandLoc, (Widget) new_w))) { XtWidgetProc resize; _XmProcessLock(); resize = XtCoreProc(nw, resize); _XmProcessUnlock(); (*resize) (nw) ; } else new_w->mwindow.CommandLoc = current->mwindow.CommandLoc; /* At InsertChild time, a lot of bad things might have happened. The command window, messagewindow and work window, which we have no real way to identify at that time, might have been mixed up. (MenuBar and application ScrollBars shouldn't be a problem) The first unidentifiable kid will take the workwindow slot (and possibly be reparented), and the followers will be just inserted in the child list without reparenting (to the clipwindow in AUTO mode I mean). After creation time, the application will use XtSetValues to set up things correctly (except changing the workwindow in AUTO, which is not allowed). The requirement, if a childType resource isn't provided, is that the workwindow be created first, at least in AUTO mode where the reparenting happens */ if ((new_w->mwindow.MenuBar != current->mwindow.MenuBar) || (new_w->mwindow.Message != current->mwindow.Message) || (new_w->mwindow.CommandWindow != current->mwindow.CommandWindow ) || (new_w->swindow.hScrollBar != current->swindow.hScrollBar) || (new_w->swindow.vScrollBar != current->swindow.vScrollBar) || (new_w->swindow.WorkWindow != current->swindow.WorkWindow ) || (flag)) { /* set our core geometry to the needed size - no resizePolicy here... Change in child type can happen before realize time, before change managed has been called, and we don't want to set up a size for the main window at this point, since its children size haven't been set up yet */ if (XtIsRealized((Widget)new_w)) { Dimension width = 0, height = 0 ; GetSize (new_w, &width, &height); new_w->core.width = width ; new_w->core.height = height ; } } return (False); }