示例#1
0
static void testPattern(BView *view, BRect frame)
{
	frame.InsetBy(2, 2);
	int x = frame.IntegerWidth() / 3;
	frame.right = frame.left + x - 2;
		// -2 for an empty pixel row between 
		// filled rectangles

	view->SetLowColor(kGreen);
	view->SetHighColor(kRed);
	
	view->FillRect(frame, B_SOLID_HIGH);
	
	frame.OffsetBy(x, 0);
	view->FillRect(frame, B_MIXED_COLORS);
	
	frame.OffsetBy(x, 0);
	view->FillRect(frame, B_SOLID_LOW);
}
示例#2
0
ModulesView::ModulesView(BRect rect, const char* name,
		ScreenSaverSettings& settings)
	:
	BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
	fSettings(settings),
	fSaverRunner(NULL),
	fSettingsView(NULL),
	fScreenSaverTestTeam(-1)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fTestButton = new BButton(rect, "TestButton", B_TRANSLATE("Test"),
		new BMessage(kMsgTestSaver), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	float width, height;
	fTestButton->GetPreferredSize(&width, &height);
	fTestButton->ResizeTo(width + 16, height);
	fTestButton->MoveTo(8, rect.bottom - 8 - height);
	AddChild(fTestButton);

	rect = fTestButton->Frame();
	rect.OffsetBy(fTestButton->Bounds().Width() + 8, 0);
	fAddButton = new BButton(rect, "AddButton",
		B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddSaver),
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	AddChild(fAddButton);

	rect = Bounds().InsetByCopy(8 + kPreviewMonitorGap, 12);
	rect.right = fAddButton->Frame().right - kPreviewMonitorGap;
	rect.bottom = rect.top + 3 * rect.Width() / 4;
		// 4:3 monitor

	fPreviewView = new PreviewView(rect, "preview");
	AddChild(fPreviewView);

	rect.left = 8;
	rect.right -= B_V_SCROLL_BAR_WIDTH + 2 - kPreviewMonitorGap;
		// scroll view border
	rect.top = rect.bottom + 14;
	rect.bottom = fTestButton->Frame().top - 10;
	fListView = new BListView(rect, "SaversListView", B_SINGLE_SELECTION_LIST,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
	fListView->SetSelectionMessage(new BMessage(kMsgSaverSelected));
	AddChild(new BScrollView("scroll_list", fListView,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 0, false, true));

	rect = Bounds().InsetByCopy(8, 8);
	rect.left = fAddButton->Frame().right + 8;
	AddChild(fSettingsBox = new BBox(rect, "SettingsBox", B_FOLLOW_ALL,
		B_WILL_DRAW));
	fSettingsBox->SetLabel(B_TRANSLATE("Screensaver settings"));

	PopulateScreenSaverList();
	fFilePanel = new BFilePanel();
}
void
WindowArea::DoGroupLayout()
{
	SATWindow* parentWindow = fWindowLayerOrder.ItemAt(0);
	if (parentWindow == NULL)
		return;

	BRect frame = parentWindow->CompleteWindowFrame();
	// Make it also work for solver which don't support negative variables
	frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);

	// adjust window size soft constraints
	fWidthConstraint->SetRightSide(frame.Width());
	fHeightConstraint->SetRightSide(frame.Height());

	LinearSpec* linearSpec = fGroup->GetLinearSpec();
	Constraint* leftConstraint = linearSpec->AddConstraint(1.0, LeftVar(),
		kEQ, frame.left);
	Constraint* topConstraint = linearSpec->AddConstraint(1.0, TopVar(), kEQ,
		frame.top);

	// give soft constraints a high penalty
	fWidthConstraint->SetPenaltyNeg(kHighPenalty);
	fWidthConstraint->SetPenaltyPos(kHighPenalty);
	fHeightConstraint->SetPenaltyNeg(kHighPenalty);
	fHeightConstraint->SetPenaltyPos(kHighPenalty);

	// After we set the new parameter solve and apply the new layout.
	ResultType result;
	for (int32 tries = 0; tries < 15; tries++) {
		result = fGroup->GetLinearSpec()->Solve();
		if (result == kInfeasible) {
			debug_printf("can't solve constraints!\n");
			break;
		}
		if (result == kOptimal) {
			const WindowAreaList& areas = fGroup->GetAreaList();
			for (int32 i = 0; i < areas.CountItems(); i++) {
				WindowArea* area = areas.ItemAt(i);
				area->_MoveToSAT(parentWindow);
			}
			break;
		}
	}

	// set penalties back to normal
	fWidthConstraint->SetPenaltyNeg(kExtentPenalty);
	fWidthConstraint->SetPenaltyPos(kExtentPenalty);
	fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
	fHeightConstraint->SetPenaltyPos(kExtentPenalty);

	linearSpec->RemoveConstraint(leftConstraint);
	linearSpec->RemoveConstraint(topConstraint);
}
示例#4
0
void KeyItem::DrawMods(BView *view, BRect r, int32 mod)
{
	float w = -(r.Width()+2);
	if (mod & B_SHIFT_KEY){
		DrawKey(view, r, "S");
		r.OffsetBy(w,0);
	}
	if (mod & B_CONTROL_KEY){
		DrawKey(view, r, "C");
		r.OffsetBy(w,0);
	}
	if (mod & B_OPTION_KEY){
		DrawKey(view, r, "O");
		r.OffsetBy(w,0);
	}
	if ((mod & B_COMMAND_KEY)){
		DrawKey(view, r, "A");
		r.OffsetBy(w,0);
	}
}
示例#5
0
float KeyControl::DrawMods(BRect r, int32 mod)
{
	float w = (r.Width()+2);
	if ((mod & B_COMMAND_KEY)){
		DrawKey(r, "A");
		r.OffsetBy(w,0);
	}
	if (mod & B_OPTION_KEY){
		DrawKey(r, "O");
		r.OffsetBy(w,0);
	}
	if (mod & B_CONTROL_KEY){
		DrawKey(r, "C");
		r.OffsetBy(w,0);
	}
	if (mod & B_SHIFT_KEY){
		DrawKey(r, "S");
		r.OffsetBy(w,0);
	}
	return r.left+4;
}
示例#6
0
void
GroupCookie::DoGroupLayout(SATWindow* triggerWindow)
{
	if (!fSATGroup.Get())
		return;

	BRect frame = triggerWindow->CompleteWindowFrame();
	// Make it also work for solver which don't support negative variables
	frame.OffsetBy(kMakePositiveOffset, kMakePositiveOffset);

	// adjust window size soft constraints
	fWidthConstraint->SetRightSide(frame.Width());
	fHeightConstraint->SetRightSide(frame.Height());

	LinearSpec* linearSpec = fSATGroup->GetLinearSpec();
	fLeftConstraint = linearSpec->AddConstraint(1.0, fLeftBorder, kEQ,
		frame.left);
	fTopConstraint  = linearSpec->AddConstraint(1.0, fTopBorder, kEQ,
		frame.top);

	// adjust window position soft constraints
	// (a bit more penalty for them so they take precedence)
	fWidthConstraint->SetPenaltyNeg(-1);
	fWidthConstraint->SetPenaltyPos(-1);
	fHeightConstraint->SetPenaltyNeg(-1);
	fHeightConstraint->SetPenaltyPos(-1);

	// After we set the new parameter solve and apply the new layout.
	ResultType result;
	for (int32 tries = 0; tries < 15; tries++) {
		result = fSATGroup->GetLinearSpec()->Solve();
		if (result == kInfeasible) {
			debug_printf("can't solve constraints!\n");
			break;
		}
		if (result == kOptimal) {
			fSATGroup->AdjustWindows(triggerWindow);
			_UpdateWindowSize(frame);
			break;
		}
	}

	// set penalties back to normal
	fWidthConstraint->SetPenaltyNeg(kExtentPenalty);
	fWidthConstraint->SetPenaltyPos(kExtentPenalty);
	fHeightConstraint->SetPenaltyNeg(kExtentPenalty);
	fHeightConstraint->SetPenaltyPos(kExtentPenalty);

	linearSpec->RemoveConstraint(fLeftConstraint);
	fLeftConstraint = NULL;
	linearSpec->RemoveConstraint(fTopConstraint);
	fTopConstraint = NULL;
}
示例#7
0
文件: URLView.cpp 项目: bbjimmy/YAB
BRect URLView::GetTextRect() {
	// This function will return a BRect that contains only the text
	// and the underline, so the mouse can change and the link will
	// be activated only when the mouse is over the text itself, not
	// just within the view.
	
	// Note:  We'll use bounding boxes, because they are the most
	//        accurate, and since the user is interacting with the
	//        view, off-by-one-pixel errors look bad.
	const char *textArray[1];
	textArray[0] = Text();
	
	escapement_delta delta;
	delta.nonspace = 0;
	delta.space = 0;
	escapement_delta escapements[1];
	escapements[0] = delta;
	
	BRect returnMe;
	BRect rectArray[1];
	rectArray[0] = returnMe;
	
	BFont font;
	GetFont( &font );
	font.GetBoundingBoxesForStrings( textArray, 1, B_SCREEN_METRIC, escapements, rectArray );

	BRect frame = Frame();
	frame.OffsetTo( B_ORIGIN );
	returnMe = rectArray[0];
	
	// Get the height of the current font.
	font_height height;
	GetFontHeight( &height );
	float descent = height.descent;
	
	// Account for rounding of the floats when drawn to avoid
	// one-pixel-off errors.
	float lowerBound = 0;
	if( (((int) descent) * 2) != ((int) (descent * 2)) )
		lowerBound = 1;
	
	// Adjust the bounding box to reflect where the text is in the view.
	returnMe.bottom += 1;
	returnMe.OffsetTo( B_ORIGIN );
	float rectHeight = returnMe.Height();
	returnMe.bottom = frame.bottom - descent;
	returnMe.top = returnMe.bottom - rectHeight;
	returnMe.bottom += 1 + underlineThickness;
	returnMe.OffsetBy( 0.0, -(1 + lowerBound) );

	return returnMe;
}
示例#8
0
void 
TTimeWindow::_InitWindow()
{
	SetPulseRate(500000);

	fDateTimeView = new DateTimeView(Bounds());
	
	BRect bounds = fDateTimeView->Bounds();
	fTimeZoneView = new TimeZoneView(bounds);

	fBaseView = new TTimeBaseView(bounds, "baseView");
	AddChild(fBaseView);
	
	fBaseView->StartWatchingAll(fDateTimeView);
	fBaseView->StartWatchingAll(fTimeZoneView);

	bounds.OffsetBy(10.0, 10.0);
	BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
		"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
	
	BTab *tab = new BTab();
	tabView->AddTab(fDateTimeView, tab);
	tab->SetLabel("Date & Time");

	tab = new BTab();
	tabView->AddTab(fTimeZoneView, tab);
	tab->SetLabel("Time zone");

	fBaseView->AddChild(tabView);
	tabView->ResizeBy(0.0, tabView->TabHeight());

	BRect rect = Bounds();

	rect.left = 10;
	rect.top = rect.bottom - 10;

	fRevertButton = new BButton(rect, "revert", "Revert",
		new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	
	fRevertButton->ResizeToPreferred();
	fRevertButton->SetEnabled(false);
	float buttonHeight = fRevertButton->Bounds().Height();
	fRevertButton->MoveBy(0, -buttonHeight);
	fBaseView->AddChild(fRevertButton);
	fRevertButton->SetTarget(this);

	fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0, 
		tabView->Bounds().Height() + buttonHeight + 30.0);

	ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
}
示例#9
0
BRect SeqToolBarView::DraggingRectFor(BPoint pt, int32* lIndex, int32* rIndex)
{
	if (mCachedData.size() < 1) {
		if (lIndex) *lIndex = -1;
		if (rIndex) *rIndex = 0;
		return Bounds();
	}
	BRect			bounds(Bounds() );
	float			x  = 0;
	float			IN_BETWEEN = 0.20;

	for (uint32 k = 0; k < mCachedData.size(); k++) {
		BRect		b = mCachedData[k].Bounds();
		float		inBetween = b.Width() * IN_BETWEEN;
		float		pad = 0;
		b.OffsetBy(BPoint(x, 0) );
		/* Special case:  If we're on the last tool, the drag bounds
		 * extend to the end of the view.
		 */
		if (k >= mCachedData.size() - 1) {
			b.right = bounds.right;
			pad = LAST_BUTTON_PAD;
		}

		if (b.Contains(pt)) {
			if (lIndex && rIndex) *lIndex = *rIndex = (int32)k;
			BRect		ans(b);
			if (pt.x <= b.left + inBetween) {
				if (lIndex) *lIndex = *lIndex -1;
				ans.right = ans.left + inBetween;
				if (k > 0) {
					float	f = (mCachedData[k-1].Bounds().Width()) * IN_BETWEEN;
					ans.left -= (mSpace + f);
				}
			} else if (pt.x >= b.right - inBetween - pad) {
				if (rIndex) *rIndex = *rIndex + 1;
				ans.left = ans.right - inBetween - pad;
				if (k != mCachedData.size() - 1) {
					float	f = (mCachedData[k+1].Bounds().Width()) * IN_BETWEEN;
					ans.right += mSpace + f;
				}
			}
			return ans;
		}
		x = b.right + 1;
		x += mSpace;
		if (x > pt.x) return BRect(-1, -1, -1, -1);
	}
	return BRect(-1, -1, -1, -1);
}
示例#10
0
void DetailsBuilder::AddView(BView* view)
{
	if (view != NULL) {
		fDetails->AddChild(view);
		view->ResizeToPreferred();
		
		fBounds.OffsetBy(0, view->Bounds().Height()+1);
		
		BControl* control = dynamic_cast<BControl*>(view);
		if (control != NULL) {
			control->SetTarget(fParent);
		}
	}
}
示例#11
0
void
ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
{
	const float lineWidth = 3;
	BRect line(Bounds());
	line.left += 3;
	line.right -= 3;
	line.top = rect.top;
	line.bottom = line.top + lineWidth - 1;
	BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT,
		B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
	view->AddChild(separatorLine);
	rect.OffsetBy(0, kLineDistance + lineWidth);
}
示例#12
0
static void testSetPenSize2(BView *view, BRect frame)
{
	// test if pen size is scaled too
	frame.InsetBy(2, 2);
	frame.OffsetBy(0, 5);
	view->SetPenSize(4);
	view->StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.right, frame.top));
	view->SetScale(0.5);
	view->StrokeLine(BPoint(frame.left + 2, frame.bottom), BPoint(frame.right + 2, frame.bottom));	
	
	// black line from left to right, 4 pixel size
	// below black line with half the length of the first one
	// and 2 pixel size
}
示例#13
0
//===========================PrefsWindow======================================
PrefsWindow::PrefsWindow(BRect frame, BMessenger *messenger) 
				:	BWindow(frame, "Preferences", B_FLOATING_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_ASYNCHRONOUS_CONTROLS),
					m_msgr(messenger),
					m_colourPrefsChanged(false),
					m_fontSizeChanged(false),
					m_toolbarChanged(false)
{	
	SetFeel(B_NORMAL_WINDOW_FEEL);
	
	m_parent = new BView(Bounds(), "parent", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	m_parent->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(m_parent);
	
	prefsLock.Lock();	
	BFont font(be_fixed_font);
	float fontSize = 10.0f;
	if (preferences.FindFloat(K_FONT_SIZE, &fontSize) == B_OK)
		font.SetSize(fontSize);
	prefsLock.Unlock();
		
	float prefsListWidth = 80.0f;		
	BRect prefsListFrame(10.0f, 10.0f, 10.0f + prefsListWidth, Bounds().bottom - 10.0f);	
	PrefsListView *prefsListView = new PrefsListView(prefsListFrame, m_parent);
	BScrollView *prefsListScroll = new BScrollView("ScrollView", prefsListView, B_FOLLOW_LEFT | B_FOLLOW_TOP,B_WILL_DRAW,false,false);
	m_parent->AddChild(prefsListScroll);
		
	float 	bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f
			;
	
	BRect okButtonFrame(Bounds().right - bspacing - bwidth, Bounds().bottom - bspacing - bheight, Bounds().right - bspacing,Bounds().bottom - bspacing);
	BButton *okButton = new BButton(okButtonFrame, "okButton", "Ok", new BMessage(PrefsConstants::K_PREFS_VIEW_OK));
	m_parent->AddChild(okButton);
	okButton->MakeDefault(true);
	
	BRect cancelButtonFrame = okButtonFrame;
	cancelButtonFrame.OffsetBy(-(bwidth + 2.0f * bspacing), 0.0f);
	BButton *cancelButton = new BButton(cancelButtonFrame,"cancelButton","Cancel",new BMessage(PrefsConstants::K_PREFS_VIEW_CANCEL));
	m_parent->AddChild(cancelButton);
	
	float respiteWidth = 41.0f;
	BRect boxRect(10.0f + prefsListWidth + 10.0f , 2.0f, Bounds().right - 7.0f , Bounds().bottom - 10.0f - respiteWidth);	
	prefsListView->AddItem(new PrefsListItem(constructGeneralBox(boxRect), m_parent, "General"));
	prefsListView->AddItem(new PrefsListItem(constructCommandBox(boxRect), m_parent, "Commands"));
	prefsListView->AddItem(new PrefsListItem(constructColourBox(boxRect), m_parent, "TexView"));
	prefsListView->AddItem(new PrefsListItem(constructToolbarBox(boxRect), m_parent, "Toolbars"));	
	prefsListView->Select(0);
	prefsListView->MakeFocus(true);	
}
示例#14
0
pbView::pbView(BRect r) : mobileView(r, "pbView") {
	caption->SetText(_("Phonebooks summary"));

	BFont font(be_plain_font);
	float maxw, totalw = 0;
	BRect r = this->MyBounds();
	r.InsetBy(10,15);
	r.right -= B_V_SCROLL_BAR_WIDTH;
	r.bottom -= 100;

	// add column list
	CLVContainerView *containerView;
	list = new ColumnListView(r, &containerView, NULL, B_FOLLOW_TOP_BOTTOM|B_FOLLOW_LEFT,
		B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, B_SINGLE_SELECTION_LIST, false, true, true, true,
		B_FANCY_BORDER);
	maxw = font.StringWidth(_("Folder"))*5+20; totalw += maxw;
	list->AddColumn(new CLVColumn(_("Folder"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
	maxw = font.StringWidth(_("Unique"))*2+20; totalw += maxw;
	list->AddColumn(new CLVColumn(_("Unique"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
	maxw = font.StringWidth(_("Used"))*2+20; totalw += maxw;
	list->AddColumn(new CLVColumn(_("Used"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
	maxw = font.StringWidth(_("Total"))*2+20; totalw += maxw;
	list->AddColumn(new CLVColumn(_("Total"), maxw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
	maxw = font.StringWidth(_("Used (%)"))+20;
	list->AddColumn(new CLVColumn(_("Used (%)"), r.right-B_V_SCROLL_BAR_WIDTH-4-totalw, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
	list->SetSortFunction(CLVEasyItem::CompareItems);
	this->AddChild(containerView);
	list->SetInvocationMessage(new BMessage(PBLIST_INV));
	list->SetSelectionMessage(new BMessage(PBLIST_SEL));

	r = this->MyBounds();
	r.InsetBy(10,15);
	r.top = r.bottom - font.Size()*4 - 30;
	r.bottom = r.top + font.Size()*2;
	this->AddChild(progress = new BStatusBar(r, "pbStatusBar"));
	progress->SetResizingMode(B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM);
	progress->SetMaxValue(100);
	progress->Hide();

	r = this->MyBounds();
	r.InsetBy(20,20);
	BRect s;
	s = r; s.top = s.bottom - font.Size()*2;
	float len = s.Width()/5;	
	s.right = s.left + len - 10;
	this->AddChild(refresh = new BButton(s, "pbRefresh", _("Refresh"), new BMessage(PBREFRESH), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM));
	s.OffsetBy(len*4,0);
	this->AddChild(refresh = new BButton(s, "pbExport", _("Export"), new BMessage(PBEXPORT), B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM));
}
示例#15
0
DesktopSettingsView::DesktopSettingsView(BRect rect)
	: SettingsView(rect, "DesktopSettingsView")
{
	rect.OffsetTo(B_ORIGIN);
	fShowDisksIconRadioButton = new BRadioButton(rect, "", "Show Disks icon",
		new BMessage(kShowDisksIconChanged));
	fShowDisksIconRadioButton->ResizeToPreferred();
	AddChild(fShowDisksIconRadioButton);

	const float itemSpacing = fShowDisksIconRadioButton->Bounds().Height() + kItemExtraSpacing;
	rect.OffsetBy(0, itemSpacing);

	fMountVolumesOntoDesktopRadioButton = new BRadioButton(rect, "",
		"Show volumes on Desktop", new BMessage(kVolumesOnDesktopChanged));
	AddChild(fMountVolumesOntoDesktopRadioButton);
	fMountVolumesOntoDesktopRadioButton->ResizeToPreferred();

	rect.OffsetBy(20, itemSpacing);

	fMountSharedVolumesOntoDesktopCheckBox = new BCheckBox(rect, "",
		"Show shared volumes on Desktop", new BMessage(kVolumesOnDesktopChanged));
	AddChild(fMountSharedVolumesOntoDesktopCheckBox);
	fMountSharedVolumesOntoDesktopCheckBox->ResizeToPreferred();

	rect.OffsetBy(-20, itemSpacing);

	rect = Bounds();
	rect.top = rect.bottom;
	fMountButton = new BButton(rect, "", "Mount settings" B_UTF8_ELLIPSIS,
		new BMessage(kRunAutomounterSettings), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fMountButton->ResizeToPreferred();
	fMountButton->MoveBy(0, -fMountButton->Bounds().Height());
	AddChild(fMountButton);

	fMountButton->SetTarget(be_app);
}
示例#16
0
void
_MediaSlider_::UpdateThumb(
	bool	force)
{
	fBitmap->Lock();

	BRect bounds = fOffscreenView->Bounds();

	bounds.left += 2.0;
	bounds.right -= kThumbWidth + 3.0;

	BRect thumbRect = fThumbRect;
	thumbRect.OffsetTo(bounds.left + (bounds.right * ((float)fCurTime / (float)fTotalTime)), thumbRect.top);

	if ((!force) && (thumbRect == fThumbRect)) {
		fBitmap->Unlock();
		return;
	}

	fOffscreenView->SetLowColor(kSliderBackgroundColor);
	fOffscreenView->FillRect(fThumbRect, B_SOLID_LOW);

	BRect drawRect = fThumbRect | thumbRect;
	fThumbRect = thumbRect;

	fOffscreenView->SetHighColor(kBlack);
	fOffscreenView->StrokeRect(thumbRect, B_SOLID_HIGH);
	thumbRect.InsetBy(1.0, 1.0);

	fOffscreenView->BeginLineArray(4);
	fOffscreenView->AddLine(thumbRect.RightTop(), thumbRect.RightBottom(), kThumbDarkColor);
	fOffscreenView->AddLine(thumbRect.RightBottom(), thumbRect.LeftBottom(), kThumbDarkColor);
	fOffscreenView->AddLine(thumbRect.LeftBottom(), thumbRect.LeftTop(), kThumbLightColor);
	fOffscreenView->AddLine(thumbRect.LeftTop(), thumbRect.RightTop(), kThumbLightColor);
	fOffscreenView->EndLineArray();	
	thumbRect.InsetBy(1.0, 1.0);

	fOffscreenView->SetHighColor(kThumbBackgroundColor);
	fOffscreenView->FillRect(thumbRect, B_SOLID_HIGH);

	fOffscreenView->Sync();
	fBitmap->Unlock();

	BPoint	drawLoc(0.0, (Bounds().Height() - kSliderHeight) / 2);
	BRect	dstRect = drawRect;
	dstRect.OffsetBy(drawLoc);
	DrawBitmap(fBitmap, drawRect, dstRect);
}
示例#17
0
AnalogView::AnalogView(BRect r, int cpu)
		   : _inherited(r, "", B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED)
{
	BDragger*	dragger; 
    BRect		rt = r; 
    	
	InitObject(r, cpu);

	rt.OffsetTo(B_ORIGIN);
	rt.left = rt.right - 7;
	rt.top = rt.bottom - 7;
	rt.OffsetBy(-1, -1);
	dragger = new BDragger(rt, (BView *)this ); 
	AddChild(dragger); 

}
示例#18
0
void TIconMenu::DrawContent()
{
	if (iconLabel) {
		Menu()->SetDrawingMode(B_OP_OVER);

		float width, height;

		Menu()->GetPreferredSize(&width, &height);

		BRect destBounds = bounds;
		destBounds.OffsetBy(8.0, ((height - bounds.Height()) * 0.5) - 1);

		// Scaling the icon is left as an exercise for the reader :)
		Menu()->DrawBitmap(iconLabel, bounds, destBounds);
	} else
		BMenuItem::DrawContent();
}
示例#19
0
void
MidiEventMeter::Draw(BView* view)
{
	const rgb_color METER_BLACK = { 0, 0, 0, 255 };
	const rgb_color METER_GREY = { 180, 180, 180, 255 };
	const rgb_color METER_GREEN = { 0, 255, 0, 255 };

	view->PushState();

	// draw the frame
	BPoint lt = METER_BOUNDS.LeftTop();
	BPoint rb = METER_BOUNDS.RightBottom();
	view->BeginLineArray(4);
	view->AddLine(BPoint(lt.x, lt.y), BPoint(rb.x - 1, lt.y), METER_BLACK);
	view->AddLine(BPoint(rb.x, lt.y), BPoint(rb.x, rb.y - 1), METER_BLACK);
	view->AddLine(BPoint(rb.x, rb.y), BPoint(lt.x + 1, rb.y), METER_BLACK);
	view->AddLine(BPoint(lt.x, rb.y), BPoint(lt.x, lt.y + 1), METER_BLACK);
	view->EndLineArray();
	
	// draw the cells
	BRect cell = METER_BOUNDS;
	cell.InsetBy(1, 1);
	cell.bottom = cell.top + (cell.Height() + 1) / 5;
	cell.bottom--;

	const float kTintArray[] =
		{B_DARKEN_4_TINT,
		 B_DARKEN_3_TINT,
		 B_DARKEN_2_TINT,
		 B_DARKEN_1_TINT,
		 B_NO_TINT};
	
	for (int32 i = 4; i >= 0; i--) {
		rgb_color color;
		if (fMeterLevel > i) {
			color = tint_color(METER_GREEN, kTintArray[i]);
		} else {
			color = METER_GREY;
		}
		view->SetHighColor(color);
		view->FillRect(cell);
		cell.OffsetBy(0, cell.Height() + 1);
	}
		
	view->PopState();
}
示例#20
0
TrashSettingsView::TrashSettingsView(BRect rect)
	: SettingsView(rect, "TrashSettingsView")
{
	rect.OffsetTo(B_ORIGIN);
	fDontMoveFilesToTrashCheckBox = new BCheckBox(rect, "", "Don't move files to Trash",
			new BMessage(kDontMoveFilesToTrashChanged));
	fDontMoveFilesToTrashCheckBox->ResizeToPreferred();
	AddChild(fDontMoveFilesToTrashCheckBox);

	rect = fDontMoveFilesToTrashCheckBox->Frame();
	rect.OffsetBy(0, fDontMoveFilesToTrashCheckBox->Bounds().Height() + kItemExtraSpacing);

	fAskBeforeDeleteFileCheckBox = new BCheckBox(rect, "", "Ask before delete",
			new BMessage(kAskBeforeDeleteFileChanged));
	fAskBeforeDeleteFileCheckBox->ResizeToPreferred();
	AddChild(fAskBeforeDeleteFileCheckBox);
}
示例#21
0
void IconBar::AttachedToWindow(void) {
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 	SetHighColor(0, 0, 0, 255);

	BDirectory dir(fAppPath.String());
 	entry_ref ref;
 	BRect iconRect = Bounds();

	fIconSize = (int16)(iconRect.Height() - (fPadding * 2));
 	
	iconRect.bottom -= fPadding;
	iconRect.top += fPadding;
 	iconRect.right = fIconSize;
 	iconRect.left += fPadding;
 	
 	fIconSize -= fPadding * 4;
	
 	while (dir.GetNextRef(&ref) == B_OK) {
 		BPath path(&ref);
 		BNode node(&ref);
 		BBitmap *icon = ReadNodeIcon(path.Path(), fIconSize, true);

		int32 length = -1;
		char *desc = ReadAttribute(node, "im_client:description", &length);
		if ((length < 1) || (desc == NULL)) desc = strdup(ref.name);
		
		BMessage *msg = new BMessage(kClickMsg);
		msg->AddRef("app_ref", &ref);
				
 		ImageButton *button = new ImageButton(iconRect, ref.name, msg,
 			B_FOLLOW_NONE, B_WILL_DRAW, icon, NULL);
 		fBubbles->SetHelp(button, desc);
 		AddChild(button);
 		
 		button->SetTarget(this);
 		
 		fButtons.push_back(button);
 		
 		free(desc);

 		
 		iconRect.OffsetBy(iconRect.Width() + fPadding, 0);
 	};
};
示例#22
0
/***********************************************************
 * AddRuler
 ***********************************************************/
void
HWrapTextView::AddRuler()
{
	if(!fRulerView && Parent())
	{
		ResizeBy(0,-(RULER_HEIGHT+1));
		MoveBy(0,RULER_HEIGHT+1);
		
		BRect rect = Bounds();
		rect = Parent()->Bounds();
		rect.top += 2;
		rect.OffsetBy(2,0);
		rect.bottom = rect.top + RULER_HEIGHT;
		fRulerView = new HRulerView(rect,"ruler",this);
		Parent()->AddChild(fRulerView);
		ResetTextRect();
	}
}
示例#23
0
AmEditorTool* AmEditorToolBarView::ToolAt(BPoint where, BRect* frame)
{
	float			x  = 0;
	for (uint32 k = 0; k < mTools.size(); k++) {
		if (mTools[k] && mTools[k]->Icon() ) {
			BRect		b = mTools[k]->Icon()->Bounds();
			b.OffsetBy( BPoint(x, 0) );
			if (b.Contains(where)) {
				if (frame) *frame = b;
				return mTools[k];
			}
			x = b.right + 1;
			x += mSpace;
			if (x > where.x) return NULL;
		}
	}
	return NULL;
}
示例#24
0
void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
	const BRect& updateRect, bool isFirst, bool isLast, bool isFront)
{
	BRect closeRect = _CloseRectFrame(frame);
	frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();

	closeRect.left = (closeRect.left + closeRect.right) / 2 - 3;
	closeRect.right = closeRect.left + 6;
	closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3;
	closeRect.bottom = closeRect.top + 6;

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	float tint = B_DARKEN_1_TINT;
	if (!IsFront()) {
		base = tint_color(base, tint);
		tint *= 1.02;
	}

	if (fOverCloseRect)
		tint *= 1.4;
	else
		tint *= 1.2;

	if (fClicked && fOverCloseRect) {
		// Draw the button frame
		BRect buttonRect(closeRect.InsetByCopy(-4, -4));
		be_control_look->DrawButtonFrame(owner, buttonRect, updateRect,
			base, base,
			BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME);
		be_control_look->DrawButtonBackground(owner, buttonRect, updateRect,
			base, BControlLook::B_ACTIVATED);
		closeRect.OffsetBy(1, 1);
		tint *= 1.2;
	}

	// Draw the ×
	base = tint_color(base, tint);
	owner->SetHighColor(base);
	owner->SetPenSize(2);
	owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
	owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
	owner->SetPenSize(1);
}
示例#25
0
//-----------------------------------------------------------------
void Be5::Kill()
{
	//save current effect (ex :flying head)
	bool valid = SEffect()->Valid;
	BBitmap* currentEffect = SEffect()->CurrentImage;
	BRect position = SEffect()->Position;

	SEffect()->Position = Position;
	SEffect()->CurrentImage = GetAnim(Type, 1, 2, PlayerColor); //Adieu !
	SEffect()->Valid = true;

	//Transparent angel
	rgb_color c;
	for(int i = 0; i < 32; i++)
		for(int j = 0; j < 32; j++)
		{
			c = ((rgb_color *)SEffect()->CurrentImage->Bits())[(i*32 + j)];
			if(!(c.red == 255 && c.green == 0 && c.blue == 255))
				((rgb_color *)SEffect()->CurrentImage->Bits())[(i*32 + j)].alpha = 128;
		}

	BRect Invalidator;
	BRect dest = Position;
	dest.OffsetBy(0,-32);

	while(SEffect()->Position != dest) //bye bye !
	{
		Invalidator = SEffect()->Position;
		SEffect()->Position.OffsetBy(0,-2);
		SEffect()->Update(Invalidator);
		snooze(SPEED);
	}

	SEffect()->Valid = false;
	SEffect()->Update(SEffect()->Position); 
	delete SEffect()->CurrentImage;
	
	//put the old effect in place
	SEffect()->Valid = valid;
	SEffect()->CurrentImage = currentEffect;
	SEffect()->Position = position;
}
示例#26
0
void
SlideShowSaver::LayoutCaption(BView *view, BFont &font, BPoint &pos, BRect &rect)
{
	font_height fontHeight;
	float width, height;
	BRect bounds(view->Bounds());
	font = be_plain_font;
	width = font.StringWidth(fCaption.String()) + 1; // 1 for text shadow
	font.GetHeight(&fontHeight);
	height = fontHeight.ascent + fontHeight.descent;
	// center text horizontally
	pos.x = (bounds.left + bounds.right - width)/2;
	// flush bottom
	pos.y = bounds.bottom - fontHeight.descent - 5;

	// background rectangle
	rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow
	rect.OffsetTo(pos);
	rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border
}
示例#27
0
/**
 * Draw
 *
 * @param BRect, the draw bounds
 * @return void
 */
void
MarginView::Draw(BRect rect)
{
	BBox::Draw(rect);

	float y_offset = (float)kOffsetY;
	float x_offset = (float)kOffsetX;
	BRect r;

	// Calculate offsets depending on orientation
	if (fPageWidth < fPageHeight) { // Portrait
		x_offset = (fMaxPageWidth/2 + kOffsetX) - fViewWidth/2;
	} else { // landscape
		y_offset = (fMaxPageHeight/2 + kOffsetY) - fViewHeight/2;
	}

	// draw the page
	SetHighColor(kWhite);
	r = BRect(0, 0, fViewWidth, fViewHeight);
	r.OffsetBy(x_offset, y_offset);
	FillRect(r);
	SetHighColor(kBlack);
	StrokeRect(r);

	// draw margin
	SetHighColor(kRed);
	SetLowColor(kWhite);
	r.top += fMargins.top;
	r.right -= fMargins.right;
	r.bottom -= fMargins.bottom;
	r.left += fMargins.left;
	StrokeRect(r, kDots);

	// draw the page size label
	SetHighColor(kBlack);
	SetLowColor(kGray);
	char str[kStringSize];
	sprintf(str, "%2.1f x %2.1f", fPageWidth/fUnitValue, fPageHeight/fUnitValue);
	SetFontSize(10);
	DrawString((const char *)str, BPoint(x_offset, fMaxPageHeight + 40));
}
示例#28
0
// -------------------------------------
AntiDithererManipulatorView::AntiDithererManipulatorView(AntiDithererManipulator *manip,
        const BMessenger& t)
    : WindowGUIManipulatorView()
{
    target = t;
    manipulator = manip;
    started_adjusting = FALSE;

    block_size_control = new NumberControl("Block Size", "0",
                                           new BMessage(BLOCK_SIZE_ADJUSTED));
    AddChild(block_size_control);
    block_size_control->ResizeToPreferred();
    block_size_control->MoveTo(BPoint(4,4));
    BRect frame = block_size_control->Frame();

    frame.OffsetBy(0,frame.Height() + 4);
    reduce_resolution_box = new BCheckBox(frame,"reduce_resolution","Reduce Resolution",new BMessage(REDUCE_RESOLUTION_ADJUSTED));
    AddChild(reduce_resolution_box);

    ResizeTo(reduce_resolution_box->Bounds().Width()+8,reduce_resolution_box->Frame().bottom+4);
}
示例#29
0
TMailWindow*
TMailApp::NewWindow(const entry_ref* ref, const char* to, bool resend,
	BMessenger* trackerMessenger)
{
	float fontFactor = be_plain_font->Size() / 12.0f;
	BRect r;
	if (fMailWindowFrame.Width() < 64 || fMailWindowFrame.Height() < 20) {
		// default size
		r.Set(40 * fontFactor, 40 * fontFactor, fontFactor * (40 + WIND_WIDTH),
			fontFactor * (40 + WIND_HEIGHT));
	} else
		r = fMailWindowFrame;

	// cascading windows
	r.OffsetBy(fontFactor * (((fWindowCount + 5) % 10) * 15 - 75),
		fontFactor * (((fWindowCount + 5) % 10) * 15 - 75));

	fWindowCount++;

	BString title;
	BFile file;
	if (!resend && ref && file.SetTo(ref, O_RDONLY) == B_OK) {
		BString name;
		if (file.ReadAttrString(B_MAIL_ATTR_NAME, &name) == B_OK) {
			title << name;
			BString subject;
			if (file.ReadAttrString(B_MAIL_ATTR_SUBJECT, &subject) == B_OK)
				title << " -> " << subject;
		}
	}
	if (title == "")
		title = B_TRANSLATE_SYSTEM_NAME("Mail");

	TMailWindow* window = new TMailWindow(r, title.String(), this, ref, to,
		&fContentFont, resend, trackerMessenger);
	fWindowList.AddItem(window);

	window->MoveOnScreen();
	return window;
}
示例#30
0
void
PeakView::_DrawBitmap()
{
	SetHighColor(0, 0, 0);
	BRect bitmapFrame = _BackBitmapFrame();
	BRect bitmapRect = fBackBitmap->Bounds();
	bitmapRect.bottom = bitmapRect.top;
	float channelHeight = (bitmapFrame.Height() + 1) / fChannelCount;
	for (uint32 i = 0; i < fChannelCount; i++) {
		BRect viewRect(bitmapFrame);
		viewRect.bottom = viewRect.top;
		viewRect.top += floorf(i * channelHeight + 0.5);
		if (i < fChannelCount - 1) {
			viewRect.bottom += floorf((i + 1) * channelHeight + 0.5) - 2;
			StrokeLine(BPoint(viewRect.left, viewRect.bottom + 1),
				BPoint(viewRect.right, viewRect.bottom + 1));
		} else
			viewRect.bottom += floorf((i + 1) * channelHeight + 0.5) - 1;
		DrawBitmapAsync(fBackBitmap, bitmapRect, viewRect);
		bitmapRect.OffsetBy(0, 1);
	}
}