[haiku-commits] BRANCH axeld-github.imap - src/preferences/mail

  • From: axeld-github.imap <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 5 Nov 2012 12:49:05 +0100 (CET)

added 1 changeset to branch 'refs/remotes/axeld-github/imap'
old head: d78d20db18f73947e98229812abc80136910e8b2
new head: 03ce17366b2993897cc0c721b30dac270760fe79

----------------------------------------------------------------------------

03ce173: Reworked the mail preferences.
  
  * Made it use the layout API.
  * Removed options that no longer apply (dial-up, for example).
  * Cleanup.
  * There are a few issues left, though, for example, the BTextView is not
    correctly sized, and it currently crashes in the protocol panels.

                                   [ Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      03ce17366b2993897cc0c721b30dac270760fe79

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Mon Nov  5 10:49:46 2012 UTC

----------------------------------------------------------------------------

10 files changed, 320 insertions(+), 694 deletions(-)
src/preferences/mail/AutoConfigView.cpp   |   4 +-
src/preferences/mail/CenterContainer.cpp  | 105 ------
src/preferences/mail/CenterContainer.h    |  31 --
src/preferences/mail/ConfigViews.cpp      | 221 ++++--------
src/preferences/mail/ConfigViews.h        |  41 +--
src/preferences/mail/ConfigWindow.cpp     | 490 ++++++++++----------------
src/preferences/mail/ConfigWindow.h       |  28 +-
src/preferences/mail/FilterConfigView.cpp |  91 ++---
src/preferences/mail/FilterConfigView.h   |   2 +-
src/preferences/mail/Jamfile              |   1 -

----------------------------------------------------------------------------

diff --git a/src/preferences/mail/AutoConfigView.cpp 
b/src/preferences/mail/AutoConfigView.cpp
index d93028e..e8b3f5d 100644
--- a/src/preferences/mail/AutoConfigView.cpp
+++ b/src/preferences/mail/AutoConfigView.cpp
@@ -505,8 +505,8 @@ ServerSettingsView::_GetAuthEncrMenu(entry_ref protocol,
        BMenuField** authField, BMenuField** sslField)
 {
        BMailAccountSettings dummySettings;
-       BView *view = CreateConfigView(protocol, 
dummySettings.InboundSettings(),
-               dummySettings, fImageId);
+       BView *view = new BStringView("", "Not 
here!");//CreateConfigView(protocol, dummySettings.InboundSettings(),
+//             dummySettings, fImageId);
 
        *authField = (BMenuField *)view->FindView("auth_method");
        *sslField = (BMenuField *)view->FindView("flavor");
diff --git a/src/preferences/mail/CenterContainer.cpp 
b/src/preferences/mail/CenterContainer.cpp
deleted file mode 100644
index 1ff1d49..0000000
--- a/src/preferences/mail/CenterContainer.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* CenterContainer - a container which centers its contents in the middle
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-
-
-#include "CenterContainer.h"
-
-#include <ObjectList.h>
-
-
-CenterContainer::CenterContainer(BRect rect,bool centerHoriz)
-       : BView(rect,NULL,B_FOLLOW_ALL,0),
-       fSpacing(7),
-       fWidth(0),
-       fCenterHoriz(centerHoriz)
-{
-}
-
-
-void CenterContainer::AttachedToWindow()
-{
-       if (Parent() != NULL)
-               SetViewColor(Parent()->ViewColor());
-}
-
-
-void CenterContainer::AllAttached()
-{
-       Layout();
-}
-
-
-void CenterContainer::FrameResized(float width,float height)
-{
-       Layout();
-}
-
-
-void CenterContainer::GetPreferredSize(float *width, float *height)
-{
-       // calculate dimensions (and, well, layout views)
-       if (fWidth == 0)
-               Layout();
-
-       if (width)
-               *width = fWidth;
-       if (height)
-               *height = fHeight;
-}
-
-
-void CenterContainer::Layout()
-{
-       // compute the size of all views
-       fHeight = 0;  fWidth = 0;
-       for (int32 i = 0;BView *view = ChildAt(i);i++)
-       {
-               if (i != 0)             // the spacing between to items
-                       fHeight += fSpacing;
-               fHeight += view->Bounds().Height();
-
-               if (view->Bounds().Width() > fWidth)
-                       fWidth = view->Bounds().Width();
-       }
-
-       // layout views
-       float y = (Bounds().Height() - fHeight) / 2;
-       for (int32 i = 0;BView *view = ChildAt(i);i++)
-       {
-               view->MoveTo(fCenterHoriz ? (Bounds().Width() - 
view->Bounds().Width()) / 2
-                                                                 : 
view->Frame().left,
-                                        y);
-               y += view->Bounds().Height() + fSpacing;
-       }
-}
-
-
-void CenterContainer::SetSpacing(float spacing)
-{
-       if (fSpacing == spacing)
-               return;
-
-       fSpacing = spacing;
-       Layout();
-}
-
-
-void CenterContainer::DeleteChildren()
-{
-       // there happens some magic in DetachedFromWindow and therefore all 
views
-       // have to exist so delete them later...
-       // TODO: maybe rethink this
-       BObjectList<BView> temp;
-       // remove all child views
-       for (int32 i = CountChildren();i-- > 0;)
-       {
-               BView *view = ChildAt(i);
-               temp.AddItem(view);
-               RemoveChild(view);
-       }
-       for (int32 i = 0; i < temp.CountItems(); i++)
-               delete temp.ItemAt(i);
-}
-
diff --git a/src/preferences/mail/CenterContainer.h 
b/src/preferences/mail/CenterContainer.h
deleted file mode 100644
index 624eaf3..0000000
--- a/src/preferences/mail/CenterContainer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef CENTER_CONTAINER_H
-#define CENTER_CONTAINER_H
-/* CenterContainer - a container which centers its contents in the middle
-**
-** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
-*/
-
-
-#include <View.h>
-
-
-class CenterContainer : public BView
-{
-       public:
-               CenterContainer(BRect rect,bool centerHoriz = true);
-
-               virtual void    AttachedToWindow();
-               virtual void    AllAttached();
-               virtual void    FrameResized(float width, float height);
-               virtual void    GetPreferredSize(float *width, float *height);
-
-               void                    Layout();
-               void                    SetSpacing(float spacing);
-               void                    DeleteChildren();
-
-       private:
-               float                   fSpacing, fWidth, fHeight;
-               bool                    fCenterHoriz;
-};
-
-#endif /* CENTER_CONTAINER_H */
diff --git a/src/preferences/mail/ConfigViews.cpp 
b/src/preferences/mail/ConfigViews.cpp
index ddad293..eab3c04 100644
--- a/src/preferences/mail/ConfigViews.cpp
+++ b/src/preferences/mail/ConfigViews.cpp
@@ -10,22 +10,22 @@
 
 
 #include "ConfigViews.h"
-#include "CenterContainer.h"
 
-#include <TextControl.h>
-#include <ListView.h>
-#include <PopUpMenu.h>
-#include <MenuField.h>
-#include <MenuItem.h>
-#include <Button.h>
-#include <Looper.h>
-#include <Path.h>
 #include <Alert.h>
+#include <Button.h>
+#include <Catalog.h>
+#include <Directory.h>
 #include <Entry.h>
 #include <FindDirectory.h>
-#include <Directory.h>
-#include <Catalog.h>
+#include <ListView.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
+#include <Looper.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <Path.h>
+#include <PopUpMenu.h>
+#include <TextControl.h>
 
 #include <string.h>
 
@@ -45,72 +45,35 @@ const uint32 kMsgAccountNameChanged = 'anmc';
 const uint32 kMsgProtocolChanged = 'prch';
 
 
-BView*
-CreateConfigView(const entry_ref& addon, BMailProtocolSettings& settings,
-       BMailAccountSettings& accountSettings, image_id& image)
-{
-       BView* (*instantiateConfig)(BMailProtocolSettings& settings,
-               BMailAccountSettings& accountSettings);
-       BPath path(&addon);
-       image = load_add_on(path.Path());
-       if (image < 0)
-               return NULL;
-
-       if (get_image_symbol(image, "instantiate_config_panel", 
B_SYMBOL_TYPE_TEXT,
-                       (void **)&instantiateConfig) != B_OK) {
-               unload_add_on(image);
-               image = -1;
-               return NULL;
-       }
-
-       return instantiateConfig(settings, accountSettings);
-}
-
-
 // #pragma mark -
 
 
-AccountConfigView::AccountConfigView(BRect rect, BMailAccountSettings* account)
+AccountConfigView::AccountConfigView(BMailAccountSettings* account)
        :
-       BBox(rect),
+       BBox("account"),
        fAccount(account)
 {
        SetLabel(B_TRANSLATE("Account settings"));
 
-       rect = Bounds().InsetByCopy(8, 8);
-       rect.top += 10;
-       CenterContainer *view = new CenterContainer(rect, false);
-       view->SetSpacing(5);
-
-       // determine font height
-       font_height fontHeight;
-       view->GetFontHeight(&fontHeight);
-       int32 height = (int32)(fontHeight.ascent + fontHeight.descent
-               + fontHeight.leading) + 5;
-
-       rect = view->Bounds();
-       rect.bottom = height + 5;
-
-       float labelWidth = view->StringWidth(B_TRANSLATE("Account name:")) + 6;
-
-       view->AddChild(fNameControl = new BTextControl(rect, NULL,
-               B_TRANSLATE("Account name:"), NULL,
-               new BMessage(kMsgAccountNameChanged)));
-       fNameControl->SetDivider(labelWidth);
-       view->AddChild(fRealNameControl = new BTextControl(rect, NULL,
-               B_TRANSLATE("Real name:"), NULL, NULL));
-       fRealNameControl->SetDivider(labelWidth);
-       view->AddChild(fReturnAddressControl = new BTextControl(rect, NULL,
-               B_TRANSLATE("Return address:"), NULL, NULL));
-       fReturnAddressControl->SetDivider(labelWidth);
-//                     control->TextView()->HideTyping(true);
-
-       float w, h;
-       view->GetPreferredSize(&w, &h);
-       ResizeTo(w + 15, h + 22);
-       view->ResizeTo(w, h);
-
-       AddChild(view);
+       fNameControl = new BTextControl(NULL, B_TRANSLATE("Account name:"), 
NULL,
+               new BMessage(kMsgAccountNameChanged));
+       fRealNameControl = new BTextControl(NULL, B_TRANSLATE("Real name:"), 
NULL,
+               NULL);
+       fReturnAddressControl = new BTextControl(NULL,
+               B_TRANSLATE("Return address:"), NULL, NULL);
+
+       BView* contents = new BView(NULL, 0);
+       AddChild(contents);
+
+       BLayoutBuilder::Grid<>(contents, 0.f)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
+               .Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)
+               .Add(fRealNameControl->CreateLabelLayoutItem(), 0, 1)
+               .Add(fRealNameControl->CreateTextViewLayoutItem(), 1, 1)
+               .Add(fReturnAddressControl->CreateLabelLayoutItem(), 0, 2)
+               .Add(fReturnAddressControl->CreateTextViewLayoutItem(), 1, 2)
+               .AddGlue(0, 3);
 }
 
 
@@ -154,46 +117,41 @@ AccountConfigView::UpdateViews()
 }
 
 
-//     #pragma mark -
+// #pragma mark -
 
 
-InProtocolsConfigView::InProtocolsConfigView(BMailAccountSettings* account)
+ProtocolConfigView::ProtocolConfigView(BMailAccountSettings& accountSettings,
+       const entry_ref& ref, BMailProtocolSettings& settings)
        :
-       BBox(BRect(0, 0, 100, 100)),
-       fAccount(account),
+       BBox("protocol"),
+       fSettings(settings),
        fConfigView(NULL)
 {
-       BString label = "Can't find protocol.";
-       entry_ref protocol = fAccount->InboundAddOnRef();
-       BMailProtocolSettings& inboundSettings = fAccount->InboundSettings();
-
-       fConfigView = CreateConfigView(protocol, inboundSettings, *account,
-               fImageID);
+       status_t status = _CreateConfigView(ref, settings, accountSettings);
+       BView* view = fConfigView;
 
        if (fConfigView != NULL) {
-               float w = fConfigView->Bounds().Width();
-               float h = fConfigView->Bounds().Height();
-               fConfigView->MoveTo(3, 13);
-               ResizeTo(w + 6, h + 16);
-               AddChild(fConfigView);
-
-               fConfigView->MoveTo(3, 21);
-               ResizeBy(0, 8);
-               if (CenterContainer *container
-                       = dynamic_cast<CenterContainer *>(Parent())) {
-                       container->Layout();
-               }
-               label = protocol.name;
-
-               fConfigView->MoveTo(3, 21);
-               ResizeBy(0, 8);
+               SetLabel(ref.name);
+       } else {
+               BString text(B_TRANSLATE("An error occurred while creating the "
+                       "config view: %error."));
+               text.ReplaceAll("%error", strerror(status));
+               view = new BStringView("error", text.String());
+
+               SetLabel(B_TRANSLATE("Error!"));
        }
-       SetLabel(label);
+
+       BView* contents = new BView(NULL, 0);
+       AddChild(contents);
+
+       BLayoutBuilder::Group<>(contents, B_VERTICAL)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .Add(view);
 }
 
 
 void
-InProtocolsConfigView::DetachedFromWindow()
+ProtocolConfigView::DetachedFromWindow()
 {
        if (fConfigView == NULL)
                return;
@@ -201,65 +159,34 @@ InProtocolsConfigView::DetachedFromWindow()
        if (fConfigView->Archive(&settings) != B_OK)
                return;
 
-       fAccount->InboundSettings().MakeEmpty();
-       fAccount->InboundSettings().Append(settings);
+       fSettings.MakeEmpty();
+       fSettings.Append(settings);
 
        RemoveChild(fConfigView);
        delete fConfigView;
        fConfigView = NULL;
-       unload_add_on(fImageID);
+       unload_add_on(fImage);
 }
 
 
-OutProtocolsConfigView::OutProtocolsConfigView(BMailAccountSettings* account)
-       :
-       BBox(BRect(0, 0, 100, 100)),
-       fAccount(account),
-       fConfigView(NULL)
+status_t
+ProtocolConfigView::_CreateConfigView(const entry_ref& ref,
+       BMailProtocolSettings& settings, BMailAccountSettings& accountSettings)
 {
-       BString label = "Can't find protocol.";
-       entry_ref protocol = fAccount->OutboundAddOnRef();
-       BMailProtocolSettings& outboundSettings = fAccount->OutboundSettings();
-       fConfigView = CreateConfigView(protocol, outboundSettings, *account,
-               fImageID);
+       BView* (*instantiateConfig)(BMailProtocolSettings& settings,
+               BMailAccountSettings& accountSettings);
+       BPath path(&ref);
+       image_id image = load_add_on(path.Path());
+       if (image < 0)
+               return image;
 
-       if (fConfigView != NULL) {
-               float w = fConfigView->Bounds().Width();
-               float h = fConfigView->Bounds().Height();
-               fConfigView->MoveTo(3, 13);
-               ResizeTo(w + 6, h + 16);
-               AddChild(fConfigView);
-
-               fConfigView->MoveTo(3, 21);
-               ResizeBy(0, 8);
-               if (CenterContainer *container
-                       = dynamic_cast<CenterContainer *>(Parent())) {
-                       container->Layout();
-               }
-               label = protocol.name;
-
-               fConfigView->MoveTo(3, 21);
-               ResizeBy(0, 8);
+       if (get_image_symbol(image, "instantiate_protocol_config_panel",
+                       B_SYMBOL_TYPE_TEXT, (void**)&instantiateConfig) != 
B_OK) {
+               unload_add_on(image);
+               return B_BAD_VALUE;
        }
 
-       SetLabel(label);
-}
-
-
-void
-OutProtocolsConfigView::DetachedFromWindow()
-{
-       if (fConfigView == NULL)
-               return;
-       BMessage settings;
-       if (fConfigView->Archive(&settings) != B_OK)
-               return;
-
-       fAccount->OutboundSettings().MakeEmpty();
-       fAccount->OutboundSettings().Append(settings);
-
-       RemoveChild(fConfigView);
-       delete fConfigView;
-       fConfigView = NULL;
-       unload_add_on(fImageID);
+       fImage = image;
+       fConfigView = instantiateConfig(settings, accountSettings);
+       return B_OK;
 }
diff --git a/src/preferences/mail/ConfigViews.h 
b/src/preferences/mail/ConfigViews.h
index afd12e1..60692ec 100644
--- a/src/preferences/mail/ConfigViews.h
+++ b/src/preferences/mail/ConfigViews.h
@@ -24,21 +24,14 @@ class BButton;
 struct entry_ref;
 
 
-class ProtocolsConfigView;
-
-
-BView* CreateConfigView(const entry_ref& ref, BMailProtocolSettings& settings,
-       BMailAccountSettings& accountSettings, image_id& image);
-
-
 class AccountConfigView : public BBox {
 public:
-                                                               
AccountConfigView(BRect rect,
-                                                                       
BMailAccountSettings *account);
+                                                               
AccountConfigView(
+                                                                       
BMailAccountSettings* account);
 
        virtual void                            DetachedFromWindow();
        virtual void                            AttachedToWindow();
-       virtual void                            MessageReceived(BMessage *msg);
+       virtual void                            MessageReceived(BMessage* 
message);
 
                        void                            UpdateViews();
 
@@ -46,32 +39,28 @@ private:
                        BTextControl*           fNameControl;
                        BTextControl*           fRealNameControl;
                        BTextControl*           fReturnAddressControl;
-                       BMailAccountSettings    *fAccount;
+                       BMailAccountSettings* fAccount;
 };
 
 
-class InProtocolsConfigView : public BBox {
+class ProtocolConfigView : public BBox {
 public:
-                                                               
InProtocolsConfigView(
-                                                                       
BMailAccountSettings* account);
+                                                               
ProtocolConfigView(
+                                                                       
BMailAccountSettings& accountSettings,
+                                                                       const 
entry_ref& ref,
+                                                                       
BMailProtocolSettings& settings);
 
                        void                            DetachedFromWindow();
-private:
-                       BMailAccountSettings*   fAccount;
-                       BView*                          fConfigView;
-                       image_id                        fImageID;
-};
 
+private:
+                       status_t                        _CreateConfigView(const 
entry_ref& ref,
+                                                                       
BMailProtocolSettings& settings,
+                                                                       
BMailAccountSettings& accountSettings);
 
-class OutProtocolsConfigView : public BBox {
-public:
-                                                               
OutProtocolsConfigView(
-                                                                       
BMailAccountSettings* account);
-                       void                            DetachedFromWindow();
 private:
-                       BMailAccountSettings*   fAccount;
+                       BMailProtocolSettings& fSettings;
                        BView*                          fConfigView;
-                       image_id                        fImageID;
+                       image_id                        fImage;
 };
 
 
diff --git a/src/preferences/mail/ConfigWindow.cpp 
b/src/preferences/mail/ConfigWindow.cpp
index 4ff929e..5df254e 100644
--- a/src/preferences/mail/ConfigWindow.cpp
+++ b/src/preferences/mail/ConfigWindow.cpp
@@ -1,12 +1,12 @@
 /*
- * Copyright 2007-2011, Haiku, Inc. All rights reserved.
+ * Copyright 2007-2012, Haiku, Inc. All rights reserved.
  * Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
  *
  * Distributed under the terms of the MIT License.
  */
 
 
-//! main E-Mail config window
+//! Main E-Mail config window
 
 
 #include "ConfigWindow.h"
@@ -15,44 +15,41 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <Alert.h>
+#include <AppFileInfo.h>
 #include <Application.h>
-#include <Catalog.h>
-#include <ListView.h>
-#include <ScrollView.h>
-#include <StringView.h>
+#include <Bitmap.h>
+#include <Box.h>
 #include <Button.h>
+#include <Catalog.h>
 #include <CheckBox.h>
-#include <MenuField.h>
-#include <TextControl.h>
-#include <TextView.h>
-#include <MenuItem.h>
-#include <Screen.h>
-#include <PopUpMenu.h>
-#include <MenuBar.h>
-#include <TabView.h>
-#include <Box.h>
-#include <Alert.h>
-#include <Bitmap.h>
-#include <Roster.h>
-#include <Resources.h>
-#include <Region.h>
-
-#include <AppFileInfo.h>
-#include <Entry.h>
+#include <ControlLook.h>
 #include <Directory.h>
+#include <Entry.h>
 #include <FindDirectory.h>
-#include <Path.h>
-
-#include <Catalog.h>
+#include <LayoutBuilder.h>
+#include <ListView.h>
 #include <Locale.h>
-
 #include <MailDaemon.h>
 #include <MailSettings.h>
+#include <MenuBar.h>
+#include <MenuField.h>
+#include <MenuItem.h>
+#include <Path.h>
+#include <PopUpMenu.h>
+#include <Region.h>
+#include <Resources.h>
+#include <Roster.h>
+#include <Screen.h>
+#include <ScrollView.h>
+#include <StringView.h>
+#include <TabView.h>
+#include <TextControl.h>
+#include <TextView.h>
 
 #include <MailPrivate.h>
 
 #include "AutoConfigWindow.h"
-#include "CenterContainer.h"
 
 
 #undef B_TRANSLATION_CONTEXT
@@ -134,9 +131,9 @@ AccountItem::ConfigPanel()
 
 class AccountsListView : public BListView {
 public:
-       AccountsListView(BRect rect, BHandler* target)
+       AccountsListView(BHandler* target)
                :
-               BListView(rect, NULL, B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL),
+               BListView(NULL, B_SINGLE_SELECTION_LIST),
                fTarget(target)
        {
        }
@@ -185,12 +182,13 @@ class BitmapView : public BView {
        public:
                BitmapView(BBitmap *bitmap)
                        :
-                       BView(bitmap->Bounds(), NULL, B_FOLLOW_NONE, 
B_WILL_DRAW)
+                       BView(NULL, B_WILL_DRAW)
                {
                        fBitmap = bitmap;
 
                        SetDrawingMode(B_OP_ALPHA);
                        SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
+                       SetExplicitSize(bitmap->Bounds().Size());
                }
 
                ~BitmapView()
@@ -201,9 +199,6 @@ class BitmapView : public BView {
                virtual void AttachedToWindow()
                {
                        SetViewColor(Parent()->ViewColor());
-
-                       MoveTo((Parent()->Bounds().Width() - Bounds().Width()) 
/ 2,
-                               Frame().top);
                }
 
                virtual void Draw(BRect updateRect)
@@ -223,161 +218,77 @@ ConfigWindow::ConfigWindow()
        :
        BWindow(BRect(100, 100, 600, 540), B_TRANSLATE_SYSTEM_NAME("E-mail"),
                B_TITLED_WINDOW,
-               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
+               B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
        fLastSelectedAccount(NULL),
        fSaveSettings(false)
 {
-       // create controls
-       BRect rect(Bounds());
-       BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0);
-       top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
-       AddChild(top);
-
-       // determine font height
-       font_height fontHeight;
-       top->GetFontHeight(&fontHeight);
-       int32 height = (int32)(fontHeight.ascent + fontHeight.descent
-               + fontHeight.leading) + 5;
-
-       rect.InsetBy(10, 10);
-       rect.bottom -= 18 + height;
-       BTabView *tabView = new BTabView(rect, NULL);
-
-       BView *view;
-       rect = tabView->Bounds();
-       rect.bottom -= tabView->TabHeight() + 4;
-       tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
-       tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));
-       view->SetViewColor(top->ViewColor());
+       BTabView* tabView = new BTabView("tab");
 
        // accounts listview
 
-       rect = view->Bounds().InsetByCopy(10, 10);
-       rect.right = 190 - B_V_SCROLL_BAR_WIDTH;
-       rect.bottom -= height + 18;
-       fAccountsListView = new AccountsListView(rect, this);
-       view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0,
-               false, true));
-       rect.right += B_V_SCROLL_BAR_WIDTH;
-
-       rect.left -= 2;
-       rect.top = rect.bottom + 10;
-       rect.bottom = rect.top + height;
-       BRect sizeRect = rect;
-       sizeRect.right = sizeRect.left + 30 + view->StringWidth(
-               B_TRANSLATE("Add"));
-       view->AddChild(new BButton(sizeRect, NULL, B_TRANSLATE("Add"),
-               new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));
-
-       sizeRect.left = sizeRect.right + 5;
-       sizeRect.right = sizeRect.left + 30 + view->StringWidth(
-               B_TRANSLATE("Remove"));
-       view->AddChild(fRemoveButton = new BButton(
-               sizeRect, NULL, B_TRANSLATE("Remove"),
-               new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));
-
-       // accounts config view
-       rect = view->Bounds();
-       rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 
16;
-       rect.right -= 10;
-       fConfigView = new CenterContainer(rect);
-       view->AddChild(fConfigView);
-
-       _MakeHowToView();
+       BView* view = new BView("accounts", 0);
+       tabView->AddTab(view);
+       tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));
+
+       fAccountsListView = new AccountsListView(this);
+
+       BButton* addButton = new BButton(NULL, B_TRANSLATE("Add"),
+               new BMessage(kMsgAddAccount));
+       fRemoveButton = new BButton(NULL, B_TRANSLATE("Remove"),
+               new BMessage(kMsgRemoveAccount));
+
+       fConfigView = new BView(NULL, 0);
+       fConfigView->SetLayout(new BGroupLayout(B_VERTICAL));
+       fConfigView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNLIMITED));
+       fConfigView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+
+       BScrollView* scroller = new BScrollView(NULL, fAccountsListView, 0,
+               false, true);
+
+       BLayoutBuilder::Group<>(view, B_HORIZONTAL)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .AddGroup(B_VERTICAL)
+                       .Add(scroller)
+                       .AddGroup(B_HORIZONTAL)
+                               .Add(addButton)
+                               .Add(fRemoveButton)
+                       .End()
+               .End()
+               .Add(fConfigView, 2.0f);
+
+       _ReplaceConfigView(_BuildHowToView());
 
        // general settings
 
-       rect = tabView->ContainerView()->Bounds();
-       tabView->AddTab(view = new CenterContainer(rect));
+       view = new BView("general", 0);
+       view->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));
+       tabView->AddTab(view);
        tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings"));
 
-       rect = view->Bounds().InsetByCopy(10, 10);
-       rect.bottom = rect.top + height * 5 + 15;
-       BBox *box = new BBox(rect);
-       box->SetLabel(B_TRANSLATE("Mail checking"));
-       view->AddChild(box);
-
-       rect = box->Bounds().InsetByCopy(10, 10);
-       rect.top += 7;
-       rect.bottom = rect.top + height;
-       BRect tile = rect.OffsetByCopy(0, 1);
-       int32 labelWidth = (int32)view->StringWidth(B_TRANSLATE("Check every")) 
+ 6;
-       tile.right = 80 + labelWidth;
-       fIntervalControl = new BTextControl(tile, "time",
-               B_TRANSLATE("Check every"), NULL, NULL);
-       fIntervalControl->SetDivider(labelWidth);
-       box->AddChild(fIntervalControl);
-
-       BPopUpMenu* frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
-       const char* frequencyStrings[] = {
-               B_TRANSLATE_COMMENT("never", "mail checking frequency"),
-               B_TRANSLATE("minutes"),
-               B_TRANSLATE("hours"),
-               B_TRANSLATE("days")};
-
-       for (int32 i = 0; i < 4; i++) {
-               BMenuItem* item = new BMenuItem(frequencyStrings[i],
-                       new BMessage(kMsgIntervalUnitChanged));
-               frequencyPopUp->AddItem(item);
-       }
-       tile.left = tile.right + 5;
-       tile.right = rect.right;
-       tile.OffsetBy(0,-1);
-       fIntervalUnitField = new BMenuField(tile, "frequency", B_EMPTY_STRING,
-               frequencyPopUp);
-       fIntervalUnitField->SetDivider(0.0);
-       box->AddChild(fIntervalUnitField);
-
-       rect.OffsetBy(0,height + 9);
-       rect.bottom -= 2;
-       fPPPActiveCheckBox = new BCheckBox(rect, "ppp active",
-               B_TRANSLATE("Only when dial-up is connected"), NULL);
-       box->AddChild(fPPPActiveCheckBox);
-
-       rect.OffsetBy(0,height + 9);
-       rect.bottom -= 2;
-       fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend",
-               B_TRANSLATE("Schedule outgoing mail when dial-up is 
disconnected"),
+       fCheckMailCheckBox = new BCheckBox("check", B_TRANSLATE("Check every"),
+               NULL);
+       fIntervalControl = new BTextControl("time", B_TRANSLATE("minutes"), 
NULL,
                NULL);
-       box->AddChild(fPPPActiveSendCheckBox);
-
-       // Miscellaneous settings box
-
-       rect = box->Frame();  rect.bottom = rect.top + 3 * height + 33;
-       box = new BBox(rect);
-       box->SetLabel(B_TRANSLATE("Miscellaneous"));
-       view->AddChild(box);
 
-       BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
-       const char *statusModes[] = {
+       BPopUpMenu* statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
+       const char* statusModes[] = {
                B_TRANSLATE_COMMENT("Never", "show status window"),
                B_TRANSLATE("While sending"),
-               B_TRANSLATE("While sending and receiving"),
-               B_TRANSLATE("Always")};
-       for (int32 i = 0; i < 4; i++) {
+               B_TRANSLATE("While sending and receiving")};
+       for (size_t i = 0; i < sizeof(statusModes) / sizeof(statusModes[0]); 
i++) {
                BMessage* msg = new BMessage(kMsgShowStatusWindowChanged);
                BMenuItem* item = new BMenuItem(statusModes[i], msg);
                statusPopUp->AddItem(item);
                msg->AddInt32("ShowStatusWindow", i);
        }
-       rect = box->Bounds().InsetByCopy(10, 10);
-       rect.top += 7;
-       rect.bottom = rect.top + height + 5;
-       labelWidth = (int32)view->StringWidth(
-               B_TRANSLATE("Show connection status window:"))  + 8;
-       fStatusModeField = new BMenuField(rect, "show status",
-               B_TRANSLATE("Show connection status window:"), statusPopUp);
-       fStatusModeField->SetDivider(labelWidth);
-       box->AddChild(fStatusModeField);
-
-       rect = fStatusModeField->Frame();;
-       rect.OffsetBy(0, rect.Height() + 10);
+
+       fStatusModeField = new BMenuField("show status",
+               B_TRANSLATE("Show notifications:"), statusPopUp);
+
        BMessage* msg = new BMessage(B_REFS_RECEIVED);
-       BButton *button = new BButton(rect, B_EMPTY_STRING,
+       BButton* editMenuButton = new BButton(B_EMPTY_STRING,
                B_TRANSLATE("Edit mailbox menuâ"), msg);
-       button->ResizeToPreferred();
-       box->AddChild(button);
-       button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
+       editMenuButton->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
 
        BPath path;
        find_directory(B_USER_SETTINGS_DIRECTORY, &path);
@@ -387,38 +298,43 @@ ConfigWindow::ConfigWindow()
                entry_ref ref;
                entry.GetRef(&ref);
                msg->AddRef("refs", &ref);
-       }
-       else
-               button->SetEnabled(false);
-
-       rect = button->Frame();
-       rect.OffsetBy(rect.Width() + 30,0);
-       fAutoStartCheckBox = new BCheckBox(rect, "start daemon",
-               B_TRANSLATE("Start mail services on startup"), NULL);
-       fAutoStartCheckBox->ResizeToPreferred();
-       box->AddChild(fAutoStartCheckBox);
+       } else
+               editMenuButton->SetEnabled(false);
+
+       BLayoutBuilder::Group<>(view, B_VERTICAL)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .AddGlue()
+               .AddGroup(B_HORIZONTAL, 0.f)
+                       .AddGlue()
+                       .Add(fCheckMailCheckBox)
+                       .Add(fIntervalControl->CreateTextViewLayoutItem())
+                       .AddStrut(be_control_look->DefaultLabelSpacing())
+                       .Add(fIntervalControl->CreateLabelLayoutItem())
+                       .AddGlue()
+               .End()
+               .AddGroup(B_HORIZONTAL, 0.f)
+                       .AddGlue()
+                       .Add(fStatusModeField->CreateLabelLayoutItem())
+                       .Add(fStatusModeField->CreateMenuBarLayoutItem())
+                       .AddGlue()
+               .End()
+               .Add(editMenuButton)
+               .AddGlue();
 
        // save/revert buttons
 
-       top->AddChild(tabView);
-
-       rect = tabView->Frame();
-       rect.top = rect.bottom + 10;
-       rect.bottom = rect.top + height + 5;
-       BButton *saveButton = new BButton(rect, "apply", B_TRANSLATE("Apply"),
+       BButton* applyButton = new BButton("apply", B_TRANSLATE("Apply"),
                new BMessage(kMsgSaveSettings));
-       float w,h;
-       saveButton->GetPreferredSize(&w, &h);
-       saveButton->ResizeTo(w, h);
-       saveButton->MoveTo(rect.right - w, rect.top);
-       top->AddChild(saveButton);
-
-       BButton *revertButton = new BButton(rect, "revert", 
B_TRANSLATE("Revert"),
+       BButton* revertButton = new BButton("revert", B_TRANSLATE("Revert"),
                new BMessage(kMsgRevertSettings));
-       revertButton->GetPreferredSize(&w, &h);
-       revertButton->ResizeTo(w,h);
-       revertButton->MoveTo(saveButton->Frame().left - 10 - w, rect.top);
-       top->AddChild(revertButton);
+
+       BLayoutBuilder::Group<>(this, B_VERTICAL)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .Add(tabView)
+               .AddGroup(B_HORIZONTAL)
+                       .AddGlue()
+                       .Add(revertButton)
+                       .Add(applyButton);
 
        _LoadSettings();
                // this will also move our window to the stored position
@@ -437,42 +353,46 @@ ConfigWindow::~ConfigWindow()
 }
 
 
-void
-ConfigWindow::_MakeHowToView()
+BView*
+ConfigWindow::_BuildHowToView()
 {
+       BView* groupView = new BView("howTo", 0);
+
+       BitmapView* bitmapView = NULL;
        app_info info;
        if (be_app->GetAppInfo(&info) == B_OK) {
                BFile appFile(&info.ref, B_READ_ONLY);
                BAppFileInfo appFileInfo(&appFile);
                if (appFileInfo.InitCheck() == B_OK) {
-                       BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 
63),
+                       BBitmap* bitmap = new (std::nothrow) BBitmap(BRect(0, 
0, 63, 63),
                                B_RGBA32);
-                       if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
-                               fConfigView->AddChild(new BitmapView(bitmap));
-                       } else
+                       if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK)
+                               bitmapView = new BitmapView(bitmap);
+                       else
                                delete bitmap;
                }
        }
 
-       BRect rect = fConfigView->Bounds();
-       BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
-               B_WILL_DRAW);
-       text->SetViewColor(fConfigView->Parent()->ViewColor());
+       BTextView* text = new BTextView(NULL, B_WILL_DRAW);
        text->SetAlignment(B_ALIGN_CENTER);
        text->SetText(B_TRANSLATE(
-               "\n\nCreate a new account with the Add button.\n\n"
+               "Create a new account with the Add button.\n\n"
                "Remove an account with the Remove button on the selected 
item.\n\n"
                "Select an item in the list to change its settings."));
-       rect = text->Bounds();
-       text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
-       text->SetTextRect(rect);
-
        text->MakeEditable(false);
        text->MakeSelectable(false);
 
-       fConfigView->AddChild(text);
+       BLayoutBuilder::Group<>(groupView, B_VERTICAL)
+               .AddGlue()
+               .Add(text)
+               .AddGlue();
+
+       if (bitmapView != NULL)
+               groupView->GetLayout()->AddView(1, bitmapView);
+
+       text->SetViewColor(groupView->ViewColor());
 
-       fConfigView->Layout();
+       return groupView;
 }
 
 
@@ -503,11 +423,8 @@ ConfigWindow::_LoadSettings()
                || !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);
-       }
+       if (status != B_OK)
+               CenterOnScreen();
 }
 
 
@@ -528,9 +445,6 @@ ConfigWindow::_LoadAccounts()
 void
 ConfigWindow::_SaveSettings()
 {
-       // remove config views (trigger view archive)
-       fConfigView->DeleteChildren();
-
        // collect changed accounts
        BMessage changedAccounts(BPrivate::kMsgAccountsChanged);
        for (int32 i = 0; i < fAccounts.CountItems(); i++) {
@@ -554,40 +468,21 @@ ConfigWindow::_SaveSettings()
 
        /*** save general settings ***/
 
-       // figure out time interval
-       float interval;
-       sscanf(fIntervalControl->Text(),"%f",&interval);
-       float multiplier = 0;
-       switch (fIntervalUnitField->Menu()->IndexOf(
-                       fIntervalUnitField->Menu()->FindMarked())) {
-               case 1:         // minutes
-                       multiplier = 60;
-                       break;
-               case 2:         // hours
-                       multiplier = 60 * 60;
-                       break;
-               case 3:         // days
-                       multiplier = 24 * 60 * 60;
-                       break;
-       }
-       time_t time = (time_t)(multiplier * interval);
-
        // apply and save general settings
        BMailSettings settings;
        if (fSaveSettings) {
-               settings.SetAutoCheckInterval(time * 1e6);
-               settings.SetCheckOnlyIfPPPUp(fPPPActiveCheckBox->Value()
-                       == B_CONTROL_ON);
-               settings.SetSendOnlyIfPPPUp(fPPPActiveSendCheckBox->Value()
-                       == B_CONTROL_ON);
-               settings.SetDaemonAutoStarts(fAutoStartCheckBox->Value()
-                       == B_CONTROL_ON);
+               // figure out time interval
+               float floatInterval;
+               sscanf(fIntervalControl->Text(), "%f", &floatInterval);
+               bigtime_t interval = bigtime_t(60000000L * floatInterval);
+
+               settings.SetAutoCheckInterval(interval);
+               settings.SetDaemonAutoStarts(interval != 0);
 
                // status mode (alway, fetching/retrieving, ...)
                int32 index = fStatusModeField->Menu()->IndexOf(
                        fStatusModeField->Menu()->FindMarked());
                settings.SetShowStatusWindow(index);
-
        } else {
                // restore status window look
                settings.SetStatusWindowLook(settings.StatusWindowLook());
@@ -611,12 +506,10 @@ ConfigWindow::_SaveSettings()
                messenger.SendMessage(&changedAccounts);
        }
 
-       // start the mail_daemon if auto start was selected
-       if (fSaveSettings && fAutoStartCheckBox->Value() == B_CONTROL_ON
-               && !be_roster->IsRunning("application/x-vnd.Be-POST"))
-       {
-               be_roster->Launch("application/x-vnd.Be-POST");
-       }
+       // Start the mail_daemon if auto start was selected
+       BMailDaemon daemon;
+       if (fSaveSettings && settings.DaemonAutoStarts() && !daemon.IsRunning())
+               daemon.Launch();
 }
 
 
@@ -698,12 +591,11 @@ ConfigWindow::MessageReceived(BMessage *msg)
                        int32 index;
                        if (msg->FindInt32("index", &index) != B_OK || index < 
0) {
                                // deselect current item
-                               fConfigView->DeleteChildren();
-                               _MakeHowToView();
+                               _ReplaceConfigView(_BuildHowToView());
                                break;
                        }
-                       AccountItem *item = (AccountItem 
*)fAccountsListView->ItemAt(index);
-                       if (item)
+                       AccountItem* item = 
(AccountItem*)fAccountsListView->ItemAt(index);
+                       if (item != NULL)
                                _AccountSelected(item);
                        break;
                }
@@ -727,7 +619,7 @@ ConfigWindow::MessageReceived(BMessage *msg)
                                        index);
                                if (item != NULL) {
                                        _RemoveAccount(item->GetAccount());
-                                       _MakeHowToView();
+                                       _ReplaceConfigView(_BuildHowToView());
                                }
                        }
                        break;
@@ -758,7 +650,7 @@ ConfigWindow::MessageReceived(BMessage *msg)
                        fSaveSettings = true;
                        _SaveSettings();
                        AccountUpdated(fLastSelectedAccount);
-                       _MakeHowToView();
+                       _ReplaceConfigView(_BuildHowToView());
                        fAccountsListView->DeselectAll();
                        break;
 
@@ -800,9 +692,9 @@ ConfigWindow::AccountUpdated(BMailAccountSettings* account)
 
 
 status_t
-ConfigWindow::_SetToGeneralSettings(BMailSettings *settings)
+ConfigWindow::_SetToGeneralSettings(BMailSettings* settings)
 {
-       if (!settings)
+       if (settings == NULL)
                return B_BAD_VALUE;
 
        status_t status = settings->InitCheck();
@@ -810,37 +702,20 @@ ConfigWindow::_SetToGeneralSettings(BMailSettings 
*settings)
                return status;
 
        // retrieval frequency
+       uint32 interval = uint32(settings->AutoCheckInterval() / 60000000L);
+       fCheckMailCheckBox->SetValue(settings->DaemonAutoStarts()
+               && interval != 0 ? B_CONTROL_ON : B_CONTROL_OFF);
 
-       time_t interval = time_t(settings->AutoCheckInterval() / 1e6L);
-       char text[25];
-       text[0] = 0;
-       int timeIndex = 0;
-       if (interval >= 60) {
-               timeIndex = 1;
-               sprintf(text, "%ld", interval / (60));
-       }
-       if (interval >= (60*60)) {
-               timeIndex = 2;
-               sprintf(text, "%ld", interval / (60*60));
-       }
-       if (interval >= (60*60*24)) {
-               timeIndex = 3;
-               sprintf(text, "%ld", interval / (60*60*24));
-       }
-       fIntervalControl->SetText(text);
-
-       if (BMenuItem *item = fIntervalUnitField->Menu()->ItemAt(timeIndex))
-               item->SetMarked(true);
-       fIntervalControl->SetEnabled(timeIndex != 0);
-
-       fPPPActiveCheckBox->SetValue(settings->CheckOnlyIfPPPUp());
-       fPPPActiveSendCheckBox->SetValue(settings->SendOnlyIfPPPUp());
+       if (interval == 0)
+               interval = 5;
 
-       fAutoStartCheckBox->SetValue(settings->DaemonAutoStarts());
+       BString intervalText;
+       intervalText.SetToFormat("%" B_PRIu32, interval);
+       fIntervalControl->SetText(intervalText.String());
 
        int32 showStatusIndex = settings->ShowStatusWindow();
-       BMenuItem *item = fStatusModeField->Menu()->ItemAt(showStatusIndex);
-       if (item) {
+       BMenuItem* item = fStatusModeField->Menu()->ItemAt(showStatusIndex);
+       if (item != NULL) {
                item->SetMarked(true);
                // send live update to the server by simulating a menu click
                BMessage msg(kMsgShowStatusWindowChanged);
@@ -877,18 +752,16 @@ ConfigWindow::_RevertToLastSettings()
        // revert account data
 
        if (fAccountsListView->CurrentSelection() != -1)
-               fConfigView->DeleteChildren();
+               _ReplaceConfigView(_BuildHowToView());
 
        for (int32 i = 0; i < fAccounts.CountItems(); i++) {
                BMailAccountSettings* account = fAccounts.ItemAt(i);
                _RemoveAccountFromListView(account);
                delete account;
        }
+
        fAccounts.MakeEmpty();
        _LoadAccounts();
-
-       if (fConfigView->CountChildren() == 0)
-               _MakeHowToView();
 }
 
 
@@ -951,38 +824,41 @@ ConfigWindow::_AccountSelected(AccountItem* item)
        BMailAccountSettings* account = item->GetAccount();
        fLastSelectedAccount = account;
 
-       fConfigView->Hide();
-       fConfigView->DeleteChildren();
-
        BView* view = NULL;
        switch (item->GetType()) {
                case ACCOUNT_ITEM:
-                       view = new AccountConfigView(fConfigView->Bounds(), 
account);
+                       view = new AccountConfigView(account);
                        break;
 
                case INBOUND_ITEM:
-               {
-                       view = new InProtocolsConfigView(account);
+                       view = new ProtocolConfigView(*account, 
account->InboundAddOnRef(),
+                               account->InboundSettings());
                        break;
-               }
 
                case OUTBOUND_ITEM:
-               {
-                       view = new OutProtocolsConfigView(account);
+                       view = new ProtocolConfigView(*account, 
account->OutboundAddOnRef(),
+                               account->OutboundSettings());
                        break;
-               }
 
                case FILTER_ITEM:
-               {
-                       view = new FiltersConfigView(fConfigView->Bounds(), 
*account);
+                       view = new FiltersConfigView(*account);
                        break;
-               }
        }
-       if (view) {
+       if (view != NULL)
                item->SetConfigPanel(view);
-               fConfigView->AddChild(view);
+
+       _ReplaceConfigView(view);
+}
+
+
+void
+ConfigWindow::_ReplaceConfigView(BView* view)
+{
+       while (BView* child = fConfigView->ChildAt(0)) {
+               fConfigView->RemoveChild(child);
+               delete child;
        }
 
-       fConfigView->Layout();
-       fConfigView->Show();
+       if (view != NULL)
+               fConfigView->AddChild(view);
 }
diff --git a/src/preferences/mail/ConfigWindow.h 
b/src/preferences/mail/ConfigWindow.h
index 140479d..2c8d8ba 100644
--- a/src/preferences/mail/ConfigWindow.h
+++ b/src/preferences/mail/ConfigWindow.h
@@ -1,10 +1,12 @@
+/*
+ * Copyright 2004-2012, Haiku Inc. All rights reserved.
+ * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
+ * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
+ *
+ * Distributed under the terms of the MIT License.
+ */
 #ifndef CONFIG_WINDOW_H
 #define CONFIG_WINDOW_H
-/* ConfigWindow - main eMail config window
- *
- * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
- * Copyright 2011, Clemens Zeidler <haiku@xxxxxxxxxxxxxxxxxx>
-*/
 
 
 #include <Window.h>
@@ -24,8 +26,7 @@ class BMailSettings;
 class CenterContainer;
 
 
-enum item_types
-{
+enum item_types {
        ACCOUNT_ITEM = 0,
        INBOUND_ITEM,
        OUTBOUND_ITEM,
@@ -66,7 +67,7 @@ public:
                        void                            
AccountUpdated(BMailAccountSettings* account);
 
 private:
-                       void                            _MakeHowToView();
+                       BView*                          _BuildHowToView();
 
                        void                            _LoadSettings();
                        void                            _LoadAccounts();
@@ -81,18 +82,17 @@ private:
                        void                            
_RemoveAccountFromListView(
                                                                        
BMailAccountSettings* account);
                        void                            
_AccountSelected(AccountItem* item);
+                       void                            
_ReplaceConfigView(BView* view);
 
+private:
                        BListView*                      fAccountsListView;
-                       BMailAccountSettings*   fLastSelectedAccount;
-                       CenterContainer*        fConfigView;
+                       BMailAccountSettings* fLastSelectedAccount;
+                       BView*                          fConfigView;
                        BButton*                        fRemoveButton;
 
+                       BCheckBox*                      fCheckMailCheckBox;
                        BTextControl*           fIntervalControl;
-                       BMenuField*                     fIntervalUnitField;
-                       BCheckBox*                      fPPPActiveCheckBox;
-                       BCheckBox*                      fPPPActiveSendCheckBox;
                        BMenuField*                     fStatusModeField;
-                       BCheckBox*                      fAutoStartCheckBox;
 
                        bool                            fSaveSettings;
                        BObjectList<BMailAccountSettings>       fAccounts;
diff --git a/src/preferences/mail/FilterConfigView.cpp 
b/src/preferences/mail/FilterConfigView.cpp
index e6bd9e9..5129cd3 100644
--- a/src/preferences/mail/FilterConfigView.cpp
+++ b/src/preferences/mail/FilterConfigView.cpp
@@ -12,12 +12,12 @@
 #include <Bitmap.h>
 #include <Box.h>
 #include <Catalog.h>
+#include <LayoutBuilder.h>
 #include <Locale.h>
 #include <MenuItem.h>
 #include <PopUpMenu.h>
 #include <ScrollView.h>
 
-#include "CenterContainer.h"
 
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "Config Views"
@@ -35,12 +35,11 @@ const uint32 kMsgItemDragged = 'itdr';
 
 class DragListView : public BListView {
 public:
-       DragListView(BRect frame, const char *name,
+       DragListView(const char* name,
                        list_view_type type = B_SINGLE_SELECTION_LIST,
-                        uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
-                        BMessage *itemMovedMsg = NULL)
+                        BMessage* itemMovedMsg = NULL)
                :
-               BListView(frame, name, type, resizingMode),
+               BListView(name, type),
                fDragging(false),
                fItemMovedMessage(itemMovedMsg)
        {
@@ -207,9 +206,9 @@ private:
 //     #pragma mark -
 
 
-FiltersConfigView::FiltersConfigView(BRect rect, BMailAccountSettings& account)
+FiltersConfigView::FiltersConfigView(BMailAccountSettings& account)
        :
-       BBox(rect),
+       BBox("filters"),
        fAccount(account),
        fDirection(kIncoming),
        fInboundFilters(kIncoming, false),
@@ -217,64 +216,44 @@ FiltersConfigView::FiltersConfigView(BRect rect, 
BMailAccountSettings& account)
        fFilterView(NULL),
        fCurrentIndex(-1)
 {
-       BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
+       BView* contents = new BView(NULL, 0);
+       AddChild(contents);
 
-       BMessage* msg;
-       BMenuItem *item;
-       msg = new BMessage(kMsgChainSelected);
-       item = new BMenuItem(B_TRANSLATE("Incoming mail filters"), msg);
-       menu->AddItem(item);
+       BMessage* msg = new BMessage(kMsgChainSelected);
        msg->AddInt32("direction", kIncoming);
+       BMenuItem* item = new BMenuItem(B_TRANSLATE("Incoming mail filters"), 
msg);
        item->SetMarked(true);
+       BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
+       menu->AddItem(item);
 
        msg = new BMessage(kMsgChainSelected);
+       msg->AddInt32("direction", kOutgoing);
        item = new BMenuItem(B_TRANSLATE("Outgoing mail filters"), msg);
        menu->AddItem(item);
-       msg->AddInt32("direction", kOutgoing);
 
-       fChainsField = new BMenuField(BRect(0, 0, 200, 40), NULL, NULL, menu);
+       fChainsField = new BMenuField(NULL, NULL, menu);
        fChainsField->ResizeToPreferred();
        SetLabel(fChainsField);
 
-       // determine font height
-       font_height fontHeight;
-       fChainsField->GetFontHeight(&fontHeight);
-       int32 height = (int32)(fontHeight.ascent + fontHeight.descent
-               + fontHeight.leading) + 5;
-
-       rect = Bounds().InsetByCopy(10, 10);
-       rect.top += 18;
-       rect.right -= B_V_SCROLL_BAR_WIDTH;
-       rect.bottom = rect.top + 4 * height + 2;
-       fListView = new DragListView(rect, NULL, B_SINGLE_SELECTION_LIST,
-               B_FOLLOW_ALL, new BMessage(kMsgFilterMoved));
-       AddChild(new BScrollView(NULL, fListView, B_FOLLOW_ALL, 0, false, 
true));
-       rect.right += B_V_SCROLL_BAR_WIDTH;
-
-//     fListView->Select(gSettings.formats.IndexOf(format));
+       fListView = new DragListView(NULL, B_SINGLE_SELECTION_LIST,
+               new BMessage(kMsgFilterMoved));
        fListView->SetSelectionMessage(new BMessage(kMsgFilterSelected));
 
-       rect.top = rect.bottom + 8;
-       rect.bottom = rect.top + height;
-       BRect sizeRect = rect;
-       sizeRect.right = sizeRect.left + 30
-               + fChainsField->StringWidth(B_TRANSLATE("Add filter"));
-
        menu = new BPopUpMenu(B_TRANSLATE("Add filter"));
        menu->SetRadioMode(false);
 
-       fAddField = new BMenuField(rect, NULL, NULL, menu);
-       fAddField->ResizeToPreferred();
-       AddChild(fAddField);
+       fAddField = new BMenuField(NULL, NULL, menu);
 
-       sizeRect.left = sizeRect.right + 5;
-       sizeRect.right = sizeRect.left + 30
-               + fChainsField->StringWidth(B_TRANSLATE("Remove"));
-       sizeRect.top--;
-       AddChild(fRemoveButton = new BButton(sizeRect, NULL, 
B_TRANSLATE("Remove"),
-               new BMessage(kMsgRemoveFilter), B_FOLLOW_BOTTOM));
+       fRemoveButton = new BButton(NULL, B_TRANSLATE("Remove"),
+               new BMessage(kMsgRemoveFilter));
 
-       ResizeTo(Bounds().Width(), sizeRect.bottom + 10);
+       BLayoutBuilder::Group<>(contents, B_VERTICAL)
+               .SetInsets(B_USE_DEFAULT_SPACING)
+               .Add(new BScrollView(NULL, fListView, 0, false, true))
+               .AddGroup(B_HORIZONTAL)
+                       .Add(fAddField)
+                       .Add(fRemoveButton)
+                       .AddGlue();
 
        _SetDirection(fDirection);
 }
@@ -282,7 +261,6 @@ FiltersConfigView::FiltersConfigView(BRect rect, 
BMailAccountSettings& account)
 
 FiltersConfigView::~FiltersConfigView()
 {
-
 }
 
 
@@ -318,10 +296,6 @@ FiltersConfigView::_SelectFilter(int32 index)
 
        fCurrentIndex = index;
 
-       // re-layout the view containing the config view
-       if (CenterContainer* container = 
dynamic_cast<CenterContainer*>(Parent()))
-               container->Layout();
-
        if (Parent())
                Parent()->Show();
 }
@@ -414,7 +388,7 @@ FiltersConfigView::MessageReceived(BMessage *msg)
                case kMsgAddFilter:
                {
                        entry_ref ref;
-                       if (msg->FindRef("filter", &ref) < B_OK)
+                       if (msg->FindRef("filter", &ref) != B_OK)
                                break;
 
                        ::FilterList* filters = _FilterList();
@@ -443,7 +417,7 @@ FiltersConfigView::MessageReceived(BMessage *msg)
                case kMsgFilterSelected:
                {
                        int32 index = -1;
-                       if (msg->FindInt32("index",&index) < B_OK)
+                       if (msg->FindInt32("index",&index) != B_OK)
                                break;
 
                        _SelectFilter(index);
@@ -478,18 +452,15 @@ FiltersConfigView::MessageReceived(BMessage *msg)
 BMailProtocolSettings*
 FiltersConfigView::_MailSettings()
 {
-       if (fDirection == kIncoming)
-               return &fAccount.InboundSettings();
-       return &fAccount.OutboundSettings();
+       return fDirection == kIncoming
+               ? &fAccount.InboundSettings() : &fAccount.OutboundSettings();
 }
 
 
 FilterList*
 FiltersConfigView::_FilterList()
 {
-       if (fDirection == kIncoming)
-               return &fInboundFilters;
-       return &fOutboundFilters;
+       return fDirection == kIncoming ? &fInboundFilters : &fOutboundFilters;
 }
 
 
diff --git a/src/preferences/mail/FilterConfigView.h 
b/src/preferences/mail/FilterConfigView.h
index 17aa48f..a0110a1 100644
--- a/src/preferences/mail/FilterConfigView.h
+++ b/src/preferences/mail/FilterConfigView.h
@@ -25,7 +25,7 @@ class FilterConfigBox;
 
 class FiltersConfigView : public BBox {
 public:
-                                                               
FiltersConfigView(BRect rect,
+                                                               
FiltersConfigView(
                                                                        
BMailAccountSettings& account);
                                                                
~FiltersConfigView();
 
diff --git a/src/preferences/mail/Jamfile b/src/preferences/mail/Jamfile
index 6fe7804..c483d09 100644
--- a/src/preferences/mail/Jamfile
+++ b/src/preferences/mail/Jamfile
@@ -13,7 +13,6 @@ local sources =
        AutoConfig.cpp
        AutoConfigView.cpp
        AutoConfigWindow.cpp
-       CenterContainer.cpp
        ConfigViews.cpp
        ConfigWindow.cpp
        FilterList.cpp


Other related posts: