Beispiel #1
0
int32_t
PListViewItemFrame(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();

	BRect outValue1;

	outValue1 = backend->ItemFrame(index);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();

	return B_OK;
}
Beispiel #2
0
void
InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);

	if (list == NULL)
		return;

	owner->PushState();

	BRect bounds = list->ItemFrame(list->IndexOf(this));

	//rgb_color highColor = list->HighColor();
	rgb_color lowColor = list->LowColor();

	if (IsSelected() || complete) {
		if (IsSelected()) {
			list->SetHighColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
			list->SetLowColor(list->HighColor());
		} else
			list->SetHighColor(lowColor);

		list->FillRect(bounds);
	}

	BString interfaceState;
	BBitmap* stateIcon(NULL);

	if (fSettings->IsDisabled()) {
		interfaceState << "disabled";
		stateIcon = fIconOffline;
	} else if (!fInterface.HasLink()) {
		interfaceState << "no link";
		stateIcon = fIconOffline;
	} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
		&& fSettings->IPAddr(AF_INET6).IsEmpty())
		&& (fSettings->AutoConfigure(AF_INET)
		|| fSettings->AutoConfigure(AF_INET6))) {
		interfaceState << "connecting" B_UTF8_ELLIPSIS;
		stateIcon = fIconPending;
	} else {
		interfaceState << "connected";
		stateIcon = fIconOnline;
	}

	// Set the initial bounds of item contents
	BPoint iconPt = bounds.LeftTop();
	BPoint namePt = bounds.LeftTop();
	BPoint line2Pt = bounds.LeftTop();
	BPoint line3Pt = bounds.LeftTop();
	BPoint statePt = bounds.RightTop();

	iconPt += BPoint(4, 4);
	statePt += BPoint(0, fFirstlineOffset);
	namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
	line2Pt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
	line3Pt += BPoint(ICON_SIZE + 12, fThirdlineOffset);

	statePt -= BPoint(
		be_plain_font->StringWidth(interfaceState.String()) + 4.0f, 0);

	if (fSettings->IsDisabled()) {
		list->SetDrawingMode(B_OP_ALPHA);
		list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
		list->SetHighColor(0, 0, 0, 32);
	} else
		list->SetDrawingMode(B_OP_OVER);

	list->DrawBitmapAsync(fIcon, iconPt);
	list->DrawBitmapAsync(stateIcon, iconPt);

	if (fSettings->IsDisabled()) {
		rgb_color textColor;
		if (IsSelected())
			textColor = ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR);
		else
			textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);

		if (textColor.red + textColor.green + textColor.blue > 128 * 3)
			list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT));
		else
			list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT));
	} else {
		if (IsSelected())
			list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
		else
			list->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
	}

	list->SetFont(be_bold_font);
	list->DrawString(Name(), namePt);
	list->SetFont(be_plain_font);
	list->DrawString(interfaceState, statePt);
	
	if (!fSettings->IsDisabled()) {
		// Render IPv4 Address
		BString ipv4Str(B_TRANSLATE_COMMENT("IP:", "IPv4 address label"));
		if (fSettings->IPAddr(AF_INET).IsEmpty())
			ipv4Str << " " << B_TRANSLATE("None");
		else
			ipv4Str << " " << BString(fSettings->IP(AF_INET));

		list->DrawString(ipv4Str, line2Pt);
	}
	
	// Render IPv6 Address (if present)
	if (!fSettings->IsDisabled()
		&& !fSettings->IPAddr(AF_INET6).IsEmpty()) {
		BString ipv6Str(B_TRANSLATE_COMMENT("IPv6:", "IPv6 address label"));
		ipv6Str << " " << BString(fSettings->IP(AF_INET6));

		list->DrawString(ipv6Str, line3Pt);
	}

	owner->PopState();
}
void
InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);

	if (!list)
		return;

	owner->PushState();

	BRect bounds = list->ItemFrame(list->IndexOf(this));

	rgb_color black = {0, 0, 0, 255};

	if (IsSelected() || complete) {
		if (IsSelected()) {
			list->SetHighColor(tint_color(list->ViewColor(),
				B_HIGHLIGHT_BACKGROUND_TINT));
		} else {
			list->SetHighColor(list->LowColor());
		}

		list->FillRect(bounds);
	}

	BString interfaceState;
	BBitmap* stateIcon(NULL);

	if (fSettings->IsDisabled()) {
		interfaceState << "disabled";
		stateIcon = fIconOffline;
	} else if (!fInterface.HasLink()) {
		interfaceState << "no link";
		stateIcon = fIconOffline;
	} else if ((fSettings->IPAddr(AF_INET).IsEmpty()
		&& fSettings->IPAddr(AF_INET6).IsEmpty())
		&& (fSettings->AutoConfigure(AF_INET)
		|| fSettings->AutoConfigure(AF_INET6))) {
		interfaceState << "connecting" B_UTF8_ELLIPSIS;
		stateIcon = fIconPending;
	} else {
		interfaceState << "connected";
		stateIcon = fIconOnline;
	}

	// Set the initial bounds of item contents
	BPoint iconPt = bounds.LeftTop();
	BPoint namePt = bounds.LeftTop();
	BPoint v4addrPt = bounds.LeftTop();
	BPoint v6addrPt = bounds.LeftTop();
	BPoint statePt = bounds.RightTop();

	iconPt += BPoint(4, 4);
	statePt += BPoint(0, fFirstlineOffset);
	namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset);
	v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset);
	v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset);

	statePt
		-= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0);

	if (fSettings->IsDisabled()) {
		list->SetDrawingMode(B_OP_ALPHA);
		list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
		list->SetHighColor(0, 0, 0, 32);
	} else
		list->SetDrawingMode(B_OP_OVER);

	list->DrawBitmapAsync(fIcon, iconPt);
	list->DrawBitmapAsync(stateIcon, iconPt);

	if (fSettings->IsDisabled())
		list->SetHighColor(tint_color(black, B_LIGHTEN_1_TINT));
	else
		list->SetHighColor(black);

	list->SetFont(be_bold_font);
	list->DrawString(Name(), namePt);
	list->SetFont(be_plain_font);

	list->DrawString(interfaceState, statePt);

	if (!fSettings->IsDisabled()) {
		// Render IPv4 Address
		BString v4str("IPv4: ");

		if (fSettings->IPAddr(AF_INET).IsEmpty())
			v4str << "none";
		else {
			v4str << fSettings->IP(AF_INET);
		}

		if (fSettings->AutoConfigure(AF_INET))
			v4str << " (DHCP)";
		else
			v4str << " (static)";

		list->DrawString(v4str.String(), v4addrPt);

		// Render IPv6 Address (if present)
		if (!fSettings->IPAddr(AF_INET6).IsEmpty()) {
			BString v6str("IPv6: ");
			v6str << fSettings->IP(AF_INET6);
			list->DrawString(v6str, v6addrPt);
		}
	}

	owner->PopState();
}
Beispiel #4
0
void
PrinterItem::DrawItem(BView *owner, BRect /*bounds*/, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);
	if (list == NULL)
		return;

	BFont font;
	owner->GetFont(&font);

	font_height height;
	font.GetHeight(&height);

	float fntheight = height.ascent + height.descent + height.leading;

	BRect bounds = list->ItemFrame(list->IndexOf(this));

	rgb_color color = owner->ViewColor();
	rgb_color oldLowColor = owner->LowColor();
	rgb_color oldHighColor = owner->HighColor();

	if (IsSelected())
		color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);

	owner->SetLowColor(color);
	owner->SetHighColor(color);

	owner->FillRect(bounds);

	owner->SetLowColor(oldLowColor);
	owner->SetHighColor(oldHighColor);

	float iconColumnWidth = B_LARGE_ICON + 8.0;
	float x = iconColumnWidth;
	BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0));
	BPoint namePt(iconPt + BPoint(x, fntheight));
	BPoint driverPt(iconPt + BPoint(x, fntheight * 2.0));
	BPoint defaultPt(iconPt + BPoint(x, fntheight * 3.0));
	BPoint transportPt(iconPt + BPoint(x, fntheight * 3.0));

	float totalWidth = bounds.Width() - iconColumnWidth;
	float maximumWidth = fLayoutData.fLeftColumnMaximumWidth +
		fLayoutData.fRightColumnMaximumWidth;
	float width;
	if (totalWidth < maximumWidth) {
		width = fLayoutData.fRightColumnMaximumWidth * totalWidth /
			maximumWidth;
	} else {
		width = fLayoutData.fRightColumnMaximumWidth;
	}

	BPoint pendingPt(bounds.right - width - 8.0, namePt.y);
	BPoint commentPt(bounds.right - width - 8.0, driverPt.y);


	drawing_mode mode = owner->DrawingMode();
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	owner->SetDrawingMode(B_OP_ALPHA);
#else
	owner->SetDrawingMode(B_OP_OVER);
#endif
	if (IsActivePrinter()) {
		if (sSelectedIcon && sSelectedIcon->IsValid())
			owner->DrawBitmap(sSelectedIcon, iconPt);
		else
			owner->DrawString(B_TRANSLATE("Default Printer"), defaultPt);
	} else {
		if (sIcon && sIcon->IsValid())
			owner->DrawBitmap(sIcon, iconPt);
	}

	owner->SetDrawingMode(B_OP_OVER);

	// left of item
	BString s = fName;
	owner->SetFont(be_bold_font);
	owner->TruncateString(&s, B_TRUNCATE_MIDDLE, pendingPt.x - namePt.x);
	owner->DrawString(s.String(), s.Length(), namePt);
	owner->SetFont(&font);

	s = B_TRANSLATE("Driver: %driver%");
	s.ReplaceFirst("%driver%", fDriverName);
	owner->TruncateString(&s, B_TRUNCATE_END, commentPt.x - driverPt.x);
	owner->DrawString(s.String(), s.Length(), driverPt);


	if (fTransport.Length() > 0) {
		s = B_TRANSLATE("Transport: %transport% %transport_address%");
		s.ReplaceFirst("%transport%", fTransport);
		s.ReplaceFirst("%transport_address%", fTransportAddress);
		owner->TruncateString(&s, B_TRUNCATE_BEGINNING, totalWidth);
		owner->DrawString(s.String(), s.Length(), transportPt);
	}

	// right of item
	s = fPendingJobs;
	owner->TruncateString(&s, B_TRUNCATE_END, bounds.Width() - pendingPt.x);
	owner->DrawString(s.String(), s.Length(), pendingPt);

	s = fComments;
	owner->TruncateString(&s, B_TRUNCATE_MIDDLE, bounds.Width() - commentPt.x);
	owner->DrawString(s.String(), s.Length(), commentPt);

	owner->SetDrawingMode(mode);
}
Beispiel #5
0
void
BackupListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);

	if (list == NULL)
		return;

	owner->PushState();

	BRect bounds = list->ItemFrame(list->IndexOf(this));

	rgb_color textColor = ui_color(B_LIST_ITEM_TEXT_COLOR);
	rgb_color backgroundColor = ui_color(B_LIST_BACKGROUND_COLOR);

	if (fIndex % 2)
		backgroundColor = (rgb_color){ 247, 247, 247, 255 };

	// draw background
	list->SetDrawingMode(B_OP_OVER);
	list->SetHighColor(backgroundColor);
	list->FillRect(bounds);

	// set proper colors for "normal" items
	list->SetHighColor(textColor);
	list->SetLowColor(backgroundColor);

	// Set up points for things in BListItem
	BPoint checkboxPt = bounds.LeftTop();
	BPoint namePt = bounds.LeftTop();
	BPoint descriptionPt = bounds.LeftTop();
	BPoint sizePt = bounds.RightTop();
	namePt += BPoint(16 + 8, fFirstlineOffset);
	sizePt += BPoint(0, fFirstlineOffset);
	descriptionPt += BPoint(16 + 8, fSecondlineOffset);
	checkboxPt += BPoint(4, 2);

	list->SetFont(be_bold_font);
	list->DrawString(fName.String(), namePt);

	char sizeText[512];
	size_to_string(fSize, sizeText, 512);
	BString sizeString(sizeText);

	list->SetFont(be_plain_font);
	sizePt -= BPoint(
		be_plain_font->StringWidth(sizeString.String()) + 4.0f, 0);

	list->DrawString(sizeString.String(), sizePt);

	if (textColor.red + textColor.green + textColor.blue > 128 * 3)
		list->SetHighColor(tint_color(textColor, B_DARKEN_1_TINT));
	else
		list->SetHighColor(tint_color(textColor, B_LIGHTEN_1_TINT));

	list->SetFontSize(11);
	list->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
	list->DrawString(fDescription.String(), descriptionPt);

	if (!fEnabled) {
		fEnabled = new BCheckBox(BRect(0, 0, 16, 16), fName.String(),
			fName.String(), new BMessage(kMsgUpdateSelection));
		list->AddChild(fEnabled);
		// First run, set default value
		fEnabled->SetValue(gLocationMap[fIndex].defaultValue
			? B_CONTROL_ON : B_CONTROL_OFF);
	}

	fEnabled->SetHighColor(textColor);
	fEnabled->SetLowColor(backgroundColor);
	fEnabled->MoveTo(checkboxPt.x, checkboxPt.y);

	owner->PopState();
}
Beispiel #6
0
void
JobItem::DrawItem(BView *owner, BRect, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);
	if (list) {
		BFont font;
		owner->GetFont(&font);

		font_height height;
		font.GetHeight(&height);
		float fntheight = height.ascent + height.descent + height.leading;

		BRect bounds = list->ItemFrame(list->IndexOf(this));

		rgb_color color = owner->ViewColor();
		rgb_color oldViewColor = color;
		rgb_color oldLowColor = owner->LowColor();
		rgb_color oldHighColor = owner->HighColor();

		if (IsSelected())
			color = tint_color(color, B_HIGHLIGHT_BACKGROUND_TINT);

		owner->SetViewColor(color);
		owner->SetHighColor(color);
		owner->SetLowColor(color);

		owner->FillRect(bounds);

		owner->SetLowColor(oldLowColor);
		owner->SetHighColor(oldHighColor);

		BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0));
		float iconHeight = B_MINI_ICON;
#ifdef ANTARES_TARGET_PLATFORM_ANTARES
		if (fIcon)
			iconHeight = fIcon->Bounds().Height();
#endif
		BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0));
		BPoint namePt(leftTop + BPoint(0.0, fntheight));
		BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0));

		float x = owner->StringWidth(fPages.String()) + 32.0;
		BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight));
		BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0));

		drawing_mode mode = owner->DrawingMode();
#ifdef ANTARES_TARGET_PLATFORM_ANTARES
	owner->SetDrawingMode(B_OP_ALPHA);
#else
	owner->SetDrawingMode(B_OP_OVER);
#endif

		if (fIcon)
			owner->DrawBitmap(fIcon, iconPt);

		// left of item
		owner->DrawString(fName.String(), fName.Length(), namePt);
		owner->DrawString(fStatus.String(), fStatus.Length(), statusPt);

		// right of item
		owner->DrawString(fPages.String(), fPages.Length(), pagePt);
		owner->DrawString(fSize.String(), fSize.Length(), sizePt);

		owner->SetDrawingMode(mode);
		owner->SetViewColor(oldViewColor);
	}
}
Beispiel #7
0
void
JobItem::DrawItem(BView *owner, BRect, bool complete)
{
	BListView* list = dynamic_cast<BListView*>(owner);
	if (list) {
		BFont font;
		owner->GetFont(&font);

		font_height height;
		font.GetHeight(&height);
		float fntheight = height.ascent + height.descent + height.leading;

		BRect bounds = list->ItemFrame(list->IndexOf(this));

		rgb_color color = owner->ViewColor();
		rgb_color oldLowColor = owner->LowColor();
		rgb_color oldHighColor = owner->HighColor();

		if (IsSelected())
			color = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);

		owner->SetHighColor(color);
		owner->SetLowColor(color);

		owner->FillRect(bounds);

		owner->SetLowColor(oldLowColor);
		owner->SetHighColor(oldHighColor);

		BPoint iconPt(bounds.LeftTop() + BPoint(2.0, 2.0));
		float iconHeight = B_MINI_ICON;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
		if (fIcon)
			iconHeight = fIcon->Bounds().Height();
#endif
		BPoint leftTop(bounds.LeftTop() + BPoint(12.0 + iconHeight, 2.0));
		BPoint namePt(leftTop + BPoint(0.0, fntheight));
		BPoint statusPt(leftTop + BPoint(0.0, fntheight * 2.0));

		float x = owner->StringWidth(fPages.String()) + 32.0;
		BPoint pagePt(bounds.RightTop() + BPoint(-x, fntheight));
		BPoint sizePt(bounds.RightTop() + BPoint(-x, fntheight * 2.0));

		drawing_mode mode = owner->DrawingMode();
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	owner->SetDrawingMode(B_OP_ALPHA);
#else
	owner->SetDrawingMode(B_OP_OVER);
#endif

		if (fIcon)
			owner->DrawBitmap(fIcon, iconPt);

		// left of item
		BString name = fName;
		owner->TruncateString(&name, B_TRUNCATE_MIDDLE, pagePt.x - namePt.x);
		owner->DrawString(name.String(), name.Length(), namePt);
		BString status = fStatus;
		owner->TruncateString(&status, B_TRUNCATE_MIDDLE, sizePt.x - statusPt.x);
		owner->DrawString(status.String(), status.Length(), statusPt);

		// right of item
		owner->DrawString(fPages.String(), fPages.Length(), pagePt);
		owner->DrawString(fSize.String(), fSize.Length(), sizePt);

		owner->SetDrawingMode(mode);
	}
}