예제 #1
0
static RotatedTextItem *XRotRetrieveFromCache(Display* dpy, 
					      XFontStruct* font, 
					      float angle, 
					      char* text, 
					      int align)
{
    Font fid;
    char *font_name = NULL;
    long unsigned int    name_value;
    RotatedTextItem *item=NULL;
    RotatedTextItem *i1=first_text_item;
    
    /* get font name, if it exists */
    if(XGetFontProperty(font, XA_FONT, &name_value)) {
	  DEBUG_PRINT1("got font name OK\n");
	  font_name=XGetAtomName(dpy, name_value);
	  fid=0;
    }
#ifdef CACHE_FID
    /* otherwise rely (unreliably?) on font ID */
    else {
	  DEBUG_PRINT1("can't get fontname, caching FID\n");
	  font_name=NULL;
	  fid=font->fid;
    }
#else
    /* not allowed to cache font ID's */
    else {
예제 #2
0
void FontByNameFunc::execute() {
  ComValue& fontarg = stack_arg(0);
  const char*  fontval = fontarg.string_ptr();
  reset_stack();
  
  char* fontvaldup=strdup(fontval);
  Catalog* catalog = unidraw->GetCatalog();
  XDisplay* dpy =World::current()->display()->rep()->display_;
  XFontStruct* xfs = XLoadQueryFont(dpy, fontvaldup);
  PSFont* font = nil;
  
  if (!xfs){
    char* xfontval=psfonttoxfont(fontvaldup);
    fontvaldup = strdup(xfontval);
    xfs = XLoadQueryFont(dpy,xfontval);
    if (!xfs){
      fprintf(stderr, "Can not load font:  %s, \n", fontval);
      fprintf(stderr, "Keeping the current font.\n");
    }
  }
  if (xfs){
    unsigned long value;
    char fontname[CHARBUFSIZE];
    char fontsizeptr[CHARBUFSIZE];
    char fontfullname[CHARBUFSIZE];
    
    XGetFontProperty(xfs, XA_FULL_NAME, &value);
    strcpy(fontfullname, XGetAtomName(dpy, (Atom)value));
    
    XGetFontProperty(xfs, XA_FONT_NAME, &value);
    strcpy(fontname, XGetAtomName(dpy, (Atom)value));
    
    XGetFontProperty(xfs,XA_POINT_SIZE, &value);
    sprintf(fontsizeptr,"%d",(unsigned int)(value/10));
    
    font = catalog->FindFont(fontvaldup,fontname,fontsizeptr);
    delete fontvaldup;
  }
  FontCmd* cmd = nil;
  
  if (font) {
    cmd = new FontCmd(_ed, font);
    execute_log(cmd);
  }
  
}
/*
 * Function:
 *	SetTabs
 *
 * Arguments:
 *	w	  - MultiSink Object
 *	tab_count - number of tabs in the list
 *	tabs	  - text positions of the tabs
 *
 * Description:
 *	Sets the Tab stops.
 */
static void
SetTabs(Widget w, int tab_count, short* tabs)
{
    MultiSinkObject sink = (MultiSinkObject)w;
    int i;
    Atom XA_FIGURE_WIDTH;
    unsigned long figure_width = 0;
    XFontStruct *font;

    /*
     * Bug:
     *	 Suppose the first font of fontset stores the unit of column.
     *
     * By Li Yuhong, Mar. 14, 1991
     */
    {
	XFontStruct **f_list;
	char **f_name;

	(void)XFontsOfFontSet(sink->multi_sink.fontset, &f_list, &f_name);
	font = f_list[0];
    }

    /*
     * Find the figure width of the current font
     */
    XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", False);
    if (XA_FIGURE_WIDTH != None
	&& (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)
	    || figure_width == 0)) {
	if (font->per_char && font->min_char_or_byte2 <= '$'
	    && font->max_char_or_byte2 >= '$')
	    figure_width = font->per_char['$' - font->min_char_or_byte2].width;
	else
	    figure_width = font->max_bounds.width;
    }

    if (tab_count > sink->text_sink.tab_count) {
	sink->text_sink.tabs = (Position *)
	    XtRealloc((char *)sink->text_sink.tabs,
		      (Cardinal)(tab_count * sizeof(Position)));
	sink->text_sink.char_tabs = (short *)
	    XtRealloc((char *)sink->text_sink.char_tabs,
		      (Cardinal)(tab_count * sizeof(short)));
      }

    for (i = 0 ; i < tab_count ; i++) {
	sink->text_sink.tabs[i] = tabs[i] * figure_width;
	sink->text_sink.char_tabs[i] = tabs[i];
    }

    sink->text_sink.tab_count = tab_count;

#ifndef NO_TAB_FIX
    ((TextWidget)XtParent(w))->text.redisplay_needed = True;
#endif
}
예제 #4
0
FontRep* FontImpl::create(Display* d, const String& name, float scale) {
    static Atom XA_CHARSET_REGISTRY = 0;

    XDisplay* dpy = d->rep()->display_;
    NullTerminatedString s(name);
    XFontStruct* xf = XLoadQueryFont(dpy, s.string());
    if (xf == nil) {
	return nil;
    }

    FontRep* f = new FontRep(d, xf, scale);
    unsigned long value;
    if (XGetFontProperty(xf, XA_FULL_NAME, &value) ||
	XGetFontProperty(xf, XA_FAMILY_NAME, &value)
    ) {
	char* fullname = XGetAtomName(dpy, (Atom)value);
	f->name_ = new CopyString(fullname);
	XFree(fullname);
    } else {
	f->name_ = new CopyString(s.string());
    }

    if (XA_CHARSET_REGISTRY == 0) {
	XA_CHARSET_REGISTRY = XInternAtom(dpy, "CHARSET_REGISTRY", False);
    }
    if (XGetFontProperty(xf, XA_CHARSET_REGISTRY, &value)) {
	char* registry = XGetAtomName(dpy, (Atom)value);
	f->encoding_ = new CopyString(registry);
	XFree(registry);
    } else {
	f->encoding_ = nil;
    }

    if (XGetFontProperty(xf, XA_POINT_SIZE, &value)) {
	f->size_ = float(value / 10) * f->scale_;
    } else {
	f->size_ = 0;
    }

    return f;
}
예제 #5
0
/* Allocates memory for and returns a string containing the font's
 * registry and encoding separated by a dash, or NULL if it can't be
 * determined */
static char *
alloc_font_code_set(Display *display, XFontStruct *font)
{
    Atom ids[2];
    char *names[2];
    char *string;
    size_t length;

    /* Look up the font's CHARSET_REGISTRY property */
    if (!XGetFontProperty(font, atoms[AN_CHARSET_REGISTRY], &ids[0])) {
        return NULL;
    }

    /* Look up the font's CHARSET_ENCODING property */
    if (!XGetFontProperty(font, atoms[AN_CHARSET_ENCODING], &ids[1])) {
        return NULL;
    }

    /* Stringify the names */
    if (!XGetAtomNames(display, ids, 2, names)) {
        return NULL;
    }

    /* Allocate some memory to hold the code set name */
    length = strlen(names[0]) + 1 + strlen(names[1]) + 1;
    string = malloc(length);
    if (string == NULL) {
        XFree(names[0]);
        XFree(names[1]);
        return NULL;
    }

    /* Construct the code set name */
    sprintf(string, "%s-%s", names[0], names[1]);

    /* Clean up a bit */
    XFree(names[0]);
    XFree(names[1]);

    return string;
}
예제 #6
0
파일: selection.c 프로젝트: tomby42/prg-xws
/*
 * Pøipojit k serveru, zjistit o nìm informace
 */
static void open_display(void)
{
    Atom val;
    char *fname;
    
    display_name = XDisplayName(NULL);
    if(!(display = XOpenDisplay(display_name))) {
	fprintf(stderr, "Cannot connect to X server \"%s\"\n", display_name);
	exit(1);
    }
    debug("Connected to X server \"%s\"\n", display_name);
    
    screen_num = DefaultScreen(display);
    screen = DefaultScreenOfDisplay(display);
    debug("Default screen number is %d\n", screen_num);
    
    screen_width = DisplayWidth(display, screen_num);
    screen_height = DisplayHeight(display, screen_num);
    screen_width_mm = DisplayWidthMM(display, screen_num);
    screen_height_mm = DisplayHeightMM(display, screen_num);
    debug("Screen size is %ux%u pixels, %ux%u mm\n", screen_width,
	  screen_height, screen_width_mm, screen_height_mm);
    
    root = RootWindow(display, screen_num);
    black = BlackPixel(display, screen_num);
    white = WhitePixel(display, screen_num);
    debug("Root window ID is %#lx, black is %#lx, white is %#lx\n", root,
	  black, white);

    def_gc = DefaultGC(display, screen_num);
    /* Toto volání XQueryFont() do def_font->fid neulo¾í ID fontu, ale
     * grafického kontextu! Nevím, jak získat ID standardního fontu. */
    if(!(def_font = XQueryFont(display, XGContextFromGC(def_gc)))) {
	fprintf(stderr, "XQueryFont() failed\n");
	exit(1);
    }
    if(XGetFontProperty(def_font, XA_FONT, &val)) {
	fname = XGetAtomName(display, val);
	debug("Default font name: %s\n", fname);
	XFree(fname);
    } else
	fprintf(stderr, "Cannot obtain default font name\n");
}
예제 #7
0
파일: Converters.c 프로젝트: aosm/X11
/*ARGSUSED*/
static Boolean
_XawCvtFontStructToString(Display *dpy, XrmValue *args, Cardinal *num_args,
			  XrmValue *fromVal, XrmValue *toVal,
			  XtPointer *converter_data)
{
  static char buffer[128];
  Cardinal size;
  Atom atom;
  unsigned long value;

  if (*num_args != 0)
    TypeToStringNoArgsWarning(dpy, XtRFontStruct);

  if ((atom = XInternAtom(dpy, "FONT", True)) == None)
    return (False);

  size = 0;

  if (XGetFontProperty(*(XFontStruct **)fromVal->addr, atom, &value))
    {
      char *tmp = XGetAtomName(dpy, value);

      if (tmp)
	{
	  XmuSnprintf(buffer, sizeof(buffer), "%s", tmp);
	  size = strlen(tmp);
	  XFree(tmp);
	}
    }

  if (size)
    {
      ++size;
    string_done(buffer);
    }

  XawTypeToStringWarning(dpy, XtRFontStruct);

  return (False);
}
예제 #8
0
파일: fonts.c 프로젝트: OrangeTide/xforms
void
fl_set_font( int numb,
             int size )
{
    int dh;
    XCharStruct overall;
    XFontStruct *fs;

    fs = fl_get_font_struct( numb, size );

    /* cur_font is always the one in current GC */

    if ( fl_state[ fl_vmode ].cur_fnt == fs )
    {
#if FL_DEBUG >= ML_DEBUG
        M_debug( "fl_set_font", "current", fli_curfnt );
#endif
        return;
    }

    fl_state[ fl_vmode ].cur_fnt = flx->fs = fs;

    /* Basic font info (no need to send a string, we just want the maximum
       ascent and descent) */

    XTextExtents( flx->fs, "", 0, &dh, &flx->fasc, &flx->fdesc, &overall );
    flx->fheight = flx->fasc + flx->fdesc;

    XSetFont( flx->display, flx->textgc, flx->fs->fid );

    if ( fli_cntl.debug > 1 )
    {
        unsigned long res = 0;

        if ( XGetFontProperty( flx->fs, XA_RESOLUTION, &res ) )
            M_info2( "fl_set_font", "FontResolution: %lu", res );
    }
}
예제 #9
0
static
FlocaleCharset *FlocaleCharsetOfFontStruct(Display *dpy, XFontStruct *fs)
{
	unsigned long value = 0;
	char *name,*tmp;
	FlocaleCharset *fc;
	int count = 0;

	if (fs == NULL)
		return NULL;

	if (!XGetFontProperty(fs, XA_FONT, &value))
	{
		return NULL;
	}
	if ((name = XGetAtomName(dpy, value)) == NULL)
	{
		return NULL;
	}

	tmp = name;
	while (*tmp != '\0' && count < 13)
	{
		if (*tmp == '-')
		{
			count++;
		}
		tmp++;
		if (count == 13)
		{
			fc = FlocaleCharsetOfXCharset(tmp);
			XFree(name);
			return fc;
		}
	}
	XFree(name);
	return NULL;
}
예제 #10
0
파일: TextSink.c 프로젝트: aosm/X11libs
static void
SetXlfdDefaults(Display *display, XawTextProperty *property)
{
    Atom atom = XInternAtom(display, "FONT", True);
    unsigned long value;
    char *str;

    if (XGetFontProperty(property->font, atom, &value)) {
	char *xlfd = XGetAtomName(display, value);

	if (xlfd) {
	    char *sep = xlfd + 1;
	    char *name = sep;

	    property->xlfd = XrmStringToQuark(xlfd);

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->foundry = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');	*sep++ = '\0';
	    property->family = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');	*sep++ = '\0';
	    property->weight = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');	*sep++ = '\0';
	    property->slant = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');	*sep++ = '\0';
	    property->setwidth = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->addstyle = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->pixel_size = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->point_size = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->res_x = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->res_y = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->spacing = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->avgwidth = XrmStringToQuark(name);
	    name = sep;

	    sep = strchr(sep, '-');     *sep++ = '\0';
	    property->registry = XrmStringToQuark(name);
	    name = sep;

	    property->encoding = XrmStringToQuark(name);

	    XFree(xlfd);
	}
    }

    atom = XInternAtom(display, "UNDERLINE_THICKNESS", True);
    if (XGetFontProperty(property->font, atom, &value) &&
	(str = XGetAtomName(display, value)) != NULL) {
	property->underline_thickness = atoi(str);
	XFree(str);
    }
    else {
	/* XLFD says:
	 * CapStemWidth = average width of the stems of capitals
	 * if (UNDERLINE_THICKNESS undefined) then
	 *   UNDERLINE_THICKNESS = CapStemWidth
	 *
	 * How do I know the value of CapStemWidth??
	 */
	if (property->pixel_size != NULLQUARK) {
	    property->underline_thickness =
		atoi(XrmQuarkToString(property->pixel_size)) / 10;
	    property->underline_thickness =
		XawMax(1, property->underline_thickness);
	}
	else
	    property->underline_thickness = 1;
    }

    atom = XInternAtom(display, "UNDERLINE_POSITION", True);
    if (XGetFontProperty(property->font, atom, &value) &&
	(str = XGetAtomName(display, value)) != NULL) {
	property->underline_position = atoi(str);
	XFree(str);
    }
    else
	/* XLFD says:
	 * if (UNDERLINE_POSITION undefined) then
	 *   UNDERLINE_POSITION = ROUND((maximum_descent) / 2)
	 */
	property->underline_position =
	    property->font->max_bounds.descent >> 1;

    /* I am assuming xlfd does not consider that lines are
     * centered in the path */
    property->underline_position += property->underline_thickness >> 1;

}
예제 #11
0
void
ui_size_to_row_col(
    Widget	   text,
    unsigned short width,
    unsigned short height,
    int		   *row_ptr,
    int		   *col_ptr
)
{

    Widget	parent;
    Widget	vsb, hsb;
    Dimension	spacing    = 0;
    Dimension   text_spacing = 0;
    Dimension 	hsb_height = 0;
    Dimension	vsb_width  = 0;
    Dimension	margin_w = 0;
    Dimension	margin_h = 0;
    Dimension   p_margin_w = 0;
    Dimension   p_margin_h = 0;
    XmFontList  fontlist;
    XFontStruct  *font;
    unsigned long charwidth;
    unsigned long lineheight;
    Dimension    pane_width, pane_height;

    if (XtIsSubclass(text, dtTermWidgetClass))
    	XtVaGetValues(text,
                XmNmarginWidth, &margin_w,
                XmNmarginHeight,&margin_h,
		DtNuserFont,	&fontlist,
                NULL);
    else
        XtVaGetValues(text,
                XmNmarginWidth, &margin_w,
                XmNmarginHeight,&margin_h,
                XmNfontList,    &fontlist, 
		XmNlistSpacing, &text_spacing,
                NULL);

    parent = XtParent(text);

    if (XtIsSubclass(parent, xmScrolledWindowWidgetClass))
    {
	XtVaGetValues(parent,
		XmNhorizontalScrollBar,	&hsb,
		XmNverticalScrollBar,	&vsb,
		XmNspacing,		&spacing,
		NULL);
	if (hsb)
	    XtVaGetValues(hsb,
		XmNheight,		&hsb_height,
		NULL);
	if (vsb)
	    XtVaGetValues(vsb,
		XmNwidth,       	&vsb_width,
                NULL); 
    }
    else if (XtIsSubclass(parent, xmRowColumnWidgetClass))
	XtVaGetValues(parent,
		XmNmarginWidth, 	&p_margin_w,
		XmNmarginHeight,	&p_margin_h,
		NULL);

    font = objxm_fontlist_to_font(fontlist);

    if ((!XGetFontProperty(font, XA_QUAD_WIDTH, &charwidth)) || charwidth == 0) {
       if (font->per_char && font->min_char_or_byte2 <= '0' &&
                                 font->max_char_or_byte2 >= '0')
           charwidth = font->per_char['0' - font->min_char_or_byte2].width;
       else
           charwidth = font->max_bounds.width;
    }
    lineheight = font->max_bounds.ascent + font->max_bounds.descent +
			text_spacing;

    /* Calculate new pane size */
    pane_width  = width  - (vsb_width  + spacing) - (2*p_margin_w);
    pane_height = height - (hsb_height + spacing) - (2*p_margin_h);

    *row_ptr = (int)((pane_height - (2*margin_h))/lineheight);
    *col_ptr = (int)((pane_width  - (2*margin_w))/charwidth);

    /* For some reason, above calculations result in rows being 1 too
     * large for a scrolled list widget; put in workaround until
     * error in calculations is found...
     */
/*
 REMIND: versions of Motif beyond August 10 don't need this
    if (XtIsSubclass(text, xmListWidgetClass) && *row_ptr > 1)
	(*row_ptr)--;
*/

}
예제 #12
0
/*********************************************************************
 * Function: CreateDA
 *
 *    CreateDA creates a Text Graphic area with the appropriate scroll bars.
 *
 *********************************************************************/
static XtPointer
HelpCreateDA(
    Widget	 parent,
    char	*name,
    short	 vert_flag,
    short	 horz_flag,
    Boolean	 traversal_flag,
    _DtCvValue   honor_size,
    _DtCvRenderType render_type,
    int          rows,
    int          columns,
    unsigned short media_resolution,
    void	(*hyperTextCB)(),
    void	(*resizeCB)(),
    int		(*exec_ok_routine)(),
    XtPointer	 client_data,
    XmFontList	 default_list )
{
    DtHelpDispAreaStruct *pDAS;
    DAArgs DA_args;
    Arg args[20];
    int n;
    int maxFontAscent;
    int maxFontDescent;
    int maxFontCharWidth;
  
    short margin_width;
    short margin_height;
    short shadowThick, highThick;
    Dimension hBarHeight = 0;
    Dimension vBarWidth  = 0;
    Dimension width;
    Boolean   value;

    Widget form;
    Display *dpy = XtDisplay(parent);
    Screen      *retScr = XtScreen(parent);
    int          screen = XScreenNumberOfScreen(retScr);

    Colormap colormap;

    Pixmap		 tile;
    XGCValues		 gcValues;
    unsigned long	 gcMask;

    unsigned long char_width;

    Atom xa_ave_width;

    XFontStruct *tmpFont = NULL;
    XtPointer	 default_font = NULL;
    XRectangle   rectangle[1];

    XmFontContext	fontContext;
    XmFontListEntry	fontEntry;
    XmFontType		fontType;

    /* Allocate the Display Area. */
    pDAS = (DtHelpDispAreaStruct *) XtMalloc(sizeof(DtHelpDispAreaStruct));

   /*
     * get the resources
     */
    XtGetSubresources(parent, &DA_args, name, "XmDrawnButton",
		    Resources, XtNumber(Resources), NULL, 0);

    if (rows <= 0)
	rows = 1;
    if (columns <= 0)
	columns = 1;

    /*
     * initialize the structure variables.
     */
    pDAS->text_selected = False;
    pDAS->primary       = False;
    pDAS->select_state  = _DtHelpNothingDoing;
    pDAS->toc_y         = 0;
    pDAS->toc_base      = 0;
    pDAS->toc_flag      = 0;
    if (traversal_flag)
        pDAS->toc_flag  = _DT_HELP_SHADOW_TRAVERSAL | _DT_HELP_NOT_INITIALIZED;

    pDAS->max_spc       = 0;
    pDAS->cur_spc       = 0;
    pDAS->maxX          = 0;
    pDAS->virtualX      = 0;
    pDAS->firstVisible  = 0;
    pDAS->visibleCount  = rows;
    pDAS->maxYpos       = 0;
    pDAS->neededFlags   = 0;
    pDAS->vert_init_scr = DA_args.initialDelay;
    pDAS->vert_rep_scr  = DA_args.repeatDelay;
    pDAS->horz_init_scr = DA_args.initialDelay;
    pDAS->horz_rep_scr  = DA_args.repeatDelay;
    pDAS->moveThreshold = DA_args.moveThreshold;
    pDAS->marginWidth   = DA_args.marginWidth;
    pDAS->marginHeight  = DA_args.marginHeight;
    pDAS->searchColor   = DA_args.search_color;
    pDAS->depth		= 0;
    pDAS->spc_chars     = NULL;
    pDAS->scr_timer_id  = 0;
    pDAS->def_pix       = 0;
    pDAS->context       = NULL;
    pDAS->vertIsMapped  = False;
    pDAS->horzIsMapped  = False;
    pDAS->lst_topic     = NULL;
    pDAS->nextNonVisible = 0;
    pDAS->media_resolution = media_resolution;
    pDAS->honor_size = honor_size;
    pDAS->render_type = render_type;
    pDAS->dtinfo = 0;
    pDAS->stipple = None;

    /*
     * locale dependant information
     */
    pDAS->nl_to_space      = 1;
    pDAS->cant_begin_chars = NULL;
    pDAS->cant_end_chars   = NULL;
    if (1 < MB_CUR_MAX)
	_DtHelpLoadMultiInfo (&(pDAS->cant_begin_chars),
				&(pDAS->cant_end_chars), &(pDAS->nl_to_space));

    /*
     * initialize the hypertext callback pointer
     */
    pDAS->exec_filter = exec_ok_routine;
    pDAS->hyperCall   = hyperTextCB;
    pDAS->resizeCall  = resizeCB;
    pDAS->clientData  = client_data;

    /*
     * zero out other callback fields
     */
    pDAS->vScrollNotify = NULL ;
    pDAS->armCallback = NULL ;

    /*
     * create the atoms needed
     */
    xa_ave_width = XmInternAtom(dpy, "AVERAGE_WIDTH"     , False);

    /*
     * Malloc for the default font.
     */
    (void) XmeRenderTableGetDefaultFont(DA_args.userFont, &tmpFont);
    if (default_list != NULL &&
		XmFontListInitFontContext (&fontContext, default_list))
      {
	fontEntry = XmFontListNextEntry (fontContext);
	if (fontEntry != NULL)
	    default_font = XmFontListEntryGetFont (fontEntry, &fontType);

	XmFontListFreeFontContext (fontContext);
      }

    /*
     * fake out the next call by using the parent as the display widget
     */
    pDAS->dispWid = parent;
    __DtHelpFontDatabaseInit (pDAS, default_font, fontType, tmpFont);

    /*
     * Get the base font meterics.
     */
    __DtHelpFontMetrics (pDAS->font_info, __DtHelpDefaultFontIndexGet(pDAS),
			&maxFontAscent, &maxFontDescent, &maxFontCharWidth,
			NULL, NULL);

    pDAS->leading    = DA_args.leading;
    pDAS->fontAscent = maxFontAscent;
    pDAS->lineHeight = maxFontAscent + maxFontDescent + pDAS->leading + 1;

    n = __DtHelpDefaultFontIndexGet(pDAS);
    if (n < 0)
        value = get_fontsetproperty(__DtHelpFontSetGet(pDAS->font_info, n),
			xa_ave_width, ((unsigned long *) &(pDAS->charWidth)));
    else
	value = XGetFontProperty(__DtHelpFontStructGet(pDAS->font_info, n),
			xa_ave_width, ((unsigned long *) &(pDAS->charWidth)));

    if (False == value || 0 == pDAS->charWidth)
      {
	int len = maxFontCharWidth;

	if (n < 0)
	    len += XmbTextEscapement(
				__DtHelpFontSetGet(pDAS->font_info,n),"1",1);
	else
	    len += XTextWidth(__DtHelpFontStructGet(pDAS->font_info, n),"1",1);

        pDAS->charWidth = 10 * len / 2;
      }

    /*
     * Create the form to manage the window and scroll bars.
     */
    n = 0;
    XtSetArg(args[n], XmNresizePolicy      , XmRESIZE_ANY);		++n;
    XtSetArg(args[n], XmNshadowType	, XmSHADOW_OUT);		++n;
    form = XmCreateForm(parent, "DisplayAreaForm", args, n);
    XtManageChild(form);

    /*
     * force the shadowThickness to zero. The XmManager will try to set
     * this to one.
     */
    n = 0;
    XtSetArg(args[n], XmNshadowThickness   , 0);			++n;
    XtSetArg(args[n], XmNhighlightThickness, 0);			++n;
    XtSetValues (form, args, n);

    /*
     * get the colors and margin widths and heights
     */
    n = 0;
    XtSetArg (args[n], XmNmarginWidth , &margin_width);		++n;
    XtSetArg (args[n], XmNmarginHeight, &margin_height);	++n;
    XtSetArg (args[n], XmNcolormap    , &colormap);		++n;
    XtGetValues(form, args, n);

    /* Create the vertical scrollbar. */
    pDAS->vertScrollWid = NULL;
    if (vert_flag != _DtHelpNONE)
      {
	if (vert_flag == _DtHelpSTATIC)
	    pDAS->vertIsMapped = True;

	n = 0;
	XtSetArg(args[n], XmNtopAttachment     , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNtopOffset         , 0);			++n;
	XtSetArg(args[n], XmNbottomAttachment  , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNbottomOffset      , margin_height);	++n;
	XtSetArg(args[n], XmNrightAttachment   , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNrightOffset       , 0);			++n;
	XtSetArg(args[n], XmNorientation       , XmVERTICAL);		++n;
	XtSetArg(args[n], XmNtraversalOn       , True);			++n;
	XtSetArg(args[n], XmNhighlightThickness, 1);			++n;
	XtSetArg(args[n], XmNshadowType        , XmSHADOW_IN);		++n;
	XtSetArg(args[n], XmNvalue             , 0);			++n;
	XtSetArg(args[n], XmNminimum           , 0);			++n;
	/* fake out the scrollbar manager, who will init dims to 100 */
	XtSetArg(args[n], XmNheight            , 1);			++n;
	XtSetArg(args[n], XmNmaximum           , 1);			++n;
	XtSetArg(args[n], XmNincrement         , 1);			++n;
	XtSetArg(args[n], XmNpageIncrement     , 1);			++n;
	XtSetArg(args[n], XmNsliderSize        , 1);			++n;
	XtSetArg(args[n], XtNmappedWhenManaged , pDAS->vertIsMapped);	++n;
	pDAS->vertScrollWid = XmCreateScrollBar(form,
					"DisplayDtHelpVertScrollBar", args, n);

	XtManageChild(pDAS->vertScrollWid);
	if (vert_flag != _DtHelpSTATIC)
	    pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags,
						_DtHelpVERTICAL_SCROLLBAR);
  
	XtAddCallback(pDAS->vertScrollWid, XmNdragCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNincrementCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNdecrementCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNpageIncrementCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNpageDecrementCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNtoBottomCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNtoTopCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->vertScrollWid, XmNvalueChangedCallback,
					_DtHelpVertScrollCB, (XtPointer) pDAS);

	XtAddEventHandler (pDAS->vertScrollWid, ButtonPressMask, True,
			(XtEventHandler)_DtHelpMoveBtnFocusCB,(XtPointer) pDAS);

      }

    /* Create the horizontal scrollbar. */
    pDAS->horzScrollWid = NULL;
    if (horz_flag != _DtHelpNONE)
      {
	if (horz_flag == _DtHelpSTATIC)
	    pDAS->horzIsMapped = True;

	n = 0;
	XtSetArg(args[n], XmNbottomAttachment  , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNbottomOffset      , 0);			++n;
	XtSetArg(args[n], XmNrightAttachment   , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNrightOffset       , margin_width);		++n;
	XtSetArg(args[n], XmNleftAttachment    , XmATTACH_FORM);	++n;
	XtSetArg(args[n], XmNleftOffset        , 0);			++n;
	XtSetArg(args[n], XmNorientation       , XmHORIZONTAL);		++n;
	XtSetArg(args[n], XmNtraversalOn       , True);			++n;
	XtSetArg(args[n], XmNhighlightThickness, 1);			++n;
	XtSetArg(args[n], XmNshadowType        , XmSHADOW_IN);		++n;
	XtSetArg(args[n], XmNvalue             , 0);			++n;
	XtSetArg(args[n], XmNminimum           , 0);			++n;
	XtSetArg(args[n], XmNmaximum           , (pDAS->charWidth/10));	++n;
	/* fake out the scrollbar manager, who will init dims to 100 */
	XtSetArg(args[n], XmNwidth             , 1);			++n;
	XtSetArg(args[n], XmNincrement         , (pDAS->charWidth/10));	++n;
	XtSetArg(args[n], XmNpageIncrement     , (pDAS->charWidth/10));	++n;
	XtSetArg(args[n], XmNsliderSize        , (pDAS->charWidth/10));	++n;
	XtSetArg(args[n], XtNmappedWhenManaged , pDAS->horzIsMapped);	++n;
	pDAS->horzScrollWid = XmCreateScrollBar(form,
					"DisplayHorzScrollBar", args, n);
	XtManageChild(pDAS->horzScrollWid);
	if (horz_flag != _DtHelpSTATIC)
	    pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags,
						_DtHelpHORIZONTAL_SCROLLBAR);
  
	XtAddCallback(pDAS->horzScrollWid, XmNdragCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNincrementCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNdecrementCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNpageIncrementCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNpageDecrementCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNtoBottomCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNtoTopCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
	XtAddCallback(pDAS->horzScrollWid, XmNvalueChangedCallback,
					_DtHelpHorzScrollCB, (XtPointer) pDAS);
      }

    /*
     * check for the horizontal attachments
     */
    n = 0;
    if (horz_flag == _DtHelpSTATIC)
      {
	XtSetArg(args[n], XmNbottomAttachment  , XmATTACH_WIDGET);	++n;
	XtSetArg(args[n], XmNbottomWidget      , pDAS->horzScrollWid);	++n;
      }
    else
      {
	XtSetArg(args[n], XmNbottomAttachment  , XmATTACH_FORM);	++n;
      }

    /*
     * check for the vertical attachments
     */
    if (vert_flag == _DtHelpSTATIC)
      {
	XtSetArg(args[n], XmNrightAttachment   , XmATTACH_WIDGET);	++n;
	XtSetArg(args[n], XmNrightWidget       , pDAS->vertScrollWid);	++n;
      }
    else
      {
	XtSetArg(args[n], XmNrightAttachment  , XmATTACH_FORM);		++n;
      }

    /*
     * do the rest of the arguments
     */
    XtSetArg(args[n], XmNbottomOffset      , margin_height);		++n;
    XtSetArg(args[n], XmNrightOffset       , margin_width);		++n;
    XtSetArg(args[n], XmNtopAttachment     , XmATTACH_FORM);		++n;
    XtSetArg(args[n], XmNtopOffset	   , 0);			++n;
    XtSetArg(args[n], XmNleftAttachment    , XmATTACH_FORM);		++n;
    XtSetArg(args[n], XmNleftOffset	   , 0);			++n;
    XtSetArg(args[n], XmNrecomputeSize     , False);			++n;
    XtSetArg(args[n], XmNpushButtonEnabled , False);			++n;
    XtSetArg(args[n], XmNtraversalOn       , True);			++n;
    XtSetArg(args[n], XmNhighlightThickness, 1);			++n;
    XtSetArg(args[n], XmNshadowType        , XmSHADOW_IN);		++n;
    XtSetArg(args[n], XmNmultiClick	   , XmMULTICLICK_DISCARD);	++n;
    XtSetArg(args[n], XmNuserData  	   , pDAS);			++n;
    pDAS->dispWid = XmCreateDrawnButton(form, name, args, n);
    XtManageChild(pDAS->dispWid);
  
    XtAddCallback(pDAS->dispWid, XmNexposeCallback, _DtHelpExposeCB,
						(XtPointer) pDAS);
    XtAddCallback(pDAS->dispWid, XmNresizeCallback, _DtHelpResizeCB,
						(XtPointer) pDAS);
    XtAddCallback(pDAS->dispWid, XmNarmCallback, _DtHelpClickOrSelectCB,
						(XtPointer) pDAS);
    XtAddCallback(pDAS->dispWid, XmNdisarmCallback, _DtHelpEndSelectionCB,
						(XtPointer) pDAS);

    XtAddEventHandler (pDAS->dispWid, Button1MotionMask, True,
			(XtEventHandler)_DtHelpMouseMoveCB, (XtPointer) pDAS);

    /*
     * add my actions
     * parse the translations.
     */
    _DtHelpProcessLock();
    if (DrawnBTrans == NULL)
        DrawnBTrans = XtParseTranslationTable(DrawnBTransTable);

     /*
     * override the translations
    XtSetArg(args[n], XmNtranslations	   , DrawnBTrans);		++n;
     */
    if (DrawnBTrans != NULL)
	XtOverrideTranslations(pDAS->dispWid, DrawnBTrans);
    _DtHelpProcessUnlock();
  
    if (_XmGetFocusPolicy(parent) == XmPOINTER)
      {
	XtAddEventHandler (pDAS->dispWid, EnterWindowMask, True,
			(XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS);
	XtAddEventHandler (pDAS->dispWid, LeaveWindowMask, True,
			(XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS);
      }
    else
	XtAddEventHandler (pDAS->dispWid, FocusChangeMask, True,
			(XtEventHandler)_DtHelpFocusCB, (XtPointer) pDAS);

    XtAddEventHandler (pDAS->dispWid, VisibilityChangeMask, True,
			(XtEventHandler)_DtHelpVisibilityCB, (XtPointer) pDAS);
  

    /* Add a destroy callback so that the display area can clean up prior to
     * the help widget getting destroyed (e.g. display area's parent) 
     */
    XtAddCallback(pDAS->dispWid, XmNdestroyCallback,
				_DtHelpDisplayAreaDestroyCB, (XtPointer) pDAS);
  
    n = 0;
    XtSetArg(args[n], XmNshadowThickness   , &shadowThick);	++n;
    XtSetArg(args[n], XmNhighlightThickness, &highThick);	++n;
    XtSetArg(args[n], XmNforeground    , &(pDAS->foregroundColor)); ++n;
    XtSetArg(args[n], XmNbackground    , &(pDAS->backgroundColor)); ++n;
    XtSetArg(args[n], XmNhighlightColor, &(pDAS->traversalColor) ); ++n;
    XtSetArg(args[n], XmNdepth         , &(pDAS->depth)          ); ++n;
    XtGetValues(pDAS->dispWid, args, n);
    pDAS->decorThickness = shadowThick + highThick;

    /*
     * Get the underline information
     */
    GetUnderLineInfo (dpy, pDAS, &(pDAS->lineThickness));

    /*
     * get the tiling pattern.
     */
    tile = XmGetPixmap (XtScreen(pDAS->dispWid), "50_foreground",
				pDAS->foregroundColor, pDAS->backgroundColor);

    /*
     * Get the data for the graphics contexts and create the GC's.
     */
    gcMask = (GCFunction   | GCPlaneMask   | GCForeground  |
		GCBackground  | GCLineWidth   | GCLineStyle   |
		GCClipXOrigin | GCClipYOrigin | GCClipMask);

    gcValues.function      = GXcopy;
    gcValues.plane_mask    = AllPlanes;
    gcValues.foreground    = pDAS->foregroundColor;
    gcValues.background    = pDAS->backgroundColor;
    gcValues.line_style    = LineSolid;
    gcValues.line_width    = pDAS->lineThickness;
    gcValues.clip_x_origin = 0;
    gcValues.clip_y_origin = 0;
    gcValues.clip_mask     = None;
    if (tile)
      {
	gcMask |= GCTile;
	gcValues.tile = tile;
      }
 
    pDAS->normalGC = XCreateGC(dpy,
		RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);

    gcMask &= (~GCTile);
    pDAS->pixmapGC = XCreateGC(dpy,
		RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);
  
    gcValues.foreground = pDAS->backgroundColor;
    gcValues.background = pDAS->foregroundColor;
    pDAS->invertGC = XCreateGC(dpy,
		RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);
  
    /*
     * Set the size of the text view area to the requested
     * number of columns and lines.
     */
    char_width          = pDAS->charWidth * columns;

    /*
     * Make sure the margins include enough room for a traversal line
     */
    if (((int) pDAS->marginWidth) < pDAS->lineThickness)
	pDAS->marginWidth = pDAS->lineThickness;
    if (((int) pDAS->marginHeight) < pDAS->lineThickness)
	pDAS->marginHeight = pDAS->lineThickness;
    if (pDAS->leading < pDAS->lineThickness)
	pDAS->leading = pDAS->lineThickness;

    /*
     * get the scrollbar widths.
     */
    if (NULL != pDAS->horzScrollWid)
      {
	n = 0;
	XtSetArg(args[n], XmNheight      , &hBarHeight); n++;
	XtSetArg(args[n], XmNinitialDelay, &(pDAS->horz_init_scr)); n++;
	XtSetArg(args[n], XmNrepeatDelay , &(pDAS->horz_rep_scr));  n++;
	XtGetValues(pDAS->horzScrollWid, args, n);
      }

    if (NULL != pDAS->vertScrollWid)
      {
	n = 0;
	XtSetArg(args[n], XmNwidth       , &vBarWidth);             n++;
	XtSetArg(args[n], XmNinitialDelay, &(pDAS->vert_init_scr)); n++;
	XtSetArg(args[n], XmNrepeatDelay , &(pDAS->vert_rep_scr));  n++;
	XtGetValues(pDAS->vertScrollWid, args, n);
      }

    /*
     * calculate the display area height/width
     */
    pDAS->dispUseWidth  = ((int) (char_width / 10 + (char_width % 10 ? 1 : 0)))
					      + 2 * pDAS->marginWidth;
    if (vert_flag != _DtHelpSTATIC && pDAS->dispUseWidth < vBarWidth)
	pDAS->dispUseWidth = vBarWidth;
    pDAS->dispWidth     = pDAS->dispUseWidth  + 2 * pDAS->decorThickness;

    pDAS->dispUseHeight = pDAS->lineHeight * rows;
    if (horz_flag != _DtHelpSTATIC && pDAS->dispUseHeight < hBarHeight)
	pDAS->dispUseHeight = hBarHeight;
    pDAS->dispHeight    = pDAS->dispUseHeight + 2 * pDAS->decorThickness;

    /*
     * Truncate the width and height to the size of the display.
     * This will prevent an X protocal error when it is asked for
     * a too large size. Besides, any decent window manager will
     * force the overall size to the height and width of the display.
     * This simply refines the size down to a closer (but not perfect)
     * fit.
     */
    if (((int) pDAS->dispWidth) > XDisplayWidth (dpy, screen)) {
	pDAS->dispWidth = XDisplayWidth (dpy, screen);
    }
    if (((int) pDAS->dispHeight) > XDisplayHeight (dpy, screen)) {
	pDAS->dispHeight = XDisplayHeight (dpy, screen);
    }

    n = 0;
    pDAS->formWidth  = 0;
    pDAS->formHeight = 0;
    XtSetArg(args[n], XmNwidth, pDAS->dispWidth);		++n;
    XtSetArg(args[n], XmNheight, pDAS->dispHeight);		++n;
    XtSetValues(pDAS->dispWid, args, n);

    /*
     * set the scroll bar values
     */
    if (pDAS->vertScrollWid != NULL)
      {
        n = 0;
        XtSetArg(args[n], XmNmaximum           , pDAS->dispUseHeight);	++n;
        XtSetArg(args[n], XmNincrement         , pDAS->lineHeight);	++n;
        XtSetArg(args[n], XmNpageIncrement     , pDAS->lineHeight);	++n;
        XtSetArg(args[n], XmNsliderSize        , pDAS->dispUseHeight);	++n;
        XtSetValues(pDAS->vertScrollWid, args, n);
      }
  
    if (pDAS->resizeCall)
	(*(pDAS->resizeCall)) (pDAS->clientData);

    /*
     * calculate the offset for the right edge of the
     * horizontal scrollbar.
     */
    if (vert_flag == _DtHelpSTATIC && pDAS->horzScrollWid)
      {
	width = vBarWidth + margin_width;

	XtSetArg(args[0], XmNrightOffset , width);
	XtSetValues(pDAS->horzScrollWid, args, 1);
      }

    /*
     * calculate the offset for the bottom end of the
     * vertical scrollbar.
     */
    if (horz_flag == _DtHelpSTATIC && pDAS->vertScrollWid)
      {
	width = hBarHeight + margin_height;

	XtSetArg(args[0], XmNbottomOffset , width);
	XtSetValues(pDAS->vertScrollWid, args, 1);
      }

    rectangle[0].x      = pDAS->decorThickness;
    rectangle[0].y      = pDAS->decorThickness;
    rectangle[0].width  = pDAS->dispUseWidth;
    rectangle[0].height = pDAS->dispUseHeight;
    XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->normalGC, 0, 0,
						rectangle, 1, Unsorted);
    XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->invertGC, 0, 0,
						rectangle, 1, Unsorted);

    /*
     * get the colormap and the visual
     */
    if (!XtIsShell(parent) && XtParent(parent) != NULL)
	parent = XtParent(parent);

    pDAS->visual = NULL;

    n = 0;
    XtSetArg (args[n], XmNcolormap, &(pDAS->colormap)); n++;
    XtSetArg (args[n], XmNvisual  , &(pDAS->visual  )); n++;
    XtGetValues (parent, args, n);

    if (pDAS->visual == NULL)
	pDAS->visual = XDefaultVisualOfScreen(XtScreen(pDAS->dispWid));

    /*
     * set up the canvas
     */
    _DtHelpProcessLock();
    DefVirtFunctions.exec_cmd_filter = exec_ok_routine;

    pDAS->canvas = _DtCanvasCreate (DefVirtFunctions, (_DtCvPointer) pDAS);
    _DtHelpProcessUnlock();

    return (XtPointer) pDAS;

}  /* End _DtHelpCreateDA */
예제 #13
0
/*
 * This function returns the underline distance and size for the base
 * font.
 */
static	void
GetUnderLineInfo (
	Display			*dpy,
	DtHelpDispAreaStruct	*pDAS,
	int			*ret_underThick )
{
    int   idx;
    XtPointer myFont;
    XFontSetExtents *extents;

    /*
     * cast the parameter as a pointer to a long though the value
     * returned is really a int.
     */
    idx = __DtHelpDefaultFontIndexGet(pDAS);
    if (idx < 0)
      {
        myFont = (XtPointer)__DtHelpFontSetGet(pDAS->font_info, idx);
        if (get_fontsetproperty((XFontSet)myFont, XA_UNDERLINE_POSITION,
                ((unsigned long *) &(pDAS->underLine))) == FALSE)
	  {
            extents = XExtentsOfFontSet((XFontSet)myFont);
            pDAS->underLine = ((int)(extents->max_ink_extent.height +
                               extents->max_ink_extent.y)) / 2;
          }
      }
    else
      {
        myFont = (XtPointer)__DtHelpFontStructGet(pDAS->font_info, idx);
        if (XGetFontProperty((XFontStruct *)myFont, XA_UNDERLINE_POSITION, 
			     ((unsigned long *) &(pDAS->underLine))) == FALSE)
            pDAS->underLine = ((XFontStruct *)myFont)->max_bounds.descent / 2;
      }

    /*
     * if we do not find an underline thickness for the font
     * use 15% of the font height.
     *
     * cast the parameter to a pointer to a long though the value
     * returned is really a unsigned int.
     */
    if (idx < 0)
      {
        if (get_fontsetproperty((XFontSet)myFont, XA_UNDERLINE_THICKNESS,
                ((unsigned long *) ret_underThick)) == FALSE)
            *ret_underThick = pDAS->lineHeight * 15 / 100;
      }
    else
      {
        if (XGetFontProperty((XFontStruct *)myFont, XA_UNDERLINE_THICKNESS, 
			     ((unsigned long *) ret_underThick)) == FALSE)
            *ret_underThick = pDAS->lineHeight * 15 / 100;
      }


    /*
     * now adjust the underline depth so that the when the underline is
     * drawn the top of the line is UNDERLINE_POSITION pixels below
     * the base line.
     */
/*
 * SYSTEM - ifdef this for other architectures.
 * an example of Hewlett-Packard's implementation is given for reference.
 */
		/* On Hewlett-Packard machines lines are */
		/* drawn like this:                      */
		/*					 */
		/*  line width 1:  y-> ****************  */
		/*					 */
		/*		       ****************  */
		/*  line width 2:  y-> ****************  */
		/*					 */
		/*		       ****************  */
		/*  line width 3:  y-> ****************  */
		/*		       ****************  */
		/*					 */
		/*		       ****************  */
		/*		       ****************  */
		/*  line width 4:  y-> ****************  */
		/*		       ****************  */
		/*					 */
		/*		       ****************  */
		/*		       ****************  */
		/*  line width 5:  y-> ****************  */
		/*		       ****************  */
		/*		       ****************  */
		/* etc......				 */
		/*					 */
    pDAS->underLine = pDAS->underLine + (*ret_underThick) / 2;

}
예제 #14
0
파일: font.c 프로젝트: juddy/edcde
extern void
load_app_font(
	Calendar	*cal, 
	Font_Weight	 weight,
	Cal_Font	*userfont,
	Cal_Font	*return_font)
{
	unsigned long	 pixel_size;
	Display		*dpy = XtDisplay(cal->frame);
	char		 font_name[128],
			*font_name_ptr = font_name,
		       **font_names;
	int		 nnames;
	XrmValue	 in_font;
	XrmValue	 out_fontlist;
	XmFontList	 font_list;
	Atom		 pixel_atom = XmInternAtom(dpy, "PIXEL_SIZE", FALSE);

	/* First get the pixel size from the User Font */
	if (userfont->cf_type == XmFONT_IS_FONT) {
		/* If we can't get the pixel size from the user font we
		 * defaults to a 12 pixel font.
		 */
		if (!XGetFontProperty(userfont->f.cf_font, pixel_atom, 
							&pixel_size))
			pixel_size = 12;
	} else {
		XFontStruct 	**font_struct_list;
		char		**font_name_list;
		int		  list_size;

		if (!(list_size = XFontsOfFontSet(userfont->f.cf_fontset,
					    &font_struct_list,
					    &font_name_list))) {
			pixel_size = 12;
		} else {
			int i;
			if (!XGetFontProperty(font_struct_list[0],
					      pixel_atom, 
					      &pixel_size))
				pixel_size = 12;
		}
	}

	/* If the font family is not ``application'' then it is probably
	 * multibyte so we can't assume there is an add-style or a proportional
	 * version available.
	 */
	if (!strcmp(cal->app_data->app_font_family, "application")) {
		sprintf (font_name, "-dt-%s-%s-r-normal-sans-%lu-*-*-*-p-*",
				cal->app_data->app_font_family,
				(weight == BOLD)?"bold":"medium",
				pixel_size);
	} else {
		sprintf (font_name, "-dt-%s-%s-r-normal--%lu-*-*-*-*-*",
				cal->app_data->app_font_family,
				(weight == BOLD)?"bold":"medium",
				pixel_size);
	}

	/* See if the font exists */
	font_names = XListFonts(dpy, font_name, 1, &nnames);
	if (!nnames) {
		if (!ProbeForFont(cal, weight, pixel_size, TRUE, 
							font_name_ptr)) {
			/* We didn't find anything */
			*return_font = *userfont;
			return;
		}
	} else
		XFreeFontNames(font_names);

	strcat(font_name, ":");
	in_font.size = strlen(font_name);
	in_font.addr = font_name;
	out_fontlist.size = sizeof(XmFontList);
	out_fontlist.addr = (XPointer)&font_list;

	/* Convert font string to a font list. */
	if (!XtConvertAndStore(cal->frame, XtRString, &in_font, XmRFontList,
				&out_fontlist)) {
		*return_font = *userfont;
	}

	if (!fontlist_to_font(font_list, return_font)) {
		*return_font = *userfont;
	}
}
예제 #15
0
파일: fonttest.c 프로젝트: jff/mathspad
int main(int argc, char **argv)
{
    Display *display;
    XFontStruct *fs;
    int i;
    unsigned long prop;

    if (!(display=XOpenDisplay(""))) {
	fprintf(stderr, "Unable to connect to server\n");
	exit(EXIT_FAILURE);
    }
    fs = XLoadQueryFont(display, argv[1]);
    if (!fs) {
	fprintf(stderr, "Unable to load font %s\n", argv[1]);
	exit(EXIT_FAILURE);
    }
    printf("FontID\t\t%lu\n"
	  "Direction\t%i\n"
	  "MinChar\t\t%i\n"
	  "MaxChar\t\t%i\n"
	  "MinByte\t\t%i\n"
	  "MaxByte\t\t%i\n"
	  "All Exist\t%s\n"
	  "Default Char\t%i\n"
	  "Ascent\t\t%i\n"
	  "Descent\t\t%i\n"
	  "Extra Data\t%s\n"
	  "Properties\t%i\n",
	  fs->fid, fs->direction, fs->min_char_or_byte2, fs->max_char_or_byte2,
	  fs->min_byte1, fs->max_byte1, (fs->all_chars_exist?"Yes":"No"),
	  fs->default_char, fs->ascent, fs->descent, (fs->ext_data?"Yes":"No"),
	  fs->n_properties);
    for (i=0; i<fs->n_properties; i++)
	print_property(display, fs->properties+i);
    if (XGetFontProperty(fs, XA_POINT_SIZE, &prop))
	printf("PointSize\t%li\n", prop);
    if (XGetFontProperty(fs, XA_COPYRIGHT, &prop))
	printf("Copyright\t%li\n", prop);
    printf("%8s%8s%8s%8s%8s%8s   %8s\n", "Pos","Left", "Right", "Width",
	   "Ascent", "Descent", "Attrib");
    print_charstruct(&fs->min_bounds, -1);
    print_charstruct(&fs->max_bounds, -2);
    if (!fs->per_char) printf("All glyphs have equal size\n");
    else {
	if (!fs->min_byte1 && !fs->max_byte1) {
	    /* single byte fonts */
	    int i,j,n;
	    j=fs->min_char_or_byte2;
	    n=fs->max_char_or_byte2-j+1;
	    for (i=0; i<n; i++)
		print_charstruct(fs->per_char+i, j+i);
	} else {
	    /* double byte fonts */
	    int i,j,n;
	    j=(fs->max_char_or_byte2-fs->min_char_or_byte2+1);
	    n=j*(fs->max_byte1-fs->min_byte1+1);
	    printf("Total %i, Row: %i\n", n,j);
	    for (i=0; i<n; i++) {
		print_charstruct(fs->per_char+i,
				 ((i/j+fs->min_byte1)<<8)+i%j+
				 fs->min_char_or_byte2);
	    }
	}
    }
    XCloseDisplay(display);
    return 0;
}
예제 #16
0
bool CGLTxtFontX11::Create()
{
	if( !m_poDisplay )
		return false;

	Destroy();

	//UpdatePixelExt();

	Font id;
	int first, last, firstbitmap, i;
	int firstrow, lastrow;
	int maxchars;


	m_poFont = XLoadQueryFont( m_poDisplay, m_pcFont );
	if( !m_poFont )
		return false;

	long unsigned int luiValue;
	//if( XGetFontProperty( m_poFont, XA_X_HEIGHT, &luiValue ) ) {
	//	m_uiSize = luiValue;
	//	GLTXT_LOG( "font size: %li\n", luiValue );
	//}

	if( XGetFontProperty( m_poFont, XA_FONT, &luiValue ) )
	{
		char *pcFontName = XGetAtomName( m_poDisplay, (Atom)luiValue );
		GLTXT_LOG( "font name: %s\n", pcFontName );

		const char *pcStartSize = 0;
		unsigned int c = 0;
		while( *pcFontName )
		{
			if( *pcFontName == '-' )
			{
				++c;
				if( c == 7 )
				{
					pcStartSize = pcFontName + 1;
				}
				else if( c == 8 )
				{
					*pcFontName = '\0';
					m_uiSize = atoi( pcStartSize );
					GLTXT_LOG( "font pixel size: %d\n", m_uiSize );
					break;
				}
			}
			pcFontName++;
		}
	}
	id = m_poFont->fid;

	// First and Last char in a row of chars.
	first = (int)m_poFont->min_char_or_byte2;
	last = (int)m_poFont->max_char_or_byte2;

	// First and Last row of chars, important for multibyte charset's.
	firstrow = (int)m_poFont->min_byte1;
	lastrow = (int)m_poFont->max_byte1;

	// How many chars in the charset.
	maxchars = 256 * lastrow + last;
	InitDisplayLists( glGenLists(maxchars+1) );

	// Get offset to first char in the charset.
	firstbitmap = 256 * firstrow + first;

	// for each row of chars, call glXUseXFont to build the bitmaps.
	for( i=firstrow; i<=lastrow; i++ )
	{
		glXUseXFont( id, firstbitmap, last-first+1, m_uiLstBase+firstbitmap );
		firstbitmap += 256;
	}

	return true;
}