Пример #1
0
BPoint
TReplicantTray::LocationForReplicant(int32 index, float width)
{
	BPoint loc(kIconGap + 1, kGutter + 1);

	if (fMultiRowMode) {
		// try to find free space in every row
		for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
			// determine free space in this row
			BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap
				- 2.0, loc.y + kMaxReplicantHeight);
			if (row == 0 && !fTime->IsHidden())
				rect.right -= fTime->Frame().Width() + kIconGap;

			for (int32 i = 0; i < index; i++) {
				BView* view = NULL;
				fShelf->ReplicantAt(i, &view);
				if (view == NULL || view->Frame().top != rect.top)
					continue;

				rect.left = view->Frame().right + kIconGap + 1;
			}

			if (rect.Width() >= width) {
				// the icon fits in this row
				loc = rect.LeftTop();
				break;
			}
		}
	} else {
		if (index > 0) {
			// get the last replicant added for placement reference
			BView* view = NULL;
			fShelf->ReplicantAt(index - 1, &view);
			if (view) {
				// push this rep placement past the last one
				loc.x = view->Frame().right + kIconGap + 1;
				loc.y = view->Frame().top;
			}
		}
	}

	if ((loc.y == fRightBottomReplicant.top && loc.x
		> fRightBottomReplicant.left) || loc.y > fRightBottomReplicant.top) {
		fRightBottomReplicant.Set(loc.x, loc.y, loc.x + width, loc.y
		+ kMaxReplicantHeight);
		fLastReplicant = index;
	}

	return loc;
}
Пример #2
0
void SnowView::AttachedToWindow()
{
	BView *p;
	rgb_color col;
	fAttached = true;
/*	if (!fMsgRunner)
		fMsgRunner = new BMessageRunner(BMessenger(this), 
					new BMessage(MSG_PULSE_ME), 
					INTERVAL);
*/
	p = Parent();
	if (p)
		col = B_TRANSPARENT_32_BIT;//Parent()->ViewColor();
	else
		col = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(col);
//	BScreen bs;
//	fCachedWsWidth = bs.Frame().IntegerWidth();
//	fCachedWsHeight = bs.Frame().IntegerHeight();
	fDragger = dynamic_cast<BDragger *>(FindView("_dragger_"));
	if (fDragger && p) {
		fCachedParent = p;
		fCachedWsWidth = p->Frame().IntegerWidth();
		fCachedWsHeight = p->Frame().IntegerHeight();
		fDragger->SetViewColor(col);
		if (fDragger->InShelf()) {
			p->SetFlags(p->Flags() | B_DRAW_ON_CHILDREN);
#ifdef B_BEOS_VERSION_DANO
			p->SetDoubleBuffering(p->DoubleBuffering() | B_UPDATE_EXPOSED);
#endif
			ResizeTo(p->Bounds().Width(), p->Bounds().Height());
			MoveTo(0,0);
			fDragger->MoveTo(p->Bounds().Width()-7, p->Bounds().Height()-7);
		}
		BRect fallenRect(p->Bounds());
		fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT;
		fFallenBmp = new BBitmap(fallenRect, B_BITMAP_ACCEPTS_VIEWS, B_CMAP8);
		memset(fFallenBmp->Bits(), B_TRANSPARENT_MAGIC_CMAP8, (size_t)(fallenRect.Height()*fFallenBmp->BytesPerRow()));
		fFallenView = new BView(fallenRect, "offscreen fallen snow", B_FOLLOW_NONE, 0);
		fFallenBmp->AddChild(fFallenView);
		fFallenReg = new BRegion;
		fInvalidator = spawn_thread(SnowMakerThread, INVALIDATOR_THREAD_NAME, B_LOW_PRIORITY, (void *)this);
		resume_thread(fInvalidator);
		printf("BSnow: OK: ws = %ld x %ld\n", fCachedWsWidth, fCachedWsHeight);
#ifdef DEBUG
		Window()->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, msgfilter));
#endif
	}
}
void TScrollViewComponent::FrameMoved(BPoint screenPoint)		
{
	printf("TScrollViewComponent::FrameMoved....\n");
	Invalidate();
	BView *child; 
   	if ( child = ChildAt(0) ) 
   	{
   		child->Invalidate();
   		child->FrameResized(0,0);
		BRect AFrame = this->Frame();
		BRect AFrame2 = child->Frame();
		printf("TScrollViewComponent::FrameMoved Getting ScrollBar\n");
		BScrollBar *truc = this->ScrollBar(B_HORIZONTAL);
		AFrame2 = truc->Frame();
		FPropertyList->SetPropertyValue(PROP_BOTTOM,FloatToStr(AFrame.bottom -2 -((AFrame2.bottom - AFrame2.top))));
		truc = this->ScrollBar(B_VERTICAL);		
		AFrame2 = truc->Frame();
		FPropertyList->SetPropertyValue(PROP_RIGHT,FloatToStr(AFrame.right -2 - ((AFrame2.right-AFrame2.left))));
		FPropertyList->SetPropertyValue(PROP_TOP,FloatToStr(AFrame.top + 2));
		FPropertyList->SetPropertyValue(PROP_LEFT,FloatToStr(AFrame.left + 2));
   	}
   	BScrollView::FrameMoved(screenPoint);
//	FrameMovedComponent(FInternalComponent);
//	FInternalComponent->FrameMovedComponent(FInternalComponent);
}
Пример #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
BPoint HTabSheet::AdjustBottomRightOfAllPanes()
{
	BPoint overallBottomRight(0.0, 0.0);
	for(int i=0; i<fPanes.CountItems(); ++i)
	{
		BView* pane = (BView*)fPanes.ItemAt(i);
		if (!pane)
			continue;
		BPoint paneBottomRight = DetermineBottomRightOfPane(pane);
		if (overallBottomRight.x < paneBottomRight.x)
			overallBottomRight.x = paneBottomRight.x;
		if (overallBottomRight.y < paneBottomRight.y)
			overallBottomRight.y = paneBottomRight.y;
	}
	BPoint paneLeftTop;
	for(int i=0; i<fPanes.CountItems(); ++i)
	{
		BView* pane = (BView*)fPanes.ItemAt(i);
		if (!pane)
			continue;
		if (i == 0)
			paneLeftTop = pane->Frame().LeftTop();
		pane->ResizeTo(overallBottomRight.x + 1, overallBottomRight.y + 1);
	}
	return overallBottomRight+paneLeftTop;
}
Пример #6
0
void MainView::getSelBounds(BRect& bounds)
{
	BPoint upper_left, lower_right;
	
	upper_left.x = upper_left.y = 999999;
	lower_right.x = lower_right.y = 0;
	
	for(int i = 0; i < selected_fields.CountItems(); i++) {
		BView *field = (BView *)selected_fields.ItemAt(i);
		BRect frame = field->Frame();
		BPoint tl = frame.LeftTop();
		BPoint br = frame.RightBottom();
		
		if(tl.x < upper_left.x) {
			upper_left.x = tl.x;
		}
		if(br.x > lower_right.x) {
			lower_right.x = br.x;
		}
		if(tl.y < upper_left.y) {
			upper_left.y = tl.y;
		}
		if(br.y > lower_right.y) {
			lower_right.y = br.y;
		}
	}
	
	bounds.SetLeftTop(upper_left);
	bounds.SetRightBottom(lower_right);
}
Пример #7
0
void CharismaWindow::Minimize(bool minimize)
{
	const float margin=4.0f;
	BRect r;
	
	// en réalité, minimize est ignoré
	
	if(!isminim){
		menubar->Hide();
		setupview->MoveTo(B_ORIGIN);
		modemenu->MoveTo(margin,margin);
	
		r=modemenu->Frame();
		ResizeTo(r.right+margin,r.bottom+margin);
		
		SetLook(B_MODAL_WINDOW_LOOK);

		isminim=1;
	}else{
		menubar->Show();
		setupview->MoveTo(0,menubar->Frame().bottom);
		modemenu->MoveTo(10.0f,10.0f);

		r=setupview->Frame();
		ResizeTo(r.right,r.bottom);

		SetLook(B_TITLED_WINDOW_LOOK);

		isminim=0;
	}
}
Пример #8
0
void
PackagesView::FrameResized(float width, float height)
{
    if (CountChildren() == 0)
        Invalidate();

    BScrollBar* scrollBar = ScrollBar(B_VERTICAL);
    if (scrollBar == NULL)
        return;

    float virtualHeight = 0.0;

    int32 count = CountChildren();
    if (count > 0) {
        BView* child = ChildAt(count - 1);
        virtualHeight = child->Frame().bottom;
    }

    if (height > virtualHeight) {
        scrollBar->SetRange(0.0f, 0.0f);
        scrollBar->SetValue(0.0f);
    } else {
        scrollBar->SetRange(0.0f, virtualHeight - height);
        scrollBar->SetProportion(height / virtualHeight);
    }

    scrollBar->SetSteps(15, height);
}
Пример #9
0
/*=============================================================================================*\
|	Expand																						|
+-----------------------------------------------------------------------------------------------+
|	Effet: Reduire la view, la fenetre mere et deplacer les autre view si necessaire.			|
\*=============================================================================================*/
void ShrinkView::Expand()
{
	BView * pTempView;	//Utiliser pour parcourir les View attacher a la meme fenetre mere.
	
	//Agradir la View.
	ResizeTo(Frame().Width(), m_fFullHeight);
	m_bShrink = false;

	//Redimentionner la fenetre mere
	if( Window() != NULL )
	{
		Window()->ResizeBy(0, m_fFullHeight - 15.0 );		
	}
	
	//Deplacer, si necessaire, les autre View. 
	pTempView = this;
	while( pTempView->PreviousSibling() != NULL)
	{
		pTempView = pTempView->PreviousSibling();
	}
	while(pTempView != NULL)
	{
		if(Frame().top + 16.0 <= pTempView->Frame().top )
		{	
			pTempView->MoveBy(0, m_fFullHeight - 15.0);
		}
		pTempView = pTempView->NextSibling();
	}
	
	Draw(Bounds());
}//End of Expand.
Пример #10
0
/* This is a hack necessary because sometimes this view gets bogus FrameResize()
 * messages.  Not sure what's happening exactly, but fairly frequently I receive
 * a correct FrameResized() view followed by one that reports the Window()'s frame
 * to be 140 pixels shorter then the immediately preceding call.  Checking the
 * frame of the child views seems to bypass the bug.
 */
static float furthest_right(BWindow* window)
{
    float	right = 0;
    for (BView* child = window->ChildAt(0); child; child = child->NextSibling() ) {
        BRect	f = child->Frame();
        if (f.right > right) right = f.right;
    }
    return right;
}
Пример #11
0
BRect
TReplicantTray::IconFrame(int32 target, bool byIndex)
{
	int32 index, id;
	BView* view = ViewAt(&index, &id, target, byIndex);
	if (view)
		return view->Frame();

	return BRect(0, 0, 0, 0);
}
Пример #12
0
void WrappingTextView::CalculateVerticalOffset() {
	float offset = 0;
	int max=CountChildren();
	for( int i=0; i<max; ++i) {
		BView* child = ChildAt(i);
		child->MoveTo( 0, offset);
		BRect frame = child->Frame();
		offset += frame.Height();
	}
	m_vertical_offset = MAX( offset, 0);
	ResetTextRect();
}
float MessageView::ItemTop()
{
	int32 count	= CountChildren();
	if (count > 0)
	{
		BView *tmpChild = ChildAt(count-1);
		return tmpChild->Frame().bottom+MARGIN_SPACE;
		
	}
	else
		return MARGIN_SPACE;	
}
Пример #14
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();
	}
}
Пример #15
0
void ArpKnobPanel::GetPreferredSize(float* width, float* height)
{
	float	w = 0, h = 0;
	BView*	view;
	for( view = ChildAt(0); view != 0; view = view->NextSibling() ) {
		BRect	b = view->Frame();
		if( b.right > w ) w = b.right;
		if( b.bottom > h ) h = b.bottom;
	}
	*width = w;
	*height = h;
}
Пример #16
0
BRect
TReplicantTray::IconFrame(const char* name)
{
	if (!name)
		return BRect(0, 0, 0, 0);

	int32 id, index;
	BView* view = ViewAt(&index, &id, name);
	if (view)
		return view->Frame();

	return BRect(0, 0, 0, 0);
}
Пример #17
0
void
TReplicantTray::RealignReplicants(int32 startIndex)
{
	if (startIndex < 0)
		startIndex = 0;

	int32 count = fShelf->CountReplicants();
	if (count <= 0)
		return;

	if (startIndex == 0)
		fRightBottomReplicant.Set(0, 0, 0, 0);

	BView *view = NULL;
	for (int32 i = startIndex ; i < count ; i++){
		fShelf->ReplicantAt(i, &view);
		BPoint loc = LocationForReplicant(i, view->Frame().Width());
		if (view && (view->Frame().LeftTop() != loc)) {
			view->MoveTo(loc);
		}
	}
}
Пример #18
0
static filter_result
TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
{
	uchar key;
	if (message->FindInt8("byte", (int8*)&key) != B_OK)
		return B_DISPATCH_MESSAGE;

	ThrowOnAssert(filter != NULL);

	BContainerWindow* window = dynamic_cast<BContainerWindow*>(
		filter->Looper());
	ThrowOnAssert(window != NULL);

	BPoseView* poseView = window->PoseView();
	ThrowOnAssert(poseView != NULL);

	if (key == B_RETURN || key == B_ESCAPE) {
		poseView->CommitActivePose(key == B_RETURN);
		return B_SKIP_MESSAGE;
	}

	if (key == B_TAB) {
		if (poseView->ActivePose()) {
			if (message->FindInt32("modifiers") & B_SHIFT_KEY)
				poseView->ActivePose()->EditPreviousWidget(poseView);
			else
				poseView->ActivePose()->EditNextWidget(poseView);
		}

		return B_SKIP_MESSAGE;
	}

	// the BTextView doesn't respect window borders when resizing itself;
	// we try to work-around this "bug" here.

	// find the text editing view
	BView* scrollView = poseView->FindView("BorderView");
	if (scrollView != NULL) {
		BTextView* textView = dynamic_cast<BTextView*>(
			scrollView->FindView("WidgetTextView"));
		if (textView != NULL) {
			BRect rect = scrollView->Frame();

			if (rect.right + 3 > poseView->Bounds().right
				|| rect.left - 3 < 0)
				textView->MakeResizable(true, NULL);
		}
	}

	return B_DISPATCH_MESSAGE;
}
Пример #19
0
void
TimeFormatSettingsView::GetPreferredSize(float *_width, float *_height)
{
	if (_width != NULL) {
		BView* view = fMDYRadioButton->Parent();
		if (view != NULL)
			*_width = view->Frame().right;
		else
			*_width = Bounds().Width();
	}

	if (_height != NULL)
		*_height = fShortDateExampleView->Frame().bottom;
}
Пример #20
0
/**
	Lays out child views.
*/
void SplitView::Arrange()
{
	fLayout.Frame()= Bounds();
	fLayout.Reset();
	BView *child;
	uint32 hint = LAYOUT_HINT_NONE;
	for (int32 i = 0; (child = ChildAt(i)); i++) {
		if (i == CountChildren() - 1)
			hint |= (LAYOUT_HINT_LAST | LAYOUT_HINT_CLIP);
		BRect frame = fLayout.Next(child->Frame(), hint);
		child->MoveTo(frame.LeftTop());
		child->ResizeTo(frame.Width(), frame.Height());
	}
}
Пример #21
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);
	}
}
Пример #22
0
BPoint HTabSheet::DetermineBottomRightOfPane(BView* pane)
{
	BPoint bottomRight(0, 0);
	for(int i=0; i<pane->CountChildren(); ++i)
	{
		BView* child = pane->ChildAt(i);
		if (!child)
			continue;
		BRect childFrame = child->Frame();
		if (bottomRight.x < childFrame.right)
			bottomRight.x = childFrame.right;
		if (bottomRight.y < childFrame.bottom)
			bottomRight.y = childFrame.bottom;
	}
	return bottomRight;
}
Пример #23
0
void
SpaceBarSettingsView::GetPreferredSize(float *_width, float *_height)
{
	BView* view = fColorControl->Parent();
	if (view == NULL)
		BView::GetPreferredSize(_width, _height);

	if (_width != NULL) {
		float width = fSpaceBarShowCheckBox->Bounds().Width();
		if (view->Bounds().Width() > width)
			width = view->Bounds().Width();

		*_width = width;
	}

	if (_height != NULL)
		*_height = view->Frame().bottom;
}
Пример #24
0
/**
	Draws all spliters.	
*/
void SplitView::Draw(BRect update)
{
	BView *child;	
	for (int i = 0; i < CountChildren() -1; i++) {
		child = ChildAt(i);
		BRect frame = child->Frame();
		if (fLayout.Mode() == B_HORIZONTAL) {
			frame.left = frame.right+1;
			frame.right = frame.left + fLayout.Spacing().x-2;
		}
		else {
			frame.top = frame.bottom+1;
			frame.bottom = frame.top + fLayout.Spacing().y-2;
		}
		if (frame.Intersects(update))
			DrawSplitter(frame, child == fSelected && fDragged);		
	}
}
Пример #25
0
void
MixerView::ArrangeChildren()
{
	BRect	f1 = channelSelector->Frame();
	for (short i=0; i<back->CountChildren(); i++) {
		BView	*v = back->ChildAt(i);
		if (strcmp(v->Name(), "schedulable") == 0) {
			v->MoveTo(f1.left,f1.bottom+1);
			f1 = v->Frame();
		}
	}
	lastPanelBottom = f1.bottom;
	BRect	f0 = back->Bounds();
	float	x = lastPanelBottom-(f0.bottom-f0.top);
	if (x < 0)
		x = 0;
	verticalScroll->SetRange(0,x);
}
Пример #26
0
/***************************************************************************
 * ARP-KNOB-PANEL
 * This class constructs a knob along with an optional label and/or int
 * control.  Part of its usefulness is that it hides hooking up the knob
 * and int controls to each other, which is behaviour that will probably
 * change at some point.
 ***************************************************************************/
ArpKnobPanel::ArpKnobPanel(	const char* name, const char* label,
							BMessage* message, int32 minValue, int32 maxValue,
							bool showIntControl, orientation layout, uint32 knobFlags,
							float labelWidth, float intControlWidth, uint32 rmask, uint32 flags)
		: inherited( BRect( 0, 0, 0, 0 ), "knob_panel", rmask, flags )
{
	if( layout == B_VERTICAL )
		LayoutVertical(name, label, message, minValue, maxValue, showIntControl, knobFlags, labelWidth, intControlWidth);
	else
		LayoutHorizontal(name, label, message, minValue, maxValue, showIntControl, knobFlags, labelWidth, intControlWidth);

	float		width = 0, height = 0;
	BView*		view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.right > width ) width = f.right;
		if( f.bottom > height ) height = f.bottom;
	}
	ResizeTo( width, height );
}
Пример #27
0
/*************************************************************************
 * SEQ-PHRASE-PROPERTY-WINDOW
 *************************************************************************/
SeqPhrasePropertyWindow::SeqPhrasePropertyWindow(	AmSongRef songRef,
													AmPhraseEvent* event,
													const BMessage* config)
		: inherited(BRect(0, 0, 0, 0),
					"Phrase Properties",
					B_TITLED_WINDOW_LOOK,
					B_NORMAL_WINDOW_FEEL,
					B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
		  mSongRef(songRef), mEvent(NULL),
		  mBg(NULL), mNameCtrl(NULL), mTimeLabel(NULL), mTimeCtrl(NULL),
		  mColorField(NULL), mColorCtrl(NULL)
{
	AddViews(BRect(0, 0, 50, 50));
	float	w = 0, h = 0;
	/* Set my dimensions.
	 */
	if (mBg) {
		for (BView* view = mBg->ChildAt(0); view; view = view->NextSibling() ) {
			BRect	f = view->Frame();
			if (f.right > w) w = f.right;
			if (f.bottom > h) h = f.bottom;
		}
		ResizeTo(w + Prefs().Size(BORDER_X), h + Prefs().Size(BORDER_Y));
	}
	/* Set my location.
	 */
	BScreen	s(this);
	if (s.IsValid() ) {
		BRect	sf = s.Frame();
		float	newX = 10, newY = 10;
		if (w < sf.Width() ) newX = (sf.Width() - w) / 2;
		if (h < sf.Height() ) newY = (sf.Height() - h) / 2;
		MoveTo(newX, newY);
	}

	if (config) SetConfiguration(config);
	if (event) SetPhraseEvent(event);
}
Пример #28
0
void
WonderBrushView::AttachedToWindow()
{
	// Hack for DataTranslations which doesn't resize visible area to requested by view
	// which makes some parts of bigger than usual translationviews out of visible area
	// so if it was loaded to DataTranslations resize window if needed
	BWindow *window = Window();
	if (!strcmp(window->Name(), "DataTranslations")) {
		BView *view = Parent();
		if (view) {
			BRect frame = view->Frame();
			float x, y;
			GetPreferredSize(&x, &y);
			if (frame.Width() < x || (frame.Height() - 48) < y) {
				x -= frame.Width();
				y -= frame.Height() - 48;
				if (x < 0) x = 0;
				if (y < 0) y = 0;

				// DataTranslations has main view called "Background"
				// change it's resizing mode so it will always resize with window
				// also make sure view will be redrawed after resize
				view = window->FindView("Background");
				if (view) {
					view->SetResizingMode(B_FOLLOW_ALL);
					view->SetFlags(B_FULL_UPDATE_ON_RESIZE);
				}

				// The same with "Info..." button, except redrawing, which isn't needed
				view = window->FindView("Info" B_UTF8_ELLIPSIS);
				if (view)
					view->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);

				window->ResizeBy( x, y);
			}
		}
	}
}
Пример #29
0
void ArpKnobPanel::LayoutVertical(	const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceY = 3;
	float			top = 0;
	float			widest = 0;		// Cache the widest view just to save ourselves an
									// extra iteration over the views
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( 0, top, 0 + w, top + fh ),
								"label", label );
		if( sv ) {
			AddChild( sv );
			if( w > widest ) widest = w;
		}
		top += fh + spaceY;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(0, top, knobW, top + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		if( knobW > widest ) widest = knobW;
		top += knobH + spaceY;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(0, top, w, top + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
			if( w > widest ) widest = w;
		}
	}
	/* Now center everything based on the widest view.
	 */
	if( !sv && !intCtrl ) return;
	if( widest <= 0 ) return;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Width() < widest )
			view->MoveTo( (widest - f.Width()) / 2, f.top );
	}		
}
Пример #30
0
void ArpKnobPanel::LayoutHorizontal(const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceX = 8;
	float			left = 0;
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( left, 0, left + w, 0 + fh ),
								"label", label );
		if( sv ) AddChild( sv );
		left += w + spaceX;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(left, 0, left + knobW, 0 + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		left += knobW + spaceX;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(left, 0, left + w, 0 + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
		}
	}
	/* Now center everything based on the tallest view.
	 */
	if( !sv && !intCtrl ) return;
	float	tallest = (knobH > fh) ? knobH : fh;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Height() < tallest )
			view->MoveTo( f.left, (tallest - f.Height()) / 2 );
	}		
}