Exemple #1
0
void GetMenuSize(XlibMenu * menu)
{
    int i = 0;
    int winheight = 0;
    int fontheight = 0;
    int menuwidth = 0;
    FcitxSkin *sc = &menu->owner->skin;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    winheight = sc->skinMenu.marginTop + sc->skinMenu.marginBottom;//菜单头和尾都空8个pixel
    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU)
            winheight += 6 + fontheight;
        else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE)
            winheight += 5;

        int width = StringWidth(GetMenuItem(menu->menushell, i)->tipstr, menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
        if (width > menuwidth)
            menuwidth = width;
    }
    menu->height = winheight;
    menu->width = menuwidth + sc->skinMenu.marginLeft + sc->skinMenu.marginRight + 15 + 20;
}
BFileControl::BFileControl(BRect rect, const char* name, const char* label,
	const char *pathOfFile,uint32 flavors)
	:
	BView(rect, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// determine font height
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent
		+ fontHeight.leading) + 13;
	BString selectString = B_TRANSLATE("Select" B_UTF8_ELLIPSIS);
	float labelWidth = StringWidth(selectString) + 20;
	rect = Bounds();
	rect.right -= labelWidth;
	rect.top = 4;
	rect.bottom = itemHeight + 2;
	fText = new BTextControl(rect,"file_path", label, pathOfFile, NULL);
	if (label)
		fText->SetDivider(fText->StringWidth(label) + 6);
	AddChild(fText);

	fButton = new BButton(BRect(0, 0, 1, 1), "select_file", selectString,
		new BMessage(kMsgSelectButton));
	fButton->ResizeToPreferred();
	fButton->MoveBy(rect.right + 6,
		(rect.Height() - fButton->Frame().Height()) / 2);
	AddChild(fButton);

	fPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, flavors, false);

	ResizeToPreferred();
}
Exemple #3
0
void YabTabView::DrawLabel(int32 current, BRect frame)
{
    BString label = GetTabName(current);
	if (label == NULL)
		return;

	float frameWidth = frame.Width();
	float width = StringWidth(label.String());
	font_height fh;

	if (width > frameWidth) {
		BFont font;
		GetFont(&font);
		font.TruncateString(&label, B_TRUNCATE_END, frameWidth);
		width = frameWidth;
		font.GetHeight(&fh);
	} else {
		GetFontHeight(&fh);
	}

	SetDrawingMode(B_OP_OVER);
	SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
	DrawString(label.String(),
		BPoint((frame.left + frame.right - width) / 2.0,
 			(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
 			+ fh.ascent));
}
Exemple #4
0
EventPrefsView::EventPrefsView(BRect frame)
	: BView(frame, "Event prefs", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS)
{
	AdoptSystemColors();
	BRect bounds(Bounds());
	bounds.left += 3;
	bounds.right -= B_V_SCROLL_BAR_WIDTH + 3;
	bounds.top += 3;
	bounds.bottom -= 5;
	int32 i(0);

	float label_width(0.0);

	for (i = 0; EventControlLabels[i]; ++i)
		if (StringWidth(EventControlLabels[i]) > label_width)
			label_width = StringWidth(EventControlLabels[i]);

	BView* bgView(new BView(bounds, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW));
	bgView->AdoptSystemColors();
	fEvents = new VTextControl* [MAX_EVENTS];

	for (i = 0; i < MAX_EVENTS; ++i) {
		fEvents[i] = new VTextControl(
			BRect(5, be_plain_font->Size() + ((1.5 * i) * 1.5 * be_plain_font->Size()),
				  5 + bounds.right - be_plain_font->StringWidth("gP"),
				  be_plain_font->Size() + (1.5 * (i + 1) * 1.5 * be_plain_font->Size())),
			"commands", EventControlLabels[i], vision_app->GetEvent(i).String(), NULL,
			B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);

		fEvents[i]->SetDivider(label_width + 5);

		BMessage* msg(new BMessage(M_EVENT_MODIFIED));

		msg->AddInt32("which", i);
		fEvents[i]->SetModificationMessage(msg);
		bgView->AddChild(fEvents[i]);
	}
	fScroller = new BScrollView("command fScroller", bgView, B_FOLLOW_ALL_SIDES, 0, false, true);
	BScrollBar* bar(fScroller->ScrollBar(B_VERTICAL));

	fMaxheight = bgView->Bounds().Height();
	fProportionheight = fEvents[MAX_EVENTS - 1]->Frame().bottom + 10.0;
	bar->SetRange(0.0, (fProportionheight - fScroller->Bounds().Height()));
	bar->SetProportion(fScroller->Bounds().Height() / fProportionheight);

	AddChild(fScroller);
}
/*******************************************************
 * ARP-FONT-CONTROL
 *******************************************************/
ArpFontControl::ArpFontControl(	BRect frame,
								const char* name,
								const BString16* label,
								uint32 message,
								float divider)
		: inherited(frame, name, 0, new BMessage(message),
					B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW),
		  mFontCtrl(0), mSizeCtrl(0), mMsgWhat(message)
{
	if (label) {
		if (divider <= 0) divider = StringWidth(label);
		BRect			f(0, 0, divider, frame.Height());
		BStringView*	sv = new BStringView(f, "sv", label);
		if (sv) AddChild(sv);
	}

	float				sizeW = StringWidth("000") + 5;
	float				sizeL = frame.Width() - sizeW;
	BRect				f(divider + 1, 0, sizeL - 1, frame.Height());
	mFontCtrl = new BMenuField(f, "fonts", 0, new BMenu("font"), true,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (!mFontCtrl) return;

	mFontCtrl->SetDivider(0);
	BMenu*		m = mFontCtrl->Menu();
	if (m) {
		m->SetLabelFromMarked(true);
		_ArpFontControlFamilies		families(m);
		families.ForEach();
	}
	AddChild(mFontCtrl);

	float		iH = float(Prefs().GetInt32(ARP_INTCTRL_Y));
	float		iT = 0, iB = frame.Height();
	if (iH < frame.Height()) {
		iT = (frame.Height() - iH) / 2;
		iB = iT + iH;
	}
	f.Set(sizeL, iT, sizeL + sizeW, iB);
	mSizeCtrl = new ArpIntControl(	f, "size", 0, new BMessage(SIZE_IMSG),
									B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	if (mSizeCtrl) {
		mSizeCtrl->SetLimits(1, 512);
		AddChild(mSizeCtrl);
	}

}
Exemple #6
0
BSize
BButton::_ValidatePreferredSize()
{
	if (fPreferredSize.width < 0) {
		BControlLook::background_type backgroundType
			= fBehavior == B_POP_UP_BEHAVIOR
				? BControlLook::B_BUTTON_WITH_POP_UP_BACKGROUND
				: BControlLook::B_BUTTON_BACKGROUND;
		float left, top, right, bottom;
		be_control_look->GetInsets(BControlLook::B_BUTTON_FRAME, backgroundType,
			IsDefault() ? BControlLook::B_DEFAULT_BUTTON : 0,
			left, top, right, bottom);

		// width
		float width = left + right + 2 * kLabelMargin - 1;

		const char* label = Label();
		if (label != NULL) {
			width = std::max(width, 20.0f);
			width += (float)ceil(StringWidth(label));
		}

		const BBitmap* icon = IconBitmap(B_INACTIVE_ICON_BITMAP);
		if (icon != NULL)
			width += icon->Bounds().Width() + 1;

		if (label != NULL && icon != NULL)
			width += be_control_look->DefaultLabelSpacing();

		// height
		float minHorizontalMargins = top + bottom + 2 * kLabelMargin;
		float height = -1;

		if (label != NULL) {
			font_height fontHeight;
			GetFontHeight(&fontHeight);
			float textHeight = fontHeight.ascent + fontHeight.descent;
			height = ceilf(textHeight * 1.8);
			float margins = height - ceilf(textHeight);
			if (margins < minHorizontalMargins)
				height += minHorizontalMargins - margins;
		}

		if (icon != NULL) {
			height = std::max(height,
				icon->Bounds().Height() + minHorizontalMargins);
		}

		// force some minimum width/height values
		width = std::max(width, label != NULL ? 75.0f : 5.0f);
		height = std::max(height, 5.0f);

		fPreferredSize.Set(width, height);

		ResetLayoutInvalidation();
	}

	return fPreferredSize;
}
Exemple #7
0
// PreferredLabelWidth
float
PropertyItemView::PreferredLabelWidth() const
{
	float width = 0.0;
	if (const Property* property = GetProperty())
		width = ceilf(StringWidth(name_for_id(property->Identifier())) + 10.0);
	return width;
}
Exemple #8
0
BStringView::BStringView(const char* name, const char* text, uint32 flags)
	:	BView(name, flags | B_FULL_UPDATE_ON_RESIZE),
		fText(text ? strdup(text) : NULL),
		fStringWidth(text ? StringWidth(text) : 0.0),
		fAlign(B_ALIGN_LEFT),
		fPreferredSize(-1, -1)
{
}
Exemple #9
0
IPCPView::IPCPView(IPCPAddon *addon, BRect frame)
	: BView(frame, kLabelIPCP, B_FOLLOW_NONE, 0),
	fAddon(addon)
{
	BRect rect = Bounds();
	rect.InsetBy(10, 10);
	rect.bottom = rect.top + 20;
	BRect optionalRect(rect);
	rect.right -= 75;
	fIPAddress = new BTextControl(rect, "ip", kLabelIPAddress, NULL, NULL);
	optionalRect.left = rect.right + 5;
	optionalRect.bottom = optionalRect.top + 15;
	AddChild(new BStringView(optionalRect, "optional_1", kLabelOptional));
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 20;
	fPrimaryDNS = new BTextControl(rect, "primaryDNS", kLabelPrimaryDNS, NULL, NULL);
	optionalRect.top = rect.top;
	optionalRect.bottom = optionalRect.top + 15;
	AddChild(new BStringView(optionalRect, "optional_2", kLabelOptional));
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 20;
	fSecondaryDNS = new BTextControl(rect, "secondaryDNS", kLabelSecondaryDNS, NULL,
		NULL);
	optionalRect.top = rect.top;
	optionalRect.bottom = optionalRect.top + 15;
	AddChild(new BStringView(optionalRect, "optional_3", kLabelOptional));
	rect.top = rect.bottom + 50;
	rect.bottom = rect.top + 10;
	AddChild(new BStringView(rect, "expert", kLabelExtendedOptions));
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 15;
	fIsEnabled = new BCheckBox(rect, "isEnabled", kLabelEnabled,
		new BMessage(kMsgUpdateControls));
	
	// set divider of text controls
	float controlWidth = max(max(StringWidth(fIPAddress->Label()),
		StringWidth(fPrimaryDNS->Label())), StringWidth(fSecondaryDNS->Label()));
	fIPAddress->SetDivider(controlWidth + 5);
	fPrimaryDNS->SetDivider(controlWidth + 5);
	fSecondaryDNS->SetDivider(controlWidth + 5);
	
	AddChild(fIsEnabled);
	AddChild(fIPAddress);
	AddChild(fPrimaryDNS);
	AddChild(fSecondaryDNS);
}
Exemple #10
0
void VideoDVDPanel::AllAttached() {
    mi->SetTarget(this, Looper());
    filesystemMF->SetDivider(StringWidth(_T("Volume name"))+30); // "TVOLUMENAME"
    filesystemMF->MoveTo(5,2);
    filesystemMF->ResizeTo(200, 22);
    volumenameTC->MoveTo(5,28);
    volumenameTC->ResizeTo(200, 20);
}
void
TNameControl::AttachedToWindow()
{
	BTextControl::AttachedToWindow();

	SetDivider(StringWidth(fLabel) + 6);
	TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);
}
void AmTimeView::AddViews()
{
	font_height		fheight;
	GetFontHeight( &fheight );
	// Add the measure control
	float	left = 0, top = 0;
	float	width = StringWidth("0000") + 5;
	float	height = fheight.ascent + fheight.descent + fheight.leading + 1;
	BRect	f(left, top, left + width, top + height);
	if( (mMeasureCtrl = new ArpIntControl(f, "measure", 0, 0)) != 0 ) {
		mMeasureCtrl->SetLimits(1, 9999);
		mMeasureCtrl->StartWatching(this, ARPMSG_INT_CONTROL_CHANGED);
		mMeasureCtrl->SetMotion( new ArpIntControlSmallMotion() );
		AddChild(mMeasureCtrl);
	}
	// Add a ":"
	left += width;
	float	dotW = StringWidth(":") + 2;
	BStringView	*sv = new BStringView(	BRect(left, top, left + dotW, top + height - 2),
										"dot", ":");
	if( sv ) AddChild(sv);
	// Add the beat control
	left += dotW;
	width = StringWidth("00") + 5;
	f.Set(left, top, left + width, top + height);
	if( (mBeatCtrl = new ArpIntControl(f, "beat", 0, 0)) != 0 ) {
		mBeatCtrl->StartWatching(this, ARPMSG_INT_CONTROL_CHANGED);
		AddChild(mBeatCtrl);
	}
	// Add a ":"
	left += width;
	sv = new BStringView(	BRect(left, top, left + dotW, top + height - 2),
							"dot", ":");
	if( sv ) AddChild(sv);
	// Add the clock control
	left += dotW;
	width = StringWidth("0000") + 5;
	f.Set(left, top, left + width, top + height);
	if ( (mClockCtrl = new ArpIntControl(f, "clock", 0, 0)) != 0 ) {
		mClockCtrl->SetLimits(0, PPQN - 1);
		mClockCtrl->StartWatching(this, ARPMSG_INT_CONTROL_CHANGED);
		AddChild(mClockCtrl);
	}
	ResizeTo(left + width, top + height);	
}
Exemple #13
0
void
Spinner::_InitObject(void)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect r(Bounds());
	if (r.Height() < B_H_SCROLL_BAR_HEIGHT * 2)
		r.bottom = r.top + 1 + B_H_SCROLL_BAR_HEIGHT * 2;
	ResizeTo(r.Width(),r.Height());
	
	r.right -= B_V_SCROLL_BAR_WIDTH;
	
	font_height fh;
	BFont font;
	font.GetHeight(&fh);
	float textheight = fh.ascent + fh.descent + fh.leading;
	
	r.top = 0;
	r.bottom = textheight;
	
	fTextControl = new BTextControl(r,"textcontrol",Label(),"0",
									new BMessage(M_TEXT_CHANGED), B_FOLLOW_TOP | 
									B_FOLLOW_LEFT_RIGHT,
									B_WILL_DRAW | B_NAVIGABLE);
	AddChild(fTextControl);
	fTextControl->ResizeTo(r.Width(), MAX(textheight, fTextControl->TextView()->LineHeight(0) + 4.0));
	fTextControl->MoveTo(0,
		((B_H_SCROLL_BAR_HEIGHT * 2) - fTextControl->Bounds().Height()) / 2);
		
	fTextControl->SetDivider(StringWidth(Label()) + 5);
	
	BTextView *tview = fTextControl->TextView();
	tview->SetAlignment(B_ALIGN_LEFT);
	tview->SetWordWrap(false);
	
	BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| "
		"asdfghjkl:\"zxcvbnm<>?!@#$%^&*()-_=+`~\r");
	
	for (int32 i = 0; i < string.CountChars(); i++) {
		char c = string.ByteAt(i);
		tview->DisallowChar(c);
	}
	
	r = Bounds();
	r.left = r.right - B_V_SCROLL_BAR_WIDTH;
	r.bottom = B_H_SCROLL_BAR_HEIGHT;
	
	fUpButton = new SpinnerArrowButton(r.LeftTop(),"up",ARROW_UP);
	AddChild(fUpButton);
	
	r.OffsetBy(0,r.Height() + 1);
	fDownButton = new SpinnerArrowButton(r.LeftTop(),"down",ARROW_DOWN);
	AddChild(fDownButton);
	
	
	fPrivateData = new SpinnerPrivateData;
	fFilter = new SpinnerMsgFilter;
}
Exemple #14
0
BSize
PaneSwitch::MinSize()
{
	BSize size;
	float onLabelWidth = StringWidth(fLabelOn);
	float offLabelWidth = StringWidth(fLabelOff);
	float labelWidth = max_c(onLabelWidth, offLabelWidth);
	size.width = sLatchSize;
	if (labelWidth > 0.0)
		size.width += ceilf(sLatchSize / 2.0) + labelWidth;

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	size.height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
	size.height = max_c(size.height, sLatchSize);

	return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
}
Exemple #15
0
void StatusView::AddItem(StatusItem* item, bool erase)
{
	StatusItem* last((StatusItem*)items.LastItem());
	float width(3.0);

	if (last) width = last->frame.right + 8.0;

	if (item->label.Length()) width += StringWidth(item->label.String()) + 3;

	item->frame.top = 2.0;
	item->frame.bottom = Bounds().Height();
	item->frame.left = width;
	item->frame.right = width + StringWidth(item->value.String());

	if (erase) item->value = "";

	items.AddItem(item);
}
Exemple #16
0
void
BSlider::UpdateTextChanged()
{
	// update text label
	float oldWidth = 0.0;
	if (fUpdateText != NULL)
		oldWidth = StringWidth(fUpdateText);

	const char* oldUpdateText = fUpdateText;
	fUpdateText = UpdateText();
	bool updateTextOnOff = (fUpdateText == NULL && oldUpdateText != NULL)
		|| (fUpdateText != NULL && oldUpdateText == NULL);

	float newWidth = 0.0;
	if (fUpdateText != NULL)
		newWidth = StringWidth(fUpdateText);

	float width = ceilf(max_c(newWidth, oldWidth)) + 2.0f;
	if (width != 0) {
		font_height fontHeight;
		GetFontHeight(&fontHeight);

		float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
		float lineHeight = height + ceilf(fontHeight.leading);
		BRect invalid(Bounds());
		if (fOrientation == B_HORIZONTAL)
			invalid = BRect(invalid.right - width, 0, invalid.right, height);
		else {
			if (!updateTextOnOff) {
				invalid.left = (invalid.left + invalid.right - width) / 2;
				invalid.right = invalid.left + width;
				if (fMinLimitLabel)
					invalid.bottom -= lineHeight;
				invalid.top = invalid.bottom - height;
			}
		}
		Invalidate(invalid);
	}

	float oldMaxUpdateTextWidth = fMaxUpdateTextWidth;
	fMaxUpdateTextWidth = MaxUpdateTextWidth();
	if (oldMaxUpdateTextWidth != fMaxUpdateTextWidth)
		InvalidateLayout();
}
void
BChannelSlider::Draw(BRect updateRect)
{
	_UpdateFontDimens();
	_DrawThumbs();

	BRect bounds(Bounds());
	if (Label()) {
		float labelWidth = StringWidth(Label());
		DrawString(Label(), BPoint((bounds.Width() - labelWidth) / 2.0,
			fBaseLine));
	}

	if (MinLimitLabel()) {
		if (fIsVertical) {
			if (MinLimitLabel()) {
				float x = (bounds.Width() - StringWidth(MinLimitLabel()))
					/ 2.0;
				DrawString(MinLimitLabel(), BPoint(x, bounds.bottom
					- kPadding));
			}
		} else {
			if (MinLimitLabel()) {
				DrawString(MinLimitLabel(), BPoint(kPadding, bounds.bottom
					- kPadding));
			}
		}
	}

	if (MaxLimitLabel()) {
		if (fIsVertical) {
			if (MaxLimitLabel()) {
				float x = (bounds.Width() - StringWidth(MaxLimitLabel()))
					/ 2.0;
				DrawString(MaxLimitLabel(), BPoint(x, 2 * fLineFeed));
			}
		} else {
			if (MaxLimitLabel()) {
				DrawString(MaxLimitLabel(), BPoint(bounds.right - kPadding
					- StringWidth(MaxLimitLabel()), bounds.bottom - kPadding));
			}
		}
	}
}
Exemple #18
0
static void CcpParamProc (ButtoN b)
{
  WindoW           w;
  GrouP            h, g, h1;
  ButtoN           b1, b2, b3;
  XOSPtr           xosp;

  SeqScrollDataPtr ssdp_ccp = NULL;

  if ((xosp = (XOSPtr) GetObjectExtra (b)) == NULL)
    return;
  if (xosp->flagParamWindow)
    return;

  w = FixedWindow (-50, -10, -10, -10,
                   "Ccp Parameters", CloseParamWindowProc);

  h = HiddenGroup (w, 1, 0, NULL);
  h1 = HiddenGroup (h, 2, 0, NULL);
  StaticPrompt (h1, "window", StringWidth ("window"), dialogTextHeight,
                NULL, 'c');
  StaticPrompt (h1, "linker", StringWidth ("linker"), dialogTextHeight,
                NULL, 'c');
  h1 = HiddenGroup (h, 2, 0, NULL);
  g = HiddenGroup (h1, 2, 0, NULL);
  AddScrollControl (&ssdp_ccp, g, 22, 7, 42, 24);
  g = HiddenGroup (h1, 2, 0, NULL);
  AddScrollControl (&ssdp_ccp, g, 0, 0, 64, 24);
  SetObjectExtra (w, ssdp_ccp, NULL);

  h1 = HiddenGroup (h, 3, 0, NULL);
  b1 = PushButton (h1, "Accept", AcceptParamProc);
  SetObjectExtra (b1, xosp, NULL);
  b2 = PushButton (h1, "Apply ", UpdateParamProc);
  SetObjectExtra (b2, xosp, NULL);
  b3 = PushButton (h1, "Cancel", CancelParamProc);
  SetObjectExtra (b3, xosp, NULL);

  Show (w);
  Select (w);
  xosp->flagParamWindow = TRUE;

  return;
}
Exemple #19
0
BStringView::BStringView(BRect frame, const char* name, const char* text,
	uint32 resizingMode, uint32 flags)
	:
	BView(frame, name, resizingMode, flags | B_FULL_UPDATE_ON_RESIZE),
	fText(text ? strdup(text) : NULL),
	fTruncation(B_NO_TRUNCATION),
	fAlign(B_ALIGN_LEFT),
	fPreferredSize(text ? StringWidth(text) : 0.0, -1)
{
}
Exemple #20
0
void 
Stringview1::SetTypeText(const char *utypetext) {


	rgb_color lc=LowColor();
	rgb_color hc=HighColor();
	
	SetHighColor(190,190,190,255);
	FillRect(BRect(Bounds().Width()-20-StringWidth(typetext->String()),0,
			Bounds().Width()-20,Bounds().Height()),B_SOLID_HIGH);
	SetHighColor(0,0,0,255);
	SetLowColor(255,255,255,255);
	typetext->SetTo(utypetext);
	DrawString(typetext->String(), BPoint(Bounds().Width()-20-StringWidth(typetext->String()),12));
	
	SetLowColor(lc);
	SetHighColor(hc);

}
Exemple #21
0
void
BStringView::SetFont(const BFont* font, uint32 mask)
{
	BView::SetFont(font, mask);

	fPreferredSize.width = StringWidth(fText);

	Invalidate();
	InvalidateLayout();
}
Exemple #22
0
void
BMenuField::_ValidateLayoutData()
{
	CALLED();

	if (fLayoutData->valid)
		return;

	// cache font height
	font_height& fh = fLayoutData->font_info;
	GetFontHeight(&fh);

	if (Label() != NULL) {
		fLayoutData->label_width = ceilf(StringWidth(Label()));
		fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent);
	} else {
		fLayoutData->label_width = 0;
		fLayoutData->label_height = 0;
	}

	// compute the minimal divider
	float divider = 0;
	if (fLayoutData->label_width > 0)
		divider = fLayoutData->label_width + 5;

	// If we shan't do real layout, we let the current divider take influence.
	if (!(Flags() & B_SUPPORTS_LAYOUT))
		divider = max_c(divider, fDivider);

	// get the minimal (== preferred) menu bar size
	// TODO: BMenu::MinSize() is using the ResizeMode() to decide the
	// minimum width. If the mode is B_FOLLOW_LEFT_RIGHT, it will use the
	// parent's frame width or window's frame width. So at least the returned
	// size is wrong, but apparantly it doesn't have much bad effect.
	fLayoutData->menu_bar_min = fMenuBar->MinSize();

	TRACE("menu bar min width: %.2f\n", fLayoutData->menu_bar_min.width);

	// compute our minimal (== preferred) size
	BSize min(fLayoutData->menu_bar_min);
	min.width += 2 * kVMargin;
	min.height += 2 * kVMargin;

	if (divider > 0)
		min.width += divider;
	if (fLayoutData->label_height > min.height)
		min.height = fLayoutData->label_height;

	fLayoutData->min = min;

	fLayoutData->valid = true;
	ResetLayoutInvalidation();

	TRACE("width: %.2f, height: %.2f\n", min.width, min.height);
}
StepGuider::StepGuiderConfigDialogPane::StepGuiderConfigDialogPane(wxWindow *pParent, StepGuider *pStepGuider)
    : MountConfigDialogPane(pParent, _("AO Settings"), pStepGuider)
{
    int width;

    m_pStepGuider = pStepGuider;

    width = StringWidth(_T("000"));
    m_pCalibrationStepsPerIteration = new wxSpinCtrl(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
            wxSize(width+30, -1), wxSP_ARROW_KEYS, 0, 10, 3,_T("Cal_Steps"));

    DoAdd(_("Calibration Steps"), m_pCalibrationStepsPerIteration,
        wxString::Format(_("How many steps should be issued per calibration cycle. Default = %d, increase for short f/l scopes and decrease for longer f/l scopes"), DefaultCalibrationStepsPerIteration));

    width = StringWidth(_T("000"));
    m_pSamplesToAverage = new wxSpinCtrl(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
            wxSize(width+30, -1), wxSP_ARROW_KEYS, 0, 9, 0, _T("Samples_To_Average"));

    DoAdd(_("Samples to Average"), m_pSamplesToAverage,
        wxString::Format(_("When calibrating, how many samples should be averaged. Default = %d, increase for worse seeing and small imaging scales"), DefaultSamplesToAverage));

    width = StringWidth(_T("000"));
    m_pBumpPercentage = new wxSpinCtrl(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
            wxSize(width+30, -1), wxSP_ARROW_KEYS, 0, 99, 0, _T("Bump_Percentage"));

    DoAdd(_("Bump Percentage"), m_pBumpPercentage,
        wxString::Format(_("What percentage of the AO travel can be used before bumping the mount. Default = %d"), DefaultBumpPercentage));

    width = StringWidth(_T("00.00"));
    m_pBumpMaxStepsPerCycle = new wxSpinCtrlDouble(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
            wxSize(width+30, -1), wxSP_ARROW_KEYS, 0.01, 99.99, 0.0, 0.25, _T("Bump_steps"));
    wxSizer *sz = MakeLabeledControl(_("Bump Step"), m_pBumpMaxStepsPerCycle, wxString::Format(_("How far should a mount bump move the mount between images (in AO steps). Default = %.2f, decrease if mount bumps cause spikes on the graph"), DefaultBumpMaxStepsPerCycle));

    m_bumpOnDither = new wxCheckBox(pParent, wxID_ANY, _("Bump on Dither"));
    m_bumpOnDither->SetToolTip(_("Bump the mount to return the AO to center at each dither"));

    wxSizer *hsz = new wxBoxSizer(wxHORIZONTAL);
    hsz->Add(sz, wxSizerFlags(1));
    hsz->Add(m_bumpOnDither, wxSizerFlags(1).Right().Border(wxLEFT, 15).Align(wxALIGN_CENTER_VERTICAL));

    DoAdd(hsz);
}
Exemple #24
0
void
ImageView::Draw(BRect updateRect)
{
	if (fSuccess)
		DrawBitmapAsync(fImage, Bounds());
	else {
		float length = StringWidth(B_TRANSLATE("Image not loaded correctly"));
		DrawString(B_TRANSLATE("Image not loaded correctly"),
			BPoint((Bounds().Width() - length) / 2.0f, 30.0f));
	}
}
Exemple #25
0
// GetPreferredSize
void
ListLabelView::GetPreferredSize(float* width, float* height)
{
	font_height fh;
	GetFontHeight(&fh);

	if (width)
		*width = max_c(Bounds().Width(), StringWidth(fLabel.String()) + 10);
	if (height)
		*height = fh.ascent + fh.descent + 8;
}
Exemple #26
0
void
TypeIconView::GetPreferredSize(float* _width, float* _height)
{
	if (_width) {
		float a = StringWidth("(from application)");
		float b = StringWidth("(from super type)");
		float width = max_c(a, b);
		if (width < IconSize())
			width = IconSize();

		*_width = ceilf(width);
	}

	if (_height) {
		font_height fontHeight;
		GetFontHeight(&fontHeight);

		*_height = IconSize() + 3.0f + ceilf(fontHeight.ascent + fontHeight.descent);
	}
}
void
StatusView::GetPreferredSize(float *width, float *height)
{
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	*height = fontHeight.ascent + fontHeight.descent;
	if (!fInDeskbar)
		*height += 7;

	*width = StringWidth(MAX_FREQ_STRING);
}
Exemple #28
0
//------------------------------------------------------------------------------
void BMenuField::AttachedToWindow()
{
	if (Parent())
	{
		SetViewColor(Parent()->ViewColor());
		SetLowColor(Parent()->ViewColor());
	}

	if (fLabel)
			fStringWidth = StringWidth(fLabel);
}
Exemple #29
0
void DrawAboutWindow (void)
{
#ifdef _USE_XFT
    OutputString (aboutWindow, xftVKWindowFont, strTitle, (ABOUT_WINDOW_WIDTH - StringWidth (strTitle, xftVKWindowFont)) / 2, iVKWindowFontSize + 6 + 30, AboutWindowFontColor.color);
#else
    OutputString (aboutWindow, fontSetVKWindow, strTitle, (ABOUT_WINDOW_WIDTH - StringWidth (strTitle, fontSetVKWindow)) / 2, iVKWindowFontSize + 6 + 30, AboutWindowFontColor.gc);
#endif

#ifdef _USE_XFT
    OutputString (aboutWindow, xftVKWindowFont, AboutEmail, (ABOUT_WINDOW_WIDTH - StringWidth (AboutEmail, xftVKWindowFont)) / 2, iVKWindowFontSize + 6 + 60, AboutWindowFontColor.color);
#else
    OutputString (aboutWindow, fontSetVKWindow, AboutEmail, (ABOUT_WINDOW_WIDTH - StringWidth (AboutEmail, fontSetVKWindow)) / 2, iVKWindowFontSize + 6 + 60, AboutWindowFontColor.gc);
#endif

#ifdef _USE_XFT
    OutputString (aboutWindow, xftVKWindowFont, AboutCopyRight, (ABOUT_WINDOW_WIDTH - StringWidth (AboutCopyRight, xftVKWindowFont)) / 2, iVKWindowFontSize + 6 + 80, AboutWindowFontColor.color);
#else
    OutputString (aboutWindow, fontSetVKWindow, AboutCopyRight, (ABOUT_WINDOW_WIDTH - StringWidth (AboutCopyRight, fontSetVKWindow)) / 2, iVKWindowFontSize + 6 + 80, AboutWindowFontColor.gc);
#endif
}
short stringwidth(char *s)
{
	short w = 0;
	char localStr[256] ="";
	if(s) {
		strcpy(localStr,s);
		my_c2pstr(localStr);
		w = StringWidth((StringPtr)localStr);
	}
	return w;
}