Ticket #3866: LocalePrefs_layout.diff

File LocalePrefs_layout.diff, 3.6 KB (added by pulkomandy, 11 years ago)
  • src/preferences/locale/LocaleWindow.cpp

     
    88#include "LocaleWindow.h"
    99
    1010#include <Application.h>
     11#include <Button.h>
     12#include <GroupLayout.h>
     13#include <GroupLayoutBuilder.h>
     14#include <ListView.h>
    1115#include <Screen.h>
     16#include <ScrollView.h>
    1217#include <TabView.h>
    13 #include <ScrollView.h>
    14 #include <ListView.h>
    15 #include <Button.h>
    1618
    1719
    1820const static uint32 kMsgSelectLanguage = 'slng';
     
    2426    : BWindow(rect, "Locale", B_TITLED_WINDOW,
    2527        B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
    2628{
    27     rect = Bounds();
    28     BView *view = new BView(rect, "view", B_FOLLOW_ALL, 0);
    29     view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    30     AddChild(view);
     29    // Buttons at the bottom
    3130
    32     BButton *button = new BButton(rect, "defaults", "Defaults",
    33         new BMessage(kMsgDefaults), B_FOLLOW_NONE);
    34     button->ResizeToPreferred();
    35     button->MoveTo(10, rect.bottom - 10 - button->Bounds().Height());
    36     view->AddChild(button);
     31    BButton *button = new BButton("Defaults", new BMessage(kMsgDefaults));
    3732
    38     fRevertButton = new BButton(rect, "revert", "Revert",
    39         new BMessage(kMsgRevert), B_FOLLOW_NONE);
    40     fRevertButton->ResizeToPreferred();
    41     fRevertButton->MoveTo(20 + button->Bounds().Width(), button->Frame().top);
     33    fRevertButton = new BButton("Revert", new BMessage(kMsgRevert));
    4234    fRevertButton->SetEnabled(false);
    43     view->AddChild(fRevertButton);
    4435
    45     rect.InsetBy(10, 10);
    46     rect.bottom -= 10 + button->Bounds().Height();
    47     BTabView *tabView = new BTabView(rect, "tabview");
     36    // Tabs
     37    BTabView *tabView = new BTabView("tabview");
    4838
    49     rect = tabView->ContainerView()->Bounds();
    50     rect.InsetBy(2, 2);
    51     BView *tab = new BView(rect, "Language", B_FOLLOW_NONE, B_WILL_DRAW);
     39    // Language tab
     40
     41    BView *tab = new BView("Language", B_WILL_DRAW);
    5242    tab->SetViewColor(tabView->ViewColor());
     43    tab->SetLayout(new BGroupLayout(B_VERTICAL,10));
    5344    tabView->AddTab(tab);
    5445
    5546    {
    56         BRect frame = rect;
    57         frame.InsetBy(12, 12);
    58         frame.right = 100 + B_V_SCROLL_BAR_WIDTH;
    59         frame.bottom = 150;
    60 
    61         BListView *listView = new BListView(frame, "preferred", B_SINGLE_SELECTION_LIST,
    62             B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
     47        BListView *listView = new BListView("preferred", B_SINGLE_SELECTION_LIST);
    6348        listView->SetSelectionMessage(new BMessage(kMsgSelectLanguage));
    6449
    6550        BScrollView *scrollView = new BScrollView("scroller", listView,
    66             B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
    67         tab->AddChild(scrollView);
     51            0, false, true, B_FANCY_BORDER);
     52        tab->AddChild(BGroupLayoutBuilder(B_HORIZONTAL,10)
     53            .Add(scrollView)
     54            .AddGlue()
     55        );
    6856    }
    6957
    70     tab = new BView(rect, "Country", B_FOLLOW_NONE, B_WILL_DRAW);
     58    // Country tab
     59
     60    tab = new BView("Country", B_WILL_DRAW);
    7161    tab->SetViewColor(tabView->ViewColor());
    7262    tabView->AddTab(tab);
    7363
    74     tab = new BView(rect, "Keyboard", B_FOLLOW_NONE, B_WILL_DRAW);
     64    // Keyboard tab
     65
     66    tab = new BView("Keyboard", B_WILL_DRAW);
    7567    tab->SetViewColor(tabView->ViewColor());
    7668    tabView->AddTab(tab);
    7769
    78     view->AddChild(tabView);
    79 
    8070    // check if the window is on screen
    8171
    8272    rect = BScreen().Frame();
     
    9080        position.y = (rect.Height() - Bounds().Height()) / 2;
    9181    }
    9282    MoveTo(position);
     83
     84    // Layout management
     85
     86    SetLayout(new BGroupLayout(B_HORIZONTAL));
     87
     88    AddChild(BGroupLayoutBuilder(B_VERTICAL,10)
     89        .Add(tabView)
     90        .Add(BGroupLayoutBuilder(B_HORIZONTAL,10)
     91            .Add(button)
     92            .Add(fRevertButton)
     93            .AddGlue()
     94        )
     95        .SetInsets(5,5,5,5)
     96    );
    9397}
    9498
    9599