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 "ConfigWindow.h"
|
||||||
#include "CenterContainer.h"
|
#include "CenterContainer.h"
|
||||||
@@ -233,11 +236,10 @@ class AboutTextView : public BTextView
|
|||||||
|
|
||||||
|
|
||||||
ConfigWindow::ConfigWindow()
|
ConfigWindow::ConfigWindow()
|
||||||
: BWindow(BRect(100.0, 100.0, 580.0, 540.0),
|
: BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
|
||||||
"E-mail", B_TITLED_WINDOW,
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
fLastSelectedAccount(NULL),
|
||||||
fLastSelectedAccount(NULL),
|
fSaveSettings(false)
|
||||||
fSaveSettings(false)
|
|
||||||
{
|
{
|
||||||
// create controls
|
// create controls
|
||||||
|
|
||||||
@@ -423,6 +425,7 @@ ConfigWindow::ConfigWindow()
|
|||||||
top->AddChild(revertButton);
|
top->AddChild(revertButton);
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
// this will also move our window to the stored position
|
||||||
|
|
||||||
fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
|
fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
|
||||||
fAccountsListView->MakeFocus(true);
|
fAccountsListView->MakeFocus(true);
|
||||||
@@ -438,19 +441,15 @@ void
|
|||||||
ConfigWindow::MakeHowToView()
|
ConfigWindow::MakeHowToView()
|
||||||
{
|
{
|
||||||
BResources *resources = BApplication::AppResources();
|
BResources *resources = BApplication::AppResources();
|
||||||
if (resources)
|
if (resources) {
|
||||||
{
|
|
||||||
size_t length;
|
size_t length;
|
||||||
char *buffer = (char *)resources->FindResource('ICON',101,&length);
|
char *buffer = (char *)resources->FindResource('ICON', 101, &length);
|
||||||
if (buffer)
|
if (buffer) {
|
||||||
{
|
BBitmap *bitmap = new BBitmap(BRect(0, 0, 63, 63), B_CMAP8);
|
||||||
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
|
// copy and enlarge a 32x32 8-bit bitmap
|
||||||
char *bits = (char *)bitmap->Bits();
|
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)
|
if ((i % 32) == 0)
|
||||||
j += 64;
|
j += 64;
|
||||||
|
|
||||||
@@ -458,14 +457,13 @@ ConfigWindow::MakeHowToView()
|
|||||||
b[0] = b[1] = b[64] = b[65] = buffer[i];
|
b[0] = b[1] = b[64] = b[65] = buffer[i];
|
||||||
}
|
}
|
||||||
fConfigView->AddChild(new BitmapView(bitmap));
|
fConfigView->AddChild(new BitmapView(bitmap));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect rect = fConfigView->Bounds();
|
BRect rect = fConfigView->Bounds();
|
||||||
BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW);
|
BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE, B_WILL_DRAW);
|
||||||
text->SetViewColor(fConfigView->Parent()->ViewColor());
|
text->SetViewColor(fConfigView->Parent()->ViewColor());
|
||||||
text->SetAlignment(B_ALIGN_CENTER);
|
text->SetAlignment(B_ALIGN_CENTER);
|
||||||
text->SetText(
|
text->SetText(
|
||||||
@@ -476,7 +474,7 @@ ConfigWindow::MakeHowToView()
|
|||||||
"\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。"
|
"\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。"
|
||||||
"\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。"));
|
"\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。"));
|
||||||
rect = text->Bounds();
|
rect = text->Bounds();
|
||||||
text->ResizeTo(rect.Width(),text->TextHeight(0,42));
|
text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
|
||||||
text->SetTextRect(rect);
|
text->SetTextRect(rect);
|
||||||
|
|
||||||
text->MakeEditable(false);
|
text->MakeEditable(false);
|
||||||
@@ -492,30 +490,30 @@ void
|
|||||||
ConfigWindow::LoadSettings()
|
ConfigWindow::LoadSettings()
|
||||||
{
|
{
|
||||||
Accounts::Delete();
|
Accounts::Delete();
|
||||||
Accounts::Create(fAccountsListView,fConfigView);
|
Accounts::Create(fAccountsListView, fConfigView);
|
||||||
|
|
||||||
// load in general settings
|
// load in general settings
|
||||||
BMailSettings *settings = new BMailSettings();
|
BMailSettings settings;
|
||||||
status_t status = SetToGeneralSettings(settings);
|
status_t status = SetToGeneralSettings(&settings);
|
||||||
if (status == B_OK)
|
if (status == B_OK) {
|
||||||
{
|
// move own window
|
||||||
// adjust own window frame
|
MoveTo(settings.ConfigWindowFrame().LeftTop());
|
||||||
BScreen screen(this);
|
} else {
|
||||||
BRect screenFrame(screen.Frame().InsetByCopy(0,5));
|
fprintf(stderr, MDR_DIALECT_CHOICE("Error retrieving general settings: %s\n",
|
||||||
BRect frame(settings->ConfigWindowFrame());
|
"一般設定の収得に失敗: %s\n"), strerror(status));
|
||||||
|
|
||||||
if (screenFrame.Contains(frame.LeftTop()))
|
|
||||||
MoveTo(frame.LeftTop());
|
|
||||||
else // center 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;
|
BScreen screen(this);
|
||||||
|
BRect screenFrame(screen.Frame().InsetByCopy(0, 5));
|
||||||
|
if (!screenFrame.Contains(Frame().LeftTop())
|
||||||
|
|| !screenFrame.Contains(Frame().RightBottom()))
|
||||||
|
status = B_ERROR;
|
||||||
|
|
||||||
|
if (status != B_OK) {
|
||||||
|
// center window on screen
|
||||||
|
MoveTo((screenFrame.Width() - Frame().Width()) / 2,
|
||||||
|
(screenFrame.Height() - Frame().Height()) / 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user