Exemple #1
0
/*++++++++++++++++++++++++++++ transfer_data() ++++++++++++++++++++++++++*/
static void
transfer_data(Widget        w,
              XtPointer     client_data,
              Atom          *selection,
              Atom          *type,
              XtPointer     value,
              unsigned long *length,
              int           *format)
{
   if ((*type == compound_text) && (y != -1))
   {
      int           i,
                    no_selected,
                    *select_list,
                    pos = XmListYToPos(host_list_w, y);
      char          *ptr;
      XmString      str;
      XmStringTable xmsel;

      /* Retrieve the selected items from the list. */
      XtVaGetValues(host_list_w,
                    XmNselectedItemCount, &no_selected,
                    XmNselectedItems,     &xmsel,
                    NULL);

      for (i = 0; i < no_selected; i++)
      {
         ptr = XmCvtXmStringToCT(xmsel[i]);
         str = XmStringCreateLocalized(ptr);
         if (pos == 0) /* Last position! */
         {
            XmListAddItemUnselected(host_list_w, str, 0);
         }
         else
         {
            XmListAddItemUnselected(host_list_w, str, pos + i);
         }
         XmStringFree(str);
      }
      if (XmListGetSelectedPos(host_list_w, &select_list, &no_selected) == True)
      {
         XmListDeletePositions(host_list_w, select_list, no_selected);
      }

      /* Select the host that was selected last. */
      str = XmStringCreateLocalized(last_selected_host);
      last_selected = -1;
      XmListSelectItem(host_list_w, str, True);
      XmStringFree(str);

      XtFree((char *)select_list);

      host_alias_order_change = YES;
   }

   return;
}
Exemple #2
0
void CLogMotif::activate_select_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
  XmString cstr;  
  char str[200];
  char *s;

  if ( !clog->filesel_loaded) {
    for ( int i = 0; i < (int) clog->clognav->file_list.size(); i++) {
      time_AtoAscii( &clog->clognav->file_list[i].time, time_eFormat_ComprDateAndTime, 
		     str, sizeof(str));
      str[17] = 0;
      strcat( str, "    ");
      s = strrchr( clog->clognav->file_list[i].name, '/');
      if ( s)
	strcat( str, s+1);
      else
	strcat( str, clog->clognav->file_list[i].name);

      cstr = XmStringCreateSimple( str);
      XmListAddItemUnselected( ((CLogMotif *)clog)->filesel_list_w, cstr, 0);
      XmStringFree(cstr);
    }
    clog->filesel_loaded = true;
  }
  XtManageChild( ((CLogMotif *)clog)->filesel_form);
}
Exemple #3
0
int wxListBox::DoAppend(const wxString& item)
{
    wxSizeKeeper sk( this );
    Widget listBox = (Widget) m_mainWidget;

    bool managed = XtIsManaged(listBox);

    if (managed)
        XtUnmanageChild (listBox);
    int n;
    XtVaGetValues (listBox, XmNitemCount, &n, NULL);
    wxXmString text( item );
    //  XmListAddItem(listBox, text, n + 1);
    XmListAddItemUnselected (listBox, text(), 0);

    // It seems that if the list is cleared, we must re-ask for
    // selection policy!!
    SetSelectionPolicy();

    if (managed)
        XtManageChild (listBox);

    sk.Restore();
    m_noItems ++;

    return GetCount() - 1;
}
Exemple #4
0
void update_hotlinks(void)
{
    int i, j;
    char buf[256];
    XmString xms;

    if (hotlink_frame != NULL)
    {
        set_wait_cursor();
        XmListDeleteAllItems(hotlink_list_item);
        for (i = 0; i < maxgraph; i++)
        {
            for (j = 0; j < g[i].maxplot; j++)
            {
                if (is_hotlinked(i, j))
                {
                    sprintf(buf, "S%02d -> %s -> %s", j,
                            get_hotlink_src(i, j) == DISK ? "DISK" : "PIPE",
                            get_hotlink_file(i, j));
                    xms = XmStringCreateLtoR(buf, charset);
                    XmListAddItemUnselected(hotlink_list_item, xms, 0);
                    XmStringFree(xms);
                }
            }
        }
        unset_wait_cursor();
    }
}
Exemple #5
0
void wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
{
    Widget listBox = (Widget) m_mainWidget;

    XmString *text = new XmString[items.GetCount()];
    unsigned int i;
    // Steve Hammes: Motif 1.1 compatibility
    // #if XmVersion > 1100
    // Corrected by Sergey Krasnov from Steve Hammes' code
#if XmVersion > 1001
    for (i = 0; i < items.GetCount(); i++)
        text[i] = wxStringToXmString(items[i]);
    XmListAddItemsUnselected(listBox, text, items.GetCount(), pos+1);
#else
    for (i = 0; i < items.GetCount(); i++)
    {
        text[i] = wxStringToXmString(items[i]);
        // Another Sergey correction
        XmListAddItemUnselected(listBox, text[i], pos+i+1);
    }
#endif
    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();
}
Exemple #6
0
void WVselMotif::list_add_item( char *str)
{
  XmString 	cstr;  

  cstr = XmStringCreateSimple( str);
  XmListAddItemUnselected( widgets.volumelist, cstr, 0);
  XmStringFree(cstr);	  
}
Exemple #7
0
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;
}
Exemple #8
0
Fichier : ssX.c Projet : q3k/ski
static void SimCmd(Widget w, XEvent *event,
		   String *params, Cardinal *num_params)
{
    XmString xms;
    char s[100];

    xms = XmStringCreateLocalized(*params);
    XmListAddItemUnselected(cmdHist, xms, 0);
    XmListSetBottomPos(cmdHist, 0);
    XmStringFree(xms);
    (void)strcpy(prevCmdStr, *params);
    (void)sprintf(s, "%s\n", *params);
    (void)cmdExLin(s);
}
Exemple #9
0
/* 
 * File selection box callback 
 */
void openCB(Widget w,int client_data,XmFileSelectionBoxCallbackStruct *call_data)
{ 
    if (client_data==DIALOG_CANCEL)
	{ /* do nothing if cancel is selected. */
	    XtUnmanageChild(open_dialog);
	    return;
	}
    else if (client_data==DIALOG_ALL)
	{ /* Add all the listed files  */
	    Arg al[10];
	    int ac;
	    Widget the_list;
	    int nbfile;
	    XmStringTable files;
	    int i;
	   	    
	    the_list=XmFileSelectionBoxGetChild(open_dialog,XmDIALOG_LIST);
	    if (!XmIsList(the_list))
		{
		    printf("PANIC: List are not what they used to be\n");
		    exit;
		}
	    
	    ac=0;
	    XtSetArg(al[ac], XmNitemCount, &nbfile); ac++;
	    XtSetArg(al[ac], XmNitems, &files); ac++;
	    XtGetValues(the_list, al, ac);
	    
	    for (i=0;i<nbfile;i++)
		XmListAddItemUnselected(file_list,files[i],0);
	}
    else
	{   /* get filename from file selection box and add it to the list*/
	    XmListAddItemUnselected(file_list,call_data->value,0);
	    XtUnmanageChild(open_dialog);
	}
}
Exemple #10
0
void button_cb1(Widget w, XtPointer clientData, XtPointer callData)
{
    char string[100];
    XmString xmstr;

    sprintf (string, "XmScrolledList Item %d", current_item);

    xmstr = XmStringCreateSimple(string);

    XmListAddItemUnselected(listw, xmstr, 0);

    XmStringFree(xmstr);

    current_item ++;
}
Exemple #11
0
int wxListBox::DoAppend(const wxString& item)
{
    Widget listBox = (Widget) m_mainWidget;

    int n;
    XtVaGetValues (listBox, XmNitemCount, &n, NULL);
    wxXmString text( item );
    //  XmListAddItem(listBox, text, n + 1);
    XmListAddItemUnselected (listBox, text(), 0);

    // It seems that if the list is cleared, we must re-ask for
    // selection policy!!
    SetSelectionPolicy();

    m_noItems ++;

    return GetCount() - 1;
}
Exemple #12
0
/* We've just init'd a new history list widget; look at the window's
   history and load 'er up. */
static void mo_load_history_list (mo_window *win, Widget list)
{
  mo_node *node;
  
  for (node = win->history; node != NULL; node = node->next)
    {
      XmString xmstr = 
	XmxMakeXmstrFromString (get_pref_boolean(eDISPLAY_URLS_NOT_TITLES) ?
                                node->url : node->title);
      XmListAddItemUnselected 
        (list, xmstr, 0);
      XmStringFree (xmstr);
    }
  
  XmListSetBottomPos (list, 0);
  if (win->current_node)
    XmListSelectPos (win->history_list, win->current_node->position, False);

  return;
}
Exemple #13
0
/* Called from mo_record_visit to insert an mo_node into the history
   list of an mo_window. */
mo_status mo_add_node_to_history (mo_window *win, mo_node *node)
{
  /* If there is no current node, this is our first time through. */
  if (win->history == NULL)
    {
      win->history = node;
      node->previous = NULL;
      node->next = NULL;
      node->position = 1;
      win->current_node = node;
    }
  else
    {
      /* Node becomes end of history list. */
      /* Point back at current node. */
      node->previous = win->current_node;
      /* Point forward to nothing. */
      node->next = NULL;
      node->position = node->previous->position + 1;
      /* Kill descendents of current node, since we'll never
         be able to go forward to them again. */
      mo_kill_node_descendents (win, win->current_node);
      /* Current node points forward to this. */
      win->current_node->next = node;
      /* Current node now becomes new node. */
      win->current_node = node;
    }

  if (win->history_list)
    {
      XmString xmstr = 
	XmxMakeXmstrFromString(
			       get_pref_boolean(eDISPLAY_URLS_NOT_TITLES) ?
			       node->url : node->title);
      XmListAddItemUnselected 
        (win->history_list, xmstr, node->position);
      XmStringFree (xmstr);
    }

  return mo_succeed;
}
Exemple #14
0
Fichier : ssX.c Projet : q3k/ski
/*ARGSUSED*/
static void simCmdCallback(CALLBACK_ARGS)
{
    char s[100];

    if (client_data) {
	XmString xms = XmStringCreateLocalized((char *)client_data);

	XmListAddItemUnselected(cmdHist, xms, 0);
	XmListSetBottomPos(cmdHist, 0);
	XmStringFree(xms);
	(void)strcpy(prevCmdStr, (char*)client_data);
	(void)sprintf(s, "%s\n", (char *)client_data);
    } else {
	XmCommandCallbackStruct *cbs = (XmCommandCallbackStruct *)call_data;
	char *cmdStr;

	(void)XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &cmdStr);
	if (cmdStr[0] == 'X') {
	    XmString msg = XmStringCreateLocalized("Bad command");

	    XmCommandError(cmd, msg);
	    XmStringFree(msg);
	}
	if (cmdStr[0] == '\0' && prevCmdStr != '\0') {
	    (void)strcpy(cmdStr, prevCmdStr);
	    XmStringFree(cbs->value);
	    cbs->value = XmStringCreateLocalized(cmdStr);
	}
	(void)strcpy(prevCmdStr, cmdStr);
	(void)sprintf(s, "%s\n", cmdStr);
    }
    if (!cmdExLin(s)) {
	XmString msg = XmStringCreateLocalized("Bad command");

	XmCommandError(cmd, msg);
	XmStringFree(msg);
    }
    (void)XmProcessTraversal(cmd, XmTRAVERSE_CURRENT);
}
void
ttab_page_callback (
Widget		w,
XtPointer	client_data,
XtPointer	call_data
)
{
	int		i;
	XmString	str;

	current_page = current_page + (int) client_data;

	if (current_page < 0) {

	    current_page = 0;
	    return;

	} else if (current_page >= ttab->number_of_pages) {

	    current_page = ttab->number_of_pages-1;
	    return;

	}

	XmListDeleteAllItems (ttab_list);

	for (i=0;i<=ttab->number_of_lines [current_page];i++) {

	    str = XmStringCreate (ttab->text [current_page][i], "ttab_font");

	    XmListAddItemUnselected (ttab_list, str, i+1);

	    XmStringFree (str);

	}

}
Exemple #16
0
static void do_hotlink_proc(Widget, XtPointer, XtPointer)
{
    int setno, src;
    char fname[256];
    char buf[256];
    XmString xms;

    set_wait_cursor();

    setno = GetSelectedSet(hotlink_set_item);
    src = GetChoice(hotlink_source_item);
    strcpy(fname, xv_getstr(hotlink_file_item));

    sprintf(buf, "S%02d -> %s -> %s", setno, src == 0 ? "DISK" : "PIPE", fname);

    xms = XmStringCreateLtoR(buf, charset);
    XmListAddItemUnselected(hotlink_list_item, xms, 0);

    set_hotlink(cg, setno, TRUE, fname, src == 0 ? DISK : PIPE);

    XmStringFree(xms);

    unset_wait_cursor();
}
Exemple #17
0
static void CreateHelpDialog (void)
{
    Widget pane, form, buttons, w;
    int i;
    XmString str;
    static Arg list_args[] = { { XmNlistSizePolicy, XmCONSTANT },
			       { XmNselectionPolicy, XmSINGLE_SELECT } };
    static Arg text_args[] = { { XmNcursorPositionVisible, FALSE },
			       { XmNeditable, FALSE },
			       { XmNeditMode, XmMULTI_LINE_EDIT } };

    /* Read text about various topics from the help file: */
    if (ntopics == 0)
	LoadHelpFile ();

    /* Create the help dialog: */
    helpDialog = XVCPS ("help", topLevelShellWidgetClass, topLevelShell,
			XmNcolormap, VColormapColormap (vcolormap),
			XmNiconPixmap, iconPixmap,
			XmNmwmInputMode, MWM_INPUT_MODELESS,
			XmNvisual, VColormapVisual (vcolormap),
			(char *) NULL);
    XtAddCallback (helpDialog, XmNdestroyCallback, HelpDestroyCB, NULL);

    /* Use a pane widget to separate the dialog into a top and bottom areas: */
    pane = XVCW ("pane", xmPanedWindowWidgetClass, helpDialog,
		 XmNsashWidth, 1,		/* to prevent moving sash */
		 XmNsashHeight, 1, (char *) NULL);

    /* Create a form containing the topic list and text at the top of
       the dialog: */
    form = XVCW ("form1", xmFormWidgetClass, pane, (char *) NULL);

    w = XVCMW ("topics_label", xmLabelGadgetClass, form,
	       XmNtopAttachment, XmATTACH_FORM,
	       XmNleftAttachment, XmATTACH_FORM, (char *) NULL);

    helpTopics = XmCreateScrolledList (form, "topic_list",
				       list_args, XtNumber (list_args));
    XtVaSetValues (XtParent (helpTopics),
		   XmNtopAttachment, XmATTACH_WIDGET,
		   XmNtopWidget, w,
		   XmNleftAttachment, XmATTACH_FORM,
		   XmNbottomAttachment, XmATTACH_FORM, (char *) NULL);
    XtAddCallback (helpTopics, XmNsingleSelectionCallback, HelpSelectCB, NULL);
    for (i = 0; i < ntopics; i++) {
	str = XmStringCreateSimple (topics[i].topic);
	XmListAddItemUnselected (helpTopics, str, 0);
    }

    XtManageChild (helpTopics);

    w = XVCMW ("text_label", xmLabelGadgetClass, form,
	       XmNtopAttachment, XmATTACH_FORM,
	       XmNleftAttachment, XmATTACH_WIDGET,
	       XmNleftWidget, helpTopics, (char *) NULL);

    helpText = XmCreateScrolledText (form, "text",
				     text_args, XtNumber (text_args));
    XtVaSetValues (XtParent (helpText),
		   XmNtopAttachment, XmATTACH_WIDGET,
		   XmNtopWidget, w,
		   XmNbottomAttachment, XmATTACH_FORM,
		   XmNleftAttachment, XmATTACH_WIDGET,
		   XmNleftWidget, helpTopics,
		   XmNrightAttachment, XmATTACH_FORM, (char *) NULL);
    XtManageChild (helpText);

    /* Create a form containing the Close button at the bottom of the
       dialog: */
    buttons = XVCW ("buttons", xmFormWidgetClass, pane,
		    XmNfractionBase, 10, (char *) NULL);

    w = XVCMW ("close", xmPushButtonGadgetClass, buttons,
	       XmNtopAttachment, XmATTACH_FORM,
	       XmNbottomAttachment, XmATTACH_FORM,
	       XmNleftAttachment, XmATTACH_POSITION,
	       XmNleftPosition, 1,
	       XmNrightAttachment, XmATTACH_POSITION,
	       XmNrightPosition, 3,
	       XmNshowAsDefault, TRUE,
	       (char *) NULL);
    XtAddCallback (w, XmNactivateCallback,
		   UnmanageCallback, (XtPointer) helpDialog);
    XtVaSetValues (form, XmNcancelButton, w, (char *) NULL);
    XtVaSetValues (form, XmNdefaultButton, w, (char *) NULL);
    XtVaSetValues (buttons, XmNcancelButton, w, (char *) NULL);
    XtVaSetValues (buttons, XmNdefaultButton, w, (char *) NULL);

    XtManageChild (buttons);
    FixButtonPane (w);
    XtManageChild (form);
    XtManageChild (pane);
}
Exemple #18
0
void *CoWowMotif::CreateList( const char *title, const char *texts, int textsize,
			      void (action_cb)( void *, char *),
			      void (cancel_cb)( void *),
			      void *parent_ctx,
			      int show_apply_button)
{
  Arg	    args[15];
  XmString cstr;
  Widget mainwindow;
  Widget ok_button;
  Widget cancel_button;
  Widget form;
  char *name_p;
  int i;
  wow_tListCtx ctx;
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  ctx = (wow_tListCtx) calloc( 1, sizeof(*ctx));
  ctx->action_cb = action_cb;
  ctx->cancel_cb = cancel_cb;
  ctx->parent_ctx = parent_ctx;
  
  i=0;
  XtSetArg( args[i], XmNiconName, title); i++;

  ctx->toplevel = XtCreatePopupShell (
        title, topLevelShellWidgetClass, m_parent, args, i);

  // Set default fontlist
  font = XLoadQueryFont( XtDisplay(ctx->toplevel),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i=0;
  XtSetArg( args[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg( args[i], XtNallowShellResize, TRUE); i++;
  XtSetValues( ctx->toplevel, args, i);

  mainwindow = XmCreateMainWindow( ctx->toplevel, (char*) "mainWindow", NULL, 0);
  XtManageChild( mainwindow);

  i=0;
  XtSetArg(args[i],XmNwidth, 200);i++;
  XtSetArg(args[i],XmNheight, 400);i++;
  XtSetArg(args[i],XmNresizePolicy,XmRESIZE_NONE); i++;

  form = XmCreateForm( mainwindow, (char*) "form", args, i);
  XtManageChild( form);

  cstr = XmStringCreateLtoR( (char*) "Ok", XmSTRING_DEFAULT_CHARSET);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNbottomOffset, 20); i++;
  XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNleftOffset, 20); i++;
  XtSetArg( args[i], XmNwidth, 50); i++;
  XtSetArg( args[i], XmNlabelString, cstr); i++;

  ok_button = XmCreatePushButton( form, (char*) "okButton", args, i);
  XtAddCallback( ok_button, XmNactivateCallback,
		(XtCallbackProc) list_ok_cb, ctx);
  XtManageChild( ok_button);

  XmStringFree( cstr);

  cstr = XmStringCreateLtoR( (char*) "Cancel", XmSTRING_DEFAULT_CHARSET);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNbottomOffset, 20); i++;
  XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNrightOffset, 20); i++;
  XtSetArg( args[i], XmNwidth, 50); i++;
  XtSetArg( args[i], XmNlabelString, cstr); i++;

  cancel_button = XmCreatePushButton( form, (char*) "okButton", args, i);
  XtAddCallback( cancel_button, XmNactivateCallback,
		(XtCallbackProc) list_cancel_cb, ctx);
  XtManageChild( cancel_button);

  XmStringFree( cstr);

  i = 0;
  XtSetArg( args[i], XmNdefaultButton, ok_button); i++;
  XtSetArg( args[i], XmNcancelButton, cancel_button); i++;
  XtSetValues( form, args, i);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
  XtSetArg( args[i], XmNbottomWidget, ok_button); i++;
  XtSetArg( args[i], XmNbottomOffset, 15); i++;
  XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNrightOffset, 15); i++;
  XtSetArg( args[i], XmNtopAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNtopOffset, 15); i++;
  XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNleftOffset, 15); i++;
  XtSetArg( args[i], XmNselectionPolicy, XmSINGLE_SELECT); i++;
  XtSetArg( args[i], XmNfontList, fontlist); i++;
  ctx->list = XmCreateScrolledList( form, (char*) "scrolledList", args, i);
  XtAddCallback( ctx->list, XmNdefaultActionCallback,
		(XtCallbackProc) list_action_cb, ctx);

  XmFontListFree( fontlist);
  XtManageChild( ctx->list);

  name_p = (char *)texts;
  i = 0;
  while ( strcmp( name_p, "") != 0) {
    cstr = XmStringCreateSimple( name_p);
    XmListAddItemUnselected( ctx->list, cstr, 0);
    XmStringFree(cstr);	  
    name_p += textsize;
    i++;
  }

  ctx->texts = (char *) calloc( i+1, textsize);
  ctx->textsize = textsize;
  memcpy( ctx->texts, texts, (i+1) * textsize); 
  XtPopup( ctx->toplevel, XtGrabNone);

  // Set input focus to the scrolled list widget
  XmProcessTraversal( ctx->list, XmTRAVERSE_CURRENT);


  return ctx;
}
Exemple #19
0
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 display_tabular_data ()
{
	Widget		form;
	Widget		rowcol;
	Widget		page;
	Arg		args [10];
	XmString	str;
	int		i;

	void	ttab_page_callback (Widget w, XtPointer client_data,
			XtPointer call_data);

	if (ttab_dialog != (Widget) NULL) {

	    XmListDeleteAllItems (ttab_list);

	} else {

	    ttab_dialog = XtVaCreatePopupShell ("Product Tabular Data",
		xmDialogShellWidgetClass,	draw_widget,
		XmNdeleteResponse,		XmDESTROY,
		NULL);

	    form = XtVaCreateWidget ("tabular_form",
		xmFormWidgetClass,	ttab_dialog,
		XmNforeground,		white_color,
		XmNbackground,		steelblue_color,
		NULL);

	    rowcol = XtVaCreateWidget ("tabular_rowcol",
		xmRowColumnWidgetClass,	form,
		XmNtopAttachment,	XmATTACH_FORM,
		XmNleftAttachment,	XmATTACH_FORM,
		XmNrightAttachment,	XmATTACH_FORM,
		XmNorientation,		XmHORIZONTAL,
		XmNforeground,		white_color,
		XmNbackground,		steelblue_color,
		NULL);

	    page = XtVaCreateManagedWidget ("Previous Page",
		xmPushButtonWidgetClass,	rowcol,
		XmNforeground,		white_color,
		XmNbackground,		steelblue_color,
		NULL);

	    XtAddCallback (page,
		XmNactivateCallback, ttab_page_callback, (XtPointer) -1);

	    page = XtVaCreateManagedWidget ("Next Page",
		xmPushButtonWidgetClass,	rowcol,
		XmNforeground,		white_color,
		XmNbackground,		steelblue_color,
		NULL);

	    XtAddCallback (page,
		XmNactivateCallback, ttab_page_callback, (XtPointer) 1);

	    XtManageChild (rowcol);

	    XtSetArg (args [0], XmNvisibleItemCount, ttab->number_of_lines [0]);
	    XtSetArg (args [1], XmNtopWidget,        rowcol);
	    XtSetArg (args [2], XmNtopAttachment,    XmATTACH_WIDGET);
	    XtSetArg (args [3], XmNleftAttachment,   XmATTACH_WIDGET);
	    XtSetArg (args [4], XmNrightAttachment,  XmATTACH_WIDGET);
	    XtSetArg (args [5], XmNbottomAttachment, XmATTACH_WIDGET);
	    XtSetArg (args [6], XmNfontList,	 fontlist);
	    XtSetArg (args [7], XmNforeground,	 white_color);
	    XtSetArg (args [8], XmNbackground,	 seagreen_color);
	    XtSetArg (args [9], XmNwidth, 		 720);

	    ttab_list = XmCreateScrolledList (form,
		"ttab_scrolled_list",
		args,
		10);

	    XtManageChild (ttab_list);

	    XtManageChild (form);

	    XtPopup (ttab_dialog, XtGrabNone);

	}

	current_page = 0;

	for (i=0;i<=ttab->number_of_lines [current_page];i++) {

	    str = XmStringCreate (ttab->text [current_page][i], "ttab_font");

	    XmListAddItemUnselected (ttab_list, str, i+1);

	    XmStringFree (str);

	}
}
Exemple #21
0
void update_netcdfs(void)
{
    int i, j;
    char buf[256], fname[512];
    XmString xms;
    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;
    extern int ncopts;

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

    if (netcdf_frame != NULL)
    {
        strcpy(fname, xv_getstr(netcdf_file_item));
        set_wait_cursor();
        XmListDeleteAllItems(netcdf_listx_item);
        XmListDeleteAllItems(netcdf_listy_item);
        xms = XmStringCreateLtoR("INDEX", charset);
        XmListAddItemUnselected(netcdf_listx_item, xms, 0);
        XmStringFree(xms);

        if (strlen(fname) < 2)
        {
            unset_wait_cursor();
            return;
        }
        if ((cdfid = ncopen(fname, NC_NOWRITE)) == -1)
        {
            errwin("Can't open file.");
            unset_wait_cursor();
            return;
        }
        ncinquire(cdfid, &ndims, &nvars, &ngatts, &recdim);
        /*
          printf("%d %d %d %d\n", ndims, nvars, ngatts, recdim);
      */
        for (i = 0; i < ndims; i++)
        {
            ncdiminq(cdfid, i, NULL, &dimlen[i]);
        }
        for (i = 0; i < nvars; i++)
        {
            ncvarinq(cdfid, i, varname, &datatype, &ndims, dim, &natts);
            if ((var_id = ncvarid(cdfid, varname)) == -1)
            {
                char ebuf[256];
                sprintf(ebuf, "update_netcdfs(): No such variable %s", varname);
                errwin(ebuf);
                continue;
            }
            if (ndims != 1)
            {
                continue;
            }
            ncdiminq(cdfid, dim[0], (char *)NULL, &len);
            sprintf(buf, "%s", varname);
            xms = XmStringCreateLtoR(buf, charset);
            XmListAddItemUnselected(netcdf_listx_item, xms, 0);
            XmListAddItemUnselected(netcdf_listy_item, xms, 0);
            XmStringFree(xms);
        }
        ncclose(cdfid);
        unset_wait_cursor();
    }
}
Exemple #22
0
/*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 ;
}
Exemple #23
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 ;
    }
Exemple #24
0
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), "");
}