* 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:
@@ -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);
|
||||||
@@ -41,7 +41,7 @@ DataTranslationsSettings::DataTranslationsSettings()
|
|||||||
|
|
||||||
|
|
||||||
DataTranslationsSettings::~DataTranslationsSettings()
|
DataTranslationsSettings::~DataTranslationsSettings()
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -140,7 +124,7 @@ status_t
|
|||||||
DataTranslationsWindow::_ShowConfigView(int32 id)
|
DataTranslationsWindow::_ShowConfigView(int32 id)
|
||||||
{
|
{
|
||||||
// Shows the config panel for the translator with the given id
|
// Shows the config panel for the translator with the given id
|
||||||
|
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
@@ -222,7 +206,7 @@ DataTranslationsWindow::_SetupViews()
|
|||||||
// Add the translator name view
|
// Add the translator name view
|
||||||
fTranslatorNameView = new BStringView("TranName", "None");
|
fTranslatorNameView = new BStringView("TranName", "None");
|
||||||
|
|
||||||
// Populate the translators list view
|
// Populate the translators list view
|
||||||
_PopulateListView();
|
_PopulateListView();
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
@@ -403,6 +387,6 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
|
|||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user