Ticket #5690: filetypes.patch

File filetypes.patch, 98.2 KB (added by yourpalal, 14 years ago)

added SetEnabled() stuff in ApplicationTypesWindow.cpp

  • AttributeListView.h

     
    5050
    5151class AttributeListView : public BListView {
    5252    public:
    53         AttributeListView(BRect frame, const char* name, uint32 resizingMode);
     53        AttributeListView(const char* name);
    5454        virtual ~AttributeListView();
    5555
    5656        void SetTo(BMimeType* type);
     
    7676
    7777extern const struct display_as_map kDisplayAsMap[];
    7878
    79 AttributeItem *create_attribute_item(BMessage& attributes, int32 index);
     79AttributeItem* create_attribute_item(BMessage& attributes, int32 index);
    8080
    8181#endif  // ATTRIBUTE_LIST_VIEW_H
  • StringView.cpp

     
    44 */
    55
    66
     7#include <GroupView.h>
     8#include <LayoutItem.h>
     9#include <StringView.h>
     10
    711#include "StringView.h"
    812
    9 
    10 StringView::StringView(BRect frame, const char* name, const char* label,
    11     const char* text, uint32 resizeMask, uint32 flags)
    12     : BView(frame, name, resizeMask, flags),
    13     fLabel(label),
    14     fText(text),
    15     fLabelAlignment(B_ALIGN_RIGHT),
    16     fTextAlignment(B_ALIGN_LEFT),
    17     fEnabled(true)
     13StringView::StringView(const char* label, const char* text)
     14    :
     15    fView(NULL),
     16    fLabel(new BStringView(NULL, label)),
     17    fLabelItem(NULL),
     18    fText(new BStringView(NULL, text)),
     19    fTextItem(NULL)
    1820{
    19     fDivider = StringWidth(label) + 4.0f;
    2021}
    2122
    2223
    23 StringView::~StringView()
    24 {
    25 }
    26 
    27 
    2824void
    29 StringView::SetAlignment(alignment labelAlignment, alignment textAlignment)
     25StringView::SetLabel(const char* label)
    3026{
    31     if (labelAlignment == fLabelAlignment && textAlignment == fTextAlignment)
    32         return;
    33 
    34     fLabelAlignment = labelAlignment;
    35     fTextAlignment = textAlignment;
    36 
    37     Invalidate();
     27    fLabel->SetText(label);
    3828}
    3929
    4030
    4131void
    42 StringView::GetAlignment(alignment* _label, alignment* _text) const
     32StringView::SetText(const char* text)
    4333{
    44     if (_label)
    45         *_label = fLabelAlignment;
    46     if (_text)
    47         *_text = fTextAlignment;
     34    fText->SetText(text);
    4835}
    4936
    5037
    51 void
    52 StringView::SetDivider(float divider)
     38BLayoutItem*
     39StringView::GetLabelLayoutItem()
    5340{
    54     fDivider = divider;
    55     _UpdateText();
    56 
    57     Invalidate();
     41    return fLabelItem;
    5842}
    5943
    6044
    61 void
    62 StringView::AttachedToWindow()
    63 {
    64     if (Parent() != NULL)
    65         SetViewColor(Parent()->ViewColor());
    66     else
    67         SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
     45BView*
     46StringView::LabelView()
     47{ return fLabel; }
    6848
    69     SetLowColor(ViewColor());
    70     _UpdateText();
    71 }
    7249
    73 
    74 void
    75 StringView::Draw(BRect updateRect)
     50BLayoutItem*
     51StringView::GetTextLayoutItem()
    7652{
    77     BRect rect = Bounds();
    78 
    79     font_height fontHeight;
    80     GetFontHeight(&fontHeight);
    81 
    82     float y = ceilf(fontHeight.ascent) + 1.0f;
    83     float x;
    84 
    85 #if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE)
    86     rgb_color textColor = {0, 0, 0, 255};
    87 #else
    88     rgb_color textColor = ui_color(B_CONTROL_TEXT_COLOR);
    89 #endif
    90 
    91     SetHighColor(IsEnabled() ? textColor
    92         : tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT));
    93 
    94     if (Label()) {
    95         switch (fLabelAlignment) {
    96             case B_ALIGN_RIGHT:
    97                 x = Divider() - StringWidth(Label()) - 3.0f;
    98                 break;
    99 
    100             case B_ALIGN_CENTER:
    101                 x = Divider() - StringWidth(Label()) / 2.0f;
    102                 break;
    103 
    104             default:
    105                 x = 1.0f;
    106                 break;
    107         }
    108 
    109         DrawString(Label(), BPoint(x, y));
    110     }
    111 
    112     if (fTruncatedText.String() != NULL) {
    113         switch (fTextAlignment) {
    114             case B_ALIGN_RIGHT:
    115                 x = rect.Width() - StringWidth(fTruncatedText.String());
    116                 break;
    117 
    118             case B_ALIGN_CENTER:
    119                 x = Divider() + (rect.Width() - Divider() - StringWidth(Label())) / 2.0f;
    120                 break;
    121 
    122             default:
    123                 x = Divider() + 3.0f;
    124                 break;
    125         }
    126 
    127         DrawString(fTruncatedText.String(), BPoint(x, y));
    128     }
     53    return fTextItem;
    12954}
    13055
    13156
    132 void
    133 StringView::FrameResized(float width, float height)
    134 {
    135     BString oldTruncated = fTruncatedText;
    136     _UpdateText();
     57BView*
     58StringView::TextView()
     59{ return fText; }
    13760
    138     if (oldTruncated != fTruncatedText) {
    139         // invalidate text portion only
    140         BRect rect = Bounds();
    141         rect.left = Divider();
    142         Invalidate(rect);
    143     }
    144 }
    14561
    146 
    14762void
    148 StringView::ResizeToPreferred()
     63StringView::SetEnabled(bool enabled)
    14964{
    150     float width, height;
    151     GetPreferredSize(&width, &height);
     65   
     66    rgb_color color;
    15267
    153     // Resize the width only for B_ALIGN_LEFT (if its large enough already, that is)
    154     if (Bounds().Width() > width
    155         && (fLabelAlignment != B_ALIGN_LEFT || fTextAlignment != B_ALIGN_LEFT))
    156         width = Bounds().Width();
    157 
    158     BView::ResizeTo(width, height);
    159 }
    160 
    161 
    162 void
    163 StringView::GetPreferredSize(float* _width, float* _height)
    164 {
    165     if (!Text() && !Label()) {
    166         BView::GetPreferredSize(_width, _height);
    167         return;
     68    if (!enabled) {
     69        color = tint_color(
     70            ui_color(B_PANEL_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT);
     71    } else {
     72        color = ui_color(B_CONTROL_TEXT_COLOR);
    16873    }
    16974
    170     if (_width)
    171         *_width = 7.0f + ceilf(StringWidth(Label()) + StringWidth(Text()));
    172 
    173     if (_height) {
    174         font_height fontHeight;
    175         GetFontHeight(&fontHeight);
    176         *_height = ceilf(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 2.0f;
    177     }
     75    fLabel->SetHighColor(color);
     76    fText->SetHighColor(color);
     77    fLabel->Invalidate();
     78    fText->Invalidate();
    17879}
    17980
    180 
    181 void
    182 StringView::SetEnabled(bool enabled)
     81   
     82//cast operator BView*
     83StringView::operator BView*()
    18384{
    184     if (IsEnabled() == enabled)
    185         return;
    186 
    187     fEnabled = enabled;
    188     Invalidate();
     85    if (fView) return fView;
     86    fView = new BGroupView(B_HORIZONTAL);
     87    BLayout* layout = fView->GroupLayout();
     88    fLabelItem = layout->AddView(fLabel);
     89    fTextItem = layout->AddView(fText);
     90    return fView;
    18991}
    19092
    19193
    192 void
    193 StringView::SetLabel(const char* label)
     94const char*
     95StringView::Label() const
    19496{
    195     fLabel = label;
    196 
    197     // invalidate label portion only
    198     BRect rect = Bounds();
    199     rect.right = Divider();
    200     Invalidate(rect);
     97    return fLabel->Text();
    20198}
    20299
    203100
    204 void
    205 StringView::SetText(const char* text)
     101const char*
     102StringView::Text() const
    206103{
    207     fText = text;
    208 
    209     _UpdateText();
    210 
    211     // invalidate text portion only
    212     BRect rect = Bounds();
    213     rect.left = Divider();
    214     Invalidate(rect);
     104    return fText->Text();
    215105}
    216106
    217 
    218 void
    219 StringView::_UpdateText()
    220 {
    221     fTruncatedText = fText;
    222     TruncateString(&fTruncatedText, B_TRUNCATE_MIDDLE, Bounds().Width() - Divider());
    223 }
  • ExtensionWindow.cpp

     
    99#include "FileTypesWindow.h"
    1010
    1111#include <Button.h>
     12#include <ControlLook.h>
     13#include <GridLayoutBuilder.h>
     14#include <GroupLayout.h>
    1215#include <MenuField.h>
    1316#include <MenuItem.h>
    1417#include <Mime.h>
     
    104107ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type,
    105108        const char* extension)
    106109    : BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK,
    107         B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
    108             | B_ASYNCHRONOUS_CONTROLS),
     110        B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE
     111            | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
    109112    fTarget(target),
    110113    fMimeType(type.Type()),
    111114    fExtension(extension)
    112115{
    113     BRect rect = Bounds();
    114     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    115     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    116     AddChild(topView);
     116    SetLayout(new BGroupLayout(B_VERTICAL));
    117117
    118     rect.InsetBy(8.0f, 8.0f);
    119     fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension,
    120         NULL, B_FOLLOW_LEFT_RIGHT);
    121 
    122     float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f;
     118    float padding = 3.0f;
     119    //if (be_control_look)
     120        // padding = be_control_look->DefaultItemSpacing();
     121            // this seems to be very large!
     122   
     123    fExtensionControl = new BTextControl("Extension:", extension, NULL);
    123124    fExtensionControl->SetModificationMessage(new BMessage(kMsgExtensionUpdated));
    124     fExtensionControl->SetDivider(labelWidth);
    125     fExtensionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
     125    fExtensionControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT);
    126126
    127127    // filter out invalid characters that can't be part of an extension
    128128    BTextView* textView = fExtensionControl->TextView();
     
    131131        textView->DisallowChar(disallowedCharacters[i]);
    132132    }
    133133
    134     float width, height;
    135     fExtensionControl->GetPreferredSize(&width, &height);
    136     fExtensionControl->ResizeTo(rect.Width(), height);
    137     topView->AddChild(fExtensionControl);
    138 
    139     fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add",
    140         new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    141     fAcceptButton->ResizeToPreferred();
    142     fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
    143         Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
     134    fAcceptButton = new BButton(extension ? "Done" : "Add",
     135        new BMessage(kMsgAccept));
    144136    fAcceptButton->SetEnabled(false);
    145     topView->AddChild(fAcceptButton);
    146137
    147     BButton* button = new BButton(rect, "cancel", "Cancel",
    148         new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    149     button->ResizeToPreferred();
    150     button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
    151         fAcceptButton->Frame().top);
    152     topView->AddChild(button);
     138    BButton* button = new BButton("Cancel",
     139        new BMessage(B_QUIT_REQUESTED));
    153140
    154     ResizeTo(labelWidth * 4.0f + 24.0f, fExtensionControl->Bounds().Height()
    155         + fAcceptButton->Bounds().Height() + 28.0f);
    156     SetSizeLimits(button->Bounds().Width() + fAcceptButton->Bounds().Width() + 26.0f,
    157         32767.0f, Frame().Height(), Frame().Height());
     141    AddChild(BGridLayoutBuilder(padding, padding)
     142        .Add(fExtensionControl->CreateLabelLayoutItem(), 0, 0)
     143        .Add(fExtensionControl->CreateTextViewLayoutItem(), 1, 0)
     144        .Add(fAcceptButton, 0, 1)
     145        .Add(button, 1, 1)
     146        .SetInsets(padding, padding, padding, padding)
     147    );
    158148
    159149    // omit the leading dot
    160150    if (fExtension.ByteAt(0) == '.')
  • TypeListWindow.cpp

     
    88#include "TypeListWindow.h"
    99
    1010#include <Button.h>
     11#include <ControlLook.h>
     12#include <GroupLayoutBuilder.h>
    1113#include <ScrollView.h>
    1214
    1315#include <string.h>
     
    1719const uint32 kMsgSelected = 'seld';
    1820
    1921
    20 TypeListWindow::TypeListWindow(const char* currentType, uint32 what, BWindow* target)
    21     : BWindow(BRect(100, 100, 360, 440), "Choose type", B_MODAL_WINDOW,
    22         B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
     22TypeListWindow::TypeListWindow(const char* currentType,
     23    uint32 what, BWindow* target)
     24    :
     25    BWindow(BRect(100, 100, 360, 440), "Choose type", B_MODAL_WINDOW,
     26        B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
    2327    fTarget(target),
    2428    fWhat(what)
    2529{
    26     BRect rect = Bounds();
    27     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    28     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    29     AddChild(topView);
     30    float padding=3.0f;
     31    //if (be_control_look)
     32        // padding = be_control_look->DefaultItemSpacing();
     33        // seems too big
    3034
    31     fSelectButton = new BButton(rect, "select", "Done",
    32         new BMessage(kMsgSelected), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    33     fSelectButton->ResizeToPreferred();
    34     fSelectButton->MoveTo(topView->Bounds().right - 8.0f - fSelectButton->Bounds().Width(),
    35         topView->Bounds().bottom - 8.0f - fSelectButton->Bounds().Height());
     35    fSelectButton = new BButton("select", "Done",
     36        new BMessage(kMsgSelected));
    3637    fSelectButton->SetEnabled(false);
    37     topView->AddChild(fSelectButton);
    3838
    39     BButton* button = new BButton(fSelectButton->Frame(), "cancel", "Cancel",
    40         new BMessage(B_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    41     button->ResizeToPreferred();
    42     button->MoveBy(-button->Bounds().Width() - 8.0f, 0.0f);
    43     topView->AddChild(button);
     39    BButton* button = new BButton("cancel", "Cancel",
     40        new BMessage(B_CANCEL));
    4441
    4542    fSelectButton->MakeDefault(true);
    4643
    47     rect.bottom = button->Frame().top - 10.0f;
    48     rect.top = 10.0f;
    49     rect.left = 10.0f;
    50     rect.right -= 10.0f + B_V_SCROLL_BAR_WIDTH;
    51     fListView = new MimeTypeListView(rect, "typeview", NULL, true, false,
    52         B_FOLLOW_ALL);
     44    fListView = new MimeTypeListView("typeview", NULL, true, false);
    5345    fListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
    5446    fListView->SetInvocationMessage(new BMessage(kMsgSelected));
    5547
    5648    BScrollView* scrollView = new BScrollView("scrollview", fListView,
    57         B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    58     topView->AddChild(scrollView);
     49        B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    5950
     51    SetLayout(new BGroupLayout(B_VERTICAL));
     52    AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
     53        .Add(scrollView)
     54        .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)     
     55            .Add(button)
     56            .Add(fSelectButton)
     57        )
     58        .SetInsets(padding, padding, padding, padding)
     59    );
     60
     61    BAlignment buttonAlignment =
     62        BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_CENTER);
     63    button->SetExplicitAlignment(buttonAlignment);
     64    fSelectButton->SetExplicitAlignment(buttonAlignment);
     65
    6066    MoveTo(target->Frame().LeftTop() + BPoint(15.0f, 15.0f));
    61     SetSizeLimits(button->Bounds().Width() + fSelectButton->Bounds().Width() + 64.0f, 32767.0f,
    62         fSelectButton->Bounds().Height() * 5.0f, 32767.0f);
    6367}
    6468
    6569
  • DropTargetListView.h

     
    1111
    1212class DropTargetListView : public BListView {
    1313    public:
    14         DropTargetListView(BRect frame, const char* name,
     14        DropTargetListView(const char* name,
    1515            list_view_type type = B_SINGLE_SELECTION_LIST,
    16             uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
    1716            uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
    1817        virtual ~DropTargetListView();
    1918
  • PreferredAppMenu.h

     
    1515
    1616void update_preferred_app_menu(BMenu* menu, BMimeType* type, uint32 what,
    1717    const char* preferredFrom = NULL);
    18 status_t retrieve_preferred_app(BMessage* message, bool sameAs, const char* forType,
    19     BString& preferredApp);
    2018
     19status_t retrieve_preferred_app(BMessage* message, bool sameAs,
     20    const char* forType, BString& preferredApp);
     21
    2122#endif  // PREFERRED_APP_MENU_H
  • FileTypeWindow.cpp

     
    1414#include <Bitmap.h>
    1515#include <Box.h>
    1616#include <Button.h>
     17#include <ControlLook.h>
    1718#include <File.h>
     19#include <GridLayoutBuilder.h>
     20#include <GroupLayoutBuilder.h>
    1821#include <MenuField.h>
    1922#include <MenuItem.h>
    2023#include <Mime.h>
    2124#include <NodeInfo.h>
    2225#include <PopUpMenu.h>
     26#include <SpaceLayoutItem.h>
    2327#include <TextControl.h>
    2428
    2529#include <stdio.h>
     
    3943
    4044
    4145FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs)
    42     : BWindow(BRect(0.0f, 0.0f, 200.0f, 200.0f).OffsetBySelf(position),
     46    :
     47    BWindow(BRect(0.0f, 0.0f, 200.0f, 200.0f).OffsetBySelf(position),
    4348        "File type", B_TITLED_WINDOW,
    44         B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
     49        B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE |
     50        B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
    4551{
    46     BRect rect = Bounds();
    47     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    48     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    49     AddChild(topView);
     52    float padding = 3.0f;
     53    // if (be_control_look)
     54        // padding = be_control_look->DefaultItemSpacing();
     55            // too big!
    5056
    5157    // "File Type" group
     58    BBox* fileTypeBox = new BBox("file type BBox");
     59    fileTypeBox->SetLabel("File type");
    5260
    53     BFont font(be_bold_font);
    54     font_height fontHeight;
    55     font.GetHeight(&fontHeight);
     61    fTypeControl = new BTextControl("type", NULL, "fTypeControl",
     62        new BMessage(kMsgTypeEntered));
    5663
    57     rect.InsetBy(8.0f, 8.0f);
    58     BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    59     box->SetLabel("File type");
    60     topView->AddChild(box);
    61 
    62     rect = box->Bounds();
    63     rect.InsetBy(8.0f, 4.0f + fontHeight.ascent + fontHeight.descent);
    64     fTypeControl = new BTextControl(rect, "type", NULL, NULL,
    65         new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT);
    66     fTypeControl->SetDivider(0.0f);
    67     float width, height;
    68     fTypeControl->GetPreferredSize(&width, &height);
    69     fTypeControl->ResizeTo(rect.Width(), height);
    70     box->AddChild(fTypeControl);
    71 
    7264    // filter out invalid characters that can't be part of a MIME type name
    7365    BTextView* textView = fTypeControl->TextView();
    7466    const char* disallowedCharacters = "<>@,;:\"()[]?=";
     
    7668        textView->DisallowChar(disallowedCharacters[i]);
    7769    }
    7870
    79     rect.OffsetBy(0.0f, fTypeControl->Bounds().Height() + 5.0f);
    80     fSelectTypeButton = new BButton(rect, "select type", "Select" B_UTF8_ELLIPSIS,
    81         new BMessage(kMsgSelectType), B_FOLLOW_LEFT | B_FOLLOW_TOP);
    82     fSelectTypeButton->ResizeToPreferred();
    83     box->AddChild(fSelectTypeButton);
     71    fSelectTypeButton = new BButton("select type", "Select" B_UTF8_ELLIPSIS,
     72        new BMessage(kMsgSelectType));
    8473
    85     rect.OffsetBy(fSelectTypeButton->Bounds().Width() + 8.0f, 0.0f);
    86     fSameTypeAsButton = new BButton(rect, "same type as", "Same as" B_UTF8_ELLIPSIS,
    87         new BMessage(kMsgSameTypeAs), B_FOLLOW_LEFT | B_FOLLOW_TOP);
    88     fSameTypeAsButton->ResizeToPreferred();
    89     box->AddChild(fSameTypeAsButton);
     74    fSameTypeAsButton = new BButton("same type as", "Same as" B_UTF8_ELLIPSIS,
     75        new BMessage(kMsgSameTypeAs));
    9076
    91     width = font.StringWidth("Icon") + 16.0f;
    92     if (width < B_LARGE_ICON + 16.0f)
    93         width = B_LARGE_ICON + 16.0f;
     77    fileTypeBox->AddChild(BGridLayoutBuilder(padding, padding)
     78        .Add(fTypeControl, 0, 0, 2, 1)
     79        .Add(fSelectTypeButton, 0, 1)
     80        .Add(fSameTypeAsButton, 1, 1)
     81        .SetInsets(padding, padding, padding, padding)
     82    );
    9483
    95     height = fSelectTypeButton->Frame().bottom + 8.0f;
    96     if (height < 8.0f + B_LARGE_ICON + fontHeight.ascent + fontHeight.descent)
    97         height = 8.0f + B_LARGE_ICON + fontHeight.ascent + fontHeight.descent;
    98     box->ResizeTo(box->Bounds().Width() - width - 8.0f, height);
    99 
    10084    // "Icon" group
    10185
    102     rect = box->Frame();
    103     rect.left = rect.right + 8.0f;
    104     rect.right += width + 8.0f;
    105     float iconBoxWidth = rect.Width();
    106     box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    107     box->SetLabel("Icon");
    108     topView->AddChild(box);
     86    BBox* iconBox = new BBox("icon BBox");
     87    iconBox->SetLabel("Icon");
     88    fIconView = new IconView("icon");
     89    iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
     90        .Add(fIconView)
     91        .SetInsets(padding, padding, padding, padding));
    10992
    110     rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f);
    111     rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f);
    112     if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f)
    113         rect.top = fontHeight.ascent + fontHeight.descent + 4.0f;
    114     fIconView = new IconView(rect, "icon");
    115     box->AddChild(fIconView);
    116 
    11793    // "Preferred Application" group
    11894
    119     rect.top = box->Frame().bottom + 8.0f;
    120     rect.bottom = rect.top + box->Bounds().Height();
    121     rect.left = 8.0f;
    122     rect.right = Bounds().Width() - 8.0f;
    123     box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    124     box->SetLabel("Preferred application");
    125     topView->AddChild(box);
     95    BBox* preferredBox = new BBox("preferred BBox");
     96    preferredBox->SetLabel("Preferred application");
    12697
    12798    BMenu* menu = new BPopUpMenu("preferred");
    12899    BMenuItem* item;
     
    130101        new BMessage(kMsgPreferredAppChosen)));
    131102    item->SetMarked(true);
    132103
    133     rect = fTypeControl->Frame();
    134     BView* constrainingView = new BView(rect, NULL, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
    135     constrainingView->SetViewColor(topView->ViewColor());
     104    fPreferredField = new BMenuField("preferred", NULL, menu);
    136105
    137     fPreferredField = new BMenuField(rect.OffsetToCopy(B_ORIGIN), "preferred",
    138         NULL, menu);
    139     fPreferredField->GetPreferredSize(&width, &height);
    140     fPreferredField->ResizeTo(rect.Width(), height);
    141     constrainingView->ResizeTo(rect.Width(), height);
    142     constrainingView->AddChild(fPreferredField);
    143         // we embed the menu field in another view to make it behave like
    144         // we want so that it can't obscure other elements with larger
    145         // labels
     106    fSelectAppButton = new BButton("select app", "Select" B_UTF8_ELLIPSIS,
     107        new BMessage(kMsgSelectPreferredApp));
    146108
    147     box->AddChild(constrainingView);
     109    fSameAppAsButton = new BButton("same app as", "Same as" B_UTF8_ELLIPSIS,
     110        new BMessage(kMsgSamePreferredAppAs));
    148111
    149     rect.OffsetBy(0.0f, height + 5.0f);
    150     fSelectAppButton = new BButton(rect, "select app", "Select" B_UTF8_ELLIPSIS,
    151         new BMessage(kMsgSelectPreferredApp), B_FOLLOW_LEFT | B_FOLLOW_TOP);
    152     fSelectAppButton->ResizeToPreferred();
    153     box->AddChild(fSelectAppButton);
     112    preferredBox->AddChild(BGridLayoutBuilder(padding, padding)
     113        .Add(fPreferredField, 0, 0, 2, 1)
     114        .Add(fSelectAppButton, 0, 1)
     115        .Add(fSameAppAsButton, 1, 1)
     116        .Add(BSpaceLayoutItem::CreateGlue(), 3, 0, 1, 2)
     117        .SetInsets(padding, padding, padding, padding)
     118    );
    154119
    155     rect.OffsetBy(fSelectAppButton->Bounds().Width() + 8.0f, 0.0f);
    156     fSameAppAsButton = new BButton(rect, "same app as", "Same as" B_UTF8_ELLIPSIS,
    157         new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_LEFT | B_FOLLOW_TOP);
    158     fSameAppAsButton->ResizeToPreferred();
    159     box->AddChild(fSameAppAsButton);
    160     box->ResizeBy(0.0f, height - fTypeControl->Bounds().Height());
     120    SetLayout(new BGroupLayout(B_VERTICAL));
     121    AddChild(BGridLayoutBuilder(padding, padding)
     122        .Add(fileTypeBox, 0, 0, 1, 2)
     123        .Add(iconBox, 1, 1, 1, 2)
     124        .Add(preferredBox, 0, 2, 1, 2)
     125        .SetInsets(padding, padding, padding, padding)
     126    );
    161127
    162     ResizeTo(fSameAppAsButton->Frame().right + 100.0f, box->Frame().bottom + 8.0f);
    163     SetSizeLimits(fSameAppAsButton->Frame().right + iconBoxWidth + 32.0f, 32767.0f,
    164         Bounds().Height(), Bounds().Height());
     128    float minWidth, minHeight;
     129    GetSizeLimits(&minWidth, NULL, &minHeight, NULL);
     130    ResizeTo(minWidth, minHeight);
    165131
    166132    fTypeControl->MakeFocus(true);
    167 
    168133    BMimeType::StartWatching(this);
    169134    _SetTo(refs);
    170135}
  • MimeTypeListView.cpp

     
    267267//  #pragma mark -
    268268
    269269
    270 MimeTypeListView::MimeTypeListView(BRect rect, const char* name,
    271         const char* supertype, bool showIcons, bool applicationMode,
    272         uint32 resizingMode)
    273     : BOutlineListView(rect, name, B_SINGLE_SELECTION_LIST, resizingMode),
     270MimeTypeListView::MimeTypeListView(const char* name,
     271        const char* supertype, bool showIcons, bool applicationMode)
     272    : BOutlineListView(name, B_SINGLE_SELECTION_LIST),
    274273    fSupertype(supertype),
    275274    fShowIcons(showIcons),
    276275    fApplicationMode(applicationMode)
  • NewFileTypeWindow.cpp

     
    99#include "NewFileTypeWindow.h"
    1010
    1111#include <Button.h>
     12#include <ControlLook.h>
     13#include <GroupLayout.h>
     14#include <GridLayoutBuilder.h>
     15#include <MenuBar.h>
    1216#include <MenuField.h>
    1317#include <MenuItem.h>
    1418#include <Mime.h>
    1519#include <PopUpMenu.h>
     20#include <SpaceLayoutItem.h>
    1621#include <String.h>
     22#include <StringView.h>
    1723#include <TextControl.h>
    1824
    1925#include <string.h>
     
    2733const uint32 kMsgAddType = 'atyp';
    2834
    2935
    30 NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* currentType)
    31     : BWindow(BRect(100, 100, 350, 200), "New file type", B_TITLED_WINDOW,
    32         B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS),
     36NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target,
     37    const char* currentType)
     38    :
     39    BWindow(BRect(100, 100, 350, 200), "New file type", B_MODAL_WINDOW,
     40        B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS
     41        | B_AUTO_UPDATE_SIZE_LIMITS ),
    3342    fTarget(target)
    3443{
    35     BRect rect = Bounds();
    36     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    37     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    38     AddChild(topView);
    39 
    40     float labelWidth = be_plain_font->StringWidth("Internal name:") + 2.0f;
    41 
    42     rect.InsetBy(8.0f, 6.0f);
    4344    fSupertypesMenu = new BPopUpMenu("supertypes");
    4445    BMenuItem* item;
    4546    BMessage types;
     
    6162        if (i > 1)
    6263            fSupertypesMenu->AddSeparatorItem();
    6364    }
     65
    6466    fSupertypesMenu->AddItem(new BMenuItem("Add new group",
    6567        new BMessage(kMsgNewSupertypeChosen)));
     68    BMenuField* typesMenuField = new BMenuField(NULL, fSupertypesMenu);
    6669
    67     BMenuField* menuField = new BMenuField(rect, "supertypes",
    68         "Group:", fSupertypesMenu);
    69     menuField->SetDivider(labelWidth);
    70     menuField->SetAlignment(B_ALIGN_RIGHT);
    71     float width, height;
    72     menuField->GetPreferredSize(&width, &height);
    73     menuField->ResizeTo(rect.Width(), height);
    74     topView->AddChild(menuField);
     70    BStringView* typesMenuLabel = new BStringView(NULL, "Group:");
     71        // Create a separate label view, otherwise things don't line up right
     72    typesMenuLabel->SetAlignment(B_ALIGN_LEFT);
     73    typesMenuLabel->SetExplicitAlignment(
     74        BAlignment(B_ALIGN_LEFT, B_ALIGN_USE_FULL_HEIGHT));
    7575
    76     fNameControl = new BTextControl(rect, "internal", "Internal name:", "",
    77         NULL, B_FOLLOW_LEFT_RIGHT);
     76    fNameControl = new BTextControl("Internal name:", "", NULL);
    7877    fNameControl->SetModificationMessage(new BMessage(kMsgNameUpdated));
    79     fNameControl->SetDivider(labelWidth);
    80     fNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    8178
    8279    // filter out invalid characters that can't be part of a MIME type name
    83     BTextView* textView = fNameControl->TextView();
     80    BTextView* nameControlTextView = fNameControl->TextView();
    8481    const char* disallowedCharacters = "/<>@,;:\"()[]?=";
    8582    for (int32 i = 0; disallowedCharacters[i]; i++) {
    86         textView->DisallowChar(disallowedCharacters[i]);
     83        nameControlTextView->DisallowChar(disallowedCharacters[i]);
    8784    }
    8885
    89     fNameControl->GetPreferredSize(&width, &height);
    90     fNameControl->ResizeTo(rect.Width(), height);
    91     fNameControl->MoveTo(8.0f, 12.0f + menuField->Bounds().Height());
    92     topView->AddChild(fNameControl);
     86    fAddButton = new BButton("Add type", new BMessage(kMsgAddType));
    9387
    94     fAddButton = new BButton(rect, "add", "Add type", new BMessage(kMsgAddType),
    95         B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    96     fAddButton->ResizeToPreferred();
    97     fAddButton->MoveTo(Bounds().Width() - 8.0f - fAddButton->Bounds().Width(),
    98         Bounds().Height() - 8.0f - fAddButton->Bounds().Height());
    99     fAddButton->SetEnabled(false);
    100     topView->AddChild(fAddButton);
     88    float padding = 3.0f;
     89    // if (be_control_look)
     90        // padding = be_control_look->DefaultItemSpacing();
    10191
    102     BButton* button = new BButton(rect, "cancel", "Cancel",
    103         new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    104     button->ResizeToPreferred();
    105     button->MoveTo(fAddButton->Frame().left - 10.0f - button->Bounds().Width(),
    106         fAddButton->Frame().top);
    107     topView->AddChild(button);
     92    SetLayout(new BGroupLayout(B_VERTICAL));
     93    AddChild(BGridLayoutBuilder(padding, padding)
     94        .SetInsets(padding, padding, padding, padding)
     95        .Add(typesMenuLabel, 0, 0)
     96        .Add(typesMenuField, 1, 0, 2)
     97        .Add(fNameControl->CreateLabelLayoutItem(), 0, 1)
     98        .Add(fNameControl->CreateTextViewLayoutItem(), 1, 1, 2)
     99        .Add(BSpaceLayoutItem::CreateGlue(), 0, 2)
     100        .Add(new BButton("Cancel", new BMessage(B_QUIT_REQUESTED)), 1, 2)
     101        .Add(fAddButton, 2, 2)
     102        .SetColumnWeight(0, 3)
     103        );
    108104
    109     ResizeTo(labelWidth * 4.0f + 24.0f, fNameControl->Bounds().Height()
    110         + menuField->Bounds().Height() + fAddButton->Bounds().Height() + 30.0f);
    111     SetSizeLimits(button->Bounds().Width() + fAddButton->Bounds().Width() + 26.0f,
    112         32767.0f, Frame().Height(), Frame().Height());
     105    BAlignment fullSize = BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
     106    typesMenuField->MenuBar()->SetExplicitAlignment(fullSize);
     107    fNameControl->TextView()->SetExplicitAlignment(fullSize);
    113108
     109    BLayoutItem* nameControlLabelItem = fNameControl->CreateLabelLayoutItem();
     110    nameControlLabelItem->SetExplicitMinSize(nameControlLabelItem->MinSize());
     111        // stops fNameControl's label from truncating under certain conditions
     112
    114113    fAddButton->MakeDefault(true);
    115114    fNameControl->MakeFocus(true);
    116115
     
    131130            fAddButton->SetLabel("Add type");
    132131            fNameControl->SetLabel("Internal name:");
    133132            fNameControl->MakeFocus(true);
     133            InvalidateLayout(true);
    134134            break;
    135135
    136136        case kMsgNewSupertypeChosen:
    137137            fAddButton->SetLabel("Add group");
    138138            fNameControl->SetLabel("Group name:");
    139139            fNameControl->MakeFocus(true);
     140            InvalidateLayout(true);
    140141            break;
    141142
    142143        case kMsgNameUpdated:
     
    195196    fTarget.SendMessage(kMsgNewTypeWindowClosed);
    196197    return true;
    197198}
     199
     200
  • ApplicationTypesWindow.h

     
    2727        ApplicationTypesWindow(const BMessage& settings);
    2828        virtual ~ApplicationTypesWindow();
    2929
    30         virtual void FrameResized(float width, float height);
    3130        virtual void MessageReceived(BMessage* message);
    3231        virtual bool QuitRequested();
    3332
  • IconView.h

     
    5050
    5151        Icon& operator=(const Icon& source);
    5252
    53         void AdoptLarge(BBitmap *large);
    54         void AdoptMini(BBitmap *mini);
     53        void AdoptLarge(BBitmap* large);
     54        void AdoptMini(BBitmap* mini);
    5555        void AdoptData(uint8* data, size_t size);
    5656
    5757        static BBitmap* AllocateBitmap(int32 size, int32 space = -1);
     
    6363        size_t      fSize;
    6464};
    6565
     66class BSize;
     67
    6668class IconView : public BControl {
    6769    public:
    68         IconView(BRect rect, const char* name,
    69             uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
    70             uint32 flags = B_NAVIGABLE);
     70        IconView(const char* name, uint32 flags = B_NAVIGABLE);
    7171        virtual ~IconView();
    7272
    7373        virtual void AttachedToWindow();
     
    7676        virtual void Draw(BRect updateRect);
    7777        virtual void GetPreferredSize(float* _width, float* _height);
    7878
     79        virtual BSize MaxSize();
     80        virtual BSize MinSize();
     81        virtual BSize PreferredSize();
     82
    7983        virtual void MouseDown(BPoint where);
    8084        virtual void MouseUp(BPoint where);
    8185        virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage);
     
    9296        void SetIconSize(int32 size);
    9397        void ShowIconHeap(bool show);
    9498        void ShowEmptyFrame(bool show);
    95         void SetTarget(const BMessenger& target);
     99        status_t SetTarget(const BMessenger& target);
    96100        void SetModificationMessage(BMessage* message);
    97         void Invoke(const BMessage* message = NULL);
     101        status_t Invoke(const BMessage* message = NULL);
    98102
    99103        ::Icon* Icon();
    100104        int32 IconSize() const { return fIconSize; }
  • AttributeListView.cpp

     
    7171    buffer[4] = 0xff & (type);
    7272    buffer[5] = '\'';
    7373    buffer[6] = 0;
    74     for (int16 i = 0;i < 4;i++) {
     74    for (int16 i = 0; i < 4; i++) {
    7575        if (buffer[i] < ' ')
    7676            buffer[i] = '.';
    7777    }
     
    8181}
    8282
    8383
    84 AttributeItem *
     84AttributeItem*
    8585create_attribute_item(BMessage& attributes, int32 index)
    8686{
    8787    const char* publicName;
     
    235235//  #pragma mark -
    236236
    237237
    238 AttributeListView::AttributeListView(BRect frame, const char* name,
    239         uint32 resizingMode)
    240     : BListView(frame, name, B_SINGLE_SELECTION_LIST, resizingMode,
     238AttributeListView::AttributeListView(const char* name)
     239    : BListView(name, B_SINGLE_SELECTION_LIST,
    241240        B_WILL_DRAW | B_NAVIGABLE | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
    242241{
    243242}
  • AttributeWindow.cpp

     
    1111#include <Box.h>
    1212#include <Button.h>
    1313#include <CheckBox.h>
     14#include <ControlLook.h>
     15#include <GridLayoutBuilder.h>
     16#include <GroupLayoutBuilder.h>
    1417#include <MenuField.h>
    1518#include <MenuItem.h>
    1619#include <Mime.h>
    1720#include <PopUpMenu.h>
     21#include <SpaceLayoutItem.h>
    1822#include <String.h>
    1923#include <TextControl.h>
    2024
     
    8589
    8690AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
    8791        AttributeItem* attributeItem)
    88     : BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
    89         B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
     92    :
     93    BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
     94        B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS
    9095            | B_ASYNCHRONOUS_CONTROLS),
    9196    fTarget(target),
    9297    fMimeType(mimeType.Type())
    9398{
     99    float padding = 3.0f;
     100    //if (be_control_look)
     101        //padding = be_control_look->DefaultItemSpacing();
     102
    94103    if (attributeItem != NULL)
    95104        fAttribute = *attributeItem;
    96105
    97     BRect rect = Bounds();
    98     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    99     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    100     AddChild(topView);
    101 
    102     rect.InsetBy(8.0f, 8.0f);
    103     fPublicNameControl = new BTextControl(rect, "public", "Attribute name:",
    104         fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT);
    105     fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
    106 
    107     float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f;
    108     fPublicNameControl->SetDivider(labelWidth);
     106    fPublicNameControl = new BTextControl("Attribute name:",
     107        fAttribute.PublicName(), NULL);
     108    fPublicNameControl->SetModificationMessage(
     109        new BMessage(kMsgAttributeUpdated));
    109110    fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    110111
    111     float width, height;
    112     fPublicNameControl->GetPreferredSize(&width, &height);
    113     fPublicNameControl->ResizeTo(rect.Width(), height);
    114     topView->AddChild(fPublicNameControl);
    115 
    116     rect = fPublicNameControl->Frame();
    117     rect.OffsetBy(0.0f, rect.Height() + 5.0f);
    118     fAttributeControl = new BTextControl(rect, "internal", "Internal name:",
    119         fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT);
    120     fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
    121     fAttributeControl->SetDivider(labelWidth);
     112    fAttributeControl = new BTextControl("Internal name:",
     113        fAttribute.Name(), NULL);
     114    fAttributeControl->SetModificationMessage(
     115        new BMessage(kMsgAttributeUpdated));
    122116    fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    123117
    124118    // filter out invalid characters that can't be part of an attribute
     
    128122        textView->DisallowChar(disallowedCharacters[i]);
    129123    }
    130124
    131     topView->AddChild(fAttributeControl);
    132 
    133125    fTypeMenu = new BPopUpMenu("type");
    134126    BMenuItem* item = NULL;
    135127    for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
     
    143135            item->SetMarked(true);
    144136    }
    145137
    146     rect.OffsetBy(0.0f, rect.Height() + 4.0f);
    147     BMenuField* menuField = new BMenuField(rect, "types",
    148         "Type:", fTypeMenu);
    149     menuField->SetDivider(labelWidth);
    150     menuField->SetAlignment(B_ALIGN_RIGHT);
    151     menuField->GetPreferredSize(&width, &height);
    152     menuField->ResizeTo(rect.Width(), height);
    153     topView->AddChild(menuField);
     138    BMenuField* typeMenuField = new BMenuField("types" , "Type:", fTypeMenu);
     139    typeMenuField->SetAlignment(B_ALIGN_RIGHT);
    154140
    155     rect.OffsetBy(0.0f, rect.Height() + 4.0f);
    156     rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f;
    157     BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT);
    158     topView->AddChild(box);
    159 
    160     fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible",
     141    fVisibleCheckBox = new BCheckBox("visible", "Visible",
    161142        new BMessage(kMsgVisibilityChanged));
    162143    fVisibleCheckBox->SetValue(fAttribute.Visible());
    163     fVisibleCheckBox->ResizeToPreferred();
    164     box->SetLabel(fVisibleCheckBox);
    165144
    166     labelWidth -= 8.0f;
    167 
    168145    BMenu* menu = new BPopUpMenu("display as");
    169146    for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
    170147        BMessage* message = new BMessage(kMsgDisplayAsChosen);
     
    182159            item->SetMarked(true);
    183160    }
    184161
    185     rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height());
    186     rect.right -= 18.0f;
    187     fDisplayAsMenuField = new BMenuField(rect, "display as",
     162    fDisplayAsMenuField = new BMenuField("display as",
    188163        "Display as:", menu);
    189     fDisplayAsMenuField->SetDivider(labelWidth);
    190164    fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT);
    191     fDisplayAsMenuField->ResizeTo(rect.Width(), height);
    192     box->AddChild(fDisplayAsMenuField);
    193165
    194     fEditableCheckBox = new BCheckBox(rect, "editable", "Editable",
    195         new BMessage(kMsgAttributeUpdated), B_FOLLOW_RIGHT);
     166    fEditableCheckBox = new BCheckBox("editable", "Editable",
     167        new BMessage(kMsgAttributeUpdated));
    196168    fEditableCheckBox->SetValue(fAttribute.Editable());
    197     fEditableCheckBox->ResizeToPreferred();
    198     fEditableCheckBox->MoveTo(rect.right - fEditableCheckBox->Bounds().Width(),
    199         rect.top + (fDisplayAsMenuField->Bounds().Height()
    200         - fEditableCheckBox->Bounds().Height()) / 2.0f);
    201     box->AddChild(fEditableCheckBox);
    202169
    203     rect.OffsetBy(0.0f, menuField->Bounds().Height() + 4.0f);
    204     rect.bottom = rect.top + fPublicNameControl->Bounds().Height();
    205     fSpecialControl = new BTextControl(rect, "special", "Special:",
    206         display_as_parameter(fAttribute.DisplayAs()), NULL,
    207         B_FOLLOW_LEFT_RIGHT);
    208     fSpecialControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
    209     fSpecialControl->SetDivider(labelWidth);
     170    fSpecialControl = new BTextControl("Special:",
     171        display_as_parameter(fAttribute.DisplayAs()), NULL);
     172    fSpecialControl->SetModificationMessage(
     173        new BMessage(kMsgAttributeUpdated));
    210174    fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    211175    fSpecialControl->SetEnabled(false);
    212     box->AddChild(fSpecialControl);
    213176
    214177    char text[64];
    215178    snprintf(text, sizeof(text), "%ld", fAttribute.Width());
    216     rect.OffsetBy(0.0f, fSpecialControl->Bounds().Height() + 4.0f);
    217     fWidthControl = new BTextControl(rect, "width", "Width:",
    218         text, NULL, B_FOLLOW_LEFT_RIGHT);
    219     fWidthControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
    220     fWidthControl->SetDivider(labelWidth);
     179    fWidthControl = new BTextControl("Width:", text, NULL);
     180    fWidthControl->SetModificationMessage(
     181        new BMessage(kMsgAttributeUpdated));
    221182    fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    222183
    223184    // filter out invalid characters that can't be part of a width
     
    228189    }
    229190    textView->SetMaxBytes(4);
    230191
    231     box->AddChild(fWidthControl);
    232 
    233192    const struct alignment_map {
    234193        int32       alignment;
    235194        const char* name;
     
    252211            item->SetMarked(true);
    253212    }
    254213
    255     rect.OffsetBy(0.0f, menuField->Bounds().Height() + 1.0f);
    256     fAlignmentMenuField = new BMenuField(rect, "alignment",
     214    fAlignmentMenuField = new BMenuField("alignment",
    257215        "Alignment:", menu);
    258     fAlignmentMenuField->SetDivider(labelWidth);
    259216    fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT);
    260     fAlignmentMenuField->ResizeTo(rect.Width(), height);
    261     box->AddChild(fAlignmentMenuField);
    262     box->ResizeBy(0.0f, fAlignmentMenuField->Bounds().Height() * 2.0f
    263         + fVisibleCheckBox->Bounds().Height());
    264217
    265     fAcceptButton = new BButton(rect, "add", item ? "Done" : "Add",
    266         new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    267     fAcceptButton->ResizeToPreferred();
    268     fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
    269         Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
     218    fAcceptButton = new BButton("add", item ? "Done" : "Add",
     219        new BMessage(kMsgAccept));
    270220    fAcceptButton->SetEnabled(false);
    271     topView->AddChild(fAcceptButton);
    272221
    273     BButton* button = new BButton(rect, "cancel", "Cancel",
    274         new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
    275     button->ResizeToPreferred();
    276     button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
    277         fAcceptButton->Frame().top);
    278     topView->AddChild(button);
     222    BButton* cancelButton = new BButton("cancel", "Cancel",
     223        new BMessage(B_QUIT_REQUESTED));
    279224
    280     ResizeTo(labelWidth * 4.0f + 24.0f, box->Frame().bottom
    281         + button->Bounds().Height() + 20.0f);
    282     SetSizeLimits(fEditableCheckBox->Bounds().Width() + button->Bounds().Width()
    283         + fAcceptButton->Bounds().Width() + labelWidth + 24.0f,
    284         32767.0f, Frame().Height(), Frame().Height());
     225    BBox* visibleBox;
     226    SetLayout(new BGroupLayout(B_VERTICAL));
     227    AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
     228        .SetInsets(padding, padding, padding, padding)
     229        .Add(BGridLayoutBuilder(padding, padding)
     230            .Add(fPublicNameControl->CreateLabelLayoutItem(), 0, 0)
     231            .Add(fPublicNameControl->CreateTextViewLayoutItem(), 1, 0)
     232            .Add(fAttributeControl->CreateLabelLayoutItem(), 0, 1)
     233            .Add(fAttributeControl->CreateTextViewLayoutItem(), 1, 1)
     234            .Add(typeMenuField->CreateLabelLayoutItem(), 0, 2)
     235            .Add(typeMenuField->CreateMenuBarLayoutItem(), 1, 2)
     236        )
     237        .Add(visibleBox = new BBox(B_FANCY_BORDER,
     238            BGridLayoutBuilder(padding, padding)
     239                .Add(fDisplayAsMenuField->CreateLabelLayoutItem(), 0, 0)
     240                .Add(fDisplayAsMenuField->CreateMenuBarLayoutItem(), 1, 0)
     241                .Add(fEditableCheckBox, 3, 0)
     242                .Add(fSpecialControl->CreateLabelLayoutItem(), 0, 1)
     243                .Add(fSpecialControl->CreateTextViewLayoutItem(), 1, 1, 3)
     244                .Add(fWidthControl->CreateLabelLayoutItem(), 0, 2)
     245                .Add(fWidthControl->CreateTextViewLayoutItem(), 1, 2, 3)
     246                .Add(fAlignmentMenuField->CreateLabelLayoutItem(), 0, 3)
     247                .Add(fAlignmentMenuField->CreateMenuBarLayoutItem(), 1, 3, 3)
     248                .SetInsets(padding, padding, padding, padding)
     249            ))
     250        .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     251            .Add(BSpaceLayoutItem::CreateGlue())
     252            .Add(BSpaceLayoutItem::CreateGlue())
     253            .Add(cancelButton)
     254            .Add(fAcceptButton)
     255        )
     256    );
     257    visibleBox->SetLabel(fVisibleCheckBox);
    285258
    286259    fAcceptButton->MakeDefault(true);
    287260    fPublicNameControl->MakeFocus(true);
  • FileTypesWindow.h

     
    2020
    2121class AttributeListView;
    2222class ExtensionListView;
     23class StringView;
    2324class TypeIconView;
    2425class MimeTypeListView;
    25 class StringView;
    2626
    2727
    2828class FileTypesWindow : public BWindow {
  • DropTargetListView.cpp

     
    77#include "DropTargetListView.h"
    88
    99
    10 DropTargetListView::DropTargetListView(BRect frame, const char* name,
    11         list_view_type type, uint32 resizeMask, uint32 flags)
    12     : BListView(frame, name, type, resizeMask, flags),
     10DropTargetListView::DropTargetListView(const char* name,
     11        list_view_type type, uint32 flags)
     12    : BListView(name, type, flags),
    1313    fDropTarget(false)
    1414{
    1515}
  • StringView.h

     
    66#define STRING_VIEW_H
    77
    88
    9 #include <String.h>
    10 #include <View.h>
     9class BLayoutItem;
     10class BGroupView;
     11class BStringView;
    1112
    12 
    13 class StringView : public BView {
     13class StringView {
    1414    public:
    15         StringView(BRect frame, const char* name, const char* label,
    16             const char* text, uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
    17             uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS);
    18         virtual ~StringView();
     15        StringView(const char* label,
     16            const char* text);
    1917
    20         virtual void Draw(BRect updateRect);
    21         virtual void AttachedToWindow();
    22 
    23         virtual void FrameResized(float width, float height);
    24 
    25         virtual void GetPreferredSize(float* _width, float* _height);
    26         virtual void ResizeToPreferred();
    27 
    2818        void SetEnabled(bool enabled);
    29         bool IsEnabled() const { return fEnabled; }
    3019
    3120        void SetLabel(const char* label);
    32         const char* Label() const { return fLabel.String(); }
    33 
     21        const char* Label() const;
    3422        void SetText(const char* text);
    35         const char* Text() const { return fText.String(); }
     23        const char* Text() const;
    3624
    37         void SetDivider(float divider);
    38         float Divider() const { return fDivider; }
     25        BLayoutItem* GetLabelLayoutItem();
     26        BView* LabelView();
     27        BLayoutItem* GetTextLayoutItem();
     28        BView* TextView();
    3929
    40         void SetAlignment(alignment labelAlignment, alignment textAlignment);
    41         void GetAlignment(alignment* _label, alignment* _text) const;
     30        operator BView*();
    4231
    4332    private:
    44         void _UpdateText();
    4533
    46         BString     fLabel;
    47         BString     fText;
    48         BString     fTruncatedText;
    49         float       fDivider;
    50         alignment   fLabelAlignment;
    51         alignment   fTextAlignment;
    52         bool        fEnabled;
     34        BGroupView*     fView;
     35        BStringView*    fLabel;
     36        BLayoutItem*    fLabelItem;
     37        BStringView*    fText;
     38        BLayoutItem*    fTextItem;
    5339};
    5440
     41
    5542#endif  // STRING_VIEW_H
  • ApplicationTypesWindow.cpp

     
    1616#include <Bitmap.h>
    1717#include <Box.h>
    1818#include <Button.h>
     19#include <ControlLook.h>
     20#include <GridLayoutBuilder.h>
     21#include <GroupLayoutBuilder.h>
    1922#include <MenuField.h>
    2023#include <MenuItem.h>
    2124#include <Mime.h>
     
    5457const uint32 kMsgEdit = 'edit';
    5558
    5659
    57 const char*
     60const char* 
    5861variety_to_text(uint32 variety)
    5962{
    6063#if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE)
     
    8891//  #pragma mark -
    8992
    9093
    91 ProgressWindow::ProgressWindow(const char* message, int32 max, volatile bool* signalQuit)
    92     : BWindow(BRect(0, 0, 300, 200), "Progress", B_MODAL_WINDOW_LOOK,
    93         B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
     94ProgressWindow::ProgressWindow(const char* message,
     95    int32 max, volatile bool* signalQuit)
     96    :
     97    BWindow(BRect(0, 0, 300, 200), "Progress", B_MODAL_WINDOW_LOOK,
     98        B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS |
     99            B_NOT_V_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
    94100    fQuitListener(signalQuit)
    95101{
    96     BView* topView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    97     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    98     AddChild(topView);
    99 
    100102    char count[100];
    101103    snprintf(count, sizeof(count), "/%ld", max);
    102104
    103     BRect rect = Bounds().InsetByCopy(8, 8);
    104     fStatusBar = new BStatusBar(rect, "status", message, count);
     105    fStatusBar = new BStatusBar("status", message, count);
    105106    fStatusBar->SetMaxValue(max);
    106     fStatusBar->SetResizingMode(B_FOLLOW_LEFT_RIGHT);
    107     float width, height;
    108     fStatusBar->GetPreferredSize(&width, &height);
    109     fStatusBar->ResizeTo(rect.Width(), height);
    110     topView->AddChild(fStatusBar);
     107    fAbortButton = new BButton("abort", "Abort", new BMessage(B_CANCEL));
     108   
     109    SetLayout(new BGroupLayout(B_VERTICAL));
     110    AddChild(BGroupLayoutBuilder(B_VERTICAL, 3.0f)
     111        .Add(fStatusBar)
     112        .Add(fAbortButton)
     113        .SetInsets(3.0f, 3.0f, 3.0f, 3.0f)
     114    );
    111115
    112     fAbortButton = new BButton(rect, "abort", "Abort", new BMessage(B_CANCEL),
    113         B_FOLLOW_H_CENTER | B_FOLLOW_TOP);
    114     fAbortButton->ResizeToPreferred();
    115     fAbortButton->MoveTo((Bounds().Width() - fAbortButton->Bounds().Width()) / 2,
    116         fStatusBar->Frame().bottom + 10.0f);
    117     topView->AddChild(fAbortButton);
    118 
    119     ResizeTo(width * 1.4f, fAbortButton->Frame().bottom + 8.0f);
    120     SetSizeLimits(width + 42.0f, 32767.0f,
    121         Bounds().Height(), Bounds().Height());
    122 
    123116    // center on screen
    124117    BScreen screen(this);
    125     MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2.0f,
    126         screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2.0f);
     118    MoveTo(screen.Frame().left + (screen.Frame().Width()
     119            - Bounds().Width()) / 2.0f,
     120        screen.Frame().top + (screen.Frame().Height()
     121            - Bounds().Height()) / 2.0f);
    127122}
    128123
    129124
     
    159154//  #pragma mark -
    160155
    161156
    162 ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings)
     157ApplicationTypesWindow::ApplicationTypesWindow(const BMessage& settings)
    163158    : BWindow(_Frame(settings), "Application types", B_TITLED_WINDOW,
    164         B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
     159        B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
    165160{
    166     // Application list
    167161
    168     BRect rect = Bounds();
    169     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    170     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    171     AddChild(topView);
     162    float padding = 3.0f;
     163    BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
     164    BAlignment fullWidthTopAlignment =
     165        BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP);
     166    if (be_control_look) {
     167        // padding = be_control_look->DefaultItemSpacing();
     168            // seems too big
     169        labelAlignment = be_control_look->DefaultLabelAlignment();
     170    }
    172171
    173     BButton* button = new BButton(rect, "remove", "Remove uninstalled",
    174         new BMessage(kMsgRemoveUninstalled), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
    175     button->ResizeToPreferred();
    176     button->MoveTo(8.0f, rect.bottom - 8.0f - button->Bounds().Height());
    177     topView->AddChild(button);
     172    // Application list
     173    BView* currentView = new BGroupView(B_VERTICAL, padding);
    178174
    179     rect.bottom = button->Frame().top - 10.0f;
    180     rect.top = 10.0f;
    181     rect.left = 10.0f;
    182     rect.right = 170;
    183 
    184     fTypeListView = new MimeTypeListView(rect, "listview", "application", true, true,
    185         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
     175    fTypeListView = new MimeTypeListView("listview", "application", true, true);
    186176    fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
    187177    fTypeListView->SetInvocationMessage(new BMessage(kMsgTypeInvoked));
    188178
    189179    BScrollView* scrollView = new BScrollView("scrollview", fTypeListView,
    190         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    191     topView->AddChild(scrollView);
     180        B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    192181
    193     // "Information" group
     182    BButton* button = new BButton("remove", "Remove uninstalled",
     183        new BMessage(kMsgRemoveUninstalled));
    194184
    195     BFont font(be_bold_font);
    196     font_height fontHeight;
    197     font.GetHeight(&fontHeight);
     185    SetLayout(BGroupLayoutBuilder(B_HORIZONTAL));
    198186
    199     rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH;
    200     rect.top -= 2.0f;
    201     rect.right = topView->Bounds().Width() - 8.0f;
    202     rect.bottom = rect.top + ceilf(fontHeight.ascent) + 24.0f;
    203     BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    204     box->SetLabel("Information");
    205     topView->AddChild(box);
     187    // "Information" group
    206188
    207     BRect innerRect = box->Bounds().InsetByCopy(8.0f, 6.0f);
    208     float labelWidth = topView->StringWidth("Description:") + 4.0f;
     189    BBox* infoBox = new BBox((char*)NULL);
     190    infoBox->SetLabel("Information");
     191    infoBox->SetExplicitAlignment(fullWidthTopAlignment);
     192   
     193    fNameView = new StringView("Name:", NULL);
     194    fNameView->TextView()->SetExplicitAlignment(labelAlignment);
     195    fNameView->LabelView()->SetExplicitAlignment(labelAlignment);
     196    fSignatureView = new StringView("Signature:", NULL);
     197    fSignatureView->TextView()->SetExplicitAlignment(labelAlignment);
     198    fSignatureView->LabelView()->SetExplicitAlignment(labelAlignment);
     199    fPathView = new StringView("Path:", NULL);
     200    fPathView->TextView()->SetExplicitAlignment(labelAlignment);
     201    fPathView->LabelView()->SetExplicitAlignment(labelAlignment);
    209202
    210     innerRect.right = box->Bounds().Width() - 8.0f;
    211     innerRect.top += ceilf(fontHeight.ascent);
    212     fNameView = new StringView(innerRect, "name", "Name:", NULL, B_FOLLOW_LEFT_RIGHT);
    213     fNameView->SetDivider(labelWidth);
    214     float width, height;
    215     fNameView->GetPreferredSize(&width, &height);
    216     fNameView->ResizeTo(innerRect.Width(), height);
    217     box->ResizeBy(0, fNameView->Bounds().Height() * 3.0f);
    218     box->AddChild(fNameView);
     203    infoBox->AddChild(
     204        BGridLayoutBuilder(padding, padding)
     205            .Add(fNameView->LabelView(), 0, 0)
     206            .Add(fNameView->TextView(), 1, 0, 2)
     207            .Add(fSignatureView->LabelView(), 0, 1)
     208            .Add(fSignatureView->TextView(), 1, 1, 2, 2)
     209            .Add(fPathView->LabelView(), 0, 2)
     210            .Add(fPathView->TextView(), 1, 2, 2)
     211            .SetInsets(padding, padding, padding, padding)
     212    );
    219213
    220     innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f);
    221     innerRect.bottom = innerRect.top + height;
    222     fSignatureView = new StringView(innerRect, "signature", "Signature:", NULL,
    223         B_FOLLOW_LEFT_RIGHT);
    224     fSignatureView->SetDivider(labelWidth);
    225     box->AddChild(fSignatureView);
    226 
    227     innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f);
    228     fPathView = new StringView(innerRect, "path", "Path:", NULL,
    229         B_FOLLOW_LEFT_RIGHT);
    230     fPathView->SetDivider(labelWidth);
    231     box->AddChild(fPathView);
    232 
    233214    // "Version" group
    234215
    235     rect.top = box->Frame().bottom + 8.0f;
    236     rect.bottom = rect.top + ceilf(fontHeight.ascent)
    237         + fNameView->Bounds().Height() * 4.0f + 20.0f;
    238     box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    239     box->SetLabel("Version");
    240     topView->AddChild(box);
     216    BBox* versionBox = new BBox("");
     217    versionBox->SetLabel("Version");
     218    versionBox->SetExplicitAlignment(fullWidthTopAlignment);
    241219
    242     innerRect = fNameView->Frame();
    243     fVersionView = new StringView(innerRect, "version", "Version:", NULL,
    244         B_FOLLOW_LEFT_RIGHT);
    245     fVersionView->SetDivider(labelWidth);
    246     box->AddChild(fVersionView);
    247 
    248     innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f);
    249     innerRect.right = innerRect.left + labelWidth;
    250     fDescriptionLabel = new StringView(innerRect, "description", "Description:", NULL);
    251     fDescriptionLabel->SetDivider(labelWidth);
    252     box->AddChild(fDescriptionLabel);
    253 
    254     innerRect.left = innerRect.right + 3.0f;
    255     innerRect.top += 1.0f;
    256     innerRect.right = box->Bounds().Width() - 8.0f;
    257     innerRect.bottom += fNameView->Bounds().Height() * 2.0f - 1.0f;
    258     fDescriptionView = new BTextView(innerRect, "description",
    259         innerRect.OffsetToCopy(B_ORIGIN), B_FOLLOW_LEFT_RIGHT,
    260         B_WILL_DRAW | B_FRAME_EVENTS);
     220    fVersionView = new StringView("Version:", NULL);
     221    fVersionView->TextView()->SetExplicitAlignment(labelAlignment);
     222    fVersionView->LabelView()->SetExplicitAlignment(labelAlignment);
     223    fDescriptionLabel = new StringView("Description:", NULL);
     224    fDescriptionLabel->LabelView()->SetExplicitAlignment(labelAlignment);
     225    fDescriptionView = new BTextView("description");
    261226    fDescriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    262227    fDescriptionView->SetLowColor(fDescriptionView->ViewColor());
    263228    fDescriptionView->MakeEditable(false);
    264     box->AddChild(fDescriptionView);
     229   
     230    versionBox->AddChild(currentView =
     231        BGridLayoutBuilder(padding, padding)
     232            .Add(fVersionView->LabelView(), 0, 0)
     233            .Add(fVersionView->TextView(), 1, 0)
     234            .Add(fDescriptionLabel->LabelView(), 0, 1)
     235            .Add(fDescriptionView, 1, 1, 2, 2)
     236            .SetInsets(padding, padding, padding, padding)
     237    );
     238    currentView->SetExplicitAlignment(fullWidthTopAlignment);
    265239
    266240    // Launch and Tracker buttons
    267241
    268     rect = box->Frame();
    269     rect.top = rect.bottom + 8.0f;
    270     rect.bottom = rect.top + 20.0f;
    271     fTrackerButton = new BButton(rect, "tracker", "Show in Tracker" B_UTF8_ELLIPSIS, NULL,
    272         B_FOLLOW_RIGHT);
    273     fTrackerButton->ResizeToPreferred();
    274     fTrackerButton->MoveTo(rect.right - fTrackerButton->Bounds().Width(), rect.top);
    275     topView->AddChild(fTrackerButton);
     242    fEditButton = new BButton("Edit" B_UTF8_ELLIPSIS, new BMessage(kMsgEdit));
     243    // launch and tracker buttons get messages in _SetType()
     244    fLaunchButton = new BButton("Launch");
     245    fTrackerButton = new BButton("Show in Tracker" B_UTF8_ELLIPSIS);
    276246
    277     fLaunchButton = new BButton(rect, "launch", "Launch", NULL,
    278         B_FOLLOW_RIGHT);
    279     fLaunchButton->ResizeToPreferred();
    280     fLaunchButton->MoveTo(fTrackerButton->Frame().left - 6.0f
    281         - fLaunchButton->Bounds().Width(), rect.top);
    282     topView->AddChild(fLaunchButton);
    283    
    284     fEditButton = new BButton(rect, "edit", "Edit" B_UTF8_ELLIPSIS, new BMessage(kMsgEdit),
    285         B_FOLLOW_RIGHT);
    286     fEditButton->ResizeToPreferred();
    287     fEditButton->MoveTo(fLaunchButton->Frame().left - 6.0f
    288         - fEditButton->Bounds().Width(), rect.top);
    289     topView->AddChild(fEditButton);
     247    AddChild(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     248        .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
     249            .Add(scrollView)
     250            .Add(button)
     251            .SetInsets(padding, padding, padding, padding)
     252        , 3)
     253        .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
     254            .Add(infoBox)
     255            .Add(versionBox)
     256            .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     257                .Add(fEditButton)
     258                .Add(fLaunchButton)
     259                .Add(fTrackerButton)
     260            )
     261            .AddGlue()
     262            .SetInsets(padding, padding, padding, padding)
     263        )
     264        .SetInsets(padding, padding, padding, padding)
     265    );
    290266
    291     SetSizeLimits(scrollView->Frame().right + 22.0f + fTrackerButton->Frame().Width()
    292         + fLaunchButton->Frame().Width() + 6 + fEditButton->Frame().Width(), 32767.0f,
    293         fTrackerButton->Frame().bottom + 8.0f, 32767.0f);
    294 
    295267    BMimeType::StartWatching(this);
    296268    _SetType(NULL);
    297269}
     
    322294    int32 removed = 0;
    323295    volatile bool quit = false;
    324296
    325     BWindow* progressWindow = new ProgressWindow("Removing uninstalled application types",
    326         fTypeListView->FullListCountItems(), &quit);
     297    BWindow* progressWindow =
     298        new ProgressWindow("Removing uninstalled application types",
     299            fTypeListView->FullListCountItems(), &quit);
    327300    progressWindow->AddToSubset(this);
    328301    progressWindow->Show();
    329302
    330303    for (int32 i = fTypeListView->FullListCountItems(); i-- > 0 && !quit;) {
    331         MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(fTypeListView->FullListItemAt(i));
     304        MimeTypeItem* item = dynamic_cast<MimeTypeItem*>
     305            (fTypeListView->FullListItemAt(i));
    332306        progressWindow->PostMessage(B_UPDATE_STATUS_BAR);
    333307
    334308        if (item == NULL)
     
    474448    fNameView->SetEnabled(enabled);
    475449    fSignatureView->SetEnabled(enabled);
    476450    fPathView->SetEnabled(enabled);
    477 
     451   
    478452    fVersionView->SetEnabled(enabled);
    479453    fDescriptionLabel->SetEnabled(enabled);
    480454
     
    485459
    486460
    487461void
    488 ApplicationTypesWindow::FrameResized(float width, float height)
    489 {
    490     // This works around a flaw of BTextView
    491     fDescriptionView->SetTextRect(fDescriptionView->Bounds());
    492 }
    493 
    494 
    495 void
    496462ApplicationTypesWindow::MessageReceived(BMessage* message)
    497463{
    498464    switch (message->what) {
  • IconView.cpp

     
    2121#include <PopUpMenu.h>
    2222#include <Resources.h>
    2323#include <Roster.h>
     24#include <Size.h>
    2425
    2526#include <new>
    2627#include <stdlib.h>
     
    523524//  #pragma mark -
    524525
    525526
    526 IconView::IconView(BRect rect, const char* name, uint32 resizeMode, uint32 flags)
    527     : BControl(rect, name, NULL, NULL, resizeMode, B_WILL_DRAW | flags),
     527IconView::IconView(const char* name, uint32 flags)
     528    : BControl(name, NULL, NULL, B_WILL_DRAW | flags),
    528529    fModificationMessage(NULL),
    529530    fIconSize(B_LARGE_ICON),
    530531    fIcon(NULL),
     
    781782}
    782783
    783784
     785BSize
     786IconView::MinSize()
     787{
     788    float width, height;
     789    GetPreferredSize(&width, &height);
     790    return BSize(width, height);
     791}
     792
     793
     794BSize
     795IconView::PreferredSize()
     796{
     797    return MinSize();
     798}
     799
     800
     801BSize
     802IconView::MaxSize()
     803{
     804    return MinSize();
     805}
     806
     807
    784808void
    785809IconView::MouseDown(BPoint where)
    786810{
     
    11081132}
    11091133
    11101134
    1111 void
     1135status_t
    11121136IconView::SetTarget(const BMessenger& target)
    11131137{
    11141138    fTarget = target;
     1139    return B_OK;
    11151140}
    11161141
    11171142
     
    11231148}
    11241149
    11251150
    1126 void
     1151status_t
    11271152IconView::Invoke(const BMessage* _message)
    11281153{
    11291154    if (_message == NULL)
     
    11321157        BMessage message(*_message);
    11331158        fTarget.SendMessage(&message);
    11341159    }
     1160    return B_OK;
    11351161}
    11361162
    11371163
  • MimeTypeListView.h

     
    5252
    5353class MimeTypeListView : public BOutlineListView {
    5454    public:
    55         MimeTypeListView(BRect rect, const char* name,
     55        MimeTypeListView(const char* name,
    5656            const char* supertype = NULL, bool showIcons = false,
    57             bool applicationMode = false,
    58             uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP);
     57            bool applicationMode = false);
    5958        virtual ~MimeTypeListView();
    6059
    6160        void SelectNewType(const char* type);
  • FileTypesWindow.cpp

     
    1616#include "PreferredAppMenu.h"
    1717#include "StringView.h"
    1818
     19#include <Alignment.h>
    1920#include <AppFileInfo.h>
    2021#include <Application.h>
    2122#include <Bitmap.h>
    2223#include <Box.h>
    2324#include <Button.h>
     25#include <ControlLook.h>
     26#include <GridLayoutBuilder.h>
     27#include <GroupLayoutBuilder.h>
    2428#include <ListView.h>
    2529#include <MenuBar.h>
    2630#include <MenuField.h>
     
    3034#include <OutlineListView.h>
    3135#include <PopUpMenu.h>
    3236#include <ScrollView.h>
     37#include <SpaceLayoutItem.h>
     38#include <SplitView.h>
    3339#include <TextControl.h>
    3440
    3541#include <OverrideAlert.h>
     
    3844#include <stdio.h>
    3945#include <stdlib.h>
    4046
    41 
    4247const uint32 kMsgTypeSelected = 'typs';
    4348const uint32 kMsgAddType = 'atyp';
    4449const uint32 kMsgRemoveType = 'rtyp';
     
    6974
    7075class TypeIconView : public IconView {
    7176    public:
    72         TypeIconView(BRect frame, const char* name,
    73             int32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP);
     77        TypeIconView(const char* name);
    7478        virtual ~TypeIconView();
    7579
    7680        virtual void Draw(BRect updateRect);
     
    8286
    8387class ExtensionListView : public DropTargetListView {
    8488    public:
    85         ExtensionListView(BRect frame, const char* name,
     89        ExtensionListView(const char* name,
    8690            list_view_type type = B_SINGLE_SELECTION_LIST,
    87             uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
    8891            uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
    8992        virtual ~ExtensionListView();
    9093
     
    101104//  #pragma mark -
    102105
    103106
    104 TypeIconView::TypeIconView(BRect frame, const char* name, int32 resizingMode)
    105     : IconView(frame, name, resizingMode)
     107TypeIconView::TypeIconView(const char* name)
     108    : IconView(name)
    106109{
    107110    ShowEmptyFrame(false);
    108111}
     
    202205//  #pragma mark -
    203206
    204207
    205 ExtensionListView::ExtensionListView(BRect frame, const char* name,
    206         list_view_type type, uint32 resizeMask, uint32 flags)
    207     : DropTargetListView(frame, name, type, resizeMask, flags)
     208ExtensionListView::ExtensionListView(const char* name,
     209        list_view_type type, uint32 flags)
     210    : DropTargetListView(name, type, flags)
    208211{
    209212}
    210213
     
    271274
    272275
    273276FileTypesWindow::FileTypesWindow(const BMessage& settings)
    274     : BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW,
    275         B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
     277    :
     278    BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW,
     279        B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
    276280    fNewTypeWindow(NULL)
    277281{
    278282    bool showIcons;
     
    282286    if (settings.FindBool("show_rule", &showRule) != B_OK)
    283287        showRule = false;
    284288
     289    SetLayout(new BGroupLayout(B_VERTICAL));
     290    float padding = 3.0f;
     291    BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
     292    if (be_control_look) {
     293        // padding = be_control_look->DefaultItemSpacing();
     294            // this seems to be very large!
     295        labelAlignment = be_control_look->DefaultLabelAlignment();
     296    }
     297    BAlignment fullAlignment =
     298        BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
     299
    285300    // add the menu
     301    BMenuBar* menuBar = new BMenuBar("");
    286302
    287     BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
    288     AddChild(menuBar);
    289 
    290303    BMenu* menu = new BMenu("File");
    291304    BMenuItem* item;
    292305    menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS,
     
    298311    item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel));
    299312    item->SetShortcut('O', B_COMMAND_KEY);
    300313    menu->AddItem(item);
     314
    301315    menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS,
    302316        new BMessage(kMsgOpenApplicationTypesWindow)));
    303317    menu->AddSeparatorItem();
     
    323337    menu->AddItem(item);
    324338    menuBar->AddItem(menu);
    325339
     340    AddChild(menuBar);
     341    menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
     342
    326343    // MIME Types list
     344    BButton* addTypeButton = new BButton( "add", "Add" B_UTF8_ELLIPSIS,
     345        new BMessage(kMsgAddType));
    327346
    328     BRect rect = Bounds();
    329     rect.top = menuBar->Bounds().Height() + 1.0f;
    330     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    331     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    332     AddChild(topView);
     347    fRemoveTypeButton = new BButton( "remove", "Remove",
     348        new BMessage(kMsgRemoveType) );
    333349
    334     BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS,
    335         new BMessage(kMsgAddType), B_FOLLOW_BOTTOM);
    336     button->ResizeToPreferred();
    337     button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height());
    338     topView->AddChild(button);
    339 
    340     rect = button->Frame();
    341     rect.OffsetBy(rect.Width() + 8.0f, 0.0f);
    342     fRemoveTypeButton = new BButton(rect, "remove", "Remove",
    343         new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM);
    344     fRemoveTypeButton->ResizeToPreferred();
    345     topView->AddChild(fRemoveTypeButton);
    346 
    347     rect.bottom = rect.top - 10.0f;
    348     rect.top = 10.0f;
    349     rect.left = 10.0f;
    350     rect.right -= B_V_SCROLL_BAR_WIDTH + 2.0f;
    351     if (rect.right < 180)
    352         rect.right = 180;
    353 
    354     fTypeListView = new MimeTypeListView(rect, "typeview", NULL, showIcons, false,
    355         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
     350    fTypeListView = new MimeTypeListView( "typeview", NULL, showIcons, false);
    356351    fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
    357352
    358     BScrollView* scrollView = new BScrollView("scrollview", fTypeListView,
    359         B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    360     topView->AddChild(scrollView);
     353    BScrollView* typeListScrollView = new BScrollView("scrollview", fTypeListView,
     354        B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    361355
    362356    // "Icon" group
    363357
    364     font_height plainHeight;
    365     be_plain_font->GetHeight(&plainHeight);
    366     float height = ceilf(plainHeight.ascent + plainHeight.descent
    367         + plainHeight.leading) + 2.0f;
    368 
    369     BFont font(be_bold_font);
    370     float labelWidth = font.StringWidth("Icon");
    371     font_height boldHeight;
    372     font.GetHeight(&boldHeight);
    373 
    374     BRect innerRect;
    375     fIconView = new TypeIconView(innerRect, "icon",
    376         B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
    377     fIconView->ResizeToPreferred();
    378 
    379     rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH;
    380     rect.right = rect.left + max_c(fIconView->Bounds().Width(), labelWidth) + 16.0f;
    381     rect.bottom = rect.top + ceilf(boldHeight.ascent)
    382         + max_c(fIconView->Bounds().Height(),
    383             button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f;
    384     rect.top -= 2.0f;
    385     fIconBox = new BBox(rect);
     358    fIconView = new TypeIconView( "icon");
     359    fIconBox = new BBox("Icon BBox");
    386360    fIconBox->SetLabel("Icon");
    387     topView->AddChild(fIconBox);
     361    fIconBox->AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
     362        .Add(BSpaceLayoutItem::CreateGlue(), 1)
     363        .Add(fIconView, 3)
     364        .Add(BSpaceLayoutItem::CreateGlue(), 1)
     365        .SetInsets(padding, padding, padding, padding)
     366    );
    388367
    389     innerRect.left = 8.0f;
    390     innerRect.top = plainHeight.ascent + 3.0f
    391         + (rect.Height() - boldHeight.ascent - fIconView->Bounds().Height()) / 2.0f;
    392     if (innerRect.top + fIconView->Bounds().Height() > fIconBox->Bounds().Height() - 6.0f)
    393         innerRect.top = fIconBox->Bounds().Height() - 6.0f - fIconView->Bounds().Height();
    394     fIconView->MoveTo(innerRect.LeftTop());
    395     fIconBox->AddChild(fIconView);
    396 
    397368    // "File Recognition" group
    398369
    399     BRect rightRect(rect);
    400     rightRect.left = rect.right + 8.0f;
    401     rightRect.right = topView->Bounds().Width() - 8.0f;
    402     fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT);
     370    fRecognitionBox = new BBox("Recognition Box");
    403371    fRecognitionBox->SetLabel("File recognition");
    404     topView->AddChild(fRecognitionBox);
     372    fRecognitionBox->SetExplicitAlignment(fullAlignment);
    405373
    406     innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f);
    407     innerRect.top += ceilf(boldHeight.ascent);
    408     fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL);
    409     fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT);
    410     fExtensionLabel->ResizeToPreferred();
    411     fRecognitionBox->AddChild(fExtensionLabel);
     374    fExtensionLabel = new StringView("Extensions:", NULL);
     375    fExtensionLabel->LabelView()->SetExplicitAlignment(labelAlignment);
    412376
    413     innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f;
    414     innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
    415     innerRect.bottom = innerRect.top + button->Bounds().Height();
    416     fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS,
    417         new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT);
    418     fRecognitionBox->AddChild(fAddExtensionButton);
     377    fAddExtensionButton = new BButton("add ext", "Add" B_UTF8_ELLIPSIS,
     378        new BMessage(kMsgAddExtension));
    419379
    420     innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
    421     fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove",
    422         new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT);
    423     fRecognitionBox->AddChild(fRemoveExtensionButton);
     380    fRemoveExtensionButton = new BButton("remove ext", "Remove",
     381        new BMessage(kMsgRemoveExtension));
    424382
    425     innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
    426     innerRect.left = 10.0f;
    427     innerRect.top = fAddExtensionButton->Frame().top + 2.0f;
    428     innerRect.bottom = innerRect.bottom - 2.0f;
    429         // take scrollview border into account
    430     fExtensionListView = new ExtensionListView(innerRect, "listview ext",
    431         B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT);
     383    fExtensionListView = new ExtensionListView("listview ext",
     384        B_SINGLE_SELECTION_LIST);
    432385    fExtensionListView->SetSelectionMessage(new BMessage(kMsgExtensionSelected));
    433386    fExtensionListView->SetInvocationMessage(new BMessage(kMsgExtensionInvoked));
    434387
    435     scrollView = new BScrollView("scrollview ext", fExtensionListView,
    436         B_FOLLOW_LEFT_RIGHT, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    437     fRecognitionBox->AddChild(scrollView);
     388    BScrollView* scrollView = new BScrollView("scrollview ext",
     389        fExtensionListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    438390
    439     innerRect.left = 8.0f;
    440     innerRect.top = innerRect.bottom + 10.0f;
    441     innerRect.right = fRecognitionBox->Bounds().right - 8.0f;
    442     innerRect.bottom = innerRect.top + 20.0f;
    443     fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "",
    444         new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT);
    445     //fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    446     fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f);
     391    fRuleControl = new BTextControl("rule", "Rule:", "",
     392        new BMessage(kMsgRuleEntered));
     393    fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    447394    fRuleControl->Hide();
    448     fRecognitionBox->AddChild(fRuleControl);
    449395
     396    BView* recognitionBoxGrid =
     397        BGridLayoutBuilder(padding, padding)
     398            .Add(fExtensionLabel->LabelView(), 0, 0)
     399            .Add(scrollView, 0, 1, 2, 3)
     400            .Add(fAddExtensionButton, 2, 1)
     401            .Add(fRemoveExtensionButton, 2, 2)
     402            .Add(fRuleControl, 0, 4, 3, 1)
     403            .SetInsets(padding, padding, padding, padding);
     404
     405    recognitionBoxGrid->SetExplicitAlignment(fullAlignment);
     406    fRecognitionBox->AddChild(recognitionBoxGrid);
     407
    450408    // "Description" group
    451409
    452     rect.top = rect.bottom + 8.0f;
    453     rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f;
    454     rect.right = rightRect.right;
    455     fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
     410    fDescriptionBox = new BBox("description BBox");
    456411    fDescriptionBox->SetLabel("Description");
    457     topView->AddChild(fDescriptionBox);
     412    fDescriptionBox->SetExplicitAlignment(fullAlignment);
    458413
    459     innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f);
    460     innerRect.top += ceilf(boldHeight.ascent);
    461     innerRect.bottom = innerRect.top + button->Bounds().Height();
    462     fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "",
    463         B_FOLLOW_LEFT_RIGHT);
    464     labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f;
    465     fInternalNameView->SetDivider(labelWidth);
     414    fInternalNameView = new StringView("Internal name:", NULL);
    466415    fInternalNameView->SetEnabled(false);
    467     fInternalNameView->ResizeToPreferred();
    468     fDescriptionBox->AddChild(fInternalNameView);
     416    fTypeNameControl = new BTextControl("type", "Type name:", "",
     417        new BMessage(kMsgTypeEntered));
     418    fDescriptionControl = new BTextControl("description", "Description:",
     419        "", new BMessage(kMsgDescriptionEntered));
    469420
    470     innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f);
    471     fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "",
    472         new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT);
    473     fTypeNameControl->SetDivider(labelWidth);
    474     fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    475     fDescriptionBox->ResizeBy(0, fInternalNameView->Bounds().Height()
    476         + fTypeNameControl->Bounds().Height() * 2.0f);
    477     fDescriptionBox->AddChild(fTypeNameControl);
     421    fDescriptionBox->AddChild(BGridLayoutBuilder(padding, padding)
     422        .Add(fInternalNameView->LabelView(), 0, 0)
     423        .Add(fInternalNameView->TextView(), 1, 0)
     424        .Add(fTypeNameControl->CreateLabelLayoutItem(), 0, 1)
     425        .Add(fTypeNameControl->CreateTextViewLayoutItem(), 1, 1, 2)
     426        .Add(fDescriptionControl->CreateLabelLayoutItem(), 0, 2)
     427        .Add(fDescriptionControl->CreateTextViewLayoutItem(), 1, 2, 2)
     428        .SetInsets(padding, padding, padding, padding)
     429    );
    478430
    479     innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f);
    480     fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "",
    481         new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT);
    482     fDescriptionControl->SetDivider(labelWidth);
    483     fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    484     fDescriptionBox->AddChild(fDescriptionControl);
    485431
    486432    // "Preferred Application" group
    487433
    488     rect = fDescriptionBox->Frame();
    489     rect.top = rect.bottom + 8.0f;
    490     rect.bottom = rect.top + ceilf(boldHeight.ascent)
    491         + button->Bounds().Height() + 14.0f;
    492     fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
     434    fPreferredBox = new BBox("preferred BBox");
    493435    fPreferredBox->SetLabel("Preferred application");
    494     topView->AddChild(fPreferredBox);
    495436
    496     innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f);
    497     innerRect.top += ceilf(boldHeight.ascent);
    498     innerRect.left = innerRect.right - button->StringWidth(
    499         "Same as" B_UTF8_ELLIPSIS) - 24.0f;
    500     innerRect.bottom = innerRect.top + button->Bounds().Height();
    501     fSameAsButton = new BButton(innerRect, "same as",
    502         "Same as" B_UTF8_ELLIPSIS,
    503         new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT);
    504     fPreferredBox->AddChild(fSameAsButton);
    505 
    506     innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f);
    507     fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS,
    508         new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT);
    509     fPreferredBox->AddChild(fSelectButton);
    510 
    511437    menu = new BPopUpMenu("preferred");
    512438    menu->AddItem(item = new BMenuItem("None",
    513439        new BMessage(kMsgPreferredAppChosen)));
    514440    item->SetMarked(true);
     441    fPreferredField = new BMenuField("preferred", (char*)NULL, menu);
    515442
    516     innerRect.right = innerRect.left - 6.0f;
    517     innerRect.left = 8.0f;
     443    fSelectButton = new BButton("select", "Select" B_UTF8_ELLIPSIS,
     444        new BMessage(kMsgSelectPreferredApp));
    518445
    519     fPreferredField = new BMenuField(innerRect, "preferred", NULL, menu, true,
    520         B_FOLLOW_LEFT_RIGHT);
    521     float width;
    522     fPreferredField->GetPreferredSize(&width, &height);
    523     fPreferredField->ResizeTo(innerRect.Width(), height);
    524     fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f);
     446    fSameAsButton = new BButton("same as", "Same as" B_UTF8_ELLIPSIS,
     447        new BMessage(kMsgSamePreferredAppAs));
    525448
    526     fPreferredBox->AddChild(fPreferredField);
     449    fPreferredBox->AddChild(
     450        BGroupLayoutBuilder(B_HORIZONTAL, padding)
     451            .Add(fPreferredField)
     452            .Add(fSelectButton)
     453            .Add(fSameAsButton)
     454            .SetInsets(padding, padding, padding, padding)
     455    );
    527456
    528457    // "Extra Attributes" group
    529 
    530     rect.top = rect.bottom + 8.0f;
    531     rect.bottom = topView->Bounds().Height() - 8.0f;
    532     fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT
    533         | B_FOLLOW_TOP_BOTTOM);
     458    fAttributeBox = new BBox("fAttributeBox");
    534459    fAttributeBox->SetLabel("Extra attributes");
    535     topView->AddChild(fAttributeBox);
    536460
    537     innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f);
    538     innerRect.top += ceilf(boldHeight.ascent);
    539     innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
    540     innerRect.bottom = innerRect.top + button->Bounds().Height();
    541     fAddAttributeButton = new BButton(innerRect, "add attr",
    542         "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT);
    543     fAttributeBox->AddChild(fAddAttributeButton);
     461    fAddAttributeButton = new BButton("add attr",
     462        "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute));
    544463
    545     innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
    546     fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove",
    547         new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
    548     fAttributeBox->AddChild(fRemoveAttributeButton);
    549 /*
    550     innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
    551     button = new BButton(innerRect, "push attr", "Push Up",
    552         new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
    553     fAttributeBox->AddChild(button);
    554 */
    555     innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
    556     innerRect.left = 10.0f;
    557     innerRect.top = 8.0f + ceilf(boldHeight.ascent);
    558     innerRect.bottom = fAttributeBox->Bounds().bottom - 10.0f;
    559         // take scrollview border into account
    560     fAttributeListView = new AttributeListView(innerRect, "listview attr",
    561         B_FOLLOW_ALL);
     464    fRemoveAttributeButton = new BButton("remove attr", "Remove",
     465        new BMessage(kMsgRemoveAttribute));
     466
     467    fAttributeListView = new AttributeListView("listview attr");
    562468    fAttributeListView->SetSelectionMessage(new BMessage(kMsgAttributeSelected));
    563469    fAttributeListView->SetInvocationMessage(new BMessage(kMsgAttributeInvoked));
    564470
    565     scrollView = new BScrollView("scrollview attr", fAttributeListView,
    566         B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    567     fAttributeBox->AddChild(scrollView);
     471    BScrollView* attributesScroller = new BScrollView("scrollview attr",
     472        fAttributeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    568473
    569     SetSizeLimits(rightRect.left + 72.0f + font.StringWidth("jpg")
    570         + font.StringWidth(fRecognitionBox->Label()), 32767.0f,
    571         rect.top + 2.0f * button->Bounds().Height() + boldHeight.ascent
    572         + 32.0f + menuBar->Bounds().Height(), 32767.0f);
     474    fAttributeBox->AddChild(BGridLayoutBuilder(padding, padding)
     475        .Add(attributesScroller, 0, 0, 2, 3)
     476        .Add(fAddAttributeButton, 2, 0)
     477        .Add(fRemoveAttributeButton, 2, 1)
     478        .SetInsets(padding, padding, padding, padding)
     479    );
    573480
     481
     482    BView* topView =
     483        BGroupLayoutBuilder(B_HORIZONTAL, padding)
     484        .SetInsets(padding, padding, padding, padding)
     485        .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
     486            .Add(typeListScrollView)
     487            .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     488                .Add(addTypeButton).Add(fRemoveTypeButton)
     489            )
     490        )
     491        // Right side
     492        .Add(BGroupLayoutBuilder(B_VERTICAL, padding)
     493            .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     494                .Add(fIconBox, 1).Add(fRecognitionBox, 3)
     495            )
     496            .Add(fDescriptionBox)
     497            .Add(fPreferredBox)
     498            .Add(fAttributeBox, 5)
     499        );
     500
     501    //topView->SetExplicitAlignment(fullAlignment);
     502    //topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
     503    AddChild(topView);
     504
    574505    _SetType(NULL);
    575506    _ShowSnifferRule(showRule);
    576507
     
    591522    if (settings.FindRect("file_types_frame", &rect) == B_OK)
    592523        return rect;
    593524
    594     return BRect(80.0f, 80.0f, 600.0f, 480.0f);
     525    return BRect(80.0f, 80.0f, 0.0f, 0.0f);
    595526}
    596527
    597528
     
    601532    if (fRuleControl->IsHidden() == !show)
    602533        return;
    603534
    604     float minWidth, maxWidth, minHeight, maxHeight;
    605     GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
    606 
    607     float diff = fRuleControl->Bounds().Height() + 8.0f;
    608 
    609     if (!show) {
     535    if (!show)
    610536        fRuleControl->Hide();
    611         diff = -diff;
    612     }
    613 
    614     // adjust other controls to make space or take it again
    615 
    616     fIconBox->ResizeBy(0.0f, diff);
    617     fRecognitionBox->ResizeBy(0.0f, diff);
    618     fDescriptionBox->MoveBy(0.0f, diff);
    619     fPreferredBox->MoveBy(0.0f, diff);
    620     fAttributeBox->MoveBy(0.0f, diff);
    621     fAttributeBox->ResizeBy(0.0f, -diff);
    622 
    623     if (show)
     537    else
    624538        fRuleControl->Show();
    625 
    626     SetSizeLimits(minWidth, maxWidth, minHeight + diff, maxHeight);
    627539}
    628540
    629541
  • ApplicationTypeWindow.cpp

     
    1717#include <Box.h>
    1818#include <Button.h>
    1919#include <CheckBox.h>
     20#include <ControlLook.h>
    2021#include <File.h>
     22#include <GridLayoutBuilder.h>
     23#include <GroupLayoutBuilder.h>
     24#include <GroupView.h>
    2125#include <ListView.h>
    2226#include <MenuBar.h>
    2327#include <MenuField.h>
     
    2832#include <RadioButton.h>
    2933#include <Roster.h>
    3034#include <ScrollView.h>
     35#include <StringView.h>
    3136#include <TextControl.h>
    3237
    3338#include <ctype.h>
     
    5459// TextView that filters the tab key to be able to tab-navigate while editing   
    5560class TabFilteringTextView : public BTextView {
    5661    public:
    57         TabFilteringTextView(BRect frame, const char* name, BRect textRect,
    58             uint32 resizeMask, uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED);
     62        TabFilteringTextView(const char* name);
    5963        virtual ~TabFilteringTextView();
    6064        virtual void KeyDown(const char* bytes, int32 count);
    6165};
    6266
    6367
    64 TabFilteringTextView::TabFilteringTextView(BRect frame, const char* name,
    65     BRect textRect, uint32 resizeMask, uint32 flags)
    66     :   BTextView(frame, name, textRect, resizeMask, flags)
     68TabFilteringTextView::TabFilteringTextView(const char* name)
     69    :   BTextView(name, B_WILL_DRAW | B_PULSE_NEEDED)
    6770{
    6871}
    6972
     
    102105
    103106class SupportedTypeListView : public DropTargetListView {
    104107    public:
    105         SupportedTypeListView(BRect frame, const char* name,
     108        SupportedTypeListView(const char* name,
    106109            list_view_type type = B_SINGLE_SELECTION_LIST,
    107             uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
    108110            uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
    109111        virtual ~SupportedTypeListView();
    110112
     
    153155{
    154156    const SupportedTypeItem* a = *(const SupportedTypeItem**)_a;
    155157    const SupportedTypeItem* b = *(const SupportedTypeItem**)_b;
    156 
     158   
    157159    int compare = strcasecmp(a->Text(), b->Text());
    158160    if (compare != 0)
    159161        return compare;
    160 
     162   
    161163    return strcasecmp(a->Type(), b->Type());
    162164}
    163165
     
    165167//  #pragma mark -
    166168
    167169
    168 SupportedTypeListView::SupportedTypeListView(BRect frame, const char* name,
    169         list_view_type type, uint32 resizeMask, uint32 flags)
    170     : DropTargetListView(frame, name, type, resizeMask, flags)
     170SupportedTypeListView::SupportedTypeListView(const char* name,
     171    list_view_type type, uint32 flags)
     172    :
     173    DropTargetListView(name, type, flags)
    171174{
    172175}
    173176
     
    188191            BNodeInfo info(&node);
    189192            if (node.InitCheck() != B_OK || info.InitCheck() != B_OK)
    190193                continue;
    191 
     194   
    192195            // TODO: we could identify the file in case it doesn't have a type...
    193196            char type[B_MIME_TYPE_LENGTH];
    194197            if (info.GetType(type) != B_OK)
    195198                continue;
    196 
     199   
    197200            // check if that type is already in our list
    198201            bool found = false;
    199202            for (int32 i = CountItems(); i-- > 0;) {
     
    203206                    break;
    204207                }
    205208            }
    206 
     209   
    207210            if (!found) {
    208211                // add type
    209212                AddItem(new SupportedTypeItem(type));
    210213            }
    211214        }
    212 
     215   
    213216        SortItems(&SupportedTypeItem::Compare);
    214217    } else
    215218        DropTargetListView::MessageReceived(message);
     
    227230//  #pragma mark -
    228231
    229232
    230 ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
    231     : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
     233ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
     234    const BEntry& entry)
     235    :
     236    BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
    232237        "Application Type", B_TITLED_WINDOW,
    233         B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
     238        B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
     239            B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
    234240    fChangedProperties(0)
    235241{
    236     // add the menu
    237 
    238     BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
    239     AddChild(menuBar);
    240 
     242    float padding = 3.0f;
     243    BAlignment labelAlignment = BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP);
     244    if (be_control_look){
     245        // padding = be_control_look->DefaultItemSpacing();
     246            // seems too big
     247        labelAlignment = be_control_look->DefaultLabelAlignment();
     248    }
     249   
     250    BMenuBar* menuBar = new BMenuBar((char*)NULL);
     251    menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
     252   
    241253    BMenu* menu = new BMenu("File");
    242254    fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
    243255    fSaveMenuItem->SetEnabled(false);
     
    246258    menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
    247259        NULL));
    248260    item->SetEnabled(false);
    249 
     261   
    250262    menu->AddSeparatorItem();
    251263    menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
    252264        'W', B_COMMAND_KEY));
    253265    menuBar->AddItem(menu);
     266   
    254267
    255     // Top view and signature
    256 
    257     BRect rect = Bounds();
    258     rect.top = menuBar->Bounds().Height() + 1.0f;
    259     BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
    260     topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    261     AddChild(topView);
    262 
    263     rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
    264     fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
    265         new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
    266     fSignatureControl->SetModificationMessage(
     268    // Signature
     269   
     270    fSignatureControl = new BTextControl("Signature:", NULL,
    267271        new BMessage(kMsgSignatureChanged));
    268     fSignatureControl->SetDivider(fSignatureControl->StringWidth(
    269         fSignatureControl->Label()) + 4.0f);
    270     float width, height;
    271     fSignatureControl->GetPreferredSize(&width, &height);
    272     fSignatureControl->ResizeTo(rect.Width(), height);
    273     topView->AddChild(fSignatureControl);
    274 
     272    fSignatureControl->SetModificationMessage(
     273        new BMessage(kMsgSignatureChanged));
     274   
    275275    // filter out invalid characters that can't be part of a MIME type name
    276276    BTextView* textView = fSignatureControl->TextView();
    277277    textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
     
    279279    for (int32 i = 0; disallowedCharacters[i]; i++) {
    280280        textView->DisallowChar(disallowedCharacters[i]);
    281281    }
    282 
     282   
    283283    // "Application Flags" group
     284   
     285    BBox* flagsBox = new BBox("flagsBox");
    284286
    285     BFont font(be_bold_font);
    286     font_height fontHeight;
    287     font.GetHeight(&fontHeight);
    288 
    289     width = font.StringWidth("Icon") + 16.0f;
    290     if (width < B_LARGE_ICON + 16.0f)
    291         width = B_LARGE_ICON + 16.0f;
    292 
    293     rect.top = fSignatureControl->Frame().bottom + 4.0f;
    294     rect.bottom = rect.top + 100.0f;
    295     rect.right -= width + 8.0f;
    296     BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    297     topView->AddChild(box);
    298 
    299     fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
     287    fFlagsCheckBox = new BCheckBox("flags", "Application flags",
    300288        new BMessage(kMsgToggleAppFlags));
    301289    fFlagsCheckBox->SetValue(B_CONTROL_ON);
    302     fFlagsCheckBox->ResizeToPreferred();
    303     box->SetLabel(fFlagsCheckBox);
    304 
    305     rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
    306     fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
     290   
     291    fSingleLaunchButton = new BRadioButton("single", "Single launch",
    307292        new BMessage(kMsgAppFlagsChanged));
    308     fSingleLaunchButton->ResizeToPreferred();
    309     box->AddChild(fSingleLaunchButton);
    310 
    311     rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
    312     fMultipleLaunchButton = new BRadioButton(rect, "multiple",
     293   
     294    fMultipleLaunchButton = new BRadioButton("multiple",
    313295        "Multiple launch", new BMessage(kMsgAppFlagsChanged));
    314     fMultipleLaunchButton->ResizeToPreferred();
    315     box->AddChild(fMultipleLaunchButton);
    316 
    317     rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
    318     fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
     296   
     297    fExclusiveLaunchButton = new BRadioButton("exclusive",
    319298        "Exclusive launch", new BMessage(kMsgAppFlagsChanged));
    320     fExclusiveLaunchButton->ResizeToPreferred();
    321     box->AddChild(fExclusiveLaunchButton);
    322 
    323     rect.top = fSingleLaunchButton->Frame().top;
    324     rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
    325     fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
     299   
     300    fArgsOnlyCheckBox = new BCheckBox("args only", "Args only",
    326301        new BMessage(kMsgAppFlagsChanged));
    327     fArgsOnlyCheckBox->ResizeToPreferred();
    328     box->AddChild(fArgsOnlyCheckBox);
    329 
    330     rect.top += fArgsOnlyCheckBox->Bounds().Height();
    331     fBackgroundAppCheckBox = new BCheckBox(rect, "background",
     302   
     303    fBackgroundAppCheckBox = new BCheckBox("background",
    332304        "Background app", new BMessage(kMsgAppFlagsChanged));
    333     fBackgroundAppCheckBox->ResizeToPreferred();
    334     box->AddChild(fBackgroundAppCheckBox);
    335 
    336     box->ResizeTo(box->Bounds().Width(),
    337         fExclusiveLaunchButton->Frame().bottom + 8.0f);
    338 
     305   
     306    flagsBox->AddChild(BGridLayoutBuilder(padding, padding)
     307        .Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
     308        .Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
     309        .Add(fExclusiveLaunchButton, 0, 2)
     310        .SetInsets(padding, padding, padding, padding));
     311    flagsBox->SetLabel(fFlagsCheckBox);
     312   
    339313    // "Icon" group
    340 
    341     rect = box->Frame();
    342 #ifdef __HAIKU__
    343     rect.top += box->TopBorderOffset();
    344 #endif
    345     rect.left = rect.right + 8.0f;
    346     rect.right += width + 8.0f;
    347     float iconBoxWidth = rect.Width();
    348     box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    349     box->SetLabel("Icon");
    350 #ifdef __HAIKU__
    351     box->MoveBy(0.0f, -box->TopBorderOffset());
    352     box->ResizeBy(0.0f, box->TopBorderOffset());
    353 #endif
    354     topView->AddChild(box);
    355 
    356     rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f);
    357 #ifdef __HAIKU__
    358     rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset()
    359         - rect.Height()) / 2.0f);
    360 #else
    361     rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f);
    362 #endif
    363     if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f)
    364         rect.top = fontHeight.ascent + fontHeight.descent + 4.0f;
    365     fIconView = new IconView(rect, "icon");
     314   
     315    BBox* iconBox = new BBox("IconBox");
     316    iconBox->SetLabel("Icon");
     317    fIconView = new IconView("icon");
    366318    fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
    367     box->AddChild(fIconView);
    368 
     319    iconBox->AddChild(
     320        BGroupLayoutBuilder(B_HORIZONTAL)
     321        .Add(fIconView)
     322        .SetInsets(padding, padding, padding, padding)
     323    );
     324   
    369325    // "Supported Types" group
    370 
    371     rect.top = box->Frame().bottom + 8.0f;
    372     rect.bottom = rect.top + box->Bounds().Height();
    373     rect.left = 8.0f;
    374     rect.right = Bounds().Width() - 8.0f;
    375     BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
     326   
     327    BBox* typeBox = new BBox("typesBox");
    376328    typeBox->SetLabel("Supported types");
    377     topView->AddChild(typeBox);
    378 
    379     rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f);
    380     rect.top += ceilf(fontHeight.ascent);
    381     fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS,
    382         new BMessage(kMsgAddType), B_FOLLOW_RIGHT);
    383     fAddTypeButton->ResizeToPreferred();
    384     fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width()
    385         - B_LARGE_ICON - 16.0f, 0.0f);
    386     typeBox->AddChild(fAddTypeButton);
    387 
    388     rect = fAddTypeButton->Frame();
    389     rect.OffsetBy(0, rect.Height() + 4.0f);
    390     fRemoveTypeButton = new BButton(rect, "remove type", "Remove",
    391         new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT);
    392     typeBox->AddChild(fRemoveTypeButton);
    393 
    394     rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
    395     rect.left = 10.0f;
    396     rect.top = 8.0f + ceilf(fontHeight.ascent);
    397     rect.bottom -= 2.0f;
    398         // take scrollview border into account
    399     fTypeListView = new SupportedTypeListView(rect, "type listview",
    400         B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL);
     329   
     330    fTypeListView = new SupportedTypeListView("Suppported Types",
     331        B_SINGLE_SELECTION_LIST);
    401332    fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
    402 
     333   
    403334    BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
    404         B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    405 
    406     typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f);
    407     typeBox->AddChild(scrollView);
    408 
    409     rect.left = fRemoveTypeButton->Frame().right + 8.0f;
    410 #ifdef __HAIKU__
    411     rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f;
    412 #else
    413     rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f;
    414 #endif
    415     rect.right = rect.left + B_LARGE_ICON - 1.0f;
    416     rect.bottom = rect.top + B_LARGE_ICON - 1.0f;
    417     fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP);
     335        B_FRAME_EVENTS | B_WILL_DRAW, false, true);
     336   
     337    fAddTypeButton = new BButton("add type", "Add" B_UTF8_ELLIPSIS,
     338        new BMessage(kMsgAddType));
     339   
     340    fRemoveTypeButton = new BButton("remove type", "Remove",
     341        new BMessage(kMsgRemoveType));
     342   
     343    fTypeIconView = new IconView("type icon");
     344    BView* iconHolder = BGroupLayoutBuilder(B_HORIZONTAL).Add(fTypeIconView);
    418345    fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged));
    419     typeBox->AddChild(fTypeIconView);
    420 
     346   
     347    typeBox->AddChild(BGridLayoutBuilder(padding, padding)
     348        .Add(scrollView, 0, 0, 1, 4)
     349        .Add(fAddTypeButton, 1, 0, 1, 2)
     350        .Add(fRemoveTypeButton, 1, 2, 1, 2)
     351        .Add(iconHolder, 2, 1, 1, 2)
     352        .SetInsets(padding, padding, padding, padding)
     353        .SetColumnWeight(0, 3)
     354        .SetColumnWeight(1, 2)
     355        .SetColumnWeight(2, 1)
     356    );
     357    iconHolder->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
     358   
    421359    // "Version Info" group
    422 
    423     rect.top = typeBox->Frame().bottom + 8.0f;
    424     rect.bottom = rect.top + typeBox->Bounds().Height();
    425     rect.left = 8.0f;
    426     rect.right = Bounds().Width() - 8.0f;
    427     box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
    428         // the resizing mode will later also be set to B_FOLLOW_BOTTOM
    429     box->SetLabel("Version info");
    430     topView->AddChild(box);
    431 
    432     BMenuField* menuField;
    433 #if 0
    434     BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true);
    435     item = new BMenuItem("Version Info", NULL);
    436     item->SetMarked(true);
    437     popUpMenu->AddItem(item);
    438     item = new BMenuItem("System Version Info", NULL);
    439     popUpMenu->AddItem(item);
    440 
    441     menuField = new BMenuField(BRect(0, 0, 100, 15),
    442         "version kind", NULL, popUpMenu, true);
    443     menuField->ResizeToPreferred();
    444     box->SetLabel(menuField);
    445 #endif
    446 
    447     rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent);
    448     rect.bottom = rect.top + height;
    449     fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL,
    450         NULL);
    451     fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth(
    452         fMajorVersionControl->Label()) + 4.0f);
    453     fMajorVersionControl->GetPreferredSize(&width, &height);
    454     width = 12.0f + fMajorVersionControl->StringWidth("99");
    455     fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height);
     360   
     361    BBox* versionBox = new BBox("versionBox");
     362    versionBox->SetLabel("Version info");
     363   
     364    fMajorVersionControl = new BTextControl("Version:", NULL, NULL);
    456365    _MakeNumberTextControl(fMajorVersionControl);
    457     box->AddChild(fMajorVersionControl);
    458 
    459     rect.left = fMajorVersionControl->Frame().right + 1.0f;
    460     fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL,
    461         NULL);
    462     fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth(
    463         fMiddleVersionControl->Label()) + 4.0f);
    464     fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height);
     366   
     367    fMiddleVersionControl = new BTextControl(".", NULL, NULL);
    465368    _MakeNumberTextControl(fMiddleVersionControl);
    466     box->AddChild(fMiddleVersionControl);
    467 
    468     rect.left = fMiddleVersionControl->Frame().right + 1.0f;
    469     fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL,
    470         NULL);
    471     fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth(
    472         fMinorVersionControl->Label()) + 4.0f);
    473     fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height);
     369   
     370    fMinorVersionControl = new BTextControl(".", NULL, NULL);
    474371    _MakeNumberTextControl(fMinorVersionControl);
    475     box->AddChild(fMinorVersionControl);
    476 
     372   
    477373    fVarietyMenu = new BPopUpMenu("variety", true, true);
    478374    fVarietyMenu->AddItem(new BMenuItem("Development", NULL));
    479375    fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL));
    480376    fVarietyMenu->AddItem(new BMenuItem("Beta", NULL));
    481377    fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL));
    482     fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL));
     378    item = new BMenuItem("Golden master", NULL);
     379    fVarietyMenu->AddItem(item);
    483380    item->SetMarked(true);
    484381    fVarietyMenu->AddItem(new BMenuItem("Final", NULL));
    485 
    486     rect.top--;
    487         // BMenuField oddity
    488     rect.left = fMinorVersionControl->Frame().right + 6.0f;
    489     menuField = new BMenuField(rect,
    490         "variety", NULL, fVarietyMenu, true);
    491     menuField->ResizeToPreferred();
    492     box->AddChild(menuField);
    493 
    494     rect.top++;
    495     rect.left = menuField->Frame().right;
    496     rect.right = rect.left + 30.0f;
    497     fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL,
    498         NULL);
    499     fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth(
    500         fInternalVersionControl->Label()) + 4.0f);
    501     fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height);
    502     box->AddChild(fInternalVersionControl);
    503 
    504     rect = box->Bounds().InsetByCopy(8.0f, 0.0f);
    505     rect.top = fInternalVersionControl->Frame().bottom + 8.0f;
    506     fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:",
    507         NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
    508     float labelWidth = fShortDescriptionControl->StringWidth(
    509         fShortDescriptionControl->Label()) + 4.0f;
    510     fShortDescriptionControl->SetDivider(labelWidth);
    511     fShortDescriptionControl->GetPreferredSize(&width, &height);
    512     fShortDescriptionControl->ResizeTo(rect.Width(), height);
    513 
     382   
     383    BMenuField* varietyField = new BMenuField("", fVarietyMenu);
     384    fInternalVersionControl = new BTextControl("/", NULL, NULL);
     385    fShortDescriptionControl =
     386        new BTextControl("Short description:", NULL, NULL);
     387   
    514388    // TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says?
    515389    version_info versionInfo;
    516     fShortDescriptionControl->TextView()->SetMaxBytes(sizeof(versionInfo.short_info));
    517     box->AddChild(fShortDescriptionControl);
    518 
    519     rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f);
    520     rect.right = rect.left + labelWidth;
    521     StringView* label = new StringView(rect, NULL, "Long description:", NULL);
    522     label->SetDivider(labelWidth);
    523     box->AddChild(label);
    524 
    525     rect.left = rect.right + 3.0f;
    526     rect.top += 1.0f;
    527     rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH;
    528     rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f;
    529     fLongDescriptionView = new TabFilteringTextView(rect, "long desc",
    530         rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS
    531         | B_NAVIGABLE);
     390    fShortDescriptionControl->TextView()->SetMaxBytes(
     391        sizeof(versionInfo.short_info));
     392   
     393    BStringView* longLabel = new BStringView(NULL, "Long description:");
     394    longLabel->SetExplicitAlignment(labelAlignment);
     395    fLongDescriptionView = new TabFilteringTextView("long desc");
    532396    fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));
    533 
     397   
    534398    scrollView = new BScrollView("desc scrollview", fLongDescriptionView,
    535         B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    536     box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f);
    537     box->AddChild(scrollView);
     399        B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    538400
    539     // Adjust window size and limits
     401    // TODO: remove workaround (bug #5678)
     402    BSize minScrollSize = scrollView->ScrollBar(B_VERTICAL)->MinSize();
     403    minScrollSize.width+=fLongDescriptionView->MinSize().width;
     404    scrollView->SetExplicitMinSize(minScrollSize);
     405   
     406    versionBox->AddChild(BGridLayoutBuilder(padding, padding)
     407        .Add(fMajorVersionControl->CreateLabelLayoutItem(), 0, 0)
     408        .Add(fMajorVersionControl->CreateTextViewLayoutItem(), 1, 0)
     409        .Add(fMiddleVersionControl, 2, 0, 2)
     410        .Add(fMinorVersionControl, 4, 0, 2)
     411        .Add(varietyField, 6, 0, 3)
     412        .Add(fInternalVersionControl, 9, 0, 2)
     413        .Add(fShortDescriptionControl->CreateLabelLayoutItem(), 0, 1)
     414        .Add(fShortDescriptionControl->CreateTextViewLayoutItem(), 1, 1, 10)
     415        .Add(longLabel, 0, 2)
     416        .Add(scrollView, 1, 2, 10, 3)
     417        .SetInsets(padding, padding, padding, padding)
     418        .SetRowWeight(3, 3)
     419    );
    540420
    541     width = fInternalVersionControl->Frame().right + 16.0f;
    542     float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f;
    543     if (width > minWidth)
    544         minWidth = width;
     421    // put it all together
     422    SetLayout(new BGroupLayout(B_VERTICAL));
     423    AddChild(menuBar);
     424    AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
     425        .Add(fSignatureControl)
     426        .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
     427            .Add(flagsBox, 3)
     428            .Add(iconBox, 1)
     429        )
     430        .Add(typeBox)
     431        .Add(versionBox)
     432        .SetInsets(padding, padding, padding, padding)
     433    );
    545434
    546     ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth,
    547         box->Frame().bottom + topView->Frame().top + 8.0f);
    548     SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f);
    549     typeBox->SetResizingMode(B_FOLLOW_ALL);
    550     box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
     435    SetKeyMenuBar(menuBar);
    551436
    552437    fSignatureControl->MakeFocus(true);
    553 
    554438    BMimeType::StartWatching(this);
    555439    _SetTo(entry);
    556440}