Пример #1
0
// Draw
void
TestView::Draw(BRect updateRect)
{
//	DrawBitmap(BBitmap*, BRect source, BRect destination);
//
//  BeBook:
//  If a source rectangle is given, only that part of the
//  bitmap image is drawn. Otherwise, the entire bitmap
//  is placed in the view. The source rectangle is stated
//  in the internal coordinates of the BBitmap object.

// Test 1:
	// if the above was true, then we should see the left
	// top area of the bitmap...
//	BRect view(0, 0, 50, 50);
//	BRect bitmap = view.OffsetByCopy(fBitmap->Bounds().LeftTop());
//
//	DrawBitmap(fBitmap, bitmap, view);

// Test 2:
	// if the above was true, we should simply see the entire
	// bitmap at the left top corner of the view
	BRect bitmap = fBitmap->Bounds();
	BRect view = bitmap.OffsetToCopy(B_ORIGIN);

	DrawBitmap(fBitmap, bitmap, view);
}
Пример #2
0
// constructor
IconBar::IconBar(BRect frame, enum orientation orientation)
	: BView(frame, "icon bar", B_FOLLOW_NONE, /*B_FRAME_EVENTS |*/ B_WILL_DRAW),
	  fPreviousBounds(frame.OffsetToCopy(B_ORIGIN)),
	  fOrientation(orientation)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
Пример #3
0
void
BAbstractSpinner::_LayoutTextView()
{
	BRect rect;
	if (fLayoutData->text_view_layout_item != NULL) {
		rect = fLayoutData->text_view_layout_item->FrameInParent();
	} else {
		rect = Bounds();
		rect.left = fDivider;
	}
	rect.InsetBy(kFrameMargin, kFrameMargin);
	rect.right -= rect.Height() * 2 + kFrameMargin * 2 + 1.0f;

	fTextView->MoveTo(rect.left, rect.top);
	fTextView->ResizeTo(rect.Width(), rect.Height());
	fTextView->SetTextRect(rect.OffsetToCopy(B_ORIGIN));

	rect.InsetBy(0.0f, -kFrameMargin);

	rect.left = rect.right + kFrameMargin * 2;
	rect.right = rect.left + rect.Height() - kFrameMargin * 2;

	fDecrement->ResizeTo(rect.Width(), rect.Height());
	fDecrement->MoveTo(rect.LeftTop());

	rect.left = rect.right + 1.0f;
	rect.right = rect.left + rect.Height() - kFrameMargin * 2;

	fIncrement->ResizeTo(rect.Width(), rect.Height());
	fIncrement->MoveTo(rect.LeftTop());
}
Пример #4
0
void
Leaves::StartConfig(BView* view)
{
	BRect bounds = view->Bounds();
	bounds.InsetBy(10, 10);
	BRect frame(0, 0, bounds.Width(), 20);

	fDropRateSlider = new BSlider(frame, "drop rate",
		B_TRANSLATE("Drop rate:"), new BMessage(MSG_SET_DROP_RATE),
		kMinimumDropRate, kMaximumDropRate,	B_BLOCK_THUMB,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
	fDropRateSlider->SetValue(fDropRate);
	fDropRateSlider->ResizeToPreferred();
	bounds.bottom -= fDropRateSlider->Bounds().Height() * 1.5;
	fDropRateSlider->MoveTo(bounds.LeftBottom());
	view->AddChild(fDropRateSlider);

	fLeafSizeSlider = new BSlider(frame, "leaf size",
		B_TRANSLATE("Leaf size:"), new BMessage(MSG_SET_LEAF_SIZE),
		kMinimumLeafSize, kMaximumLeafSize,	B_BLOCK_THUMB,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
	fLeafSizeSlider->SetValue(fLeafSize);
	fLeafSizeSlider->ResizeToPreferred();
	bounds.bottom -= fLeafSizeSlider->Bounds().Height() * 1.5;
	fLeafSizeSlider->MoveTo(bounds.LeftBottom());
	view->AddChild(fLeafSizeSlider);

	fSizeVariationSlider = new BSlider(frame, "variation",
		B_TRANSLATE("Size variation:"),	new BMessage(MSG_SET_SIZE_VARIATION),
		0, kMaximumSizeVariation, B_BLOCK_THUMB,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
	fSizeVariationSlider->SetValue(fSizeVariation);
	fSizeVariationSlider->ResizeToPreferred();
	bounds.bottom -= fSizeVariationSlider->Bounds().Height() * 1.5;
	fSizeVariationSlider->MoveTo(bounds.LeftBottom());
	view->AddChild(fSizeVariationSlider);

	BTextView* textView = new BTextView(bounds, B_EMPTY_STRING,
		bounds.OffsetToCopy(0., 0.), B_FOLLOW_ALL, B_WILL_DRAW);
	textView->SetViewColor(view->ViewColor());
	BString name = B_TRANSLATE("Leaves");
	BString text = name;
	text << "\n\n";
	text << B_TRANSLATE("by Deyan Genovski, Geoffry Song");
	text << "\n\n";

	textView->Insert(text.String());
	textView->SetStylable(true);
	textView->SetFontAndColor(0, name.Length(), be_bold_font);
	textView->MakeEditable(false);
	view->AddChild(textView);

	BWindow* window = view->Window();
	if (window) window->AddHandler(this);

	fDropRateSlider->SetTarget(this);
	fLeafSizeSlider->SetTarget(this);
	fSizeVariationSlider->SetTarget(this);
}
Пример #5
0
void
RemoteDrawingEngine::DrawBitmap(ServerBitmap* bitmap, const BRect& _bitmapRect,
	const BRect& _viewRect, uint32 options)
{
	if (!fClippingRegion.Intersects(_viewRect))
		return;

	BRect viewRect = _viewRect;
	BRect bitmapRect = _bitmapRect;
	if (bitmapRect.IntegerWidth() == viewRect.IntegerWidth()
		&& bitmapRect.IntegerHeight() == viewRect.IntegerHeight()) {
		// unscaled bitmap we can chop off stuff we don't need
		BRegion target(viewRect);
		target.IntersectWith(&fClippingRegion);
		BRect frame = target.Frame();

		if (frame != viewRect) {
			BPoint offset = frame.LeftTop() - viewRect.LeftTop();
			viewRect = frame;
			bitmapRect = viewRect.OffsetToCopy(bitmapRect.LeftTop() + offset);
		}
	}

	UtilityBitmap* other = NULL;
	BRect bounds = bitmap->Bounds();
	BRect newBounds;
	newBounds.right
		= min_c(bounds.IntegerWidth(), bitmapRect.IntegerWidth());
	newBounds.bottom	
		= min_c(bounds.IntegerHeight(), bitmapRect.IntegerHeight());

	if (newBounds.IntegerWidth() < bounds.IntegerWidth()
		|| newBounds.IntegerHeight() < bounds.IntegerHeight()) {

		other = new(std::nothrow) UtilityBitmap(newBounds, bitmap->ColorSpace(),
			bitmap->Flags());

		if (other != NULL && other->ImportBits(bitmap->Bits(),
				bitmap->BitsLength(), bitmap->BytesPerRow(),
				bitmap->ColorSpace(), bitmapRect.LeftTop(), BPoint(0, 0),
				newBounds.IntegerWidth() + 1,
				newBounds.IntegerHeight() + 1) == B_OK) {
			bitmapRect.OffsetTo(0, 0);
			bitmap = other;
		}
	}

	// TODO: we may want to cache/checksum bitmaps
	RemoteMessage message(NULL, fHWInterface->SendBuffer());
	message.Start(RP_DRAW_BITMAP);
	message.Add(fToken);
	message.Add(bitmapRect);
	message.Add(viewRect);
	message.Add(options);
	message.AddBitmap(*bitmap);

	if (other != NULL)
		delete other;
}
Пример #6
0
//******************************************************************************************************
//**** TextEntryAlertTextEntryView
//******************************************************************************************************
TextEntryAlertTextEntryView::TextEntryAlertTextEntryView(BRect frame, bool multi_line)
: BTextView(frame,NULL,frame.OffsetToCopy(0,0).InsetByCopy(c_text_margin,c_text_margin),
	multi_line?B_FOLLOW_ALL_SIDES:B_FOLLOW_LEFT_RIGHT,B_WILL_DRAW|B_NAVIGABLE)
{
	m_tab_allowed = false;
	m_multi_line = multi_line;
	SetViewColor( ui_color( B_DOCUMENT_BACKGROUND_COLOR));
	SetWordWrap(true);
}
Пример #7
0
void
BPrintJob::_RecurseView(BView* view, BPoint origin, BPicture* picture,
	BRect rect)
{
	ASSERT(picture != NULL);

	BRegion region;
	region.Set(BRect(rect.left, rect.top, rect.right, rect.bottom));
	view->fState->print_rect = rect;

	view->AppendToPicture(picture);
	view->PushState();
	view->SetOrigin(origin);
	view->ConstrainClippingRegion(&region);

	if (view->ViewColor() != B_TRANSPARENT_COLOR) {
		rgb_color highColor = view->HighColor();
		view->SetHighColor(view->ViewColor());
		view->FillRect(rect);
		view->SetHighColor(highColor);
	}

	view->fIsPrinting = true;
	view->Draw(rect);
	view->fIsPrinting = false;

	view->PopState();
	view->EndPicture();

	BView* child = view->ChildAt(0);
	while (child != NULL) {
		if ((child->Flags() & B_WILL_DRAW) && !child->IsHidden()) {
			BPoint leftTop(view->Bounds().LeftTop() + child->Frame().LeftTop());
			BRect printRect(rect.OffsetToCopy(rect.LeftTop() - leftTop)
				& child->Bounds());
			if (printRect.IsValid())
				_RecurseView(child, origin + leftTop, picture, printRect);
		}
		child = child->NextSibling();
	}

	if ((view->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		view->AppendToPicture(picture);
		view->PushState();
		view->SetOrigin(origin);
		view->ConstrainClippingRegion(&region);
		view->fIsPrinting = true;
		view->DrawAfterChildren(rect);
		view->fIsPrinting = false;
		view->PopState();
		view->EndPicture();
	}
}
Пример #8
0
StringEditView::StringEditView(const BRect &frame)
  :	BView(frame, "edit", B_FOLLOW_ALL, B_WILL_DRAW)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	BRect r;
	
	float labelwidth = be_plain_font->StringWidth("ID: ");
	float strwidth = be_plain_font->StringWidth("(attr) ");
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	float strheight = fh.ascent + fh.descent + fh.leading + 5;
	
	fIDBox = new BTextControl(BRect(10, 10, 10 + (strwidth + labelwidth) + 15,
									10 + strheight),
							  "id", "ID: ", "", NULL);
	fIDBox->SetDivider(labelwidth + 5);
	AddChild(fIDBox);
	
	r = fIDBox->Frame();
	r.OffsetBy(r.Width() + 10, 0);
	r.right = Bounds().right - 10;
	fNameBox = new BTextControl(r, "name", "Name: ", "", NULL,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5);
	AddChild(fNameBox);
	
	r.OffsetBy(0, r.Height() + 10);
	r.left = 10;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	BRect textRect(r.OffsetToCopy(0.0, 0.0));
	textRect.InsetBy(5.0, 5.0);
	fValueView = new BTextView(r, "value", textRect, B_FOLLOW_ALL);
	
	BScrollView *scrollView = new BScrollView("scrollView", fValueView,
												B_FOLLOW_ALL, 0, false, true);
	AddChild(scrollView);
	
	fOK = new BButton(BRect(10, 10, 11, 11), "ok", "Cancel", new BMessage(M_UPDATE_RESOURCE),
					  B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fOK->ResizeToPreferred();
	fOK->SetLabel("OK");
	AddChild(fOK);
	
	fOK->MoveTo(r.right - fOK->Bounds().Width(), r.bottom + 10);
	r = fOK->Frame();
	r.OffsetBy(-r.Width() - 10, 0);
	fCancel = new BButton(r, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED),
					  B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	AddChild(fCancel);
}
Пример #9
0
TWindow::TWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace)
		: BWindow(frame, title, type, flags, workspace), quited(false)
{
//	SetBackgroundColor(0, 255, 255);

	BButton *btn = new BButton(BRect(10, 200, 40, 230), NULL, "Focus Button", new BMessage(BTN_FOCUS_MSG));
	AddChild(btn);
	btn->ResizeToPreferred();
	btn->MakeFocus(true);

	BView *view = new TView(frame.OffsetToCopy(B_ORIGIN), NULL, B_FOLLOW_ALL, B_WILL_DRAW |B_FRAME_EVENTS);
	AddChild(view);
}
Пример #10
0
BRect
CenterRectOnScreen(BRect source)
{
	BRect screenFrame = BScreen().Frame();

	BPoint leftTop((screenFrame.Width() + source.Width()) / 2.0,
		(screenFrame.Height() + source.Height()) / 2.0);

	if (leftTop.x < 0.0) leftTop.x = 0.0;
	if (leftTop.y < 0.0) leftTop.y = 0.0;

	return source.OffsetToCopy(leftTop);
}
Пример #11
0
StringInputWindow::StringInputWindow(const char *title, const char *text, BMessage msg,
									BMessenger target)
	:	DWindow(BRect(0,0,300,200),title,B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
		fMessage(msg),
		fMessenger(target)
{
	MakeCenteredOnShow(true);
	BView *top = GetBackgroundView();
	
	BRect r = Bounds().InsetByCopy(10,10);
	r.bottom = r.top + 10;
	BRect textRect = r.OffsetToCopy(0,0);
	textRect.InsetBy(10,10);
	fTextView = new BTextView(r,"paneltext",textRect,B_FOLLOW_LEFT | B_FOLLOW_TOP);
	top->AddChild(fTextView);
	fTextView->MakeEditable(false);
	fTextView->SetText(text);
	fTextView->ResizeTo(r.Width(), 20.0 + (fTextView->CountLines() * 
									fTextView->TextHeight(0,fTextView->TextLength())));
	fTextView->SetViewColor(top->ViewColor());
	
	fText = new BTextControl(BRect(10,10,11,11),"nametext","", "", new BMessage);
	top->AddChild(fText);
	fText->ResizeToPreferred();
	fText->ResizeTo(Bounds().Width() - 20,fText->Bounds().Height());
	fText->SetDivider(0.0);
	fText->MoveTo(10,fTextView->Frame().bottom + 10.0);
	
	r = fText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	BButton *cancel = new BButton(r,"cancel","Cancel",
									new BMessage(B_QUIT_REQUESTED));
	cancel->ResizeToPreferred();
	top->AddChild(cancel);
	
	ResizeTo(300, cancel->Frame().bottom + 10);
	cancel->MoveTo( Bounds().Width() - (cancel->Bounds().Width() * 2) - 20,
					cancel->Frame().top);
	
	r = cancel->Frame();
	r.OffsetBy(r.Width() + 10,0);
	BButton *open = new BButton(r,"ok","OK", new BMessage(M_INVOKE));
	top->AddChild(open);
	open->MakeDefault(true);
	fText->MakeFocus(true);
	
	open->MakeDefault(true);
}
Пример #12
0
/**
	Lays out items one after another.
*/
void AlbumView::Arrange(bool invalidate)
{
	// scale back the page relative to zoom ratio
	BRect bounds = Bounds();
	bounds.left /= fZoom;
	bounds.top /= fZoom;
	bounds.right /= fZoom;
	bounds.bottom /= fZoom;
	FlowLayout layout(bounds.OffsetToCopy(0,0), fColumns);
	layout.SetSpacing(1,1);
	// The entire set must be examined.
	float width = 0;
	float height = 0;
	AlbumItem *item;
	for (int32 i = 0; (item = ItemAt(i)); i++) {
		if (!IsItemVisible(item))
			continue;
		BRect frame0 = item->Frame();
		// separator
		uint32 hint = item->Flags() & ALBUMITEM_SEPARATOR ? LAYOUT_HINT_BREAK : 0;
		BRect frame = layout.Next(frame0, hint);
		if (hint == LAYOUT_HINT_BREAK) {
			// shift the last frame, so we get a gap in the layout
			layout.Last().OffsetBy(0,fSeparatorHeight);
			frame = layout.Last();
		}
		if (frame != frame0) {
			// rects outside the bounds are new
			if (invalidate && bounds.Intersects(frame0) && frame0.left >= 0) {
				// clear the old rect
				Invalidate(Adjust(frame0));				
			}
			// reposition to the new location
			item->SetFrame(frame);
			if (invalidate && bounds.Intersects(frame))  {
				// show on the new location
				Invalidate(Adjust(frame));
			}
		}
		if (frame.right > width)
			width = frame.right;
		if (frame.bottom > height)
			height = frame.bottom;
	}
	SetPageBounds(BRect(0,0,width,height));
}
Пример #13
0
ExpressionTextView::ExpressionTextView(BRect frame, CalcView* calcView)
	:
	InputTextView(frame, "expression text view",
		(frame.OffsetToCopy(B_ORIGIN)).InsetByCopy(2, 2),
		B_FOLLOW_NONE, B_WILL_DRAW),
	fCalcView(calcView),
	fKeypadLabels(""),
	fPreviousExpressions(20),
	fHistoryPos(0),
	fCurrentExpression(""),
	fCurrentValue(""),
	fChangesApplied(false)
{
	SetStylable(false);
	SetDoesUndo(true);
	SetColorSpace(B_RGB32);
	SetFontAndColor(be_bold_font, B_FONT_ALL);
}
Пример #14
0
MessageView::MessageView(BRect rect, DataEditor &editor)
	: TypeEditorView(rect, B_TRANSLATE("Message View"), B_FOLLOW_ALL, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	rect = Bounds().InsetByCopy(10, 10);
	rect.right -= B_V_SCROLL_BAR_WIDTH;
	rect.bottom -= B_H_SCROLL_BAR_HEIGHT;

	fTextView = new BTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(5, 5),
		B_FOLLOW_ALL, B_WILL_DRAW);
	fTextView->SetViewColor(ViewColor());
	fTextView->SetLowColor(ViewColor());

	BScrollView *scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, true, true);
	AddChild(scrollView);
}
Пример #15
0
StringEditor::StringEditor(BRect rect, DataEditor& editor)
	: TypeEditorView(rect, B_TRANSLATE("String editor"), B_FOLLOW_ALL, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BStringView *stringView = new BStringView(BRect(5, 5, rect.right, 20),
		B_EMPTY_STRING, B_TRANSLATE("Contents:"));
	stringView->ResizeToPreferred();
	AddChild(stringView);

	rect = Bounds();
	rect.top = stringView->Frame().bottom + 5;
	rect.right -= B_V_SCROLL_BAR_WIDTH;
	rect.bottom -= B_H_SCROLL_BAR_HEIGHT;

	fTextView = new BTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(5, 5),
		B_FOLLOW_ALL, B_WILL_DRAW);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, true, true);
	AddChild(scrollView);
}
Пример #16
0
 Layer(Layer* previous)
     : view(0)
     , bitmap(0)
     , clipping()
     , cippingSet(false)
     , globalAlpha(255)
     , currentShape(0)
     , clipShape(previous->clipShape ? new BShape(*previous->clipShape) : 0)
     , locationInParent(B_ORIGIN)
     , accumulatedOrigin(B_ORIGIN)
     , previous(previous)
 {
     BRegion parentClipping;
     previous->view->GetClippingRegion(&parentClipping);
     BRect frameInParent = parentClipping.Frame();
     if (!frameInParent.IsValid())
         frameInParent = previous->view->Bounds();
     BRect bounds = frameInParent.OffsetToCopy(B_ORIGIN);
     locationInParent += frameInParent.LeftTop();
     view = new BView(bounds, "WebCore transparency layer", 0, 0);
     bitmap = new BBitmap(bounds, B_RGBA32, true);
     bitmap->Lock();
     bitmap->AddChild(view);
     view->SetHighColor(0, 0, 0, 0);
     view->FillRect(view->Bounds());
     view->SetHighColor(previous->view->HighColor());
     view->SetDrawingMode(previous->view->DrawingMode());
     view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
     // TODO: locationInParent and accumulatedOrigin can
     // probably somehow be merged. But for now it works.
     accumulatedOrigin.x = -frameInParent.left;
     accumulatedOrigin.y = -frameInParent.top;
     view->SetOrigin(previous->accumulatedOrigin + accumulatedOrigin);
     view->SetScale(previous->view->Scale());
     view->SetPenSize(previous->view->PenSize());
 }
Пример #17
0
StyleView::StyleView(BRect frame)
	:
	BView("style view", 0),
	fCommandStack(NULL),
	fCurrentColor(NULL),
	fStyle(NULL),
	fGradient(NULL),
	fIgnoreCurrentColorNotifications(false),
	fIgnoreControlGradientNotifications(false),
	fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// style type
	BMenu* menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
	BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_COLOR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Color"), message));
	message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_GRADIENT);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Gradient"), message));

	BGridLayout* layout = new BGridLayout(5, 5);
	SetLayout(layout);

	fStyleType = new BMenuField(B_TRANSLATE("Style type"), menu);

	// gradient type
	menu = new BPopUpMenu(B_TRANSLATE("<unavailable>"));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_LINEAR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Linear"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CIRCULAR);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Radial"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_DIAMOND);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Diamond"), message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CONIC);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Conic"), message));

	fGradientType = new BMenuField(B_TRANSLATE("Gradient type"), menu);
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);

	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);

	layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
	layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);

	layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
	layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);

	layout->AddView(fGradientControl, 1, 3, 2);

	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);

	fStyleType->SetEnabled(false);
	fGradientType->SetEnabled(false);
	fGradientControl->SetEnabled(false);
	fGradientControl->Gradient()->AddObserver(this);
}
Пример #18
0
AboutWindow::AboutWindow (void)
	: BWindow (
			BRect (0.0, 0.0, 420.0, 266.0),
			"About Vision",
			B_TITLED_WINDOW,
			B_WILL_DRAW | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	/*
	 * Function purpose: Construct
	 */

	
	BRect bounds (Bounds());
	BBitmap *bmp (NULL);

	fBackground = new BView (
										 bounds,
										 "background",
										 B_FOLLOW_ALL_SIDES,
										 B_WILL_DRAW);
	fBackground->SetViewColor (255, 255, 255);
	AddChild (fBackground);


	if ((bmp = BTranslationUtils::GetBitmap ('bits', "vision")) != 0)
	{
		//BRect logo_bounds (bmp->Bounds());

		fLogo = new ClickView (
										bmp->Bounds().OffsetByCopy (16, 16),
										"image",
										B_FOLLOW_LEFT | B_FOLLOW_TOP,
										B_WILL_DRAW,
										"http://vision.sourceforge.net");
		fBackground->AddChild (fLogo);
		fLogo->SetViewBitmap (bmp);
		delete bmp;

		bounds.Set (
			0.0,
			fLogo->Frame().bottom + 12, 
			Bounds().right,
			Bounds().bottom);
	}

	fCredits = new BTextView (
									bounds,
									"credits",
									bounds.OffsetToCopy (B_ORIGIN).InsetByCopy (20, 0),
									B_FOLLOW_LEFT | B_FOLLOW_TOP,
									B_WILL_DRAW); 

	fCredits->MakeSelectable (false);
	fCredits->MakeEditable (false);
	fCredits->SetStylable (true);
	fCredits->SetAlignment (B_ALIGN_CENTER);
	fBackground->AddChild (fCredits);


	fCreditsText =
		"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
		"Unit A\n[Vision]\n"
		"{A-Z}\n"
		"Alan Ellis (voidref)\n"
		"Rene Gollent (AnEvilYak)\n"
		"Todd Lair (tlair)\n"
		"Wade Majors (kurros)\n\n\n\n"

		"\n\n\n\nUnit B\n[Bowser]\n"
		"{A-Z}\n"
		"Andrew Bazan (Hiisi)\n"
		"Rene Gollent (AnEvilYak)\n"
		"Todd Lair (tlair)\n"
		"Brian Luft (Electroly)\n"
		"Wade Majors (kurros)\n"
		"Jamie Wilkinson (project)\n\n\n\n"
	
		"\n\n\n\nBrought To You In Part By Contributions From\n"
		"{A-Z}\n"
		"Seth Flaxman (Flax)\n"
		"Joshua Jensen\n"
		"Gord McLeod (G_McLeod)\n"
		"John Robinson ([geo])\n"
		"Bjorn Oksholen (GuinnessM)\n"
		"Jean-Baptiste M. Quéru (jbq)\n"
		"\n\n\n"

		"\n\n\n\nUnit C\n[Support Crew]\n"
		"Assistant to Wade Majors: Patches\n"
		"Music Supervisor: Baron Arnold\n"
		"Assistant to Baron Arnold: Ficus Kirkpatrick\n"
		"Stunt Coordinator: Gilligan\n"
		"Nude Scenes: Natalie Portman\n"
		"Counselors: regurg and helix\n\n\n"
		"No animals were injured during the production of this IRC client\n\n\n"
		"Soundtrack available on Catastrophe Records\n\n\n\n"
		
		"\n\n\n\nSpecial Thanks\n\n"
		"Olathe\n"
		"Terminus\n"
		"Bob Maple\n"
		"Ted Stodgell\n"
		"Seth Flaxman\n"
		"David Aquilina\n"
		"Kurt von Finck\n"
		"Kristine Gouveia\n"
		"Jessica Tallon\n"
		"Be, Inc., Menlo Park, CA\n"
		"Pizza Hut, Winter Haven, FL (now give me that free pizza Mike)\n\n\n"
		
		"send all complaints and nipple pictures to kaye\n\n\n"

		"\n\n\n\n\n"
		"\"A human being should be able to change "
		"a diaper, plan an invasion, butcher a "
		"hog, conn a ship, design a building, "
		"write a sonnet, balance accounts, build "
		"a wall, set a bone, comfort the dying, "
		"take orders, give orders, cooperate, act "
		"alone, solve equations, analyze a new "
		"problem, pitch manure, program a com"
		"puter, cook a tasty meal, fight effi"
		"ciently, die gallantly. Specialization "
		"is for insects.\" -- Robert A. Heinlein"
	;

	rgb_color myBlack = {0,0,0,255};
	fTextRun.count					= 1;
	fTextRun.runs[0].offset = 0;
	fTextRun.runs[0].font	 = *be_fixed_font;
	fTextRun.runs[0].color	= myBlack;

	fCredits->Insert (fCreditsText, &fTextRun);

	// Center window
	BRect frame (BScreen().Frame());
	MoveTo (
		frame.Width()/2 - Frame().Width()/2,
		frame.Height()/2 - Frame().Height()/2);
	fScrollRunner = new BMessageRunner (BMessenger (this), new BMessage (M_ABOUT_SCROLL),
		 50000);
}
Пример #19
0
RemoteView::RemoteView(BRect frame, uint16 listenPort)
	:
	BView(frame, "RemoteView", B_FOLLOW_NONE, B_WILL_DRAW),
	fInitStatus(B_NO_INIT),
	fIsConnected(false),
	fReceiveBuffer(NULL),
	fSendBuffer(NULL),
	fReceiveEndpoint(NULL),
	fSendEndpoint(NULL),
	fReceiver(NULL),
	fSender(NULL),
	fStopThread(false),
	fOffscreenBitmap(NULL),
	fOffscreen(NULL),
	fViewCursor(kCursorData),
	fCursorBitmap(NULL),
	fCursorVisible(false)
{
	fReceiveBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
	if (fReceiveBuffer == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fInitStatus = fReceiveBuffer->InitCheck();
	if (fInitStatus != B_OK)
		return;

	fSendBuffer = new(std::nothrow) StreamingRingBuffer(16 * 1024);
	if (fSendBuffer == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fInitStatus = fSendBuffer->InitCheck();
	if (fInitStatus != B_OK)
		return;

	fReceiveEndpoint = new(std::nothrow) BNetEndpoint();
	if (fReceiveEndpoint == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fInitStatus = fReceiveEndpoint->Bind(listenPort);
	if (fInitStatus != B_OK)
		return;

	fReceiver = new(std::nothrow) NetReceiver(fReceiveEndpoint, fReceiveBuffer);
	if (fReceiver == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fSendEndpoint = new(std::nothrow) BNetEndpoint();
	if (fSendEndpoint == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fSender = new(std::nothrow) NetSender(fSendEndpoint, fSendBuffer);
	if (fSender == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	BRect bounds = frame.OffsetToCopy(0, 0);
	fOffscreenBitmap = new(std::nothrow) BBitmap(bounds, B_BITMAP_ACCEPTS_VIEWS,
		B_RGB32);
	if (fOffscreenBitmap == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fOffscreen = new(std::nothrow) BView(bounds, "offscreen remote view",
		B_FOLLOW_NONE, B_WILL_DRAW);
	if (fOffscreen == NULL) {
		fInitStatus = B_NO_MEMORY;
		return;
	}

	fOffscreenBitmap->AddChild(fOffscreen);
	fOffscreen->SetDrawingMode(B_OP_COPY);

	fDrawThread = spawn_thread(&_DrawEntry, "draw thread", B_NORMAL_PRIORITY,
		this);
	if (fDrawThread < 0) {
		fInitStatus = fDrawThread;
		return;
	}

	resume_thread(fDrawThread);
}
Пример #20
0
// When this is running, no member variable should be accessed
// from other threads
status_t
MovieEncoder::_EncoderThread()
{	
	int32 framesLeft = fFileList->CountItems();
	int32 framesWritten = 0;
	
	if (framesLeft <= 0) {
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)B_ERROR);
		fMessenger.SendMessage(&message);
		return B_ERROR;
	}
	
	// Create movie
	entry_ref movieRef;
	get_ref_for_path(fOutputFile.Path(), &movieRef);
		
	BitmapEntry* entry = fFileList->ItemAt(0);
	BBitmap* bitmap = entry->Bitmap();
	BRect sourceFrame = bitmap->Bounds();
	delete bitmap;
		
	if (!fDestFrame.IsValid())
		fDestFrame = sourceFrame.OffsetToCopy(B_ORIGIN);
	
	// Calc the average time difference between the first 100 frames,
	// and use it to calculate the framerate.
	// TODO: Actually we could just calculate the number of frames and
	// the time difference between the first and the last one.
	/*int32 maxTimeStampNum = std::min((int32)100, fFileList->CountItems());	
	bigtime_t previousFrameTime = entry->TimeStamp();
	bigtime_t diffSum = 0;
	for (int32 i = 0; i < maxTimeStampNum; i++) {
		BitmapEntry* entry = fFileList->ItemAt(i);
		bigtime_t currentFrameTime = entry->TimeStamp();
		diffSum += currentFrameTime - previousFrameTime;		
		previousFrameTime = currentFrameTime;
	}
	
	float medianDiffTime = diffSum / maxTimeStampNum;
	*/
	int32 numFrames = fFileList->CountItems();
	BitmapEntry* firstEntry = fFileList->ItemAt(0);
	BitmapEntry* lastEntry = fFileList->ItemAt(numFrames - 1);
	int frameSeconds = (1000000 * numFrames) / (lastEntry->TimeStamp() - firstEntry->TimeStamp());
	media_format inputFormat = fFormat;
	inputFormat.u.raw_video.field_rate = frameSeconds;
	
	status_t status = _CreateFile(movieRef, fFileFormat, inputFormat, fCodecInfo);
	if (status < B_OK) {
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)status);
		fMessenger.SendMessage(&message);		
		return status;
	}
		
	// Bitmap and view used to convert the source bitmap
	// to the correct size and depth	
	BBitmap* destBitmap = new BBitmap(fDestFrame, fColorSpace, true);
	BView* destDrawer = new BView(fDestFrame, "drawing view", B_FOLLOW_NONE, 0);
	if (destBitmap->Lock()) {
		destBitmap->AddChild(destDrawer);
		destBitmap->Unlock();
	}
	
	const uint32 keyFrameFrequency = 10;
		// TODO: Make this tunable
	
	BMessage progressMessage(B_UPDATE_STATUS_BAR);
	progressMessage.AddFloat("delta", 1.0);
	
	destBitmap->Bounds().PrintToStream();
	PrintMediaFormat(inputFormat);
	
	status = B_OK;
	while (BitmapEntry* entry = const_cast<FileList*>(fFileList)->Pop()) {
		if (fKillThread)
			break;
	
		bool keyFrame = (framesWritten % keyFrameFrequency == 0);
		BBitmap* frame = entry->Bitmap();
		if (frame == NULL) {
			// TODO: What to do here ? Exit with an error ?
			std::cerr << "Error while loading bitmap entry" << std::endl;
			delete entry;
			continue;
		}
						
		// Draw scaled
		if (status == B_OK) {
			destBitmap->Lock();
			destDrawer->DrawBitmap(frame, frame->Bounds(), destDrawer->Bounds());
			destDrawer->Sync();
			destBitmap->Unlock();
		}
		
		delete frame;
		delete entry;
			
		if (status == B_OK)
			status = _WriteFrame(destBitmap, keyFrame);
		
		if (status != B_OK)
			break;

		framesWritten++;

		if (fMessenger.IsValid())
			fMessenger.SendMessage(new BMessage(progressMessage));
		else {
			// BMessenger is no longer valid. This means that the application
			// has been closed or it has crashed.
			break;
		}
	}

	delete destBitmap;
	
	DisposeData();
	
	if (fMessenger.IsValid()) {
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)status);
		message.AddInt32("frames", (int32)framesWritten);
		fMessenger.SendMessage(&message);
	}
		
	return status;
}
Пример #21
0
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target,
		const BMessage* settings)
	: BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0);
	view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(view);

	int8 mode = kAsciiMode;
	if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
		settings->FindInt8("find_mode", &mode);

	// add the top widgets

	fMenu = new BPopUpMenu("mode");
	BMessage* message;
	BMenuItem* item;
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"),
		message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kAsciiMode);
	if (mode == kAsciiMode)
		item->SetMarked(true);
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", 
		"A menu item, as short as possible, noun is recommended if it is "
		"shorter than adjective."), message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kHexMode);
	if (mode == kHexMode)
		item->SetMarked(true);

	BRect rect = Bounds().InsetByCopy(5, 5);
	BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING,
		B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	view->AddChild(menuField);

	// add the bottom widgets

	BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"),
		new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->MoveTo(rect.right - button->Bounds().Width(),
		rect.bottom - button->Bounds().Height());
	view->AddChild(button);

	fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"),
		NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fCaseCheckBox->ResizeToPreferred();
	fCaseCheckBox->MoveTo(5, button->Frame().top);
	bool caseSensitive;
	if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
		if (settings == NULL
			|| settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
			caseSensitive = true;
	}
	fCaseCheckBox->SetValue(caseSensitive);
	view->AddChild(fCaseCheckBox);

	// and now those inbetween

	rect.top = menuField->Frame().bottom + 5;
	rect.bottom = fCaseCheckBox->Frame().top - 8;
	rect.InsetBy(2, 2);
	fTextView = new FindTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL);
	fTextView->SetWordWrap(true);
	fTextView->SetMode((find_mode)mode);
	fTextView->SetData(previous);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, false, false);
	view->AddChild(scrollView);

	ResizeTo(290, button->Frame().Height() * 3 + 30);

	SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width()
			+ 20, 32768, button->Frame().Height() * 3 + 10, 32768);
}
Пример #22
0
void
SLoadingModulesView::ReGetBitmap()
{
	BWindow *window = Window();
	if(!window) return;

	bool is_hidden = window->IsHidden();

	if(!is_hidden) window->Hide();

	BScreen screen(window);
	BBitmap *screen_bitmap = NULL;
	BRect rect = screen.Frame().OffsetToCopy(B_ORIGIN);
	if(screen.GetBitmap(&screen_bitmap, false, &rect) == B_OK)
	{
		if(screen_bitmap)
		{
			if(bitmap) delete bitmap;
			rect = ConvertToScreen(Bounds());
			bitmap = new BBitmap(rect.OffsetToCopy(B_ORIGIN), B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
			if(bitmap)
			{
				SAutolock<BBitmap> autolock(bitmap);
				BView *bitmap_view = new BView(bitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
				bitmap->AddChild(bitmap_view);
				bitmap_view->PushState();
				bitmap_view->SetDrawingMode(B_OP_COPY);
				bitmap_view->DrawBitmap(screen_bitmap, rect, rect.OffsetToCopy(B_ORIGIN));
				bitmap_view->SetDrawingMode(B_OP_ALPHA);

				BPoint circle_center;
				float circle_radius = bitmap->Bounds().Height() / 2;
				circle_center.x = bitmap->Bounds().left + circle_radius;
				circle_center.y = bitmap->Bounds().top + circle_radius;
				
				bitmap_view->SetHighColor(ViewColor());
				bitmap_view->FillArc(circle_center, circle_radius, circle_radius, 0, 360);
				bitmap_view->SetHighColor(220, 220, 220, 150);
				bitmap_view->StrokeArc(circle_center, circle_radius, circle_radius, 45, 180);
				bitmap_view->SetHighColor(20, 20, 20, 150);
				bitmap_view->StrokeArc(circle_center, circle_radius, circle_radius, 225, 180);

				BRect rect = bitmap->Bounds();
				rect.left = circle_center.x;
				rect.InsetBy(0, 5);

				bitmap_view->SetHighColor(ViewColor());
				bitmap_view->FillRoundRect(rect, 3, 3);
				bitmap_view->SetHighColor(220, 220, 220, 150);
				bitmap_view->StrokeRoundRect(rect, 3, 3);
				bitmap_view->SetHighColor(20, 20, 20, 150);
				rect.left += 1; rect.top += 1;
				bitmap_view->StrokeRoundRect(rect, 3, 3);
				rect.right -= 1; rect.bottom -= 1;
				bitmap_view->SetHighColor(ViewColor());
				bitmap_view->FillArc(circle_center, circle_radius - 1, circle_radius - 1, 0, 360);
				bitmap_view->FillRoundRect(rect, 3, 3);

				bitmap_view->PopState();
				bitmap_view->Sync();
			}
			delete screen_bitmap;
		}
	}

	if(!is_hidden) window->Show();
}
Пример #23
0
status_t
MovieEncoder::Encode()
{	
	int32 framesLeft = fFileList->CountItems();
	int32 framesWritten = 0;
	
	if (framesLeft <= 0) {
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)B_ERROR);
		fMessenger.SendMessage(&message);
		return B_ERROR;
	}
	
	// Create movie
	char movieName[B_FILE_NAME_LENGTH];
	MakeUniqueName(fOutputFile.Path(), movieName, B_FILE_NAME_LENGTH);
	entry_ref movieRef;
	get_ref_for_path(movieName, &movieRef);
	
	BBitmap* bitmap = BTranslationUtils::GetBitmapFile(fFileList->ItemAt(0));
	BRect sourceFrame = bitmap->Bounds();
	delete bitmap;
		
	if (!fDestFrame.IsValid())
		fDestFrame = sourceFrame.OffsetToCopy(B_ORIGIN);
				
	BitmapMovie* movie = new BitmapMovie(fDestFrame.IntegerWidth() + 1,
					fDestFrame.IntegerHeight() + 1, fColorSpace);
				
	status_t status = movie->CreateFile(movieRef, fFileFormat, fFormat, fCodecInfo);
	if (status < B_OK) {
		delete movie;
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)status);
		fMessenger.SendMessage(&message);		
		return status;
	}
		
	// Bitmap and view used to convert the source bitmap
	// to the correct size and depth	
	BBitmap* destBitmap = new BBitmap(fDestFrame, fColorSpace, true);
	BView* destDrawer = new BView(fDestFrame, "drawing view", B_FOLLOW_NONE, 0);
	if (destBitmap->Lock()) {
		destBitmap->AddChild(destDrawer);
		destBitmap->Unlock();
	}
	
	const uint32 keyFrameFrequency = 10;
		// TODO: Make this tunable
	
	BMessage progressMessage(B_UPDATE_STATUS_BAR);
	progressMessage.AddFloat("delta", 1.0);
	
	status = B_OK;
	for (int32 i = 0; i < fFileList->CountItems(); i++) {
		bool keyFrame = (framesWritten % keyFrameFrequency == 0);
		const char* fileName = fFileList->ItemAt(i);
		BBitmap* frame = BTranslationUtils::GetBitmapFile(fileName);
		if (frame == NULL) {
			// TODO: What to do here ? Exit with an error ?
			continue;
		}
						
		// Draw scaled
		if (status == B_OK) {
			destBitmap->Lock();
			destDrawer->DrawBitmap(frame, frame->Bounds(), destDrawer->Bounds());
			destDrawer->Sync();
			destBitmap->Unlock();
		}
		
		delete frame;
			
		if (status == B_OK)
			status = movie->WriteFrame(destBitmap, keyFrame);
		
		if (status != B_OK)
			break;

		framesWritten++;

		if (fMessenger.IsValid())
			fMessenger.SendMessage(new BMessage(progressMessage));		
	}

	delete movie;
	delete destBitmap;
	
	DisposeData();
	
	if (fMessenger.IsValid()) {
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)status);
		message.AddInt32("frames", (int32)framesWritten);
		fMessenger.SendMessage(&message);
	}
		
	return status;
}
Пример #24
0
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
	: BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
		"Application Type", B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
	fChangedProperties(0)
{
	// add the menu

	BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
	fSaveMenuItem->SetEnabled(false);
	menu->AddItem(fSaveMenuItem);
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
		NULL));
	item->SetEnabled(false);

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
		'W', B_COMMAND_KEY));
	menuBar->AddItem(menu);

	// Top view and signature

	BRect rect = Bounds();
	rect.top = menuBar->Bounds().Height() + 1.0f;
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
	fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
		new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
	fSignatureControl->SetModificationMessage(
		new BMessage(kMsgSignatureChanged));
	fSignatureControl->SetDivider(fSignatureControl->StringWidth(
		fSignatureControl->Label()) + 4.0f);
	float width, height;
	fSignatureControl->GetPreferredSize(&width, &height);
	fSignatureControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fSignatureControl);

	// filter out invalid characters that can't be part of a MIME type name
	BTextView* textView = fSignatureControl->TextView();
	textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
	const char* disallowedCharacters = "<>@,;:\"()[]?=";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	// "Application Flags" group

	BFont font(be_bold_font);
	font_height fontHeight;
	font.GetHeight(&fontHeight);

	width = font.StringWidth("Icon") + 16.0f;
	if (width < B_LARGE_ICON + 16.0f)
		width = B_LARGE_ICON + 16.0f;

	rect.top = fSignatureControl->Frame().bottom + 4.0f;
	rect.bottom = rect.top + 100.0f;
	rect.right -= width + 8.0f;
	BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	topView->AddChild(box);

	fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
		new BMessage(kMsgToggleAppFlags));
	fFlagsCheckBox->SetValue(B_CONTROL_ON);
	fFlagsCheckBox->ResizeToPreferred();
	box->SetLabel(fFlagsCheckBox);

	rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
	fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
		new BMessage(kMsgAppFlagsChanged));
	fSingleLaunchButton->ResizeToPreferred();
	box->AddChild(fSingleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fMultipleLaunchButton = new BRadioButton(rect, "multiple",
		"Multiple launch", new BMessage(kMsgAppFlagsChanged));
	fMultipleLaunchButton->ResizeToPreferred();
	box->AddChild(fMultipleLaunchButton);

	rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
	fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
		"Exclusive launch", new BMessage(kMsgAppFlagsChanged));
	fExclusiveLaunchButton->ResizeToPreferred();
	box->AddChild(fExclusiveLaunchButton);

	rect.top = fSingleLaunchButton->Frame().top;
	rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
	fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
		new BMessage(kMsgAppFlagsChanged));
	fArgsOnlyCheckBox->ResizeToPreferred();
	box->AddChild(fArgsOnlyCheckBox);

	rect.top += fArgsOnlyCheckBox->Bounds().Height();
	fBackgroundAppCheckBox = new BCheckBox(rect, "background",
		"Background app", new BMessage(kMsgAppFlagsChanged));
	fBackgroundAppCheckBox->ResizeToPreferred();
	box->AddChild(fBackgroundAppCheckBox);

	box->ResizeTo(box->Bounds().Width(),
		fExclusiveLaunchButton->Frame().bottom + 8.0f);

	// "Icon" group

	rect = box->Frame();
#ifdef __ANTARES__
	rect.top += box->TopBorderOffset();
#endif
	rect.left = rect.right + 8.0f;
	rect.right += width + 8.0f;
	float iconBoxWidth = rect.Width();
	box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	box->SetLabel("Icon");
#ifdef __ANTARES__
	box->MoveBy(0.0f, -box->TopBorderOffset());
	box->ResizeBy(0.0f, box->TopBorderOffset());
#endif
	topView->AddChild(box);

	rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f);
#ifdef __ANTARES__
	rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset()
		- rect.Height()) / 2.0f);
#else
	rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f);
#endif
	if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f)
		rect.top = fontHeight.ascent + fontHeight.descent + 4.0f;
	fIconView = new IconView(rect, "icon");
	fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
	box->AddChild(fIconView);

	// "Supported Types" group

	rect.top = box->Frame().bottom + 8.0f;
	rect.bottom = rect.top + box->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	typeBox->SetLabel("Supported types");
	topView->AddChild(typeBox);

	rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f);
	rect.top += ceilf(fontHeight.ascent);
	fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddType), B_FOLLOW_RIGHT);
	fAddTypeButton->ResizeToPreferred();
	fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width()
		- B_LARGE_ICON - 16.0f, 0.0f);
	typeBox->AddChild(fAddTypeButton);

	rect = fAddTypeButton->Frame();
	rect.OffsetBy(0, rect.Height() + 4.0f);
	fRemoveTypeButton = new BButton(rect, "remove type", "Remove",
		new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT);
	typeBox->AddChild(fRemoveTypeButton);

	rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.left = 10.0f;
	rect.top = 8.0f + ceilf(fontHeight.ascent);
	rect.bottom -= 2.0f;
		// take scrollview border into account
	fTypeListView = new SupportedTypeListView(rect, "type listview",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
		B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f);
	typeBox->AddChild(scrollView);

	rect.left = fRemoveTypeButton->Frame().right + 8.0f;
#ifdef __ANTARES__
	rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f;
#else
	rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f;
#endif
	rect.right = rect.left + B_LARGE_ICON - 1.0f;
	rect.bottom = rect.top + B_LARGE_ICON - 1.0f;
	fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged));
	typeBox->AddChild(fTypeIconView);

	// "Version Info" group

	rect.top = typeBox->Frame().bottom + 8.0f;
	rect.bottom = rect.top + typeBox->Bounds().Height();
	rect.left = 8.0f;
	rect.right = Bounds().Width() - 8.0f;
	box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
		// the resizing mode will later also be set to B_FOLLOW_BOTTOM
	box->SetLabel("Version info");
	topView->AddChild(box);

	BMenuField* menuField;
#if 0
	BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true);
	item = new BMenuItem("Version Info", NULL);
	item->SetMarked(true);
	popUpMenu->AddItem(item);
	item = new BMenuItem("System Version Info", NULL);
	popUpMenu->AddItem(item);

	menuField = new BMenuField(BRect(0, 0, 100, 15),
		"version kind", NULL, popUpMenu, true);
	menuField->ResizeToPreferred();
	box->SetLabel(menuField);
#endif

	rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent);
	rect.bottom = rect.top + height;
	fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL,
		NULL);
	fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth(
		fMajorVersionControl->Label()) + 4.0f);
	fMajorVersionControl->GetPreferredSize(&width, &height);
	width = 12.0f + fMajorVersionControl->StringWidth("99");
	fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMajorVersionControl);
	box->AddChild(fMajorVersionControl);

	rect.left = fMajorVersionControl->Frame().right + 1.0f;
	fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth(
		fMiddleVersionControl->Label()) + 4.0f);
	fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMiddleVersionControl);
	box->AddChild(fMiddleVersionControl);

	rect.left = fMiddleVersionControl->Frame().right + 1.0f;
	fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL,
		NULL);
	fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth(
		fMinorVersionControl->Label()) + 4.0f);
	fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height);
	_MakeNumberTextControl(fMinorVersionControl);
	box->AddChild(fMinorVersionControl);

	fVarietyMenu = new BPopUpMenu("variety", true, true);
	fVarietyMenu->AddItem(new BMenuItem("Development", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Beta", NULL));
	fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL));
	fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL));
	item->SetMarked(true);
	fVarietyMenu->AddItem(new BMenuItem("Final", NULL));

	rect.top--;
		// BMenuField oddity
	rect.left = fMinorVersionControl->Frame().right + 6.0f;
	menuField = new BMenuField(rect,
		"variety", NULL, fVarietyMenu, true);
	menuField->ResizeToPreferred();
	box->AddChild(menuField);

	rect.top++;
	rect.left = menuField->Frame().right;
	rect.right = rect.left + 30.0f;	
	fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL,
		NULL);
	fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth(
		fInternalVersionControl->Label()) + 4.0f);
	fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height);
	box->AddChild(fInternalVersionControl);

	rect = box->Bounds().InsetByCopy(8.0f, 0.0f);
	rect.top = fInternalVersionControl->Frame().bottom + 8.0f;
	fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:",
		NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	float labelWidth = fShortDescriptionControl->StringWidth(
		fShortDescriptionControl->Label()) + 4.0f;
	fShortDescriptionControl->SetDivider(labelWidth);
	fShortDescriptionControl->GetPreferredSize(&width, &height);
	fShortDescriptionControl->ResizeTo(rect.Width(), height);

	// TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says?
	version_info versionInfo;
	fShortDescriptionControl->TextView()->SetMaxBytes(sizeof(versionInfo.short_info));
	box->AddChild(fShortDescriptionControl);

	rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f);
	rect.right = rect.left + labelWidth;
	StringView* label = new StringView(rect, NULL, "Long description:", NULL);
	label->SetDivider(labelWidth);
	box->AddChild(label);

	rect.left = rect.right + 3.0f;
	rect.top += 1.0f;
	rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH;
	rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f;
	fLongDescriptionView = new TabFilteringTextView(rect, "long desc",
		rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
		| B_NAVIGABLE);
	fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));

	scrollView = new BScrollView("desc scrollview", fLongDescriptionView,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f);
	box->AddChild(scrollView);

	// Adjust window size and limits

	width = fInternalVersionControl->Frame().right + 16.0f;
	float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f;
	if (width > minWidth)
		minWidth = width;

	ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth,
		box->Frame().bottom + topView->Frame().top + 8.0f);
	SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f);
	typeBox->SetResizingMode(B_FOLLOW_ALL);
	box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);

	fSignatureControl->MakeFocus(true);

	BMimeType::StartWatching(this);
	_SetTo(entry);
}
Пример #25
0
status_t
MovieEncoder::Encode()
{
	int32 framesLeft = fFileList->CountItems();
	int32 framesWritten = 0;
	
	if (framesLeft <= 0) {
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)B_ERROR);
		fMessenger.SendMessage(&message);
		return B_ERROR;
	}
	
	// Create movie
	char movieName[B_FILE_NAME_LENGTH];
	MakeUniqueName(fOutputFile.Path(), movieName, B_FILE_NAME_LENGTH);
	entry_ref movieRef;
	get_ref_for_path(movieName, &movieRef);
	
	media_file_format fileFormat;
	if (!GetMediaFileFormat(fFamily, fileFormat)) {
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)B_ERROR);
		fMessenger.SendMessage(&message);
		return B_ERROR;
	}
	
	BBitmap* bitmap = BTranslationUtils::GetBitmapFile(fFileList->ItemAt(0));
	BRect sourceFrame = bitmap->Bounds();
	delete bitmap;
		
	if (!fDestFrame.IsValid())
		fDestFrame = sourceFrame.OffsetToCopy(B_ORIGIN);
				
	BitmapMovie* movie = new BitmapMovie(fDestFrame.IntegerWidth() + 1,
					fDestFrame.IntegerHeight() + 1, fColorSpace);
				
	status_t error = movie->CreateFile(movieRef, fileFormat, fFormat, fCodecInfo);
	if (error < B_OK) {
		delete movie;
		DisposeData();
		BMessage message(kEncodingFinished);
		message.AddInt32("status", (int32)error);
		fMessenger.SendMessage(&message);		
		return error;
	}
		
	// Bitmap and view used to convert the source bitmap
	// to the correct size and depth	
	BBitmap* destBitmap = new BBitmap(fDestFrame, fColorSpace, true);
	BView* destDrawer = new BView(fDestFrame, "drawing view", B_FOLLOW_NONE, 0);
	if (destBitmap->Lock()) {
		destBitmap->AddChild(destDrawer);
		destBitmap->Unlock();
	}
	
	const uint32 keyFrameFrequency = 10;
	
	BMessage progressMessage(B_UPDATE_STATUS_BAR);
	progressMessage.AddFloat("delta", 1.0);
	bool keyFrame = true;		
	for (int32 i = 0; i < fFileList->CountItems(); i++) {
		if (framesWritten % keyFrameFrequency == 0)
			keyFrame = true;
		const char* fileName = fFileList->ItemAt(i);
		BBitmap* frame = BTranslationUtils::GetBitmapFile(fileName);
		if (frame == NULL)
			continue;
						
		// Draw scaled
		if (error == B_OK) {
			destBitmap->Lock();
			destDrawer->DrawBitmap(frame, frame->Bounds(), destDrawer->Bounds());
			destDrawer->Sync();
			destBitmap->Unlock();
		}
		
		delete frame;
			
		if (error == B_OK)
			error = movie->WriteFrame(destBitmap, keyFrame);
		
		if (error == B_OK) {
			framesWritten++;
			keyFrame = false;				
		} else {
			printf("%s\n", strerror(error));
			break;
		}
		
		if (fMessenger.IsValid())
			fMessenger.SendMessage(new BMessage(progressMessage));		
	}
	
	//printf("%ld frames written\n", framesWritten);
		
	delete movie;
	delete destBitmap;
	//delete cursor;
	
	DisposeData();
	
	BMessage message(kEncodingFinished);
	message.AddInt32("status", (int32)B_OK);
	fMessenger.SendMessage(&message);
		
	return B_OK;
}
Пример #26
0
    AboutTextView(BRect rect) : BTextView(rect, NULL,
                                              rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_NONE, B_WILL_DRAW)
    {
        int32 major = 0,middle = 0,minor = 0,variety = 0,internal = 1;

        // get version information for app

        app_info appInfo;
        if (be_app->GetAppInfo(&appInfo) == B_OK) {
            BFile file(&appInfo.ref, B_READ_ONLY);
            if (file.InitCheck() == B_OK) {
                BAppFileInfo info(&file);
                if (info.InitCheck() == B_OK) {
                    version_info versionInfo;
                    if (info.GetVersionInfo(&versionInfo,
                                            B_APP_VERSION_KIND) == B_OK) {
                        major = versionInfo.major;
                        middle = versionInfo.middle;
                        minor = versionInfo.minor;
                        variety = versionInfo.variety;
                        internal = versionInfo.internal;
                    }
                }
            }
        }
        // prepare version variety string
        const char *varietyStrings[] = {"Development","Alpha","Beta","Gamma","Golden master","Final"};
        char varietyString[32];
        strcpy(varietyString,varietyStrings[variety % 6]);
        if (variety < 5)
            sprintf(varietyString + strlen(varietyString),"/%li",internal);

        char s[512];
        sprintf(s,	"Mail Daemon Replacement\n\n"
                "by Haiku, Inc. All rights reserved.\n\n"
                "Version %ld.%ld.%ld %s\n\n"
                "See LICENSE file included in the installation package for more information.\n\n\n\n"
                "You can contact us at:\n"
                "%s\n\n"
                "Please submit bug reports using the %s\n\n"
                "Project homepage at:\n%s",
                major,middle,minor,varietyString,
                kEMail,kBugsitePretty,kWebsite);

        SetText(s);
        MakeEditable(false);
        MakeSelectable(false);

        SetAlignment(B_ALIGN_CENTER);
        SetStylable(true);

        // aethetical changes
        BFont font;
        GetFont(&font);
        font.SetSize(24);
        SetFontAndColor(0,23,&font,B_FONT_SIZE);

        // center the view vertically
        rect = TextRect();
        rect.OffsetTo(0,(Bounds().Height() - TextHeight(0,42)) / 2);
        SetTextRect(rect);

        // set the link regions
        int start = strstr(s,kEMail) - s;
        int finish = start + strlen(kEMail);
        GetTextRegion(start,finish,&fMail);
        SetFontAndColor(start,finish,NULL,0,&kLinkColor);

        start = strstr(s,kBugsitePretty) - s;
        finish = start + strlen(kBugsitePretty);
        GetTextRegion(start,finish,&fBugsite);
        SetFontAndColor(start,finish,NULL,0,&kLinkColor);

        start = strstr(s,kWebsite) - s;
        finish = start + strlen(kWebsite);
        GetTextRegion(start,finish,&fWebsite);
        SetFontAndColor(start,finish,NULL,0,&kLinkColor);
    }
Пример #27
0
// constructor
StyleView::StyleView(BRect frame)
	:
#ifdef __HAIKU__
	BView("style view", 0),
#else
	BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS),
#endif
	fCommandStack(NULL),
	fCurrentColor(NULL),
	fStyle(NULL),
	fGradient(NULL),
	fIgnoreCurrentColorNotifications(false),
	fIgnoreControlGradientNotifications(false),
	fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// style type
	BMenu* menu = new BPopUpMenu("<unavailable>");
	BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_COLOR);
	menu->AddItem(new BMenuItem("Color", message));
	message = new BMessage(MSG_SET_STYLE_TYPE);
	message->AddInt32("type", STYLE_TYPE_GRADIENT);
	menu->AddItem(new BMenuItem("Gradient", message));

#ifdef __HAIKU__
	BGridLayout* layout = new BGridLayout(5, 5);
	SetLayout(layout);

	fStyleType = new BMenuField( "Style type", menu, NULL);

#else
	frame.OffsetTo(B_ORIGIN);
	frame.InsetBy(5, 5);
	frame.bottom = frame.top + 15;

	fStyleType = new BMenuField(frame, "style type", "Style type",
		menu, true);
	AddChild(fStyleType);

	float width;
	float height;
	fStyleType->MenuBar()->GetPreferredSize(&width, &height);
	fStyleType->MenuBar()->ResizeTo(width, height);
	fStyleType->ResizeTo(frame.Width(), height + 6);
	fStyleType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fStyleType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
#endif // __HAIKU__

	// gradient type
	menu = new BPopUpMenu("<unavailable>");
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_LINEAR);
	menu->AddItem(new BMenuItem("Linear", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CIRCULAR);
	menu->AddItem(new BMenuItem("Radial", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_DIAMOND);
	menu->AddItem(new BMenuItem("Diamond", message));
	message = new BMessage(MSG_SET_GRADIENT_TYPE);
	message->AddInt32("type", GRADIENT_CONIC);
	menu->AddItem(new BMenuItem("Conic", message));

#if __HAIKU__
	fGradientType = new BMenuField("Gradient type", menu, NULL);
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);

	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);

	layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
	layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);

	layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
	layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);

	layout->AddView(fGradientControl, 1, 3, 2);

	layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
	layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);

#else // !__HAIKU__
	frame.OffsetBy(0, fStyleType->Frame().Height() + 6);
	fGradientType = new BMenuField(frame, "gradient type", "Gradient type",
		menu, true);
	AddChild(fGradientType);

	fGradientType->MenuBar()->GetPreferredSize(&width, &height);
	fGradientType->MenuBar()->ResizeTo(width, height);
	fGradientType->ResizeTo(frame.Width(), height + 6);
	fGradientType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fGradientType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);

	// create gradient control
	frame.top = fGradientType->Frame().bottom + 8;
	frame.right = Bounds().right - 5;
	fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR),
										   this);

	width = frame.Width();
	height = max_c(fGradientControl->Frame().Height(), 30);

	fGradientControl->ResizeTo(width, height);
	fGradientControl->FrameResized(width, height);
	fGradientControl->MoveTo(frame.left, frame.top);
	fGradientControl->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);

	AddChild(fGradientControl);

	// align label divider
	float divider = fGradientType->StringWidth(fGradientType->Label());
	divider = max_c(divider, fStyleType->StringWidth(fStyleType->Label()));
	fGradientType->SetDivider(divider + 8);
	fStyleType->SetDivider(divider + 8);

#endif // __HAIKU__

	fStyleType->SetEnabled(false);
	fGradientType->SetEnabled(false);
	fGradientControl->SetEnabled(false);
	fGradientControl->Gradient()->AddObserver(this);
}