superior SupportedTypesView

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4348 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shatty
2003-08-20 07:59:28 +00:00
parent b98ed81007
commit f490f7ff66
2 changed files with 40 additions and 29 deletions
@@ -1,32 +1,48 @@
#include <AppTypeSupportedTypesView.h> #include <AppTypeSupportedTypesView.h>
#include <SupportDefs.h>
AppTypeSupportedTypesView::AppTypeSupportedTypesView(BRect viewFrame) AppTypeSupportedTypesView::AppTypeSupportedTypesView(BRect viewFrame)
: BView(viewFrame, "AppTypeSupportedTypesView", B_FOLLOW_ALL, : BView(viewFrame, "AppTypeSupportedTypesView", B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW) B_FRAME_EVENTS|B_WILL_DRAW)
{ {
float width = 0, height = 0; font_height fontHeight;
GetFontHeight(&fontHeight);
float lineHeight = fontHeight.ascent+fontHeight.descent+fontHeight.leading;
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
fSupportedTypesBox = new BBox(Bounds(),"box", fBox = new BBox(Bounds(),"box",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP); fBox->SetLabel("Supported Types:");
fSupportedTypesBox->SetLabel("Supported Types:"); AddChild(fBox);
AddChild(fSupportedTypesBox);
const char * addButtonLabel = "Add..."; const char * addButtonLabel = "Add...";
float addButtonStringWidth = StringWidth(addButtonLabel); fAddButton = new BButton(Bounds(),addButtonLabel,addButtonLabel,NULL);
BRect addButtonFrame = fSupportedTypesBox->Bounds(); float addButtonWidth = 0, addButtonHeight = 0;
addButtonFrame.top = 10; fAddButton->GetPreferredSize(&addButtonWidth,&addButtonHeight);
addButtonFrame.left = 10;
addButtonFrame.right -= 10; const char * removeButtonLabel = "Remove";
fSupportedTypesAddButton = new BButton(addButtonFrame, fRemoveButton = new BButton(Bounds(),removeButtonLabel,removeButtonLabel,NULL);
addButtonLabel, float removeButtonWidth = 0, removeButtonHeight = 0;
addButtonLabel,NULL); fRemoveButton->GetPreferredSize(&removeButtonWidth,&removeButtonHeight);
fSupportedTypesBox->AddChild(fSupportedTypesAddButton);
fSupportedTypesAddButton->GetPreferredSize(&width,&height);
fSupportedTypesAddButton->ResizeTo(width,height);
float leftWidth = width;
float buttonWidth = max_c(addButtonWidth,removeButtonWidth);
float buttonHeight = max_c(addButtonHeight,removeButtonHeight);
fRemoveButton->ResizeTo(buttonWidth,buttonHeight);
fAddButton->ResizeTo(buttonWidth,buttonHeight);
fBox->AddChild(fAddButton);
fAddButton->MoveTo(fBox->Bounds().Width() - 60 - fAddButton->Bounds().Width(),14);
fBox->AddChild(fRemoveButton);
fRemoveButton->MoveTo(fAddButton->Frame().left,fAddButton->Frame().bottom);
fListView = new BListView(Bounds(),"listview");
fListView->ResizeTo(fAddButton->Frame().left - 20 - B_V_SCROLL_BAR_WIDTH,
max_c(1*lineHeight,2*buttonHeight - 2));
fListView->MoveTo(12,fAddButton->Frame().top+2);
fScrollView = new BScrollView("scrollview",fListView,B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW,false,true);
fBox->AddChild(fScrollView);
fBox->ResizeTo(Bounds().Width(),fScrollView->Frame().bottom+8);
ResizeTo(fBox->Bounds().Width(),fBox->Bounds().Height());
} }
AppTypeSupportedTypesView::~AppTypeSupportedTypesView() AppTypeSupportedTypesView::~AppTypeSupportedTypesView()
@@ -3,13 +3,8 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Menu.h> #include <ListView.h>
#include <MenuField.h> #include <ScrollView.h>
#include <MenuItem.h>
#include <String.h>
#include <StringView.h>
#include <TextControl.h>
#include <TextView.h>
#include <View.h> #include <View.h>
class AppTypeSupportedTypesView : public BView { class AppTypeSupportedTypesView : public BView {
@@ -20,11 +15,11 @@ public:
bool IsClean() const; bool IsClean() const;
private: private:
BBox * fSupportedTypesBox; BBox * fBox;
BListView * fSupportedTypesListView; BListView * fListView;
BScrollView * fSupportedTypesScrollView; BScrollView * fScrollView;
BButton * fSupportedTypesAddButton; BButton * fAddButton;
BButton * fSupportedTypesRemoveButton; BButton * fRemoveButton;
}; };
#endif // APP_TYPE_SUPPORTED_TYPES_VIEW_H #endif // APP_TYPE_SUPPORTED_TYPES_VIEW_H