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();
}
Esempio n. 2
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);
}
Esempio n. 3
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 :)
}
Esempio n. 4
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);
}
PPSize
DisplayDevice_Haiku::getDisplayResolution() const
{
	BScreen screen;
	BRect frame = screen.Frame();
	return PPSize(frame.IntegerWidth(), frame.IntegerHeight());
}
Esempio n. 6
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 );
}
Esempio n. 7
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();
	
}
Esempio n. 8
0
void
MediaView::InitObject()
{
	BScreen screen;

	fMediaFile = NULL;
	fVideoTrack = NULL;
	fAudioTrack = NULL;
	fAudioOutput = NULL;
	fMediaBar = NULL;
	fBitmap = NULL;
	fBitmapDepth = screen.ColorSpace();
	fCurTime = 0;
	fPlayerThread = B_ERROR;
	fPlaySem = B_ERROR;
	fScrubSem = B_ERROR;
	fPlaying = false;
	fSnoozing = false;
	fAudioDumpingBuffer = NULL;

	BRect mediaBarFrame = Bounds();
	mediaBarFrame.top = mediaBarFrame.bottom - kMediaBarHeight;
	fMediaBar = new _MediaBar_(mediaBarFrame, this);
	AddChild(fMediaBar);

	SetViewColor(B_TRANSPARENT_32_BIT);
}
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));
	}
}
Esempio n. 10
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);
}
Esempio n. 11
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);
}
Esempio n. 12
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;
}
Esempio n. 13
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());
}
Esempio n. 14
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);
}
Esempio n. 15
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);
}
Esempio n. 16
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);
}
Esempio n. 17
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);
}
Esempio n. 18
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;   
	}
}
Esempio 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());
}
Esempio n. 20
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;

}
Esempio n. 21
0
void InitSelectedMap()
{
	BScreen screen;
	rgb_color c, d;
	int32 i;

	for (i = 0; i < 255; i++)
	{
		d = c = screen.ColorForIndex(i);

		c.red = c.red * 2 / 3;
		c.green = c.green * 2 / 3;
		c.blue = c.blue * 2 / 3;

		gSelectedMap[i] = screen.IndexForColor(c);

		d.red = (c.red + 438) / 3;
		d.green = (c.green + 438) / 3;
		d.blue = (c.blue + 438) / 3;

		gDisabledMap[i] = screen.IndexForColor(d);
	}

	gSelectedMap[255] = 255;
	gDisabledMap[255] = 255;
} /* InitSelectedMap */
Esempio n. 22
0
status_t
GlutGameMode::Leave()
{
	if (!fActive)
		return B_OK;

	if (fGameModeWorkspace < 0)
		return B_ERROR;

	if (fGameModeWindow) {
		glutDestroyWindow(fGameModeWindow);
		fGameModeWindow = 0;
		if (fPreviousWindow)
			glutSetWindow(fPreviousWindow);
	}

	if (_CompareModes(&fOriginalMode, &fCurrentMode)) {
		// Restore original display mode
		BScreen screen;
		// Make restored mode the default one,
		// as it was before entering game mode...
		screen.SetMode(fGameModeWorkspace, &fOriginalMode, true);
	}

	fActive = false;
	return B_OK;
}
Esempio n. 23
0
status_t
DWindowHWInterface::WaitForRetrace(bigtime_t timeout)
{
	// Locking shouldn't be necessary here - R5 should handle this for us. :)
	BScreen screen;
	return screen.WaitForRetrace(timeout);
}
Esempio n. 24
0
void BBackView::Create()
{
	BScreen * screen = new BScreen();
	color_space clrmap = screen->ColorSpace(); 
	back = new BBitmap(Bounds(), clrmap, true);
	delete screen;	
}
Esempio n. 25
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());
	}
}
Esempio 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!"
} 
Esempio n. 27
0
void restoreWorkspaceResolution()
{
	BScreen screen;
	display_mode displayMode;

	if (screen.GetMode(&displayMode) == B_OK && memcmp(&displayMode,&gDisplayMode,sizeof(display_mode)))
		screen.SetMode(&gDisplayMode);
}
Esempio n. 28
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 );
}
Esempio 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);
}
Esempio n. 30
0
status_t
GlutGameMode::Enter()
{
	display_mode* mode = _FindMatchingMode();
	if (!mode)
		return B_BAD_VALUE;

	BScreen screen;
	if (!fActive) {
		// First enter: remember this workspace original mode...
		fGameModeWorkspace = current_workspace();
		screen.GetMode(fGameModeWorkspace, &fOriginalMode);
	}

	// Don't make it new default mode for this workspace...
	status_t status = screen.SetMode(fGameModeWorkspace, mode, false);
	if (status != B_OK)
		return status;

	// Retrieve the new active display mode, which could be
	// a sligth different than the one we asked for...
	screen.GetMode(fGameModeWorkspace, &fCurrentMode);

	if (!fGameModeWindow) {
		// create a new window
		fPreviousWindow = glutGetWindow();
		fGameModeWindow = glutCreateWindow("glutGameMode");
		if (!fGameModeWindow)
			return Leave();
	} else
		// make sure it's the current window
		glutSetWindow(fGameModeWindow);

	BDirectWindow *directWindow
		= dynamic_cast<BDirectWindow*>(gState.currentWindow->Window());
	if (directWindow == NULL)
		// Hum?!
		return B_ERROR;

	// Give it some useless title, except for debugging (thread name).
	BString name;
	name << "Game Mode " << fCurrentMode.virtual_width
		<< "x" << fCurrentMode.virtual_height
		<< ":" << _GetModePixelDepth(&fCurrentMode)
		<< "@" << _GetModeRefreshRate(&fCurrentMode);

	// force the game mode window to fullscreen
	directWindow->Lock();
	directWindow->SetTitle(name.String());
	directWindow->SetFullScreen(true);
	directWindow->Unlock();

	fDisplayChanged = true;
	fActive = true;

	return B_OK;
}