void iupdrvListRemoveItem(Ihandle* ih, int pos) { /* The utility functions use 0=last 1=first */ if (ih->data->is_dropdown || ih->data->has_editbox) { if (ih->data->is_dropdown && !ih->data->has_editbox) { /* must check if removing the current item */ int curpos; XtVaGetValues(ih->handle, XmNselectedPosition, &curpos, NULL); if (pos == curpos && iupdrvListGetCount(ih)>1) { if (curpos > 0) curpos--; else curpos++; XtRemoveCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih); XtVaSetValues(ih->handle, XmNselectedPosition, curpos, NULL); XtAddCallback(ih->handle, XmNselectionCallback, (XtCallbackProc)motListComboBoxSelectionCallback, (XtPointer)ih); } } XmComboBoxDeletePos(ih->handle, pos+1); } else XmListDeletePos(ih->handle, pos+1); iupListUpdateOldValue(ih, pos, 1); }
/* * Remove the name from the UI and from the list if the calendar handle is NULL. * If the calendar handle is not null, tag it as deleted and it will be taken * care of later. */ static void blist_removenames(Widget widget, XtPointer client_data, XtPointer call_data) { int i, idx, valid_cnt, *pos_list, pos_cnt; Calendar *c = (Calendar *)client_data; BlistData *bd = NULL; Browselist *bl = (Browselist *)c->browselist; int rejected_name = 0; set_message(bl->message, " "); XmListGetSelectedPos(bl->browse_list, &pos_list, &pos_cnt); if (pos_cnt <= 0) { set_message(bl->message, catgets(calendar->DT_catd, 1, 17, "Select a name to remove")); return; } for (i = 0; i < pos_cnt; i++) { if (pos_list[i] == 1) { set_message(bl->message, catgets(calendar->DT_catd, 1, 16, "You may not remove the default calendar")); rejected_name++; continue; } XmListDeletePos(bl->browse_list, pos_list[i] - i + rejected_name); bd = (BlistData *)CmDataListGetData(bl->blist_data, pos_list[i]); if (bd) { bd->tag = BLIST_DELETE; } } blist_clean(bl, False); bl_list_is_changed(bl); }
/* Kill a single mo_node associated with a given mo_window; it the history list exists we delete it from that. In any case we call mo_free_node_data and return. */ mo_status mo_kill_node (mo_window *win, mo_node *node) { if (win->history_list) XmListDeletePos (win->history_list, node->position); mo_free_node_data (node); return mo_succeed; }
void wxListBox::Delete(unsigned int n) { Widget listBox = (Widget) m_mainWidget; XmListDeletePos (listBox, n + 1); m_clientDataDict.Delete(n, HasClientObjectData()); m_noItems --; }
/* ARGSUSED */ void GpDelete_Callback ( Widget widget, XtPointer clnt, XmListCallbackStruct *list_data ) { int nselect; /*------------------------------------------------------------------*/ /* * return when no selection was made */ XtVaGetValues(ggroup_listW, XmNselectedItemCount, &nselect, NULL); if ( nselect == 0 ) return; if (SelectGroupNo) { XmListDeletePos(group_listW,SelectGroupNo); XmListDeletePos(ggroup_listW,SelectGroupNo); change_group(SelectGroupNo); GroupNo --; } }
void XmCommandError(Widget w, XmString error) { if (Com_Error(w)) { DEBUGOUT(_LtDebug(__FILE__, w, "Error Condition detected")); XmListDeletePos(SB_List(w), 0); } XmListAddItemUnselected(SB_List(w), error, 0); Com_Error(w) = True; }
void wxListBox::SetString(unsigned int n, const wxString& s) { wxSizeKeeper sk( this ); Widget listBox = (Widget) m_mainWidget; wxXmString text( s ); // delete the item and add it again. // FIXME isn't there a way to change it in place? XmListDeletePos (listBox, n+1); XmListAddItem (listBox, text(), n+1); sk.Restore(); }
void wxListBox::Delete(int N) { wxSizeKeeper sk( this ); Widget listBox = (Widget) m_mainWidget; bool managed = XtIsManaged(listBox); if (managed) XtUnmanageChild (listBox); XmListDeletePos (listBox, N + 1); if (managed) XtManageChild (listBox); sk.Restore(); m_clientDataDict.Delete(N, HasClientObjectData()); m_noItems --; }
void AliasListUiItem::handleDeleteButtonPress() { Widget list_widget = this->getWidget(); int *p_list, p_count; // get the selected position if(XmListGetSelectedPos(list_widget, &p_list, &p_count)) { if(deleted_items == NULL) { deleted_items = new DtVirtArray<char *>(10); } deleted_items->append(strdup((*list_items)[p_list[0] -1]->label)); // delete the item from our list this->list_items->remove(p_list[0] - 1); // remove only first // delete the item from the widget XmListDeletePos(list_widget, p_list[0]); XtVaSetValues(this->getKeyWidget(), XmNvalue,"", NULL); XtVaSetValues(this->getValueWidget(), XmNvalue,"", NULL); XmListSelectPos(list_widget, p_list[0], TRUE); props_changed = TRUE; } }
/*ARGSUSED*/ static void Initialize( Widget rw, /* unused */ Widget nw, ArgList args, /* unused */ Cardinal *num_args ) /* unused */ { XmCommandWidget new_w = (XmCommandWidget) nw ; int max; Arg argv[5] ; Cardinal argc ; /****************/ /* Here we have now to take care of XmUNSPECIFIED (CR 4856). */ if (new_w->selection_box.selection_label_string == (XmString) XmUNSPECIFIED) { XmString local_xmstring ; local_xmstring = XmStringCreate(">", XmFONTLIST_DEFAULT_TAG); argc = 0 ; XtSetArg( argv[argc], XmNlabelString, local_xmstring) ; ++argc ; XtSetValues( SB_SelectionLabel( new_w), argv, argc) ; XmStringFree(local_xmstring); new_w->selection_box.selection_label_string = NULL ; } /* mustMatch does not apply to command... (it is always false) */ if (new_w->selection_box.must_match != False) { new_w->selection_box.must_match = False; XmeWarning( (Widget) new_w, WARNING5); } /* check for and change max history items (remove items if needed) */ if (new_w->command.history_max_items < 1) { new_w->command.history_max_items = 100; XmeWarning( (Widget) new_w, WARNING6); } argc = 0 ; XtSetArg( argv[argc], XmNitemCount, &max) ; ++argc ; XtGetValues( SB_List( new_w), argv, argc) ; if (new_w->command.history_max_items < max) { while (max > new_w->command.history_max_items) { XmListDeletePos (new_w->selection_box.list, 1); if (new_w->selection_box.list_selected_item_position > 0) new_w->selection_box.list_selected_item_position--; max--; } } if (new_w->selection_box.dialog_type != XmDIALOG_COMMAND) { new_w->selection_box.dialog_type = XmDIALOG_COMMAND ; XmeWarning( (Widget) new_w, WARNING1); } XtAddCallback (new_w->selection_box.text, XmNvalueChangedCallback, CommandCallback, (XtPointer) new_w); new_w->command.error = FALSE; return ; }
void appIcon_AddRemoveItem(Widget wList, struct Broadcast_Packet* p_Item, char m_Option, XtPointer xtLabel) { XmString xstr_item; XmStringTable xstr_list; int mFound = 0; int mIdx = 0; int mCount; char str_Item[150]; char* text; char* test; char str_Count[4]; if(strlen(p_Item->Handlename) == 0) { sprintf(str_Item, "%s@%s (%s)", p_Item->Username, p_Item->Hostname, p_Item->IP_Address); } else { sprintf(str_Item, "%s@%s (%s)", p_Item->Handlename, p_Item->Hostname, p_Item->IP_Address); } // Get the current entries (and number of entries) from the List XtVaGetValues (wList, XmNitemCount, &mCount, XmNitems, &xstr_list, NULL); xstr_item = XmStringCreateLocalized (str_Item); if(m_Option == 1) { while(mCount>mIdx) { if(XmStringCompare(xstr_item, xstr_list[mIdx])) { mFound = 1; break; } mIdx++; } if(mFound == 0) { mIdx = 0; while(mCount>mIdx) { text = (char *) XmStringUnparse (xstr_list[mIdx], NULL,XmCHARSET_TEXT, XmCHARSET_TEXT,NULL, 0, XmOUTPUT_ALL); if (strcmp (text, str_Item) > 0) { // str_Item comes before item XtFree(text); break; } XtFree(text); mIdx++; } mCount++; XmListAddItemUnselected (wList, xstr_item, mIdx+1); if(wList != APPICON_List_Users) { sprintf(str_Count, "%i", mCount); XtVaSetValues(*(Widget*)xtLabel, XmNvalue, str_Count, NULL); } } } else { while(mCount>mIdx) { text = (char *) XmStringUnparse (xstr_list[mIdx], NULL,XmCHARSET_TEXT, XmCHARSET_TEXT,NULL, 0, XmOUTPUT_ALL); if ((test = strstr(text, p_Item->IP_Address)) != '\0') { *(strchr(test,')')) = '\0'; if(strcmp(test, p_Item->IP_Address) == 0) { mFound = 1; XtFree(text); break; } } XtFree(text); mIdx++; } if(mFound == 1) { mCount--; XmListDeletePos(wList, mIdx+1); if(wList != APPICON_List_Users) { sprintf(str_Count, "%i", mCount); XtVaSetValues(*(Widget*)xtLabel, XmNvalue, str_Count, NULL); } } } XmStringFree (xstr_item); }
void __vi_pop_tag(void) { if ( ! active ) return; XmListDeletePos( db_list, 1 ); }
void location_delete(/*@unused@*/ Widget w, /*@unused@*/ XtPointer clientData, /*@unused@*/ XtPointer callData) { int i,x; char *location; XmString *list; int found,ok; FILE *f,*fout; char temp[200]; char name[100]; char pos[100]; char *temp_ptr; char filen[400]; char filen_bak[400]; char location_file_path[MAX_VALUE]; char location_sys_path[MAX_VALUE]; get_user_base_dir("config/locations.sys", location_file_path, sizeof(location_file_path)); get_user_base_dir("config/locations.sys-tmp", location_sys_path, sizeof(location_sys_path)); found=0; ok=0; XtVaGetValues(location_list,XmNitemCount,&i,XmNitems,&list,NULL); for (x=1; x<=i;x++) { if (XmListPosSelected(location_list,x)) { found=1; if (XmStringGetLtoR(list[(x-1)],XmFONTLIST_DEFAULT_TAG,&location)) { XmListDeletePos(location_list,x); x=i+1; } } } if(found) { f=fopen(location_file_path,"r"); if (f!=NULL) { fout=fopen(location_sys_path,"a"); if (fout!=NULL) { while (!feof(f)) { (void)get_line(f,temp,200); if (!feof(f) && strlen(temp)>8) { temp_ptr=strtok(temp,"|"); /* get the name */ if (temp_ptr!=NULL) { xastir_snprintf(name, sizeof(name), "%s", temp); temp_ptr=strtok(NULL,"|"); /* get the pos */ xastir_snprintf(pos, sizeof(pos), "%s", temp_ptr); if (strcmp(location,name)!=0) { fprintf(fout,"%s|%s\n",name,pos); } } } } (void)fclose(fout); ok=1; } else fprintf(stderr,"Couldn't open file: %s\n", location_sys_path ); (void)fclose(f); } else { fprintf(stderr,"Couldn't open file: %s\n", location_file_path ); } XtFree(location); } if (ok==1){ xastir_snprintf(filen, sizeof(filen), "%s", location_file_path); xastir_snprintf(filen_bak, sizeof(filen_bak), "%s", location_sys_path); (void)unlink(filen); (void)rename(filen_bak,filen); } }
/*ARGSUSED*/ static Boolean SetValues( Widget ow, Widget rw, /* unused */ Widget nw, ArgList args, /* unused */ Cardinal *num_args ) /* unused */ { XmCommandWidget old = (XmCommandWidget) ow ; XmCommandWidget new_w = (XmCommandWidget) nw ; int max; Arg argv[5] ; Cardinal argc ; /****************/ /* mustMatch does not apply to command... (it is always false) */ if (new_w->selection_box.must_match != False) { new_w->selection_box.must_match = False; XmeWarning( (Widget) new_w, WARNING5); } if (new_w->selection_box.dialog_type != XmDIALOG_COMMAND) { new_w->selection_box.dialog_type = XmDIALOG_COMMAND; XmeWarning( (Widget) new_w, WARNING1); } /* check for and change max history items (remove items if needed) */ if (new_w->command.history_max_items < 1) { new_w->command.history_max_items = old->command.history_max_items; XmeWarning( (Widget) new_w, WARNING6); } if (new_w->command.history_max_items < old->command.history_max_items) { argc = 0 ; XtSetArg( argv[argc], XmNitemCount, &max) ; ++argc ; XtGetValues( SB_List( new_w), argv, argc) ; while (max > new_w->command.history_max_items) { XmListDeletePos (new_w->selection_box.list, 1); if (new_w->selection_box.list_selected_item_position > 0) new_w->selection_box.list_selected_item_position--; max--; } } if (old->command.error) { XmString new_xms, old_xms; int new_count = new_w->selection_box.list_item_count; int old_count = old->selection_box.list_item_count; if (new_count > 2 && old_count > 2) { XmString new_blank, old_blank, new_error, old_error; new_error = new_w->selection_box.list_items[new_count-1]; old_error = old->selection_box.list_items[new_count-1]; new_blank = new_w->selection_box.list_items[new_count-2]; old_blank = old->selection_box.list_items[new_count-2]; if (XmStringCompare(new_error, old_error) && XmStringCompare(new_blank, old_blank)) { new_w->command.error = FALSE; #if 0 XmListDeletePos(SB_List(old), 0); /* Delete error message.*/ XmListDeletePos(SB_List(old), 0) ; /* Delete blank line.*/ old->command.error = FALSE ; #endif } } else new_w->command.error = FALSE; } /* require redisplay */ return(True); }
/*ARGSUSED*/ void _XmCommandReturn( Widget wid, XEvent *event, String *params, /* unused */ Cardinal *numParams ) /* unused */ { XmCommandWidget w = (XmCommandWidget) wid ; XmCommandCallbackStruct cb; XmString tmpXmString; String tmpString; Arg argv[5] ; Cardinal argc ; int count ; /****************/ /* if an error has been sent to the history list, remove it now */ if (w->command.error) { XmListDeletePos (w->selection_box.list, 0); /* delete error msg */ XmListDeletePos (w->selection_box.list, 0); /* delete blank line */ w->command.error = FALSE; XmListSetBottomPos (w->selection_box.list, 0); } /* update the history: - get text, check null/empty */ /* - create XmString from text */ /* - increment local list count */ /* - add to history list */ /* - delete first element if too */ /* many items (maxItemCount) */ /* - position list to end */ /* - reset selection list ptr */ /* - reset command to "" */ tmpString = XmTextFieldGetString (w->selection_box.text); if ((tmpString == NULL) || (strcmp(tmpString, "") == 0)) { if (tmpString) XtFree(tmpString); return; } argc = 0 ; XtSetArg( argv[argc], XmNitemCount, &count) ; ++argc ; XtGetValues( SB_List( w), argv, argc) ; /* if already at max items, remove first item in list */ if (count >= w->command.history_max_items) { XmListDeletePos (w->selection_box.list, 1); if (w->selection_box.list_selected_item_position > 0) w->selection_box.list_selected_item_position--; } tmpXmString = XmStringGenerate(tmpString, XmFONTLIST_DEFAULT_TAG, XmCHARSET_TEXT, NULL); XmListAddItemUnselected (w->selection_box.list, tmpXmString, 0); XmListSetBottomPos (w->selection_box.list, 0); XmTextFieldSetString (w->selection_box.text, ""); /* call the users command entered callback */ cb.reason = XmCR_COMMAND_ENTERED; cb.event = event; cb.value = tmpXmString; cb.length = XmStringLength (tmpXmString); XtCallCallbackList ((Widget) w, w->command.callback, &cb); XmStringFree (tmpXmString); XtFree (tmpString); return ; }
static void _XmCommandCallback(Widget w, XtPointer client, XtPointer call) { XmCommandCallbackStruct cbs; XmAnyCallbackStruct *p = (XmAnyCallbackStruct *)call; XmListCallbackStruct *l = (XmListCallbackStruct *) call; XmCommandWidget cw = (XmCommandWidget)XtParent(w); char *t; if (client != C_ACT) cw = (XmCommandWidget)XtParent(XtParent(w)); DEBUGOUT(_LtDebug(__FILE__, (Widget)cw, "_XmCommandCallback [%s]\n", (client == C_ACT) ? "TextField Activate" : "List Selection")); /* * In the cases of TextField Activate and List DefaultAction, we need to * call a callback ourselves. * In the List SingleSelect case, just make the list item show up in * TextField. */ if (client == C_ACT) { cbs.reason = XmCR_COMMAND_ENTERED; cbs.event = p->event; t = XmTextFieldGetString(w); cbs.value = XmStringCreateSimple(t); cbs.length = (t == NULL) ? 0 : strlen(t); XtFree(t); XtCallCallbackList((Widget)cw, cw->command.callback, &cbs); } if (client == C_LIST_SELECT) { if (!XmStringGetLtoR(l->item, XmFONTLIST_DEFAULT_TAG, &t)) { return; } XmTextFieldSetString(SB_Text(cw), t); cbs.value = XmStringCreateSimple(t); XtFree(t); return; } if (client == C_LIST_DOUBLE) { cbs.reason = XmCR_COMMAND_ENTERED; cbs.event = l->event; cbs.value = l->item; cbs.length = XmStringLength(l->item); XtCallCallbackList((Widget)cw, cw->command.callback, &cbs); } /* If we have an error condition, remove it */ if (Com_Error(cw)) { Com_Error(cw) = False; XmListDeletePos(SB_List(cw), 0); } /* We need to blindly insert now. */ XmListAddItemUnselected(SB_List(cw), cbs.value, 0); /* 0 is at the end */ /* * If #items in list is larger than HistoryMaxItems, remove the first * This code will actually delete more than just the first item, in case * some sick programmer decides to manually cram more items in the list * than XmNhistoryMaxItems allows */ if (List_ItemCount(SB_List(cw)) > Com_HistoryMaxItems(cw)) { DEBUGOUT(_LtDebug(__FILE__, (Widget)cw, "_XmCommandCallback: List too long; removing %d items" " from list\n", List_ItemCount(SB_List(cw)) - Com_HistoryMaxItems(cw))); XmListDeleteItemsPos(SB_List(cw), List_ItemCount(SB_List(cw)) - Com_HistoryMaxItems(cw), 1); } if (client != C_LIST_DOUBLE) /* FIX ME - I think this is right ! */ { XmStringFree(cbs.value); } /* Clear the text field */ XmTextFieldSetString(SB_Text(cw), ""); }
void UpdatePresenceWorkspaces( WmScreenData *pSD ) { PtrWsPresenceData pPres = &pSD->presence; int wsnum; XmString xmsTmp; if (pPres->shellW) { if (pPres->numWorkspaces < pSD->numWorkspaces) { if (((pPres->ItemStrings = (XmStringTable) XtRealloc ((char *)pPres->ItemStrings, (pSD->numWorkspaces * sizeof(XmString *)))) == NULL) || ((pPres->ItemSelected = (Boolean *) XtRealloc ((char *)pPres->ItemSelected, (pSD->numWorkspaces * sizeof(Boolean)))) == NULL)) { Warning (((char *)GETMESSAGE(52, 5, "Insufficient memory to create Occupy Workspace dialog."))); pPres->shellW = NULL; return; } } /* * Replace the names in the dialog's list */ for (wsnum = 0; wsnum < pPres->numWorkspaces; wsnum++) { if (wsnum < pSD->numWorkspaces) { xmsTmp = XmStringCopy (pSD->pWS[wsnum].title); if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum])) { /* * Replace the string in our local list */ XmStringFree (pPres->ItemStrings[wsnum]); pPres->ItemStrings[wsnum] = xmsTmp; /* * Replace the item in the scrolled list. */ XmListDeletePos (pPres->workspaceListW, 1+wsnum); XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum); } else { XmStringFree (xmsTmp); } } else { /* * Delete this workspace from the list */ XmStringFree (pPres->ItemStrings[wsnum]); pPres->ItemStrings[wsnum] = NULL; XmListDeletePos (pPres->workspaceListW, 1+wsnum); } } for (; wsnum < pSD->numWorkspaces; wsnum++) { /* * Add these workspaces to the list. */ xmsTmp = XmStringCopy (pSD->pWS[wsnum].title); pPres->ItemStrings[wsnum] = xmsTmp; XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum); if (pPres->pCDforClient && (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum], pPres->pCDforClient))) { XmListSelectPos (pPres->workspaceListW, 1+wsnum, TRUE); pPres->ItemSelected[wsnum] = True; } else { pPres->ItemSelected[wsnum] = False; } } pPres->numWorkspaces = pSD->numWorkspaces; } } /* END OF FUNCTION UpdatePresenceWorkspaces */
/*************************************<->************************************* * * wspUpdateWorkspaceList (pPres) * * * Description: * ----------- * Updates the list widget containing all the workspaces. * Sets the ones for this client. * * Inputs: * ------ * pPres = ptr to presence dialog data * * Outputs: * ------- * none * * Comments: * --------- ******************************<->***********************************/ static void wspUpdateWorkspaceList( PtrWsPresenceData pPres ) { int n; XmString xmsTmp, *pxmsSelected; WmScreenData *pSD; Arg args[5]; int wsnum, numSelected; /* * Update the list of workspaces to -- one may have been * renamed since the last time we were up. */ pSD = pPres->pCDforClient->pSD; for (wsnum = 0; wsnum < pSD->numWorkspaces; wsnum++) { xmsTmp = XmStringCopy (pSD->pWS[wsnum].title); if (!XmStringCompare (xmsTmp, pPres->ItemStrings[wsnum])) { /* * Replace the string in our local list */ XmStringFree (pPres->ItemStrings[wsnum]); pPres->ItemStrings[wsnum] = xmsTmp; /* * Replace the item in the scrolled list. */ XmListDeletePos (pPres->workspaceListW, 1+wsnum); XmListAddItem (pPres->workspaceListW, xmsTmp, 1+wsnum); } else { XmStringFree (xmsTmp); } } /* * Highlight the workspaces this client resides in */ XmListDeselectAllItems (pPres->workspaceListW); pxmsSelected = (XmString *) XtMalloc (pPres->pCDforClient->pSD->numWorkspaces * sizeof (XmString)); numSelected = 0; for (wsnum = 0; wsnum < pPres->pCDforClient->pSD->numWorkspaces; wsnum++) { if (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[wsnum], pPres->pCDforClient)) { pxmsSelected[numSelected++] = pPres->ItemStrings[wsnum]; pPres->ItemSelected[wsnum] = True; } else { pPres->ItemSelected[wsnum] = False; pPres->pCDforClient->putInAll = False; } if (pPres->pCDforClient->pSD->pActiveWS->id == pPres->pCDforClient->pSD->pWS[wsnum].id) { /* save item number of current workspace */ pPres->currentWsItem = 1+wsnum; } } /* set the selected items */ n = 0; XtSetArg (args[n], XmNselectedItems, pxmsSelected); n++; XtSetArg (args[n], XmNselectedItemCount, numSelected); n++; XtSetValues (pPres->workspaceListW, args, n); /* set state of all workspaces button */ n = 0; XtSetArg (args[n], XmNset, pPres->pCDforClient->putInAll); n++; XtSetValues (pPres->allWsW, args, n); /* set name of window we're popped up for */ wspSetWindowName (pPres); XtFree ((char *) pxmsSelected); } /* END OF FUNCTION */
/*ARGSUSED*/ static void ListCallback( Widget w, /* unused */ XtPointer client_data, XtPointer call_data ) { XmListCallbackStruct * listCB = (XmListCallbackStruct *) call_data ; XmCommandCallbackStruct cmdCB ; XmCommandWidget cmdWid = (XmCommandWidget) client_data ; char * text_value ; Arg argv[5] ; Cardinal argc ; int count ; XmString tmpXmString ; /*********** reset is not used ************ Boolean reset = FALSE ; ****************/ argc = 0 ; XtSetArg( argv[argc], XmNitemCount, &count) ; ++argc ; XtGetValues( SB_List( cmdWid), argv, argc) ; if( !count ) { return ; } if( cmdWid->command.error ) { if( (listCB->item_position == (count - 1)) || ( (listCB->item_position == count) && (listCB->reason != XmCR_DEFAULT_ACTION)) ) { /* Selection or default action on the blank line, or selection on * error message. Restore previous selection and return. */ XmListDeselectPos( SB_List( cmdWid), listCB->item_position) ; if( cmdWid->selection_box.list_selected_item_position ) { XmListSelectPos( SB_List( cmdWid), cmdWid->selection_box.list_selected_item_position, FALSE) ; } return ; } XmListDeletePos( SB_List( cmdWid), 0) ; /* Delete error message.*/ XmListDeletePos( SB_List( cmdWid), 0) ; /* Delete blank line.*/ cmdWid->command.error = FALSE ; if( count <= 2 ) { /* List only contained error message and blank line. */ cmdWid->selection_box.list_selected_item_position = 0 ; return ; } count -= 2 ; if( (listCB->item_position > count) && (listCB->reason == XmCR_DEFAULT_ACTION) ) { /* Default action on the error message line. Restore previous * selection, clear text area, and return. */ if( cmdWid->selection_box.list_selected_item_position ) { XmListSelectPos( SB_List( cmdWid), cmdWid->selection_box.list_selected_item_position, FALSE) ; } XmTextFieldSetString( cmdWid->selection_box.text, "") ; return ; } } if( listCB->reason == XmCR_DEFAULT_ACTION ) { /* If we are already at max items, remove first item. */ if( count >= cmdWid->command.history_max_items ) { XmListDeletePos( cmdWid->selection_box.list, 1) ; if( cmdWid->selection_box.list_selected_item_position > 0 ) { cmdWid->selection_box.list_selected_item_position-- ; } } tmpXmString = XmStringCopy( listCB->item) ; XmListAddItemUnselected( cmdWid->selection_box.list, tmpXmString, 0) ; XmListSetBottomPos( cmdWid->selection_box.list, 0) ; XmTextFieldSetString( cmdWid->selection_box.text, "") ; /* Call the users command entered callback. */ cmdCB.reason = XmCR_COMMAND_ENTERED ; cmdCB.event = NULL ; cmdCB.value = tmpXmString ; cmdCB.length = XmStringLength( tmpXmString) ; XtCallCallbackList( (Widget) cmdWid, cmdWid->command.callback, &cmdCB) ; XmStringFree( tmpXmString) ; } else /* listCB->reason is BROWSE_SELECT or SINGLE_SELECT */ { /* Update the text widget to relect the latest list selection. */ cmdWid->selection_box.list_selected_item_position = listCB->item_position ; if((text_value = _XmStringGetTextConcat( listCB->item)) != NULL) { XmTextFieldSetString( SB_Text( cmdWid), text_value) ; XmTextFieldSetInsertionPosition( SB_Text( cmdWid), XmTextFieldGetLastPosition( SB_Text( cmdWid))) ; XtFree( text_value) ; } } return ; }