Now contains the DataEditor for the file.

No longer uses the node monitoring itself, but the watching mechanism
provided by the DataEditor (it now even does this at the right place).
Removed some variables now maintained by the DataEditor.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-02-12 03:09:22 +00:00
parent 990e75bacf
commit bc005359f2
2 changed files with 20 additions and 21 deletions

View File

@ -5,6 +5,7 @@
#include "ProbeView.h"
#include "DataView.h"
#define BEOS_R5_COMPATIBLE
// for SetLimits()
@ -347,24 +348,12 @@ 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),
fAttribute(attribute)
: BView(rect, "probeView", B_FOLLOW_ALL, B_WILL_DRAW)
{
BNode node(ref);
node_ref nodeRef;
if (node.GetNodeRef(&nodeRef) == B_OK)
watch_node(&nodeRef, B_WATCH_STAT, this);
struct stat stat;
stat.st_mode = 0;
BEntry entry(ref);
entry.GetStat(&stat);
fIsDevice = (stat.st_mode & (S_IFBLK | S_IFCHR)) != 0;
fEditor.SetTo(*ref, attribute);
rect = Bounds();
fHeaderView = new HeaderView(rect, ref, fIsDevice, attribute ? fAttribute.String() : NULL);
fHeaderView = new HeaderView(rect, ref, fEditor.IsDevice(), fEditor.Attribute());
fHeaderView->ResizeToPreferred();
AddChild(fHeaderView);
@ -372,7 +361,7 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute)
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);
BView *view = new DataView(rect, fEditor);
fScrollView = new BScrollView("scroller", view, B_FOLLOW_ALL, B_WILL_DRAW, true, true);
AddChild(fScrollView);
@ -381,7 +370,13 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute)
ProbeView::~ProbeView()
{
stop_watching(this);
}
void
ProbeView::DetachedFromWindow()
{
fEditor.StopWatching(this);
}
@ -399,6 +394,8 @@ ProbeView::AddFileMenuItems(BMenu *menu, int32 index)
void
ProbeView::AttachedToWindow()
{
fEditor.StartWatching(this);
// Add menu to window
BMenuBar *bar = Window()->KeyMenuBar();
@ -410,7 +407,7 @@ ProbeView::AttachedToWindow()
MoveBy(0, bar->Bounds().Height());
ResizeBy(0, -bar->Bounds().Height());
BMenu *menu = new BMenu(fAttribute.Length() > 0 ? "Attribute" : fIsDevice ? "Device" : "File");
BMenu *menu = new BMenu(fEditor.IsAttribute() ? "Attribute" : fEditor.IsDevice() ? "Device" : "File");
AddFileMenuItems(menu, 0);
menu->AddSeparatorItem();

View File

@ -6,6 +6,8 @@
#define PROBE_VIEW_H
#include "DataEditor.h"
#include <View.h>
#include <String.h>
#include <Path.h>
@ -21,16 +23,16 @@ class ProbeView : public BView {
ProbeView(BRect rect, entry_ref *ref, const char *attribute = NULL);
virtual ~ProbeView();
virtual void DetachedFromWindow();
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message);
void AddFileMenuItems(BMenu *menu, int32 index);
private:
BString fAttribute;
bool fIsDevice;
DataEditor fEditor;
HeaderView *fHeaderView;
BScrollView *fScrollView;
};
#endif /* PROBE_WINDOW_H */
#endif /* PROBE_VIEW_H */