Пример #1
0
void
KeyboardLayoutView::Draw(BRect updateRect)
{
	if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
		_InitOffscreen();
		_LayoutKeyboard();
	}

	BView* view;
	if (fOffscreenBitmap != NULL) {
		view = fOffscreenView;
		view->LockLooper();
	} else
		view = this;

	// Draw background

	if (Parent())
		view->SetLowColor(Parent()->ViewColor());
	else
		view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->FillRect(updateRect, B_SOLID_LOW);

	// Draw keys

	for (int32 i = 0; i < fLayout->CountKeys(); i++) {
		Key* key = fLayout->KeyAt(i);

		_DrawKey(view, updateRect, key, _FrameFor(key),
			_IsKeyPressed(key->code));
	}

	// Draw LED indicators

	for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
		Indicator* indicator = fLayout->IndicatorAt(i);

		_DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
			(fModifiers & indicator->modifier) != 0);
	}

	if (fOffscreenBitmap != NULL) {
		view->Sync();
		view->UnlockLooper();

		DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
	}
}
Пример #2
0
void
ActivityView::_UpdateOffscreenBitmap()
{
	BRect frame = _HistoryFrame();
	frame.OffsetTo(B_ORIGIN);

	if (fOffscreen != NULL && frame == fOffscreen->Bounds())
		return;

	delete fOffscreen;

	// create offscreen bitmap

	fOffscreen = new(std::nothrow) BBitmap(frame, B_BITMAP_ACCEPTS_VIEWS,
		B_RGB32);
	if (fOffscreen == NULL || fOffscreen->InitCheck() != B_OK) {
		delete fOffscreen;
		fOffscreen = NULL;
		return;
	}

	BView* view = new BView(frame, NULL, B_FOLLOW_NONE, B_SUBPIXEL_PRECISE);
	view->SetViewColor(fHistoryBackgroundColor);
	view->SetLowColor(view->ViewColor());
	fOffscreen->AddChild(view);
}
Пример #3
0
PreviewView::PreviewView(const char* name)
	:
	BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fSaverView(NULL),
	fNoPreview(NULL)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	// We draw the "monitor" around the preview, hence the strange insets.
	layout->SetInsets(7, 6, 8, 12);
	SetLayout(layout);

	// A BStringView would be enough, if only it handled word wrapping.
	fNoPreview = new BTextView("no preview");
	fNoPreview->SetText(B_TRANSLATE("No preview available"));
	fNoPreview->SetFontAndColor(be_plain_font, B_FONT_ALL, &kWhite);
	fNoPreview->MakeEditable(false);
	fNoPreview->MakeResizable(false);
	fNoPreview->MakeSelectable(false);
	fNoPreview->SetViewColor(0, 0, 0);
	fNoPreview->SetLowColor(0, 0, 0);

	fNoPreview->Hide();

	BView* container = new BView("preview container", 0);
	container->SetLayout(new BCardLayout());
	AddChild(container);
	container->SetViewColor(0, 0, 0);
	container->SetLowColor(0, 0, 0);
	container->AddChild(fNoPreview);

	fNoPreview->SetHighColor(255, 255, 255);
	fNoPreview->SetAlignment(B_ALIGN_CENTER);
}
Пример #4
0
TestWindow::TestWindow(BApplication* myApp)
	: BWindow(BRect(20,20,100,100),
	  "Code Profile", B_TITLED_WINDOW, 0)
{
	BRect frm = Bounds();

	BView* myview = new BView(BRect(),"testView",0,0);
	
	BOutlineListView* olist =
		new BOutlineListView(BRect(),"MyList",
							B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
	if( myview && olist ) {
		myview->AddChild(olist);
		BView* vw = olist;
		vw->SetViewColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetLowColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetHighColor(0x00,0x00,0x00);
		vw->Invalidate();
		vw->SetFont(be_bold_font);
		this->AddChild(myview);
		BRect frm = vw->Frame();
		vw->ResizeTo(1,1);
		vw->Draw(vw->Bounds());
		vw->ResizeToPreferred();
		float w=0,h=0;
		vw->GetPreferredSize(&w,&h);
		printf("Preferred size = %f x %f\n",w,h);
	}
	
	string = new BStringView(BRect(0,0,100,20),"String",
								"Ready to profile...");	
	
	if( string ) {
		string->SetViewColor(0xc0,0xc0,0xc0);
		this->AddChild(string);
		float w=0, h=0;
		string->GetPreferredSize(&w,&h);
		MoveTo(30,30);
		ResizeTo(w,h);
	}
	
	BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
	if( menu ) {
		this->AddChild(menu);
		float w=0, h=0;
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_plain_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_bold_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_fixed_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
	}
}
Пример #5
0
HSPictureButton::HSPictureButton(BRect frame, BBitmap* off, BBitmap* on,
		BMessage* message, const char* helpMessage, const char* longHelpMessage,
		uint32 behavior, uint32 mode, uint32 flags)
	: BPictureButton(frame, "?", NULL, NULL, message, behavior, mode, flags)
	, fLongHelpMessage(longHelpMessage)
{
	if (helpMessage)
		SetToolTip(helpMessage);

	BRect rect(0, 0, 0, 0);
	BBitmap* offScreen = new BBitmap(rect, B_RGB_32_BIT, true);
	BView* offView = new BView(rect, "", B_FOLLOW_ALL, 0);

	offScreen->AddChild(offView);
	offScreen->Lock();

	offView->SetHighColor(255, 0, 0);
	offView->SetLowColor(0, 0, 120);
	offView->SetDrawingMode(B_OP_COPY);

	offView->BeginPicture(new BPicture());
	offView->DrawBitmap(on, BPoint(0, 0));
	SetEnabledOn(offView->EndPicture());

	offView->BeginPicture(new BPicture());
	offView->DrawBitmap(off, BPoint(0, 0));
	SetEnabledOff(offView->EndPicture());

	offScreen->Unlock();

	delete offScreen;
}
Пример #6
0
BView *ViewFactory::Create<BView>(BRect rect, const char *name, uint32 resize, uint32 flags) {
	BView *view = NULL;

#ifdef __HAIKU__
	view = new BView(name, flags & B_SUPPORTS_LAYOUT);
#else
	view = new BView(rect, name, resize, flags);
#endif

#if B_BEOS_VERSION > B_BEOS_VERSION_5
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
#else
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->SetHighColor(0, 0, 0, 0);
#endif

	return view;
};
Пример #7
0
StickItWindow::StickItWindow(BRect frame)
    : BWindow(frame, "StickIt", B_TITLED_WINDOW, NULL)
{
    frame = Bounds();
    frame.InsetBy(5, 5);
    BBox* box = new BBox(frame, NULL, B_FOLLOW_ALL_SIDES);


    // Allocate object
    BView* view = new BView(Bounds(), "", B_FOLLOW_ALL_SIDES, NULL);
    view->SetViewColor(216, 216, 216);
    view->SetLowColor(216, 216, 216);

    BRect rectString = BRect(frame.left, frame.top-10, frame.right -30, 30);
    BStringView* stringview1 = new BStringView(rectString,"StringView1",
            "This list, lists action that StickIt makes.");

    BRect rect = BRect(rectString.left, rectString.bottom + SPACE,
                       rectString.right, rectString.bottom + SPACE + 200);
    fListView1 = new BListView(rect,"ListView1");

    rectString = BRect(rect.left, rect.bottom + SPACE, rect.right,
                       rect.bottom + SPACE + 15);
    BStringView* stringview2 = new BStringView(rectString,"StringView2",
            "Choose Joystick below if any exists");

    rect = BRect(rectString.left, rectString.bottom + SPACE, rectString.right,
                 Bounds().bottom -20);
    fListView2 = new BListView(rect,"ListView2");
    fListView2->SetSelectionMessage(new BMessage(SELECTED));
    fListView2->SetInvocationMessage(new BMessage(INVOKE));


    // Adding object
    box->AddChild(new BScrollView("fListView1", fListView1,
                                  B_FOLLOW_LEFT_RIGHT, NULL, false, true));

    box->AddChild(new BScrollView("fListView2", fListView2,
                                  B_FOLLOW_ALL_SIDES, NULL, false, true));

    box->AddChild(stringview1);
    box->AddChild(stringview2);
    view->AddChild(box);
    AddChild(view);

    fJoystick = new BJoystick;
    PickJoystick(fJoystick);
}
Пример #8
0
BBitmap *bitmap (char *title)
{
	strcpy (title, "Grabbed");
	BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true);
	BView *v = new BView (BRect (0, 0, 127, 127), "bg", 0, 0);
	b->Lock();
	b->AddChild (v);
	rgb_color fg, bg;
	fg.red = 255; fg.green = 255; fg.blue = 255; fg.alpha = 255;
	bg.red = 0;   bg.green = 0;   bg.blue = 0;   bg.alpha = 127;
	v->SetHighColor (fg);
	v->SetLowColor (bg);
	v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS);
	v->Sync();
	b->RemoveChild (v);
	b->Unlock();
	delete v;
	return (b);
}
Пример #9
0
void
BSlider::AttachedToWindow()
{
	ResizeToPreferred();

#if USE_OFF_SCREEN_VIEW
	BRect bounds(Bounds());

	if (!fOffScreenView) {
		fOffScreenView = new BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW);

		BFont font;
		GetFont(&font);
		fOffScreenView->SetFont(&font);
	}

	if (!fOffScreenBits) {
		fOffScreenBits = new BBitmap(bounds, B_RGBA32, true, false);

		if (fOffScreenBits && fOffScreenView)
			fOffScreenBits->AddChild(fOffScreenView);

	} else if (fOffScreenView)
		fOffScreenBits->AddChild(fOffScreenView);
#endif // USE_OFF_SCREEN_VIEW

	BControl::AttachedToWindow();

	BView* view = OffscreenView();
	if (view && view->LockLooper()) {
		view->SetViewColor(B_TRANSPARENT_COLOR);
		view->SetLowColor(LowColor());
		view->UnlockLooper();
	}

	int32 value = Value();
	SetValue(value);
		// makes sure the value is within valid bounds
	_SetLocationForValue(Value());
		// makes sure the location is correct
	UpdateTextChanged();
}
Пример #10
0
void ArpTextControl::copy_colors(BView* v)
{
	// Make no assumptions about the structure of the children.
	if( !v ) return;
	int32 num = v->CountChildren();
	for( int32 i=0; i<num; i++ ) {
		BView* child = v->ChildAt(i);
		if( child ) {
			copy_colors(child);
			BTextView* text = dynamic_cast<BTextView*>(child);
			if( text ) {
				text->SetFontAndColor(NULL, B_FONT_ALL, &PV_FillForeColor);
			}
			child->SetViewColor(PV_FillBackColor);
			child->SetLowColor(PV_FillBackColor);
			child->SetHighColor(PV_FillForeColor);
			child->Invalidate();
		}
	}
}
Пример #11
0
BBitmap *DragonView::_MakeNoneImage( void )
{
	// Draw an "empty" bitmap to represent "no image"; we'll use one
	// that tells the user what to do.
	BBitmap *bitmap = new BBitmap( BRect( 0, 0, 319, 199 ),
								   BScreen().ColorSpace(),
								   true );
	BView *view = new BView( bitmap->Bounds(),
							 "not a bitmap",
							 B_FOLLOW_ALL_SIDES, 0 );
	bitmap->AddChild( view );

	DragonApp *app = dynamic_cast<DragonApp *>( be_app );
	
	rgb_color White = { 255, 255, 255, 0 };
	rgb_color Black = { 0, 0, 0, 0 };
	
	bitmap->Lock();

	view->SetLowColor( White );
	view->SetViewColor( White );
	view->SetHighColor( Black );
	view->SetDrawingMode( B_OP_OVER );
	view->FillRect( view->Bounds(), B_SOLID_LOW );

	// Excercise for the reader here:  Read the old newsletter articles
	// about how to use the font metrics to find out how large a font is,
	// then center to font in the window dynamically no matter what font
	// settings the user has.

	view->SetFont( be_plain_font );
	view->MovePenTo( 5, 100 );
	view->DrawString( app->rsrc_strings->FindString( RSRC_Drop_an_image ) );
	view->Sync();
	
	bitmap->Unlock();

	return bitmap;
}
Пример #12
0
status_t
CanvasMessage::ReadViewState(BView& view, ::pattern& pattern)
{
	bool subPixelPrecise;
	float penSize, miterLimit;
	drawing_mode drawingMode;
	source_alpha sourceAlpha;
	alpha_function alphaFunction;
	cap_mode capMode;
	join_mode joinMode;
	rgb_color highColor, lowColor;

	Read(penSize);
	Read(subPixelPrecise);
	Read(drawingMode);
	Read(sourceAlpha);
	Read(alphaFunction);
	Read(pattern);
	Read(capMode);
	Read(joinMode);
	Read(miterLimit);
	Read(highColor);
	status_t result = Read(lowColor);
	if (result != B_OK)
		return result;

	uint32 flags = view.Flags() & ~B_SUBPIXEL_PRECISE;
	view.SetFlags(flags | (subPixelPrecise ? B_SUBPIXEL_PRECISE : 0));
	view.SetPenSize(penSize);
	view.SetDrawingMode(drawingMode);
	view.SetBlendingMode(sourceAlpha, alphaFunction);
	view.SetLineMode(capMode, joinMode, miterLimit);
	view.SetHighColor(highColor);
	view.SetLowColor(lowColor);
	return B_OK;
}
Пример #13
0
void 
BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
	const BColumnTitle *pressedColumn,
	void (*trackRectBlitter)(BView *, BRect), BRect passThru)
{
	BRect bounds(Bounds());
	BView *view;

	if (useOffscreen) {
		ASSERT(sOffscreen);
		BRect frame(bounds);
		frame.right += frame.left;
			// this is kind of messy way of avoiding being clipped by the ammount the
			// title is scrolled to the left
			// ToDo: fix this
		view = sOffscreen->BeginUsing(frame);
		view->SetOrigin(-bounds.left, 0);
		view->SetLowColor(LowColor());
		view->SetHighColor(HighColor());
		BFont font(be_plain_font);
		font.SetSize(9);
		view->SetFont(&font);
	} else
		view = this;

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		view->SetHighColor(tint_color(base, B_DARKEN_2_TINT));
		view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
		bounds.bottom--;

		be_control_look->DrawButtonBackground(view, bounds, bounds, base, 0,
			BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);
	} else {
		// fill background with light gray background
		if (!updateOnly)
			view->FillRect(bounds, B_SOLID_LOW);
	
		view->BeginLineArray(4);
		view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor);
		view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor);
		// draw lighter gray and white inset lines
		bounds.InsetBy(0, 1);
		view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor);
		view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor);
		view->EndLineArray();
	}

	int32 count = fTitleList.CountItems();
	float minx = bounds.right;
	float maxx = bounds.left;
	for (int32 index = 0; index < count; index++) {
		BColumnTitle *title = fTitleList.ItemAt(index);
		title->Draw(view, title == pressedColumn);
		BRect titleBounds(title->Bounds());
		if (titleBounds.left < minx)
			minx = titleBounds.left;
		if (titleBounds.right > maxx)
			maxx = titleBounds.right;
	}

	if (be_control_look != NULL) {
		bounds = Bounds();
		minx--;
		view->SetHighColor(sLightShadowColor);
		view->StrokeLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom - 1));
	} else {
		// first and last shades before and after first column
		maxx++;
		minx--;
		view->BeginLineArray(2);
		view->AddLine(BPoint(minx, bounds.top),
					  BPoint(minx, bounds.bottom), sShadowColor);
		view->AddLine(BPoint(maxx, bounds.top),
					  BPoint(maxx, bounds.bottom), sShineColor);
		view->EndLineArray();
	}

#if !(APP_SERVER_CLEARS_BACKGROUND)
	FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1), B_SOLID_LOW);
	FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1), B_SOLID_LOW);
#endif

	if (useOffscreen) {
		if (trackRectBlitter)
			(trackRectBlitter)(view, passThru);
		view->Sync();
		DrawBitmap(sOffscreen->Bitmap());
		sOffscreen->DoneUsing();
	} else if (trackRectBlitter)
		(trackRectBlitter)(view, passThru);
}
Пример #14
0
AttribRect::AttribRect ()
    : AttribView (BRect (0, 0, 148, 90), lstring (31, "Rectangles"))
{
    SetViewColor (LightGrey);
    lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
    AddChild (lSlid);
    fType = RECT_OUTFILL;
    fPenSize = 1;
    BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
    type->SetLabel (lstring (311, "Type"));
    AddChild (type);
    BRect shape = BRect (3, 5, 27, 25);

    BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
    BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
    picWindow->AddChild (bg);

    BPicture *p10;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p10 = bg->EndPicture();

    BPicture *p20;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p20 = bg->EndPicture();

    BPicture *p30;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (LightGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p30 = bg->EndPicture();

    BPicture *p11;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    bg->StrokeRect (shape);
    p11 = bg->EndPicture();

    BPicture *p21;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->FillRect (shape, B_SOLID_LOW);
    p21 = bg->EndPicture();

    BPicture *p31;
    bg->BeginPicture (new BPicture);
    bg->SetLowColor (DarkGrey);
    bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
    bg->SetHighColor (Black);
    bg->SetLowColor (White);
    bg->StrokeRect (shape);
    p31 = bg->EndPicture();

    SetViewColor (LightGrey);
    delete picWindow;

    pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
    pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
    pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
    type->AddChild (pT1);
    type->AddChild (pT2);
    type->AddChild (pT3);
    pT1->SetValue (B_CONTROL_ON);
    fCurrentProperty = 0;
}
Пример #15
0
void
ColorStepView::Draw(BRect updateRect)
{
	BView *view = NULL;
	if(fOffScreenView){
		view = fOffScreenView;
	}
	else{
		view = this;
	}

	if (!fOffScreenBitmap || !fOffScreenBitmap->Lock())
		return;
	view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	view->FillRect(updateRect);

	BRect colorBarRect =  fSlider->BarFrame();
	colorBarRect.top = 0;
	colorBarRect.bottom = kColorBarHeight;
	colorBarRect.OffsetTo(colorBarRect.left, fSlider->Frame().bottom);

	float pos = 0.0;
	for (int i = fPerformanceList->CountItems() - 1; i >= 0 ; i--) {
		performance_step* perfState = fPerformanceList->ItemAt(i);

		float nextPos = perfState->cpu_usage;
		float width = colorBarRect.Width();

		BRect subRect(colorBarRect);
		subRect.left += pos * width;
		subRect.right = colorBarRect.left + nextPos * width;

		view->SetHighColor(perfState->color);
		view->FillRect(subRect);

		pos = nextPos;
	}
	// draw label
	if (IsEnabled()) {
		view->SetHighColor(0, 0, 0);
	} else {
		view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
	}

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float totalFontHeight = fontHeight.descent + fontHeight.ascent;

	view->DrawString(fMinFrequencyLabel.String(),
						BPoint(0.0,
								colorBarRect.bottom + totalFontHeight + 5));

	view->DrawString(fMaxFrequencyLabel.String(),
						BPoint(Bounds().right
								- StringWidth(fMaxFrequencyLabel.String()),
								colorBarRect.bottom	+ totalFontHeight + 5));

	// blit bitmap
	view->Sync();
	fOffScreenBitmap->Unlock();
	DrawBitmap(fOffScreenBitmap, B_ORIGIN);

	BView::Draw(updateRect);
}
Пример #16
0
void
RemoteView::_DrawThread()
{
	RemoteMessage reply(NULL, fSendBuffer);
	RemoteMessage message(fReceiveBuffer, NULL);

	// cursor
	BPoint cursorHotSpot(0, 0);

	while (!fStopThread) {
		uint16 code;
		status_t status = message.NextMessage(code);
		if (status != B_OK) {
			TRACE_ERROR("failed to read message from receiver\n");
			break;
		}

		TRACE("code %u with %ld bytes data\n", code, message.DataLeft());

		BAutolock locker(this->Looper());
		if (!locker.IsLocked())
			break;

		// handle stuff that doesn't go to a specicifc engine
		switch (code) {
			case RP_INIT_CONNECTION:
			{
				uint16 port;
				status_t result = message.Read(port);
				if (result != B_OK) {
					TRACE_ERROR("failed to read remote port\n");
					continue;
				}

				BNetEndpoint *endpoint = fReceiver->Endpoint();
				if (endpoint == NULL) {
					TRACE_ERROR("receiver not connected anymore\n");
					continue;
				}

				in_addr remoteHost;
				char hostName[MAXHOSTNAMELEN + 1];
				BNetAddress address(endpoint->RemoteAddr());
				address.GetAddr(remoteHost);
				address.GetAddr(hostName, NULL);
				address.SetTo(remoteHost, port);

				TRACE("connecting to host \"%s\" port %u\n", hostName, port);
				result = fSendEndpoint->Connect(address);
				if (result != B_OK) {
					TRACE_ERROR("failed to connect to host \"%s\" port %u\n",
						hostName, port);
					continue;
				}

				BRect bounds = fOffscreenBitmap->Bounds();
				reply.Start(RP_UPDATE_DISPLAY_MODE);
				reply.Add(bounds.IntegerWidth() + 1);
				reply.Add(bounds.IntegerHeight() + 1);
				if (reply.Flush() == B_OK)
					fIsConnected = true;

				continue;
			}

			case RP_CLOSE_CONNECTION:
			{
				be_app->PostMessage(B_QUIT_REQUESTED);
				continue;
			}

			case RP_CREATE_STATE:
			case RP_DELETE_STATE:
			{
				uint32 token;
				message.Read(token);

				if (code == RP_CREATE_STATE)
					_CreateState(token);
				else
					_DeleteState(token);

				continue;
			}

			case RP_SET_CURSOR:
			{
				BBitmap *bitmap;
				BPoint oldHotSpot = cursorHotSpot;
				message.Read(cursorHotSpot);
				if (message.ReadBitmap(&bitmap) != B_OK)
					continue;

				delete fCursorBitmap;
				fCursorBitmap = bitmap;

				Invalidate(fCursorFrame);

				BRect bounds = fCursorBitmap->Bounds();
				fCursorFrame.right = fCursorFrame.left
					+ bounds.IntegerWidth() + 1;
				fCursorFrame.bottom = fCursorFrame.bottom
					+ bounds.IntegerHeight() + 1;

				fCursorFrame.OffsetBy(oldHotSpot - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_SET_CURSOR_VISIBLE:
			{
				bool wasVisible = fCursorVisible;
				message.Read(fCursorVisible);
				if (wasVisible != fCursorVisible)
					Invalidate(fCursorFrame);
				continue;
			}

			case RP_MOVE_CURSOR_TO:
			{
				BPoint position;
				message.Read(position);

				if (fCursorVisible)
					Invalidate(fCursorFrame);

				fCursorFrame.OffsetTo(position - cursorHotSpot);

				Invalidate(fCursorFrame);
				continue;
			}

			case RP_INVALIDATE_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				Invalidate(rect);
				continue;
			}

			case RP_INVALIDATE_REGION:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				Invalidate(&region);
				continue;
			}

			case RP_FILL_REGION_COLOR_NO_CLIPPING:
			{
				BRegion region;
				rgb_color color;

				message.ReadRegion(region);
				if (message.Read(color) != B_OK)
					continue;

				fOffscreen->LockLooper();
				fOffscreen->SetHighColor(color);
				fOffscreen->FillRegion(&region);
				fOffscreen->UnlockLooper();
				Invalidate(&region);
				continue;
			}

			case RP_COPY_RECT_NO_CLIPPING:
			{
				int32 xOffset, yOffset;
				BRect rect;

				message.Read(xOffset);
				message.Read(yOffset);
				if (message.Read(rect) != B_OK)
					continue;

				BRect dest = rect.OffsetByCopy(xOffset, yOffset);
				fOffscreen->LockLooper();
				fOffscreen->CopyBits(rect, dest);
				fOffscreen->UnlockLooper();
				continue;
			}
		}

		uint32 token;
		message.Read(token);

		engine_state *state = _FindState(token);
		if (state == NULL) {
			TRACE_ERROR("didn't find state for token %lu\n", token);
			continue;
		}

		BView *offscreen = state->view;
		::pattern &pattern = state->pattern;
		BRegion &clippingRegion = state->clipping_region;
		float &penSize = state->pen_size;
		bool &syncDrawing = state->sync_drawing;
		BRegion invalidRegion;

		BAutolock offscreenLocker(offscreen->Looper());
		if (!offscreenLocker.IsLocked())
			break;

		switch (code) {
			case RP_ENABLE_SYNC_DRAWING:
				syncDrawing = true;
				continue;

			case RP_DISABLE_SYNC_DRAWING:
				syncDrawing = false;
				continue;

			case RP_SET_OFFSETS:
			{
				int32 xOffset, yOffset;
				message.Read(xOffset);
				if (message.Read(yOffset) != B_OK)
					continue;

				offscreen->MovePenTo(xOffset, yOffset);
				break;
			}

			case RP_SET_HIGH_COLOR:
			case RP_SET_LOW_COLOR:
			{
				rgb_color color;
				if (message.Read(color) != B_OK)
					continue;

				if (code == RP_SET_HIGH_COLOR)
					offscreen->SetHighColor(color);
				else
					offscreen->SetLowColor(color);

				break;
			}

			case RP_SET_PEN_SIZE:
			{
				float newPenSize;
				if (message.Read(newPenSize) != B_OK)
					continue;

				offscreen->SetPenSize(newPenSize);
				penSize = newPenSize / 2;
				break;
			}

			case RP_SET_STROKE_MODE:
			{
				cap_mode capMode;
				join_mode joinMode;
				float miterLimit;

				message.Read(capMode);
				message.Read(joinMode);
				if (message.Read(miterLimit) != B_OK)
					continue;

				offscreen->SetLineMode(capMode, joinMode, miterLimit);
				break;
			}

			case RP_SET_BLENDING_MODE:
			{
				source_alpha sourceAlpha;
				alpha_function alphaFunction;

				message.Read(sourceAlpha);
				if (message.Read(alphaFunction) != B_OK)
					continue;

				offscreen->SetBlendingMode(sourceAlpha, alphaFunction);
				break;
			}

			case RP_SET_PATTERN:
			{
				if (message.Read(pattern) != B_OK)
					continue;
				break;
			}

			case RP_SET_DRAWING_MODE:
			{
				drawing_mode drawingMode;
				if (message.Read(drawingMode) != B_OK)
					continue;

				offscreen->SetDrawingMode(drawingMode);
				break;
			}

			case RP_SET_FONT:
			{
				BFont font;
				if (message.ReadFontState(font) != B_OK)
					continue;

				offscreen->SetFont(&font);
				break;
			}

			case RP_CONSTRAIN_CLIPPING_REGION:
			{
				if (message.ReadRegion(clippingRegion) != B_OK)
					continue;

				offscreen->ConstrainClippingRegion(&clippingRegion);
				break;
			}

			case RP_INVERT_RECT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				offscreen->InvertRect(rect);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_BITMAP:
			{
				BBitmap *bitmap;
				BRect bitmapRect, viewRect;
				uint32 options;

				message.Read(bitmapRect);
				message.Read(viewRect);
				message.Read(options);
				if (message.ReadBitmap(&bitmap) != B_OK || bitmap == NULL)
					continue;

				offscreen->DrawBitmap(bitmap, bitmapRect, viewRect, options);
				invalidRegion.Include(viewRect);
				delete bitmap;
				break;
			}

			case RP_DRAW_BITMAP_RECTS:
			{
				color_space colorSpace;
				int32 rectCount;
				uint32 flags, options;

				message.Read(options);
				message.Read(colorSpace);
				message.Read(flags);
				message.Read(rectCount);
				for (int32 i = 0; i < rectCount; i++) {
					BBitmap *bitmap;
					BRect viewRect;

					message.Read(viewRect);
					if (message.ReadBitmap(&bitmap, true, colorSpace,
							flags) != B_OK || bitmap == NULL) {
						continue;
					}

					offscreen->DrawBitmap(bitmap, bitmap->Bounds(), viewRect,
						options);
					invalidRegion.Include(viewRect);
					delete bitmap;
				}

				break;
			}

			case RP_STROKE_ARC:
			case RP_FILL_ARC:
			case RP_FILL_ARC_GRADIENT:
			{
				BRect rect;
				float angle, span;

				message.Read(rect);
				message.Read(angle);
				if (message.Read(span) != B_OK)
					continue;

				if (code == RP_STROKE_ARC) {
					offscreen->StrokeArc(rect, angle, span, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ARC)
					offscreen->FillArc(rect, angle, span, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillArc(rect, angle, span, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_BEZIER:
			case RP_FILL_BEZIER:
			case RP_FILL_BEZIER_GRADIENT:
			{
				BPoint points[4];
				if (message.ReadList(points, 4) != B_OK)
					continue;

				BRect bounds = _BuildInvalidateRect(points, 4);
				if (code == RP_STROKE_BEZIER) {
					offscreen->StrokeBezier(points, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_BEZIER)
					offscreen->FillBezier(points, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillBezier(points, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_ELLIPSE:
			case RP_FILL_ELLIPSE:
			case RP_FILL_ELLIPSE_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_ELLIPSE) {
					offscreen->StrokeEllipse(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ELLIPSE)
					offscreen->FillEllipse(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillEllipse(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_POLYGON:
			case RP_FILL_POLYGON:
			case RP_FILL_POLYGON_GRADIENT:
			{
				BRect bounds;
				bool closed;
				int32 numPoints;

				message.Read(bounds);
				message.Read(closed);
				if (message.Read(numPoints) != B_OK)
					continue;

				BPoint points[numPoints];
				for (int32 i = 0; i < numPoints; i++)
					message.Read(points[i]);

				if (code == RP_STROKE_POLYGON) {
					offscreen->StrokePolygon(points, numPoints, bounds, closed,
						pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_POLYGON)
					offscreen->FillPolygon(points, numPoints, bounds, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillPolygon(points, numPoints, bounds,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_RECT:
			case RP_FILL_RECT:
			case RP_FILL_RECT_GRADIENT:
			{
				BRect rect;
				if (message.Read(rect) != B_OK)
					continue;

				if (code == RP_STROKE_RECT) {
					offscreen->StrokeRect(rect, pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_RECT)
					offscreen->FillRect(rect, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRect(rect, *gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_ROUND_RECT:
			case RP_FILL_ROUND_RECT:
			case RP_FILL_ROUND_RECT_GRADIENT:
			{
				BRect rect;
				float xRadius, yRadius;

				message.Read(rect);
				message.Read(xRadius);
				if (message.Read(yRadius) != B_OK)
					continue;

				if (code == RP_STROKE_ROUND_RECT) {
					offscreen->StrokeRoundRect(rect, xRadius, yRadius,
						pattern);
					rect.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_ROUND_RECT)
					offscreen->FillRoundRect(rect, xRadius, yRadius, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRoundRect(rect, xRadius, yRadius,
						*gradient);
					delete gradient;
				}

				invalidRegion.Include(rect);
				break;
			}

			case RP_STROKE_SHAPE:
			case RP_FILL_SHAPE:
			case RP_FILL_SHAPE_GRADIENT:
			{
				BRect bounds;
				int32 opCount, pointCount;

				message.Read(bounds);
				if (message.Read(opCount) != B_OK)
					continue;

				BMessage archive;
				for (int32 i = 0; i < opCount; i++) {
					int32 op;
					message.Read(op);
					archive.AddInt32("ops", op);
				}

				if (message.Read(pointCount) != B_OK)
					continue;

				for (int32 i = 0; i < pointCount; i++) {
					BPoint point;
					message.Read(point);
					archive.AddPoint("pts", point);
				}

				BPoint offset;
				message.Read(offset);

				float scale;
				if (message.Read(scale) != B_OK)
					continue;

				offscreen->PushState();
				offscreen->MovePenTo(offset);
				offscreen->SetScale(scale);

				BShape shape(&archive);
				if (code == RP_STROKE_SHAPE) {
					offscreen->StrokeShape(&shape, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_SHAPE)
					offscreen->FillShape(&shape, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK) {
						offscreen->PopState();
						continue;
					}

					offscreen->FillShape(&shape, *gradient);
					delete gradient;
				}

				offscreen->PopState();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_TRIANGLE:
			case RP_FILL_TRIANGLE:
			case RP_FILL_TRIANGLE_GRADIENT:
			{
				BRect bounds;
				BPoint points[3];

				message.ReadList(points, 3);
				if (message.Read(bounds) != B_OK)
					continue;

				if (code == RP_STROKE_TRIANGLE) {
					offscreen->StrokeTriangle(points[0], points[1], points[2],
						bounds, pattern);
					bounds.InsetBy(-penSize, -penSize);
				} else if (code == RP_FILL_TRIANGLE) {
					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, pattern);
				} else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillTriangle(points[0], points[1], points[2],
						bounds, *gradient);
					delete gradient;
				}

				invalidRegion.Include(bounds);
				break;
			}

			case RP_STROKE_LINE:
			{
				BPoint points[2];
				if (message.ReadList(points, 2) != B_OK)
					continue;

				offscreen->StrokeLine(points[0], points[1], pattern);

				BRect bounds = _BuildInvalidateRect(points, 2);
				invalidRegion.Include(bounds.InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_ARRAY:
			{
				int32 numLines;
				if (message.Read(numLines) != B_OK)
					continue;

				BRect bounds;
				offscreen->BeginLineArray(numLines);
				for (int32 i = 0; i < numLines; i++) {
					rgb_color color;
					BPoint start, end;
					message.ReadArrayLine(start, end, color);
					offscreen->AddLine(start, end, color);

					bounds.left = min_c(bounds.left, min_c(start.x, end.x));
					bounds.top = min_c(bounds.top, min_c(start.y, end.y));
					bounds.right = max_c(bounds.right, max_c(start.x, end.x));
					bounds.bottom = max_c(bounds.bottom, max_c(start.y, end.y));
				}

				offscreen->EndLineArray();
				invalidRegion.Include(bounds);
				break;
			}

			case RP_FILL_REGION:
			case RP_FILL_REGION_GRADIENT:
			{
				BRegion region;
				if (message.ReadRegion(region) != B_OK)
					continue;

				if (code == RP_FILL_REGION)
					offscreen->FillRegion(&region, pattern);
				else {
					BGradient *gradient;
					if (message.ReadGradient(&gradient) != B_OK)
						continue;

					offscreen->FillRegion(&region, *gradient);
					delete gradient;
				}

				invalidRegion.Include(&region);
				break;
			}

			case RP_STROKE_POINT_COLOR:
			{
				BPoint point;
				rgb_color color;

				message.Read(point);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);
				offscreen->StrokeLine(point, point);
				offscreen->SetHighColor(oldColor);

				invalidRegion.Include(
					BRect(point, point).InsetBySelf(-penSize, -penSize));
				break;
			}

			case RP_STROKE_LINE_1PX_COLOR:
			{
				BPoint points[2];
				rgb_color color;

				message.ReadList(points, 2);
				if (message.Read(color) != B_OK)
					continue;

				float oldSize = offscreen->PenSize();
				rgb_color oldColor = offscreen->HighColor();
				drawing_mode oldMode = offscreen->DrawingMode();
				offscreen->SetPenSize(1);
				offscreen->SetHighColor(color);
				offscreen->SetDrawingMode(B_OP_OVER);

				offscreen->StrokeLine(points[0], points[1]);

				offscreen->SetDrawingMode(oldMode);
				offscreen->SetHighColor(oldColor);
				offscreen->SetPenSize(oldSize);

				invalidRegion.Include(_BuildInvalidateRect(points, 2));
				break;
			}

			case RP_STROKE_RECT_1PX_COLOR:
			case RP_FILL_RECT_COLOR:
			{
				BRect rect;
				rgb_color color;

				message.Read(rect);
				if (message.Read(color) != B_OK)
					continue;

				rgb_color oldColor = offscreen->HighColor();
				offscreen->SetHighColor(color);

				if (code == RP_STROKE_RECT_1PX_COLOR) {
					float oldSize = PenSize();
					offscreen->SetPenSize(1);
					offscreen->StrokeRect(rect);
					offscreen->SetPenSize(oldSize);
				} else
					offscreen->FillRect(rect);

				offscreen->SetHighColor(oldColor);
				invalidRegion.Include(rect);
				break;
			}

			case RP_DRAW_STRING:
			{
				BPoint point;
				size_t length;
				char *string;
				bool hasDelta;

				message.Read(point);
				message.ReadString(&string, length);
				if (message.Read(hasDelta) != B_OK) {
					free(string);
					continue;
				}

				if (hasDelta) {
					escapement_delta delta[length];
					message.ReadList(delta, length);
					offscreen->DrawString(string, point, delta);
				} else
					offscreen->DrawString(string, point);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

				font_height height;
				offscreen->GetFontHeight(&height);

				BRect bounds(point, offscreen->PenLocation());
				bounds.top -= height.ascent;
				bounds.bottom += height.descent;
				invalidRegion.Include(bounds);
				break;
			}

			case RP_DRAW_STRING_WITH_OFFSETS:
			{
				size_t length;
				char *string;
				message.ReadString(&string, length);
				int32 count = UTF8CountChars(string, length);

				BPoint offsets[count];
				if (message.ReadList(offsets, count) != B_OK) {
					free(string);
					continue;
				}

				offscreen->DrawString(string, offsets, count);

				free(string);
				reply.Start(RP_DRAW_STRING_RESULT);
				reply.Add(token);
				reply.Add(offscreen->PenLocation());
				reply.Flush();

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

				BRect boxes[count];
				font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC,
					boxes);

				font_height height;
				offscreen->GetFontHeight(&height);

				for (int32 i = 0; i < count; i++) {
					// TODO: validate
					boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent));
					invalidRegion.Include(boxes[i]);
				}

				break;
			}

			case RP_READ_BITMAP:
			{
				BRect bounds;
				bool drawCursor;

				message.Read(bounds);
				if (message.Read(drawCursor) != B_OK)
					continue;

				// TODO: support the drawCursor flag
				BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32);
				bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(),
					BPoint(0, 0), bounds.IntegerWidth() + 1,
					bounds.IntegerHeight() + 1);

				reply.Start(RP_READ_BITMAP_RESULT);
				reply.Add(token);
				reply.AddBitmap(&bitmap);
				reply.Flush();
				break;
			}

			default:
				TRACE_ERROR("unknown protocol code: %u\n", code);
				break;
		}

		if (syncDrawing) {
			offscreen->Sync();
			Invalidate(&invalidRegion);
		}
	}
}
Пример #17
0
void
BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly,
	const BColumnTitle* pressedColumn,
	void (*trackRectBlitter)(BView*, BRect), BRect passThru)
{
	BRect bounds(Bounds());
	BView* view;

	if (useOffscreen) {
		ASSERT(sOffscreen);
		BRect frame(bounds);
		frame.right += frame.left;
			// ToDo: this is kind of messy way of avoiding being clipped
			// by the amount the title is scrolled to the left
		view = sOffscreen->BeginUsing(frame);
		view->SetOrigin(-bounds.left, 0);
		view->SetLowColor(LowColor());
		view->SetHighColor(HighColor());
		BFont font;
		GetFont(&font);
		view->SetFont(&font);
	} else
		view = this;

	view->SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_2_TINT);
	view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
	bounds.bottom--;

	rgb_color baseColor = ui_color(B_PANEL_BACKGROUND_COLOR);
	be_control_look->DrawButtonBackground(view, bounds, bounds, baseColor, 0,
		BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER);

	int32 count = fTitleList.CountItems();
	float minx = bounds.right;
	float maxx = bounds.left;
	for (int32 index = 0; index < count; index++) {
		BColumnTitle* title = fTitleList.ItemAt(index);
		title->Draw(view, title == pressedColumn);
		BRect titleBounds(title->Bounds());
		if (titleBounds.left < minx)
			minx = titleBounds.left;
		if (titleBounds.right > maxx)
			maxx = titleBounds.right;
	}

	bounds = Bounds();
	minx--;
	view->SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_1_TINT);
	view->StrokeLine(BPoint(minx, bounds.top),
		BPoint(minx, bounds.bottom - 1));

#if !(APP_SERVER_CLEARS_BACKGROUND)
	FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1),
		B_SOLID_LOW);
	FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1),
		B_SOLID_LOW);
#endif

	if (useOffscreen) {
		if (trackRectBlitter)
			(trackRectBlitter)(view, passThru);

		view->Sync();
		DrawBitmap(sOffscreen->Bitmap());
		sOffscreen->DoneUsing();
	} else if (trackRectBlitter)
		(trackRectBlitter)(view, passThru);
}
Пример #18
0
MEMORY::MEMORY()
	: BWindow(rect, "Aural illusion - Memory Setup", B_TITLED_WINDOW, B_CURRENT_WORKSPACE)
{
	BView* memoryview = new BView(BRect(0,0,210,160),"memoryview", B_FOLLOW_ALL, B_WILL_DRAW);

	memoryview->SetViewColor(216,216,216); // View is Grey
	memoryview->SetHighColor(255,255,255);
	memoryview->SetLowColor(0,0,0);

	memlev = new BSlider(BRect(3,3,200,53), "memlev", "Memory Size",  new BMessage(MEM_LEV), 0,100);
	memlev->SetHashMarks(B_HASH_MARKS_BOTH);
	memlev->SetHashMarkCount(9);
	memlev->SetLimitLabels("Min", "Max");
	memlev->SetValue(0);
	memoryview->AddChild(memlev);

	// View for Radio Buttons
	BView* memtypview = new BView(BRect(145,65,210,135), "memtypview", B_FOLLOW_ALL, B_WILL_DRAW);
	
	small = new BRadioButton(BRect(0,0,65,15),"small","Small",			new BMessage(MEM_SMALL));
	small->SetValue(1); // default is small
	memtypview->AddChild(small);

	medium = new BRadioButton(BRect(0,16,65,29),"medium","Medium",		new BMessage(MEM_MEDIUM));
	memtypview->AddChild(medium);

	large = new BRadioButton(BRect(0,32,65,33),"large","Large",		new BMessage(MEM_LARGE));
	memtypview->AddChild(large);

	memtypview->SetViewColor(216,216,216);
	memoryview->AddChild(memtypview);

	// OK Button
	memok = new BButton(BRect(80,130,130,150), "ok", "OK",	new BMessage(MEM_OK));
	memok->MakeDefault(1); // set as default for fancy surround
	memok->SetFont(be_bold_font);
	memoryview->AddChild(memok);

	// memory display string
	memstring = new BStringView(BRect(5,70,144,84), "memstring"," ",  B_WILL_DRAW);
	memstring->SetFont(be_bold_font);
	memstring->SetHighColor(0,0,0); // text to Black
	memoryview->AddChild(memstring);

	// Time display string
	timestring = new BStringView(BRect(5,85,144,100), "timestring"," ",  B_WILL_DRAW);
	timestring->SetFont(be_bold_font);
	timestring->SetHighColor(0,0,0); // text to Black
	memoryview->AddChild(timestring);

	// KHz string
	kstring = new BStringView(BRect(5,101,144,116), "kstring","at 44KHz Mono",  B_WILL_DRAW);
	kstring->SetFont(be_bold_font);
	kstring->SetHighColor(0,0,0); // text to Black
	memoryview->AddChild(kstring);

	// show the window
	AddChild(memoryview);
	Show();
	SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE);
	
//	BRect screenrect = Frame();
	memtyp = 1;
	Displaymemory();
}
Пример #19
0
// Private function to add the config view of the currently
// selected output format to our window
void
OutputFormatView::AddConfigView()
{
	the_window->Lock();
	// Remove the window size limits,
	// so we are free to do whatever we like
	the_window->SetSizeLimits(0.0, 32767.0, 0.0, 32767.0);
	// The current views must stay put while we resize
	// the window to make room for the config view
	MakeFollowBottom(false);

	// Remove the old config view if there is one
	if (config_view)
	{
		RemoveChild(config_view);
		delete config_view;
		config_view = 0;
	}

	BRect config_rect;
	if (the_roster->MakeConfigurationView(
	    	output_list[index].translator,
	    	0,
	    	&config_view,
	    	&config_rect) == B_NO_ERROR &&
	    config_view != 0)
	{
		// Create a caption for the config view
		// if there wasn't one already
		if (!config_caption)
		{
			config_caption = new CaptionView(
				BRect(8.0, info_view->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0),
				"config caption",
				StringsRsrc[STR_TRANSLATOR_SETTINGS]);
			config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
			AddChild(config_caption);
		}

		// Move the config view to just below the config caption
		config_view->MoveBy(
			16.0 - config_view->Frame().left,
			config_caption->Frame().bottom + 1.0 - config_view->Frame().top);

		// Colour it gray
		config_view->SetViewColor(222, 222, 222);
		config_view->SetLowColor(222, 222, 222);

		// First resize the window so that the config view will fit,
		// otherwise the config view may want to change with us
		float width_diff = config_view->Frame().right + 16.0 - Bounds().Width();
		the_window->ResizeTo(
			Bounds().Width() + (width_diff > 0.0 ? width_diff : 0.0),
			config_view->Frame().bottom + 8.0);

		// Add it to the main view
		AddChild(config_view);

		// Make the config_view and its children follow the bottom of the window
		RecursiveSetMode(config_view);
	}
	else
	{
		// This translator doesn't have a config view
		if (config_caption)
		{
			RemoveChild(config_caption);
			delete config_caption;
			config_caption = 0;
		}
		the_window->ResizeTo(Bounds().right, info_view->Frame().bottom + 8.0);
	}

	// Make all views follow the bottom of the window again
	MakeFollowBottom();

	// Set the window's minimum size
	float min_width = (config_view ? config_view->Frame().right : 200.0);
	if (min_width < 200.0)
		min_width = 200.0;
	the_window->SetSizeLimits(
		min_width,
		32767.0,
		Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
		32767.0);

	the_window->Unlock();
}
void
ActivityView::_DrawHistory(bool drawBackground)
{
	_UpdateOffscreenBitmap();

	BView* view = this;
	if (fOffscreen != NULL) {
		fOffscreen->Lock();
		view = _OffscreenView();
	}

	BRect frame = _HistoryFrame();
	BRect outerFrame = frame.InsetByCopy(-2, -2);

	// draw the outer frame
	uint32 flags = 0;
	if (!drawBackground)
		flags |= BControlLook::B_BLEND_FRAME;
	be_control_look->DrawTextControlBorder(this, outerFrame,
		outerFrame, fLegendBackgroundColor, flags);

	// convert to offscreen view if necessary
	if (view != this)
		frame.OffsetTo(B_ORIGIN);

	view->SetLowColor(fHistoryBackgroundColor);
	view->FillRect(frame, B_SOLID_LOW);

	uint32 step = 2;
	uint32 resolution = fDrawResolution;
	if (fDrawResolution > 1) {
		step = 1;
		resolution--;
	}

	uint32 width = frame.IntegerWidth() - 10;
	uint32 steps = width / step;
	bigtime_t timeStep = RefreshInterval() * resolution;
	bigtime_t now = system_time();

	// Draw scale
	// TODO: add second markers?

	view->SetPenSize(1);

	rgb_color scaleColor = view->LowColor();
	uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
	if (average < 96)
		scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
	else
		scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);

	view->SetHighColor(scaleColor);
	view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
		BPoint(frame.right, frame.top + frame.Height() / 2));

	// Draw values

	view->SetPenSize(1.5);
	BAutolock _(fSourcesLock);

	for (uint32 i = fSources.CountItems(); i-- > 0;) {
		ViewHistory* viewValues = fViewValues.ItemAt(i);
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);

		viewValues->Update(values, steps, fDrawResolution, now, timeStep,
			RefreshInterval());

		uint32 x = viewValues->Start() * step;
		BShape shape;
		bool first = true;

		for (uint32 i = viewValues->Start(); i < steps; x += step, i++) {
			float y = _PositionForValue(source, values,
				viewValues->ValueAt(i));

			if (first) {
				shape.MoveTo(BPoint(x, y));
				first = false;
			} else
				shape.LineTo(BPoint(x, y));
		}

		view->SetHighColor(source->Color());
		view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
		view->MovePenTo(B_ORIGIN);
		view->StrokeShape(&shape);
	}

	// TODO: add marks when an app started or quit
	view->Sync();
	if (fOffscreen != NULL) {
		fOffscreen->Unlock();
		DrawBitmap(fOffscreen, outerFrame.LeftTop());
	}
}
Пример #21
0
AttribPolygon::AttribPolygon ()
: AttribView (BRect (0, 0, 148, 90), lstring (30, "Polygons"))
{
	SetViewColor (LightGrey);
	lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc'));
	AddChild (lSlid);
	fPenSize = 1;
	fType = POLYGON_OUTFILL;
	BBox *type = new BBox (BRect (18, 32, 130, 82), "type");
	type->SetLabel (lstring (311, "Type"));
	AddChild (type);

	BPoint pointArray[] = {
		BPoint ( 2,  8),
		BPoint ( 9,  2),
		BPoint (27, 12),
		BPoint (19, 28),
		BPoint (14, 20),
		BPoint ( 9, 26)
		};
	BPolygon *poly = new BPolygon();
	poly->AddPoints(pointArray, 6);

	BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL));
	BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL));
	picWindow->AddChild (bg);
	
	BPicture *p10;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p10 = bg->EndPicture();
	
	BPicture *p20;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p20 = bg->EndPicture();
	
	BPicture *p30;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (LightGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p30 = bg->EndPicture();

	BPicture *p11;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	bg->StrokePolygon (poly);
	p11 = bg->EndPicture();
	
	BPicture *p21;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->FillPolygon (poly, B_SOLID_LOW);
	p21 = bg->EndPicture();
	
	BPicture *p31;
	bg->BeginPicture (new BPicture);
	bg->SetLowColor (DarkGrey);
	bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW);
	bg->SetHighColor (Black);
	bg->SetLowColor (White);
	bg->StrokePolygon (poly);
	p31 = bg->EndPicture();
	
	delete poly;
	delete picWindow;
	
	SetViewColor (LightGrey);
	
	pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON);
	pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON);
	pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON);
	type->AddChild (pT1);
	type->AddChild (pT2);
	type->AddChild (pT3);
	pT1->SetValue (B_CONTROL_ON);
	fCurrentProperty = 0;
}
Пример #22
0
void CalcoloKtView::AttachedToWindow() 
{
    BBox *aBox;
    BRect aBoxRect;
	aBoxRect.Set(10, 10, 370, 340);
    
    aBox = new BBox(aBoxRect /*BRect(10, 10, 340, 312)*/, "Box_Calcolo_Kt",B_FOLLOW_NONE);
    aBox->SetLabel(LABEL_BOX_TITLE);
    AddChild(aBox);
    
    BRect txt1Rect;
	txt1Rect.Set(10, 20, 180, 30);
	
	txt1 = new BTextControl(txt1Rect, "txt1", "r/d :", "0.10", NULL, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_NAVIGABLE);
	txt1->SetDivider(30);
	txt1->SetTarget(this);
	aBox->AddChild(txt1);
	
	/*
	app_info  theInfo;
	entry_ref theRef;
	
	be_roster->GetRunningAppInfo(be_app->Team(), &theInfo);
	theRef = theInfo.ref;
	
	BEntry theEntry(&theRef);
	BPath path;
	char name[B_FILE_NAME_LENGTH];
	
	theEntry.GetName(name);
	theEntry.GetPath(&path);
	
	txt1->SetText(name);
	*/
	
	BRect txt2Rect;
	txt2Rect.Set(10, 40, 180, 50);
	
	txt2 = new BTextControl(txt2Rect, "txt2", "D/d :", "1.2", NULL, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_NAVIGABLE);
	txt2->SetDivider(30);
	txt2->SetTarget(this);
	aBox->AddChild(txt2);
	
	//txt2->SetText(path.Path());
	
	BRect lbl1Rect;
	lbl1Rect.Set(10, 70, 80, 80);
	
	lbl1 = new BStringView(lbl1Rect, "lbl1", "Kt : 0.00"); //, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW|B_NAVIGABLE);
	aBox->AddChild(lbl1);
	
	BRect buttonRect;
	buttonRect.Set(90, 60, 180, 80);

	BButton * button = new BButton(buttonRect, NULL, LABEL_BUTTON_CAPTION, new BMessage(COMMAND_CALC), B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE);
	button->SetTarget(this);
	aBox->AddChild(button);
	
	BRect drawRect;
	drawRect.Set(20, 100, 330, 310);
	
	BView *drawView;
	drawView = new BView(drawRect, "drawView", B_FOLLOW_ALL_SIDES, 0);
	drawView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	drawView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	aBox->AddChild(drawView);
	

	BRect iconRect;
	iconRect.Set(210, 20, 340, 80);
	
	BView *iconView;
	iconView = new BView(iconRect, "iconView", B_FOLLOW_ALL_SIDES, 0);
	iconView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	iconView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	aBox->AddChild(iconView);

}
Пример #23
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
BPicture* BmToolbarButton::CreatePicture( int32 mode, float width, 
														float height) {
	const char* label = mLabel.String();
	BmBitmapHandle* imageHandle 
		= TheResources->IconByName(BmString("Button_")<<mResourceName);
	BBitmap* image = imageHandle ? imageHandle->bitmap : NULL;
	// Calc icon/label positions
	BFont font( be_plain_font);
	bool showIcons = ThePrefs->GetBool( "ShowToolbarIcons", true);
	BmString labelMode = ThePrefs->GetString( "ShowToolbarLabel", "Bottom");
	float labelWidth 
		= (label && labelMode != "Hide") ? font.StringWidth( label) : 0;
	float labelHeight 
		= (label && labelMode != "Hide") 
				? TheResources->FontLineHeight( &font) 
				: 0;
	float iconWidth  = (showIcons && image) ? image->Bounds().Width()  : 0;
	float iconHeight = (showIcons && image) ? image->Bounds().Height() : 0;

	BPoint posIcon( 0,0), posLabel( 0,0);
	if (showIcons && (labelMode == "Left")) {
		// Icon + Label/Left
		float d = (width-(mNeedsLatch ? DIVLATCHW : 0)-DIVW-labelWidth-iconWidth)/2;
		posLabel = BPoint( d,(height-labelHeight)/2);
		posIcon = BPoint( d+DIVW+labelWidth+(mNeedsLatch ? DIVLATCHW : 0),
								(height-iconHeight)/2-1);
	} else if (showIcons && (labelMode == "Right")) {
		// Icon + Label/Right
		float d = (width-(mNeedsLatch ? DIVLATCHW : 0)-DIVW-labelWidth-iconWidth)/2;
		posLabel = BPoint( d+DIVW+iconWidth,(height-labelHeight)/2);
		posIcon = BPoint( d,(height-iconHeight)/2-1);
	} else if (showIcons && (labelMode == "Top")) {
		// Icon + Label/top
		float d = (height-DIVH-labelHeight-iconHeight)/2-2;
		posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, d);
		posIcon = BPoint( (width-iconWidth)/2-1,d+DIVH+labelHeight);
	} else if (showIcons && (labelMode == "Bottom")) {
		// Icon + Label/bottom
		float d = (height-DIVH-labelHeight-iconHeight)/2;
		posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, 
								 d+DIVH+iconHeight);
		posIcon = BPoint( (width-iconWidth)/2-1,d);
	} else if (!showIcons && labelMode != "Hide") {
		// Label only
		posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, 
								 (height-labelHeight)/2);
	} else if (showIcons && labelMode == "Hide") {
		// Icon only
		posIcon = BPoint( (width-iconWidth-(mNeedsLatch ? DIVLATCHW : 0))/2,
								(height-iconHeight)/2);
	}
	
	if (mNeedsLatch) {
		if (labelMode == "Hide")
			mLatchRect.Set( posIcon.x+iconWidth+2, 
								 posIcon.y+iconHeight/2-LATCHSZ/2, 
								 width, height);
		else
			mLatchRect.Set( posLabel.x+labelWidth+2, 
								 posLabel.y+labelHeight/2-LATCHSZ/2, 
								 width, height);
	} else
		mLatchRect.Set( -1, -1, -1, -1);

	// Draw
	BRect rect(0,0,width-1,height-1);
	BView* view = new BView( rect, NULL, B_FOLLOW_NONE, 0);
	BBitmap* drawImage = new BBitmap( rect, B_RGBA32, true);
	drawImage->AddChild( view);
	drawImage->Lock();
	BPicture* picture = new BPicture();
	view->BeginPicture( picture);
	view->SetHighColor( ui_color( B_PANEL_TEXT_COLOR));
	view->SetViewColor( B_TRANSPARENT_COLOR);
	view->SetLowColor( ui_color( B_PANEL_BACKGROUND_COLOR));

#ifndef __HAIKU__
	BmToolbar* toolbar = dynamic_cast<BmToolbar*>(Parent()->Parent());
	BBitmap* toolbarBackground = NULL;
	if (toolbar) {
		toolbarBackground = toolbar->BackgroundBitmap();
		if (toolbarBackground)
			view->DrawBitmap( toolbarBackground, Frame(), rect);
	}

	if (mode == STATE_ON) {
		rect.InsetBy( 1, 1);
		view->BeginLineArray(4);
		view->AddLine( rect.LeftBottom(), rect.LeftTop(), 
							BmWeakenColor(B_SHADOW_COLOR, BeShadowMod));
		view->AddLine( rect.LeftTop(), rect.RightTop(), 
							BmWeakenColor(B_SHADOW_COLOR, BeShadowMod));
		view->AddLine( rect.LeftBottom(), rect.RightBottom(), 
							ui_color( B_SHINE_COLOR));
		view->AddLine( rect.RightBottom(), rect.RightTop(), 
							ui_color( B_SHINE_COLOR));
		view->EndLineArray();
	}
#endif

	// Draw Icon
	if (showIcons && image) {
		view->SetDrawingMode( B_OP_ALPHA);
		view->SetBlendingMode( B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
#ifdef __HAIKU__
		BBitmap disabledImage(image);
		if (mode == STATE_DISABLED) {
			image = &disabledImage;
			uint8* bits = (uint8*)image->Bits();
			uint32 width = image->Bounds().IntegerWidth() + 1;
			uint32 height = image->Bounds().IntegerWidth() + 1;
			uint32 bpr = image->BytesPerRow();
			for (uint32 y = 0; y < height; y++) {
				uint8* b = bits;
				for (uint32 x = 0; x < width; x++) {
					b[3] = (uint8)(((int)b[3] * 100) >> 8);
					b += 4;
				}
				bits += bpr;
			}
		}
Пример #24
0
void
ActivityView::_DrawHistory(bool drawBackground)
{
	_UpdateOffscreenBitmap();

	BView* view = this;
	if (fOffscreen != NULL) {
		fOffscreen->Lock();
		view = _OffscreenView();
	}

	BRect frame = _HistoryFrame();
	BRect outerFrame = frame.InsetByCopy(-2, -2);

	// draw the outer frame
	uint32 flags = 0;
	if (!drawBackground)
		flags |= BControlLook::B_BLEND_FRAME;
	be_control_look->DrawTextControlBorder(this, outerFrame,
		outerFrame, fLegendBackgroundColor, flags);

	// convert to offscreen view if necessary
	if (view != this)
		frame.OffsetTo(B_ORIGIN);

	view->SetLowColor(fHistoryBackgroundColor);
	view->FillRect(frame, B_SOLID_LOW);

	uint32 step = 2;
	uint32 resolution = fDrawResolution;
	if (fDrawResolution > 1) {
		step = 1;
		resolution--;
	}

	// We would get a negative number of steps which isn't a good idea.
	if (frame.IntegerWidth() <= 10)
		return;

	uint32 width = frame.IntegerWidth() - 10;
	uint32 steps = width / step;
	bigtime_t timeStep = RefreshInterval() * resolution;
	bigtime_t now = system_time();

	// Draw scale
	// TODO: add second markers?

	view->SetPenSize(1);

	rgb_color scaleColor = view->LowColor();
	uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
	if (average < 96)
		scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
	else
		scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);

	view->SetHighColor(scaleColor);
	view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
		BPoint(frame.right, frame.top + frame.Height() / 2));

	// Draw values

	view->SetPenSize(1.5);
	BAutolock _(fSourcesLock);

	for (uint32 i = fSources.CountItems(); i-- > 0;) {
		ViewHistory* viewValues = fViewValues.ItemAt(i);
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);

		viewValues->Update(values, steps, fDrawResolution, now, timeStep,
			RefreshInterval());

		if (viewValues->Start() >= (int32)steps - 1)
			continue;

		uint32 x = viewValues->Start() * step;

		bool first = true;

		view->SetHighColor(source->Color());
		view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
		view->MovePenTo(B_ORIGIN);

		try {
			view->BeginLineArray(steps - viewValues->Start() - 1);

			BPoint prev;

			for (uint32 j = viewValues->Start(); j < steps; x += step, j++) {
				float y = _PositionForValue(source, values,
					viewValues->ValueAt(j));

				if (first) {
					first = false;
				} else
					view->AddLine(prev, BPoint(x, y), source->Color());

				prev.Set(x, y);
			}

		} catch (std::bad_alloc) {
			// Not enough memory to allocate the line array.
			// TODO we could try to draw using the slower but less memory
			// consuming solution using StrokeLine.
		}

		view->EndLineArray();
	}

	// TODO: add marks when an app started or quit
	view->Sync();
	if (fOffscreen != NULL) {
		fOffscreen->Unlock();
		DrawBitmap(fOffscreen, outerFrame.LeftTop());
	}
}
Пример #25
0
// ToolboxWindow::InitWindow -- Initialization Commands here
void ToolboxWindow::InitWindow(void)
{
	BRect r;
	r = Bounds();
    // Add Controls
    
    // Toolbar
    //int ToolbarButtonMargin = 2;
    //int ToolbarButtonWidth = 22;
    //int ButtonGap = 1;
	
	// StringView Button
  	BRect BitmapFrame (BRect(0,0,23,23));
  	BPicture *tmpBPicture;
  	BPicture *tmpBPicture2;
  	BView    *tmpBPictureView = new BView(BitmapFrame, "tmpBPictureView",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
  	rgb_color toolbar_button_background = { 255, 255, 255, 0 };
  	
  	AddChild(tmpBPictureView);
  	
  	BBitmap *stringviewpicture = new BBitmap(BitmapFrame,B_RGB32);
	stringviewpicture->SetBits(stringviewicon,1728,0,B_RGB32);
  	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(stringviewpicture,BPoint(0,0));
  	tmpBPicture = tmpBPictureView->EndPicture();
  	
  	tmpBPictureView->RemoveSelf();
    AddChild(tmpBPictureView);
  	
  	BBitmap *stringviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
	stringviewpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32);
	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(stringviewpicture_state2,BPoint(0,0));
  	tmpBPicture2 = tmpBPictureView->EndPicture();
  		
 	btnBrieStringViewControl = new BPictureButton(BRect (1,0,24,23),"StringView",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_STRINGVIEWCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
 	 	
	tmpBPictureView->RemoveSelf();
	AddChild(tmpBPictureView);
    //--------------------------------------------------------------------//
        
    // TextView Button
    BBitmap *textviewpicture = new BBitmap(BitmapFrame,B_RGB32);
	textviewpicture->SetBits(brietextcontrol,1728,0,B_RGB32);
  	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(textviewpicture,BPoint(0,0));
  	tmpBPicture = tmpBPictureView->EndPicture();
  	
  	tmpBPictureView->RemoveSelf();
    AddChild(tmpBPictureView);
  	
  	BBitmap *textviewpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
	textviewpicture_state2->SetBits(brietextcontrolinverse,1728,0,B_RGB32);
	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(textviewpicture_state2,BPoint(0,0));
  	tmpBPicture2 = tmpBPictureView->EndPicture();
  	
  	btnBrieTextControl = new BPictureButton(BRect (26,0,50,23),"TextControl",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_TEXTCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
 	
	tmpBPictureView->RemoveSelf();
	AddChild(tmpBPictureView);
	//--------------------------------------------------------------------//
	
	// Button Button
	BBitmap *buttonpicture = new BBitmap(BitmapFrame,B_RGB32);
	buttonpicture->SetBits(stringviewicon,1728,0,B_RGB32);
  	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(buttonpicture,BPoint(0,0));
  	tmpBPicture = tmpBPictureView->EndPicture();
  	
  	tmpBPictureView->RemoveSelf();
    AddChild(tmpBPictureView);
  	
  	BBitmap *buttonpicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
	buttonpicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32);
	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(buttonpicture_state2,BPoint(0,0));
  	tmpBPicture2 = tmpBPictureView->EndPicture();
  		
 	btnBrieButtonControl = new BPictureButton(BRect (1,25,24,48),
 							  "Button",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_BUTTONCONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
 	
	tmpBPictureView->RemoveSelf();
	AddChild(tmpBPictureView);
    //--------------------------------------------------------------------//
    
    // Picture Button
    BBitmap *picturepicture = new BBitmap(BitmapFrame,B_RGB32);
	picturepicture->SetBits(stringviewicon,1728,0,B_RGB32);
  	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(picturepicture,BPoint(0,0));
  	tmpBPicture = tmpBPictureView->EndPicture();
  	
  	tmpBPictureView->RemoveSelf();
    AddChild(tmpBPictureView);
  	
  	BBitmap *picturepicture_state2 = new BBitmap(BitmapFrame,B_RGB32);
	picturepicture_state2->SetBits(stringviewiconinverse,1728,0,B_RGB32);
	tmpBPictureView->SetLowColor(toolbar_button_background);
  	tmpBPictureView->BeginPicture(new BPicture);
  	tmpBPictureView->DrawBitmap(picturepicture_state2,BPoint(0,0));
  	tmpBPicture2 = tmpBPictureView->EndPicture();
  		
 	btnBriePictureControl = new BPictureButton(BRect (26,25,50,48),
 							  "TextControl",tmpBPicture,tmpBPicture2, new BMessage(TOOLBOX_BTN_PICTURECONTROL),B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);
 	
	tmpBPictureView->RemoveSelf();
	AddChild(tmpBPictureView);
	//--------------------------------------------------------------------//
	
	
    AddChild(btnBriePictureControl);
    AddChild(btnBrieButtonControl);
    AddChild(btnBrieTextControl);
    AddChild(btnBrieStringViewControl);
	
	// Add the Drawing View
	AddChild(ptrToolboxWindowView = new ToolboxWindowView(r));
}
Пример #26
0
void BochsView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
{
  backing_store->Lock();
  backing_view->SetLowColor(r,g,b,a);
  backing_store->Unlock();
}
Пример #27
0
void
PBox::AttachedToWindow(){
	
	//calc font height (for nice control size)	
	font_height fontHeight;
	be_bold_font->GetHeight(&fontHeight);
	fFontHeight = fontHeight.descent + fontHeight.leading + fontHeight.ascent;


	BRect frame = Bounds();
	frame.InsetBy(5,5);
	
	BRect temp = frame;
	temp.bottom = temp.top + 40;	
	
	SettingsTextView *testo1=new SettingsTextView(temp,"testo",_T("Settings"));
	AddChild(testo1);
	frame.top +=40;
	//BSeparator *sep=new BSeparator(frame,"sep","cippa");
	//sep->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	//AddChild(sep);

	//frame.InsetBy(kEdgeOffset, kEdgeOffset);
	//frame.top += fFontHeight; //some space

#if SCROLLBAR
	frame.right -= B_V_SCROLL_BAR_WIDTH + 2;
#endif
	
			BView *view = new BView(frame, "", B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
						
#if B_BEOS_VERSION > B_BEOS_VERSION_5
			view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
			view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
			view->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
#else
			view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
			view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
			view->SetHighColor(0, 0, 0, 0);
#endif

	
			float settings_height = BuildGUI(fTemplate, fData, view);
					

			view->ResizeTo( view->Bounds().Width(), settings_height);
#if	SCROLLBAR			


			BScrollView * scroller = new BScrollView(
				"scroller", view, B_FOLLOW_ALL,
				0, false, true
			);
			float scroll_height = scroller->Bounds().Height();
			float diff = settings_height - scroll_height;
			if ( diff < 0 ) diff = 0;
			
			scroller->ScrollBar(B_VERTICAL)->SetRange(0, diff);

			view = scroller;
#endif
			fPrefView = view;

			AddChild(fPrefView);
			
			testo1->SetText(fTemplate.FindString("name"));
}