Пример #1
0
Файл: List.c Проект: aosm/X11
static void
PaintItemName(Widget w, int item)
{
    char *str;
    GC gc;
    int x, y, str_y;
    ListWidget lw = (ListWidget)w;
    XFontSetExtents *ext  = XExtentsOfFontSet(lw->list.fontset);

    if (!XtIsRealized(w) || item > lw->list.nitems)
      return;

    if (lw->list.vertical_cols) {
	x = lw->list.col_width * (item / lw->list.nrows)
	  + lw->list.internal_width;
	y = lw->list.row_height * (item % lw->list.nrows)
	  + lw->list.internal_height;
    }
    else {
	x = lw->list.col_width * (item % lw->list.ncols)
	  + lw->list.internal_width;
	y = lw->list.row_height * (item / lw->list.ncols)
	  + lw->list.internal_height;
    }

    if ( lw->simple.international == True )
	str_y = y + XawAbs(ext->max_ink_extent.y);
    else
	str_y = y + lw->list.font->max_bounds.ascent;

    if (item == lw->list.is_highlighted) {
	if (item == lw->list.highlight) {
	    gc = lw->list.revgc;
	    HighlightBackground(w, x, y, lw->list.normgc);
	}
	else {
	    if (XtIsSensitive(w)) 
		gc = lw->list.normgc;
	    else
		gc = lw->list.graygc;
	    HighlightBackground(w, x, y, lw->list.revgc);
	    lw->list.is_highlighted = NO_HIGHLIGHT;
	}
    }
    else {
	if (item == lw->list.highlight) {
	    gc = lw->list.revgc;
	    HighlightBackground(w, x, y, lw->list.normgc);
	    lw->list.is_highlighted = item;
	}
	else {
	    if (XtIsSensitive(w)) 
		gc = lw->list.normgc;
	    else
		gc = lw->list.graygc;
	}
    }

    /* List's overall width contains the same number of inter-column
       column_space's as columns.  There should thus be a half
       column_width margin on each side of each column.
       The row case is symmetric */

    x += lw->list.column_space >> 1;
    str_y += lw->list.row_space >> 1;

    str =  lw->list.list[item];	/* draw it */

    ClipToShadowInteriorAndLongest(lw, &gc, x);

    if (lw->simple.international == True)
	XmbDrawString(XtDisplay(w), XtWindow(w), lw->list.fontset,
		      gc, x, str_y, str, strlen(str));
    else
	XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, strlen(str));

    XSetClipMask(XtDisplay(w), gc, None);
}
Пример #2
0
/* ARGSUSED */
static void
XawSmeBSBRedisplay(Widget w, XEvent *event, Region region)
{
    GC gc;
    SmeBSBObject entry = (SmeBSBObject)w;
    int	font_ascent, font_descent, y_loc;
    int	fontset_ascent, fontset_descent;
    XFontSetExtents *ext = XExtentsOfFontSet(entry->sme_bsb.fontset);

    font_ascent = font_descent = fontset_ascent = fontset_descent = 0;
    entry->sme_bsb.set_values_area_cleared = False;

    if (entry->sme.international == True) {
	fontset_ascent = XawAbs(ext->max_ink_extent.y);
	fontset_descent = ext->max_ink_extent.height - fontset_ascent;
    }
    else {
	font_ascent = entry->sme_bsb.font->max_bounds.ascent;
	font_descent = entry->sme_bsb.font->max_bounds.descent;
    }
    y_loc = XtY(entry);

    if (XtIsSensitive(w) && XtIsSensitive(XtParent(w))) {
	if (w == XawSimpleMenuGetActiveEntry(XtParent(w))) {
	    XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), 
			   entry->sme_bsb.norm_gc, XtX(w), y_loc,
			   XtWidth(entry), XtHeight(entry));
	    gc = entry->sme_bsb.rev_gc;
	}
	else
	    gc = entry->sme_bsb.norm_gc;
    }
    else
	gc = entry->sme_bsb.norm_gray_gc;
    
    if (entry->sme_bsb.label != NULL) {
	int x_loc = entry->sme_bsb.left_margin;
	int len = strlen(entry->sme_bsb.label);
	char *label = entry->sme_bsb.label;
	 int width, t_width;

	switch(entry->sme_bsb.justify) {
	    case XtJustifyCenter:
		if (entry->sme.international == True) {
		    t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
						len);
		    width = XtWidth(entry) - (entry->sme_bsb.left_margin +
					      entry->sme_bsb.right_margin);
		}
		else {
		    t_width = XTextWidth(entry->sme_bsb.font, label, len);
		    width = XtWidth(entry) - (entry->sme_bsb.left_margin +
					      entry->sme_bsb.right_margin);
		}
		x_loc += (width - t_width) >> 1;
		break;
	    case XtJustifyRight:
		if (entry->sme.international == True) {
		    t_width = XmbTextEscapement(entry->sme_bsb.fontset,label,
						len);
		    x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
					      t_width);
		}
		else {
		    t_width = XTextWidth(entry->sme_bsb.font, label, len);
		    x_loc = XtWidth(entry) - (entry->sme_bsb.right_margin +
					      t_width);
		}
		break;
	    case XtJustifyLeft:
		/*FALLTHROUGH*/
	    default:
		break;
	}

	/* this will center the text in the gadget top-to-bottom */
	if (entry->sme.international == True) {
	    y_loc += ((XtHeight(entry) -
		      (fontset_ascent + fontset_descent)) >> 1) +
		       fontset_ascent;

	    XmbDrawString(XtDisplayOfObject(w), XtWindowOfObject(w),
		          entry->sme_bsb.fontset, gc,
			  XtX(w) + x_loc, y_loc, label, len);
	}
Пример #3
0
/*ARGSUSED*/
static void
XawLabelRedisplay(Widget gw, XEvent *event, Region region)
{
    LabelWidget w = (LabelWidget)gw;
    GC gc;

    if (*Superclass->core_class.expose != NULL)
	(*Superclass->core_class.expose)(gw, event, region);

    gc = XtIsSensitive(gw) ? w->label.normal_GC : w->label.gray_GC;
#ifdef notdef
    if (region != NULL)
	XSetRegion(XtDisplay(gw), gc, region);
#endif /*notdef*/

    if (w->label.pixmap == None) {
	int len = w->label.label_len;
	char *label = w->label.label;
	Position y = w->label.label_y + w->label.font->max_bounds.ascent;
	Position ksy = w->label.label_y;

	/* display left bitmap */
	if (w->label.left_bitmap && w->label.lbm_width != 0)
	    XCopyPlane (XtDisplay(gw), w->label.left_bitmap, XtWindow(gw), gc,
			0, 0, w->label.lbm_width, w->label.lbm_height,
			w->label.internal_width,
			w->label.internal_height + w->label.lbm_y, 1L);

	if (w->simple.international == True) {
	    XFontSetExtents *ext = XExtentsOfFontSet(w->label.fontset);

	    ksy += XawAbs(ext->max_ink_extent.y);

	    if (len == MULTI_LINE_LABEL) {
		char *nl;

		while ((nl = index(label, '\n')) != NULL) {
		    XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset,
				  gc, w->label.label_x, ksy, label,
				  (int)(nl - label));
		    ksy += ext->max_ink_extent.height;
		    label = nl + 1;
		}
		len = strlen(label);
	    }
	    if (len)
		XmbDrawString(XtDisplay(w), XtWindow(w), w->label.fontset, gc,
			      w->label.label_x, ksy, label, len);
	}
	else {
	    if (len == MULTI_LINE_LABEL) {
		char *nl;

		while ((nl = index(label, '\n')) != NULL) {
		    if (w->label.encoding)
			XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
				      w->label.label_x, y,
				      (XChar2b *)label, (int)(nl - label) / 2);
		    else
			XDrawString(XtDisplay(gw), XtWindow(gw), gc,
				    w->label.label_x, y, label, (int)(nl - label));
		    y += w->label.font->max_bounds.ascent +
			 w->label.font->max_bounds.descent;
		    label = nl + 1;
		}
		len = strlen(label);
	    }
	    if (len) {
		if (w->label.encoding)
		    XDrawString16(XtDisplay(gw), XtWindow(gw), gc,
				  w->label.label_x, y, (XChar2b *)label, len / 2);
		else
		    XDrawString(XtDisplay(gw), XtWindow(gw), gc,
				w->label.label_x, y, label, len);
	    }
	}
    }
    else if (w->label.label_len == 1)
	XCopyPlane(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
		   0, 0, w->label.label_width, w->label.label_height,
		   w->label.label_x, w->label.label_y, 1L);
    else
	XCopyArea(XtDisplay(gw), w->label.pixmap, XtWindow(gw), gc,
		  0, 0, w->label.label_width, w->label.label_height,
		  w->label.label_x, w->label.label_y);

#ifdef notdef
    if (region != NULL)
	XSetClipMask(XtDisplay(gw), gc, (Pixmap)None);
#endif /* notdef */
}