Standardizing on BWindow::CenterOnScreen()

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33378 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2009-10-01 00:03:00 +00:00
parent 71bd3ba59c
commit 941098a211
13 changed files with 13 additions and 121 deletions
+1 -23
View File
@@ -35,7 +35,7 @@ BootManagerWindow::BootManagerWindow()
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
_CenterWindow();
CenterOnScreen();
}
@@ -73,25 +73,3 @@ BootManagerWindow::QuitRequested()
return true;
}
void
BootManagerWindow::_CenterWindow()
{
BScreen screen(this);
if (!screen.IsValid())
return;
BRect frame = screen.Frame();
BRect windowFrame = Frame();
float left = floor((frame.Width() - windowFrame.Width()) / 2);
float top = floor((frame.Height() - windowFrame.Height()) / 2);
if (left < 20)
left = 20;
if (top < 20)
top = 20;
MoveTo(left, top);
}
-2
View File
@@ -26,8 +26,6 @@ public:
private:
void _CenterWindow();
BootManagerController fController;
WizardView* fWizardView;
};
+2 -15
View File
@@ -102,19 +102,6 @@ FontHeight(BView* target, bool full)
}
static void
CenterWindowOnScreen(BWindow* w)
{
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
BPoint pt;
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
if (screenFrame.Contains(pt))
w->MoveTo(pt);
}
static void
BoundsSelection(int32 incX, int32 incY, float* x, float* y,
int32 xCount, int32 yCount)
@@ -473,7 +460,7 @@ ALMOST_DONE: // clean up and try to position the window
}
// if prefs dont yet exist or the window is not onscreen, center the window
CenterWindowOnScreen(this);
CenterOnScreen();
// set all the settings to defaults if we get here
DONE:
@@ -839,7 +826,7 @@ TWindow::ShowHelp()
text->Insert(" option-arrow key - moves the mouse location 1 pixel at a time\n");
text->Insert(" x marks the selection - the current selection has an 'x' in it\n");
CenterWindowOnScreen(w);
w->CenterOnScreen();
w->Show();
}
+1 -22
View File
@@ -133,7 +133,7 @@ MainWin::MainWin(BRect frame_rect)
VideoFormatChange(fSourceWidth, fSourceHeight, fWidthScale, fHeightScale);
CenterWindow();
CenterOnScreen();
}
@@ -1178,24 +1178,3 @@ MainWin::MessageReceived(BMessage *msg)
}
}
void
MainWin::CenterWindow()
{
BScreen screen(this);
if (!screen.IsValid())
return;
BRect frame = screen.Frame();
BRect windowFrame = Frame();
float left = floor((frame.Width() - windowFrame.Width()) / 2);
float top = floor((frame.Height() - windowFrame.Height()) / 2);
if (left < 20)
left = 20;
if (top < 20)
top = 20;
MoveTo(left, top);
}
-1
View File
@@ -75,7 +75,6 @@ public:
void ToggleNoBorder();
void ToggleNoMenu();
void ToggleNoBorderNoMenu();
void CenterWindow();
void ShowContextMenu(const BPoint &screen_point);
+3 -9
View File
@@ -219,13 +219,7 @@ const unsigned char kSmallNewGroupIcon [] = {
void
CenterWindowOnScreen(BWindow *window)
{
BRect screenFrame = BScreen(B_MAIN_SCREEN_ID).Frame();
BPoint point;
point.x = screenFrame.Width() / 2 - window->Bounds().Width() / 2;
point.y = screenFrame.Height() / 2 - window->Bounds().Height() / 2;
if (screenFrame.Contains(point))
window->MoveTo(point);
window->CenterOnScreen();
}
@@ -264,7 +258,7 @@ TFavoritesConfigWindow::TFavoritesConfigWindow(BRect frame, const char *title,
MoveTo(-1024, -1024);
Show();
AddParts(maxApps, maxDocs, maxFolders);
CenterWindowOnScreen(this);
CenterOnScreen();
Unlock();
AddShortcut('R', B_COMMAND_KEY, new BMessage(kRemove));
@@ -2219,7 +2213,7 @@ NameItemPanel::NameItemPanel(BWindow *parent, const char *initialtext)
AddParts(initialtext);
ResizeTo(Bounds().Width(), fCancelBtn->Frame().bottom + 10);
Unlock();
CenterWindowOnScreen(this);
CenterOnScreen();
}
@@ -142,7 +142,7 @@ ConfigurationWindow::ConfigurationWindow(BRect frame, DeviceItem *item)
B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE|B_NOT_RESIZABLE),
fItem(item)
{
CenterWindowOnScreen(this);
CenterOnScreen();
fItem->SetWindow(this);
InitWindow();
+1 -15
View File
@@ -48,25 +48,11 @@ const uint32 BTN_CONFIGURE = 'bcfg';
const uint32 SELECTION_CHANGED = 'slch';
// CenterWindowOnScreen -- Centers the BWindow to the Current Screen
void CenterWindowOnScreen(BWindow* w)
{
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
BPoint pt;
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
if (screenFrame.Contains(pt))
w->MoveTo(pt);
}
// ---------------------------------------------------------------------------------------------------------- //
// DevicesWindow - Constructor
DevicesWindow::DevicesWindow(BRect frame) : BWindow (frame, "Devices", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0)
{
InitWindow();
CenterWindowOnScreen(this);
CenterOnScreen();
// Load User Settings
BPath path;
-2
View File
@@ -31,8 +31,6 @@ class BStringView;
#define MODEM_ADDED 'moad'
void CenterWindowOnScreen(BWindow* w);
class ResourceUsageWindow : public BWindow {
public:
ResourceUsageWindow(BRect frame, BList &);
+1 -1
View File
@@ -44,7 +44,7 @@ ModemWindow::ModemWindow(BRect frame, BMessenger messenger)
fMessenger(messenger)
{
InitWindow();
CenterWindowOnScreen(this);
CenterOnScreen();
Show();
}
// -------------------------------------------------------------------------------------------------- //
@@ -188,7 +188,7 @@ ResourceUsageWindow::ResourceUsageWindow(BRect frame, BList &list)
: BWindow (frame, "Resource Usage", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL , B_NOT_ZOOMABLE|B_NOT_RESIZABLE)
{
InitWindow(list);
CenterWindowOnScreen(this);
CenterOnScreen();
Show();
}
// -------------------------------------------------------------------------------------------------- //
+1 -14
View File
@@ -13,24 +13,11 @@ Author: Sikosis ([email protected])
#include "ModemWindow.h"
// CenterWindowOnScreen -- Centers the BWindow to the Current Screen
static void CenterWindowOnScreen(BWindow* w)
{
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
BPoint pt;
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
if (screenFrame.Contains(pt))
w->MoveTo(pt);
}
// ------------------------------------------------------------------------------------------ //
// ModemWindow -- constructor for ModemWindow Class
ModemWindow::ModemWindow(BRect frame) : BWindow (frame, "", B_MODAL_WINDOW, B_NOT_RESIZABLE , 0)
{
InitWindow();
CenterWindowOnScreen(this);
CenterOnScreen();
Show();
}
// ------------------------------------------------------------------------------- //
+1 -15
View File
@@ -33,25 +33,11 @@ const uint32 TXT_NEW_CONNECTION = 'TxCx';
// ---------------------------------------------------------------------------------------------------------- //
// CenterWindowOnScreen -- Centers the BWindow to the Current Screen
static void CenterWindowOnScreen(BWindow* w)
{
BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());
BPoint pt;
pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;
pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;
if (screenFrame.Contains(pt))
w->MoveTo(pt);
}
// ---------------------------------------------------------------------------------------------------------- //
// NewConnectionWindow - Constructor
NewConnectionWindow::NewConnectionWindow(BRect frame) : BWindow (frame, "NewConnectionWindow", B_MODAL_WINDOW , B_NOT_RESIZABLE , 0)
{
InitWindow();
CenterWindowOnScreen(this);
CenterOnScreen();
Show();
}