* The window is now centered on screen when opened for the first time.

* Simplified and cleaned up the "window not on screen" code.
* Enlarged the default window size a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36525 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-04-29 08:37:12 +00:00
parent 0230fc14ea
commit 5151639147
2 changed files with 15 additions and 31 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2006, Haiku, Inc. * Copyright 2002-2010, Haiku, Inc.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -25,7 +25,7 @@ DataTranslationsSettings::DataTranslationsSettings()
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
return; return;
fCorner = BPoint(50, 50); fCorner = BPoint(-1, -1);
path.Append("system/DataTranslations settings"); path.Append("system/DataTranslations settings");
BFile file(path.Path(), B_READ_ONLY); BFile file(path.Path(), B_READ_ONLY);
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009, Haiku, Inc. * Copyright 2002-2010, Haiku, Inc.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -36,41 +36,25 @@
#include "XTab.h" #include "XTab.h"
#include "YTab.h" #include "YTab.h"
#define DTW_RIGHT 400
#define DTW_BOTTOM 300
const uint32 kMsgTranslatorInfo = 'trin'; const uint32 kMsgTranslatorInfo = 'trin';
const uint32 kMsgSelectedTranslator = 'trsl'; const uint32 kMsgSelectedTranslator = 'trsl';
DataTranslationsWindow::DataTranslationsWindow() DataTranslationsWindow::DataTranslationsWindow()
: BWindow(BRect(0, 0, DTW_RIGHT, DTW_BOTTOM), : BWindow(BRect(0, 0, 550, 350), "DataTranslations", B_TITLED_WINDOW,
"DataTranslations", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) | B_AUTO_UPDATE_SIZE_LIMITS)
{ {
MoveTo(dynamic_cast<DataTranslationsApplication *>(be_app)->WindowCorner()); MoveTo(dynamic_cast<DataTranslationsApplication *>(be_app)->WindowCorner());
_SetupViews();
// Make sure that the window isn't positioned off screen // Make sure that the window isn't positioned off screen
BScreen screen; BScreen screen;
BRect scrf = screen.Frame(), winf = Frame(); BRect screenFrame = screen.Frame();
float x = winf.left, y = winf.top; if (!screenFrame.Contains(Frame()))
scrf.top += 24; CenterOnScreen();
scrf.left += 5;
scrf.right -= 5;
if (winf.left < scrf.left)
x = scrf.left;
if (winf.right > scrf.right)
x = scrf.right - winf.Width() - 5;
if (winf.top < scrf.top)
y = scrf.top;
if (winf.bottom > scrf.bottom)
y = scrf.bottom - winf.Height() - 15;
if (x != winf.left || y != winf.top)
MoveTo(x, y);
_SetupViews();
BTranslatorRoster *roster = BTranslatorRoster::Default(); BTranslatorRoster *roster = BTranslatorRoster::Default();
roster->StartWatching(this); roster->StartWatching(this);