Example #1
0
File: mtfgui.c Project: juddy/edcde
static void
XlfdCB()
{
  Widget	dialog;
  Arg		args[5];
  char		mess[1024];
  int		n;
  XmString	cs, cs1, cs2;

  sprintf(mess, "%s : %s", resource.file_name, fullpath);
  cs = XmStringCreateLocalized(mess);
  cs1 = XmStringSeparatorCreate();
  cs2 = XmStringConcat(cs, cs1);
  XmStringFree(cs);
  XmStringFree(cs1);
  sprintf(mess, "%s : %s", resource.xlfd_name, fullFontData.xlfdname);
  cs1 = XmStringCreateLocalized(mess);
  cs = XmStringConcat(cs2, cs1);
  XmStringFree(cs1);
  XmStringFree(cs2);
  n = 0;
  XtSetArg (args[n], XmNtitle, resource.l_xlfd_title); n++;
  XtSetArg (args[n], XmNmessageString, cs); n++;
  XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
  dialog = XmCreateInformationDialog (toplevel, "Xlfd_name", args, n);
  XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
  XtUnmanageChild (XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
  XtManageChild (dialog);
  XmStringFree(cs);
}
Example #2
0
XmString multiline_xmstring(char *text)
{

    char *start, *end;
    Boolean done;
    XmString string = NULL;
    XmString tmp_string;
    XmString separator = NULL;
    char *buffer;

    if (!text) return (NULL);


    buffer = alloca(strlen((const char *)text) + 1);

    start = text;
    done = FALSE;


    while ( ! done)           /* loop thu local copy */
      {                               /* looking for \n */
      end = start;

      while ((*end != '\0') && (*end != '\n'))  end++;

      if (*end == '\0')
          done = TRUE;                /* we are at the end */

      /* Don't convert empty string unless it's an initial newline. */
      if ((start != end) || (start == text))
          {
          strncpy(buffer, start, end - start);
          buffer[end - start] = '\0';
          if (!string)
              string = XmStringCreate(buffer, XmFONTLIST_DEFAULT_TAG);
          else
              {
              tmp_string = XmStringCreate(buffer, XmFONTLIST_DEFAULT_TAG);
              string = XmStringConcat(string, tmp_string);
              XmStringFree(tmp_string);
              }
          }

      /* Make a separator if this isn't the last segment. */
      if (!done) 
          {
          if (!separator)
              separator = XmStringSeparatorCreate();
          string = XmStringConcat(string, separator);
          start = ++end;              /* start at next char */
          }
      }

    if (separator)
      XmStringFree(separator);

    return (string);
}
Example #3
0
int
main(int argc, char **argv)
{
	Widget		toplevel, one, d;
	XtAppContext	app;
	XmFontList	fontlist;
	XmString	xms;
	Arg           args[10];
	XmTab         tabs[MAX_COLUMNS];
	XmTabList     tablist;
	XmRendition   renditions[MAX_COLUMNS];
	XmRenderTable rendertable;
	XmStringTable xmstring_table;
	int           xmstring_count;
	Pixel         pixels[MAX_COLUMNS];
	int           n, i;

	XtSetLanguageProc(NULL, NULL, NULL);
	toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv,
		fallback, NULL);

	d = XmGetXmDisplay(XtDisplay(toplevel));

	/* Create the multi-column data for the list */

	xmstring_table = CreateListData(&xmstring_count) ;

	xms = xmstring_table[0];
	for (i=1; i<xmstring_count; i++) {
		XmString	s, x;
		s = XmStringSeparatorCreate();
		x = XmStringConcat(xms, s);
		xms = XmStringConcat(x, xmstring_table[i]);
	}

	one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel,
		XmNalignment,	XmALIGNMENT_BEGINNING,
		XmNlabelString, xms,
		NULL);

	XtRealizeWidget(toplevel);

#if 0
/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   {CWWidth | CWHeight            ,    0,    0,  112,   58, 0,0,0}, /* One */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
#endif

	LessTifTestMainLoop(toplevel);
	exit(0);
}
Example #4
0
/*
 * as close as we can come to Latin1Create without knowing the charset of
 * Latin1.  This imposes the semantic of \n meaning separator.
 */
XmString 
XmStringLtoRCreate(
        char *text,
        XmStringTag tag )
{
  char *start, *end;
  Boolean done;
  XmString string;

  _XmProcessLock();
  if (!text) {
	_XmProcessUnlock();
	return (NULL);
  }

  start = text;
  done = FALSE;

  /* Set the direction once only at the beginning. */
  string = XmStringDirectionCreate(XmSTRING_DIRECTION_L_TO_R);
    
  while ( ! done)		/* loop thu local copy */
    {				/* looking for \n */
      end = start;

      while ((*end != '\0') && (*end != '\n'))  end++;

      if (*end == '\0')
	done = TRUE;		/* we are at the end */

      /* Don't convert empty string unless it's an initial newline. */
      /* Done so StringHeight has clue to size of empty lines. */
      if ((start != end) || (start == text))
        string = XmStringConcatAndFree (string, 
					_XmStringNCreate(start, tag, 
							 (int)(end - start))); /* Wyoming 64-bit fix */ 
      
      /* Make a separator if this isn't the last segment. */
      if (!done) {
        string = XmStringConcatAndFree(string, XmStringSeparatorCreate());
	start = ++end;		/* start at next char */
      }
    }

  _XmProcessUnlock();
  return (string);
}
Example #5
0
void 
MakeDialog( DialogType dtype )
{
    register int i, j;

    int		width;
    
    FILE	*fp, *fopen();
    char	buffer[128];
    char	*str;

    Widget	w, text;
    Dimension	txt_width, txt_height;
    XmString	ok, cancel, nw, sv;

    Widget      tlev;

    /*
     *  do things common to all dialogs...
     */

    ok     = ReadCatalogXms(MC_LABEL_SET, MC_OK_LABEL, MC_DEF_OK_LABEL);
    cancel = ReadCatalogXms(MC_LABEL_SET, MC_CANCEL_LABEL, MC_DEF_CANCEL_LABEL);

    i = InitArg(MessageBox);
    XtSetArg(argt[i], XmNmarginHeight,		MBOX_MARGIN_HEIGHT	); i++;
    XtSetArg(argt[i], XmNmarginWidth,		MBOX_MARGIN_WIDTH	); i++;
    XtSetArg(argt[i], XmNshadowThickness,	SHADOW_THICKNESS	); i++;
    XtSetArg(argt[i], XmNokLabelString,		ok			); i++;
    XtSetArg(argt[i], XmNcancelLabelString,	cancel			); i++;
    XtSetArg(argt[i], XmNnoResize,		False			); i++;
    XtSetArg(argt[i], XmNresizePolicy,		XmRESIZE_ANY		); i++;

    /*
     *  create the various dialogs...
     */

    /* JET - check the matte widget, and if non-null, well use that as
     * the parent for dialogs.  Otherwise use table (the original
     * toplevel widget for this func).  This is useful for Xinerama so
     * that child dialogs are centered on the matte, and not the whole
     * SLS screen.
     */
    if (matte != (Widget)NULL)
      tlev = matte;
    else
      tlev = table;


    switch (dtype) {

    case error:
	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_LOGIN, "");
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateErrorDialog(tlev, "error_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	error_message = w;
	break;


    case help:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
	str = (char*) ReadCatalog(MC_HELP_SET, MC_HELP, MC_DEF_HELP);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
	break;


    case copyright:
	if ((fp = fopen(COPYRIGHT,"r")) == NULL)
#if defined( __hp_osf )
	    xmstr = XmStringCreate("Cannot open copyright file '/usr/X11/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#else
	    xmstr = XmStringCreate("Cannot open copyright file '/etc/copyright'.",
				XmFONTLIST_DEFAULT_TAG);
#endif
	else {
	    xmstr = (XmString) NULL;
	
	    while (fgets(buffer, 128, fp) != NULL) {
		j = strlen(buffer);
		if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';
	    
		if ( xmstr != NULL )
		    xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate());

		xmstr = XmStringConcat(xmstr,
	    			       XmStringCreate(buffer,
				       XmFONTLIST_DEFAULT_TAG));
	    }	    
	}

	fclose(fp);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateInformationDialog(tlev, "copyright_msg", argt, i);
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));
	
	XtAddCallback(w, XmNokCallback, CopyrightCB, (XtPointer) 0);    

	copyright_msg = w;
	break;
    

    case hostname:
	    
	nw = ReadCatalogXms(MC_LABEL_SET, MC_NW_LABEL,  MC_DEF_NW_LABEL);
	sv = ReadCatalogXms(MC_LABEL_SET, MC_START_LABEL, MC_DEF_START_LABEL);

	xmstr = ReadCatalogXms(MC_HELP_SET, MC_SYSTEM, MC_DEF_SYSTEM);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;
	XtSetArg(argt[i], XmNokLabelString,		nw		); i++;
	XtSetArg(argt[i], XmNcancelLabelString,		sv		); i++;

	w = XmCreateWarningDialog(tlev, "hostname_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	XmStringFree(nw);
	XmStringFree(sv);

	hostname_message = w;
	break;


    case expassword:

	xmstr = ReadCatalogXms(MC_ERROR_SET, MC_PASSWD_EXPIRED, 
			    MC_DEF_PASSWD_EXPIRED);
	XtSetArg(argt[i], XmNmessageString,		xmstr		); i++;

	w = XmCreateQuestionDialog(tlev, "password_msg", argt, i);

	XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

	passwd_message = w;
	break;


    case help_chooser:
	xmstr = ReadCatalogXms(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);

	w = XmCreateInformationDialog(tlev, "help_message", argt, i);
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_CANCEL_BUTTON));
        XtUnmanageChild(XmMessageBoxGetChild(w,XmDIALOG_HELP_BUTTON));

        txt_width = DisplayWidth (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_height = DisplayHeight (XtDisplay(w), DefaultScreen(XtDisplay(w)));
        txt_width = (txt_width > 850) ? 800 : txt_width - 50;
        txt_height = (txt_height > 900) ? 750 : txt_height - 150;
        i = InitArg(Text);
        XtSetArg(argt[i], XmNheight, txt_height); i++;
        XtSetArg(argt[i], XmNwidth, txt_width); i++;
        XtSetArg(argt[i], XmNeditMode, XmMULTI_LINE_EDIT); i++;
        XtSetArg(argt[i], XmNscrollBarDisplayPolicy, XmAS_NEEDED); i++;
        XtSetArg(argt[i], XmNscrollingPolicy, XmAUTOMATIC); i++;
        XtSetArg(argt[i], XmNeditable, False); i++;
        str = (char*)
	      ReadCatalog(MC_HELP_SET, MC_HELP_CHOOSER, MC_DEF_HELP_CHOOSER);
        XtSetArg(argt[i], XmNvalue, strdup(str)); i++;
        text = XmCreateScrolledText(w, "help_message_text", argt, i);

        XtManageChild(text);
        XtManageChild(w);
        help_message = w;
        break;
    }
Example #6
0
void 
RequestCB(
        XtPointer client_data,
        int *source,
        XtInputId *id)
{
  char buf[512];
  int count;
  int remainder;
  RequestHeader *phdr = (RequestHeader *)buf;

#ifdef VG_TRACE
  vg_TRACE_EXECUTION("main:  entered RequestCB ...");
#endif /* VG_TRACE */

 /*
  * There's a request in the pipe. Read the header.
  */
  count = read(0, buf, sizeof(*phdr));
  if (count != sizeof(*phdr))
  {
    return;
  }

 /*
  * Calculate amount of data after header.
  */ 
  remainder =  phdr->length - sizeof(*phdr);
  if (remainder > 0)
  {
   /*
    * Read remainder of request.
    */
    count = read(0, buf+sizeof(*phdr), remainder);
  }

 /* 
  * Initiate response to request.
  */
  switch(phdr->opcode)
  {
    case REQUEST_OP_EXIT:
#ifdef VG_TRACE
      vg_TRACE_EXECUTION("main:  got REQUEST_OP_EXIT ...");
#endif /* VG_TRACE */
      RespondExitCB(NULL, NULL, NULL);
      break;

    case REQUEST_OP_MESSAGE:
      {
        RequestMessage *r = (RequestMessage *)phdr;
        XmString string;

#ifdef VG_TRACE
        vg_TRACE_EXECUTION("main:  got REQUEST_OP_MESSAGE ...");
#endif /* VG_TRACE */
        if (r->idMC)
        {
          FILE *fp;

         /*
          * Caller passed in MC_* message id.
          */
          if (r->idMC == MC_NO_LOGIN &&
              (fp = fopen(NO_LOGIN_FILE,"r")) != NULL)
          {
           /*
            * For MC_NO_LOGIN read message from file.
            */
            char buffer[256];
            int j;

            string = NULL;

            while (fgets(buffer, 256, fp) != NULL)
            {
              j = strlen(buffer);
              if ( buffer[j-1] == '\n' ) buffer[j-1] = '\0';

              string = XmStringConcat(xmstr,
                                      XmStringCreate(buffer,
                                      XmFONTLIST_DEFAULT_TAG));
              string = XmStringConcat(xmstr, XmStringSeparatorCreate());
            }
          }
          else
          {
           /*
            * Read message from message catalog.
            */
            string = ReadCatalogXms(MC_ERROR_SET, r->idMC, buf+r->offMessage);
          }
        }
        else
        {
         /*
          * Generate message from provided string. 
          */
#ifdef SIA
          string = multiline_xmstring(buf+r->offMessage);
#else
          string = XmStringCreate(buf+r->offMessage,XmFONTLIST_DEFAULT_TAG);
#endif
        }
      
        _DtShowDialog(error, string);
 
        XmStringFree(string);
      }
      break;

    case REQUEST_OP_HOSTNAME:
#ifdef VG_TRACE
      vg_TRACE_EXECUTION("main:  got REQUEST_OP_HOSTNAME ...");
#endif /* VG_TRACE */
      _DtShowDialog(hostname, NULL);
      break;

    case REQUEST_OP_EXPASSWORD:
#ifdef VG_TRACE
      vg_TRACE_EXECUTION("main:  got REQUEST_OP_EXPASSWORD ...");
#endif /* VG_TRACE */
      _DtShowDialog(expassword, NULL);
      break;

    case REQUEST_OP_CHPASS:
#ifdef VG_TRACE
      vg_TRACE_EXECUTION("main:  got REQUEST_OP_CHPASS ...");
#endif /* VG_TRACE */
      break;

    case REQUEST_OP_CHALLENGE:
      {
        RequestChallenge *r = (RequestChallenge *)phdr;
        XmString string;
        int i;
        LoginTextPtr textdata;
        Boolean change;

#ifdef VG_TRACE
        vg_TRACE_EXECUTION("main:  got REQUEST_OP_CHALLENGE ...");
#endif /* VG_TRACE */
        textdata = GetLoginTextPtr(login_text);

        change = (textdata->bEcho != r->bEcho);

        XtUnmapWidget(textdata->text[textdata->bEcho]);

        textdata->bEcho = r->bEcho;
        textdata->noechobuf[0] = '\0';

        XtAddEventHandler(textdata->text[textdata->bEcho], ExposureMask, False,
                        FakeFocusIn, NULL);

        XtMapWidget(textdata->text[textdata->bEcho]);

        XtPopup(login_shell, XtGrabNone); 

	XGrabKeyboard (dpyinfo.dpy, XtWindow (textdata->text[textdata->bEcho]),
        False, GrabModeAsync, GrabModeAsync, CurrentTime); 

        XmTextFieldSetString(
          textdata->text[textdata->bEcho],
          r->offUserNameSeed ? buf+r->offUserNameSeed : "");

        XmTextFieldSetSelection (
          textdata->text[1],
          0, XmTextFieldGetLastPosition(textdata->text[1]),
          CurrentTime );

        if (r->idMC)
        {
         /*
          * Read message from message catalog.
          */
          string = ReadCatalogXms(MC_LABEL_SET, r->idMC, buf+r->offChallenge);
        }
        else
        {
         /*
          * Generate message from provided string.
          */
          string = XmStringCreate(buf+r->offChallenge,XmFONTLIST_DEFAULT_TAG);
        }

        i = 0;
        XtSetArg(argt[i], XmNlabelString,       string                   ); i++;
        XtSetValues(login_label, argt, i);

        XmStringFree(string); 

        if (change)
        {
           char buf[256];

           i = 0;
           if (textdata->bEcho)
           {
             XtSetArg(argt[i], XmNlabelString, textdata->onGreeting     ); i++;
           }
           else
           {
             sprintf(buf, textdata->offGreetingFormat,
                     textdata->offGreetingUname);
             string = XmStringCreate(buf, XmFONTLIST_DEFAULT_TAG);
             XtSetArg(argt[i], XmNlabelString, string    ); i++;
             free(textdata->offGreetingUname);
           }
           XtSetValues(greeting, argt, i);
	   /* set the dt_label with the session that is enabled */
  	   SetDtLabelAndIcon();

        }

        XtSetSensitive(ok_button, True);
        XtSetSensitive(clear_button, True);
        XtSetSensitive(options_button, True);
        XtSetSensitive(help_button, True);

	XUngrabKeyboard(dpyinfo.dpy,CurrentTime);
      }
      break;
#ifdef SIA
    case REQUEST_OP_FORM:
      {
      RequestForm *r = (RequestForm *)buf;
      int i;
      char *prompt_ptr;

#ifdef VG_TRACE
      vg_TRACE_EXECUTION("main:  got REQUEST_OP_FORM ...");
#endif /* VG_TRACE */
      siaFormInfo.num_prompts = r->num_prompts;
      siaFormInfo.rendition = r->rendition;
      siaFormInfo.title = XtMalloc(strlen(buf + r->offTitle));
      strcpy(siaFormInfo.title, buf + r->offTitle);

      prompt_ptr = buf + r->offPrompts;

      for (i=0; i < siaFormInfo.num_prompts; i++)
          {
          siaFormInfo.visible[i] = r->visible[i];
          siaFormInfo.prompts[i] = XtMalloc(strlen(prompt_ptr));
          siaFormInfo.answers[i] = NULL;
          strcpy(siaFormInfo.prompts[i], prompt_ptr);
          prompt_ptr += strlen(prompt_ptr) + 1;
          }

      /*
       * Create Widgets:
       *  Form
       *   Title
       *   prompt labels and answer text fields for each prompt
       *   OK button
       * Add callbacks as needed.  If not visible don't echo.
       * On OK callback, collect info and send it.  Destroy widgets.
       */
       SiaForm(&siaFormInfo);

      }
      break;
#endif /* SIA */
  }


#if 0
  {
   /*
    * Send immediate response to debug.
    */
    char outbuf[512];
    char *p;
    ResponseDebug *rdebug = (ResponseDebug *)outbuf;

    rdebug->hdr.opcode = REQUEST_OP_DEBUG;
    rdebug->hdr.reserved = 0;
    rdebug->offString = sizeof(*rdebug);
    p = ((char *)(rdebug)) + rdebug->offString;
    strcpy(p, "This is my debug string");
    rdebug->hdr.length = sizeof(*rdebug) + strlen(p) + 1;
    
    TellRequester(outbuf, (size_t) rdebug->hdr.length);
  } 
#endif
}
Example #7
0
static void
da_expose(Widget          w,
   	  XtPointer       client_data,
	  XtPointer       call_data)
{
	XExposeEvent   *e = &((XmDrawingAreaCallbackStruct *) call_data)
	->event->xexpose;
	XmString       *items, *selected_items, out_string, tmp_string;
	Boolean         underline;
	int             item_count, selected_count;
	Widget          list = (Widget) client_data;
	Dimension       width, height, extent, item_extent, string_height;
	int             i;
	XmFontList      font_list;
	XRectangle      clip;

	/* Extract items, selected items and font from XmList */
	XtVaGetValues(list,
	              XmNitems, &items,
		      XmNitemCount, &item_count,
		      XmNselectedItems, &selected_items,
		      XmNselectedItemCount, &selected_count,
		      XmNfontList, &font_list,
		      NULL);
	XtVaGetValues(w, XmNwidth, &width, XmNheight, &height, NULL);
	underline = (selected_count > 0);
	create_gc(w);
	extent = 0;
	out_string = NULL;
	/*
	 * Form list items into a single compound string, inserting
	 * separators where needed to avoid drawing outside the XmDrawingArea
	 */
	for (i = 0; i < item_count; i++) {
		item_extent = XmStringWidth(font_list, items[i]);
		if (out_string != NULL && (extent + item_extent > width)) {
			extent = 0;
			out_string = string_append(out_string,
						 XmStringSeparatorCreate());
		}
		tmp_string = XmStringConcat(out_string, items[i]);
		XmStringFree(out_string);
		out_string = tmp_string;
		extent = extent + item_extent;
	}
	string_height = XmStringHeight(font_list, out_string);
	clip.x = e->x;
	clip.y = e->y;
	clip.width = e->width;
	clip.height = e->height;
	XSetClipRectangles(XtDisplay(w), gc, 0, 0, &clip, 1, YXBanded);
	/* Draw compound string, underlining the selected item if any */
	if (underline)
		XmStringDrawUnderline(XtDisplay(w), XtWindow(w), font_list,
		     out_string, gc, 0, (height - string_height) / 2, width,
				      XmALIGNMENT_CENTER,
				      XmSTRING_DIRECTION_L_TO_R, NULL,
				      selected_items[0]);
	else
		XmStringDraw(XtDisplay(w), XtWindow(w), font_list, out_string, gc,
			     0, (height - string_height) / 2, width,
			     XmALIGNMENT_CENTER,
			     XmSTRING_DIRECTION_L_TO_R, NULL);
	XmStringFree(out_string);
}
Example #8
0
int
main(int argc, char **argv)
{
	Widget		toplevel, one, d;
	XtAppContext	app;
	XmFontList	fontlist;
	XmString	xms;
	Arg           args[10];
	XmTab         tabs[MAX_COLUMNS];
	XmTabList     tablist;
	XmRendition   renditions[MAX_COLUMNS];
	XmRenderTable rendertable;
	XmStringTable xmstring_table;
	int           xmstring_count;
	Pixel         pixels[MAX_COLUMNS];
	int           n, i;

	XtSetLanguageProc(NULL, NULL, NULL);
	toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL);

	d = XmGetXmDisplay(XtDisplay(toplevel));
	XtAddCallback(d, XmNnoFontCallback, NoFontCB, NULL);
	XtAddCallback(d, XmNnoRenditionCallback, NoRenditionCB, NULL);

	/* Create some colors */
	for (i = 0 ; i < MAX_COLUMNS ; i++) {
		pixels[i] = ConvertStringToPixel (toplevel, rendition_data[i].color) ;
	}

	/* Create tab stops for columnar output */
	for (i = 0 ; i < MAX_COLUMNS ; i++) {
		tabs[i] = XmTabCreate ((float) 1.5, 
				       XmINCHES, 
				       ((i == 0) ? XmABSOLUTE : XmRELATIVE),
				       XmALIGNMENT_BEGINNING, 
				       ".") ;
	}

	/* Create a tablist table which contains the tabs */
	tablist = XmTabListInsertTabs (NULL, tabs, XtNumber (tabs), 0) ;

	/* Create some multi-font/color renditions, and use the tablist */
	/* This will be inherited if we use it on the first rendition   */
	for (i = 0 ; i < MAX_COLUMNS ; i++) {
		n = 0 ;

		if (i == 0) {
			XtSetArg (args[n], XmNtabList, tablist); n++;
		}

		XtSetArg (args[n], XmNrenditionForeground, pixels[i]); n++;
		XtSetArg (args[n], XmNfontName, rendition_data[i].font); n++;
		XtSetArg (args[n], XmNfontType, XmFONT_IS_FONT); n++;
		renditions[i] = XmRenditionCreate (toplevel, rendition_data[i].tag, args, n);
	}

	/* Create the Render Table */
	rendertable = XmRenderTableAddRenditions (NULL, renditions, XtNumber (renditions), XmMERGE_NEW) ;

	/* Create the multi-column data for the list */

	xmstring_table = CreateListData(&xmstring_count) ;

	xms = xmstring_table[0];
	for (i=1; i<xmstring_count; i++) {
		XmString	s, x;
		s = XmStringSeparatorCreate();
		x = XmStringConcat(xms, s);
		xms = XmStringConcat(x, xmstring_table[i]);
	}

	one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel,
		XmNalignment,	XmALIGNMENT_BEGINNING,
		XmNrenderTable,	rendertable,
		XmNlabelString, xms,
		NULL);

	XtRealizeWidget(toplevel);

#if 0
/* Note: the following values are the result of
 * querying the current geometry.
 */
{
static XtWidgetGeometry Expected[] = {
   {CWWidth | CWHeight            ,    0,    0,  112,   58, 0,0,0}, /* One */
};
/* toplevel should be replaced with to correct applicationShell */
PrintDetails(toplevel, Expected);
}
#endif

	LessTifTestMainLoop(toplevel);
	exit(0);
}