model_server/gala/src/dis_cmds.cxx
//--------------------------------------------------------------------------------
// dis_gdAddListToCombo - Adds a list of values to a combo box
// 
// argv[1] is the gd
// argv[2] is the Combobox tag name
// argv[3 thru argc - 1] are the elements to add to the list.
//
// Because I couldn't get it to work any other way, we also check if
// each arg is a list. Each list has all of its members added to the combo.
// If you want spaces in the combo label, you need to use AddItemToCombo above.
// NOTE - This routine doesn't handle braces or quotes!
//
// returns TCL_OK or TCL_ERROR.
//--------------------------------------------------------------------------------
Adds a list of values to a combo box
argv[1] is the gd
argv[2] is the Combobox tag name
argv[3 thru argc - 1] are the elements to add to the list.

Because I couldn't get it to work any other way, we also check if
each arg is a list. Each list has all of its members added to the combo.
If you want spaces in the combo label, you need to use AddItemToCombo above.
NOTE - This routine doesn't handle braces or quotes!


Adds a list of values to a combo box argv [ 1 ] is the gd argv [ 2 ] is the Combobox tag name argv [ 3 thru argc - 1 ] are the elements to add to the list . Because I couldn ' t get it to work any other way we also check if each arg is a list . Each list has all of its members added to the combo . If you want spaces in the combo label you need to use AddItemToCombo above . NOTE - This routine doesn ' t handle braces or quotes!
int dis_gdAddListToCombo (ClientData, Tcl_Interp* interp, int argc, char *argv[])
{
    if (argc < 4)
        TCL_EXECERR ("wrong number of arguments") 
    gdComboBox* myItem = (gdComboBox*) dis_findItem(interp, (vchar*) argv[2]);
    if (myItem) {
        char* currentValue = Tcl_GetVar(interp, argv[2], TCL_GLOBAL_ONLY);
        for (int i = 3; i < argc; i++) {
            vstr* lStr = vstrCloneScribed(vcharScribeSystem(argv[i]) );
            vchar* item = vcharGetFirstToken(lStr, " ");
            while (item) {
                myItem->AppendText (item);
                item = vcharGetNextToken(" ");
            }
            vstrDestroy(lStr);
        }
        if ((currentValue == NULL) || (*currentValue == NULL) ) {
			if(myItem->GetValueCount()!=0) {
				myItem->SelectTextAt(0);
                Tcl_SetVar(interp, argv[2], (char*)myItem->GetTextAt(0), TCL_GLOBAL_ONLY);
			} else {
                Tcl_SetVar(interp, argv[2], (char*)"", TCL_GLOBAL_ONLY);
			}
        }
    }
    return TCL_OK;
}
int dis_gdAddListToCombo ( ClientData , Tcl_Interp * interp , int argc , char * argv [ ] ) { if ( argc < 4 ) TCL_EXECERR ( " " ) gdComboBox * myItem = ( gdComboBox * ) dis_findItem ( interp , ( vchar * ) argv [ 2 ] ) ; if ( myItem ) { char * currentValue = Tcl_GetVar ( interp , argv [ 2 ] , TCL_GLOBAL_ONLY ) ; for ( int i = 3 ; i < argc ; i ++ ) { vstr * lStr = vstrCloneScribed ( vcharScribeSystem ( argv [ i ] ) ) ; vchar * item = vcharGetFirstToken ( lStr , " " ) ; while ( item ) { myItem -> AppendText ( item ) ; item = vcharGetNextToken ( " " ) ; } vstrDestroy ( lStr ) ; } if ( ( currentValue == NULL ) || ( * currentValue == NULL ) ) { if ( myItem -> GetValueCount ( ) != 0 ) { myItem -> SelectTextAt ( 0 ) ; Tcl_SetVar ( interp , argv [ 2 ] , ( char * ) myItem -> GetTextAt ( 0 ) , TCL_GLOBAL_ONLY ) ; } else { Tcl_SetVar ( interp , argv [ 2 ] , ( char * ) " " , TCL_GLOBAL_ONLY ) ; } } } return TCL_OK ; }
dis_gdAddListToCombo - Adds a list of values to a combo box
argv[1] is the gd
argv[2] is the Combobox tag name
argv[3 thru argc - 1] are the elements to add to the list.
dis_gdAddListToCombo - Adds a list of values to a combo box argv [ 1 ] is the gd argv [ 2 ] is the Combobox tag name argv [ 3 thru argc - 1 ] are the elements to add to the list .
// Get the current value. // We will check for it being empty later. // Loop through the args, adding to the combo list. // Copy the arg and add each word into the Combo. // If the current value is empty, set it to the first item.