예제 #1
0
void
BSeparatorItem::Draw()
{
	BMenu *menu = Menu();
	if (menu == NULL)
		return;

	BRect bounds = Frame();
	rgb_color oldColor = menu->HighColor();
	rgb_color lowColor = menu->LowColor();

	const float startTop = bounds.top + (floor(bounds.Height())) / 2;
	menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
		BPoint(bounds.right - 1.0f, startTop));
	menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
		BPoint(bounds.right - 1.0f, startTop + 1.0f));

	menu->SetHighColor(oldColor);
}
예제 #2
0
파일: ListViews.cpp 프로젝트: DonCN/haiku
// SimpleItem::DrawItem
void
SimpleItem::Draw(BView *owner, BRect frame, uint32 flags)
{
	DrawBackground(owner, frame, flags);
	// label
	owner->SetHighColor( 0, 0, 0, 255 );
	font_height fh;
	owner->GetFontHeight( &fh );
	const char* text = Text();
	BString truncatedString( text );
	owner->TruncateString( &truncatedString, B_TRUNCATE_MIDDLE,
						   frame.Width() - TEXT_OFFSET - 4.0 );
	float height = frame.Height();
	float textHeight = fh.ascent + fh.descent;
	BPoint textPoint;
	textPoint.x = frame.left + TEXT_OFFSET;
	textPoint.y = frame.top
				  + ceilf(height / 2.0 - textHeight / 2.0
				  		  + fh.ascent);
	owner->DrawString(truncatedString.String(), textPoint);
}
예제 #3
0
void
TDateEdit::DrawSection(uint32 index, BRect bounds, bool hasFocus)
{
	if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount)
		return;

	SetLowColor(ViewColor());
	if (hasFocus)
		SetLowColor(tint_color(ViewColor(), B_DARKEN_1_TINT));

	BString field;
	fText.CopyCharsInto(field, fFieldPositions[index * 2],
		fFieldPositions[index * 2 + 1] - fFieldPositions[index * 2]);

	BPoint point(bounds.LeftBottom());
	point.y -= bounds.Height() / 2.0 - 6.0;
	point.x += (bounds.Width() - StringWidth(field)) / 2;
	SetHighColor(0, 0, 0, 255);
	FillRect(bounds, B_SOLID_LOW);
	DrawString(field, point);
}
예제 #4
0
void TElementsSorter::HandleSorterResize(BMessage* theMessage)
{
	// Extract sorter ID from message
	int16 theID;

	if (theMessage->FindInt16("ID", &theID) == B_OK) {
		// Get sorter from list
		TSorterContainer* theSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(theID) );
		if (theSorter) {
			// Get drag point
			BPoint dragPt;
			if (theMessage->FindPoint("ResizePoint", &dragPt) == B_OK) {
				// Get current size
				BRect sizeRect = theSorter->Bounds();

				// Resize
				sizeRect.right = dragPt.x;

				// Check for width violation
				if (sizeRect.Width() > kMinSorterWidth) {
					// Resize the sorter based on drag
					theSorter->ResizeTo(sizeRect.Width(), sizeRect.Height());

					// Now scoot the other views over
					for (int32 index = theID+1; index < fSorterList->CountItems(); index++ ) {
						TSorterContainer* moveSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(index) );
						if (moveSorter) {
							// Get previous item in list for MoveTo coordinates
							TSorterContainer* prevSorter = static_cast<TSorterContainer*>(fSorterList->ItemAt(index-1) );
							if (prevSorter) {
								moveSorter->MoveTo( prevSorter->Frame().right+1, moveSorter->Frame().top);
							}
						}
					}

				}
			}
		}
	}
}
예제 #5
0
/**
 *	@brief	コンテナのスクロールバーを調整します。
 */
void TextDiffView::DiffPaneView::adjustScrollBar()
{
	if (NULL == scroller)
	{
		return;
	}

	BRect bounds = Bounds();
	
	// 縦スクロールバーについての調整
	BScrollBar* verticalBar = scroller->ScrollBar(B_VERTICAL);
	if (NULL != verticalBar)
	{
		float boundsHeight = bounds.Height() + 1;
		float height = getDataHeight();
		if (height < boundsHeight)
		{
			height = boundsHeight;
		}
		verticalBar->SetRange(0, height - boundsHeight);
		verticalBar->SetProportion(boundsHeight / height);
		
		BFont font;
		GetFont(&font);
		font_height fh;
		font.GetHeight(&fh);
		float lineHeight = static_cast<float>(ceil(fh.ascent + fh.descent + fh.leading));
		verticalBar->SetSteps(lineHeight, boundsHeight);
	}

	// 横スクロールバーについての調整	
	BScrollBar* horizontalBar = scroller->ScrollBar(B_HORIZONTAL);
	if (NULL != horizontalBar)
	{
		float boundsWidth = bounds.Width() + 1;
		horizontalBar->SetRange(0, HORIZONTAL_SCROLL_MAX);
		horizontalBar->SetProportion(boundsWidth / (HORIZONTAL_SCROLL_MAX + boundsWidth));
		horizontalBar->SetSteps(HORIZONTAL_SCROLL_MINSTEPS, boundsWidth);
	}
}
예제 #6
0
void ClientView::CopyBitmap(BBitmap *bmp1, BRect frame, const BBitmap *bmp2)
{
	char *bits1=(char *)bmp1->Bits();
	const char *bits2=(char *)bmp2->Bits();
	int32 bpr1=bmp1->BytesPerRow();
	int32 bpr2=bmp2->BytesPerRow();
	int32 height=int32(frame.Height()+1);
	int32 offset=int32(frame.left)*4+int32(frame.top)*bpr1;
	for(int32 i=0; i<height; i++)
		memcpy(&(bits1[offset+i*bpr1]), &(bits2[i*bpr2]), bpr2);
	
//	for(int32 i=0; i<height; i++)
//	{
//		bits1[offset+i*bpr1+2]=255;
//		bits1[offset+i*bpr1+bpr2-2]=255;
//	}
//	for(int32 j=2; j<bpr2-2; j+=4)
//	{
//		bits1[offset+j]=255;
//		bits1[offset+(height-1)*bpr1+j]=255;
//	}
}
예제 #7
0
StatusView::StatusView(
	BRect frame,
	RouteAppNodeManager *manager,
	BScrollBar *scrollBar)
	:	BStringView(frame, "StatusView", "", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
					B_FRAME_EVENTS | B_WILL_DRAW),
		m_scrollBar(scrollBar),
		m_icon(0),
		m_opacity(1.0),
		m_clock(0),
		m_dragging(false),
		m_backBitmap(0),
		m_backView(0),
		m_dirty(true),
		m_manager(manager) {
	D_ALLOC(("StatusView::StatusView()\n"));

	SetViewColor(B_TRANSPARENT_COLOR);
	SetFont(be_plain_font);
	
	allocBackBitmap(frame.Width(), frame.Height());
}
예제 #8
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());
	}
}
예제 #9
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);
	}
}
예제 #10
0
void
DataView::MakeVisible(int32 position)
{
	if (position < 0 || position > int32(fDataSize) - 1)
		return;

	BRect frame = SelectionFrame(fFocus, position, position);
	BRect bounds = Bounds();
	if (bounds.Contains(frame))
		return;

	// special case the first and the last line and column, so that
	// we can take kHorizontalSpace & kVerticalSpace into account

	if ((position % kBlockSize) == 0)
		frame.left -= kHorizontalSpace;
	else if ((position % kBlockSize) == kBlockSize - 1)
		frame.right += kHorizontalSpace;

	if (position < int32(kBlockSize))
		frame.top -= kVerticalSpace;
	else if (position > int32(fDataSize - kBlockSize))
		frame.bottom += kVerticalSpace;

	// compute the scroll point

	BPoint point = bounds.LeftTop();
	if (bounds.left > frame.left)
		point.x = frame.left;
	else if (bounds.right < frame.right)
		point.x = frame.right - bounds.Width();

	if (bounds.top > frame.top)
		point.y = frame.top;
	else if (bounds.bottom < frame.bottom)
		point.y = frame.bottom - bounds.Height();

	ScrollTo(point);
}
예제 #11
0
void
BBox::_DrawPlain(BRect labelBox)
{
	BRect rect = Bounds();
	rect.top += TopBorderOffset();

	float lightTint;
	float shadowTint;
	if (be_control_look != NULL) {
		lightTint = B_LIGHTEN_1_TINT;
		shadowTint = B_DARKEN_1_TINT;
	} else {
		lightTint = B_LIGHTEN_MAX_TINT;
		shadowTint = B_DARKEN_3_TINT;
	}

	if (rect.Height() == 0.0 || rect.Width() == 0.0) {
		// used as separator
		rgb_color shadow = tint_color(ViewColor(), B_DARKEN_2_TINT);

		SetHighColor(shadow);
		StrokeLine(rect.LeftTop(),rect.RightBottom());
	} else {
		// used as box
		rgb_color light = tint_color(ViewColor(), lightTint);
		rgb_color shadow = tint_color(ViewColor(), shadowTint);

		BeginLineArray(4);
			AddLine(BPoint(rect.left, rect.bottom),
					BPoint(rect.left, rect.top), light);
			AddLine(BPoint(rect.left + 1.0f, rect.top),
					BPoint(rect.right, rect.top), light);
			AddLine(BPoint(rect.left + 1.0f, rect.bottom),
					BPoint(rect.right, rect.bottom), shadow);
			AddLine(BPoint(rect.right, rect.bottom - 1.0f),
					BPoint(rect.right, rect.top + 1.0f), shadow);
		EndLineArray();
	}
}
예제 #12
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);
}
예제 #13
0
void
WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
	bool isFirst, bool isLast, bool isFront)
{
	if (fController->CloseButtonsAvailable())
		_DrawCloseButton(owner, frame, updateRect, isFirst, isLast, isFront);

	if (fIcon) {
		BRect iconBounds(0, 0, kIconSize - 1, kIconSize - 1);
		// clip to icon bounds, if they are smaller
		if (iconBounds.Contains(fIcon->Bounds()))
			iconBounds = fIcon->Bounds();
		else {
			// Try to scale down the icon by an even factor so the
			// final size is between 14 and 18 pixel size. If this fails,
			// the icon will simply be displayed at 18x18.
			float scale = 2;
			while ((fIcon->Bounds().Width() + 1) / scale > kIconSize)
				scale *= 2;
			if ((fIcon->Bounds().Width() + 1) / scale >= kIconSize - 4
				&& (fIcon->Bounds().Height() + 1) / scale >= kIconSize - 4
				&& (fIcon->Bounds().Height() + 1) / scale <= kIconSize) {
				iconBounds.right = (fIcon->Bounds().Width() + 1) / scale - 1;
				iconBounds.bottom = (fIcon->Bounds().Height() + 1) / scale - 1;
			}
		}
		BPoint iconPos(frame.left + kIconInset - 1,
			frame.top + floorf((frame.Height() - iconBounds.Height()) / 2));
		iconBounds.OffsetTo(iconPos);
		owner->SetDrawingMode(B_OP_ALPHA);
		owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		owner->DrawBitmap(fIcon, fIcon->Bounds(), iconBounds,
			B_FILTER_BITMAP_BILINEAR);
		owner->SetDrawingMode(B_OP_COPY);
		frame.left = frame.left + kIconSize + kIconInset * 2;
	}

	TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, isFront);
}
예제 #14
0
BRect
ActivityView::_LegendFrameAt(BRect frame, int32 index) const
{
	int32 column = index & 1;
	int32 row = index / 2;
	if (column == 0) {
		// Use the full width if there is only one item
		if (fSources.CountItems() != 1)
			frame.right = frame.left + floorf(frame.Width() / 2) - 5;
	} else
		frame.left = frame.right - floorf(frame.Width() / 2) + 5;

	BAutolock _(fSourcesLock);

	int32 rows = (fSources.CountItems() + 1) / 2;
	float height = floorf((frame.Height() - 5) / rows);

	frame.top = frame.top + 5 + row * height;
	frame.bottom = frame.top + height - 1;

	return frame;
}
예제 #15
0
// MouseMoved
void
DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
{
	if (msg && AcceptDragMessage(msg)) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW: {
				// remember drag message
				// this is needed to react on modifier changes
				_SetDragMessage(msg);
				// set drop target through virtual function
				SetDropTargetRect(msg, where);
				// go into autoscrolling mode
				BRect r = Bounds();
				r.InsetBy(0.0, r.Height() * SCROLL_AREA);
				SetAutoScrolling(!r.Contains(where));
				break;
			}
			case B_EXITED_VIEW:
				// forget drag message
				_SetDragMessage(NULL);
				SetAutoScrolling(false);
				// fall through
			case B_OUTSIDE_VIEW:
				_RemoveDropAnticipationRect();
				break;
		}
	} else {
		_RemoveDropAnticipationRect();
		BListView::MouseMoved(where, transit, msg);
		_SetDragMessage(NULL);
		SetAutoScrolling(false);

		BCursor cursor(B_HAND_CURSOR);
		SetViewCursor(&cursor, true);
	}
	fLastMousePos = where;
}
예제 #16
0
void ThresholdManipulator::SetPreviewBitmap(BBitmap *bm)
{
	if (preview_bitmap != bm) {
		delete copy_of_the_preview_bitmap;
		if (bm != NULL) {
			preview_bitmap = bm;
			copy_of_the_preview_bitmap = DuplicateBitmap(bm,0);
		}
		else {
			preview_bitmap = NULL;
			copy_of_the_preview_bitmap = NULL;
		}
	}

	if (preview_bitmap != NULL) {
		system_info info;
		get_system_info(&info);
		double speed = info.cpu_count * info.cpu_clock_speed;

		// Let's select a resolution that can handle all the pixels at least
		// 10 times in a second while assuming that one pixel calculation takes
		// about 50 CPU cycles.
		speed = speed / (10*50);
		BRect bounds = preview_bitmap->Bounds();
		float num_pixels = (bounds.Width()+1) * (bounds.Height() + 1);
		lowest_available_quality = 1;
		while ((num_pixels/lowest_available_quality/lowest_available_quality) > speed)
			lowest_available_quality *= 2;

		lowest_available_quality = min_c(lowest_available_quality,16);
		highest_available_quality = max_c(lowest_available_quality/2,1);
	}
	else {
		lowest_available_quality = 1;
		highest_available_quality = 1;
	}
	last_calculated_resolution = lowest_available_quality;
}
예제 #17
0
void GPView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case bmsgBitmapDirty:
		{
//			m_bitmap->Lock();
//			m_bitmap->display();
//			m_bitmap->Unlock();
//			printf("view (dirty) displaying %d commands\n",m_bitmap->ncommands);
			Draw(Bounds());
			break;
		};
		case bmsgBitmapResize:
		{
			BRect r;
			msg->FindRect("rect",&r);
			m_bitmap->ResizeTo(r.Width(),r.Height(),0);
			break;
		};
		case bmsgNewCmd:
		{
			char *cmd = NULL;
			int32 i, num;
			num = msg->FindInt32("numcmds");
			m_bitmap->addCommands(msg,num);
//			printf("view (new cmds) displaying %d commands\n",m_bitmap->ncommands);
			Draw(Bounds());
			break;
		}
		case bmsgClrCmd:
		{
			m_bitmap->clearCommands();
			break;
		}
		default:
			BView::MessageReceived(msg);
	};
};
예제 #18
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();
}
예제 #19
0
void
BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
{
	CALLED();

	fMenu = menu;
	InitMenu(menu);

	if ((Flags() & B_SUPPORTS_LAYOUT)) {
		fMenuBar = new _BMCMenuBar_(fixedSize, this);
	} else {
		frame.left = _MenuBarOffset();
		frame.top = kVMargin;
		frame.right -= kVMargin;
		frame.bottom -= kVMargin;

		TRACE("frame(%.1f, %.1f, %.1f, %.1f) (%.2f, %.2f)\n",
			frame.left, frame.top, frame.right, frame.bottom,
			frame.Width(), frame.Height());

		fMenuBar = new _BMCMenuBar_(frame, fixedSize, this);
	}

	if (fixedSize) {
		// align the menu bar in the full available space
		fMenuBar->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
			B_ALIGN_VERTICAL_UNSET));
	} else {
		// align the menu bar left in the available space
		fMenuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
			B_ALIGN_VERTICAL_UNSET));
	}

	AddChild(fMenuBar);
	fMenuBar->AddItem(menu);

	fMenuBar->SetFont(be_plain_font);
}
예제 #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;
}
예제 #21
0
static int cdactivate(cdCtxCanvas *ctxcanvas)
{
  BView* view = ctxcanvas->view;

  BLooper* looper = view->Looper();
  const char* ln = "";
  if (looper != NULL) {
	  ln = looper->Name();
  }
  printf("CD Activate view %p (%s), looper is %s\n", view, view->Name(), ln);

  BRect rect = view->Bounds();

  ctxcanvas->canvas->w = (int)(rect.Width());
  ctxcanvas->canvas->h = (int)(rect.Height());

  ctxcanvas->canvas->w_mm = ((double)ctxcanvas->canvas->w) / ctxcanvas->canvas->xres;
  ctxcanvas->canvas->h_mm = ((double)ctxcanvas->canvas->h) / ctxcanvas->canvas->yres;

  if (ctxcanvas->canvas->use_matrix)
    ctxcanvas->canvas->cxTransform(ctxcanvas, ctxcanvas->canvas->matrix);
  return CD_OK;
}
예제 #22
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;
}
예제 #23
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();
}
예제 #24
0
파일: WatchView.cpp 프로젝트: DonCN/haiku
void WatchView::Draw(BRect updateRect)
{
	super::Draw(updateRect);

	char string[5];
	sprintf(string, "@%03" B_PRId32, GetInternetTime());
	
	font_height height;         // center the text horizontally
	GetFontHeight(&height);     // and vertically in the Deskbar
	BRect rect = Bounds();
	float width = StringWidth(string);
	float x = 1 + (rect.Width() - width)/2;
	float y = height.ascent
			    + (rect.Height() - (height.ascent + height.descent))/2;

	SetHighColor(Parent()->ViewColor());
	FillRect(updateRect);

	SetLowColor(Parent()->ViewColor());
	SetHighColor(COLOR_FOREGROUND);
	SetDrawingMode(B_OP_OVER);
	DrawString(string, BPoint(x, y));
}
예제 #25
0
파일: GWindow.cpp 프로젝트: FEI17N/Lgi
bool GWindow::Attach(GViewI *Parent)
{
	if (!Wnd)
		return false;

	if (Wnd->Lock())
	{
		if (!Handle()->Parent())
		{
			// Set pos
			BRect r = Wnd->Bounds();
			Handle()->MoveTo(0, 0);
			Handle()->ResizeTo(r.Width(), r.Height());

			// Insert view
			Wnd->AddChild(Handle());
		}
			
		Wnd->Unlock();
	}

	return true;
}
예제 #26
0
/*protected*/
ValControl::ValControl(BRect frame, const char* name, const char* label,
                       BMessage* message, align_mode alignMode, align_flags alignFlags,
                       update_mode updateMode, bool backBuffer)
    : BControl(frame, name, label, message, B_FOLLOW_TOP|B_FOLLOW_LEFT,
               B_WILL_DRAW|B_FRAME_EVENTS),
      fDirty(true),
      fUpdateMode(updateMode),
      fLabelFont(be_bold_font),
      fValueFont(be_bold_font),
      fAlignMode(alignMode),
      fAlignFlags(alignFlags),
      fOrigBounds(Bounds()),
      fHaveBackBuffer(backBuffer),
      fBackBuffer(NULL),
      fBackBufferView(NULL)
{
    if (fHaveBackBuffer)
        _AllocBackBuffer(frame.Width(), frame.Height());

//	m_font.SetSize(13.0);
//	rgb_color red = {255,0,0,255};
//	SetViewColor(red);
}
예제 #27
0
TranslationManipulatorView::TranslationManipulatorView(BRect rect,
		TranslationManipulator* manipulator, const BMessenger& target)
	: BView(rect, "configuration_view", B_FOLLOW_ALL, B_WILL_DRAW)
	, fTarget(target)
	, fManipulator(manipulator)
{
	fXControl = new NumberControl("X:", "9999˚",
		new BMessage(HS_MANIPULATOR_ADJUSTING_FINISHED), 5, true);
	AddChild(fXControl);
	fXControl->MoveTo(rect.LeftTop());
	fXControl->ResizeToPreferred();
	float divider = fXControl->Divider();
	fXControl->ResizeBy(fXControl->TextView()->StringWidth("99999")
		- fXControl->TextView()->Bounds().Width(), 0);
	fXControl->TextView()->ResizeBy(fXControl->TextView()->StringWidth("99999")
		- fXControl->TextView()->Bounds().Width(), 0);

	fXControl->SetDivider(divider);

	BRect frame_rect = fXControl->Frame();
	frame_rect.OffsetBy(frame_rect.Width() + 10,0);

	fYControl = new NumberControl("Y:", "9999˚",
		new BMessage(HS_MANIPULATOR_ADJUSTING_FINISHED), 5, true);
	AddChild(fYControl);
	fYControl->MoveTo(frame_rect.LeftTop());
	fYControl->ResizeToPreferred();
	divider = fYControl->Divider();
	fYControl->ResizeBy(fYControl->TextView()->StringWidth("99999")
		- fYControl->TextView()->Bounds().Width(), 0);
	fYControl->TextView()->ResizeBy(fYControl->TextView()->StringWidth("99999")
		- fYControl->TextView()->Bounds().Width(), 0);
	fYControl->SetDivider(divider);

	ResizeTo(min_c(fYControl->Frame().right, rect.Width()),
		min_c(fYControl->Frame().Height(), rect.Height()));
}
예제 #28
0
void TCueSheetWindow::AdjustScrollBars()
{
	const BRect scrollRect = Bounds();

	// Get start and duration in pixels
	int32 startPixels        = TimeToPixels( fCueSheetView->StartTime(), fCueSheetView->GetTimeFormat(), fCueSheetView->GetResolution());
	int32 durationPixels = TimeToPixels( fCueSheetView->Duration(),  fCueSheetView->GetTimeFormat(), fCueSheetView->GetResolution());
	int32 resizePixels       = durationPixels - startPixels;

	// Adjust horizontal scrollbar
	AdjustScrollBar( fHScroll, scrollRect.Width(), kTickSpacing, resizePixels+kTimeScalerWidth+1, scrollRect.left);

	//      Vertical scrollbar area is total combined height of all channels
	//	Iterate through all of the channels and calculate height
	int32 totalHeight = 0;
	for (int32 index = 0; index < fCueSheetView->GetTotalChannels(); index++) {
		TCueChannel* theChannel = (TCueChannel*)fCueSheetView->GetChannelList()->ItemAt(index);
		if (theChannel)
			totalHeight += (int32)(theChannel->Bounds().Height());
	}

	// Adjust vertical scrollbar
	AdjustScrollBar( fVScroll, scrollRect.Height()-(kTimelineHeight+kToolbarHeight+kMenuHeight+10), kTickSpacing, totalHeight+kTimelineHeight+kToolbarHeight+kMenuHeight+1, scrollRect.top);
}
예제 #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();
	}
}
예제 #30
0
/*******************************************************
 * ARP-COLOUR-CONTROL
 *******************************************************/
ArpColourControl::ArpColourControl(	BRect frame,
									const char* name,
									const BString16* label,
									float div)
		: inherited(frame, name, 0, 0, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS),
		  mR(0), mG(0), mB(0), mA(0), mChangingMsg(0),
		  mChangedMsg(0)
{
	BRect		f(0, 0, 0, frame.Height());
	f.right = 0;
	if (label || div > 0) {
		if (div <= 0) div = StringWidth(label) + 2;
		f.right = div;
		BStringView*	sv = new BStringView(f, "label", label);
		if (sv) AddChild(sv);
//		f.left = f.right + 1;
	}

	float		iw = StringWidth("255") + 5;
	if ((mR = new_component(f, iw, "r", _R_MSG)) != 0) AddChild(mR);
	if ((mG = new_component(f, iw, "g", _G_MSG)) != 0) AddChild(mG);
	if ((mB = new_component(f, iw, "b", _B_MSG)) != 0) AddChild(mB);
	if ((mA = new_component(f, iw, "a", _A_MSG)) != 0) AddChild(mA);
}