diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 6e26bcbe83..ee28eccf7f 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -323,19 +324,12 @@ void HeaderView::Draw(BRect updateRect) { BRect rect = Bounds(); - rect.bottom -= 2; SetHighColor(ui_color(B_SHINE_COLOR)); StrokeLine(rect.LeftTop(), rect.LeftBottom()); StrokeLine(rect.LeftTop(), rect.RightTop()); - rect.bottom++; - SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); - StrokeLine(rect.LeftBottom(), rect.RightBottom()); - - rect.bottom++; - SetHighColor(tint_color(ViewColor(), B_DARKEN_2_TINT)); - StrokeLine(rect.LeftBottom(), rect.RightBottom()); + // the gradient at the bottom is drawn by the BScrollView } @@ -345,7 +339,7 @@ HeaderView::GetPreferredSize(float *_width, float *_height) if (_width) *_width = Bounds().Width(); if (_height) - *_height = fPositionSlider->Frame().bottom + 4; + *_height = fPositionSlider->Frame().bottom + 2; } @@ -353,7 +347,8 @@ HeaderView::GetPreferredSize(float *_width, float *_height) ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute) - : BView(rect, "probeView", B_FOLLOW_ALL, B_WILL_DRAW) + : BView(rect, "probeView", B_FOLLOW_ALL, B_WILL_DRAW), + fAttribute(attribute) { BNode node(ref); @@ -369,10 +364,18 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute) fIsDevice = (stat.st_mode & (S_IFBLK | S_IFCHR)) != 0; rect = Bounds(); - rect.bottom = rect.top + 62; - fHeaderView = new HeaderView(rect, ref, fIsDevice); + fHeaderView = new HeaderView(rect, ref, fIsDevice, attribute ? fAttribute.String() : NULL); fHeaderView->ResizeToPreferred(); AddChild(fHeaderView); + + rect = fHeaderView->Frame(); + rect.top = rect.bottom + 3; + rect.bottom = Bounds().bottom - B_H_SCROLL_BAR_HEIGHT; + rect.right -= B_V_SCROLL_BAR_WIDTH; + BView *view = new BView(rect, "text", B_FOLLOW_NONE, B_WILL_DRAW); + + fScrollView = new BScrollView("scroller", view, B_FOLLOW_ALL, B_WILL_DRAW, true, true); + AddChild(fScrollView); } @@ -382,14 +385,38 @@ ProbeView::~ProbeView() } +void +ProbeView::AddFileMenuItems(BMenu *menu, int32 index) +{ + BMenuItem *item; + menu->AddItem(item = new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, NULL), index++); + item->SetEnabled(false); + menu->AddItem(item = new BMenuItem("Print" B_UTF8_ELLIPSIS, NULL, 'P', B_COMMAND_KEY), index++); + item->SetEnabled(false); +} + + void ProbeView::AttachedToWindow() { // Add menu to window - + BMenuBar *bar = Window()->KeyMenuBar(); - if (bar == NULL) - return; + if (bar == NULL) { + // there is none? Well, but we really want to have one + bar = new BMenuBar(BRect(0, 0, 0, 0), NULL); + Window()->AddChild(bar); + + MoveBy(0, bar->Bounds().Height()); + ResizeBy(0, -bar->Bounds().Height()); + + BMenu *menu = new BMenu(fAttribute.Length() > 0 ? "Attribute" : fIsDevice ? "Device" : "File"); + AddFileMenuItems(menu, 0); + menu->AddSeparatorItem(); + + menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); + bar->AddItem(menu); + } BMenu *menu = new BMenu("Edit"); menu->AddItem(new BMenuItem("Undo", NULL, 'Z', B_COMMAND_KEY)); diff --git a/src/apps/diskprobe/ProbeView.h b/src/apps/diskprobe/ProbeView.h index 72053ffd9c..fdc5a08940 100644 --- a/src/apps/diskprobe/ProbeView.h +++ b/src/apps/diskprobe/ProbeView.h @@ -7,11 +7,11 @@ #include +#include #include -class BTextControl; -class BStringView; -class BSlider; + +class BScrollView; class HeaderView; @@ -24,9 +24,13 @@ class ProbeView : public BView { virtual void AttachedToWindow(); virtual void MessageReceived(BMessage *message); + void AddFileMenuItems(BMenu *menu, int32 index); + private: + BString fAttribute; bool fIsDevice; HeaderView *fHeaderView; + BScrollView *fScrollView; }; #endif /* PROBE_WINDOW_H */ diff --git a/src/apps/diskprobe/ProbeWindow.cpp b/src/apps/diskprobe/ProbeWindow.cpp index fe63539b9c..272d7a66c7 100644 --- a/src/apps/diskprobe/ProbeWindow.cpp +++ b/src/apps/diskprobe/ProbeWindow.cpp @@ -36,7 +36,7 @@ ProbeWindow::ProbeWindow(BRect rect, entry_ref *ref, const char *attribute) } // add the menu - + BMenuBar *menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); @@ -53,11 +53,7 @@ ProbeWindow::ProbeWindow(BRect rect, entry_ref *ref, const char *attribute) new BMessage(kMsgOpenFilePanel), 'O', B_COMMAND_KEY)); menu->AddSeparatorItem(); - BMenuItem *item; - menu->AddItem(item = new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, NULL)); - item->SetEnabled(false); - menu->AddItem(item = new BMenuItem("Print" B_UTF8_ELLIPSIS, NULL, 'P', B_COMMAND_KEY)); - item->SetEnabled(false); + // the ProbeView file menu items will be inserted here menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About DiskProbe" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); @@ -71,8 +67,9 @@ ProbeWindow::ProbeWindow(BRect rect, entry_ref *ref, const char *attribute) BRect rect = Bounds(); rect.top = menuBar->Bounds().Height() + 1; - BView *view = new ProbeView(rect, ref, attribute); - AddChild(view); + ProbeView *probeView = new ProbeView(rect, ref, attribute); + probeView->AddFileMenuItems(menu, menu->CountItems() - 4); + AddChild(probeView); }