コード例 #1
0
int CALLBACK _FontCreateEnumFontFamProc(const LOGFONT * lpelf, const TEXTMETRIC* lpntm, DWORD FontType, LPARAM lParam)
#endif
{
    AMFont_* f = (AMFont_*)lParam;
    if(NULL == f)
        return 0;
    if(NULL == f->hfont)
    {

        memcpy(&f->format, lpelf,  sizeof(LOGFONT));
		 _SetFontSize(f->size, lpelf, &f->format);
        f->hfont = CreateFontIndirect(&f->format);
        return 0;
    }
    return 1;
}
コード例 #2
0
int CALLBACK _FontCreateSystemFontEnumFontFamProc(const LOGFONT* lpelf, const TEXTMETRIC* lpntm, DWORD FontType, LPARAM lParam)
#endif
{

    AMFont_* f = (AMFont_*)lParam;
    if(NULL == f)
        return 0;
    if(NULL == f->hfont)
    {
        memcpy(&f->format, lpelf,  sizeof(LOGFONT));
        f->format.lfItalic = ((f->style & AMFONT_STYLE_ITALIC) > 0 ) ? TRUE : FALSE;
        f->format.lfWeight = ((f->style & AMFONT_STYLE_BOLD) > 0 ) ? FW_BOLD : FW_NORMAL;
        _SetFontSize(f->size, lpelf, &f->format);
        f->hfont = CreateFontIndirect(&f->format);
        return 0;
    }
    return 1;
}
コード例 #3
0
void
KeyboardLayoutView::_DrawIndicator(BView* view, BRect updateRect,
	const Indicator* indicator, BRect rect, bool lit)
{
	float rectTop = rect.top;
	rect.top += 2 * rect.Height() / 3;

	const char* label = NULL;
	if (indicator->modifier == B_CAPS_LOCK)
		label = "caps";
	else if (indicator->modifier == B_NUM_LOCK)
		label = "num";
	else if (indicator->modifier == B_SCROLL_LOCK)
		label = "scroll";
	if (label != NULL) {
		_SetFontSize(view, kIndicator);

		font_height fontHeight;
		GetFontHeight(&fontHeight);
		if (ceilf(rect.top - fontHeight.ascent + fontHeight.descent - 2)
				>= rectTop) {
			view->SetHighColor(0, 0, 0);
			view->SetLowColor(ViewColor());

			BString text(label);
			view->TruncateString(&text, B_TRUNCATE_END, rect.Width());
			view->DrawString(text.String(),
				BPoint(ceilf(rect.left + (rect.Width()
						- StringWidth(text.String())) / 2),
					ceilf(rect.top - fontHeight.descent - 2)));
		}
	}

	rect.left += rect.Width() / 4;
	rect.right -= rect.Width() / 3;

	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color base = lit ? kLitIndicatorColor : kDarkColor;

	be_control_look->DrawButtonFrame(view, rect, updateRect, base,
		background, BControlLook::B_DISABLED);
	be_control_look->DrawButtonBackground(view, rect, updateRect,
		base, BControlLook::B_DISABLED);
}
コード例 #4
0
void
KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
	BRect rect, bool pressed)
{
	rgb_color base = key->dark ? kDarkColor : kBrightColor;
	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	key_kind keyKind = kNormalKey;
	int32 deadKey = 0;
	bool secondDeadKey = false;
	bool isDeadKeyEnabled = true;

	char text[32];
	if (fKeymap != NULL) {
		_GetKeyLabel(key, text, sizeof(text), keyKind);
		deadKey = fKeymap->DeadKey(key->code, fModifiers, &isDeadKeyEnabled);
		secondDeadKey = fKeymap->IsDeadSecondKey(key->code, fModifiers,
			fDeadKey);
	} else {
		// Show the key code if there is no keymap
		snprintf(text, sizeof(text), "%02" B_PRIx32, key->code);
	}

	_SetFontSize(view, keyKind);

	if (secondDeadKey)
		base = kSecondDeadKeyColor;
	else if (deadKey > 0 && isDeadKeyEnabled)
		base = kDeadKeyColor;

	if (key->shape == kRectangleKeyShape) {
		_DrawKeyButton(view, rect, updateRect, base, background, pressed);

		rect.InsetBy(1, 1);

		_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
		be_control_look->DrawLabel(view, text, rect, updateRect,
			base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
	} else if (key->shape == kEnterKeyShape) {
		BRect topLeft = rect;
		BRect topRight = rect;
		BRect bottomLeft = rect;
		BRect bottomRight = rect;

		// TODO: for some reason, this does not always equal the bottom of
		// the other keys...
		bottomLeft.top = floorf(rect.top
			+ fLayout->DefaultKeySize().height * fFactor - fGap - 1);
		bottomLeft.right = floorf(rect.left
			+ (key->frame.Width() - key->second_row) * fFactor - fGap - 2);

		topLeft.bottom = bottomLeft.top;
		topLeft.right = bottomLeft.right + 1;
			// add one to make the borders meet

		topRight.bottom = topLeft.bottom;
		topRight.left = topLeft.right;

		bottomRight.top = bottomLeft.top;
		bottomRight.left = bottomLeft.right;

		// draw top left corner
		be_control_look->DrawButtonFrame(view, topLeft, updateRect,
			4.0f, 0.0f, 4.0f, 0.0f, base, background,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
				| BControlLook::B_BOTTOM_BORDER);
		be_control_look->DrawButtonBackground(view, topLeft, updateRect,
			4.0f, 0.0f, 4.0f, 0.0f, base,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
				| BControlLook::B_BOTTOM_BORDER);

		// draw top right corner
		be_control_look->DrawButtonFrame(view, topRight, updateRect,
			0.0f, 4.0f, 0.0f, 0.0f, base, background,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
		be_control_look->DrawButtonBackground(view, topRight, updateRect,
			0.0f, 4.0f, 0.0f, 0.0f, base,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);

		// draw bottom right corner
		be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
			0.0f, 0.0f, 4.0f, 4.0f, base, background,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
				 | BControlLook::B_BOTTOM_BORDER);
		be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
			0.0f, 0.0f, 4.0f, 4.0f, base,
			pressed ? BControlLook::B_ACTIVATED : 0,
			BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
				 | BControlLook::B_BOTTOM_BORDER);

		// clip out the bottom left corner
		bottomLeft.right += 1;
		bottomLeft.top -= 2;
		BRegion region(rect);
		region.Exclude(bottomLeft);
		view->ConstrainClippingRegion(&region);

		// Fill in the rect with the background color
		SetHighColor(background);
		FillRect(rect);

		// draw the button background
		BRect bgRect = rect.InsetByCopy(2, 2);
		be_control_look->DrawButtonBackground(view, bgRect, updateRect,
			4.0f, 4.0f, 0.0f, 4.0f, base,
			pressed ? BControlLook::B_ACTIVATED : 0);

		rect.left = bottomLeft.right;
		_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));

		// draw the button label
		be_control_look->DrawLabel(view, text, rect, updateRect,
			base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));

		// reset the clipping region
		view->ConstrainClippingRegion(NULL);
	}
}
コード例 #5
0
ファイル: HYGraphicPane.cpp プロジェクト: mdsmith/OCLHYPHY
void _HYGraphicPane::SetFontSize (long s)
{
	font.size = s;
	_SetFontSize (s);
}