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:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ProbeView.h"
|
#include "ProbeView.h"
|
||||||
|
#include "DataView.h"
|
||||||
|
|
||||||
#define BEOS_R5_COMPATIBLE
|
#define BEOS_R5_COMPATIBLE
|
||||||
// for SetLimits()
|
// for SetLimits()
|
||||||
@@ -347,24 +348,12 @@ HeaderView::GetPreferredSize(float *_width, float *_height)
|
|||||||
|
|
||||||
|
|
||||||
ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute)
|
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);
|
fEditor.SetTo(*ref, attribute);
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
rect = Bounds();
|
rect = Bounds();
|
||||||
fHeaderView = new HeaderView(rect, ref, fIsDevice, attribute ? fAttribute.String() : NULL);
|
fHeaderView = new HeaderView(rect, ref, fEditor.IsDevice(), fEditor.Attribute());
|
||||||
fHeaderView->ResizeToPreferred();
|
fHeaderView->ResizeToPreferred();
|
||||||
AddChild(fHeaderView);
|
AddChild(fHeaderView);
|
||||||
|
|
||||||
@@ -372,7 +361,7 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute)
|
|||||||
rect.top = rect.bottom + 3;
|
rect.top = rect.bottom + 3;
|
||||||
rect.bottom = Bounds().bottom - B_H_SCROLL_BAR_HEIGHT;
|
rect.bottom = Bounds().bottom - B_H_SCROLL_BAR_HEIGHT;
|
||||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
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);
|
fScrollView = new BScrollView("scroller", view, B_FOLLOW_ALL, B_WILL_DRAW, true, true);
|
||||||
AddChild(fScrollView);
|
AddChild(fScrollView);
|
||||||
@@ -381,7 +370,13 @@ ProbeView::ProbeView(BRect rect, entry_ref *ref, const char *attribute)
|
|||||||
|
|
||||||
ProbeView::~ProbeView()
|
ProbeView::~ProbeView()
|
||||||
{
|
{
|
||||||
stop_watching(this);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ProbeView::DetachedFromWindow()
|
||||||
|
{
|
||||||
|
fEditor.StopWatching(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -399,6 +394,8 @@ ProbeView::AddFileMenuItems(BMenu *menu, int32 index)
|
|||||||
void
|
void
|
||||||
ProbeView::AttachedToWindow()
|
ProbeView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
fEditor.StartWatching(this);
|
||||||
|
|
||||||
// Add menu to window
|
// Add menu to window
|
||||||
|
|
||||||
BMenuBar *bar = Window()->KeyMenuBar();
|
BMenuBar *bar = Window()->KeyMenuBar();
|
||||||
@@ -410,7 +407,7 @@ ProbeView::AttachedToWindow()
|
|||||||
MoveBy(0, bar->Bounds().Height());
|
MoveBy(0, bar->Bounds().Height());
|
||||||
ResizeBy(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);
|
AddFileMenuItems(menu, 0);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#define PROBE_VIEW_H
|
#define PROBE_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "DataEditor.h"
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
@@ -21,16 +23,16 @@ class ProbeView : public BView {
|
|||||||
ProbeView(BRect rect, entry_ref *ref, const char *attribute = NULL);
|
ProbeView(BRect rect, entry_ref *ref, const char *attribute = NULL);
|
||||||
virtual ~ProbeView();
|
virtual ~ProbeView();
|
||||||
|
|
||||||
|
virtual void DetachedFromWindow();
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
void AddFileMenuItems(BMenu *menu, int32 index);
|
void AddFileMenuItems(BMenu *menu, int32 index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BString fAttribute;
|
DataEditor fEditor;
|
||||||
bool fIsDevice;
|
|
||||||
HeaderView *fHeaderView;
|
HeaderView *fHeaderView;
|
||||||
BScrollView *fScrollView;
|
BScrollView *fScrollView;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PROBE_WINDOW_H */
|
#endif /* PROBE_VIEW_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user