Example #1
0
DocInfoWindow::DocInfoWindow(BMessage *docInfo)
	: HWindow(BRect(0, 0, 400, 250), "Document Information", B_TITLED_WINDOW_LOOK,
		B_MODAL_APP_WINDOW_FEEL, B_NOT_MINIMIZABLE),
	fDocInfo(docInfo)
{
	BRect bounds(Bounds());
	BView *background = new BView(bounds, "bachground", B_FOLLOW_ALL, B_WILL_DRAW);
	background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(background);

	bounds.InsetBy(10.0, 10.0);
	BButton *button = new BButton(bounds, "ok", "OK", new BMessage(OK_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right - button->Bounds().Width(),
		bounds.bottom - button->Bounds().Height());

	BRect buttonFrame(button->Frame());
	button = new BButton(buttonFrame, "cancel", "Cancel", new BMessage(CANCEL_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(buttonFrame.left - (button->Bounds().Width() + 10.0),
		buttonFrame.top);

	bounds.bottom = buttonFrame.top - 10.0;

#if HAVE_FULLVERSION_PDF_LIB
	BString permissions;
	if (_DocInfo()->FindString("permissions", &permissions) == B_OK)
		fPermissions.Decode(permissions.String());

	BTabView *tabView = new BTabView(bounds, "tabView");
	_SetupDocInfoView(_CreateTabPanel(tabView, "Information"));
	_SetupPasswordView(_CreateTabPanel(tabView, "Password"));
	_SetupPermissionsView(_CreateTabPanel(tabView, "Permissions"));

	background->AddChild(tabView);
#else
	BBox* panel = new BBox(bounds, "top_panel", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER);

	_SetupDocInfoView(panel);
	background->AddChild(panel);
#endif

	if (fTable->ChildAt(0))
		fTable->ChildAt(0)->MakeFocus();

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);

	SetSizeLimits(400.0, 10000.0, 250.0, 10000.0);
}
Example #2
0
DesktopWindow::DesktopWindow(BRect frame, bool editMode)
	: BWindow(frame, B_TRANSLATE("Desktop"), 
		kPrivateDesktopWindowLook, 
		kPrivateDesktopWindowFeel, 
		B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
		 | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
		 | B_ASYNCHRONOUS_CONTROLS,
		editMode?B_CURRENT_WORKSPACE:B_ALL_WORKSPACES),
	  fEditShelfMode(editMode)
{
	BScreen screen;
	BView *desktop = new BView(Bounds(), "desktop", B_FOLLOW_NONE, 0);
	desktop->SetViewColor(screen.DesktopColor());
	AddChild(desktop);

	// load the shelf
	BPath path;
	status_t err;
	entry_ref ref;
	err = find_directory(B_SYSTEM_SETTINGS_DIRECTORY, &path, true);
	if (err >= B_OK) {
		BDirectory dir(path.Path());
		if (!dir.Contains("x-vnd.Haiku-Login", B_DIRECTORY_NODE))
			dir.CreateDirectory("x-vnd.Haiku-Login", NULL);
		path.Append("x-vnd.Haiku-Login");
		dir.SetTo(path.Path());
		if (!dir.Contains("Shelf", B_FILE_NODE))
			dir.CreateFile("Shelf", NULL);
		path.Append("Shelf");
		get_ref_for_path(path.Path(), &ref);
	}

	fDesktopShelf = new BShelf(&ref, desktop, fEditShelfMode, "DesktopShelf");
	if (fDesktopShelf)
		fDesktopShelf->SetDisplaysZombies(true);
}
Example #3
0
File: Box.cpp Project: D-os/BeFree
void
BBox::SetLabel(const char *label)
{
	if (!(label == NULL || *label == 0)) {
		BStringView *strView = cast_as(fLabelView, BStringView);
		if (strView != NULL) {
			strView->SetText(label);
			strView->ResizeToPreferred();
			ReAdjustLabel();
			return;
		}

		if ((strView = new BStringView(BRect(0, 0, 1, 1), NULL, label, B_FOLLOW_NONE)) == NULL) return;
		strView->SetFont(be_bold_font);
		strView->ResizeToPreferred();
		if (SetLabel(strView) != B_OK) delete strView;
	} else if (fLabelView != NULL) {
		BView *view = fLabelView;
		fLabelView = NULL;

		view->RemoveSelf();
		delete view;
	}
}
Example #4
0
/**
	Starts dragging.
*/
void SplitView::MouseDown(BPoint where)
{
    // This is an event hook so there must be a Looper.
    BMessage *message = Looper()->CurrentMessage();
    int32 clicks = 0;
    message->FindInt32("clicks", &clicks);
    fDoubleClick = clicks == 2;
	if (!fDragged) {
		fDragged = true;
		fGrabPoint = where;
		BView *child = NULL;
		for (int i=0; (child = ChildAt(i)); i++) {
			if (fLayout.Mode() == B_HORIZONTAL && child->Frame().left > where.x)
				break;
			if (fLayout.Mode() == B_VERTICAL && child->Frame().top > where.y)
				break;
		}
		if (child)
			fSelected = child->PreviousSibling();
		Draw(Bounds());
		// Subscribe to off-view mouse events.
		SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS);
	}
}
Example #5
0
// ---------------------------------------------------------------
// MakeConfigurationView
//
// Makes a BView object for configuring / displaying info about
// this translator. 
//
// Preconditions:
//
// Parameters:	ioExtension,	configuration options for the
//								translator
//
//				outView,		the view to configure the
//								translator is stored here
//
//				outExtent,		the bounds of the view are
//								stored here
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
status_t
BaseTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView,
	BRect *outExtent)
{
	if (!outView || !outExtent)
		return B_BAD_VALUE;
	if (ioExtension && fSettings->LoadSettings(ioExtension) != B_OK)
		return B_BAD_VALUE;

	BView *view = NewConfigView(AcquireSettings());
		// implemented in derived class

	if (view) {
		*outView = view;
		if ((view->Flags() & B_SUPPORTS_LAYOUT) != 0)
			view->ResizeTo(view->ExplicitPreferredSize());

		*outExtent = view->Bounds();

		return B_OK;
	} else
		return BTranslator::MakeConfigurationView(ioExtension, outView,
			outExtent);
}
Example #6
0
InfoWindow::InfoWindow(BRect r)
	: BWindow(r,"Update Progress",B_MODAL_WINDOW,B_NOT_RESIZABLE)
{
	BView *mainView = new BView(Bounds(),NULL,B_FOLLOW_ALL,B_WILL_DRAW);
	mainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(mainView);
	
	BRect sv = Bounds();
	sv.bottom = sv.top+14;
	
	line1 = new BStringView(sv,NULL,T("Updating..."));
	sv.top = sv.bottom;
	sv.bottom += 14;
	line2 = new BStringView(sv,NULL,"");
	sv.bottom = Bounds().bottom;
	sv.top = sv.bottom-30;
	bar = new BStatusBar(sv,NULL);
	
	mainView->AddChild(line1);
	mainView->AddChild(line2);
	mainView->AddChild(bar);
	
	Show();
}
Example #7
0
File: Delay.cpp Project: ysei/Faber
BView*
DelayEffect::SettingsPanel()
{
	BRect r(0,0,200,100);
	BView *view = new BView(r, "delayview", B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	delay = new SpinSlider("delay", B_TRANSLATE("Delay (ms)"),
		new BMessage(CONTROL_CHANGED), 1, 500);

//	delay->SetValue(Prefs.filter_delay_delay * 1000);

	gain = new SpinSlider("gain", B_TRANSLATE("Gain %"),
		new BMessage(CONTROL_CHANGED), 1, 200);

//	gain->SetValue(Prefs.filter_delay_gain * 100);

	BLayoutBuilder::Group<>(view, B_VERTICAL, 2)
		.Add(delay, 0)
		.Add(gain, 1)
	.End();

	return view;
}
void FontDrawView::MessageReceived(BMessage *message)
{	BView *parentview;
	BWindow *parentwin;
	switch(message->what)
	{
		case FONTVIEW_TOGGLE:
			parentview=Parent();
			parentwin=parentview->Window();
			if(IsHidden())
			{	
				parentwin->PostMessage(FONTVIEW_TOGGLE);
				Show();
			}
			else
			{	
				parentwin->PostMessage(FONTVIEW_TOGGLE);
				Hide();
			}
			break;	

		default:
			BView::MessageReceived(message);
	}
}
Example #9
0
AttribFill::AttribFill ()
: AttribView (BRect (0, 0, 146, 146), lstring (24, "Fill"))
{
	SetViewColor (LightGrey);
	BBox *tolSets = new BBox (BRect (4, 4, 142, 142), "tol");
	tolSets->SetLabel (lstring (338, "Tolerance"));
	AddChild (tolSets);
	tol = new BRadioButton (BRect (8, 13, 124, 30), "tol", lstring (339, "Visual Distance"), new BMessage ('AFtV'));
	rgb = new BRadioButton (BRect (8, 30, 124, 46), "rgb", lstring (340, "Absolute RGB"), new BMessage ('AFtS'));
	tol->SetValue (B_CONTROL_ON);
	tolSets->AddChild (tol);
	tolSets->AddChild (rgb);
	TabView *bgTab = new TabView (BRect (4, 50, 132, 134), "AttribFill Tab");
	tolSets->AddChild (bgTab);
	BView *tolTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "tol View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	BView *rgbTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "rgb View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	tolTab->SetViewColor (LightGrey);
	rgbTab->SetViewColor (LightGrey);
	bgTab->AddView (tolTab, lstring (341, "Visual"));
	bgTab->AddView (rgbTab, lstring (342, "RGB"));
	BStringView *explD = new BStringView (BRect (2, 8, 122, 20), "explD", lstring (343, "Visual Factors:"));
	BStringView *facD = new BStringView (BRect (2, 20, 122, 32), "facD", lstring (344, "R: 0.213 G: 0.715 B: 0.072"));
	explD->SetFontSize (10);
	facD->SetFontSize (10);
	sT = new Slider (BRect (4, 42, 122, 58), 10, "D", 0, 255, 1, new BMessage ('AFcT'));
	sR = new Slider (BRect (4,  2, 122, 18), 10, "R", 0, 255, 1, new BMessage ('AFcR'));
	sG = new Slider (BRect (4, 22, 122, 38), 10, "G", 0, 255, 1, new BMessage ('AFcG'));
	sB = new Slider (BRect (4, 42, 122, 58), 10, "B", 0, 255, 1, new BMessage ('AFcB'));
	tolTab->AddChild (sT);
	tolTab->AddChild (explD);
	tolTab->AddChild (facD);
	rgbTab->AddChild (sR);
	rgbTab->AddChild (sG);
	rgbTab->AddChild (sB);
	fTolMode = FILLTOL_TOL;
	fTolerance = 0;
	fToleranceRGB.red = 0;
	fToleranceRGB.green = 0;
	fToleranceRGB.blue = 0;
	fCurrentProperty = 0;
}
Example #10
0
void MediaNodePanel::_updateBitmap()
{
	if (m_bitmap)
	{
		delete m_bitmap;
	}
	BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true);
	tempBitmap->Lock();
	{
		BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
		tempBitmap->AddChild(tempView);
		tempView->SetOrigin(0.0, 0.0);
	
		int32 layout = dynamic_cast<MediaRoutingView *>(view())->getLayout();	
		_drawInto(tempView, tempView->Bounds(), layout);

		tempView->Sync();
		tempBitmap->RemoveChild(tempView);
		delete tempView;
	}
	tempBitmap->Unlock();
	m_bitmap = new BBitmap(tempBitmap);
	delete tempBitmap;
}
BView* SeqEditMultiFilterWindow::NewGeneralView(BRect frame)
{
	BView*		v = new BView(frame, GENERAL_STR, B_FOLLOW_ALL, 0);
	if (!v) return NULL;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float		fh = arp_get_font_height(v);
	float		spaceX = 5, spaceY = 5;
	float		divider = v->StringWidth("Author:") + 10;
	BRect		f(spaceX, 0, frame.Width() - spaceX, fh);
	/* The Name field.
	 */
	mNameCtrl = new BTextControl(f, "name_ctrl", "Name:", NULL, new BMessage(NAME_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mNameCtrl) {
		f.top = mNameCtrl->Frame().bottom;
		mNameCtrl->SetDivider(divider);
		mNameCtrl->MakeFocus(true);
		v->AddChild(mNameCtrl);
	}
	/* The Key field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mKeyCtrl = new BTextControl(f, "key_ctrl", "Key:", NULL, new BMessage(KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mKeyCtrl) {
		f.top = mKeyCtrl->Frame().bottom;
		mKeyCtrl->SetDivider(divider);
		v->AddChild(mKeyCtrl);
	}
	/* The Author field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mAuthorCtrl = new BTextControl(f, "author_ctrl", "Author:", NULL, new BMessage(AUTHOR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mAuthorCtrl) {
		f.top = mAuthorCtrl->Frame().bottom;
		mAuthorCtrl->SetDivider(divider);
		v->AddChild(mAuthorCtrl);
	}
	/* The Email field.
	 */
	f.top += spaceY;
	f.bottom = f.top + fh;
	mEmailCtrl = new BTextControl(f, "email_ctrl", "Email:", NULL, new BMessage(EMAIL_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mEmailCtrl) {
		f.top = mEmailCtrl->Frame().bottom;
		mEmailCtrl->SetDivider(divider);
		v->AddChild(mEmailCtrl);
	}

	return v;
}
Example #12
0
RunArgsWindow::RunArgsWindow(Project *proj)
	:	DWindow(BRect(0,0,400,300),"Run Arguments",B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
		fProject(proj)
{
	AddCommonFilter(new EscapeCancelFilter());
	
	BView *top = GetBackgroundView();
	
	fArgText = new AutoTextControl(BRect(10,10,11,11),"argtext",TR("Arguments: "),
									fProject->GetRunArgs(), new BMessage,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fArgText);
	fArgText->ResizeToPreferred();
	fArgText->ResizeTo(Bounds().Width() - 20,fArgText->Bounds().Height());
	fArgText->SetDivider(fArgText->StringWidth(TR("Arguments: ")) + 5);
	
	ResizeTo(Bounds().Width(),fArgText->Frame().bottom + 10);
	
	MakeCenteredOnShow(true);
	
	fArgText->MakeFocus(true);
	fArgText->TextView()->SelectAll();
}
Example #13
0
LibraryWindow::LibraryWindow(BRect frame, const BMessenger &parent, Project *project)
	:	DWindow(frame,NULL,B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS |
											B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
		fParent(parent),
		fProject(project)
{
	if (project)
	{
		BString title(TR("Libraries: "));
		title << project->GetName();
		SetTitle(title.String());
	}
	
	BView *top = GetBackgroundView();
	
	BRect r(10,10,11,11);
	BStringView *label = new BStringView(r,"label",TR("Choose the system libraries "
													"for your project."));
	label->ResizeToPreferred();
	top->AddChild(label);
	label->SetText(TR("Scanning libraries…"));
	
	r = Bounds().InsetByCopy(10,10);
	r.top = label->Frame().top + 20;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	fCheckList = new BView(r,"checklist",B_FOLLOW_ALL,B_WILL_DRAW);
	
	BScrollView *scrollView = new BScrollView("scrollView",fCheckList,
											B_FOLLOW_ALL, 0,false,true);
	top->AddChild(scrollView);
	
	fScanThread = spawn_thread(ScanThread,"libscanthread",B_NORMAL_PRIORITY,this);
	resume_thread(fScanThread);
	
	fCheckList->MakeFocus(true);
}
Example #14
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));
	}
}
Example #15
0
void
IconSpewer::DrawSomeNew()
{
	target->Lock();
	BView* view = target->FindView("iconView");
	ASSERT(view);

	BRect bounds(target->Bounds());
	view->SetHighColor(Color(255, 255, 255));
	view->FillRect(bounds);

	view->SetHighColor(Color(0, 0, 0));
	char buffer[256];
	if (cycleTime) {
		sprintf(buffer, "last cycle time %" B_PRId64 " ms", cycleTime/1000);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 20));
	}

	if (numDrawn) {
		sprintf(buffer, "average draw time %" B_PRId64 " us per icon",
			watch.ElapsedTime() / numDrawn);
		view->DrawString(buffer, BPoint(20, bounds.bottom - 30));
	}

	sprintf(buffer, "directory: %s", currentPath.Path());
	view->DrawString(buffer, BPoint(20, bounds.bottom - 40));

	target->Unlock();

	for (int32 row = 0; row < kRowCount; row++) {
		for (int32 column = 0; column < kColumnCount; column++) {
			BEntry entry(NextRef());
			Model model(&entry, true);

			if (!target->Lock())
				return;

			if (model.IsDirectory())
				entry.GetPath(&currentPath);

			IconCache::sIconCache->Draw(&model, view,
				BPoint(column * (kIconSize + 2), row * (kIconSize + 2)),
				kNormalIcon, kIconSize, true);
			target->Unlock();
			numDrawn++;
		}
	}
}
Example #16
0
void
BPrintJob::_RecurseView(BView* view, BPoint origin, BPicture* picture,
	BRect rect)
{
	ASSERT(picture != NULL);

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

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

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

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

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

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

	if ((view->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		view->AppendToPicture(picture);
		view->PushState();
		view->SetOrigin(origin);
		view->ConstrainClippingRegion(&region);
		view->fIsPrinting = true;
		view->DrawAfterChildren(rect);
		view->fIsPrinting = false;
		view->PopState();
		view->EndPicture();
	}
}
void ArpConfigurePanel::GetPreferredSize(float* width, float* height)
{
	float maxw=0, maxh=0;
	size_t i;
	
	// Get dimensions of all configuration views.
	for( i=0; i<mConfigViews->size(); i++ ) {
		BView* view = 0;
		if( (view=mConfigViews->at(i)) != 0 ) {
			ArpD(cdb << ADH << "Processing dimens for view #" << i
							<< ", name="
							<< view->Name() << endl);
			float vwidth=0, vheight=0;
			// If this view is not attached to the window (i.e., it
			// is not currently displayed by the tab view), then it
			// may not be able to report correct dimensions.  To fix
			// this, we temporarily add it to your view.
			if( !view->Window() ) {
				ArpD(cdb << ADH << "Temporarily attaching view to window."
							<< endl);
				bool hidden = view->IsHidden();
				view->Hide();
				AddChild(view);
				view->GetPreferredSize(&vwidth, &vheight);
				RemoveChild(view);
				if( !hidden ) view->Show();
			} else {
				view->GetPreferredSize(&vwidth, &vheight);
			}
			ArpD(cdb << ADH << "Preferred width=" << vwidth
							<< ", height=" << vheight << endl);
			if( vwidth > maxw ) maxw = vwidth;
			if( vheight > maxh ) maxh = vheight;
		}
	}
	
	ArpD(cdb << ADH << "Final size=(" << (maxw+mTabWidth)
				<< ", " << (maxh+mTabHeight) << ")" << endl);
				
	if( width ) *width = maxw + mTabWidth + 2;
	if( height ) *height = maxh + mTabHeight + 2;
}
Example #18
0
void TMediaTabView::DeactivateView(EChildID which)
{
	// Take away the control buttons
	BView* view = ChildAt(which);

	BView* b = view->ChildAt(0);
	while (b) {
		BView* next = b->NextSibling();
		if (dynamic_cast<TRadioBitmapButton*>(b) != 0)
			view->RemoveChild(b);
		b = next;
	}

	// Make sure the view is invisible
	if (!view->IsHidden())
		view->Hide();
}
Example #19
0
BBitmap*
OffscreenBitmap::Copy()
{
	// the result bitmap that does not accept views	
	// to save resources in the application server
	BBitmap *copy = new BBitmap(fFrame, fColorSpace, false);
	AutoDelete<BBitmap> _copy(copy);
	if (copy == NULL || copy->IsValid() == false || copy->InitCheck() != B_OK)
		return NULL;

	fView->Sync();
	fBitmap->Unlock();
	
	memcpy(copy->Bits(), fBitmap->Bits(), fBitmap->BitsLength());	
	
	fBitmap->Lock();

	return _copy.Release();
}
BFIV_PrefWin::BFIV_PrefWin(BRect frame)
    : BWindow(frame, "Preferences", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
    BRect rect = Bounds();
    BView *back;
    BTextControl *scratchPath;
    BButton *cancelButton, *okButton, *selectButton;
    font_height fontHeight;
    float fontSize, tmp;

    // private data
    filePanel = NULL;

    // some font voodoo
    be_plain_font->GetHeight(&fontHeight);
    fontSize = fontHeight.ascent + fontHeight.descent;

    // the background
    back = new BView(rect, "background", B_FOLLOW_ALL, 0);
    back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    AddChild(back);

    // the select button
    tmp = be_plain_font->StringWidth("Select");
    rect.Set(frame.Width() - tmp - 20., 5., frame.Width() - 5., 5. + fontSize + 10.);
    selectButton = new BButton(rect, "select", "Select", new BMessage(SELECT_SCRATCH_PATH));
    back->AddChild(selectButton);

    // the path
    rect.Set(5.,5., selectButton->Frame().left - 5., 5. + fontSize + 10.);
    scratchPath = new BTextControl(rect, "path", "Scratch Location", NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
    back->AddChild(scratchPath);
    scratchPath->SetText(((BFIV_App *)be_app)->ScratchDirectory()); // current dir
    scratchPath->TextView()->MakeEditable(false); // only works after AddChild() (!!)


    // the ok button
    tmp = be_plain_font->StringWidth("OK");
    rect.Set(frame.Width() - tmp - 35., Frame().Height() - fontSize - 20., frame.Width() - 10., Frame().Height() - 10.);
    okButton = new BButton(rect, "ok", "OK", new BMessage(APPLY_PREFS_CHANGE));
    back->AddChild(okButton);
    okButton->MakeDefault(true);

    // the cancel button
    tmp = be_plain_font->StringWidth("Cancel");
    rect.Set(okButton->Frame().left - tmp - 20., okButton->Frame().top, okButton->Frame().left - 5., okButton->Frame().bottom);
    cancelButton = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED));
    back->AddChild(cancelButton);
}
StringInputWindow::StringInputWindow(const char *title, const char *text, BMessage msg,
									BMessenger target)
	:	DWindow(BRect(0,0,300,200),title,B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
		fMessage(msg),
		fMessenger(target)
{
	MakeCenteredOnShow(true);
	BView *top = GetBackgroundView();
	
	BRect r = Bounds().InsetByCopy(10,10);
	r.bottom = r.top + 10;
	BRect textRect = r.OffsetToCopy(0,0);
	textRect.InsetBy(10,10);
	fTextView = new BTextView(r,"paneltext",textRect,B_FOLLOW_LEFT | B_FOLLOW_TOP);
	top->AddChild(fTextView);
	fTextView->MakeEditable(false);
	fTextView->SetText(text);
	fTextView->ResizeTo(r.Width(), 20.0 + (fTextView->CountLines() * 
									fTextView->TextHeight(0,fTextView->TextLength())));
	fTextView->SetViewColor(top->ViewColor());
	
	fText = new BTextControl(BRect(10,10,11,11),"nametext","", "", new BMessage);
	top->AddChild(fText);
	fText->ResizeToPreferred();
	fText->ResizeTo(Bounds().Width() - 20,fText->Bounds().Height());
	fText->SetDivider(0.0);
	fText->MoveTo(10,fTextView->Frame().bottom + 10.0);
	
	r = fText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	BButton *cancel = new BButton(r,"cancel","Cancel",
									new BMessage(B_QUIT_REQUESTED));
	cancel->ResizeToPreferred();
	top->AddChild(cancel);
	
	ResizeTo(300, cancel->Frame().bottom + 10);
	cancel->MoveTo( Bounds().Width() - (cancel->Bounds().Width() * 2) - 20,
					cancel->Frame().top);
	
	r = cancel->Frame();
	r.OffsetBy(r.Width() + 10,0);
	BButton *open = new BButton(r,"ok","OK", new BMessage(M_INVOKE));
	top->AddChild(open);
	open->MakeDefault(true);
	fText->MakeFocus(true);
	
	open->MakeDefault(true);
}
Example #22
0
CColorPicker::CColorPicker(BRect frame, const char *name, bool stayOpen)
	: BWindow(frame, name, stayOpen ? B_TITLED_WINDOW : B_MODAL_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	fStayOpen = stayOpen;
	fCaller = NULL;
	
	BView *main = new BView(Bounds(), "main", 0, B_WILL_DRAW);
	AddChild(main);
	main->SetViewColor(kGray);
	
	BRect r(10, 10, 145, 130);
	fHSV = new CHSVView(r, "hsvview");
	main->AddChild(fHSV);
	
	r.Set(155, 10, 205, 130);
	fON = new CONView(r, "o&n");
	main->AddChild(fON);

	r.Set(215, 10, 380, 130);
	fRGB = new CRGBView(r, "rgbview");
	main->AddChild(fRGB);

	if (fStayOpen)
	{
		BRect b(Bounds());
		
		ResizeTo(b.Width(), b.Height() - 30);
	}
	else
	{
		r.Set(320, 140, 380, 160);
		BButton * ok = new BButton(r, "ok", "OK", new BMessage(msg_OK));
		main->AddChild(ok);
		ok->MakeDefault(true);
		
		r.Set(250, 140, 310, 160);
		main->AddChild(new BButton(r, "cancel", "Cancel", new BMessage(msg_Cancel)));

		// TPV 00-02-27
        KeyFilter * kf = new KeyFilter(B_ESCAPE, msg_Cancel) ;
        AddCommonFilter( kf ) ;
	}
} /* CColorPicker::CColorPicker */
ListChooseWindow::ListChooseWindow(list<string>* strL, string title, 
	string text1, string text2, string str) : 
	BWindow(BRect(200, 200, 415, 400), title.c_str(),
	B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 
	B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_CLOSABLE)
{
	BRect rect(200, 200, 415, 400);
	rect.OffsetTo(0, 0);
	BView* backview = new BView(rect, "ListChooseBackView", 0, B_WILL_DRAW);
	backview->SetViewColor(222, 222, 222);
	AddChild(backview);
	
	BStringView* sv = new BStringView(BRect(15, 5, 185, 20),
		"ListChooseSV", text1.c_str());
	backview->AddChild(sv);
	sv = new BStringView(BRect(15, 20, 185, 33),
		"ListChooseSV", text2.c_str());
	backview->AddChild(sv);

	lv = new BListView(BRect(15, 40, 185, 153), "ListChooseLV");
	backview->AddChild(new BScrollView("scrollregister", lv,
		B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));

	BStringItem* si;
	for (list<string>::iterator iter = strL->begin(); iter !=
		strL->end(); iter++)
	{
		si = new BStringItem((*iter).c_str());
		lv->AddItem(si);
		if (*iter == str)
			si->SetEnabled(false);
	}
	
	BButton* button = new BButton(BRect(15, 165, 95, 185), "okB",
		"OK", new BMessage(ListChooseOKMSG));
	backview->AddChild(button);
	button->MakeDefault(true);
	button = new BButton(BRect(105, 165, 200, 185), "cancelB",
		"Cancel", new BMessage(ListChooseCancelMSG));
	backview->AddChild(button);
	
	clickWait = create_sem(0, "clickWait");
}
Example #24
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;
}
BView* SeqEditMultiFilterWindow::NewDescriptionView(BRect frame)
{
	BView*			v = new BView(frame, DESCRIPTION_STR, B_FOLLOW_ALL, 0);
	if (!v) return NULL;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );

	float			fh = arp_get_font_height(v);
	float			spaceX = 5, spaceY = 5;
	BRect			shortLabelR(spaceX, 0, frame.Width(), fh);
	BRect			shortR(spaceX, shortLabelR.bottom + spaceY, shortLabelR.right - Prefs().Size(V_SCROLLBAR_X) - 4, shortLabelR.bottom + spaceY + (fh * 3) + spaceY);
	BRect			longLabelR(spaceX, shortR.bottom + spaceY, shortLabelR.right, shortR.bottom + spaceY + fh);
	BRect			longR(spaceX, longLabelR.bottom + spaceY, shortR.right, frame.Height() - 2);

	BStringView*	sv = new BStringView(shortLabelR, "short_label", "Short description:");
	if (sv) v->AddChild(sv);
	sv = new BStringView(longLabelR, "long_label", "Long description:");
	if (sv) v->AddChild(sv);

	mShortDescriptionCtrl = new SeqDumbTextView(shortR, "short_descr", BRect(5, 5, shortR.Width() - 10, 0), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (mShortDescriptionCtrl) {
		mShortDescriptionCtrl->SetModificationMessage(new BMessage(DESCRIPTION_MOD_MSG) );
		BScrollView*		sv = new BScrollView("short_scroll", mShortDescriptionCtrl,
												 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 0, false, true);
		if (sv) v->AddChild(sv);
		else v->AddChild(mShortDescriptionCtrl);
	}
	mLongDescriptionCtrl = new SeqDumbTextView(longR, "long_descr", BRect(5, 5, shortR.Width() - 10, 0), B_FOLLOW_ALL);
	if (mLongDescriptionCtrl) {
		mLongDescriptionCtrl->SetModificationMessage(new BMessage(DESCRIPTION_MOD_MSG) );
		BScrollView*		sv = new BScrollView("long_scroll", mLongDescriptionCtrl,
												 B_FOLLOW_ALL, 0, false, true);
		if (sv) v->AddChild(sv);
		else v->AddChild(mLongDescriptionCtrl);
	}
	return v;
}
Example #26
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;
};
Example #27
0
Window::Window()
	: BWindow(BRect(100, 100, 590, 260), "EventMask-Test",
			B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	BView* view = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(view);

	BTextControl* textControl = new BTextControl(BRect(10, 10, 290, 30),
		"text", "Type to test focus suspending:", "", NULL, B_FOLLOW_LEFT_RIGHT);
	textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8);
	view->AddChild(textControl);

	textControl = new BTextControl(BRect(300, 10, 420, 30),
		"all", "All keys:", "", NULL, B_FOLLOW_LEFT_RIGHT);
	textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8);
	view->AddChild(textControl);
	textControl->TextView()->SetEventMask(B_KEYBOARD_EVENTS, 0);

	BRect rect(10, 40, 120, 120);
	for (int32 i = 0; i < 4; i++) {
		uint32 options = 0;
		switch (i) {
			case 1:
				options = B_SUSPEND_VIEW_FOCUS;
				break;
			case 2:
				options = B_LOCK_WINDOW_FOCUS;
				break;
			case 3:
				options = B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS;
				break;
		}

		fViews[i] = new PositionView(rect, options);
		view->AddChild(fViews[i]);

		rect.OffsetBy(120, 0);
	}

	BCheckBox* checkBox = new BCheckBox(BRect(10, 130, 200, 160), "permanent", "Get all pointer events", new BMessage(kMsgPointerEvents));
	view->AddChild(checkBox);
}
BView* SeqEditMultiFilterWindow::NewPipelineView(BRect frame)
{
	BView*		v = new BView(frame, PIPELINE_STR, B_FOLLOW_ALL, 0);
	if (!v) return NULL;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float			x = 5, y = 5;
	const char*		addL = "Add";
	const char*		deleteL = "Delete";
	float			buttonW = v->StringWidth(deleteL) + 30, buttonH = 24;
	/* Lay out the views.
	 */
	BRect			addF(x, 0, x + buttonW, buttonH);
	BRect			deleteF(addF.right + x, addF.top, addF.right + x + buttonW, addF.bottom);
	float			sbW = Prefs().Size(V_SCROLLBAR_X) + 3, sbH = Prefs().Size(H_SCROLLBAR_Y) + 3;
	BRect			pipelineF(x, addF.bottom + y, frame.Width() - sbW, frame.Height() - sbH);
	/* Create and add the views.
	 */
	BButton*	button = new BButton(addF, "add_btn", addL, new BMessage(ADD_PIPELINE_MSG), B_FOLLOW_LEFT | B_FOLLOW_TOP);
	if (button) v->AddChild(button);
	button = new BButton(deleteF, "del_btn", deleteL, new BMessage(DELETE_PIPELINE_MSG), B_FOLLOW_LEFT | B_FOLLOW_TOP);
	if (button) v->AddChild(button);
	mPipelineView = new SeqPipelineMatrixView(	pipelineF, "pipeline_matrix",
												AmPipelineMatrixRef(mMultiFilter),
												NULLINPUTOUTPUT_PIPELINE, SEQ_SUPPRESS_BACKGROUND);
	if (mPipelineView) {
		mPipelineView->SetResizingMode(B_FOLLOW_ALL);
		mPipelineView->SetShowProperties(true);
		mPipelineView->ForceViewColor( tint_color(Prefs().Color(AM_AUX_WINDOW_BG_C), B_DARKEN_1_TINT) );
		mPipelineScrollView = new BScrollView("pipeline_scroll", mPipelineView, B_FOLLOW_ALL, 0, true, true);	
		if (mPipelineScrollView) {
			v->AddChild(mPipelineScrollView);
			mPipelineScrollView->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
		} else v->AddChild(mPipelineView);
	}
	return v;
}
Example #29
0
/**
 *	@brief	レイアウトを調整します。
 */
void TextDiffView::recalcLayout()
{
	BRect bounds = Bounds();
	float leftWidth = floor((bounds.Width() + 1 - B_H_SCROLL_BAR_HEIGHT - PANE_SPLITTER_WIDTH) / 2);
	float rightWidth = (bounds.Width() + 1 - PANE_SPLITTER_WIDTH) - leftWidth;

	// 左ペイン
	BView* leftPaneView = FindView(NAME_LEFT_PANE_SCROLLER);
	if (NULL != leftPaneView)
	{
		leftPaneView->MoveTo(bounds.left, bounds.top);
		leftPaneView->ResizeTo(leftWidth - 1, bounds.Height());
	}
	
	// 右ペイン
	BView* rightPaneView = FindView(NAME_RIGHT_PANE_SCROLLER);
	if (NULL != rightPaneView)
	{
		rightPaneView->MoveTo(bounds.left + leftWidth + PANE_SPLITTER_WIDTH, bounds.top);
		rightPaneView->ResizeTo(rightWidth - 1, bounds.Height());
	}
}
Example #30
0
InfoWindow::InfoWindow(BRect r,BWindow *win)
	: BWindow(r,"Update Progress",B_TITLED_WINDOW,B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
	BView *mainView = new BView(Bounds(),NULL,B_FOLLOW_ALL,B_WILL_DRAW);
	mainView->SetViewColor(216,216,216);
	AddChild(mainView);
	
	BRect sv = Bounds();
	sv.bottom = sv.top+14;
	
	line1 = new BStringView(sv,NULL,"Updating...");
	sv.top = sv.bottom;
	sv.bottom += 14;
	line2 = new BStringView(sv,NULL,"");
	sv.bottom = Bounds().bottom-30;
	sv.top = sv.bottom-30;
	bar = new BStatusBar(sv,NULL);
	
	mainView->AddChild(line1);
	mainView->AddChild(line2);
	mainView->AddChild(bar);
	
	sv.top = sv.bottom+5;
	sv.bottom = sv.top+20;
	sv.left = 0;
	sv.right = 100;
	BButton *button = new BButton(sv,NULL,"Pause",new BMessage('Paus'));
	mainView->AddChild(button);
	button->SetTarget(win);
	sv.left = 150;
	sv.right = 250;
	button = new BButton(sv,NULL,"Stop",new BMessage('Stop'));
	mainView->AddChild(button);
	button->SetTarget(win);
	
	Show();
}