Fonts Preflet : The centering didn't work.

* Make use of CenterOnScreen(); to center the window rather than the dirty trick I tried months ago.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33071 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2009-09-12 01:39:18 +00:00
parent 608aa1d9db
commit 8a0ea31a5a
2 changed files with 3 additions and 22 deletions

View File

@ -36,8 +36,7 @@ static const uint32 kMsgCheckFonts = 'chkf';
MainWindow::MainWindow() MainWindow::MainWindow()
: BWindow(BRect(0, 0, 1, 1), "Fonts", B_TITLED_WINDOW, : BWindow(BRect(0, 0, 1, 1), "Fonts", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
fCentered(false)
{ {
fDefaultsButton = new BButton("defaults", "Defaults", fDefaultsButton = new BButton("defaults", "Defaults",
new BMessage(kMsgSetDefaults), B_WILL_DRAW); new BMessage(kMsgSetDefaults), B_WILL_DRAW);
@ -77,19 +76,14 @@ MainWindow::MainWindow()
if (fSettings.WindowCorner() == BPoint(-1, -1)) { if (fSettings.WindowCorner() == BPoint(-1, -1)) {
// center window on screen // center window on screen
fCentered = true; CenterOnScreen();
} else { } else {
MoveTo(fSettings.WindowCorner()); MoveTo(fSettings.WindowCorner());
// make sure window is on screen // make sure window is on screen
BScreen screen(this); BScreen screen(this);
if (!screen.Frame().InsetByCopy(10, 10).Intersects(Frame())) if (!screen.Frame().InsetByCopy(10, 10).Intersects(Frame()))
fCentered = true; CenterOnScreen();
}
if (fCentered) {
// draw offscreen to avoid flashing windows
MoveTo(BPoint(-1000, -1000));
} }
fRunner = new BMessageRunner(this, new BMessage(kMsgCheckFonts), 3000000); fRunner = new BMessageRunner(this, new BMessage(kMsgCheckFonts), 3000000);
@ -99,16 +93,6 @@ MainWindow::MainWindow()
} }
void
MainWindow::Show()
{
BWindow::Show();
if (fCentered)
_Center();
}
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
delete fRunner; delete fRunner;

View File

@ -27,14 +27,11 @@ public:
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void Show();
private: private:
void _Center(); void _Center();
bool fCentered;
BMessageRunner* fRunner; BMessageRunner* fRunner;
FontView* fFontsView; FontView* fFontsView;
BButton* fDefaultsButton; BButton* fDefaultsButton;