当前位置: 首页>>代码示例>>C++>>正文


C++ BFont::TruncateString方法代码示例

本文整理汇总了C++中BFont::TruncateString方法的典型用法代码示例。如果您正苦于以下问题:C++ BFont::TruncateString方法的具体用法?C++ BFont::TruncateString怎么用?C++ BFont::TruncateString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BFont的用法示例。


在下文中一共展示了BFont::TruncateString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Label

void
BTab::DrawLabel(BView *owner, BRect frame)
{
	if (Label() == NULL)
		return;

	BString label = Label();
	float frameWidth = frame.Width();
	float width = owner->StringWidth(label.String());
	font_height fh;

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

	owner->SetDrawingMode(B_OP_OVER);
	owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
	owner->DrawString(label.String(),
		BPoint((frame.left + frame.right - width) / 2.0,
 			(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
 			+ fh.ascent));
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:28,代码来源:TabView.cpp

示例2: b

// Draw
void
PropertyItemView::Draw(BRect updateRect)
{
	const Property* property = GetProperty();
	if (property && fParent) {
		BRect b(Bounds());

		// just draw background and label
		rgb_color labelColor = LowColor();
		if (fEnabled)
			labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
		else
			labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);
		
		SetHighColor(labelColor);
		BFont font;
		GetFont(&font);
		
		BString truncated(name_for_id(property->Identifier()));
		font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, fLabelWidth - 10.0);

		font_height fh;
		font.GetHeight(&fh);

		FillRect(BRect(b.left, b.top, b.left + fLabelWidth, b.bottom), B_SOLID_LOW);
		DrawString(truncated.String(), BPoint(b.left + 5.0,
											  floorf(b.top + b.Height() / 2.0
												  		   + fh.ascent / 2.0)));

		// draw a "separator" line behind the label
		SetHighColor(tint_color(LowColor(), B_DARKEN_1_TINT));
		StrokeLine(BPoint(b.left + fLabelWidth - 1.0, b.top),
				   BPoint(b.left + fLabelWidth - 1.0, b.bottom), B_SOLID_HIGH);
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:36,代码来源:PropertyItemView.cpp

示例3: DrawLabel

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));
}
开发者ID:HaikuArchives,项目名称:Yab,代码行数:27,代码来源:YabTabView.cpp

示例4: Draw

	virtual void Draw(BRect updateRect)
	{
		if (fMouseOver) {
			float tint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0;
			SetHighColor(tint_color(HighColor(), tint));
			SetLowColor(tint_color(LowColor(), tint));
		}

		BRect b(Bounds());
		if (fSelected) {
			SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
		} else if (fLevel > 0) {
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
		}

		FillRect(b, B_SOLID_LOW);

		// prevent the text from moving when border width changes
		if (!fSelected)
			b.InsetBy(1, 1);

		float width;
		BFont font;
		GetFont(&font);

		font_height fh;
		font.GetHeight(&fh);

		// draw the partition label, but only if we have no child partition
		// views
		BPoint textOffset;
		if (CountChildren() > 0) {
			font.SetRotation(0.0);
			SetFont(&font);
			width = b.Width();
			textOffset = b.LeftTop();
			textOffset.x += 3;
			textOffset.y += ceilf(fh.ascent);
		} else {
			width = b.Height();
			textOffset = b.LeftBottom();
			textOffset.x += ceilf(fh.ascent);
		}

		BString name(Name());
		font.TruncateString(&name, B_TRUNCATE_END, width);

		SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT));
		DrawString(name.String(), textOffset);
	}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:55,代码来源:DiskView.cpp

示例5: string

void
BMenuItem::TruncateLabel(float maxWidth, char *newLabel)
{
	BFont font;
	BString string(fLabel);

	font.TruncateString(&string, B_TRUNCATE_MIDDLE, maxWidth);

	string.CopyInto(newLabel, 0, string.Length());
	newLabel[string.Length()] = '\0';
}
开发者ID:mariuz,项目名称:haiku,代码行数:11,代码来源:MenuItem.cpp

示例6: Bounds

void
CProgramChangeMonitorView::ProgramChange(
	BString program)
{
	BFont font;
	GetFont(&font);
	font.TruncateString(&program, B_TRUNCATE_END, Bounds().Width());

	m_program = program;
	
	m_fresh = 15;
}
开发者ID:HaikuArchives,项目名称:MeV,代码行数:12,代码来源:DestinationMonitorView.cpp

示例7: b

// Draw
void
FontValueView::Draw(BRect updateRect)
{
	BRect b(Bounds());
	// focus indication
	if (IsFocus()) {
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
		StrokeRect(b);
		b.InsetBy(1.0, 1.0);
		BRegion clipping;
		clipping.Include(b);
		ConstrainClippingRegion(&clipping);
		b.left --;
	}
	// background
	FillRect(b, B_SOLID_LOW);

	rgb_color labelColor = LowColor();
	if (fEnabled)
		labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
	else
		labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);

	SetHighColor(labelColor);

	b.InsetBy(2.0, 1.0);

	float center = floorf(b.top + b.Height() / 2.0);

	BPoint arrow[3];
	arrow[0] = BPoint(b.left, center - 3.0);
	arrow[1] = BPoint(b.left, center + 3.0);
	arrow[2] = BPoint(b.left + 3.0, center);

	FillPolygon(arrow, 3);

	b.left += 6.0;

	BFont font;
	GetFont(&font);

	font_height fh;
	font.GetHeight(&fh);

	BString truncated(fCurrentFont);
	font.TruncateString(&truncated, B_TRUNCATE_END, b.Width());

	DrawString(truncated.String(),
			   BPoint(b.left, floorf(center + fh.ascent / 2.0)));
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:51,代码来源:FontValueView.cpp

示例8: b

void
ShowImageStatusView::Draw(BRect updateRect)
{
	rgb_color darkShadow = tint_color(LowColor(), B_DARKEN_2_TINT);
	rgb_color shadow = tint_color(LowColor(), B_DARKEN_1_TINT);
	rgb_color light = tint_color(LowColor(), B_LIGHTEN_MAX_TINT);

	BRect b(Bounds());

	BeginLineArray(5);
		AddLine(BPoint(b.left, b.top),
				BPoint(b.right, b.top), darkShadow);
		b.top += 1.0;
		AddLine(BPoint(b.left, b.top),
				BPoint(b.right, b.top), light);
		AddLine(BPoint(b.right, b.top + 1.0),
				BPoint(b.right, b.bottom), shadow);
		AddLine(BPoint(b.right - 1.0, b.bottom),
				BPoint(b.left + 1.0, b.bottom), shadow);
		AddLine(BPoint(b.left, b.bottom),
				BPoint(b.left, b.top + 1.0), light);
	EndLineArray();

	b.InsetBy(1.0, 1.0);

	// Truncate and layout text
	BString truncated(fText);
	BFont font;
	GetFont(&font);
	font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, b.Width() - 4.0);
	font_height fh;
	font.GetHeight(&fh);

	FillRect(b, B_SOLID_LOW);
	SetDrawingMode(B_OP_OVER);
	DrawString(truncated.String(), BPoint(b.left + 2.0,
		floorf(b.top + b.Height() / 2.0 + fh.ascent / 2.0)));
}
开发者ID:DonCN,项目名称:haiku,代码行数:38,代码来源:ShowImageStatusView.cpp

示例9: rect

void
BButton::Draw(BRect updateRect)
{
	if (be_control_look != NULL) {
		BRect rect(Bounds());
		rgb_color background = LowColor();
		rgb_color base = background;
		uint32 flags = be_control_look->Flags(this);
		if (IsDefault())
			flags |= BControlLook::B_DEFAULT_BUTTON;
		be_control_look->DrawButtonFrame(this, rect, updateRect,
			base, background, flags);
		be_control_look->DrawButtonBackground(this, rect, updateRect,
			base, flags);

		// always leave some room around the label
		rect.InsetBy(3.0, 3.0);
		be_control_look->DrawLabel(this, Label(), rect, updateRect,
			base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
		return;
	}

	font_height fh;
	GetFontHeight(&fh);

	const BRect bounds = Bounds();
	BRect rect = bounds;

	const bool enabled = IsEnabled();
	const bool pushed = Value() == B_CONTROL_ON;
	// Default indicator
	if (IsDefault())
		rect = _DrawDefault(rect, enabled);

	BRect fillArea = rect;
	fillArea.InsetBy(3.0, 3.0);

	BString text = Label();

#if 1
	// Label truncation
	BFont font;
	GetFont(&font);
	font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4);
#endif

	// Label position
	const float stringWidth = StringWidth(text.String());
	const float x = (rect.right - stringWidth) / 2.0;
	const float labelY = bounds.top
		+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0)
		+ fh.ascent + 1.0;
	const float focusLineY = labelY + fh.descent;

	/* speed trick:
	   if the focus changes but the button is not pressed then we can
	   redraw only the focus line,
	   if the focus changes and the button is pressed invert the internal rect
	   this block takes care of all the focus changes
	*/
	if (IsFocusChanging()) {
		if (pushed) {
			rect.InsetBy(2.0, 2.0);
			InvertRect(rect);
		} else {
			_DrawFocusLine(x, focusLineY, stringWidth, IsFocus()
				&& Window()->IsActive());
		}

		return;
	}

	// colors
	rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
	rgb_color lightColor;
	rgb_color maxLightColor;

	rgb_color dark1BorderColor;
	rgb_color dark2BorderColor;

	rgb_color bevelColor1;
	rgb_color bevelColor2;
	rgb_color bevelColorRBCorner;

	rgb_color borderBevelShadow;
	rgb_color borderBevelLight;

	if (enabled) {
		lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
		maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);

		dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT);
		dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT);

		bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT);
		bevelColor2 = panelBgColor;

		if (IsDefault()) {
			borderBevelShadow = tint_color(dark1BorderColor,
//.........这里部分代码省略.........
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:101,代码来源:Button.cpp

示例10: background

void
BStatusBar::Draw(BRect updateRect)
{
    rgb_color backgroundColor = LowColor();

    font_height fontHeight;
    GetFontHeight(&fontHeight);
    BRect barFrame = _BarFrame(&fontHeight);
    BRect outerFrame = barFrame.InsetByCopy(-2, -2);

    BRegion background(updateRect);
    background.Exclude(outerFrame);
    FillRegion(&background, B_SOLID_LOW);

    // Draw labels/texts

    BRect rect = outerFrame;
    rect.top = 0;
    rect.bottom = outerFrame.top - 1;

    if (updateRect.Intersects(rect)) {
        // update labels
        BString leftText;
        leftText << fLabel << fText;

        BString rightText;
        rightText << fTrailingText << fTrailingLabel;

        float baseLine = ceilf(fontHeight.ascent) + 1;
        fTextDivider = rect.right;

        BFont font;
        GetFont(&font);

        if (rightText.Length()) {
            font.TruncateString(&rightText, B_TRUNCATE_BEGINNING,
                                rect.Width());
            fTextDivider -= StringWidth(rightText.String());
        }

        if (leftText.Length()) {
            float width = max_c(0.0, fTextDivider - rect.left);
            font.TruncateString(&leftText, B_TRUNCATE_END, width);
        }

        rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);

        if (backgroundColor != ui_color(B_PANEL_BACKGROUND_COLOR)) {
            if (backgroundColor.Brightness() > 100)
                textColor = make_color(0, 0, 0, 255);
            else
                textColor = make_color(255, 255, 255, 255);
        }

        SetHighColor(textColor);

        if (leftText.Length())
            DrawString(leftText.String(), BPoint(rect.left, baseLine));

        if (rightText.Length())
            DrawString(rightText.String(), BPoint(fTextDivider, baseLine));
    }

    // Draw bar

    if (!updateRect.Intersects(outerFrame))
        return;

    rect = outerFrame;

    if (be_control_look != NULL) {
        be_control_look->DrawStatusBar(this, rect, updateRect,
                                       backgroundColor, fBarColor, _BarPosition(barFrame));
        return;
    }

    // First bevel
    SetHighColor(tint_color(backgroundColor, B_DARKEN_1_TINT));
    StrokeLine(rect.LeftBottom(), rect.LeftTop());
    StrokeLine(rect.RightTop());

    SetHighColor(tint_color(backgroundColor, B_LIGHTEN_2_TINT));
    StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
    StrokeLine(BPoint(rect.right, rect.top + 1));

    rect.InsetBy(1, 1);

    // Second bevel
    SetHighColor(tint_color(backgroundColor, B_DARKEN_4_TINT));
    StrokeLine(rect.LeftBottom(), rect.LeftTop());
    StrokeLine(rect.RightTop());

    SetHighColor(backgroundColor);
    StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom());
    StrokeLine(BPoint(rect.right, rect.top + 1));

    rect = barFrame;
    rect.right = _BarPosition(barFrame);

    // draw bar itself
//.........这里部分代码省略.........
开发者ID:jessicah,项目名称:haiku-private,代码行数:101,代码来源:StatusBar.cpp

示例11: background

void
BStatusBar::Draw(BRect updateRect)
{
	rgb_color backgroundColor = LowColor();

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	BRect barFrame = _BarFrame(&fontHeight);
	BRect outerFrame = barFrame.InsetByCopy(-2, -2);

	BRegion background(updateRect);
	background.Exclude(outerFrame);
	FillRegion(&background, B_SOLID_LOW);

	// Draw labels/texts

	BRect rect = outerFrame;
	rect.top = 0;
	rect.bottom = outerFrame.top - 1;

	if (updateRect.Intersects(rect)) {
		// update labels
		BString leftText;
		leftText << fLabel << fText;

		BString rightText;
		rightText << fTrailingText << fTrailingLabel;

		float baseLine = ceilf(fontHeight.ascent) + 1;
		fTextDivider = rect.right;

		BFont font;
		GetFont(&font);

		if (rightText.Length()) {
			font.TruncateString(&rightText, B_TRUNCATE_BEGINNING,
				rect.Width());
			fTextDivider -= StringWidth(rightText.String());
		}

		if (leftText.Length()) {
			float width = max_c(0.0, fTextDivider - rect.left);
			font.TruncateString(&leftText, B_TRUNCATE_END, width);
		}

		rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);

		if (backgroundColor != ui_color(B_PANEL_BACKGROUND_COLOR)) {
			if (backgroundColor.Brightness() > 100)
				textColor = make_color(0, 0, 0, 255);
			else
				textColor = make_color(255, 255, 255, 255);
		}

		SetHighColor(textColor);

		if (leftText.Length())
			DrawString(leftText.String(), BPoint(rect.left, baseLine));

		if (rightText.Length())
			DrawString(rightText.String(), BPoint(fTextDivider, baseLine));
	}

	// Draw bar

	if (!updateRect.Intersects(outerFrame))
		return;

	rect = outerFrame;

	be_control_look->DrawStatusBar(this, rect, updateRect,
		backgroundColor, fBarColor, _BarPosition(barFrame));
}
开发者ID:looncraz,项目名称:haiku,代码行数:73,代码来源:StatusBar.cpp

示例12: if

float
PieView::_DrawDirectory(BRect b, FileInfo* info, float parentSpan,
	float beginAngle, int colorIdx, int level)
{
	if (b.Width() < 2.0 * (kPieCenterSize + level * kPieRingSize
		+ kPieOuterMargin + kPieInnerMargin)) {
		return 0.0;
	}

	if (info != NULL && info->color >= 0 && level == 0)
		colorIdx = info->color % kBasePieColorCount;
	else if (info != NULL)
		info->color = colorIdx;

	VolumeSnapshot* snapshot = fScanner->Snapshot();

	float cx = floorf(b.left + b.Width() / 2.0 + 0.5);
	float cy = floorf(b.top + b.Height() / 2.0 + 0.5);

	float mySpan;

	if (level == 0) {
		// Make room for mouse over info.
		fMouseOverInfo.clear();
		fMouseOverInfo[0] = SegmentList();

		// Draw the center circle.
		const char* displayName;
		if (info == NULL) {
			// NULL represents the entire volume.  Show used and free space in
			// the center circle, with the used segment representing the
			// volume's root directory.
			off_t volCapacity = snapshot->capacity;
			mySpan = 360.0 * (volCapacity - snapshot->freeBytes) / volCapacity;

			SetHighColor(kEmptySpcColor);
			FillEllipse(BPoint(cx, cy), kPieCenterSize, kPieCenterSize);

			SetHighColor(kBasePieColor[0]);
			FillArc(BPoint(cx, cy), kPieCenterSize, kPieCenterSize, 0.0,
				mySpan);

			// Show total volume capacity.
			char label[B_PATH_NAME_LENGTH];
			size_to_string(volCapacity, label, sizeof(label));
			SetHighColor(kPieBGColor);
			SetDrawingMode(B_OP_OVER);
			DrawString(label, BPoint(cx - StringWidth(label) / 2.0,
				cy + fFontHeight + kSmallVMargin));
			SetDrawingMode(B_OP_COPY);

			displayName = snapshot->name.c_str();

			// Record in-use space and free space for use during MouseMoved().
			info = snapshot->rootDir;
			info->color = colorIdx;
			fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info));
			if (mySpan < 360.0 - kMinSegmentSpan) {
				fMouseOverInfo[0].push_back(Segment(mySpan, 360.0,
					snapshot->freeSpace));
			}
		} else {
			// Show a normal directory.
			SetHighColor(kBasePieColor[colorIdx]);
			FillEllipse(BRect(cx - kPieCenterSize, cy - kPieCenterSize,
				cx + kPieCenterSize + 0.5, cy + kPieCenterSize + 0.5));
			displayName = info->ref.name;
			mySpan = 360.0;

			// Record the segment for use during MouseMoved().
			fMouseOverInfo[0].push_back(Segment(0.0, mySpan, info));
		}

		SetPenSize(1.0);
		SetHighColor(kOutlineColor);
		StrokeEllipse(BPoint(cx, cy), kPieCenterSize + 0.5,
			kPieCenterSize + 0.5);

		// Show the name of the volume or directory.
		BString label(displayName);
		BFont font;
		GetFont(&font);
		font.TruncateString(&label, B_TRUNCATE_END,
			2.0 * (kPieCenterSize - kSmallHMargin));
		float labelWidth = font.StringWidth(label.String());

		SetHighColor(kPieBGColor);
		SetDrawingMode(B_OP_OVER);
		DrawString(label.String(), BPoint(cx - labelWidth / 2.0, cy));
		SetDrawingMode(B_OP_COPY);
		beginAngle = 0.0;
	} else {
		// Draw an exterior segment.
		float parentSize;
		if (info->parent == NULL)
			parentSize = (float)snapshot->capacity;
		else
			parentSize = (float)info->parent->size;

		mySpan = parentSpan * (float)info->size / parentSize;
//.........这里部分代码省略.........
开发者ID:ysei,项目名称:haiku,代码行数:101,代码来源:PieView.cpp

示例13: r

// Draw
void
SplitManipulator::Draw(BView* into, BRect updateRect)
{
	if (fItemFrame.IsValid()) {
		into->SetDrawingMode(B_OP_COPY);
		into->SetHighColor(0, 0, 0, 255);
		BRect r(fItemFrame);
		into->StrokeRect(r);
		if (r.IntegerWidth() < 3)
			return;

		into->SetDrawingMode(B_OP_ALPHA);
		into->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);

		rgb_color base;
		if (ToolIsActive())
			base = (rgb_color){ 200, 200, 200, 220 };
		else {
			base = (rgb_color){ 230, 230, 230, 200 };
			if (fItem && fItem->IsSelected())
				base = tint_color(base, B_DARKEN_1_TINT);
		}

		into->SetHighColor(base);
		into->SetLowColor(base);

		rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
		rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);

		r = _UpperFrame();
		r.InsetBy(1, 1);

		into->BeginLineArray(3);
			into->AddLine(BPoint(r.left, r.bottom - 1),
						  BPoint(r.left, r.top), lighten2);
			into->AddLine(BPoint(r.left + 1, r.top),
						  BPoint(r.right - 1, r.top), lighten2);
			into->AddLine(BPoint(r.right, r.top),
						  BPoint(r.right, r.bottom - 1), darken2);
		into->EndLineArray();

		r.InsetBy(1, 1);
		into->FillRect(r);
		if (r.IntegerWidth() == 0)
			return;

		// clip name
		BString truncated(fItem->Name());
		BFont font;
		into->GetFont(&font);

		if (fItem->IsVideoMuted() || fItem->IsAudioMuted()) {
			// TODO: icons for displaying this info instead of font
			font.SetFace(B_ITALIC_FACE);
			into->SetFont(&font, B_FONT_FACE);
		}

		font.TruncateString(&truncated, B_TRUNCATE_END, r.Width() - 10.0);
		font_height fh;
		font.GetHeight(&fh);
		BPoint textPos;
		textPos.x = r.left + 5.0;
		textPos.y = (r.top + r.bottom + fh.ascent) / 2.0 - 1.0;

		into->SetHighColor(0, 0, 0, 200);
		into->DrawString(truncated.String(), textPos);

		// let the tool manipulator draw
		ToolDraw(into, r);

		// fill lower half for property display
		r.left = fItemFrame.left + 1;
		r.right = fItemFrame.right - 1;
		r.top = r.bottom + 1;
		r.bottom = fItemFrame.bottom - 1;

		if (ToolIsActive())
			base = (rgb_color){ 205, 205, 205, 220 };
		else {
			base = (rgb_color){ 235, 235, 235, 220 };
			if (fItem && fItem->IsSelected())
				base = tint_color(base, B_DARKEN_1_TINT);
		}

		into->SetHighColor(base);

		lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
		rgb_color darken1 = tint_color(base,
									   (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
		darken2 = tint_color(base, B_DARKEN_1_TINT);

		into->BeginLineArray(4);
			into->AddLine(BPoint(r.left, r.bottom),
						  BPoint(r.left, r.top + 1), lighten2);
			into->AddLine(BPoint(r.left, r.top),
						  BPoint(r.right - 1, r.top), darken1);
			into->AddLine(BPoint(r.right, r.top),
						  BPoint(r.right, r.bottom), darken2);
			into->AddLine(BPoint(r.right - 1, r.bottom),
//.........这里部分代码省略.........
开发者ID:stippi,项目名称:Clockwerk,代码行数:101,代码来源:SplitManipulator.cpp


注:本文中的BFont::TruncateString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。