/*********************************************************************** * * * Copy selected items from the left list to the right list. * * * ***********************************************************************/ static void copy_cb(Widget w, XtPointer cd, XmAnyCallbackStruct *cbs) { int icnt, pos, pcnt, *posl; XmString *items; if (XmListGetSelectedPos(var2NtSList, &posl, &pcnt)) { pos = posl[pcnt-1] + 1; XtFree((char *)posl); } else pos = 0; XmListDeselectAllItems(var2NtSList); if (w == exprNtSText) { char *expr = XmTextGetString(w); if (!strempty(expr)) { XmString xms = XmStringCreateSimple(expr); XmListAddItem(var2NtSList, xms, pos); XmStringFree(xms); } XtFree(expr); /* * ugly... I don't want to show the scanner after hitting the * KActivate in the text widget */ no_scan = True; } else if (w == copyNtSButton) { XtVaGetValues(var1NtSList, XmNselectedItemCount, &icnt, XmNselectedItems, &items, NULL); XmListAddItems(var2NtSList, items, icnt, pos); } else if (w == copyAllNtSButton) { XtVaGetValues(var1NtSList, XmNitemCount, &icnt, XmNitems, &items, NULL); clear_selector_columns(2); XmListAddItems(var2NtSList, items, icnt, pos); } else if (w == var1NtSList) { XmListCallbackStruct *cbsl = (XmListCallbackStruct *) cbs; if (cbsl->event->type == ButtonRelease) XmListAddItem(var2NtSList, cbsl->item, pos); } XmListSelectPos(var2NtSList, pos, False); }
void wxListBox::DoSetItems(const wxArrayString& items, void** clientData) { Widget listBox = (Widget) m_mainWidget; if( HasClientObjectData() ) m_clientDataDict.DestroyData(); XmString *text = new XmString[items.GetCount()]; unsigned int i; for (i = 0; i < items.GetCount(); ++i) text[i] = wxStringToXmString (items[i]); if ( clientData ) for (i = 0; i < items.GetCount(); ++i) m_clientDataDict.Set(i, (wxClientData*)clientData[i], false); XmListAddItems (listBox, text, items.GetCount(), 0); for (i = 0; i < items.GetCount(); i++) XmStringFree (text[i]); delete[] text; // It seems that if the list is cleared, we must re-ask for // selection policy!! SetSelectionPolicy(); m_noItems = items.GetCount(); }
void display_note_equip_poplist (Widget w, XtPointer client_data, XtPointer call_data) { if (notesc_poplist_shell == NULL) create_notesc_poplist_shell (notes_create_shell); /* Populate the list. The subscr_no values are not saved in a ** list structure, but are retrieved from the db every time the ** poplist button is activated. */ XmListDeleteAllItems (notesc_poplist); populate_note_subscr_no_list(); XmListAddItems (notesc_poplist, note_subscr_no_strings, num_note_subscr_no_codes, 0); /* Set the text field that will be populated when user selects * a value from the list. */ XtVaSetValues (notesc_poplist, XmNuserData, notes_equip_txt, NULL); position_poplist (w, notesc_poplist_shell); XtManageChild (notesc_poplist_form); XtPopup (notesc_poplist_shell, XtGrabNone); XmProcessTraversal (notesc_poplist, XmTRAVERSE_CURRENT); }
void display_note_text_poplist (Widget w, XtPointer client_data, XtPointer call_data) { int status; if (notesc_poplist_shell == NULL) create_notesc_poplist_shell (notes_create_shell); /* Populate the list */ XmListDeleteAllItems (notesc_poplist); status = populate_note_text_list(); if (status != SUCCESS) return; XmListAddItems (notesc_poplist, note_text_strings, num_note_text_codes, 0); /* Set the text field that will be populated when user selects * a value from the list. */ XtVaSetValues (notesc_poplist, XmNuserData, notes_text_txt, NULL); position_poplist (w, notesc_poplist_shell); XtManageChild (notesc_poplist_form); XtPopup (notesc_poplist_shell, XtGrabNone); XmProcessTraversal (notesc_poplist, XmTRAVERSE_CURRENT); }
void populate_status_codes(Widget w, XtPointer client_data, XmAnyCallbackStruct *call_data) { if(eft_sel_shell == NULL) create_eft_sel_shell(eft_shell); XmListDeselectAllItems(eftsellist); XmListDeleteAllItems(eftsellist); XmListAddItems(eftsellist, eft_display_statuses_list, eft_num_display_statuses, 0); position_poplist(w, eft_sel_shell); XtManageChild(eft_sel_form); XtPopup(eft_sel_shell, XtGrabNone); XmProcessTraversal(eftsellist, XmTRAVERSE_CURRENT); }
void wxListBox::DoSetItems(const wxArrayString& items, void** clientData) { wxSizeKeeper sk( this ); Widget listBox = (Widget) m_mainWidget; if( HasClientObjectData() ) m_clientDataDict.DestroyData(); bool managed = XtIsManaged(listBox); if (managed) XtUnmanageChild (listBox); XmString *text = new XmString[items.GetCount()]; size_t i; for (i = 0; i < items.GetCount(); ++i) text[i] = wxStringToXmString (items[i]); if ( clientData ) for (i = 0; i < items.GetCount(); ++i) m_clientDataDict.Set(i, (wxClientData*)clientData[i], false); XmListAddItems (listBox, text, items.GetCount(), 0); for (i = 0; i < items.GetCount(); i++) XmStringFree (text[i]); delete[] text; // It seems that if the list is cleared, we must re-ask for // selection policy!! SetSelectionPolicy(); if (managed) XtManageChild (listBox); sk.Restore(); m_noItems = items.GetCount(); }
void emf_display_external_id_type_poplist (Widget w, XtPointer client_data, XmPushButtonCallbackStruct *call_data) { if (emf_idinfo_poplist_shell == NULL) create_emf_idinfo_poplist_shell (emf_iddetail_shell); /* Populate the list */ XmListDeleteAllItems (emf_idinfo_poplist); XmListAddItems (emf_idinfo_poplist,cmf_external_id_type_strings,num_cmf_external_id_type_codes,0); /* Set the text field that will be populated when user selects * a value from the list. */ XtVaSetValues (emf_idinfo_poplist, XmNuserData, emf_iddetail_source_txt, NULL); position_poplist (w,emf_idinfo_poplist); XtManageChild (emf_idinfo_poplist_form); XtPopup (emf_idinfo_poplist_shell, XtGrabNone); XmProcessTraversal (emf_idinfo_poplist,XmTRAVERSE_CURRENT); }
/* * Parse through the fontlist data and set up the three scroll lists. The fix * parameter can be used to exclude a list from any changes. This is used for * updates after selections caused by the users actions. */ static void fill_lists(enum ListSpecifier fix, SharedFontSelData *data) { char *list[NONE][MAX_ENTRIES_IN_LIST]; int count[NONE]; char buf[TEMP_BUF_SIZE]; XmString items[MAX_ENTRIES_IN_LIST]; int i; int idx; for (idx = (int)ENCODING; idx < (int)NONE; ++idx) count[idx] = 0; /* First we insert the wild char into every single list. */ if (fix != ENCODING) add_to_list(list[ENCODING], wild, &count[ENCODING]); if (fix != NAME) add_to_list(list[NAME], wild, &count[NAME]); if (fix != STYLE) add_to_list(list[STYLE], wild, &count[STYLE]); if (fix != SIZE) add_to_list(list[SIZE], wild, &count[SIZE]); for (i = 0; i < data->num && i < MAX_ENTRIES_IN_LIST; i++) { if (proportional(fn(data, i))) continue; if (fix != ENCODING && match(data, NAME, i) && match(data, STYLE, i) && match(data, SIZE, i)) { encoding_part(fn(data, i), buf); add_to_list(list[ENCODING], buf, &count[ENCODING]); } if (fix != NAME && match(data, ENCODING, i) && match(data, STYLE, i) && match(data, SIZE, i)) { name_part(fn(data, i), buf); add_to_list(list[NAME], buf, &count[NAME]); } if (fix != STYLE && match(data, ENCODING, i) && match(data, NAME, i) && match(data, SIZE, i)) { style_part(fn(data, i), buf); add_to_list(list[STYLE], buf, &count[STYLE]); } if (fix != SIZE && match(data, ENCODING, i) && match(data, NAME, i) && match(data, STYLE, i)) { size_part(fn(data, i), buf, data->in_pixels); add_to_list(list[SIZE], buf, &count[SIZE]); } } /* * And now do the preselection in all lists where there was one: */ if (fix != ENCODING) { Cardinal n_items; WidgetList children; Widget selected_button = 0; /* Get and update the current button list. */ XtVaGetValues(data->encoding_pulldown, XmNchildren, &children, XmNnumChildren, &n_items, NULL); for (i = 0; i < count[ENCODING]; ++i) { Widget button; items[i] = XmStringCreateLocalized(list[ENCODING][i]); if (i < (int)n_items) { /* recycle old button */ XtVaSetValues(children[i], XmNlabelString, items[i], XmNuserData, i, NULL); button = children[i]; } else { /* create a new button */ button = XtVaCreateManagedWidget("button", xmPushButtonGadgetClass, data->encoding_pulldown, XmNlabelString, items[i], XmNuserData, i, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) encoding_callback, (XtPointer) data); XtManageChild(button); } if (data->sel[ENCODING]) { if (!strcmp(data->sel[ENCODING], list[ENCODING][i])) selected_button = button; } XtFree(list[ENCODING][i]); } /* Destroy all the outstanding menu items. */ for (i = count[ENCODING]; i < (int)n_items; ++i) { XtUnmanageChild(children[i]); XtDestroyWidget(children[i]); } /* Preserve the current selection visually. */ if (selected_button) { XtVaSetValues(data->encoding_menu, XmNmenuHistory, selected_button, NULL); } for (i = 0; i < count[ENCODING]; ++i) XmStringFree(items[i]); } /* * Now loop trough the remaining lists and set them up. */ for (idx = (int)NAME; idx < (int)NONE; ++idx) { Widget w; if (fix == (enum ListSpecifier)idx) continue; switch ((enum ListSpecifier)idx) { case NAME: w = data->list[NAME]; break; case STYLE: w = data->list[STYLE]; break; case SIZE: w = data->list[SIZE]; break; default: w = (Widget)0; /* for lint */ } for (i = 0; i < count[idx]; ++i) { items[i] = XmStringCreateLocalized(list[idx][i]); XtFree(list[idx][i]); } XmListDeleteAllItems(w); XmListAddItems(w, items, count[idx], 1); if (data->sel[idx]) { XmStringFree(items[0]); items[0] = XmStringCreateLocalized(data->sel[idx]); XmListSelectItem(w, items[0], False); XmListSetBottomItem(w, items[0]); } for (i = 0; i < count[idx]; ++i) XmStringFree(items[i]); } }
static void CreateComboBoxes(Widget parent) { Widget titleLabel, comboBox, list; XmString *valueXmstrings, *colorXmstrings; int numValueStrings, numColorStrings; XmString labelString, xmString; Arg args[20]; int i, n; /* Create value compound strings */ numValueStrings = XtNumber(comboValueStrings); valueXmstrings = (XmString *)XtMalloc(numValueStrings * sizeof(XmString*)); for (i = 0; i < numValueStrings; i++) { valueXmstrings[i] = XmStringCreateLocalized(comboValueStrings[i]); } /* Create color compound strings */ numColorStrings = XtNumber(colorStrings); colorXmstrings = (XmString *)XtMalloc(numColorStrings * sizeof(XmString*)); for (i = 0; i < numColorStrings; i++) { colorXmstrings[i] = XmStringCreateLocalized(colorStrings[i]); } /* Create title label */ labelString = XmStringCreateLocalized("ComboBox Widget"); n = 0; XtSetArg(args[n], XmNlabelString, labelString); n++; titleLabel = XmCreateLabel(parent, "title", args, n); XtManageChild(titleLabel); XmStringFree(labelString); /* * Create an editable ComboBox containing the color strings. * Get the widget id of the drop down list, add some greek * letter names to it, and make more items visible. */ n = 0; XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++; XtSetArg(args[n], DtNitems, colorXmstrings); n++; XtSetArg(args[n], DtNitemCount, numColorStrings); n++; XtSetArg(args[n], DtNvisibleItemCount, 5); n++; XtSetArg(args[n], DtNcolumns, 10); n++; comboBox = DtCreateComboBox(parent, "comboBox1", args, n); XtManageChild(comboBox); list = XtNameToWidget(comboBox, "*List"); XmListAddItems(list, valueXmstrings, 10, 0); XtVaSetValues(list, XmNvisibleItemCount, 10, NULL); /* * Create an editable ComboBox with no entries. * Get the widget id of the drop down list, add some greek * letter names to it and select the third item in the list. */ n = 0; XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++; XtSetArg(args[n], DtNorientation, DtLEFT); n++; XtSetArg(args[n], DtNcolumns, 10); n++; comboBox = DtCreateComboBox(parent, "comboBox2", args, n); XtManageChild(comboBox); list = XtNameToWidget(comboBox, "*List"); XmListAddItems(list, valueXmstrings, 7, 0); XtVaSetValues(list, XmNvisibleItemCount, 7, NULL); XtVaSetValues(comboBox, DtNselectedPosition, 3, NULL); /* * Create a non-editable ComboBox containing some greek letter names. * Position the arrow on the left. * Select the 'gamma' item in the list. */ n = 0; XtSetArg(args[n], DtNorientation, DtLEFT); n++; XtSetArg(args[n], DtNitems, valueXmstrings); n++; XtSetArg(args[n], DtNitemCount, numValueStrings); n++; XtSetArg(args[n], DtNvisibleItemCount, 8); n++; comboBox = DtCreateComboBox(parent, "comboBox3", args, n); XtManageChild(comboBox); xmString = XmStringCreateLocalized("gamma"); XtVaSetValues(comboBox, DtNselectedItem, xmString, NULL); XmStringFree(xmString); /* * Create a non-editable ComboBox with no entries. * Position the arrow on the right. * Add the greek letter names to the list and select the fourth item. */ n = 0; XtSetArg(args[n], DtNorientation, DtRIGHT); n++; XtSetArg(args[n], DtNvisibleItemCount, 8); n++; comboBox = DtCreateComboBox(parent, "comboBox4", args, n); XtManageChild(comboBox); for (i = 0; i < numValueStrings; i++) { DtComboBoxAddItem(comboBox, valueXmstrings[i], 0, True); } XtVaSetValues(comboBox, DtNselectedPosition, 4, NULL); /* * Free value and color strings, ComboBox has taken a copy. */ for (i = 0; i < numValueStrings; i++) { XmStringFree(valueXmstrings[i]); } XtFree((char*)valueXmstrings); for (i = 0; i < numColorStrings; i++) { XmStringFree(colorXmstrings[i]); } XtFree((char*)colorXmstrings); }
/*********************************************************************** * * * Show (manage) the column selector dialog. * * * ***********************************************************************/ void show_columnSelector(Widget w, XtPointer cd, XmAnyCallbackStruct *call_data) { MenuCbStruct *scan_button; int icnt; XmString *items; if (!selector_dialog) { selector_dialog = create_columnSelection(w); /* * Install callbacks */ scan_button = make_menuStruct(w, selector_dialog); InstallMwmCloseCallback(XtParent(selector_dialog), (XtCallbackProc)cancel_cb, (XtPointer)scan_button); /* * Install event handler on EnterNotify events */ XtAddEventHandler(XtParent(selector_dialog), EnterWindowMask, False, (XtEventHandler)enter_ntuple_viewer, NULL); XtAddCallback(exprNtSText, XmNactivateCallback, (XtCallbackProc)copy_cb, NULL); XtAddCallback(copyNtSButton, XmNactivateCallback, (XtCallbackProc)copy_cb, NULL); XtAddCallback(copyAllNtSButton, XmNactivateCallback, (XtCallbackProc)copy_cb, NULL); XtAddCallback(var1NtSList, XmNdefaultActionCallback, (XtCallbackProc)copy_cb, NULL); XtAddCallback(scanNtSButton, XmNactivateCallback, (XtCallbackProc)show_ntupleScanner, NULL); XtAddCallback(deleteNtSButton, XmNactivateCallback, (XtCallbackProc)reset_cb, NULL); XtAddCallback(resetNtSButton, XmNactivateCallback, (XtCallbackProc)reset_cb, NULL); XtAddCallback(cancelNtSButton, XmNactivateCallback, (XtCallbackProc)cancel_cb, scan_button); /* store MenuCbSruct in userData */ XtVaSetValues(selector_dialog, XmNuserData, scan_button, NULL); } /* clear left list */ XmListSetPos(var1NtSList, 1); XmListDeselectAllItems(var1NtSList); XmListDeleteAllItems(var1NtSList); /* * Copy var list from ntupleBrowser to left list of columnSelection * dialog. In case there are no variables in the ntupleBrowser return. */ XtVaGetValues(varNtList, XmNitemCount, &icnt, XmNitems, &items, NULL); if (!icnt) return; XmListAddItems(var1NtSList, items, icnt, 1); XmListSelectPos(var1NtSList, 1, False); /* Make scan button on ntupleBrowser insensitive and popup dialog */ XtSetSensitive(w, False); XtManageChild(selector_dialog); }
EIF_POINTER font_box_create (char * a_name, EIF_POINTER a_parent, EIF_BOOLEAN dialog) { Widget form, select_form, mode_option; Widget mode_menu, stand_fonts_button, non_stand_fonts_button; Widget non_stand_list; Widget stand_column, frame; Widget form_button; Widget ok_button, apply_button, cancel_button; Widget family_menu_b, weight_menu_b, slant_menu_b; Widget width_menu_b, point_menu_b, resolution_menu_b; Widget family_menu, weight_menu, slant_menu; Widget width_menu, point_menu, resolution_menu; Widget text; Widget *family_menu_buttons; Widget *weight_menu_buttons; Widget *slant_menu_buttons; Widget *width_menu_buttons; Widget *point_menu_buttons; Widget *resolution_menu_buttons; font_box_data * client; XmString string; Display * display; int number_fonts; char ** fonts_list; char ** non_stand_fonts_list; int number_non_stand, number_stand; XmString * non_stand_strings; font_box_font_info ** stand_fonts_list; int i, j; char * tmp_string; XmString tmp_xm_string; char **family_menu_list; char **weight_menu_list; char **slant_menu_list; char **width_menu_list; char **point_menu_list; char **resolution_menu_list; int number_family, number_weight, number_slant; int number_width, number_point, number_resolution; /* * Creation of form dialog */ if (dialog) { form = XmCreateFormDialog ((Widget) a_parent, (String) a_name, NULL, 0); XtVaSetValues (form, XmNautoUnmanage, False, NULL); } else form = XmCreateForm ((Widget) a_parent, (String) a_name, NULL, 0); /* * Creation of sub-widgets */ select_form = XmCreateForm (form, "selectForm", NULL, 0); XtManageChild (select_form); text = XmCreateText (form, "text", NULL, 0); XtManageChild (text); form_button = XmCreateForm (form, "buttonsForm", NULL, 0); XtManageChild (form_button); mode_option = XmCreateOptionMenu (select_form, "switchOption", NULL, 0); XtManageChild (mode_option); mode_menu = XmCreatePulldownMenu (select_form, "switchMenu", NULL, 0); stand_fonts_button = XmCreatePushButtonGadget (mode_menu, "standFont", NULL, 0); XtManageChild (stand_fonts_button); non_stand_fonts_button = XmCreatePushButtonGadget (mode_menu, "nonStandFont", NULL, 0); XtManageChild (non_stand_fonts_button); /* * Creation of non-standard font selection system */ non_stand_list = XmCreateScrolledList (select_form, "nonStandList", NULL, 0); XtManageChild (non_stand_list); /* * Creation of standard font selection system */ frame = XmCreateFrame (select_form, "standFrame", NULL, 0); XtManageChild (frame); stand_column = XmCreateRowColumn (frame, "standColumn", NULL, 0); XtManageChild (stand_column); family_menu_b = XmCreateOptionMenu (stand_column, "familyMenuButton", NULL, 0); XtManageChild (family_menu_b); weight_menu_b = XmCreateOptionMenu (stand_column, "weightMenuButton", NULL, 0); XtManageChild (weight_menu_b); slant_menu_b = XmCreateOptionMenu (stand_column, "slantMenuButton", NULL, 0); XtManageChild (slant_menu_b); width_menu_b = XmCreateOptionMenu (stand_column, "widthMenuButton", NULL, 0); XtManageChild (width_menu_b); point_menu_b = XmCreateOptionMenu (stand_column, "pointMenuButton", NULL, 0); XtManageChild (point_menu_b); resolution_menu_b = XmCreateOptionMenu (stand_column, "resolutionMenuButton", NULL, 0); XtManageChild (resolution_menu_b); family_menu = XmCreatePulldownMenu (stand_column, "familyMenu", NULL, 0); weight_menu = XmCreatePulldownMenu (stand_column, "weightMenu", NULL, 0); slant_menu = XmCreatePulldownMenu (stand_column, "slantMenu", NULL, 0); width_menu = XmCreatePulldownMenu (stand_column, "widthMenu", NULL, 0); point_menu = XmCreatePulldownMenu (stand_column, "pointMenu", NULL, 0); resolution_menu = XmCreatePulldownMenu (stand_column, "resolutionMenu", NULL, 0); /* * Creation of buttons */ ok_button = XmCreatePushButtonGadget (form_button, "Ok", NULL, 0); XtManageChild (ok_button); apply_button = XmCreatePushButtonGadget (form_button, "Apply", NULL, 0); XtManageChild (apply_button); cancel_button = XmCreatePushButtonGadget (form_button, "Cancel", NULL, 0); XtManageChild (cancel_button); /* * Attachments in font selection system */ AttachTop (mode_option, 0); AttachLeft (mode_option, 0); AttachRight (mode_option, 0); /* * Attachments in non-standard font selection system */ AttachTopWidget (mode_option, XtParent (non_stand_list), 5); AttachLeft (XtParent (non_stand_list), 0); AttachRight (XtParent (non_stand_list), 0); AttachBottom (XtParent (non_stand_list), 0); /* * Attachments in standard font selection system */ AttachTopWidget (mode_option, frame, 5); AttachLeft (frame, 0); AttachRight (frame, 0); AttachBottom (frame, 0); /* * Attachments in buttons form */ XtVaSetValues (form_button, XmNfractionBase, 6, NULL); AttachTop (ok_button, 0); AttachBottom (ok_button, 0); AttachTop (apply_button, 0); AttachBottom (apply_button, 0); AttachTop (cancel_button, 0); AttachBottom (cancel_button, 0); /* * Attachments in global form */ AttachTop (select_form, 10); AttachLeft (select_form, 10); AttachRight (select_form, 10); AttachTopWidget (select_form, text, 10); AttachLeft (text, 10); AttachRight (text, 10); AttachBottomWidget (form_button, text, 10); AttachLeft (form_button, 10); AttachRight (form_button, 10); AttachBottom (form_button, 10); /* * Default values */ XtVaSetValues (family_menu_b, XmNsubMenuId, family_menu, NULL); XtVaSetValues (weight_menu_b, XmNsubMenuId, weight_menu, NULL); XtVaSetValues (slant_menu_b, XmNsubMenuId, slant_menu, NULL); XtVaSetValues (width_menu_b, XmNsubMenuId, width_menu, NULL); XtVaSetValues (point_menu_b, XmNsubMenuId, point_menu, NULL); XtVaSetValues (resolution_menu_b, XmNsubMenuId, resolution_menu, NULL); XmTextSetString (text, "Current_selected_font"); XtVaSetValues (text, XmNresizeHeight, True, XmNeditMode, XmMULTI_LINE_EDIT, NULL); XtVaSetValues (XtParent (non_stand_list), XmNmappedWhenManaged, False, NULL); string = XmStringCreateLtoR ("Non standard fonts", XmSTRING_DEFAULT_CHARSET); XtVaSetValues (non_stand_fonts_button, XmNlabelString, string, NULL); XmStringFree (string); string = XmStringCreateLtoR ("Standard fonts", XmSTRING_DEFAULT_CHARSET); XtVaSetValues (stand_fonts_button, XmNlabelString, string, NULL); XmStringFree (string); XtVaSetValues (mode_option, XmNsubMenuId, mode_menu, NULL); XtVaSetValues (mode_option, XmNmenuHistory, stand_fonts_button, NULL); /* * Callbacks */ client = (font_box_data *) cmalloc (sizeof (font_box_data)); XtAddCallback (non_stand_list, XmNbrowseSelectionCallback, (XtCallbackProc) font_box_select_non_stand, client); XtAddCallback (stand_fonts_button, XmNactivateCallback, (XtCallbackProc) font_box_switch_to_stand, client); XtAddCallback (non_stand_fonts_button, XmNactivateCallback, (XtCallbackProc) font_box_switch_to_non_stand, client); XtAddCallback (form, XmNdestroyCallback, (XtCallbackProc) font_box_destroy_action, client); /* * Fill the client structure */ client->non_stand_list = non_stand_list; client->is_stand_mode = 1; client->frame = frame; client->text = text; client->family_menu_b = family_menu_b; client->weight_menu_b = weight_menu_b; client->slant_menu_b = slant_menu_b; client->width_menu_b = width_menu_b; client->point_menu_b = point_menu_b; client->resolution_menu_b = resolution_menu_b; client->form = form; client->ok_button = ok_button; client->apply_button = apply_button; client->cancel_button = cancel_button; client->buttons_shown = 7; client->stand_fonts_button = stand_fonts_button; client->non_stand_fonts_button = non_stand_fonts_button; font_box_attach_buttons (client); /* * Get the font list of current display */ display = XtDisplay (form); fonts_list = XListFonts (display, "*", 10000, &number_fonts); /* * Get the non standard fonts */ number_non_stand = 0; for (i = 0; i < number_fonts; i++) if ('-' != *(fonts_list [i])) number_non_stand++; non_stand_strings = (XmString *) cmalloc (number_non_stand*sizeof (XmString)); non_stand_fonts_list = (char **) cmalloc (number_non_stand*sizeof (char *)); for (i = j = 0; i < number_fonts; i++) if ('-' != *(fonts_list [i])) { non_stand_fonts_list [j] = fonts_list [i]; non_stand_strings [j++] = XmStringCreate (fonts_list [i], XmSTRING_DEFAULT_CHARSET); } i = 1; while (i) for (j = i = 0; j < number_non_stand-1; j++) if (strcmp (non_stand_fonts_list [j], non_stand_fonts_list [j+1]) > 0) { i = 1; tmp_string = non_stand_fonts_list [j]; non_stand_fonts_list [j] = non_stand_fonts_list [j+1]; non_stand_fonts_list [j+1] = tmp_string; tmp_xm_string = non_stand_strings [j]; non_stand_strings [j] = non_stand_strings [j+1]; non_stand_strings [j+1] = tmp_xm_string; } XmListAddItems (non_stand_list, non_stand_strings, number_non_stand, 1); XmListSelectPos (non_stand_list, 1, False); /* * Get the standard fonts */ number_stand = number_fonts-number_non_stand; stand_fonts_list = (font_box_font_info **) cmalloc (number_stand*sizeof (font_box_font_info *)); for (i = j = 0; i < number_fonts; i++) if ('-' == *(fonts_list [i])) { stand_fonts_list [j++] = font_box_create_font_info (fonts_list [i]); } number_family = 0; number_weight = 0; number_slant = 0; number_width = 0; number_point = 0; number_resolution = 0; for (i = 0; i < number_stand; i++) { font_box_put_item (&(stand_fonts_list [i]->family), &number_family, &family_menu_list); font_box_put_item (&(stand_fonts_list [i]->weight), &number_weight, &weight_menu_list); font_box_put_item (&(stand_fonts_list [i]->slant), &number_slant, &slant_menu_list); font_box_put_item (&(stand_fonts_list [i]->width), &number_width, &width_menu_list); font_box_put_item (&(stand_fonts_list [i]->point), &number_point, &point_menu_list); font_box_put_item (&(stand_fonts_list [i]->resolution), &number_resolution, &resolution_menu_list); } font_box_sort_alpha (&number_family, &family_menu_list); font_box_sort_alpha (&number_weight, &weight_menu_list); font_box_sort_alpha (&number_slant, &slant_menu_list); font_box_sort_alpha (&number_width, &width_menu_list); font_box_sort_num (&number_point, &point_menu_list); font_box_sort_alpha (&number_resolution, &resolution_menu_list); font_box_fill_menu (&family_menu_buttons, family_menu, &number_family, &family_menu_list); font_box_fill_menu (&weight_menu_buttons, weight_menu, &number_weight, &weight_menu_list); font_box_fill_menu (&slant_menu_buttons, slant_menu, &number_slant, &slant_menu_list); font_box_fill_menu (&width_menu_buttons, width_menu, &number_width, &width_menu_list); font_box_fill_menu (&point_menu_buttons, point_menu, &number_point, &point_menu_list); font_box_fill_menu (&resolution_menu_buttons, resolution_menu, &number_resolution, &resolution_menu_list); for (i = 0; i < number_family; i++) XtAddCallback (family_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_family, client); for (i = 0; i < number_weight; i++) XtAddCallback (weight_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_weight, client); for (i = 0; i < number_slant; i++) XtAddCallback (slant_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_slant, client); for (i = 0; i < number_width; i++) XtAddCallback (width_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_width, client); for (i = 0; i < number_point; i++) XtAddCallback (point_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_point, client); for (i = 0; i < number_resolution; i++) XtAddCallback (resolution_menu_buttons [i], XmNactivateCallback, (XtCallbackProc) font_box_set_resolution, client); /* * Fill the client structure */ client->non_stand_fonts_list = non_stand_fonts_list; client->stand_fonts_list = stand_fonts_list; client->current_font_name = non_stand_fonts_list [0]; client->current_stand_font = 0; client->current_non_stand_font = 0; client->family_menu_buttons = family_menu_buttons; client->weight_menu_buttons = weight_menu_buttons; client->slant_menu_buttons = slant_menu_buttons; client->width_menu_buttons = width_menu_buttons; client->point_menu_buttons = point_menu_buttons; client->resolution_menu_buttons = resolution_menu_buttons; client->family_menu_list = family_menu_list; client->weight_menu_list = weight_menu_list; client->slant_menu_list = slant_menu_list; client->width_menu_list = width_menu_list; client->point_menu_list = point_menu_list; client->resolution_menu_list = resolution_menu_list; client->number_stand = number_stand; client->number_family = number_family; client->number_weight = number_weight; client->number_slant = number_slant; client->number_width = number_width; client->number_point = number_point; client->number_resolution = number_resolution; client->current_font = NULL; client->current_family = client->current_weight = client->current_slant = -1; client->current_width = client->current_point = client->current_resolution = -1; font_box_set_family (family_menu_buttons [0], client, NULL); return (EIF_POINTER) client; }
static void setupScrollLists(int dontChange, xfselControlBlkType ctrlBlk) { char *itemBuf1[MAX_ENTRIES_IN_LIST]; char *itemBuf2[MAX_ENTRIES_IN_LIST]; char *itemBuf3[MAX_ENTRIES_IN_LIST]; int itemCount1, itemCount2, itemCount3; char buff1[TEMP_BUF_SIZE]; XmString items[MAX_ENTRIES_IN_LIST]; int i; itemCount1 = 0; itemCount2 = 0; itemCount3 = 0; for (i = 0; i < ctrlBlk.numFonts && i < MAX_ENTRIES_IN_LIST; i++) { if ((dontChange != FONT) && (styleMatch(&ctrlBlk, ctrlBlk.fontData[i])) && (sizeMatch (&ctrlBlk, ctrlBlk.fontData[i])) && ((ctrlBlk.showPropFonts == PREF_PROP) || (notPropFont(ctrlBlk.fontData[i])))) { getFontPart(ctrlBlk.fontData[i], buff1); addItemToList(itemBuf1, buff1, &itemCount1); } if ((dontChange != STYLE) && (fontMatch(&ctrlBlk, ctrlBlk.fontData[i])) && (sizeMatch (&ctrlBlk, ctrlBlk.fontData[i])) && ((ctrlBlk.showPropFonts == PREF_PROP) || (notPropFont(ctrlBlk.fontData[i])))) { getStylePart(ctrlBlk.fontData[i], buff1); addItemToList(itemBuf2, buff1, &itemCount2); } if ((dontChange != SIZE) && (fontMatch(&ctrlBlk, ctrlBlk.fontData[i])) && (styleMatch (&ctrlBlk, ctrlBlk.fontData[i])) && ((ctrlBlk.showPropFonts == PREF_PROP) || (notPropFont(ctrlBlk.fontData[i])))) { getSizePart(ctrlBlk.fontData[i], buff1, ctrlBlk.showSizeInPixels); addItemToList(itemBuf3, buff1, &itemCount3); } } /* end - for (i = 0; i < ctrlBlk.numFonts; i++) */ /* recreate all three scroll lists where necessary */ if (dontChange != FONT) { for (i = 0; i < itemCount1; i++) { items[i] = XmStringCreate(itemBuf1[i], XmSTRING_DEFAULT_CHARSET); XtFree(itemBuf1[i]); } XmListDeleteAllItems(ctrlBlk.fontList); XmListAddItems(ctrlBlk.fontList, items, itemCount1, 1); if (ctrlBlk.sel1 != NULL) { XmStringFree(items[0]); items[0] = XmStringCreate(ctrlBlk.sel1, XmSTRING_DEFAULT_CHARSET); XmListSelectItem(ctrlBlk.fontList, items[0], FALSE); XmListSetBottomItem(ctrlBlk.fontList, items[0]); } for (i = 0; i < itemCount1; i++) XmStringFree(items[i]); } if (dontChange != STYLE) { for (i = 0; i < itemCount2; i++) { items[i] = XmStringCreate(itemBuf2[i], XmSTRING_DEFAULT_CHARSET); XtFree(itemBuf2[i]); } XmListDeleteAllItems(ctrlBlk.styleList); XmListAddItems(ctrlBlk.styleList, items, itemCount2, 1); if (ctrlBlk.sel2 != NULL) { XmStringFree(items[0]); items[0] = XmStringCreate(ctrlBlk.sel2, XmSTRING_DEFAULT_CHARSET); XmListSelectItem(ctrlBlk.styleList, items[0], FALSE); XmListSetBottomItem(ctrlBlk.styleList, items[0]); } for (i = 0; i < itemCount2; i++) XmStringFree(items[i]); } if (dontChange != SIZE) { for (i = 0; i < itemCount3; i++) { items[i] = XmStringCreate(itemBuf3[i], XmSTRING_DEFAULT_CHARSET); XtFree(itemBuf3[i]); } XmListDeleteAllItems(ctrlBlk.sizeList); XmListAddItems(ctrlBlk.sizeList, items, itemCount3, 1); if (ctrlBlk.sel3 != NULL) { XmStringFree(items[0]); items[0] = XmStringCreate(ctrlBlk.sel3, XmSTRING_DEFAULT_CHARSET); XmListSelectItem(ctrlBlk.sizeList, items[0], FALSE); XmListSetBottomItem(ctrlBlk.sizeList, items[0]); } for (i = 0; i < itemCount3; i++) XmStringFree(items[i]); } }