Exemplo n.º 1
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 = screenWidth / 10;
	float workspaceHeight = workspaceWidth / aspectRatio;

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

	float tabHeight = Frame().top - DecoratorFrame().top;

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

	ResizeTo(width, height);

	origin = screen.Frame().RightBottom();
	origin.x -= kScreenBorderOffset + width;
	origin.y -= kScreenBorderOffset + height;

	MoveTo(origin);
}
Exemplo n.º 2
0
void Win::WorkspacesChanged(uint32 oldws, uint32 newws) 
{
	//we don't really care what workspace we're running in, however, we need to
	//reset the size limits to match.
	BScreen Screen;
	SetSizeLimits(300,Screen.Frame().right,200,Screen.Frame().bottom);
}
Exemplo n.º 3
0
void PrefKeys::MessageReceived(BMessage *msg){
	char s[255];
	int32 i, index;
	BScreen screen;
	BPoint p;
	BListItem *it = NULL;

	switch(msg->what){
	case SELECT:
		index = list->FullListCurrentSelection();
		if(index < 0){
			break; // nothign selected 
		}
		it = list->FullListItemAt(index);
		if (it){
			i = ((KeyItem*)it)->GetID();				// needed to convert the outline numbers, they are inverted !
			if (i>0){
				sprintf(s, "item: %s", KeyBind.GetID(i));
				p.x =  (screen.Frame().left+screen.Frame().right)/2;
				p.y =  (screen.Frame().top+screen.Frame().bottom)/2;
				m_index = index;
				(new SetKeyWindow(p, i, this));
			}
		}
		break;

	default:
		BView::MessageReceived(msg);
		break;   
	}
}
Exemplo n.º 4
0
BView* instantiate_deskbar_item()
{
	// Calculate the correct size of the Deskbar replicant first
	
	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);

	// ╔═╤═╕ A Deskbar replicant can be 16px tall and 129px wide at most.
	// ║ │ │ We use 1px for the top and left borders (shown as double)
	// ╟─┼─┤ and divide the remainder equally. However, we keep in mind
	// ║ │ │ that the actual width and height of each workspace is smaller
	// ╙─┴─┘ by 1px, because of bottom/right borders (shown as single).
	// When calculating workspace width, we must ensure that the assumed
	// actual workspace height is not negative. Zero is OK.

	float height = 16;
	float rowHeight = floor((height - 1) / rows);
	if (rowHeight < 1)
		rowHeight = 1;

	float columnWidth = floor((rowHeight - 1) * aspectRatio) + 1;

	float width = columnWidth * columns + 1;
	if (width > 129)
		width = 129;

	return new WorkspacesView(BRect (0, 0, width - 1, height - 1), false);
}
Exemplo n.º 5
0
MWindow::MWindow(int width, int height, const char* title)
	: BWindow(BRect(80,80,80+width,80+height), title, B_TITLED_WINDOW_LOOK,B_NORMAL_WINDOW_FEEL,0)//B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{	
	BScreen scr;
	image_width = width;
	image_height = height;
	
	float oWidth = ( Frame().left + width )<scr.Frame().Width()?width:(scr.Frame().Width()-Frame().left-20);
	float oHeight = ( Frame().top + height )<scr.Frame().Height()?height:(scr.Frame().Height()-Frame().top-20);
	
	renderRect = Bounds();
	prev_frame = Frame();
	
	BView *view = new BView(Bounds(),"container",B_FOLLOW_ALL, B_WILL_DRAW);
	view->SetViewColor(0,0,0);
	AddChild(view);
	
	fb = new FBView(Bounds(), width, height);
	fb->SetViewColor(B_TRANSPARENT_32_BIT);
	view->AddChild(fb);
	
	ResizeTo(oWidth, oHeight);

	renderRect = Bounds();
	prev_frame = Frame();
	
}
Exemplo n.º 6
0
void
LoginApp::ReadyToRun()
{
	BScreen screen;

	if (fEditShelfMode) {
		BAlert* alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("You can "
			"customize the desktop shown behind the Login application by "
			"dropping replicants onto it.\n\n"
			"When you are finished just quit the application (Cmd-Q)."),
			B_TRANSLATE("OK"));
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go(NULL);
	} else {
		BRect frame(0, 0, 450, 150);
		frame.OffsetBySelf(screen.Frame().Width()/2 - frame.Width()/2,
			screen.Frame().Height()/2 - frame.Height()/2);
		fLoginWindow = new LoginWindow(frame);
		fLoginWindow->Show();
	}

	fDesktopWindow = new DesktopWindow(screen.Frame(), fEditShelfMode);
	fDesktopWindow->Show();
	// TODO: add a shelf with Activity Monitor replicant :)
}
Exemplo n.º 7
0
void
WorkspacesWindow::FrameResized(float width, float height)
{
	if (!modifiers() & B_SHIFT_KEY) {
		BWindow::FrameResized(width, height);
		return;
	}

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

	BScreen screen;
	float screenWidth = screen.Frame().Width();
	float screenHeight = screen.Frame().Height();

	float windowAspectRatio
		= (columns * screenWidth) / (rows * screenHeight);

	float newHeight = width / windowAspectRatio;

	if (height != newHeight)
		ResizeTo(width, newHeight);

	fSettings->SetWindowFrame(Frame());
}
Exemplo n.º 8
0
// ResizeToImage --  Resizes the window to fit snugly around the image.
//                   Should be called ONLY when there is 1 image loaded
//                   and no more. & only if the window isn't FullScreen
void PictureViewer::ResizeToImage() {
   if (setup->FullScreen()) return;
   if (thePic == NULL) return;
  
  // the window needs to be adjusted by byX and byY points
   float byX = Bounds().Width() - thePic->Bounds().Width() - 3;
   float byY = Bounds().Height() - thePic->Bounds().Height() - 3;
  
  // Now we're going to make sure it's still on the screen.
    // get the coordinates
   BScreen *theScreen = new BScreen();
    float screen_right  = theScreen->Frame().Width();
    float screen_bottom = theScreen->Frame().Height();
   delete theScreen;

  // determine where the new position should be
   float newX = Window()->Frame().right - byX;
   float newY = Window()->Frame().bottom - byY;

  // is the new position greater than the screen width? hmm... fix if so
   if (newX > screen_right)   byX = -(screen_right - Window()->Frame().right) + 5;
   if (newY > screen_bottom)  byY = -(screen_bottom - Window()->Frame().bottom) + 5;

  // finalize
   Window()->ResizeBy( - byX, - byY );
}
Exemplo n.º 9
0
LJAboutWindow::LJAboutWindow()
 : BWindow(BRect(100, 295, 411, 464), "About AliveJournal", B_TITLED_WINDOW, 0, B_CURRENT_WORKSPACE)
{

	MainView = new LJAboutMainView();
	AddChild(MainView);
	SetSizeLimits(0, 1000, 0, 1000);

    char *title = new char[32];
    sprintf( title, "About AliveJournal v%s", VERSION_NUMBER );
    SetTitle( title );
    sprintf( title, "AliveJournal v%s", VERSION_NUMBER );
    MainView->titlestring->SetText( title );
    delete title;

    // Center the about box.
    BScreen *screen = new BScreen(this);
    int x = 0;
    int y = 0;

    x = screen->Frame().IntegerWidth() / 2;
    y = screen->Frame().IntegerHeight() / 2;

    x = x - Frame().IntegerWidth() / 2;
    y = y - Frame().IntegerHeight() / 2;

    MoveTo( x, y );
    
    delete screen;

}
Exemplo n.º 10
0
WorkspacesSettings::WorkspacesSettings()
	:
	fAutoRaising(false),
	fAlwaysOnTop(false),
	fHasTitle(true),
	fHasBorder(true),
	fSwitchOnWheel(false),
	fLoaded(false)
{
	UpdateScreenFrame();

	BScreen screen;

	BFile file;
	if (_Open(file, B_READ_ONLY) == B_OK) {
		BMessage settings;
		if (settings.Unflatten(&file) == B_OK) {
			if (settings.FindRect("window", &fWindowFrame) == B_OK
				&& settings.FindRect("screen", &fScreenFrame) == B_OK)
				fLoaded = true;

			settings.FindBool("auto-raise", &fAutoRaising);
			settings.FindBool("always on top", &fAlwaysOnTop);

			if (settings.FindBool("has title", &fHasTitle) != B_OK)
				fHasTitle = true;
			if (settings.FindBool("has border", &fHasBorder) != B_OK)
				fHasBorder = true;
			if (settings.FindBool("switch on wheel", &fSwitchOnWheel) != B_OK)
				fSwitchOnWheel = false;
		}
	} else {
		// try reading BeOS compatible settings
		BPath path;
		if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
			path.Append(kOldSettingFile);
			BFile file(path.Path(), B_READ_ONLY);
			if (file.InitCheck() == B_OK
				&& file.Read(&fWindowFrame, sizeof(BRect)) == sizeof(BRect)) {
				// we now also store the frame of the screen to know
				// in which context the window frame has been chosen
				BRect frame;
				if (file.Read(&frame, sizeof(BRect)) == sizeof(BRect))
					fScreenFrame = frame;
				else
					fScreenFrame = screen.Frame();

				fLoaded = true;
			}
		}
	}

	if (fLoaded) {
		// if the current screen frame is different from the one
		// just loaded, we need to alter the window frame accordingly
		if (fScreenFrame != screen.Frame())
			UpdateFramesForScreen(screen.Frame());
	}
}
Exemplo n.º 11
0
Settings::Settings()
	:
	fMessage(kMsgDiskProbeSettings),
	fUpdated(false)
{
	float fontSize = be_plain_font->Size();
	int32 windowWidth = DataView::WidthForFontSize(fontSize) + 20;
		// TODO: make scrollbar width variable

	BScreen screen;
	fMessage.AddRect("window_frame", BLayoutUtils::AlignInFrame(screen.Frame(),
		BSize(windowWidth, windowWidth),
		BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)));
	fMessage.AddInt32("base_type", kHexBase);
	fMessage.AddFloat("font_size", fontSize);
	fMessage.AddBool("case_sensitive", true);
	fMessage.AddInt8("find_mode", kAsciiMode);

	BFile file;
	if (Open(&file, B_READ_ONLY) != B_OK)
		return;

	// TODO: load/save settings as flattened BMessage - but not yet,
	//		since that will break compatibility with R5's DiskProbe

	disk_probe_settings settings;
	if (file.Read(&settings, sizeof(settings)) == sizeof(settings)) {
#if B_HOST_IS_BENDIAN
		// settings are saved in little endian
		settings.window_frame.left = B_LENDIAN_TO_HOST_FLOAT(
			settings.window_frame.left);
		settings.window_frame.top = B_LENDIAN_TO_HOST_FLOAT(
			settings.window_frame.top);
		settings.window_frame.right = B_LENDIAN_TO_HOST_FLOAT(
			settings.window_frame.right);
		settings.window_frame.bottom = B_LENDIAN_TO_HOST_FLOAT(
			settings.window_frame.bottom);
#endif
		// check if the window frame is on screen at all
		BScreen screen;
		if (screen.Frame().Contains(settings.window_frame.LeftTop())
			&& settings.window_frame.Width() < screen.Frame().Width()
			&& settings.window_frame.Height() < screen.Frame().Height())
			fMessage.ReplaceRect("window_frame", settings.window_frame);

		if (settings.base_type == kHexBase
			|| settings.base_type == kDecimalBase)
			fMessage.ReplaceInt32("base_type",
				B_LENDIAN_TO_HOST_INT32(settings.base_type));
		if (settings.font_size >= 0 && settings.font_size <= 72)
			fMessage.ReplaceFloat("font_size",
				float(B_LENDIAN_TO_HOST_INT32(settings.font_size)));

		fMessage.ReplaceBool("case_sensitive",
			settings.flags & kCaseSensitive);
		fMessage.ReplaceInt8("find_mode",
			settings.flags & kHexFindMode ? kHexMode : kAsciiMode);
	}
}
Exemplo n.º 12
0
BRect CColorPicker::NicePosition()
{
	BRect p(0, 0, 390, 170);
	BScreen s;
	
	p.OffsetBy((s.Frame().Width() - p.Width()) / 2, (s.Frame().Height() - p.Height()) / 3);
	
	return p;
} /* CColorPicker::NicePosition */
Exemplo n.º 13
0
void
ThemesApp::ReadyToRun()
{
	BScreen s;
	BRect frame(0, 0, 550, 300);
	frame.OffsetBySelf(s.Frame().Width()/2 - frame.Width()/2, 
						s.Frame().Height()/2 - frame.Height()/2);
	BWindow *w = new BWindow(frame, "Themes", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_QUIT_ON_WINDOW_CLOSE);
	ThemeInterfaceView *v = new ThemeInterfaceView(w->Bounds());
	w->AddChild(v);
	w->Show();
}
Exemplo n.º 14
0
void
MWindow::SetFullscreen(int fs)
{
	if(fs==1) {
		prev_frame = Frame();
		BScreen scr;
		MoveTo(0,0);		
		ResizeTo(scr.Frame().right+1,scr.Frame().bottom+1);
	} else {
		MoveTo(prev_frame.left,prev_frame.top);
		ResizeTo(prev_frame.Width(),prev_frame.Height());				
	}	
}
Exemplo n.º 15
0
void
CaptureView::MouseMoved(BPoint point, uint32 transit,
	const BMessage* dragMessage)
{
	ConvertToScreen(&point);

	if (fMovedOutWhat != 0 && !fMovedOutFrame.Contains(point))
		_SendMovedOutNotification();

	uint32 modifiers = ::modifiers();
	if ((modifiers & fModifierMask) == 0) {
		_UpdateLast(point);
		return;
	}

	// TODO: we will need to iterate over all existing screens to find the
	// right one!
	BScreen screen;
	BRect screenFrame = screen.Frame();

	uint32 location = kNowhere;
	if (point.x <= screenFrame.left && fLastPoint.x > screenFrame.left)
		location = kLeftEdge;
	else if (point.x >= screenFrame.right && fLastPoint.x < screenFrame.right)
		location = kRightEdge;
	else if (point.y <= screenFrame.top && fLastPoint.y > screenFrame.top)
		location = kTopEdge;
	else if (point.y >= screenFrame.bottom && fLastPoint.y < screenFrame.bottom)
		location = kBottomEdge;

	if (location != kNowhere)
		_Notify(location, fLastTeam);

	_UpdateLast(point);
}
Exemplo n.º 16
0
bool
make_sure_frame_is_on_screen(BRect& frame, BWindow* window)
{
	BScreen* screen = window != NULL ? new BScreen(window)
		: new BScreen(B_MAIN_SCREEN_ID);

	bool success = false;
	if (frame.IsValid() && screen->IsValid()) {
		BRect screenFrame = screen->Frame();
		if (!screenFrame.Contains(frame)) {
			// make sure frame fits in the screen
			if (frame.Width() > screenFrame.Width())
				frame.right -= frame.Width() - screenFrame.Width() + 10.0;
			if (frame.Height() > screenFrame.Height())
				frame.bottom -= frame.Height() - screenFrame.Height() + 30.0;
			// frame is now at the most the size of the screen
			if (frame.right > screenFrame.right)
				frame.OffsetBy(-(frame.right - screenFrame.right), 0.0);
			if (frame.bottom > screenFrame.bottom)
				frame.OffsetBy(0.0, -(frame.bottom - screenFrame.bottom));
			if (frame.left < screenFrame.left)
				frame.OffsetBy((screenFrame.left - frame.left), 0.0);
			if (frame.top < screenFrame.top)
				frame.OffsetBy(0.0, (screenFrame.top - frame.top));
		}
		success = true;
	}
	delete screen;
	return success;
}
Exemplo n.º 17
0
void
Utility::_MakeTabSpaceTransparent(BBitmap* screenshot, BRect frame) const
{
	if (!frame.IsValid() || screenshot->ColorSpace() != B_RGBA32)
		return;

	if (!frame.Contains(tabFrame))
		return;

	float tabHeight = tabFrame.bottom - tabFrame.top;

	BRegion tabSpace(frame);
	frame.OffsetBy(0, tabHeight);
	tabSpace.Exclude(frame);
	tabSpace.Exclude(tabFrame);
	frame.OffsetBy(0, -tabHeight);
	tabSpace.OffsetBy(-frame.left, -frame.top);
	BScreen screen;
	BRect screenFrame = screen.Frame();
	tabSpace.OffsetBy(-screenFrame.left, -screenFrame.top);

	BView view(screenshot->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, 0);
	screenshot->AddChild(&view);
	if (view.Looper() && view.Looper()->Lock()) {
		view.SetDrawingMode(B_OP_COPY);
		view.SetHighColor(B_TRANSPARENT_32_BIT);

		for (int i = 0; i < tabSpace.CountRects(); i++)
			view.FillRect(tabSpace.RectAt(i));

		view.Sync();
		view.Looper()->Unlock();
	}
	screenshot->RemoveChild(&view);
}
Exemplo n.º 18
0
PPSize
DisplayDevice_Haiku::getDisplayResolution() const
{
	BScreen screen;
	BRect frame = screen.Frame();
	return PPSize(frame.IntegerWidth(), frame.IntegerHeight());
}
Exemplo n.º 19
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;
		frame.InsetBy(-1, -1); // PEN_SIZE in ShowImageView

		SetFlags(Flags() | B_NOT_RESIZABLE | B_NOT_MOVABLE);

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

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

	fImageView->SetFullScreen(fFullScreen);
	fImageView->SetShowCaption(fFullScreen && fShowCaption);
	MoveTo(frame.left, frame.top);
	ResizeTo(frame.Width(), frame.Height());
}
Exemplo n.º 20
0
void
ExpanderWindow::_ExpandListingText()
{
	float delta = fLongestLine - fListingText->Frame().Width();

	if (delta > 0) {
		BScreen screen;
		BRect screenFrame = screen.Frame();

		if (Frame().right + delta > screenFrame.right)
			delta = screenFrame.right - Frame().right - 4.0f;

		ResizeBy(delta, 0.0f);
	}

	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);

	if (minWidth < Frame().Width() + delta) {
		// set the Zoom limit as the minimal required size
		SetZoomLimits(Frame().Width() + delta,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	} else {
		// set the zoom limit based on minimal window size allowed
		SetZoomLimits(minWidth,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	}
}
void PDocument::Init()
{
	TRACE();
	bool locked = Lock();
	allNodes		= new BList();
	allConnections	= new BList();
	selected		= new BList();
	valueChanged	= new BList();
//	trashed			= new BList();

	printerSetting	= NULL;
	documentSetting	= new BMessage();
	bounds			= BRect(0,0,600,800);
	printableRect	= NULL;
	paperRect		= NULL;
	savePanel		= NULL;
	width			= 600;
	height			= 800;
	dirty			= true;
	entryRef		= NULL;
	autoSaveRef		= NULL;
	modified		= false;
	editorManager	= new PEditorManager(this);
	commandManager	= new PCommandManager(this);
	//** to do.. helpManager		= new HelpManager();
	BScreen *tmpScreen	= new BScreen();
	BRect	windowRect	= tmpScreen->Frame();
	windowRect.InsetBy(50,50);
	window			= new PWindow(windowRect,this);
	autoSaver		= new BMessageRunner(BMessenger(this),
										 new BMessage(P_C_AUTO_SAVE),
										 autoSaveIntervall);
	if (locked)
		UnlockLooper();
}
Exemplo n.º 22
0
Point2 OS_Haiku::get_screen_position(int p_screen) const {
	// TODO: make this work with the p_screen parameter
	BScreen *screen = new BScreen(window);
	BRect frame = screen->Frame();
	delete screen;
	return Point2i(frame.left, frame.top);
}
Exemplo n.º 23
0
Size2 OS_Haiku::get_screen_size(int p_screen) const {
	// TODO: make this work with the p_screen parameter
	BScreen *screen = new BScreen(window);
	BRect frame = screen->Frame();
	delete screen;
	return Size2i(frame.IntegerWidth() + 1, frame.IntegerHeight() + 1);
}
Exemplo n.º 24
0
void BubbleHelper::DisplayHelp(char *text, BPoint where)
{
    textview->SetText(text);
    
    float height=textview->TextHeight(0,2E6)+0;
    float width=0;
    int numlines=textview->CountLines();
    int linewidth;
    for(int i=0;i<numlines;i++)
        if((linewidth=int(textview->LineWidth(i)))>width)
            width=linewidth;
    textwin->ResizeTo(width+2,height);
    textview->SetTextRect(BRect(1,0,width+1,height+1));
    
    BScreen screen;
    BPoint dest=where+BPoint(0,20);
    BRect screenframe=screen.Frame();
    if((dest.y+height)>(screenframe.bottom-3))
        dest.y=dest.y-(16+height+8);

    if((dest.x+width+4)>(screenframe.right))
        dest.x=dest.x-((dest.x+width+4)-screenframe.right);

    ShowBubble(dest);
}
Exemplo n.º 25
0
// ---------------------------------------------------------------------------------- RHTML_Tag_Menu - Start -
void RHTMLTagMenu::Start(BPoint point, int32 offset, MenuType _menutype, std::vector<BString> &_tags, BString _tag, BString _param)
{
 menutype=_menutype;
 tag=_tag;
 tags=_tags;
 param=_param;
 tag.ToLower();
 param.ToLower();
 Lock();

 if (_menutype==R_TAG_MENU)
  fListView->str = "<";
 if (_menutype==R_PARAM_MENU)
  fListView->str = " ";
 if (_menutype==R_VALUE_MENU)
  fListView->str = "";
 
 LoadList();
 if (fListView->CountItems()>0)
 {
  fListView->sel1=offset-1;
  fListView->sel2=offset;
  
  if (_menutype==R_VALUE_MENU)
   fListView->sel1++;

  SetFeel(B_MODAL_APP_WINDOW_FEEL);
  Activate(true);
  fListView->MakeFocus(true);
  fListView->SetEventMask(B_POINTER_EVENTS);
  float left,top;
  BScreen screen;

  if (screen.Frame().bottom>point.y+221)
   top=point.y+20;
  else
   top=point.y-210;

  if (screen.Frame().right>point.x+Bounds().right+1)
   left=point.x;
  else
   left=point.x-Bounds().right;

  MoveTo(left,top);
 }
 Unlock();
}
Exemplo n.º 26
0
void 
Shelf::StartConfig(BView *view) 
{
	PRINT(("%p:%s()\n", this, __FUNCTION__));
	fInConfig = true;

	BStringView* titleString = new BStringView("Title",
		B_TRANSLATE("Shelf"));
	titleString->SetFont(be_bold_font);

	BStringView* copyrightString = new BStringView("Copyright",
		B_TRANSLATE("© 2012 François Revol."));

	BTextView* helpText = new BTextView("Help Text");
	helpText->MakeEditable(false);
	helpText->SetViewColor(view->ViewColor());
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	helpText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	BString help;
	help << B_TRANSLATE("Drop replicants on the full-screen window "
		"behind the preferences panel.");
	//help << "\n\n";
	//help << B_TRANSLATE("You can also drop colors.");
	helpText->SetText(help.String());

	BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_HALF_ITEM_SPACING)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(titleString)
		.Add(copyrightString)
		.AddStrut(roundf(be_control_look->DefaultItemSpacing() / 2))
		.Add(helpText)
		.AddGlue()
	.End();

	BScreen screen;
	fConfigWindow = new BWindow(screen.Frame(), "Shelf Config",
		B_UNTYPED_WINDOW, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
		| B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS);

	BView *shelfView = new BView(fConfigWindow->Bounds(), "ShelfView", 
		B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS);
	shelfView->SetViewColor(216, 216, 216, 0);

	fConfigWindow->AddChild(shelfView);

	fShelfData.Seek(SEEK_SET, 0LL);
	fShelf = new BShelf(&fShelfData, shelfView);
	fShelf->SetDisplaysZombies(true);
	fShelfData.Seek(SEEK_SET, 0LL);

	// start the Looper
	fConfigWindow->Show();

	fConfigWindow->Lock();
	fConfigWindow->SendBehind(view->Window());
	fConfigWindow->Unlock();

	//"\nDrop replicants on me!"
} 
Exemplo n.º 27
0
void GX_BDirectWindow::Center()
{
	BRect rect = Bounds();
	BScreen b;
	BRect bounds = b.Frame();
	float32_t w = bounds.right, h = bounds.bottom;
	MoveTo( (w - (rect.right - rect.left)) / 2, (h - (rect.bottom - rect.top)) / 2 );
}
Exemplo n.º 28
0
QueueWindow::QueueWindow( hb_handle_t * handle )
    : BWindow( BRect( 0,0,10,10 ), "Queue",
               B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL,
               B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
{
    /* Add the QueueView */
    fView = new QueueView( handle );
    AddChild( fView );
    
    /* Resize to fit */
    ResizeTo( fView->Bounds().Width(), fView->Bounds().Height() );
    
    /* Center */
    BScreen screen;
    MoveTo( ( screen.Frame().Width() - fView->Bounds().Width() ) / 2,
            ( screen.Frame().Height() - fView->Bounds().Height() ) / 2 );
}
Exemplo n.º 29
0
void 
TDragRegion::MouseMoved(BPoint where, uint32 code, const BMessage *message)
{
	if (IsTracking()) {
		BScreen screen;
		BRect frame = screen.Frame();

		float hDivider = frame.Width() / 6;
		hDivider = (hDivider < kMinimumWindowWidth + 10.0f) ? kMinimumWindowWidth + 10.0f : hDivider;
		float miniDivider = frame.top + kMiniHeight + 10.0f;
		float vDivider = frame.Height() / 2;
#ifdef FULL_MODE
		float thirdScreen = frame.Height() / 3;
#endif		
		BRect topLeft(frame.left, frame.top, frame.left + hDivider, miniDivider);
		BRect topMiddle(frame.left + hDivider, frame.top, frame.right - hDivider, vDivider);
		BRect topRight(frame.right - hDivider, frame.top, frame.right, miniDivider);

#ifdef FULL_MODE
		vDivider = miniDivider + thirdScreen;
#endif
		BRect middleLeft(frame.left, miniDivider, frame.left + hDivider, vDivider);
		BRect middleRight(frame.right - hDivider, miniDivider, frame.right, vDivider);

#ifdef FULL_MODE
		BRect leftSide(frame.left, vDivider, frame.left + hDivider, frame.bottom - thirdScreen);
		BRect rightSide(frame.right - hDivider, vDivider, frame.right, frame.bottom - thirdScreen);

		vDivider = frame.bottom - thirdScreen;
#endif		
		BRect bottomLeft(frame.left, vDivider, frame.left + hDivider, frame.bottom);
		BRect bottomMiddle(frame.left + hDivider, vDivider, frame.right - hDivider, frame.bottom);
		BRect bottomRight(frame.right - hDivider, vDivider, frame.right, frame.bottom);

		if (where != fPreviousPosition) {
			fPreviousPosition = where;
			ConvertToScreen(&where);

			// use short circuit evaluation for convenience
			if (SwitchModeForRect(where, topLeft, true, true, true, kMiniState)
				|| SwitchModeForRect(where, topMiddle, false, true, true, kExpandoState)
				|| SwitchModeForRect(where, topRight, true, false, true, kMiniState)

				|| SwitchModeForRect(where, middleLeft, true, true, true, kExpandoState)
				|| SwitchModeForRect(where, middleRight, true, false, true, kExpandoState)

#ifdef FULL_MODE
				|| SwitchModeForRect(where, leftSide, true, true, true, kFullState)
				|| SwitchModeForRect(where, rightSide, true, false, true, kFullState)
#endif
				|| SwitchModeForRect(where, bottomLeft, true, true, false, kMiniState)
				|| SwitchModeForRect(where, bottomMiddle, false, true, false, kExpandoState)
				|| SwitchModeForRect(where, bottomRight, true, false, false, kMiniState))
				;
		}
	} else
		BControl::MouseMoved(where, code, message);
}
BRect GenericFunctions::CenteredFrame(float window_width, float window_height) {
	// position return rectangle based on screen coordinates
	BScreen screen;

	float screen_width  = screen.Frame().Width();
	float screen_height = screen.Frame().Height();

	float frame_width   = screen_width  - window_width;
	float frame_height  = screen_height - window_height;

	float frame_start_x = frame_width   / 2;
	float frame_start_y = frame_height  / 2;
	float frame_end_x   = frame_start_x + window_width;
	float frame_end_y   = frame_start_y + window_height;

	// assemble window frame size
	return BRect(frame_start_x, frame_start_y, frame_end_x, frame_end_y);
}