Ticket #3789: 3789.diff

File 3789.diff, 5.5 KB (added by maxime.simon, 15 years ago)

Rewriting of DataTranslation using the ALM Layout.

  • src/preferences/datatranslations/DataTranslationsWindow.cpp

     
    2929#include <TranslationDefs.h>
    3030#include <TranslatorRoster.h>
    3131
     32#include "Area.h"
     33#include "BALMLayout.h"
     34#include "OperatorType.h"
     35#include "XTab.h"
     36#include "YTab.h"
     37
    3238#define DTW_RIGHT   400
    3339#define DTW_BOTTOM  300
    3440
     
    4046DataTranslationsWindow::DataTranslationsWindow()
    4147    : BWindow(BRect(0, 0, DTW_RIGHT, DTW_BOTTOM),
    4248        "DataTranslations", B_TITLED_WINDOW,
    43         B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
     49        B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS)
    4450{
    4551    MoveTo(dynamic_cast<DataTranslationsApplication *>(be_app)->WindowCorner());
    4652
     
    156162    configRect.InsetBy(3, 3);
    157163    configRect.bottom -= 45;
    158164    float width = 0, height = 0;
    159     fConfigView->GetPreferredSize(&width, &height);
     165    if ((fConfigView->Flags() & B_SUPPORTS_LAYOUT) != 0) {
     166        BSize configSize = fConfigView->ExplicitPreferredSize();
     167        width = configSize.Width();
     168        height = configSize.Height();
     169    } else {
     170        fConfigView->GetPreferredSize(&width, &height);
     171    }
    160172    float widen = max_c(0, width - configRect.Width());
    161173    float heighten = max_c(0, height - configRect.Height());
    162174    if (widen > 0 || heighten > 0) {
     
    187199    AddChild(mainView);
    188200
    189201    // Add the translators list view
    190     fTranslatorListView = new TranslatorListView(BRect(10, 10, 120, Bounds().Height() - 10),
    191         "TransList", B_SINGLE_SELECTION_LIST);
     202    fTranslatorListView = new TranslatorListView(BRect(0, 0, 1, 1), "TransList",
     203        B_SINGLE_SELECTION_LIST);
    192204    fTranslatorListView->SetSelectionMessage(new BMessage(kMsgSelectedTranslator));
    193205
    194206    BScrollView *scrollView = new BScrollView("scroll_trans", fTranslatorListView,
    195207            B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
    196208            false, true, B_FANCY_BORDER);
    197     mainView->AddChild(scrollView);
    198209
    199210    // Box around the config and info panels
    200     fRightBox = new BBox(BRect(130.0f + B_V_SCROLL_BAR_WIDTH, 8.0f, Bounds().Width() - 8.0f,
    201         Bounds().Height() - 8.0f), "Right_Side", B_FOLLOW_ALL);
    202     mainView->AddChild(fRightBox);
     211    fRightBox = new BBox("Right_Side");
    203212
    204213    // Add the translator icon view
    205     BRect rightRect(fRightBox->Bounds()), iconRect(0, 0, 31, 31);
    206     rightRect.InsetBy(8, 8);
    207     iconRect.OffsetTo(rightRect.left, rightRect.bottom - iconRect.Height());
    208     fIconView = new IconView(iconRect, "Icon",
     214    fIconView = new IconView(BRect(0, 0, 31, 31), "Icon",
    209215        B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);
    210     fRightBox->AddChild(fIconView);
    211216
    212217    // Add the translator info button
    213     BRect infoRect(0, 0, 80, 20);
    214     BButton *button = new BButton(infoRect, "STD", "Info" B_UTF8_ELLIPSIS,
    215         new BMessage(kMsgTranslatorInfo), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
    216         B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
    217     button->ResizeToPreferred();
    218     button->MoveTo(fRightBox->Bounds().Width() - button->Bounds().Width() - 10.0f,
    219         fRightBox->Bounds().Height() - button->Bounds().Height() - 10.0f);
    220     fRightBox->AddChild(button);
     218    BButton *button = new BButton("STD", "Info" B_UTF8_ELLIPSIS,
     219        new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
    221220
    222221    // Add the translator name view
    223     BRect tranNameRect(iconRect.right + 5, iconRect.top,
    224         infoRect.left - 5, iconRect.bottom);
    225     fTranslatorNameView = new BStringView(tranNameRect, "TranName", "None",
    226             B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
    227     fRightBox->AddChild(fTranslatorNameView);
     222    fTranslatorNameView = new BStringView("TranName", "None");
    228223
    229224    // Populate the translators list view   
    230225    _PopulateListView();
    231226
     227    // Build the layout
     228    BALMLayout *layout = new BALMLayout();
     229    mainView->SetLayout(layout);
     230
     231    XTab *x1 = layout->AddXTab();
     232    XTab *x2 = layout->AddXTab();
     233    XTab *x3 = layout->AddXTab();
     234    YTab *y1 = layout->AddYTab();
     235
     236    Area *leftArea = layout->AddArea(layout->Left(), layout->Top(),
     237        x1, layout->Bottom(), scrollView);
     238    leftArea->SetLeftInset(10);
     239    leftArea->SetTopInset(10);
     240    leftArea->SetBottomInset(10);
     241
     242    Area *rightArea = layout->AddArea(x1, layout->Top(), layout->Right(), y1, fRightBox);
     243    rightArea->SetLeftInset(10);
     244    rightArea->SetTopInset(10);
     245    rightArea->SetRightInset(10);
     246    rightArea->SetBottomInset(10);
     247
     248    Area *iconArea = layout->AddArea(x1, y1, x2, layout->Bottom(), fIconView);
     249    iconArea->SetLeftInset(10);
     250    iconArea->SetBottomInset(10);
     251
     252    Area *infoButtonArea = layout->AddArea(x3, y1, layout->Right(), layout->Bottom(), button);
     253    infoButtonArea->SetRightInset(10);
     254    infoButtonArea->SetBottomInset(10);
     255
     256    layout->AddConstraint(3.0, x1, -1.0, layout->Right(), OperatorType(EQ), 0.0);
     257
    232258    fTranslatorListView->MakeFocus();
    233     fTranslatorListView->Select(0, false);   
     259    fTranslatorListView->Select(0);
    234260}
    235261
    236262
  • src/preferences/datatranslations/Jamfile

     
    11SubDir HAIKU_TOP src preferences datatranslations ;
    22
     3UseLibraryHeaders lp_solve linprog alm ;
     4
    35Preference DataTranslations :
    46    DataTranslations.cpp
    57    DataTranslationsWindow.cpp
     
    79    IconView.cpp
    810    TranslatorListView.cpp
    911
    10     : be translation
     12    : be translation liblpsolve55.so liblinprog.so libalm.so
    1113    : DataTranslations.rdef
    1214    ;