void QueryGroupView::re_load_terms(QueryGroup* group) { QueryTermView* view; // destroy widgets of term view for (view = f_term_view_list; view; view = view->next_term_view()) view->destroy_widgets(); // delete term views while (f_term_view_list != NULL) delete f_term_view_list; delete f_query_group; f_query_group = group; // load new terms QueryTerm *term; for (view = 0, term= group->term_list(); term != NULL; term = term->next()) view = new QueryTermView (term, this, view, NULL); }
QueryGroupView::QueryGroupView (QueryGroup *group, Widget parent) : f_query_group (group), f_term_view_list (NULL) { f_restraint = WRestraint (WComposite (parent), "group_view", WAutoManage); f_form = WXmForm (f_restraint, "group_form"); QueryTermView *view = NULL; QueryTerm *term; for (term= group->term_list(); term != NULL; term = term->next()) view = new QueryTermView (term, this, view, NULL); f_form.Realize(); // This statement is extremely critical. 02/03/93 DJB f_form.Manage(); // Need special event handler for top level group to catch // resizes of window and resize the query view. // NOTE: It's just about time to move this to another method. if (XtClass (XtParent (f_restraint)) == xmDrawingAreaWidgetClass) { // Let's see what the parent's size is now: ON_DEBUG(printf ("Drawing area is width: %d, height: %d\n", WCore(f_restraint.Parent()).Width(), WCore(f_restraint.Parent()).Height())); // We need to grow the drawing area if it is smaller than the // restraint widget, since we don't deal with horizontal scrolling. Dimension restraint_width = f_restraint.Width(); Dimension da_width = WCore(f_restraint.Parent()).Width(); if (da_width < restraint_width) { // Can't resize the drawing area because the ^$&(*% Motif // pane widget will not allow the horizontal resize. So, // instead calculate the size increase and do it on the shell. Dimension increase = restraint_width - da_width; // Find the shell widget. Widget w = f_restraint.Parent(); while (!XtIsShell (w)) w = XtParent(w); WTopLevelShell shell (w); ON_DEBUG(printf ("** Resizing shell by = %d\n", increase)); // Change state if needed. Boolean allow_resize = shell.AllowShellResize(); if (!allow_resize) shell.AllowShellResize (True); // Change the width. shell.MinWidth (shell.Width() + increase); shell.Width (shell.Width() + increase); // Restore state if needed. if (!allow_resize) shell.AllowShellResize (False); } else if (da_width > restraint_width) { f_restraint.Width (WCore(f_restraint.Parent()).Width()); } XtAddEventHandler (XtParent (f_restraint), StructureNotifyMask, False, (XtEventHandler) &QueryGroupView::resize, (Widget) f_restraint); // Store the min width in UserData... f_restraint.UserData ((XtPointer)(size_t) f_restraint.Width()); } // Make sure the restraint widget isn't too narrow. else { f_restraint.Width (WCore(f_restraint.Parent()).Width()); } }