It now also centers the window on screen if the settings couldn't be found or at least
one corner is not visible on screen. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19942 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
/* ConfigWindow - main eMail config window
|
||||
**
|
||||
** Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
/*
|
||||
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
|
||||
* Copyright 2007, Haiku Inc. All Rights Reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! main E-Mail config window
|
||||
|
||||
#include "ConfigWindow.h"
|
||||
#include "CenterContainer.h"
|
||||
@@ -233,8 +236,7 @@ class AboutTextView : public BTextView
|
||||
|
||||
|
||||
ConfigWindow::ConfigWindow()
|
||||
: BWindow(BRect(100.0, 100.0, 580.0, 540.0),
|
||||
"E-mail", B_TITLED_WINDOW,
|
||||
: BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fLastSelectedAccount(NULL),
|
||||
fSaveSettings(false)
|
||||
@@ -423,6 +425,7 @@ ConfigWindow::ConfigWindow()
|
||||
top->AddChild(revertButton);
|
||||
|
||||
LoadSettings();
|
||||
// this will also move our window to the stored position
|
||||
|
||||
fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
|
||||
fAccountsListView->MakeFocus(true);
|
||||
@@ -438,19 +441,15 @@ void
|
||||
ConfigWindow::MakeHowToView()
|
||||
{
|
||||
BResources *resources = BApplication::AppResources();
|
||||
if (resources)
|
||||
{
|
||||
if (resources) {
|
||||
size_t length;
|
||||
char *buffer = (char *)resources->FindResource('ICON', 101, &length);
|
||||
if (buffer)
|
||||
{
|
||||
if (buffer) {
|
||||
BBitmap *bitmap = new BBitmap(BRect(0, 0, 63, 63), B_CMAP8);
|
||||
if (bitmap && bitmap->InitCheck() == B_OK)
|
||||
{
|
||||
if (bitmap && bitmap->InitCheck() == B_OK) {
|
||||
// copy and enlarge a 32x32 8-bit bitmap
|
||||
char *bits = (char *)bitmap->Bits();
|
||||
for (int32 i=0, j=-64; i<(int32)length; i++)
|
||||
{
|
||||
for (int32 i = 0, j = -64; i < (int32)length; i++) {
|
||||
if ((i % 32) == 0)
|
||||
j += 64;
|
||||
|
||||
@@ -458,8 +457,7 @@ ConfigWindow::MakeHowToView()
|
||||
b[0] = b[1] = b[64] = b[65] = buffer[i];
|
||||
}
|
||||
fConfigView->AddChild(new BitmapView(bitmap));
|
||||
}
|
||||
else
|
||||
} else
|
||||
delete bitmap;
|
||||
}
|
||||
}
|
||||
@@ -495,27 +493,27 @@ ConfigWindow::LoadSettings()
|
||||
Accounts::Create(fAccountsListView, fConfigView);
|
||||
|
||||
// load in general settings
|
||||
BMailSettings *settings = new BMailSettings();
|
||||
status_t status = SetToGeneralSettings(settings);
|
||||
if (status == B_OK)
|
||||
{
|
||||
// adjust own window frame
|
||||
BMailSettings settings;
|
||||
status_t status = SetToGeneralSettings(&settings);
|
||||
if (status == B_OK) {
|
||||
// move own window
|
||||
MoveTo(settings.ConfigWindowFrame().LeftTop());
|
||||
} else {
|
||||
fprintf(stderr, MDR_DIALECT_CHOICE("Error retrieving general settings: %s\n",
|
||||
"一般設定の収得に失敗: %s\n"), strerror(status));
|
||||
}
|
||||
|
||||
BScreen screen(this);
|
||||
BRect screenFrame(screen.Frame().InsetByCopy(0, 5));
|
||||
BRect frame(settings->ConfigWindowFrame());
|
||||
if (!screenFrame.Contains(Frame().LeftTop())
|
||||
|| !screenFrame.Contains(Frame().RightBottom()))
|
||||
status = B_ERROR;
|
||||
|
||||
if (screenFrame.Contains(frame.LeftTop()))
|
||||
MoveTo(frame.LeftTop());
|
||||
else // center on screen
|
||||
MoveTo((screenFrame.Width() - frame.Width()) / 2,(screenFrame.Height() - frame.Height()) / 2);
|
||||
if (status != B_OK) {
|
||||
// center window on screen
|
||||
MoveTo((screenFrame.Width() - Frame().Width()) / 2,
|
||||
(screenFrame.Height() - Frame().Height()) / 2);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, MDR_DIALECT_CHOICE (
|
||||
"Error retrieving general settings: %s\n",
|
||||
"一般設定の収得に失敗: %s\n"),
|
||||
strerror(status));
|
||||
|
||||
delete settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user