Exemplo n.º 1
0
void KprLabelGetSelectionBounds(KprLabel self, FskRectangle bounds)
{
	KprStyle style = self->style;
	FskRectangleSet(bounds, 0, 0, self->bounds.width, self->bounds.height);
	KprMarginsApply(&style->margins, bounds, bounds);
	FskRectangleSet(bounds, bounds->x + self->left, bounds->y, self->right - self->left, bounds->height);
}
Exemplo n.º 2
0
void KprLabelDraw(void* it, FskPort port, FskRectangle area UNUSED)
{
	KprLabel self = it;
	KprStyle style = self->style;
	char* text = self->text;
	FskRectangleRecord bounds;
	FskRectangleRecord selection;
	FskColorRGBARecord color;
	
	FskRectangleSet(&bounds, 0, 0, self->bounds.width, self->bounds.height);
	if (!bounds.width || !bounds.height) return;
	if (self->skin)
		KprSkinFill(self->skin, port, &bounds, self->variant, self->state, self->coordinates.horizontal, self->coordinates.vertical);
	KprMarginsApply(&style->margins, &bounds, &bounds);
	FskPortGetPenColor(port, &color);
	if ((self->flags & kprTextSelectable) && KprContentIsFocus((KprContent)self)) {
		FskRectangleSet(&selection, bounds.x + self->left, bounds.y, self->right - self->left, bounds.height);
		if (self->from == self->to) {
			if ((self->flags & kprTextEditable) && (self->shell->caretFlags & 2)) {
				FskPortSetPenColor(port, &style->colors[0]);
				FskPortRectangleFill(port, &selection);
			}
		}
		else if (self->skin) {
			double state = (self->shell->flags & kprWindowActive) ? 3 : 2;
			KprSkinFill(self->skin, port, &selection, self->variant, state, kprCenter, kprMiddle);
		}
	}
	if (KprStyleColorize(style, port, self->state)) {
		KprStyleApply(style, port);
		FskPortSetTextAlignment(port, style->horizontalAlignment, kFskTextAlignTop);
		if (style->verticalAlignment != kFskTextAlignTop) {
			UInt16 ascent, descent;
			KprStyleGetInfo(style, &ascent, &descent);
			if (style->verticalAlignment == kFskTextAlignBottom) {
				bounds.y += bounds.height - (ascent + descent);
			}
			else {
				bounds.y += (bounds.height - (ascent + descent)) >> 1;
			}
		}
Exemplo n.º 3
0
void KprCanvasDraw(void* it, FskPort port, FskRectangle area UNUSED)
{
	KprCanvas self = it;
	if (self->cnv) {
		FskConstBitmap bitmap = FskGetCanvasBitmap(self->cnv);
		FskRectangleRecord srcRect, dstRect;
		FskBitmapGetBounds(bitmap, &srcRect);
#if CHECK_UNACCELERATED_BITMAPS
		if (FskBitmapIsOpenGLDestinationAccelerated(port->bits) && !bitmap->accelerate)
			return;
#endif
		FskRectangleSet(&dstRect, 0, 0, self->bounds.width, self->bounds.height);
		FskPortBitmapDraw(port, (FskBitmap)bitmap, &srcRect, &dstRect);
	}
}