void ListView::create_ui_objects() { /* -------- Create ui components. -------- */ f_shell = new WTopLevelShell (toplevel(), WPopup, f_name); window_system().register_shell (f_shell); WXmForm form (*f_shell, "form"); /* -------- allow child to be creative -------- */ child_create_ui_pre(form); WXmPushButton close (form, "close", WAutoManage); WXmPushButton help (form, "help", WAutoManage); XtVaSetValues(close, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 12, "Close")), NULL); XtVaSetValues(help, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 48, "Help")), NULL); // 7/30/93 rtp - bear with this hack, it's a little bogus char *help_name = new char[strlen(f_name) + strlen("_help") + 1]; sprintf(help_name, "%s%s", f_name, "_help"); // What i've done is appended '_help' to the widget name and added // a help callback to the help button that will reference this name help_agent().add_activate_help (help, help_name); f_activate = WXmPushButton (form, "activate", WAutoManage); XtVaSetValues(f_activate, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 165, "Display")), NULL); // WXmLabelGadget label (form, "label", WAutoManage); WXmSeparator separator (form, "separator", WAutoManage); // NOTE: Fix WWL to have a scrolled list object! Widget scrolled_list = XmCreateScrolledList (form, "list", NULL, 0); f_list = new WXmList (scrolled_list); f_list->Manage(); XmFontList defaultList; { XmFontList font; XtVaGetValues(scrolled_list, XmNfontList, &font, NULL); defaultList = XmFontListCopy(font); } if (window_system().dtinfo_space_font()) defaultList = XmFontListAppendEntry(defaultList, window_system().dtinfo_space_font()); XtVaSetValues(scrolled_list, XmNfontList, defaultList, NULL); /* -------- let child add anything else -------- */ child_create_ui_post(form); /* -------- Callbacks -------- */ f_wm_delete_callback = new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(), this, (WWL_FUN) &ListView::close_window); close.SetActivateCallback (this, (WWL_FUN) &ListView::close_window); f_list->SetSingleSelectionCallback (this, (WWL_FUN) &ListView::select); f_list->SetBrowseSelectionCallback (this, (WWL_FUN) &ListView::select); f_list->SetDefaultActionCallback (this, (WWL_FUN) &ListView::activate); f_activate.SetActivateCallback (this, (WWL_FUN) &ListView::activate); /* -------- Finalize -------- */ form.DefaultButton (f_activate); form.ShadowThickness (0); // get rid of border turds (motif bug) form.Manage(); }
void QueryEditor::create_ui() { Wait_Cursor bob; XmStringLocalized mtfstring; String string; KeySym mnemonic; f_shell = WTopLevelShell(window_system().toplevel(), WPopup, "query_editor"); window_system().register_shell (&f_shell); string = CATGETS(Set_QueryEditor, 1, "Dtinfo: Query Editor"); XtVaSetValues((Widget)f_shell, XmNtitle, string, NULL); // Main form and menu bar. WXmForm form (f_shell, "form" ); WXmMenuBar menu_bar (form, "menu_bar" ); WXmPulldownMenu scope_menu (form, "scope_menu"); Arg args[1]; int n = 0; XtSetArg(args[n], XmNsubMenuId, (Widget) scope_menu); n++; f_scope_option = WXmOptionMenu (form, "scope_option", AM, args, n); mtfstring = CATGETS(Set_AgentLabel, 212, "Scope Name"); XtVaSetValues(f_scope_option, XmNlabelString, (XmString)mtfstring, NULL); // Menu definitions. how about using AddPushButton (name, obj, fun)?? WXmCascadeButton edit_cascade (menu_bar, "edit", AM); WXmPulldownMenu edit_menu (menu_bar, "edit_menu" ); f_cut_btn = WXmPushButton (edit_menu, "cut", AM); f_copy_btn = WXmPushButton (edit_menu, "copy", AM); f_paste_btn = WXmPushButton (edit_menu, "paste", AM); f_paste_btn = WXmPushButton (edit_menu, "new_term", AM); WXmSeparator group_sep (edit_menu, "group_sep", AM); f_group_btn = WXmPushButton (edit_menu, "group", AM); f_ungroup_btn = WXmPushButton (edit_menu, "ungroup", AM); WXmSeparator undo_sep (edit_menu, "undo_sep", AM); f_undo_btn = WXmPushButton (edit_menu, "undo", AM); f_redo_btn = WXmPushButton (edit_menu, "redo", AM); mtfstring = CATGETS(Set_AgentLabel, 16, "Edit"); mnemonic = *CATGETS(Set_AgentLabel, 17, "E"); XtVaSetValues(edit_cascade, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL); mtfstring = CATGETS(Set_AgentLabel, 224, "Cut"); XtVaSetValues(f_cut_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 18, "Copy"); XtVaSetValues(f_copy_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 225, "Paste"); XtVaSetValues(f_paste_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 226, "Group"); XtVaSetValues(f_group_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 227, "Ungroup"); XtVaSetValues(f_ungroup_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 228, "Undo"); XtVaSetValues(f_undo_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 229, "Redo"); XtVaSetValues(f_redo_btn, XmNlabelString, (XmString)mtfstring, NULL); // Button area at the bottom WXmForm hform (form, "hform" ); f_hist_prev = WXmArrowButton (hform, "hist_prev", AM); f_hist_next = WXmArrowButton (hform, "hist_next", AM); WXmLabel history (hform, "history", AM); f_search_btn = WXmPushButton (form, "search", AM); WXmPushButton cancel (form, "cancel", AM); WXmPushButton clear (form, "clear", AM); WXmPushButton scope (form, "scope", AM); WXmPushButton help (form, "help", AM); WXmSeparator separator (form, "separator", AM); mtfstring = CATGETS(Set_AgentLabel, 92, "History"); XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 102, "Search"); XtVaSetValues(f_search_btn, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 231, "Clear All"); XtVaSetValues(clear, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 46, "Scope Editor"); XtVaSetValues(scope, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 12, "Close"); XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL); mtfstring = CATGETS(Set_AgentLabel, 48, "Help"); XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL); help_agent().add_activate_help (help, "query_editor_help"); // Main "work" area WXmPanedWindow pane (form, "pane" ); WXmForm qform (pane, "qform" ); WXmLabel qlabel (qform, "qlabel", AM); mtfstring = CATGETS(Set_AgentLabel, 230, "Query"); XtVaSetValues(qlabel, XmNlabelString, (XmString)mtfstring, NULL); f_query_text = WXmScrolledText (qform, "qtext", AM); // f_query_text.SetEditable(False); f_query_area = WXmScrolledWindow (pane, "query_area", AM); XtUnmanageChild (f_query_area.HorizontalScrollBar()); edit_cascade.SubMenuId (edit_menu); // Callbacks ON_ACTIVATE (f_search_btn, search_activate); ON_ACTIVATE (cancel, cancel); ON_ACTIVATE (clear, clear); ON_ACTIVATE (scope, scope); // f_query_text.SetFocusCallback (this, // (WWL_FUN) &QueryEditor::modify_verify); // f_query_text.SetModifyVerifyCallback (this, // (WWL_FUN) &QueryEditor::modify_verify); // Set minimum sizes. qform.Manage(); pane.Manage(); // hform.Manage(); form.DefaultButton (f_search_btn); form.ShadowThickness (0); form.InitialFocus (pane); pane.InitialFocus (f_query_area); qform.PaneMinimum (f_query_text.Height()); form.Manage(); f_shell.Realize(); f_shell.MinWidth (f_shell.Width()); f_shell.MinHeight (f_shell.Height()); ON_DEBUG(printf ("Query for height = %d\n", qform.Height())); //cerr << "Query for height = " << qform.Height() << endl; //#ifndef UseFJMTF #if 1 // Swap the entries in the pane around. Have to do this now // to get initial sizes right. qform.PositionIndex (1); #endif fill_menu(); UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this); UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this); search_scope_mgr().option_menu(this); }
void MapAgent::create_ui() { MapButton::f_kids_size = 8; MapButton::f_kids = (Widget *) malloc (sizeof (Widget) * MapButton::f_kids_size); f_shell = new WTopLevelShell (toplevel(), WPopup, "map"); window_system().register_shell (f_shell); XtVaSetValues(*f_shell, XmNtitle, CATGETS(Set_MapAgent, 1, "Dtinfo: Local Map"), NULL); WindowGeometry wg = pref_mgr().get_geometry (PrefMgr::MapGeometry); f_shell->Set(WArgList(XmNwidth, wg.width, XmNheight, wg.height, NULL)); // rtp - added new code 8/27/92 WXmForm rootform (*f_shell, "rootform"); WXmForm bottomform (rootform, "bottomform"); WXmPushButton close (bottomform, "close", WAutoManage); WXmPushButton help (bottomform, "help", WAutoManage); help_agent().add_activate_help (help, (char*)"map_help"); XtVaSetValues(close, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 12, "Close")), NULL); XtVaSetValues(help, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 48, "Help")), NULL); WXmPanedWindow pane (rootform, "pane"); WXmForm topform (pane, "topform"); XtVaSetValues(topform, XmNheight, 75, NULL); XtVaSetValues(pane, XmNpaneMinimum, 75, XmNpositionIndex, 1, NULL); WXmFrame panner_frame (topform, "pframe", WAutoManage); f_panner = new WXawPanner (panner_frame, "panner", WAutoManage); WXmFrame tree_frame (pane, "tframe", WAutoManage); f_porthole = new WXawPorthole (tree_frame, "porthole"); f_lock = new WXmToggleButton (topform, "lock", WAutoManage); XtVaSetValues(*f_lock, XmNlabelString, (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 196, "Auto Update")), XmNindicatorSize, 15, NULL); bool lock_status = pref_mgr().get_boolean (PrefMgr::MapAutoUpdate); f_lock->Set(lock_status); f_locked = lock_status ; // NOTE: Should have a way to remove displayer so that receive function // isn't called every time a node is displayed. 14:08 12-Oct-93 DJB UAS_Common::request ((UAS_Receiver<UAS_DocumentRetrievedMsg> *) this); f_lock->SetValueChangedCallback(this, (WWL_FUN) &MapAgent::lock_toggle); f_porthole->SetReportCallback (this, (WWL_FUN) &MapAgent::porthole_resize); f_panner->SetReportCallback (this, (WWL_FUN) &MapAgent::panner_movement); bottomform.Manage(); Dimension height; f_lock->Get (WArgList (XmNheight, (XtArgVal)&height, NULL)); topform.Set(WArgList(XmNpaneMinimum, height, NULL)); topform.Manage(); f_porthole->Manage(); pane.Manage(); /* -------- Callbacks -------- */ f_wm_delete_callback = new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(), this, (WWL_FUN) &MapAgent::close_window); close.SetActivateCallback (this, (WWL_FUN) &MapAgent::close_window); rootform.Manage(); // f_shell->Realize(); f_tree = NULL; }
void QueryEditor::edit_query (QueryGroup *query) { static Boolean first_time = True; //#ifdef UseFJMTF #if 1 // Fujitsu Motif seems to be buggy for HaL's Restraint widget. // You must not destroy and re-create the Restraint widget. // Instead keep the same Restraint widget forever. - 10/22/94 kamiya // Create a group with a single term if none provided. if (query == NULL) { query = new QueryGroup(); // This QueryTerm is pointed to by the QueryGroup. new QueryTerm (query, NULL, NULL); } f_query = query; // re-load the query terms if (f_query_view != NULL) f_query_view->re_load_terms(f_query); #else // Clean up old junk. // The query isn't destroyed sometimes?? // Need to nuke only if it isn't saved on the history list. DJB if (f_query_view != NULL) { QueryGroup *group = f_query_view->query_group(); f_query_view->destroy_widgets(); delete f_query_view; delete f_query; } // NOTE: old query probably leaked!! 15:06 01/29/93 DJB // This is going to need to be fixed up to edit pre-existing querys. // NOTE: Another problem if this is called before the UI is created, // because thar's widgets created below. 17:19 02/03/93 DJB f_query = query; // Create a group with a single term if none provided. if (f_query == NULL) { f_null_terms = 0; f_query = new QueryGroup(); // This QueryTerm is pointed to by the QueryGroup. new QueryTerm (f_query, NULL, NULL); } // QueryGroupView holds the pointer to the QueryGroup. f_query_view = new QueryGroupView (f_query, WXmForm ((WObject &) f_query_area)); #endif if (first_time) { //#ifdef UseFJMTF #if 1 f_null_terms = 0; // QueryGroupView holds the pointer to the QueryGroup. f_query_view = new QueryGroupView (f_query, f_query_area); #endif // Only let pane get small enough to show two query entries. // Start with the whole scrolled window, then take out the scrolling // area to leave the borders, then add the term height * 2 back in. // NOTE: This really needs to use the height of one row. If this // dialog comes up with an existing query at this point, the // height will be wrong. We need to get the height of a single // line somehow. 11:59 02/04/93 DJB f_query_area. PaneMinimum (f_query_area.Height() - WCore (XtParent(XtParent(*f_query_view))).Height() + (2 * f_query_view->Height())); // Take the height of each pane - the min size of each pane. // That is the excess height of the dialog. // This needs to equal the current height - min height. // So subtract it from the current height to get the new min height. WXmForm qform (XtParent(f_query_text.Parent())); #ifdef DEBUG printf ("qform height = %d, scrolled height = %d\n", qform.Height(), f_query_area.Height()); printf ("qform min = %d, scrolled min = %d\n", qform.PaneMinimum(), f_query_area.PaneMinimum()); #endif Dimension excess_height = qform.Height() + f_query_area.Height() - qform.PaneMinimum() - f_query_area.PaneMinimum(); ON_DEBUG(printf ("Query Editor excess height = %d\n", excess_height)); f_shell.MinHeight (f_shell.Height() - excess_height); first_time = False; } //g_allow_query_text_change = TRUE; f_query_text.Value (""); //g_allow_query_text_change = FALSE; // Move the input focus to the term view. f_query_area.InitialFocus (*f_query_view); // f_query_view->traverse_here(); display(); }
void MapAgent::display (UAS_Pointer<UAS_Common> &doc_ptr, bool popup) { static bool first_time = True; u_int i, num_children; MapButton *parent_button, *child_button, *this_button = NULL; if (f_shell == NULL) create_ui(); // Just pop up the window if the map has already been created // for the specified document. if (doc_ptr == f_doc_ptr) { if (popup) { f_shell->Popup(); XMapRaised(XtDisplay(*f_shell), XtWindow(*f_shell)); } f_onscreen = TRUE; return; } // Must have to create a new tree, so start by wiping out the old one. if (f_tree != NULL) { f_tree->Destroy(); delete f_tree; } f_tree = new WXawTree (*f_porthole, "tree"); // f_tree->Realize(); // Tree gravity should be a preference that is retrieved right here. // (Or better yet stored in the class record.) /* -------- Start the local map at this node's parent. -------- */ UAS_Pointer<UAS_Common> toc_this = doc_ptr; UAS_Pointer<UAS_Common> toc_parent = (doc_ptr != (UAS_Pointer<UAS_Common>)0) ? doc_ptr->parent() : (UAS_Pointer<UAS_Common>)0; // If the entry has a parent, create a button for it and each of // the entry's siblings. if (toc_parent != (UAS_Pointer<UAS_Common>)NULL) { parent_button = new MapButton (*f_tree, toc_parent, NULL); // parent_button->expand(); /* -------- Create a button for each sibling. -------- */ UAS_List<UAS_Common> kids = toc_parent->children(); num_children = kids.length(); UAS_Pointer<UAS_Common> toc_kid; for (i = 0; i < num_children; i++) { toc_kid = kids[i]; child_button = new MapButton (*f_tree, toc_kid, parent_button); if (toc_kid == doc_ptr) { f_doc_ptr = doc_ptr; this_button = child_button; } } } else // No TOC parent -- SWM: Also may be no TOC!!! { f_doc_ptr = doc_ptr; this_button = new MapButton (*f_tree, toc_this, NULL); } if (this_button == NULL) { message_mgr(). error_dialog (CATGETS(Set_Messages, 7, "File a Bug")); return; } else { static bool first_time = TRUE; static Pixel highlight_bg, highlight_fg; if (first_time) { const char *s; unsigned long status; s = window_system().get_string_default ("MapHighlightBackground"); if (s == NULL || *s == '\0') { highlight_bg = this_button->f_button.Foreground(); } else { status = window_system().get_color (s, highlight_bg); // On failure to allocate, just invert. if (status == 0) { highlight_bg = this_button->f_button.Foreground(); highlight_fg = this_button->f_button.Background(); } // Got bg, so now try for fg. else { s = window_system(). get_string_default ("MapHighlightForeground"); if (s == NULL || *s == '\0') { highlight_fg =this_button->f_button.Background(); } else { status = window_system().get_color (s, highlight_fg); // If we cant get both colors, just invert the button. if (status == 0) { Display *dpy = window_system().display(); XFreeColors (dpy, DefaultColormap(dpy,DefaultScreen(dpy)), &highlight_bg, 1, 0); highlight_bg = this_button->f_button.Foreground(); highlight_fg = this_button->f_button.Background(); } } } } if (highlight_fg == this_button->f_button.Foreground() || highlight_bg == this_button->f_button.Background() || highlight_fg == highlight_bg) { highlight_bg = this_button->f_button.Foreground(); highlight_fg = this_button->f_button.Background(); } first_time = FALSE; } this_button->f_button.Background (highlight_bg); this_button->f_button.Foreground (highlight_fg); // this_button->expand(); } /* -------- Create a button for each child. -------- */ if (toc_this != (UAS_Pointer<UAS_Common>)NULL) { UAS_List<UAS_Common> myKids = toc_this->children(); num_children = myKids.length(); for (i = 0; i < num_children; i++) child_button = new MapButton (*f_tree, myKids[i], this_button); #if 0 if (!XtIsRealized(*f_shell)) { f_tree->Manage(); f_shell->Realize(); } #endif } // Manage all the children. MapButton::ManageKids(); UAS_String buffer = CATGETS(Set_MapAgent, 2, "Dtinfo: "); buffer = buffer + doc_ptr->title(); f_shell->Title ((char*)buffer); if (!XtIsRealized (*f_shell)) f_shell->Realize(); f_tree->Realize(); f_tree->ForceLayout(); f_min_tree_width = f_tree->Width(); f_min_tree_height = f_tree->Height(); ON_DEBUG (printf ("+++++ Tree min dims: %d x %d\n", f_min_tree_width, f_min_tree_height)); center_on (this_button); f_tree->Manage(); if (popup) { if (first_time) { WXmForm form (XtParent (XtParent (*f_panner))); form.Height (50); first_time = False; } f_shell->Popup(); XMapRaised(XtDisplay(*f_shell), XtWindow(*f_shell)); } f_onscreen = TRUE; }