예제 #1
0
XmFontList
XmLFontListCopyDefault(Widget widget)
	{
	Widget parent;
	XFontStruct *font;
	XmFontList fontList, fl;

	fontList = 0;
	parent = XtParent(widget);
	while (parent)
		{
		fl = 0;
		if (XmIsVendorShell(parent) || XmIsMenuShell(parent))
			XtVaGetValues(parent, XmNdefaultFontList, &fl, NULL);
		else if (XmIsBulletinBoard(parent))
			XtVaGetValues(parent, XmNbuttonFontList, &fl, NULL);
		if (fl)
			{
			fontList = XmFontListCopy(fl);
			parent = 0;
			}
		if (parent)
			parent = XtParent(parent);
		}
	if (!fontList)
		{
		font = XLoadQueryFont(XtDisplay(widget), "fixed");
		if (!font)
			XmLWarning(widget,
				"FontListCopyDefault() - FATAL ERROR - can't load fixed font");
		fontList = XmFontListCreate(font, XmSTRING_DEFAULT_CHARSET);
		}
	return fontList;
	}
예제 #2
0
파일: test2.c 프로젝트: melanj/lesstif
static void
initialise_objects(Widget parent)
{
	const char from_s[] = "-*-fixed-*-*-*-*-24-*-*-*-*-*-*-*=japanese,-*-lucidabright-medium-i-*-*-24-*-*-*-*-*-*-*=large_italic,-*-lucidabright-demibold-r-*-*-24-*-*-*-*-*-*-*=large_bold,-*-lucidabright-demibold-i-*-*-14-*-*-*-*-*-*-*=small_italic,-*-lucidabright-demibold-r-*-*-14-*-*-*-*-*-*-*=small_bold";
	XrmValue from, to;
        static int _xd_initialised = 0;
	XmFontList newfl;

	if ( _xd_initialised ) return;
	_xd_initialised = 1;
	from.size = strlen(from_s)+1;
	from.addr = XtMalloc ( from.size );
	strcpy ( from.addr, from_s );
	to.addr=NULL;
	XtConvert( parent, XmRString, &from, XmRFontList, &to);
	XtFree ( from.addr );

        newfl = *((XmFontList*)to.addr);
#if defined(LESSTIF_VERSION) && defined(TRY_IT)
	if(newfl)
  		printf("tag0=%s\n", newfl[0].tag);
	else
		printf("No fontlist returned\n");
#endif
	f1 = XmFontListCopy(newfl);
}
예제 #3
0
WXFontType wxFont::GetFontTypeC(WXDisplay* display) const
{
#if wxMOTIF_USE_RENDER_TABLE
    return Ok() ? GetRenderTable(display) : NULL;
#else
    return Ok() ? XmFontListCopy( (XmFontList)GetFontList(1.0, display) ) : NULL;
#endif
}
예제 #4
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
    }
}
예제 #5
0
void
ListView::create_ui_objects()
{
  /* -------- Create ui components. -------- */
  f_shell = new WTopLevelShell (toplevel(), WPopup, f_name);
  window_system().register_shell (f_shell);
  WXmForm form (*f_shell, "form");

  /* -------- allow child to be creative -------- */
  child_create_ui_pre(form);


  WXmPushButton close (form, "close", WAutoManage);
  WXmPushButton help (form, "help", WAutoManage);

  XtVaSetValues(close, XmNlabelString,
	(XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 12, "Close")), NULL);
  XtVaSetValues(help, XmNlabelString,
	(XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 48, "Help")), NULL);

  // 7/30/93 rtp - bear with this hack, it's a little bogus
  char *help_name = new char[strlen(f_name) + strlen("_help") + 1];
  sprintf(help_name, "%s%s", f_name, "_help");
  // What i've done is appended '_help' to the widget name and added
  // a help callback to the help button that will reference this name
  help_agent().add_activate_help (help, help_name);

  f_activate = WXmPushButton (form, "activate", WAutoManage);
  XtVaSetValues(f_activate, XmNlabelString,
	(XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 165, "Display")), NULL);
  //  WXmLabelGadget label (form, "label", WAutoManage);
  WXmSeparator separator (form, "separator", WAutoManage);
  // NOTE: Fix WWL to have a scrolled list object!
  Widget scrolled_list = XmCreateScrolledList (form, "list", NULL, 0);
  f_list = new WXmList (scrolled_list);
  f_list->Manage();

  XmFontList defaultList;
  {
    XmFontList font;
    XtVaGetValues(scrolled_list, XmNfontList, &font, NULL);
    defaultList = XmFontListCopy(font);
  }
  if (window_system().dtinfo_space_font())
    defaultList = XmFontListAppendEntry(defaultList,
                                        window_system().dtinfo_space_font());
  XtVaSetValues(scrolled_list, XmNfontList, defaultList, NULL);

  /* -------- let child add anything else -------- */
  child_create_ui_post(form);

  /* -------- Callbacks -------- */
  f_wm_delete_callback =
    new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(),
		   this, (WWL_FUN) &ListView::close_window);
  close.SetActivateCallback (this, (WWL_FUN) &ListView::close_window);
  f_list->SetSingleSelectionCallback (this, (WWL_FUN) &ListView::select);
  f_list->SetBrowseSelectionCallback (this, (WWL_FUN) &ListView::select);
  f_list->SetDefaultActionCallback (this, (WWL_FUN) &ListView::activate);
  f_activate.SetActivateCallback (this, (WWL_FUN) &ListView::activate);

  /* -------- Finalize -------- */
  form.DefaultButton (f_activate);
  form.ShadowThickness (0);  // get rid of border turds (motif bug)
  form.Manage();
}
예제 #6
0
파일: Format.c 프로젝트: idunham/cdesktop
/******************************************************************************
 * Function:	int FormatChunksToXmString ()
 *
 * Parameters:
 *               *ret_list may be NULL when called
 *
 * Returns:	0 if successful, -1 if errors
 *
 * errno Values:
 *
 * Purpose:	Take some rich text chunks and turn it into an XmString.
 *
 ******************************************************************************/
static int
FormatChunksToXmString(
    DtHelpDispAreaStruct *pDAS,
    Boolean		  free_flag,
    void		**title_chunks,
    XmString		 *ret_title,
    XmFontList		 *ret_list,
    Boolean		 *ret_mod )
{
    int			 result = 0;
    int			 i;
    long		 j;
    int			 quarkCount;
    long		 chunkType;
    long		 myIdx;
    _DtCvPointer	 fontPtr;
    char		*charSet;
    const char		*strChunk;
    char		 buffer[16];
    _DtHelpFontHints		 fontSpecs;
    XmFontContext	 fontContext;
    XmString		 partTitle;
    XmString		 newTitle;
    XrmQuark		 charSetQuark;
    XrmName		 myCharSetQuarks[20];
    XrmName		 xrmName[_CEFontAttrNumber];
    Boolean		 myMore;

    /*
     * Initialize the pointers.
     */
    *ret_title = NULL;
    *ret_mod   = False;

    if (title_chunks == NULL)
	return -1;

    /*
     * initialize the font context
     */
    _DtHelpCeCopyDefFontAttrList(&fontSpecs);
    if ( NULL != *ret_list )
      {
        if (XmFontListInitFontContext (&fontContext, *ret_list) == False)
            result = -1;
        else 
          {
            XFontStruct *myFontStruct;
            /*
             * quarkize all the character sets found.
             */
            quarkCount = 0;
            do
              {
                myMore = XmFontListGetNextFont (fontContext, &charSet,
                                                                &myFontStruct);
                if (myMore)
                  {
                    myCharSetQuarks[quarkCount++] = 
                                                XrmStringToQuark (charSet);
                    XtFree (charSet);
                  }
              } while (myMore);
    
            XmFontListFreeFontContext (fontContext);
          }
      } /* if NULL != *ret_list */
    else
      { /* if NULL == *ret_list */
         quarkCount = 0;
         myCharSetQuarks[0] = 0;
      }

    /*
     * Build the XrmString based on the segments.
     * The format of the returned information is
     *		'DT_HELP_CE_CHARSET  locale  string'
     *		'DT_HELP_CE_FONT_PTR fontptr string'
     *		'DT_HELP_CE_SPC      spc'
     *		'DT_HELP_CE_STRING   string' - uses last specified
     *                                         charset/font_ptr.
     *
     * The order and manner in which the title_chunks are processed
     * is known and depended upon in several locations.
     * Do not change this without changing the other locations.
     * See the _DtHelpFormatxxx() routines and the ones that
     * create the title_chunk arrays in FormatSDL.c and FormatCCDF.c
     */
    myIdx = __DtHelpDefaultFontIndexGet(pDAS);
    _DtHelpCopyDefaultList(xrmName);
    for (i = 0; result == 0 && title_chunks[i] != DT_HELP_CE_END; i++)
      {
        /*
         * create a string for the char set and a quark for it.
         */
	chunkType = (long) title_chunks[i++];

        /*
	 * i now points to the first value after the type
	 */
	if (chunkType & DT_HELP_CE_CHARSET)
	  {
	    char *charSet;
	    char *lang = (char *) title_chunks[i];

	    /*
	     * test to see if the locale is in a lang.codeset form
	     */
	    if (_DtHelpCeStrchr(lang, ".", 1, &charSet) == 0)
	      {
		*charSet = '\0';
		charSet++;
	      }
	    else
	      {
		charSet = lang;
		lang    = NULL;
	      }

	    /*
	     * resolve/load the font for the default fonts
	     */
	    _DtHelpDAResolveFont(pDAS, lang, charSet, fontSpecs, &fontPtr);
	    myIdx = (long) fontPtr;
	    if (lang != NULL)
	      {
		charSet--;
		*charSet = '.';
	      }

	    if (free_flag)
	        free(title_chunks[i]);

	    /*
	     * move the i to point to the string.
	     */
	    i++;
	  }
	else if (chunkType & DT_HELP_CE_FONT_PTR)
	  {
	    /*
	     * get the default font for the language and code set.
	     */
	    (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)title_chunks[i],
					&xrmName[_DT_HELP_FONT_CHAR_SET]);
	    (void) __DtHelpFontLangQuarkGet(pDAS, (long)title_chunks[i],
					&xrmName[_DT_HELP_FONT_LANG_TER]);
	    (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);

	    /*
	     * move the i to point to the string.
	     */
	    i++;
	  }

        /*
	 * the i point spc or string.
	 */
	if (chunkType & DT_HELP_CE_SPC)
	  {
	    j        = (long) title_chunks[i];
	    strChunk = _DtHelpDAGetSpcString(pDAS->spc_chars[j].spc_idx);
	    fontPtr  = pDAS->spc_chars[j].font_ptr;

	    /*
	     * get the default font for the language and code set.
	     */
	    (void) __DtHelpFontCharSetQuarkGet(pDAS, (long)fontPtr,
					&xrmName[_DT_HELP_FONT_CHAR_SET]);
	    (void) __DtHelpFontLangQuarkGet(pDAS, (long)fontPtr,
					&xrmName[_DT_HELP_FONT_LANG_TER]);
	    (void) __DtHelpFontIndexGet(pDAS, xrmName, &myIdx);
	  }
	else /* if (chunkType & _DT_HELP_CE_STRING) */
	    strChunk = (char *) title_chunks[i];

	sprintf(buffer, "%ld", myIdx);
	charSetQuark = XrmStringToQuark(buffer);

        j = 0;
        while (j < quarkCount && myCharSetQuarks[j] != charSetQuark)
            j++;

        /*
         * If we didn't find a matching character set,
         * add it to the list.
         */
        if (j >= quarkCount)
          {
	    /* Copy the input list so XmFontListAppendEntry can mangle it. */
	    /* But only do it once! */
	    if (False == *ret_mod)
	       *ret_list = XmFontListCopy(*ret_list);

	    if (myIdx < 0)
	      {
		XFontSet fontSet = __DtHelpFontSetGet(pDAS->font_info, myIdx);
                XmFontListEntry fontEntry;

		fontEntry = XmFontListEntryCreate (buffer,
						XmFONT_IS_FONTSET,
						(XtPointer) fontSet);
		*ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
		XmFontListEntryFree (&fontEntry);
	      }
	    else
	      {
		XFontStruct *fontStruct =
				__DtHelpFontStructGet(pDAS->font_info, myIdx);
                XmFontListEntry fontEntry;

		fontEntry = XmFontListEntryCreate (buffer,
						XmFONT_IS_FONT,
						(XtPointer) fontStruct);
		*ret_list = XmFontListAppendEntry (*ret_list, fontEntry);
		XmFontListEntryFree (&fontEntry);
	      }

           *ret_mod = True;
            if (*ret_list == NULL)
                result = -1;

            myCharSetQuarks[quarkCount++] = charSetQuark;
          }

        /*
         * add this segment to the XmString.
         */
        if (result == 0)
          {
            if (*ret_title == NULL)
                *ret_title = XmStringGenerate ((char *) strChunk, buffer, 
					       XmCHARSET_TEXT, NULL);
            else
              {
                partTitle = XmStringGenerate ((char *) strChunk, buffer,
					      XmCHARSET_TEXT, NULL);

                newTitle = XmStringConcat (*ret_title, partTitle);

                XmStringFree (*ret_title);
                XmStringFree (partTitle);
                *ret_title = newTitle;
              }

            /*
             * if a newline was specified,
             * replace it with a blank.
             */
            if (*ret_title != NULL && (chunkType & DT_HELP_CE_NEWLINE))
              {
                partTitle = XmStringGenerate (" ", buffer, XmCHARSET_TEXT, NULL);
                newTitle = XmStringConcat (*ret_title, partTitle);
                XmStringFree (*ret_title);
                XmStringFree (partTitle);
                *ret_title = newTitle;
              }

            if (*ret_title == NULL)
                result = -1;
          }

	if (free_flag && (chunkType & DT_HELP_CE_STRING))
	    free(title_chunks[i]);
      }
    /*
     * deallocate the memory.
     */
    if (free_flag) free(title_chunks);
    return result;
}
예제 #7
0
/**********************************************************************************
 * FUNCTIONS
 **********************************************************************************/
int video_open(PLOT *plot)
{
	struct videodata *plotdata;
	Display *dpy;
	Screen *scr;
	Widget w, mw, m0, m1, m2, m3;
	int status = SUCCESS;
	Dimension width, height;
	int depth;
    XGCValues values;
	unsigned long foreground, background;
	XmString xmstr, xmstr1;
	Arg args[10];
	int n;

	plot->plotdata = (void *)calloc(1, sizeof(struct videodata));
	plotdata = (struct videodata *)plot->plotdata;
	plotdata->image = (XImage *)calloc(sizeof(XImage), 1);
	plotdata->framedata = NULL;
	plotdata->width = 0;
	plotdata->height = 0;
	plotdata->ncomps = 0;
	plotdata->microsecs_per_frame = 0;
	plotdata->colormap = defaults.colormap;
	plotdata->framenum = 0;
	plotdata->loadedframenum = -1;

	plot->plot_widget = XtVaCreateManagedWidget("video", xmDrawingAreaWidgetClass, plot->panel->panel_container,
		XmNheight, defaults.video_height,
		XmNwidth, defaults.width,
		XmNmarginHeight, 0,
		XmNmarginWidth, 0,
		NULL);
	XtAddCallback(plot->plot_widget, XmNexposeCallback, video_expose_callback, (XtPointer)plot);
	XtAddCallback(plot->plot_widget, XmNresizeCallback, video_resize_callback, (XtPointer)plot);

	w = (Widget)plot->plot_widget;
	dpy = XtDisplay(w);
	scr = XtScreen(w);

	XtVaGetValues(w,
		XmNheight, &height,
		XmNwidth, &width,
		XmNdepth, &depth,
		XmNforeground, &foreground,
		XmNbackground, &background,
		NULL);

	/*
	** Get the font;  also, calculate the margins for the axes (this depends on the font size!).
	** Store these margins for use later (we might start off without axes, and turn them on later.
	*/
	plot->ticklblfont = XmFontListCopy(_XmGetDefaultFontList(w, XmLABEL_FONTLIST));
	plot->minoffx = 6 + XmStringWidth(plot->ticklblfont, xmstr = XmStringCreateSimple("-32768")); XmStringFree(xmstr);
	plot->minoffx2 = 0;
	plot->minoffy = 0;
	plot->minoffy2 = 6 + XmStringHeight(plot->ticklblfont, xmstr = XmStringCreateSimple("1")); XmStringFree(xmstr);

	plot->offx = 0;
	plot->offy = 0;
	plot->offx2 = 0;
	plot->offy2 = 0;
	plot->width = width;
	plot->height = height;
	plot->depth = depth;

	/*
	** Allocate our colors.  We use the XCC code that is:
	** Copyright 1994,1995 John L. Cwikla
	** This allows us to work on any visual, etc.   The danger is that
	** we may not get the exact colors we ask for... meaning that things
	** may not really be as we see them.  This is unfortunate, but the
	** alternative is to not run at all (the old code crashed).  So...
	*/
	plotdata->ncolors = MIN(SONO_DEFAULT_MAX_COLORS, MIN(XDisplayCells(dpy, XDefaultScreen(dpy)), MAXCOLORS - RESERVED_COLORS));
	plotdata->xcc = XCCCreate(dpy, DefaultVisual(dpy, DefaultScreen(dpy)), TRUE, TRUE, XA_RGB_GRAY_MAP, &(plotdata->cmap));
	if (XCCGetNumColors(plotdata->xcc) < plotdata->ncolors)
	{
		plotdata->ncolors = XCCGetNumColors(plotdata->xcc);
		printf("Warning.  Using only %d colors.\n", plotdata->ncolors);
	}
	(*((colormap[plotdata->colormap]).cmap))(dpy, plotdata->ncolors, plotdata->colors, NULL);

	/*
	** Create the Graphics contexts.
	** drawing_GC is for the picture itself.  inverse_GC is for erasing.  mark_GC is for the subregion marks.
	*/
	values.font = getFontStruct(plot->ticklblfont)->fid;
	values.function = GXcopy;
	values.plane_mask = AllPlanes;
	values.foreground = foreground;
	values.background = background;
	plotdata->drawing_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCFont, &values);
	values.foreground = background;
	values.background = background;
	plotdata->inverse_GC = XtGetGC(w, GCForeground | GCBackground, &values);
	values.function = GXxor;
	values.plane_mask = foreground ^ background;
	values.foreground = 0xffffffff;
	values.background = 0x0;
	values.line_style = LineSolid;
	plotdata->mark_GC = XtGetGC(w, GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineStyle, &values);

	plotdata->pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), width, height, depth);
	plotdata->pixmapalloced = TRUE;
	XFillRectangle(dpy, plotdata->pixmap, plotdata->inverse_GC, 0, 0, width, height);

	/*
	** Create the popup menu
	** 
	*/
	n = 0;
	XtSetArg(args[n], XmNmenuPost, "<Btn3Down>"); n++;
	mw = plot->plot_popupmenu_widget = XmCreatePopupMenu(w, "popupmenu", args, n);

	m0 = XtVaCreateManagedWidget("m0", xmLabelGadgetClass, mw,
		XmNlabelString, xmstr1 = XmStringCreateSimple("Options"),
		NULL);
	XmStringFree(xmstr1);

	m1 = XtVaCreateManagedWidget("m1", xmSeparatorGadgetClass, mw,
		NULL);

	CreateMenuButton(m2, mw, "save", "Save", "Save");
	CreateMenuButton(m3, mw, "print", "Print EPS", "Print EPS");

	/*
	** Register an event handler
	*/
	XtAddEventHandler(w, KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | Button2MotionMask,
		FALSE, (XtEventHandler) video_event_handler, (XtPointer)plot);

	plot->plot_display = video_display;
	plot->plot_set = video_set;
	plot->plot_close = video_close;
	plot->plot_print = video_print;

	plot->plot_playmarker = NULL;
	plot->plot_showvideoframe = video_showvideoframe;
	plot->plot_clearmarks = NULL;
	plot->plot_drawstartmark = NULL;
	plot->plot_drawstopmark = NULL;
	plot->plot_conv_pixel_to_time = NULL;

	plot->plot_save = video_save;

	plot->plot_event_handler = video_event_handler;
	plot->plot_play = video_play;

	plotdata->butgrabbed = FALSE;
	plot->playmark = -1;
	plot->markx1 = -1;
	plot->markx2 = -1;

	plot->group->needpcm = 1;

	return status;
}
예제 #8
0
void
SearchHistoryListView::child_create_ui_pre(WXmForm &form)
{
  Widget header = WXmLabel(form, "header", WAutoManage);

  XmFontList header_font;
  {
    XmFontList font;
    XtVaGetValues(header, XmNfontList, &font, NULL);
    header_font = XmFontListCopy(font);
  }

  if (window_system().dtinfo_space_font())
    header_font = XmFontListAppendEntry(header_font,
                                        window_system().dtinfo_space_font());

  XtVaSetValues(header, XmNfontList, header_font, NULL);

#ifdef FONT_DEBUG
  XmFontContext font_context;

  if (XmFontListInitFontContext(&font_context, header_font))
  {

    XmFontListEntry fle = NULL;
    do
    {
      if (fle = XmFontListNextEntry(font_context)) {
	char* tag = XmFontListEntryGetTag(fle);
	if (tag)
	  fprintf(stderr, "(DEBUG) tag=%s\n", tag);
      }
    }
    while (fle);
  
    XmFontListFreeFontContext(font_context);
  }
#endif

  int number_width = WXmString("0").Width(header_font);

  WXmString matchString = CATGETS(Set_AgentLabel, 246, "Matches");
  WXmString scopeString = CATGETS(Set_AgentLabel, 243, "Scope");
  WXmString queryString = CATGETS(Set_AgentLabel, 230, "Query");

  int scope_offset = 8 * number_width;

  if (matchString.Width(header_font) >= scope_offset)
  {
    char* dots = "...";

    char* ungenerated = (char*)(matchString + WXmString(dots));

    WString anonym_wstring = ungenerated; // important for digital compiler!
    wchar_t* buf = (wchar_t*)anonym_wstring;
    wchar_t* ptr = buf + wcslen(buf) - (strlen(dots)+1);

    XtFree(ungenerated);

    WXmString stake;
    WString wdots(dots);    

    int allowance;
    do
    {
      char* str;
      memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));

      stake = str = WString(buf).get_mbstr();
      
      allowance = scope_offset - stake.Width(header_font);

      delete[] str;
    }
    while (allowance <= 0 && ptr >= buf);

    while (*ptr <= (wchar_t)' ' && ptr >= buf)
    {
      char* str;
      memcpy(ptr--, (wchar_t*)wdots, (strlen(dots)+1) * sizeof(wchar_t));

      stake = str = WString(buf).get_mbstr();
      allowance = scope_offset - stake.Width(header_font);

      delete[] str;
    }
    
    matchString = stake;
  }

  WXmString matchPostfix(
	window_system().make_space(
		scope_offset - matchString.Width(header_font),
		header
	),
	False);
  WXmString scopePostfix(
	window_system().make_space(
		22 * number_width - scopeString.Width(header_font),
		header
	),
	False);
	
  WXmString header_string = matchString + matchPostfix +
			    scopeString + scopePostfix +
			    queryString;
			
  XtVaSetValues(header, XmNlabelString, (XmString)header_string, NULL);

}