Esempio n. 1
0
File: Command.c Progetto: att/uwin
static void
initialize(Widget request, Widget new_w,
	   ArgList args, Cardinal *num_args)
{
    DEBUGOUT(_LtDebug(__FILE__, new_w, "Initialize\n"));

    if (Com_PromptString(new_w) == (XmString)XmUNSPECIFIED)
    {
	XmString xms;

	xms = XmStringCreateLocalized(">");
	XtVaSetValues( SB_SelectionLabel(new_w), XmNlabelString, xms, NULL);
	XmStringFree(xms);
	Com_PromptString(new_w) = NULL;
    }
#if 0
    /* rws 2 Oct 1998
       These are just re-named SelectionBox resources so SelectionBox
       will take care of them.
     */
    if (Com_PromptString(new_w) == (XmString)XmUNSPECIFIED)
    {
	Com_PromptString(new_w) = XmStringCreateLocalized(">");
    }
    else if (Com_PromptString(new_w) != NULL)
    {
	Com_PromptString(new_w) = XmStringCopy(Com_PromptString(new_w));
    }

    if (Com_Command(new_w) == (XmString)XmUNSPECIFIED)
    {
	Com_Command(new_w) = XmStringCreateLocalized(">");
    }
    else if (Com_Command(new_w) != NULL)
    {
	Com_Command(new_w) = XmStringCopy(Com_Command(new_w));
    }
#endif

    XtAddCallback(SB_Text(new_w), XmNactivateCallback,
		  _XmCommandCallback, C_ACT);
    XtAddCallback(SB_List(new_w), XmNsingleSelectionCallback,
		  _XmCommandCallback, C_LIST_SELECT);
    XtAddCallback(SB_List(new_w), XmNdefaultActionCallback,
		  _XmCommandCallback, C_LIST_DOUBLE);

    Com_Error(new_w) = False;
}
Esempio n. 2
0
static void do_hotunlink_proc(Widget, XtPointer, XtPointer)
{
    XmString *s, cs;
    int *pos_list;
    int pos_cnt, cnt;
    char *cstr;
    int setno;

    set_wait_cursor();

    if (XmListGetSelectedPos(hotlink_list_item, &pos_list, &pos_cnt))
    {
        //j = pos_list[0];
        XtVaGetValues(hotlink_list_item,
                      XmNselectedItemCount, &cnt,
                      XmNselectedItems, &s,
                      NULL);
        cs = XmStringCopy(*s);
        if (XmStringGetLtoR(cs, charset, &cstr))
        {
            sscanf(cstr, "S%d", &setno);
            if (setno >= 0 && setno < g[cg].maxplot)
            {
                set_hotlink(cg, setno, FALSE, NULL, 0);
            }
            XtFree(cstr);
        }
        XmStringFree(cs);
        update_hotlinks();
    }

    unset_wait_cursor();
}
Esempio n. 3
0
static Boolean
set_values(Widget old, Widget request, Widget new_w, ArgList args, Cardinal *num_args)
{
    Boolean refresh = False;

#ifdef DEBUG
    printf("NumEntry - set_values(%s) - >%s< >%s<\n", XtName(new_w), NumEntry_Value(old), NumEntry_Value(new_w));
#endif
    if (XtIsSensitive(old) != XtIsSensitive(new_w) && !XtIsSensitive(new_w))
    {
	if (NumEntry_TimerId(new_w))
	{
	    XtRemoveTimeOut(NumEntry_TimerId(new_w));
	    NumEntry_TimerId(new_w) = (XtIntervalId)NULL;
	}
    }
    if (NumEntry_LabelString(old) != NumEntry_LabelString(new_w))
    {
	NumEntry_LabelString(new_w) = XmStringCopy(NumEntry_LabelString(new_w));
	XtVaSetValues(NumEntry_Label(new_w),
		      XmNlabelString, NumEntry_LabelString(new_w),
		      NULL);
	if (NumEntry_LabelString(old))
	{
	    XmStringFree(NumEntry_LabelString(old));
	}
    }
    if (NumEntry_Value(old) != NumEntry_Value(new_w))
    {
	char *tmp;
	Position Place;
#ifdef DEBUG
	printf("NumEntry - set_values(%s) - value old >%s< new >%s<\n", XtName(new_w),
	       NumEntry_Value(old), NumEntry_Value(new_w));
#endif
	tmp = NumEntry_Value(new_w);
	NumEntry_Value(new_w) = XtNewString(tmp);
	Place = XmTextFieldGetInsertionPosition(NumEntry_TextField(new_w));
	XmTextFieldSetString(NumEntry_TextField(new_w), NumEntry_Value(new_w));
	XmTextFieldSetInsertionPosition(NumEntry_TextField(new_w), Place);
	if (NumEntry_Value(old))
	{
	    XtFree(NumEntry_Value(old));
	}
	refresh = True;
	DoMath(new_w);
    }
    if (NumEntry_Columns(old) != NumEntry_Columns(new_w))
    {
    Dimension old_width = XtWidth(NumEntry_TextField(new_w));

	XtVaSetValues(NumEntry_TextField(new_w),
		      XmNcolumns, NumEntry_Columns(new_w),
		      NULL);
	XtWidth(new_w) -= (old_width - XtWidth(NumEntry_TextField(new_w)));
	refresh = True;
    }
    return (refresh);
}
Esempio n. 4
0
static XtPointer
GetValues(
        ChangeDirRec *change_dir_rec )
{
   ChangeDirData * change_dir_data;
   Arg args[8];
   register int n;
   XmStringTable history_list;
   XmString      string_path;


   /*  Allocate and initialize the change dir dialog data.  */

   change_dir_data = (ChangeDirData *) XtMalloc (sizeof (ChangeDirData));

   change_dir_data->displayed = True;
   change_dir_data->host_name = NULL;
   change_dir_data->file_mgr_rec = NULL;

   n = 0;
   XtSetArg (args[n], XmNx, &change_dir_data->x);		n++;
   XtSetArg (args[n], XmNy, &change_dir_data->y);		n++;
   XtSetArg (args[n], XmNwidth, &change_dir_data->width);		n++;
   XtSetArg (args[n], XmNheight, &change_dir_data->height);		n++;
   XtSetArg (args[n], XmNlistItemCount, &change_dir_data->list_count);	n++;
   XtSetArg (args[n], XmNlistVisibleItemCount, &change_dir_data->visible_count);	n++;
   XtSetArg (args[n], XmNtextString, &string_path);		n++;
   XtSetArg (args[n], XmNlistItems, &history_list);		n++;
   XtGetValues (change_dir_rec->change_dir, args, n);


   /*  Extract and make local copies of the XmString data.  */

   change_dir_data->history_list = (XmStringTable)
      XtMalloc (sizeof(XmStringTable) * (change_dir_data->list_count + 1));

   for (n = 0; n < change_dir_data->list_count; n++)
      change_dir_data->history_list[n] = XmStringCopy (history_list[n]);
   change_dir_data->history_list[n] = NULL;

   if(change_dir_data->string_path)
      XmStringFree (change_dir_data->string_path);
   change_dir_data->string_path = XmStringCopy (string_path);

   return ((XtPointer) change_dir_data);
}
Esempio n. 5
0
static void motFileDlgPromptCallback(Widget w, ImotPromt* prompt, XmSelectionBoxCallbackStruct* cbs)
{
  if (cbs->reason == XmCR_OK)
    prompt->xm_dir = XmStringCopy(cbs->value);

  prompt->ret_code = 1;
  XtDestroyWidget(XtParent(w));
}
Esempio n. 6
0
File: Command.c Progetto: att/uwin
static Boolean
set_values(Widget old, Widget request, Widget new_w,
	   ArgList args, Cardinal *num_args)
{
    Boolean refresh_needed = False;

    BB_InSetValues(new_w) = True;

#if 0
    /* rws 2 Oct 1998
       These are just re-named SelectionBox resources so SelectionBox
       will take care of them.
     */
    if (Com_PromptString(new_w) != Com_PromptString(old))
    {
	Com_PromptString(new_w) = XmStringCopy(Com_PromptString(new_w));

	XmStringFree(Com_PromptString(old));

	refresh_needed = True;
    }

    if (Com_Command(new_w) != Com_Command(old))
    {
	Com_Command(new_w) = XmStringCopy(Com_Command(new_w));

	XmStringFree(Com_Command(old));

	refresh_needed = True;
    }
#endif

    /* the next 8 lines are required for every BB subclass that uses
     * the GeoMatrix */
    BB_InSetValues(new_w) = False;

    if (refresh_needed && (XtClass(new_w) == xmCommandWidgetClass))
    {
	_XmBulletinBoardSizeUpdate(new_w);

	return False;
    }

    return True;
}
Esempio n. 7
0
static XmStringTable
CopyST (XmStringTable st, int nst)
{
    XmStringTable lst = (XmStringTable) XtMalloc(sizeof(XmString) * nst);
    int i ;

    for (i=0; i < nst ; i++) {
	lst[i] = XmStringCopy(st[i]);
    }

    return lst ;
}
Esempio n. 8
0
void
XmSetToolTipString (Widget w,
                    XmString s)
{
    XmToolTipTrait ttp;
    ttp = (XmToolTipTrait)XmeTraitGet(w, XmQTtoolTip);
    if (!ttp) {
        ttp = (XmToolTipTrait)XtCalloc(1, sizeof(XmToolTipTraitRec));
        XmeTraitSet(w, XmQTtoolTip, ttp);
    }
    if (ttp->tool_tip_string)
        XmStringFree(ttp->tool_tip_string);
    ttp->tool_tip_string = XmStringCopy(s);
}
Esempio n. 9
0
/*
** Sort the items in a list widget "listWidget"
*/
static void sortWidgetList(Widget listWidget)
{
    XmString *items, *sortedItems;
    int nItems, i;
    
    XtVaGetValues(listWidget, XmNitems, &items, XmNitemCount, &nItems, NULL);
    sortedItems = (XmString *)XtMalloc(sizeof(XmString) * nItems);
    for (i=0; i<nItems; i++)
    	sortedItems[i] = XmStringCopy(items[i]);
    qsort(sortedItems, nItems, sizeof(XmString), compareXmStrings);
    XmListReplaceItemsPos(listWidget, sortedItems, nItems, 1);
    for (i=0; i<nItems; i++)
    	XmStringFree(sortedItems[i]);
    XtFree((char *)sortedItems);
}
Esempio n. 10
0
void
AttachArea::setSelectedAttachName(
    XmString new_name
)
{
    int i;
    Boolean set = FALSE;
    Attachment **list = this->getList();

    XmString nn = XmStringCopy(new_name);

    // Set name of first selected attachment to new_name
    for(i=0;i<this->getIconCount() && !set;i++)
 	if(list[i]->isSelected()) {
	    list[i]->rename(nn);
	    set = TRUE;
 	}
    this->manageList();
}
Esempio n. 11
0
static void ClickAction(Widget w, XEvent *event,
                           String *params,Cardinal *nparams)
{
XmTabWidget wid = (XmTabWidget)w;
Widget tab_wid;
XmTabCallbackStruct call_data;
XmTabConstraintRec *tab_constraint;

	tab_wid = search_tab(wid, event);

	if(!tab_wid) return;

	change_tab(wid, tab_wid);
	draw_tabs(wid);

	tab_constraint = 
		(XmTabConstraintRec *) tab_wid->core.constraints;

	call_data.reason = XmCR_VALUE_CHANGED;
	call_data.tab_child = tab_wid;
	call_data.event = event;

	if( tab_constraint->tab.tab_label )
	{
		call_data.tab_label = 
			XmStringCopy(tab_constraint->tab.tab_label);
	}
	else
	{
		call_data.tab_label = 
			XmStringCreateLocalized(XtName(tab_wid));;
	}

	XtCallCallbacks(w, XmNvalueChangedCallback, &call_data);

	XmStringFree(call_data.tab_label);
}
Esempio n. 12
0
/*----------------------------------------------------------------------*/
static void
GetValuesHook(Widget w,ArgList args,Cardinal* nargs)
{
/*     XfeComboBoxPart *		cp = _XfeComboBoxPart(w); */
    Cardinal				i;
    
    for (i = 0; i < *nargs; i++)
    {
#if 0
		/* label_string */
		if (strcmp(args[i].name,XmNlabelString) == 0)
		{
			*((XtArgVal *) args[i].value) = 
				(XtArgVal) XmStringCopy(lp->label_string);
		}
		/* font_list */
		else if (strcmp(args[i].name,XmNfontList) == 0)
		{
			*((XtArgVal *) args[i].value) = 
				(XtArgVal) XmFontListCopy(lp->font_list);
		}      
#endif
    }
}
Esempio n. 13
0
/*************************************<->*************************************
 *
 *  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   */
Esempio n. 14
0
/*************************************<->*************************************
 *
 *  wspCreateWorkspaceList (mgrW, pPres, pSD)
 *
 *
 *  Description:
 *  -----------
 *  Creates a list widget containing all the workspaces defined for a 
 *  screen.
 *
 *  Inputs:
 *  ------
 *  mgrW = manager widget (parent of this child)
 *  pPres = pointer to presence data
 *  pSD = ptr to screen data
 * 
 *  Outputs:
 *  -------
 *  Return = widget created.
 *
 *  Comments:
 *  ---------
 ******************************<->***********************************/
static Widget 
wspCreateWorkspaceList(
        Widget mgrW,
        PtrWsPresenceData pPres,
        WmScreenData *pSD )
{
    Arg setArgs[20];
    int i;
    Widget listW;
    int numVisible;

#define MIN_VISIBLE	6

    /*
     * Create the array of strings that will go into the list.
     */
    if (((pPres->ItemStrings = (XmStringTable) XtMalloc 
		(pSD->numWorkspaces * sizeof(XmString *))) == NULL) ||
	((pPres->ItemSelected = (Boolean *) XtMalloc 
		(pSD->numWorkspaces * sizeof(Boolean))) == NULL))
    {
	Warning (((char *)GETMESSAGE(52, 5, "Insufficient memory to create Occupy Workspace dialog.")));
	return (NULL);
    }

    pPres->numWorkspaces = pSD->numWorkspaces;

    for (i = 0; i < pSD->numWorkspaces; i++)
    {
	pPres->ItemStrings[i] = XmStringCopy (pSD->pWS[i].title);

	if (pSD->pWS[i].id == pSD->pActiveWS->id)
	{
	    pPres->currentWsItem = 1+i;
	}
    }


    /* 
     * Create the widget
     */
    i = 0;

    XtSetArg (setArgs[i], XmNitemCount, pSD->numWorkspaces);	i++;

    XtSetArg (setArgs[i], XmNitems, pPres->ItemStrings);	i++;

    XtSetArg (setArgs[i], XmNselectionPolicy, XmEXTENDED_SELECT); i++;

    XtSetArg (setArgs[i], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); i++;

    listW = XmCreateScrolledList (mgrW, "list", setArgs, i);
    XtManageChild (listW);

    if (pPres->pCDforClient)
    {
	/*
	 * Highlight the workspaces this client resides in
	 */
	for (i = 0; i < pPres->pCDforClient->pSD->numWorkspaces; i++)
	{
	    if (ClientInWorkspace (&pPres->pCDforClient->pSD->pWS[i], 
					pPres->pCDforClient))
	    {
		XmListSelectPos (listW, i+1, TRUE);
		pPres->ItemSelected[i] = True;
	    }
	    else
	    {
		pPres->ItemSelected[i] = False;
	    }
	}
    }

    /*
     * Insure a minimum number are visible.
     */
    i = 0;
    XtSetArg (setArgs[i], XmNvisibleItemCount, &numVisible);	i++;
    XtGetValues (listW, setArgs, i);

    if (numVisible < MIN_VISIBLE)
    {
	i = 0;
	XtSetArg (setArgs[i], XmNvisibleItemCount, MIN_VISIBLE);i++;
	XtSetValues (listW, setArgs, i);
    }

    XtAddCallback (listW, XmNextendedSelectionCallback,
		(XtCallbackProc) wspExtendedSelectCB, (XtPointer)pSD);
    /* Handle the double-click just like if the Ok button was pressed */
    XtAddCallback (listW, XmNdefaultActionCallback,
		(XtCallbackProc) wspOkCB, (XtPointer)pSD); 


    return (listW);
} /* END OF FUNCTION   */
Esempio n. 15
0
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 */
Esempio n. 16
0
/*
 * TODO, lots of declared, but unused variables here
 */
static void do_netcdfquery_proc(Widget, XtPointer, XtPointer)
{
    int setno, src;
    char xvar[256], yvar[256];
    char buf[256], fname[512];
    XmString xms;
    XmString *s, cs;
    int *pos_list;
    int i, j, pos_cnt, cnt;
    char *cstr;

    int cdfid; /* netCDF id */
    int ndims, nvars, ngatts, recdim;
    int var_id;
    long start[2];
    long count[2];
    char varname[256];
    nc_type datatype = 0;
    int dim[100], natts;
    long dimlen[100];
    long len;

    int x_id, y_id;
    nc_type xdatatype = 0;
    nc_type ydatatype = 0;
    int xndims, xdim[10], xnatts;
    int yndims, ydim[10], ynatts;
    long nx, ny;

    int atlen;
    char attname[256];
    char atcharval[256];

    extern int ncopts;

    ncopts = 0; /* no crash on error */

    set_wait_cursor();

    strcpy(fname, xv_getstr(netcdf_file_item));

    if ((cdfid = ncopen(fname, NC_NOWRITE)) == -1)
    {
        errwin("Can't open file.");
        goto out2;
    }
    if (XmListGetSelectedPos(netcdf_listx_item, &pos_list, &pos_cnt))
    {
        XtVaGetValues(netcdf_listx_item,
                      XmNselectedItemCount, &cnt,
                      XmNselectedItems, &s,
                      NULL);
        cs = XmStringCopy(*s);
        if (XmStringGetLtoR(cs, charset, &cstr))
        {
            strcpy(xvar, cstr);
            XtFree(cstr);
        }
        XmStringFree(cs);
    }
    else
    {
        errwin("Need to select X, either variable name or INDEX");
        goto out1;
    }
    if (XmListGetSelectedPos(netcdf_listy_item, &pos_list, &pos_cnt))
    {
        XtVaGetValues(netcdf_listy_item,
                      XmNselectedItemCount, &cnt,
                      XmNselectedItems, &s,
                      NULL);
        cs = XmStringCopy(*s);
        if (XmStringGetLtoR(cs, charset, &cstr))
        {
            strcpy(yvar, cstr);
            XtFree(cstr);
        }
        XmStringFree(cs);
    }
    else
    {
        errwin("Need to select Y");
        goto out1;
    }
    if (strcmp(xvar, "INDEX") == 0)
    {
        stufftext("X is the index of the Y variable\n", STUFF_START);
    }
    else
    {
        if ((x_id = ncvarid(cdfid, xvar)) == -1)
        {
            char ebuf[256];
            sprintf(ebuf, "do_query(): No such variable %s for X", xvar);
            errwin(ebuf);
            goto out1;
        }
        ncvarinq(cdfid, x_id, NULL, &xdatatype, &xndims, xdim, &xnatts);
        ncdiminq(cdfid, xdim[0], NULL, &nx);
        sprintf(buf, "X is %s, data type %s \t length [%d]\n", xvar, getcdf_type(xdatatype), nx);
        stufftext(buf, STUFF_TEXT);
        sprintf(buf, "\t%d Attributes:\n", xnatts);
        stufftext(buf, STUFF_TEXT);
        for (i = 0; i < xnatts; i++)
        {
            atcharval[0] = 0;
            ncattname(cdfid, x_id, i, attname);
            ncattinq(cdfid, x_id, attname, &datatype, &atlen);
            switch (datatype)
            {
            case NC_CHAR:
                ncattget(cdfid, x_id, attname, (void *)atcharval);
                break;
            }
            sprintf(buf, "\t\t%s: %s\n", attname, atcharval);
            stufftext(buf, STUFF_TEXT);
        }
    }
    if ((y_id = ncvarid(cdfid, yvar)) == -1)
    {
        char ebuf[256];
        sprintf(ebuf, "do_query(): No such variable %s for Y", yvar);
        errwin(ebuf);
        goto out1;
    }
    ncvarinq(cdfid, y_id, NULL, &ydatatype, &yndims, ydim, &ynatts);
    ncdiminq(cdfid, ydim[0], NULL, &ny);
    sprintf(buf, "Y is %s, data type %s \t length [%d]\n", yvar, getcdf_type(ydatatype), ny);
    stufftext(buf, STUFF_TEXT);
    sprintf(buf, "\t%d Attributes:\n", ynatts);
    stufftext(buf, STUFF_TEXT);
    for (i = 0; i < ynatts; i++)
    {
        atcharval[0] = 0;
        ncattname(cdfid, y_id, i, attname);
        ncattinq(cdfid, y_id, attname, &datatype, &atlen);
        switch (datatype)
        {
        case NC_CHAR:
            ncattget(cdfid, y_id, attname, (void *)atcharval);
            break;
        }
        sprintf(buf, "\t\t%s: %s\n", attname, atcharval);
        stufftext(buf, STUFF_TEXT);
    }

out1:
    ;
    ncclose(cdfid);

out2:
    ;
    stufftext("\n", STUFF_STOP);
    unset_wait_cursor();
}
Esempio n. 17
0
static void do_netcdf_proc(Widget, XtPointer, XtPointer)
{
    int setno, src;
    char fname[256];
    char buf[256], xvar[256], yvar[256];
    XmString xms;
    XmString *s, cs;
    int *pos_list;
    int j, pos_cnt, cnt, autoflag, retval;
    char *cstr;

    set_wait_cursor();
    autoflag = XmToggleButtonGetState(netcdf_auto_item);

    /*
    * setno == -1, then next set
    */
    setno = GetChoice(netcdf_set_item) - 1;
    strcpy(fname, xv_getstr(netcdf_file_item));
    if (XmListGetSelectedPos(netcdf_listx_item, &pos_list, &pos_cnt))
    {
        XtVaGetValues(netcdf_listx_item,
                      XmNselectedItemCount, &cnt,
                      XmNselectedItems, &s,
                      NULL);
        cs = XmStringCopy(*s);
        if (XmStringGetLtoR(cs, charset, &cstr))
        {
            strcpy(xvar, cstr);
            XtFree(cstr);
        }
        XmStringFree(cs);
    }
    else
    {
        errwin("Need to select X, either variable name or INDEX");
        unset_wait_cursor();
        return;
    }
    if (XmListGetSelectedPos(netcdf_listy_item, &pos_list, &pos_cnt))
    {
        j = pos_list[0];
        XtVaGetValues(netcdf_listy_item,
                      XmNselectedItemCount, &cnt,
                      XmNselectedItems, &s,
                      NULL);
        cs = XmStringCopy(*s);
        if (XmStringGetLtoR(cs, charset, &cstr))
        {
            strcpy(yvar, cstr);
            XtFree(cstr);
        }
        XmStringFree(cs);
    }
    else
    {
        errwin("Need to select Y");
        unset_wait_cursor();
        return;
    }
    if (strcmp(xvar, "INDEX") == 0)
    {
        retval = readnetcdf(cg, setno, fname, NULL, yvar, -1, -1, 1);
    }
    else
    {
        retval = readnetcdf(cg, setno, fname, xvar, yvar, -1, -1, 1);
    }
    if (retval)
    {
        if (autoflag)
        {
            autoscale_proc((Widget)NULL, (XtPointer)0, (XtPointer)NULL);
        }
        else
        {
            drawgraph();
        }
    } /* error from readnetcdf() */
    else
    {
    }

    unset_wait_cursor();
}
Esempio n. 18
0
/*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 ;
    }
Esempio n. 19
0
void
MenuBar::rotateLabels(
    Widget pulldown,
    int startindex,
    int endindex
)
{
    // if(isValidMenuPane(pulldown) == FALSE)
    // 	return;

    int    num_managed_wids=0, i, j, num_children, num_to_change;
    WidgetList children;
    XmString label, endlabel;
    Widget prevwid, wid;

    if (startindex < 0 || endindex < 0)
	return;

    XtVaGetValues(pulldown,
	XmNnumChildren, &num_children,
	NULL);

    if (startindex >= num_children || endindex >= num_children)
	return;
    
    num_to_change = endindex - startindex;
    if (num_children < num_to_change || num_to_change == 0) 
	return;

    children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);

    XtVaGetValues(pulldown,
	XmNchildren, &children,
	NULL);

    // Some of the widgets may be unmanaged: find the first managed widget
    for (i = startindex; i < num_children; i++) {
        if (XtIsManaged(children[i]))
		break;
	startindex++;
    }

    if (startindex == num_children) 
	return;

    // Find the real endindex
    endindex = startindex+1;
    while (endindex < num_children) {
        if (XtIsManaged(children[endindex])) 
		num_managed_wids++;
	if (num_managed_wids == num_to_change)
		// We have found the endindex at this point
		break;
	endindex++;
    } 
 
    if (endindex == num_children) 
	return;

    wid = (Widget) children[endindex];
    XtVaGetValues(wid,
	XmNlabelString, &label,
	NULL);
    endlabel = XmStringCopy(label);

    j = i = endindex; 
    while (i > startindex) {

	do {
		if (--j < startindex) break;
		prevwid = (Widget) children[j];
	} while (!XtIsManaged(prevwid));

	XtVaGetValues(prevwid,
		XmNlabelString, &label,
		NULL);

	XtVaSetValues(wid,
		XmNlabelString, label,
		NULL);

	i = j;

	wid = (Widget) children[i];
    }

    wid = (Widget) children[startindex];
    XtVaSetValues(wid,
	XmNlabelString, endlabel,
	NULL);
    
    XmStringFree(endlabel);
}