Esempio n. 1
0
void
TwoStateDrawButton::ResizeToPreferred()
{
	if (fUpOne)
		ResizeTo(fUpOne->Bounds().Width(), fUpOne->Bounds().Height());
	else if (fDownOne)
		ResizeTo(fDownOne->Bounds().Width(), fDownOne->Bounds().Height());
	else if (fUpTwo)
		ResizeTo(fUpTwo->Bounds().Width(),fUpTwo->Bounds().Height());
	else if (fDownTwo)
		ResizeTo(fDownTwo->Bounds().Width(), fDownTwo->Bounds().Height());
	else if (fDisabledOne)
		ResizeTo(fDisabledOne->Bounds().Width(), fDisabledOne->Bounds().Height());
	else if(fDisabledTwo)
		ResizeTo(fDisabledTwo->Bounds().Width(), fDisabledTwo->Bounds().Height());
}
Esempio n. 2
0
void ColumnListView::CreateContainer(bool horizontal, bool vertical, border_style border,
	uint32 ResizingMode, uint32 flags)
{
	BRect ViewFrame = Frame();
	BRect LabelsFrame = fColumnLabelView->Frame();

	fScrollView = new CLVContainerView(NULL,this,ResizingMode,flags,horizontal,vertical,border);
	BRect NewFrame = Frame();
	//Resize the main view to make room for the CLVColumnLabelView
	ResizeTo(ViewFrame.right-ViewFrame.left,ViewFrame.bottom-LabelsFrame.bottom-1.0);
	MoveTo(NewFrame.left,NewFrame.top+(LabelsFrame.bottom-LabelsFrame.top+1.0));
	fColumnLabelView->MoveTo(NewFrame.left,NewFrame.top);

	//Add the ColumnLabelView
	fScrollView->AddChild(fColumnLabelView);

	//Remove and re-add the BListView so that it will draw after the CLVColumnLabelView
	fScrollView->RemoveChild(this);
	fScrollView->AddChild(this);

	fFillerView = NULL;
}
Esempio n. 3
0
PictureView::PictureView(const char* name, const char* filename, uint32 flags)
	: BView(name, flags),
	fBitmap(NULL),
	fWidth(0.0f),
	fHeight(0.0f)
{
	// Set transparent
	SetViewColor(B_TRANSPARENT_COLOR);

	// Try to get the image
	fBitmap = BTranslationUtils::GetBitmap(filename);

	if (fBitmap) {
		BRect frame(fBitmap->Bounds());

		fWidth  = frame.Width();
		fHeight = frame.Height();
	} else
		return;

	ResizeTo(fWidth, fHeight);
}
Esempio n. 4
0
void
PreferenceLog::AttachedToWindow (void)
{
	BView::AttachedToWindow();

	SetViewColor (Parent()->ViewColor());

	masterLog->SetTarget (this);
	dateLogs->SetTarget (this);

	masterLog->ResizeToPreferred();
	dateLogs->ResizeToPreferred();

	dateLogs->MoveTo (0, masterLog->Frame().bottom + 1);

	float biggest (masterLog->Frame().right);

	if (dateLogs->Frame().right > biggest)
		biggest = dateLogs->Frame().right;
	
	ResizeTo (biggest, dateLogs->Frame().bottom);
}
Esempio n. 5
0
void ClientAgent::Show(void)
{
	Window()->PostMessage(M_STATUS_CLEAR);
	this->fMsgr.SendMessage(M_STATUS_ADDITEMS);

	BMessage statusMsg(M_CW_UPDATE_STATUS);
	statusMsg.AddPointer("item", fAgentWinItem);
	statusMsg.AddInt32("status", WIN_NORMAL_BIT);
	statusMsg.AddBool("hidden", false);
	Window()->PostMessage(&statusMsg);

	const BRect* agentRect(dynamic_cast<ClientWindow*>(Window())->AgentRect());

	if (*agentRect != Frame()) {
		ResizeTo(agentRect->Width(), agentRect->Height());
		MoveTo(agentRect->left, agentRect->top);
	}

	// make RunView recalculate itself
	fText->Show();
	BView::Show();
}
Esempio n. 6
0
BTextControl::BTextControl(BRect frame, const char *name, const char *label,
						   const char *text, BMessage *message, uint32 mask,
						   uint32 flags)
	:	BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
{
	InitData(label, text);

	BRect bounds(Bounds());
	
	font_height fh;
	GetFontHeight(&fh);

	float height = (float)ceil(fh.ascent + fh.descent + fh.leading);
	float lineHeight = fText->LineHeight(0);

	ResizeTo(bounds.Width(), height + 8);

	BRect textBounds(fText->Bounds());

	fText->ResizeTo(textBounds.Width(), lineHeight + 4);
	fText->MoveBy(0, (bounds.Height() - height) / 2.0f);
}
Esempio n. 7
0
void
Controller::AddControlPanel(Panel *p)
{
    Lock();
    BRect wrect = Bounds();
    int			len = wrect.bottom - wrect.top;
    int			wid = wrect.right - wrect.left;

    wrect = p->Bounds();
    if (debug_ctl)
        fprintf(dbfp, "my size %d %d panel(%g,%g,%g,%g)\n",
                len, wid, wrect.left,wrect.top,wrect.right,wrect.bottom);

    p->MoveTo(MARGIN, len-MARGIN);
    backView->AddChild(p);

    len += (wrect.bottom - wrect.top);
    wid = Max(wid, wrect.right - wrect.left + 2*MARGIN);
    ResizeTo(wid,len);
    backView->MoveTo(0,0);
    Unlock();
}
Esempio n. 8
0
void
ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
{
	BScreen screen;
	if (!screen.IsValid())
		return;

	BRect r(pbitmap->Bounds());
	float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
	float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
		B_H_SCROLL_BAR_HEIGHT;

	BRect frame = screen.Frame();
	const float windowBorder = 5;
	// dimensions so that window does not reach outside of screen
	float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
	float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;

	// We have to check size limits manually, otherwise
	// menu bar will be too short for small images.

	float minW, maxW, minH, maxH;
	GetSizeLimits(&minW, &maxW, &minH, &maxH);
	if (maxWidth > maxW)
		maxWidth = maxW;
	if (maxHeight > maxH)
		maxHeight = maxH;
	if (width < minW)
		width = minW;
	if (height < minH)
		height = minH;

	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;

	ResizeTo(width, height);
}
Esempio n. 9
0
// _UpdateFrame
void
IconOptionsControl::_UpdateFrame()
{
	if (fLayoutData->label_layout_item && fLayoutData->icon_bar_layout_item) {
		BRect labelFrame = fLayoutData->label_layout_item->Frame();
		BRect iconFrame = fLayoutData->icon_bar_layout_item->Frame();

		BSize oldSize = Bounds().Size();

		fLayout->SetInsets(iconFrame.left, 0, 0, 0);

		// update our frame
		MoveTo(labelFrame.left, min_c(labelFrame.top, iconFrame.top));
		ResizeTo(labelFrame.Width() + iconFrame.Width(),
			max_c(labelFrame.Height(), iconFrame.Height()));

		// If the size changes, ResizeTo() will trigger a relayout, otherwise
		// we need to do that explicitly.
		if (Bounds().Size() != oldSize)
			Relayout();
	}
}
Esempio n. 10
0
void
BStatusBar::AttachedToWindow()
{
	// resize so that the height fits
	float width, height;
	GetPreferredSize(&width, &height);
	ResizeTo(Bounds().Width(), height);

	SetViewColor(B_TRANSPARENT_COLOR);
	rgb_color lowColor = B_TRANSPARENT_COLOR;

	BView* parent = Parent();
	if (parent != NULL)
		lowColor = parent->ViewColor();

	if (lowColor == B_TRANSPARENT_COLOR)
		lowColor = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetLowColor(lowColor);

	fTextDivider = Bounds().Width();
}
	StatusWindow(const char* text)
		:
		BWindow(BRect(0, 0, 10, 10), B_TRANSLATE("status"), B_MODAL_WINDOW_LOOK,
			B_MODAL_APP_WINDOW_FEEL, B_NO_WORKSPACE_ACTIVATION | B_NOT_ZOOMABLE
				| B_AVOID_FRONT | B_NOT_RESIZABLE)
	{
		BView* rootView = new BView(Bounds(), "root", B_FOLLOW_ALL,
			B_WILL_DRAW);
		AddChild(rootView);
		rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		float spacing = be_control_look->DefaultItemSpacing();
		BALMLayout* layout = new BALMLayout(spacing);
		rootView->SetLayout(layout);
		layout->SetInset(spacing);

		BStringView* string = new BStringView("text", text);
		layout->AddView(string, layout->Left(), layout->Top(), layout->Right(),
			layout->Bottom());
		BSize min = layout->MinSize();
		ResizeTo(min.Width(), min.Height());
		CenterOnScreen();
	}
Esempio n. 12
0
void
RouteWindow::_constrainToScreen()
{
	D_INTERNAL(("RouteWindow::_constrainToScreen()\n"));

	BScreen screen(this);
	BRect screenRect = screen.Frame();
	BRect windowRect = Frame();

	// if the window is outside the screen rect
	// move it to the default position
	if (!screenRect.Intersects(windowRect)) {
		windowRect.OffsetTo(screenRect.LeftTop());
		MoveTo(windowRect.LeftTop());
		windowRect = Frame();
	}

	// if the window is larger than the screen rect
	// resize it to fit at each side
	if (!screenRect.Contains(windowRect)) {
		if (windowRect.left < screenRect.left) {
			windowRect.left = screenRect.left + 5.0;
			MoveTo(windowRect.LeftTop());
			windowRect = Frame();
		}
		if (windowRect.top < screenRect.top) {
			windowRect.top = screenRect.top + 5.0;
			MoveTo(windowRect.LeftTop());
			windowRect = Frame();
		}
		if (windowRect.right > screenRect.right) {
			windowRect.right = screenRect.right - 5.0;
		}
		if (windowRect.bottom > screenRect.bottom) {
			windowRect.bottom = screenRect.bottom - 5.0;
		}
		ResizeTo(windowRect.Width(), windowRect.Height());
	}
}
Esempio n. 13
0
void
ShowImageWindow::_ToggleFullScreen()
{
	BRect frame;
	fFullScreen = !fFullScreen;
	if (fFullScreen) {
		BScreen screen;
		fWindowFrame = Frame();
		frame = screen.Frame();
		frame.top -= fBar->Bounds().Height() + 1;
		frame.right += B_V_SCROLL_BAR_WIDTH;
		frame.bottom += B_H_SCROLL_BAR_HEIGHT;

		SetFlags(Flags() | B_NOT_RESIZABLE | B_NOT_MOVABLE);

		Activate();
			// make the window frontmost
	} else {
		frame = fWindowFrame;

		SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE));
	}

	fToolBar->SetActionVisible(MSG_FULL_SCREEN, fFullScreen);
	_SetToolBarVisible(!fFullScreen && fShowToolBar);
	_SetToolBarBorder(!fFullScreen);

	MoveTo(frame.left, frame.top);
	ResizeTo(frame.Width(), frame.Height());

	fImageView->SetHideIdlingCursor(fFullScreen);
	fImageView->SetShowCaption(fFullScreen && fShowCaption);

	Layout(false);
		// We need to manually relayout here, as the views are layouted
		// asynchronously, and FitToBounds() would still have the wrong size
	fImageView->FitToBounds();
}
Esempio n. 14
0
ColorPicker::ColorPicker(BLooper * target) : BWindow(BRect(50, 75, 100 + (CP_COL_WIDTH * 32), 120 + (CP_COL_WIDTH * 8)), str(STR_SET_COLORS), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), _target(target), _whichColor(0)
{
	const float margin = 5.0f;
	const float topRowHeight = 25.0f;
	_colControl = new BColorControl(BPoint(margin, margin+topRowHeight+margin), B_CELLS_32x8, CP_COL_WIDTH, "color_picker", new BMessage(CP_COL_UPDATE));
	ResizeTo(_colControl->Frame().right+margin, _colControl->Frame().bottom+margin);

	BView * view = new BView(Bounds(), NULL, B_FOLLOW_ALL, 0);
	AddChild(view);
	view->SetViewColor(BeBackgroundGrey);
  
	const BRect & bounds = view->Bounds(); 
	float revertWidth = view->StringWidth(str(STR_REVERT))+10.0f;
	BRect revertBounds(bounds.right-(revertWidth+margin), margin, bounds.right-margin, margin+topRowHeight);
	view->AddChild(_revert = new BButton(revertBounds, NULL, str(STR_REVERT), new BMessage(CP_BUTTON_REVERT)));

	float defaultWidth = view->StringWidth(str(STR_DEFAULT))+10.0f;
	BRect defaultBounds(revertBounds.left-(margin+defaultWidth), revertBounds.top, revertBounds.left-margin, revertBounds.bottom);
	view->AddChild(_default = new BButton(defaultBounds, NULL, str(STR_DEFAULT), new BMessage(CP_BUTTON_DEFAULT)));
	
	view->AddChild(_sampleView = new BView(BRect(margin, margin, margin+topRowHeight, margin+topRowHeight), NULL, B_FOLLOW_TOP|B_FOLLOW_LEFT, B_WILL_DRAW));

	_colorMenu = new BMenu("");
	_colorMenu->SetLabelFromMarked(true);
	for (int i=0; i<NUM_COLORS; i++)
	{
		BMessage * msg = new BMessage(CP_SELECTION_CHANGED);
		msg->AddInt32("which", i);
		BMenuItem * mi = new BMenuItem(str(STR_COLOR_BG+i), msg);
		_colorMenu->AddItem(mi);
		if (i==0) mi->SetMarked(true);
	}
	view->AddChild(new BMenuField(BRect(margin+topRowHeight+margin, margin, revertBounds.left-margin, revertBounds.bottom), NULL, NULL, _colorMenu));
	view->AddChild(_colControl);
	
	BMessage initMsg(CP_INIT);
	PostMessage(&initMsg);
}
Esempio n. 15
0
TSliderComponent::TSliderComponent(const char *AComponentName, const char *AClassName, BRect AFrame, TComponent *AFatherComponent):
BSlider(AFrame,AComponentName,AComponentName,NULL,0,100),TComponentKindaView(AComponentName,AClassName,this)
{
	float largeur,hauteur;

	FParent = AFatherComponent;
	FCodeGenerator = new TSliderCodeGenerator(this,true);
	FPropertyList->AddProperty(PROP_NAME,AComponentName,PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_CLASSNAME,AClassName,PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_LABEL,AComponentName,PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);

	FPropertyList->AddProperty(PROP_MIN,"0",PROP_TYPE_FLOAT,false,true,"",PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_MAX,"100",PROP_TYPE_FLOAT,false,true,"",PROP_GENERAL_GROUP);

	FPropertyList->AddProperty(PROP_THUMB,"B_BLOCK_THUMB",PROP_TYPE_FLOAT,true,false,
								"B_BLOCK_THUMB;B_TRIANGLE_THUMB",
								PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_MESSAGE,"NULL",PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);

	FPropertyList->AddProperty(PROP_RESIZING_MODE,"B_FOLLOW_LEFT | B_FOLLOW_TOP",PROP_TYPE_FLOAT,true,false,
								"B_FOLLOW_LEFT;B_FOLLOW_RIGHT;B_FOLLOW_LEFT_RIGHT;B_FOLLOW_H_CENTER;B_FOLLOW_TOP;B_FOLLOW_BOTTOM;B_FOLLOW_TOP_BOTTOM;B_FOLLOW_V_CENTER;B_FOLLOW_ALL_SIDES;B_FOLLOW_NONE",
								PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_FLAGS,"B_NAVIGABLE | B_WILL_DRAW",PROP_TYPE_FLOAT,true,false,
								"B_WILL_DRAW;B_PULSE_NEEDED;B_FRAME_EVENTS;B_FULL_UPDATE_ON_RESIZE;B_NAVIGABLE;B_NAVIGABLE_JUMP;B_SUBPIXEL_PRECISE",
								PROP_POSITION_GROUP);

	GetPreferredSize(&largeur,&hauteur);
	ResizeTo(largeur,hauteur);
	AFrame = Frame();	
	FPropertyList->AddProperty(PROP_TOP,FloatToStr(AFrame.top),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_LEFT,FloatToStr(AFrame.left),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_RIGHT,FloatToStr(AFrame.right),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_BOTTOM,FloatToStr(AFrame.bottom),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);

	FHandler = this; // on fait pointer le FHandler interne du TCOmponent dont on a besoin dans TComponentItem.
	FElement = this;
//	Show(); 
}
Esempio n. 16
0
VolumeWindow::VolumeWindow(BRect frame, bool dontBeep, int32 volumeWhich)
	: BWindow(frame, "VolumeWindow", B_BORDERED_WINDOW_LOOK,
		B_FLOATING_ALL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK
		| B_AUTO_UPDATE_SIZE_LIMITS, 0),
	fUpdatedCount(0)
{
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL);
	layout->SetInsets(5, 5, 5, 5);

	BBox* box = new BBox("sliderbox");
	box->SetLayout(layout);
	box->SetBorder(B_PLAIN_BORDER);
	AddChild(box);

	BSlider* slider = new VolumeControl(volumeWhich, !dontBeep,
		new BMessage(kMsgVolumeChanged));
	slider->SetModificationMessage(new BMessage(kMsgVolumeUpdate));
	box->AddChild(slider);

	slider->SetTarget(this);
	ResizeTo(300, 50);

	// Make sure it's not outside the screen.
	const int32 kMargin = 3;
	BRect windowRect = Frame();
	BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
	if (screenFrame.right < windowRect.right + kMargin)
		MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
	if (screenFrame.bottom < windowRect.bottom + kMargin)
		MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom);
	if (screenFrame.left > windowRect.left - kMargin)
		MoveBy(kMargin + screenFrame.left - windowRect.left, 0);
	if (screenFrame.top > windowRect.top - kMargin)
		MoveBy(0, kMargin + screenFrame.top - windowRect.top);
}
Esempio n. 17
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);
}
Esempio n. 18
0
void
FieldView::SetBoard(uint16 width, uint16 height, uint16 count)
{
	delete fField;

	if (width < 2)
		width = 2;
	if (height < 2)
		height = 2;

	BRect r = gGameStyle->TileSize();
	ResizeTo(((r.Width() + 1.0) * width) - 1.0,
			((r.Height() + 1.0) * height) - 1.0);

	gGameState = 0;
	fFlagCount = 0;

	fField = new Minefield(width,height);
	fField->Reset(count);
	if (Window())
		Window()->PostMessage(M_SIZE_CHANGED);
	Invalidate();
}
Esempio n. 19
0
/*****************************************************************************
 * VideoWindow::_SetVideoSize
 *****************************************************************************/
void
VideoWindow::_SetVideoSize(uint32_t mode)
{
    // let size depend on aspect correction
    int32_t width = CorrectAspectRatio() ? i_width : fTrueWidth;
    int32_t height = CorrectAspectRatio() ? i_height : fTrueHeight;
    switch (mode)
    {
        case RESIZE_50:
            width /= 2;
            height /= 2;
            break;
        case RESIZE_200:
            width *= 2;
            height *= 2;
            break;
        case RESIZE_100:
        default:
            break;
    }
    fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
    ResizeTo(width, height);
}
Esempio n. 20
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
BRect BmTextControl::layout(BRect frame) {
	if (frame == Frame())
		return frame;
	MoveTo(frame.LeftTop());
	ResizeTo(frame.Width(),frame.Height());
#ifdef __HAIKU__
	float occupiedSpace = 3 + Divider();
	float top = mTextView->Frame().top;
	float height = mTextView->Frame().Height();
	if (mLabelIsMenu) {
		top = mMenuField->MenuBar()->Frame().top;
		height = mMenuField->MenuBar()->Frame().Height();
	}
	mTextView->MoveTo( occupiedSpace, top);
	mTextView->ResizeTo( frame.Width()-occupiedSpace-4, height);
#else
	float occupiedSpace = 3 + Divider();
	mTextView->MoveTo( occupiedSpace, 5);
	mTextView->ResizeTo( frame.Width()-occupiedSpace-4, 
								mTextView->Frame().Height());
#endif // __HAIKU__
	return frame;
}
Esempio n. 21
0
status_t
InspectorWindow::LoadSettings(const GuiTeamUiSettings& settings)
{
	AutoLocker<BLooper> lock(this);
	if (!lock.IsLocked())
		return B_ERROR;

	BMessage inspectorSettings;
	if (settings.Settings("inspectorWindow", inspectorSettings) != B_OK)
		return B_OK;

	BRect frameRect;
	if (inspectorSettings.FindRect("frame", &frameRect) == B_OK) {
		ResizeTo(frameRect.Width(), frameRect.Height());
		MoveTo(frameRect.left, frameRect.top);
	}

	_LoadMenuFieldMode(fHexMode, "Hex", inspectorSettings);
	_LoadMenuFieldMode(fEndianMode, "Endian", inspectorSettings);
	_LoadMenuFieldMode(fTextMode, "Text", inspectorSettings);

	return B_OK;
}
Esempio n. 22
0
void DragonView::_SetNewImage( BBitmap *bitmap, const char *name )
{
	_bits_mutex.Lock();

	if( _bits ) delete _bits;
	_bits = bitmap;

	ResizeTo( _bits->Bounds().Width(), _bits->Bounds().Height() );

	// If you stashed this in the resources instead of hard-coding it,
	// you could easily change the name of the application without
	// editing a single source file.

	BString new_title( "DragonDrop — " );
	new_title += name;

	// Note that the window is already locked when this gets called.
	Window()->SetTitle( new_title.String() );

	Invalidate();

	_bits_mutex.Unlock();
}
Esempio n. 23
0
File: Panel.cpp Progetto: dakyri/qua
void
Panel::GetItemRect(
			float indent,
			float item_wid, float item_hite,
			float seperation_wid,
			BRect &wrect)
{
	if (thePoint.x + item_wid > myWidth) {
		if (thePoint.x + item_wid < maxWidth) {	// can expand in wid
			myWidth = thePoint.x + item_wid+indent;
			seperation_wid = indent;
			if (rowHeight < item_hite + MIXER_MARGIN)
				rowHeight = item_hite + MIXER_MARGIN;
			if (thePoint.y + rowHeight > myHeight) {
				myHeight = thePoint.y + rowHeight;
			}
		} else {								// gotta go down
			thePoint.x = indent;
			thePoint.y = myHeight;
			rowHeight = item_hite + MIXER_MARGIN;
			myHeight = thePoint.y + rowHeight;
			myWidth = Max(myWidth, item_wid+2*indent);
			if (myWidth > maxWidth)
				myWidth = maxWidth;
		}
	} else {									// fits in this row.
		if (rowHeight < item_hite + MIXER_MARGIN)
			rowHeight = item_hite + MIXER_MARGIN;
		if (thePoint.y + rowHeight > myHeight) {
			myHeight = thePoint.y + rowHeight;
		}
	}
//	fprintf(stderr, "%s %g %g %g %g\n", Name(), myWidth, myHeight, item_wid, item_hite);
	ResizeTo(myWidth, myHeight);
	wrect.Set(thePoint.x, thePoint.y, thePoint.x+item_wid, thePoint.y+item_hite);
	thePoint.x += item_wid + seperation_wid;
}
Esempio n. 24
0
VirtualKeyboardWindow::VirtualKeyboardWindow(BInputServerDevice* dev)
	:
	BWindow(BRect(0,0,0,0),"Virtual Keyboard",
	B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
	B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FOCUS),
	fDevice(dev)
{
	BScreen screen;
	BRect screenRect(screen.Frame());

	ResizeTo(screenRect.Width(), screenRect.Height() / 3);
	MoveTo(0,screenRect.Height() - screenRect.Height() / 3);

	SetLayout(new BGroupLayout(B_VERTICAL));

	//Add to an options window later, use as list for now
	fMapListView = new BListView("Maps");
	fFontMenu = new BMenu("Font");
	fLayoutMenu = new BMenu("Layout");

	_LoadMaps();
	_LoadLayouts(fLayoutMenu);
	_LoadFonts();

	KeymapListItem* current =
		static_cast<KeymapListItem*>(fMapListView->LastItem());
	fCurrentKeymap.Load(current->EntryRef());


	fKeyboardView = new KeyboardLayoutView("Keyboard",fDevice);
	fKeyboardView->GetKeyboardLayout()->SetDefault();
	fKeyboardView->SetEditable(false);
	fKeyboardView->SetKeymap(&fCurrentKeymap);

	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(fKeyboardView));
}
Esempio n. 25
0
void
WorkspacesWindow::Zoom(BPoint origin, float width, float height)
{
	BScreen screen;
	float screenWidth = screen.Frame().Width();
	float screenHeight = screen.Frame().Height();
	float aspectRatio = screenWidth / screenHeight;

	uint32 columns, rows;
	BPrivate::get_workspaces_layout(&columns, &rows);

	float workspaceWidth = Frame().Width() / columns;
	float workspaceHeight = workspaceWidth / aspectRatio;

	width = floor(workspaceWidth * columns);
	height = floor(workspaceHeight * rows);

	while (width + 2 * GetScreenBorderOffset() > screenWidth
		|| height + 2 * GetScreenBorderOffset() + GetTabHeight()
			> screenHeight) {
		width = floor(0.95 * width);
		height = floor(0.95 * height);
	}

	ResizeTo(width, height);

	if (fSettings->AutoRaising()) {
		// The auto-raising mode makes sense only if the window is positionned
		// exactly in the bottom-right corner. If the setting is enabled, move
		// the window there.
		origin = screen.Frame().RightBottom();
		origin.x -= GetScreenBorderOffset() + width;
		origin.y -= GetScreenBorderOffset() + height;

		MoveTo(origin);
	}
}
Esempio n. 26
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();
}
Esempio n. 27
0
BooleanEditor::BooleanEditor(BRect rect, DataEditor &editor)
	: TypeEditorView(rect, B_TRANSLATE("Boolean editor"), B_FOLLOW_NONE, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BPopUpMenu *menu = new BPopUpMenu("bool");
	BMessage *message;
	menu->AddItem(fFalseMenuItem = new BMenuItem("false",
		new BMessage(kMsgValueChanged)));
	menu->AddItem(fTrueMenuItem = new BMenuItem("true",
		message = new BMessage(kMsgValueChanged)));
	message->AddInt8("value", 1);

	BMenuField *menuField = new BMenuField(rect.InsetByCopy(5, 5),
		B_EMPTY_STRING, B_TRANSLATE("Boolean value:"), menu, B_FOLLOW_LEFT_RIGHT);
	menuField->SetDivider(StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	ResizeTo(menuField->Bounds().Width() + 10,
		menuField->Bounds().Height() + 10);

	_UpdateMenuField();

	AddChild(menuField);
}
// Loads the application settings file from (loadMsg) and resizes the interface
// to match the previously saved settings.  Because this is a non-essential
// file, errors are ignored when loading the settings.
void
ShortcutsWindow::_LoadWindowSettings(const BMessage& loadMsg)
{
	BRect frame;
	if (loadMsg.FindRect("window frame", &frame) == B_OK) {
		// Ensure the frame does not resize below the computed minimum.
		float width = max_c(Bounds().right, frame.right - frame.left);
		float height = max_c(Bounds().bottom, frame.bottom - frame.top);
		ResizeTo(width, height);

		// Ensure the frame is not placed outside of the screen.
		BScreen screen(this);
		float left = min_c(screen.Frame().right - width, frame.left);
		float top = min_c(screen.Frame().bottom - height, frame.top);
		MoveTo(left, top);
	}

	for (int i = 0; i < fColumnListView->CountColumns(); i++) {
		CLVColumn* column = fColumnListView->ColumnAt(i);
		float columnWidth;
		if (loadMsg.FindFloat("column width", i, &columnWidth) == B_OK)
			column->SetWidth(max_c(column->Width(), columnWidth));
	}
}
Esempio n. 29
0
void
BTextControl::_UpdateFrame()
{
	CALLED();

	if (fLayoutData->label_layout_item && fLayoutData->text_view_layout_item) {
		BRect labelFrame = fLayoutData->label_layout_item->Frame();
		BRect textFrame = fLayoutData->text_view_layout_item->Frame();

		// update divider
		fDivider = textFrame.left - labelFrame.left;

		MoveTo(labelFrame.left, labelFrame.top);
		BSize oldSize = Bounds().Size();
		ResizeTo(textFrame.left + textFrame.Width() - labelFrame.left,
			textFrame.top + textFrame.Height() - labelFrame.top);
		BSize newSize = Bounds().Size();

		// If the size changes, ResizeTo() will trigger a relayout, otherwise
		// we need to do that explicitly.
		if (newSize != oldSize)
			Relayout();
	}
}
TTextControlComponent::TTextControlComponent(const char *AComponentName,const char *AClassName, BRect AFrame, TComponent *AFatherComponent):
BTextControl(AFrame,AComponentName,NULL,"Some Text",NULL,B_FOLLOW_LEFT | B_FOLLOW_TOP,B_FRAME_EVENTS | B_WILL_DRAW | B_NAVIGABLE),TComponentKindaView(AComponentName,AClassName,this)
{
	float largeur,hauteur;
	FHandler = this;
	FParent = AFatherComponent;
	FCodeGenerator = new TTextControlCodeGenerator(this,true);
	FPropertyList->AddProperty(PROP_NAME,AComponentName,PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_CLASSNAME,AClassName,PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	if (Label()==NULL) 
	{
		FPropertyList->AddProperty(PROP_LABEL,"",PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	}
	else
		FPropertyList->AddProperty(PROP_LABEL,Label(),PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);
	FPropertyList->AddProperty(PROP_MESSAGE,"NULL",PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);

	FPropertyList->AddProperty(PROP_RESIZING_MODE,"B_FOLLOW_LEFT | B_FOLLOW_TOP",PROP_TYPE_FLOAT,true,false,
								"B_FOLLOW_LEFT;B_FOLLOW_RIGHT;B_FOLLOW_LEFT_RIGHT;B_FOLLOW_H_CENTER;B_FOLLOW_TOP;B_FOLLOW_BOTTOM;B_FOLLOW_TOP_BOTTOM;B_FOLLOW_V_CENTER;B_FOLLOW_ALL_SIDES;B_FOLLOW_NONE",
								PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_FLAGS,"B_NAVIGABLE | B_WILL_DRAW",PROP_TYPE_FLOAT,true,false,
								"B_WILL_DRAW;B_PULSE_NEEDED;B_FRAME_EVENTS;B_FULL_UPDATE_ON_RESIZE;B_NAVIGABLE;B_NAVIGABLE_JUMP;B_SUBPIXEL_PRECISE",
								PROP_POSITION_GROUP);

	FPropertyList->AddProperty(PROP_TEXT,Text(),PROP_TYPE_STRING,false,true,"",PROP_GENERAL_GROUP);

	GetPreferredSize(&largeur,&hauteur);
	ResizeTo(largeur,hauteur);

	AFrame = Frame();	
	FPropertyList->AddProperty(PROP_TOP,FloatToStr(AFrame.top),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_LEFT,FloatToStr(AFrame.left),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_RIGHT,FloatToStr(AFrame.right),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);
	FPropertyList->AddProperty(PROP_BOTTOM,FloatToStr(AFrame.bottom),PROP_TYPE_FLOAT,false,true,"",PROP_POSITION_GROUP);

}