Beispiel #1
0
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
{
#if 0
	uiDrawTextFontDescriptor desc;
	uiDrawTextFont *font;
	char *s;
	char *family;		// make compiler happy
	uiDrawTextLayout *layout;
	uiDrawTextFontMetrics metrics;
	double ypos;
	double width;
	double height;

	memset(&desc, 0, sizeof (uiDrawTextFontDescriptor));
	family = uiEntryText(textFont);
	desc.Family = family;
	desc.Size = entryDouble(textSize);
	desc.Weight = uiComboboxSelected(textWeight);
	desc.Italic = uiComboboxSelected(textItalic);
	desc.SmallCaps = uiCheckboxChecked(textSmallCaps);
	desc.Stretch = uiComboboxSelected(textStretch);
	desc.Gravity = uiComboboxSelected(textGravity);
	font = uiDrawLoadClosestFont(&desc);
	uiFreeText(family);
	uiDrawTextFontGetMetrics(font, &metrics);

	width = entryDouble(textWidth);

	drawGuides(dp->Context, &metrics);

	s = uiEntryText(textString);
	layout = uiDrawNewTextLayout(s, font, width);
	uiFreeText(s);
	ypos = 10;
	uiDrawText(dp->Context, 10, ypos, layout);
	// TODO make these optional?
	uiDrawTextLayoutExtents(layout, &width, &height);
	uiDrawFreeTextLayout(layout);

	layout = uiDrawNewTextLayout("This is a second line", font, -1);
	if (/*TODO reuse width*/entryDouble(textWidth) < 0) {
		double ad;

		ad = metrics.Ascent + metrics.Descent;
		printf("ad:%g extent:%g\n", ad, height);
	}
	ypos += height;
	if (uiCheckboxChecked(addLeading))
		ypos += metrics.Leading;
	uiDrawText(dp->Context, 10, ypos, layout);
	uiDrawFreeTextLayout(layout);

	uiDrawFreeTextFont(font);
#endif
}
Beispiel #2
0
static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *dp)
{
	uiDrawTextFont *font;
	uiDrawTextLayout *layout;
	double r, g, b, al;
	char surrogates[1 + 4 + 1 + 1];
	char composed[2 + 2 + 2 + 3 + 2 + 1];
	double width, height;

	font = uiFontButtonFont(textFontButton);

	layout = uiDrawNewTextLayout("One two three four", font, -1);
	uiDrawTextLayoutSetColor(layout,
		4, 7,
		1, 0, 0, 1);
	uiDrawTextLayoutSetColor(layout,
		8, 14,
		1, 0, 0.5, 0.5);
	uiColorButtonColor(textColorButton, &r, &g, &b, &al);
	uiDrawTextLayoutSetColor(layout,
		14, 18,
		r, g, b, al);
	uiDrawText(dp->Context, 10, 10, layout);
	uiDrawTextLayoutExtents(layout, &width, &height);
	uiDrawFreeTextLayout(layout);

	surrogates[0] = 'x';
	surrogates[1] = 0xF0;		// surrogates D800 DF08
	surrogates[2] = 0x90;
	surrogates[3] = 0x8C;
	surrogates[4] = 0x88;
	surrogates[5] = 'y';
	surrogates[6] = '\0';

	layout = uiDrawNewTextLayout(surrogates, font, -1);
	uiDrawTextLayoutSetColor(layout,
		1, 2,
		1, 0, 0.5, 0.5);
	uiDrawText(dp->Context, 10, 10 + height, layout);
	uiDrawFreeTextLayout(layout);

	composed[0] = 'z';
	composed[1] = 'z';
	composed[2] = 0xC3;		// 2
	composed[3] = 0xA9;
	composed[4] = 'z';
	composed[5] = 'z';
	composed[6] = 0x65;		// 5
	composed[7] = 0xCC;
	composed[8] = 0x81;
	composed[9] = 'z';
	composed[10] = 'z';
	composed[11] = '\0';

	layout = uiDrawNewTextLayout(composed, font, -1);
	uiDrawTextLayoutSetColor(layout,
		2, 3,
		1, 0, 0.5, 0.5);
	uiDrawTextLayoutSetColor(layout,
		5, 6,
		1, 0, 0.5, 0.5);
	if (!uiCheckboxChecked(noZ))
		uiDrawTextLayoutSetColor(layout,
			6, 7,
			0.5, 0, 1, 0.5);
	uiDrawText(dp->Context, 10, 10 + height + height, layout);
	uiDrawFreeTextLayout(layout);

	uiDrawFreeTextFont(font);
}