DiskProbe: Coding style cleanup

* Not complete, no functional changes intended.
This commit is contained in:
Axel Dörfler
2018-11-03 14:07:00 +00:00
parent 49135c955b
commit e85413ad6c
13 changed files with 568 additions and 479 deletions
+8 -4
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
** Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef ATTRIBUTE_WINDOW_H #ifndef ATTRIBUTE_WINDOW_H
#define ATTRIBUTE_WINDOW_H #define ATTRIBUTE_WINDOW_H
@@ -8,19 +8,22 @@
#include "ProbeWindow.h" #include "ProbeWindow.h"
class ProbeView; class ProbeView;
class TypeEditorView; class TypeEditorView;
class AttributeWindow : public ProbeWindow { class AttributeWindow : public ProbeWindow {
public: public:
AttributeWindow(BRect rect, entry_ref *ref, const char *attribute = NULL, AttributeWindow(BRect rect, entry_ref* ref,
const char* attribute = NULL,
const BMessage* settings = NULL); const BMessage* settings = NULL);
virtual ~AttributeWindow(); virtual ~AttributeWindow();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual bool Contains(const entry_ref &ref, const char *attribute); virtual bool Contains(const entry_ref& ref,
const char* attribute);
private: private:
ProbeView* fProbeView; ProbeView* fProbeView;
@@ -28,4 +31,5 @@ class AttributeWindow : public ProbeWindow {
char* fAttribute; char* fAttribute;
}; };
#endif /* ATTRIBUTE_WINDOW_H */ #endif /* ATTRIBUTE_WINDOW_H */
+45 -23
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2007, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef DATA_EDITOR_H #ifndef DATA_EDITOR_H
#define DATA_EDITOR_H #define DATA_EDITOR_H
@@ -11,6 +11,7 @@
#include <Locker.h> #include <Locker.h>
#include <ObjectList.h> #include <ObjectList.h>
class BHandler; class BHandler;
class BLooper; class BLooper;
class BMessage; class BMessage;
@@ -23,30 +24,39 @@ class StateWatcher;
class DataEditor : public BLocker { class DataEditor : public BLocker {
public: public:
DataEditor(); DataEditor();
DataEditor(entry_ref &ref, const char *attribute = NULL); DataEditor(entry_ref& ref,
DataEditor(BEntry &entry, const char *attribute = NULL); const char* attribute = NULL);
DataEditor(BEntry& entry,
const char* attribute = NULL);
DataEditor(const DataEditor& editor); DataEditor(const DataEditor& editor);
~DataEditor(); virtual ~DataEditor();
status_t SetTo(const char *path, const char *attribute = NULL); status_t SetTo(const char* path,
status_t SetTo(entry_ref &ref, const char *attribute = NULL); const char* attribute = NULL);
status_t SetTo(BEntry &entry, const char *attribute = NULL); status_t SetTo(entry_ref &ref,
const char* attribute = NULL);
status_t SetTo(BEntry &entry,
const char* attribute = NULL);
status_t Save(); status_t Save();
bool IsReadOnly() const { return fIsReadOnly; } bool IsReadOnly() const { return fIsReadOnly; }
bool IsDevice() const { return fIsDevice; } bool IsDevice() const { return fIsDevice; }
bool IsAttribute() const { return fAttribute != NULL; } bool IsAttribute() const
bool IsModified() const { return fLastChange != fFirstChange; } { return fAttribute != NULL; }
bool IsModified() const
{ return fLastChange != fFirstChange; }
const char* Attribute() const { return fAttribute; } const char* Attribute() const { return fAttribute; }
type_code Type() const { return fType; } type_code Type() const { return fType; }
status_t InitCheck(); status_t InitCheck();
status_t Replace(off_t offset, const uint8 *data, size_t length); status_t Replace(off_t offset, const uint8* data,
size_t length);
status_t Remove(off_t offset, off_t length); status_t Remove(off_t offset, off_t length);
status_t Insert(off_t offset, const uint8 *data, size_t length); status_t Insert(off_t offset, const uint8* data,
size_t length);
status_t MoveBy(int32 bytes); status_t MoveBy(int32 bytes);
status_t MoveTo(off_t offset); status_t MoveTo(off_t offset);
@@ -74,13 +84,16 @@ class DataEditor : public BLocker {
status_t GetViewBuffer(const uint8** _buffer); status_t GetViewBuffer(const uint8** _buffer);
status_t StartWatching(BMessenger target); status_t StartWatching(BMessenger target);
status_t StartWatching(BHandler *handler, BLooper *looper = NULL); status_t StartWatching(BHandler* handler,
BLooper* looper = NULL);
void StopWatching(BMessenger target); void StopWatching(BMessenger target);
void StopWatching(BHandler *handler, BLooper *looper = NULL); void StopWatching(BHandler* handler,
BLooper* looper = NULL);
off_t Find(off_t startPosition, const uint8 *data, size_t dataSize, off_t Find(off_t startPosition, const uint8* data,
bool caseInsensitive, bool cyclic, size_t dataSize, bool caseInsensitive,
BMessenger progressMessenger, volatile bool *stop = NULL); bool cyclic, BMessenger progressMessenger,
volatile bool* stop = NULL);
BFile& File() { return fFile; } BFile& File() { return fFile; }
const entry_ref& AttributeRef() const { return fAttributeRef; } const entry_ref& AttributeRef() const { return fAttributeRef; }
@@ -91,21 +104,26 @@ class DataEditor : public BLocker {
status_t SetViewOffset(off_t offset, bool sendNotices); status_t SetViewOffset(off_t offset, bool sendNotices);
status_t SetViewSize(size_t size, bool sendNotices); status_t SetViewSize(size_t size, bool sendNotices);
void SendNotices(uint32 what, BMessage *message = NULL); void SendNotices(uint32 what,
BMessage* message = NULL);
void SendNotices(DataChange* change); void SendNotices(DataChange* change);
status_t Update(); status_t Update();
void AddChange(DataChange* change); void AddChange(DataChange* change);
void ApplyChanges(); void ApplyChanges();
void RemoveRedos(); void RemoveRedos();
private:
BObjectList<BMessenger> fObservers; BObjectList<BMessenger> fObservers;
entry_ref fRef, fAttributeRef; entry_ref fRef;
entry_ref fAttributeRef;
BFile fFile; BFile fFile;
const char* fAttribute; const char* fAttribute;
type_code fType; type_code fType;
bool fIsDevice, fIsReadOnly; bool fIsDevice;
off_t fRealSize, fSize; bool fIsReadOnly;
off_t fRealSize;
off_t fSize;
BObjectList<DataChange> fChanges; BObjectList<DataChange> fChanges;
DataChange* fFirstChange; DataChange* fFirstChange;
@@ -113,17 +131,21 @@ class DataEditor : public BLocker {
int32 fChangesFromSaved; int32 fChangesFromSaved;
uint8* fView; uint8* fView;
off_t fRealViewOffset, fViewOffset; off_t fRealViewOffset;
size_t fRealViewSize, fViewSize; off_t fViewOffset;
size_t fRealViewSize;
size_t fViewSize;
bool fNeedsUpdate; bool fNeedsUpdate;
size_t fBlockSize; size_t fBlockSize;
}; };
static const uint32 kMsgDataEditorStateChange = 'deSC'; static const uint32 kMsgDataEditorStateChange = 'deSC';
static const uint32 kMsgDataEditorUpdate = 'deUp'; static const uint32 kMsgDataEditorUpdate = 'deUp';
static const uint32 kMsgDataEditorParameterChange = 'dePC'; static const uint32 kMsgDataEditorParameterChange = 'dePC';
static const uint32 kMsgDataEditorFindProgress = 'deFP'; static const uint32 kMsgDataEditorFindProgress = 'deFP';
#endif /* DATA_EDITOR_H */ #endif /* DATA_EDITOR_H */
+12 -6
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2015, Axel Dörfler, [email protected]. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef DATA_VIEW_H #ifndef DATA_VIEW_H
@@ -51,7 +51,8 @@ public:
uint32 properties = B_FONT_ALL); uint32 properties = B_FONT_ALL);
virtual void GetPreferredSize(float* _width, float* _height); virtual void GetPreferredSize(float* _width, float* _height);
bool FontSizeFitsBounds() const { return fFitFontSize; } bool FontSizeFitsBounds() const
{ return fFitFontSize; }
float FontSize() const; float FontSize() const;
void SetFontSize(float point); void SetFontSize(float point);
@@ -78,8 +79,8 @@ private:
view_focus* _newFocus = NULL); view_focus* _newFocus = NULL);
void DrawSelectionFrame(view_focus which); void DrawSelectionFrame(view_focus which);
void DrawSelectionBlock(view_focus which, int32 start, void DrawSelectionBlock(view_focus which,
int32 end); int32 start, int32 end);
void DrawSelectionBlock(view_focus which); void DrawSelectionBlock(view_focus which);
void DrawSelection(bool frameOnly = false); void DrawSelection(bool frameOnly = false);
void SetActive(bool active); void SetActive(bool active);
@@ -94,6 +95,7 @@ private:
void Copy(); void Copy();
void Paste(); void Paste();
private:
DataEditor& fEditor; DataEditor& fEditor;
uint8* fData; uint8* fData;
size_t fDataSize; size_t fDataSize;
@@ -106,15 +108,18 @@ private:
view_focus fFocus; view_focus fFocus;
base_type fBase; base_type fBase;
bool fIsActive; bool fIsActive;
int32 fStart, fEnd; int32 fStart;
int32 fEnd;
int32 fMouseSelectionStart; int32 fMouseSelectionStart;
int32 fKeySelectionStart; int32 fKeySelectionStart;
int32 fBitPosition; int32 fBitPosition;
bool fFitFontSize; bool fFitFontSize;
int32 fDragMessageSize; int32 fDragMessageSize;
int32 fStoredStart, fStoredEnd; int32 fStoredStart;
int32 fStoredEnd;
}; };
static const uint32 kMsgBaseType = 'base'; static const uint32 kMsgBaseType = 'base';
static const uint32 kMsgUpdateData = 'updt'; static const uint32 kMsgUpdateData = 'updt';
static const uint32 kMsgSetSelection = 'ssel'; static const uint32 kMsgSetSelection = 'ssel';
@@ -126,4 +131,5 @@ static const uint32 kDataViewPreferredSize = 'dvps';
extern bool is_valid_utf8(uint8* data, size_t size); extern bool is_valid_utf8(uint8* data, size_t size);
#endif /* DATA_VIEW_H */ #endif /* DATA_VIEW_H */
+23 -19
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2015, Axel Dörfler, [email protected]. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
@@ -51,7 +51,8 @@ struct disk_probe_settings {
enum disk_probe_flags { enum disk_probe_flags {
kCaseSensitive = 0x01, // this flag alone is R5 DiskProbe settings compatible kCaseSensitive = 0x01,
// this flag alone is R5 DiskProbe settings compatible
kHexFindMode = 0x02, kHexFindMode = 0x02,
}; };
@@ -67,6 +68,7 @@ class Settings {
private: private:
status_t Open(BFile* file, int32 mode); status_t Open(BFile* file, int32 mode);
private:
BMessage fMessage; BMessage fMessage;
bool fUpdated; bool fUpdated;
}; };
@@ -86,8 +88,10 @@ class DiskProbe : public BApplication {
virtual bool QuitRequested(); virtual bool QuitRequested();
private: private:
status_t Probe(BEntry &entry, const char *attribute = NULL); status_t Probe(BEntry& entry,
const char* attribute = NULL);
private:
Settings fSettings; Settings fSettings;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
BWindow* fOpenWindow; BWindow* fOpenWindow;
@@ -123,7 +127,7 @@ Settings::Settings()
if (Open(&file, B_READ_ONLY) != B_OK) if (Open(&file, B_READ_ONLY) != B_OK)
return; return;
// ToDo: load/save settings as flattened BMessage - but not yet, // TODO: load/save settings as flattened BMessage - but not yet,
// since that will break compatibility with R5's DiskProbe // since that will break compatibility with R5's DiskProbe
disk_probe_settings settings; disk_probe_settings settings;
@@ -271,14 +275,13 @@ DiskProbe::ReadyToRun()
} }
/** Opens a window containing the file pointed to by the entry_ref. /*! Opens a window containing the file pointed to by the entry_ref.
* This function will fail if that file doesn't exist or could not This function will fail if that file doesn't exist or could not
* be opened. be opened.
* It will check if there already is a window that probes the It will check if there already is a window that probes the
* file in question and will activate it in that case. file in question and will activate it in that case.
* This function must be called with the application looper locked. This function must be called with the application looper locked.
*/ */
status_t status_t
DiskProbe::Probe(BEntry& entry, const char* attribute) DiskProbe::Probe(BEntry& entry, const char* attribute)
{ {
@@ -319,15 +322,16 @@ DiskProbe::Probe(BEntry &entry, const char *attribute)
rect.OffsetBy(kCascadeOffset, kCascadeOffset); rect.OffsetBy(kCascadeOffset, kCascadeOffset);
BWindow* window; BWindow* window;
if (attribute != NULL) if (attribute != NULL) {
window = new AttributeWindow(rect, &ref, attribute, &fSettings.Message()); window = new AttributeWindow(rect, &ref, attribute,
else &fSettings.Message());
} else
window = new FileWindow(rect, &ref, &fSettings.Message()); window = new FileWindow(rect, &ref, &fSettings.Message());
window->Show(); window->Show();
/* adjust the cascading... we can only do this after the window was created // Adjust the cascading... we can only do this after the window was created
* to adjust to the real size */ // to adjust to the real size.
rect.right = window->Frame().right; rect.right = window->Frame().right;
rect.bottom = window->Frame().bottom; rect.bottom = window->Frame().bottom;
@@ -472,8 +476,8 @@ DiskProbe::MessageReceived(BMessage *message)
if (fFindWindow == NULL) { if (fFindWindow == NULL) {
// open it! // open it!
fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80), *message, fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80),
target, &fSettings.Message()); *message, target, &fSettings.Message());
fFindWindow->Show(); fFindWindow->Show();
} else } else
fFindWindow->Activate(); fFindWindow->Activate();
+3 -2
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
** Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef DISK_PROBE_H #ifndef DISK_PROBE_H
#define DISK_PROBE_H #define DISK_PROBE_H
@@ -22,4 +22,5 @@ static const uint32 kMsgFindWindowClosed = 'clFw';
static const uint32 kMsgFindTarget = 'FTgt'; static const uint32 kMsgFindTarget = 'FTgt';
static const uint32 kMsgFind = 'find'; static const uint32 kMsgFind = 'find';
#endif /* DISK_PROBE_H */ #endif /* DISK_PROBE_H */
+8 -4
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
** Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef FILE_WINDOW_H #ifndef FILE_WINDOW_H
#define FILE_WINDOW_H #define FILE_WINDOW_H
@@ -8,18 +8,22 @@
#include "ProbeWindow.h" #include "ProbeWindow.h"
class ProbeView; class ProbeView;
class FileWindow : public ProbeWindow { class FileWindow : public ProbeWindow {
public: public:
FileWindow(BRect rect, entry_ref *ref, const BMessage *settings = NULL); FileWindow(BRect rect, entry_ref* ref,
const BMessage* settings = NULL);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual bool Contains(const entry_ref &ref, const char *attribute); virtual bool Contains(const entry_ref& ref,
const char* attribute);
private: private:
ProbeView* fProbeView; ProbeView* fProbeView;
}; };
#endif /* FILE_WINDOW_H */ #endif /* FILE_WINDOW_H */
+6 -3
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef FIND_WINDOW_H #ifndef FIND_WINDOW_H
#define FIND_WINDOW_H #define FIND_WINDOW_H
@@ -9,6 +9,7 @@
#include <Window.h> #include <Window.h>
#include <Messenger.h> #include <Messenger.h>
class BCheckBox; class BCheckBox;
class BMenu; class BMenu;
@@ -23,7 +24,8 @@ enum find_mode {
class FindWindow : public BWindow { class FindWindow : public BWindow {
public: public:
FindWindow(BRect rect, BMessage &previous, BMessenger &target, FindWindow(BRect rect, BMessage& previous,
BMessenger& target,
const BMessage* settings = NULL); const BMessage* settings = NULL);
virtual ~FindWindow(); virtual ~FindWindow();
@@ -41,4 +43,5 @@ class FindWindow : public BWindow {
BMenu* fMenu; BMenu* fMenu;
}; };
#endif /* FIND_WINDOW_H */ #endif /* FIND_WINDOW_H */
+4 -2
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef OPEN_WINDOW_H #ifndef OPEN_WINDOW_H
#define OPEN_WINDOW_H #define OPEN_WINDOW_H
@@ -8,6 +8,7 @@
#include <Window.h> #include <Window.h>
class BEntry; class BEntry;
class BMenu; class BMenu;
@@ -27,4 +28,5 @@ private:
BMenu* fDevicesMenu; BMenu* fDevicesMenu;
}; };
#endif /* OPEN_WINDOW_H */ #endif /* OPEN_WINDOW_H */
+49 -32
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2015, Axel Dörfler, [email protected]. * Copyright 2004-2018, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -91,7 +91,8 @@ class IconView : public BView {
class PositionSlider : public BSlider { class PositionSlider : public BSlider {
public: public:
PositionSlider(const char *name, BMessage *message, off_t size, PositionSlider(const char* name,
BMessage* message, off_t size,
uint32 blockSize); uint32 blockSize);
virtual ~PositionSlider(); virtual ~PositionSlider();
@@ -111,6 +112,7 @@ class PositionSlider : public BSlider {
private: private:
void Reset(); void Reset();
private:
static const int32 kMaxSliderLimit = 0x7fffff80; static const int32 kMaxSliderLimit = 0x7fffff80;
// this is the maximum value that BSlider seem to work with fine // this is the maximum value that BSlider seem to work with fine
@@ -121,7 +123,8 @@ class PositionSlider : public BSlider {
class HeaderView : public BGridView, public BInvoker { class HeaderView : public BGridView, public BInvoker {
public: public:
HeaderView(const entry_ref *ref, DataEditor &editor); HeaderView(const entry_ref* ref,
DataEditor& editor);
virtual ~HeaderView(); virtual ~HeaderView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
@@ -131,7 +134,8 @@ class HeaderView : public BGridView, public BInvoker {
base_type Base() const { return fBase; } base_type Base() const { return fBase; }
void SetBase(base_type); void SetBase(base_type);
off_t CursorOffset() const { return fPosition % fBlockSize; } off_t CursorOffset() const
{ return fPosition % fBlockSize; }
off_t Position() const { return fPosition; } off_t Position() const { return fPosition; }
uint32 BlockSize() const { return fBlockSize; } uint32 BlockSize() const { return fBlockSize; }
void SetTo(off_t position, uint32 blockSize); void SetTo(off_t position, uint32 blockSize);
@@ -139,12 +143,14 @@ class HeaderView : public BGridView, public BInvoker {
void UpdateIcon(); void UpdateIcon();
private: private:
void FormatValue(char *buffer, size_t bufferSize, off_t value); void FormatValue(char* buffer, size_t bufferSize,
off_t value);
void UpdatePositionViews(bool all = true); void UpdatePositionViews(bool all = true);
void UpdateOffsetViews(bool all = true); void UpdateOffsetViews(bool all = true);
void UpdateFileSizeView(); void UpdateFileSizeView();
void NotifyTarget(); void NotifyTarget();
private:
const char* fAttribute; const char* fAttribute;
off_t fFileSize; off_t fFileSize;
uint32 fBlockSize; uint32 fBlockSize;
@@ -166,7 +172,8 @@ class HeaderView : public BGridView, public BInvoker {
class TypeMenuItem : public BMenuItem { class TypeMenuItem : public BMenuItem {
public: public:
TypeMenuItem(const char *name, const char *type, BMessage *message); TypeMenuItem(const char* name, const char* type,
BMessage* message);
virtual void GetContentSize(float* _width, float* _height); virtual void GetContentSize(float* _width, float* _height);
virtual void DrawContent(); virtual void DrawContent();
@@ -178,14 +185,16 @@ class TypeMenuItem : public BMenuItem {
class EditorLooper : public BLooper { class EditorLooper : public BLooper {
public: public:
EditorLooper(const char *name, DataEditor &editor, BMessenger messenger); EditorLooper(const char* name,
DataEditor& editor, BMessenger messenger);
virtual ~EditorLooper(); virtual ~EditorLooper();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
bool FindIsRunning() const { return !fQuitFind; } bool FindIsRunning() const { return !fQuitFind; }
void Find(off_t startAt, const uint8 *data, size_t dataSize, void Find(off_t startAt, const uint8* data,
bool caseInsensitive, BMessenger progressMonitor); size_t dataSize, bool caseInsensitive,
BMessenger progressMonitor);
void QuitFind(); void QuitFind();
private: private:
@@ -197,8 +206,9 @@ class EditorLooper : public BLooper {
class TypeView : public BView { class TypeView : public BView {
public: public:
TypeView(BRect rect, const char* name, int32 index, TypeView(BRect rect, const char* name,
DataEditor& editor, int32 resizingMode); int32 index, DataEditor& editor,
int32 resizingMode);
virtual ~TypeView(); virtual ~TypeView();
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
@@ -311,7 +321,8 @@ IconView::UpdateIcon()
PositionSlider::PositionSlider(const char* name, BMessage* message, PositionSlider::PositionSlider(const char* name, BMessage* message,
off_t size, uint32 blockSize) off_t size, uint32 blockSize)
: BSlider(name, NULL, message, 0, kMaxSliderLimit, B_HORIZONTAL, :
BSlider(name, NULL, message, 0, kMaxSliderLimit, B_HORIZONTAL,
B_TRIANGLE_THUMB), B_TRIANGLE_THUMB),
fSize(size), fSize(size),
fBlockSize(blockSize) fBlockSize(blockSize)
@@ -912,7 +923,8 @@ HeaderView::MessageReceived(BMessage *message)
*/ */
TypeMenuItem::TypeMenuItem(const char* name, const char* type, TypeMenuItem::TypeMenuItem(const char* name, const char* type,
BMessage* message) BMessage* message)
: BMenuItem(name, message), :
BMenuItem(name, message),
fType(type) fType(type)
{ {
} }
@@ -1350,14 +1362,15 @@ ProbeView::AttachedToWindow()
Window()->AddChild(bar); Window()->AddChild(bar);
BMenu* menu = new BMenu(fEditor.IsAttribute() BMenu* menu = new BMenu(fEditor.IsAttribute()
? B_TRANSLATE("Attribute") : fEditor.IsDevice() ? B_TRANSLATE("Device") : B_TRANSLATE("File")); ? B_TRANSLATE("Attribute") : fEditor.IsDevice()
? B_TRANSLATE("Device") : B_TRANSLATE("File"));
AddSaveMenuItems(menu, 0); AddSaveMenuItems(menu, 0);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddPrintMenuItems(menu, menu->CountItems()); AddPrintMenuItems(menu, menu->CountItems());
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_CLOSE_REQUESTED), menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
'W')); new BMessage(B_CLOSE_REQUESTED), 'W'));
bar->AddItem(menu); bar->AddItem(menu);
} }
@@ -1365,23 +1378,24 @@ ProbeView::AttachedToWindow()
BMenu* menu = new BMenu(B_TRANSLATE("Edit")); BMenu* menu = new BMenu(B_TRANSLATE("Edit"));
BMenuItem* item; BMenuItem* item;
menu->AddItem(fUndoMenuItem = new BMenuItem(B_TRANSLATE("Undo"), new BMessage(B_UNDO), menu->AddItem(fUndoMenuItem = new BMenuItem(B_TRANSLATE("Undo"),
'Z')); new BMessage(B_UNDO), 'Z'));
fUndoMenuItem->SetEnabled(fEditor.CanUndo()); fUndoMenuItem->SetEnabled(fEditor.CanUndo());
fUndoMenuItem->SetTarget(fDataView); fUndoMenuItem->SetTarget(fDataView);
menu->AddItem(fRedoMenuItem = new BMenuItem(B_TRANSLATE("Redo"), new BMessage(B_REDO), menu->AddItem(fRedoMenuItem = new BMenuItem(B_TRANSLATE("Redo"),
'Z', B_SHIFT_KEY)); new BMessage(B_REDO), 'Z', B_SHIFT_KEY));
fRedoMenuItem->SetEnabled(fEditor.CanRedo()); fRedoMenuItem->SetEnabled(fEditor.CanRedo());
fRedoMenuItem->SetTarget(fDataView); fRedoMenuItem->SetTarget(fDataView);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy"),
new BMessage(B_COPY), 'C'));
item->SetTarget(NULL, Window()); item->SetTarget(NULL, Window());
menu->AddItem(fPasteMenuItem = new BMenuItem(B_TRANSLATE("Paste"), new BMessage(B_PASTE), menu->AddItem(fPasteMenuItem = new BMenuItem(B_TRANSLATE("Paste"),
'V')); new BMessage(B_PASTE), 'V'));
fPasteMenuItem->SetTarget(NULL, Window()); fPasteMenuItem->SetTarget(NULL, Window());
_CheckClipboard(); _CheckClipboard();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"), new BMessage(B_SELECT_ALL), menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"),
'A')); new BMessage(B_SELECT_ALL), 'A'));
item->SetTarget(NULL, Window()); item->SetTarget(NULL, Window());
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS), menu->AddItem(item = new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS),
@@ -1398,14 +1412,16 @@ ProbeView::AttachedToWindow()
menu = new BMenu(B_TRANSLATE("Block")); menu = new BMenu(B_TRANSLATE("Block"));
BMessage* message = new BMessage(kMsgPositionUpdate); BMessage* message = new BMessage(kMsgPositionUpdate);
message->AddInt32("delta", 1); message->AddInt32("delta", 1);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Next"), message, B_RIGHT_ARROW)); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Next"), message,
B_RIGHT_ARROW));
item->SetTarget(fHeaderView); item->SetTarget(fHeaderView);
message = new BMessage(kMsgPositionUpdate); message = new BMessage(kMsgPositionUpdate);
message->AddInt32("delta", -1); message->AddInt32("delta", -1);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Previous"), message, B_LEFT_ARROW)); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Previous"), message,
B_LEFT_ARROW));
item->SetTarget(fHeaderView); item->SetTarget(fHeaderView);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Back"), new BMessage(kMsgLastPosition), menu->AddItem(item = new BMenuItem(B_TRANSLATE("Back"),
'J')); new BMessage(kMsgLastPosition), 'J'));
item->SetTarget(fHeaderView); item->SetTarget(fHeaderView);
BMenu* subMenu = new BMenu(B_TRANSLATE("Selection")); BMenu* subMenu = new BMenu(B_TRANSLATE("Selection"));
@@ -1963,11 +1979,12 @@ ProbeView::MessageReceived(BMessage *message)
{ {
const uint8* data; const uint8* data;
ssize_t size; ssize_t size;
if (message->FindData("data", B_RAW_TYPE, (const void **)&data, &size) != B_OK) { if (message->FindData("data", B_RAW_TYPE, (const void**)&data,
&size) != B_OK) {
// search again for last pattern // search again for last pattern
BMessage* itemMessage = fFindAgainMenuItem->Message(); BMessage* itemMessage = fFindAgainMenuItem->Message();
if (itemMessage == NULL if (itemMessage == NULL || itemMessage->FindData("data",
|| itemMessage->FindData("data", B_RAW_TYPE, (const void **)&data, &size) != B_OK) { B_RAW_TYPE, (const void**)&data, &size) != B_OK) {
// this shouldn't ever happen, but well... // this shouldn't ever happen, but well...
beep(); beep();
break; break;
+8 -4
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef PROBE_VIEW_H #ifndef PROBE_VIEW_H
#define PROBE_VIEW_H #define PROBE_VIEW_H
@@ -24,7 +24,8 @@ class EditorLooper;
class ProbeView : public BView { class ProbeView : public BView {
public: public:
ProbeView(entry_ref* ref, const char* attribute = NULL, ProbeView(entry_ref* ref,
const char* attribute = NULL,
const BMessage* settings = NULL); const BMessage* settings = NULL);
virtual ~ProbeView(); virtual ~ProbeView();
@@ -44,7 +45,8 @@ class ProbeView : public BView {
private: private:
void _UpdateAttributesMenu(BMenu* menu); void _UpdateAttributesMenu(BMenu* menu);
void _UpdateSelectionMenuItems(int64 start, int64 end); void _UpdateSelectionMenuItems(int64 start,
int64 end);
void _UpdateBookmarkMenuItems(); void _UpdateBookmarkMenuItems();
void _AddBookmark(off_t position); void _AddBookmark(off_t position);
void _RemoveTypeEditor(); void _RemoveTypeEditor();
@@ -54,6 +56,7 @@ class ProbeView : public BView {
void _Print(); void _Print();
status_t _Save(); status_t _Save();
private:
DataEditor fEditor; DataEditor fEditor;
EditorLooper* fEditorLooper; EditorLooper* fEditorLooper;
HeaderView* fHeaderView; HeaderView* fHeaderView;
@@ -74,4 +77,5 @@ class ProbeView : public BView {
size_t fLastSearchSize; size_t fLastSearchSize;
}; };
#endif /* PROBE_VIEW_H */ #endif /* PROBE_VIEW_H */
+19 -4
View File
@@ -1,18 +1,33 @@
/* /*
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/
/*! Abstract base class for probe windows. It only provides the following
functionality:
- Access to the basic entry_ref
- Common BWindow flags
- Stores size in settings on QuitRequested()
- Redirects drops to BApplication
- Notifies BApplication about closed window
- Forwards mouse wheel to the DataView
- Contains() checks whether or not the ref/attribute is what this
window contains
*/ */
#include "ProbeWindow.h" #include "ProbeWindow.h"
#include "DiskProbe.h"
#include <Application.h> #include <Application.h>
#include <View.h> #include <View.h>
#include "DiskProbe.h"
ProbeWindow::ProbeWindow(BRect rect, entry_ref* ref) ProbeWindow::ProbeWindow(BRect rect, entry_ref* ref)
: BWindow(rect, ref->name, B_DOCUMENT_WINDOW, :
BWindow(rect, ref->name, B_DOCUMENT_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
fRef(*ref) fRef(*ref)
{ {
+5 -3
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de.
** Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef PROBE_WINDOW_H #ifndef PROBE_WINDOW_H
#define PROBE_WINDOW_H #define PROBE_WINDOW_H
@@ -18,7 +18,8 @@ class ProbeWindow : public BWindow {
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested(); virtual bool QuitRequested();
virtual bool Contains(const entry_ref &ref, const char *attribute) = 0; virtual bool Contains(const entry_ref& ref,
const char* attribute) = 0;
protected: protected:
const entry_ref& Ref() const { return fRef; } const entry_ref& Ref() const { return fRef; }
@@ -27,4 +28,5 @@ class ProbeWindow : public BWindow {
entry_ref fRef; entry_ref fRef;
}; };
#endif /* PROBE_WINDOW_H */ #endif /* PROBE_WINDOW_H */
+11 -6
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT license.
*/ */
#ifndef TYPE_EDITORS_H #ifndef TYPE_EDITORS_H
#define TYPE_EDITORS_H #define TYPE_EDITORS_H
@@ -8,15 +8,18 @@
#include <View.h> #include <View.h>
class DataEditor; class DataEditor;
class TypeEditorView : public BView { class TypeEditorView : public BView {
public: public:
TypeEditorView(BRect rect, const char* name, uint32 resizingMode, TypeEditorView(BRect rect, const char* name,
uint32 flags, DataEditor& editor); uint32 resizingMode, uint32 flags,
TypeEditorView(const char* name, uint32 flags, DataEditor& editor); DataEditor& editor);
~TypeEditorView(); TypeEditorView(const char* name, uint32 flags,
DataEditor& editor);
virtual ~TypeEditorView();
virtual void CommitChanges(); virtual void CommitChanges();
virtual bool TypeMatches(); virtual bool TypeMatches();
@@ -25,9 +28,11 @@ class TypeEditorView : public BView {
DataEditor& fEditor; DataEditor& fEditor;
}; };
extern TypeEditorView* GetTypeEditorFor(BRect rect, DataEditor& editor); extern TypeEditorView* GetTypeEditorFor(BRect rect, DataEditor& editor);
extern status_t GetNthTypeEditor(int32 index, const char** _name); extern status_t GetNthTypeEditor(int32 index, const char** _name);
extern TypeEditorView* GetTypeEditorAt(int32 index, BRect rect, extern TypeEditorView* GetTypeEditorAt(int32 index, BRect rect,
DataEditor& editor); DataEditor& editor);
#endif /* TYPE_EDITORS_H */ #endif /* TYPE_EDITORS_H */