diff --git a/src/apps/diskprobe/AttributeWindow.h b/src/apps/diskprobe/AttributeWindow.h index 418434e5c9..a595e1f4fd 100644 --- a/src/apps/diskprobe/AttributeWindow.h +++ b/src/apps/diskprobe/AttributeWindow.h @@ -1,31 +1,35 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the MIT License. -*/ +/* + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. + */ #ifndef ATTRIBUTE_WINDOW_H #define ATTRIBUTE_WINDOW_H #include "ProbeWindow.h" + class ProbeView; class TypeEditorView; class AttributeWindow : public ProbeWindow { - public: - AttributeWindow(BRect rect, entry_ref *ref, const char *attribute = NULL, - const BMessage *settings = NULL); - virtual ~AttributeWindow(); +public: + AttributeWindow(BRect rect, entry_ref* ref, + const char* attribute = NULL, + const BMessage* settings = NULL); + virtual ~AttributeWindow(); - virtual void MessageReceived(BMessage *message); - virtual bool QuitRequested(); - virtual bool Contains(const entry_ref &ref, const char *attribute); + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + virtual bool Contains(const entry_ref& ref, + const char* attribute); - private: - ProbeView *fProbeView; - TypeEditorView *fTypeEditorView; - char *fAttribute; +private: + ProbeView* fProbeView; + TypeEditorView* fTypeEditorView; + char* fAttribute; }; + #endif /* ATTRIBUTE_WINDOW_H */ diff --git a/src/apps/diskprobe/DataEditor.h b/src/apps/diskprobe/DataEditor.h index 1d0ef7c9c6..5cdd85c8ab 100644 --- a/src/apps/diskprobe/DataEditor.h +++ b/src/apps/diskprobe/DataEditor.h @@ -1,6 +1,6 @@ /* - * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef DATA_EDITOR_H #define DATA_EDITOR_H @@ -11,6 +11,7 @@ #include #include + class BHandler; class BLooper; class BMessage; @@ -21,109 +22,130 @@ class StateWatcher; class DataEditor : public BLocker { - public: - DataEditor(); - DataEditor(entry_ref &ref, const char *attribute = NULL); - DataEditor(BEntry &entry, const char *attribute = NULL); - DataEditor(const DataEditor &editor); - ~DataEditor(); +public: + DataEditor(); + DataEditor(entry_ref& ref, + const char* attribute = NULL); + DataEditor(BEntry& entry, + const char* attribute = NULL); + DataEditor(const DataEditor& editor); + virtual ~DataEditor(); - status_t SetTo(const char *path, 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 SetTo(const char* path, + 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 IsDevice() const { return fIsDevice; } - bool IsAttribute() const { return fAttribute != NULL; } - bool IsModified() const { return fLastChange != fFirstChange; } + bool IsReadOnly() const { return fIsReadOnly; } + bool IsDevice() const { return fIsDevice; } + bool IsAttribute() const + { return fAttribute != NULL; } + bool IsModified() const + { return fLastChange != fFirstChange; } - const char *Attribute() const { return fAttribute; } - type_code Type() const { return fType; } + const char* Attribute() const { return fAttribute; } + 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 Remove(off_t offset, off_t length); - status_t Insert(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 Insert(off_t offset, const uint8* data, + size_t length); - status_t MoveBy(int32 bytes); - status_t MoveTo(off_t offset); + status_t MoveBy(int32 bytes); + status_t MoveTo(off_t offset); - status_t Undo(); - status_t Redo(); + status_t Undo(); + status_t Redo(); - bool CanUndo() const; - bool CanRedo() const; + bool CanUndo() const; + bool CanRedo() const; - status_t SetFileSize(off_t size); - off_t FileSize() const { return fSize; } + status_t SetFileSize(off_t size); + off_t FileSize() const { return fSize; } - status_t SetViewOffset(off_t offset); - off_t ViewOffset() const { return fViewOffset; } + status_t SetViewOffset(off_t offset); + off_t ViewOffset() const { return fViewOffset; } - status_t SetViewSize(size_t size); - size_t ViewSize() const { return fViewSize; } + status_t SetViewSize(size_t size); + size_t ViewSize() const { return fViewSize; } - status_t SetBlockSize(size_t size); - size_t BlockSize() const { return fBlockSize; } + status_t SetBlockSize(size_t size); + size_t BlockSize() const { return fBlockSize; } - status_t UpdateIfNeeded(bool *_updated = NULL); - status_t ForceUpdate(); - status_t GetViewBuffer(const uint8 **_buffer); + status_t UpdateIfNeeded(bool* _updated = NULL); + status_t ForceUpdate(); + status_t GetViewBuffer(const uint8** _buffer); - status_t StartWatching(BMessenger target); - status_t StartWatching(BHandler *handler, BLooper *looper = NULL); - void StopWatching(BMessenger target); - void StopWatching(BHandler *handler, BLooper *looper = NULL); + status_t StartWatching(BMessenger target); + status_t StartWatching(BHandler* handler, + BLooper* looper = NULL); + void StopWatching(BMessenger target); + void StopWatching(BHandler* handler, + BLooper* looper = NULL); - off_t Find(off_t startPosition, const uint8 *data, size_t dataSize, - bool caseInsensitive, bool cyclic, - BMessenger progressMessenger, volatile bool *stop = NULL); + off_t Find(off_t startPosition, const uint8* data, + size_t dataSize, bool caseInsensitive, + bool cyclic, BMessenger progressMessenger, + volatile bool* stop = NULL); - BFile &File() { return fFile; } - const entry_ref &AttributeRef() const { return fAttributeRef; } - const entry_ref &Ref() const { return fRef; } + BFile& File() { return fFile; } + const entry_ref& AttributeRef() const { return fAttributeRef; } + const entry_ref& Ref() const { return fRef; } - private: - friend class StateWatcher; +private: + friend class StateWatcher; - status_t SetViewOffset(off_t offset, bool sendNotices); - status_t SetViewSize(size_t size, bool sendNotices); - void SendNotices(uint32 what, BMessage *message = NULL); - void SendNotices(DataChange *change); - status_t Update(); - void AddChange(DataChange *change); - void ApplyChanges(); - void RemoveRedos(); + status_t SetViewOffset(off_t offset, bool sendNotices); + status_t SetViewSize(size_t size, bool sendNotices); + void SendNotices(uint32 what, + BMessage* message = NULL); + void SendNotices(DataChange* change); + status_t Update(); + void AddChange(DataChange* change); + void ApplyChanges(); + void RemoveRedos(); - BObjectList fObservers; +private: + BObjectList fObservers; - entry_ref fRef, fAttributeRef; - BFile fFile; - const char *fAttribute; - type_code fType; - bool fIsDevice, fIsReadOnly; - off_t fRealSize, fSize; + entry_ref fRef; + entry_ref fAttributeRef; + BFile fFile; + const char* fAttribute; + type_code fType; + bool fIsDevice; + bool fIsReadOnly; + off_t fRealSize; + off_t fSize; - BObjectList fChanges; - DataChange *fFirstChange; - DataChange *fLastChange; - int32 fChangesFromSaved; + BObjectList fChanges; + DataChange* fFirstChange; + DataChange* fLastChange; + int32 fChangesFromSaved; - uint8 *fView; - off_t fRealViewOffset, fViewOffset; - size_t fRealViewSize, fViewSize; - bool fNeedsUpdate; + uint8* fView; + off_t fRealViewOffset; + off_t fViewOffset; + size_t fRealViewSize; + size_t fViewSize; + bool fNeedsUpdate; - size_t fBlockSize; + size_t fBlockSize; }; + static const uint32 kMsgDataEditorStateChange = 'deSC'; static const uint32 kMsgDataEditorUpdate = 'deUp'; static const uint32 kMsgDataEditorParameterChange = 'dePC'; static const uint32 kMsgDataEditorFindProgress = 'deFP'; + #endif /* DATA_EDITOR_H */ diff --git a/src/apps/diskprobe/DataView.h b/src/apps/diskprobe/DataView.h index c48907f0f7..ecf6414305 100644 --- a/src/apps/diskprobe/DataView.h +++ b/src/apps/diskprobe/DataView.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef DATA_VIEW_H @@ -29,92 +29,97 @@ enum view_focus { class DataView : public BView { public: - DataView(DataEditor& editor); - virtual ~DataView(); + DataView(DataEditor& editor); + virtual ~DataView(); - virtual void DetachedFromWindow(); - virtual void AttachedToWindow(); - virtual void MessageReceived(BMessage* message); - virtual void Draw(BRect updateRect); + virtual void DetachedFromWindow(); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* message); + virtual void Draw(BRect updateRect); - virtual void MouseDown(BPoint where); - virtual void MouseMoved(BPoint where, uint32 transit, - const BMessage* message); - virtual void MouseUp(BPoint where); + virtual void MouseDown(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message); + virtual void MouseUp(BPoint where); - virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void KeyDown(const char* bytes, int32 numBytes); - virtual void WindowActivated(bool active); - virtual void MakeFocus(bool focus); - virtual void FrameResized(float width, float height); - virtual void SetFont(const BFont* font, - uint32 properties = B_FONT_ALL); - virtual void GetPreferredSize(float* _width, float* _height); + virtual void WindowActivated(bool active); + virtual void MakeFocus(bool focus); + virtual void FrameResized(float width, float height); + virtual void SetFont(const BFont* font, + uint32 properties = B_FONT_ALL); + virtual void GetPreferredSize(float* _width, float* _height); - bool FontSizeFitsBounds() const { return fFitFontSize; } - float FontSize() const; - void SetFontSize(float point); + bool FontSizeFitsBounds() const + { return fFitFontSize; } + float FontSize() const; + void SetFontSize(float point); - void UpdateScroller(); + void UpdateScroller(); - void MakeVisible(int32 position); - void SetSelection(int32 start, int32 end, - view_focus focus = kNoFocus); - void GetSelection(int32& start, int32& end); - void InvalidateRange(int32 start, int32 end); + void MakeVisible(int32 position); + void SetSelection(int32 start, int32 end, + view_focus focus = kNoFocus); + void GetSelection(int32& start, int32& end); + void InvalidateRange(int32 start, int32 end); - base_type Base() const { return fBase; } - void SetBase(base_type type); + base_type Base() const { return fBase; } + void SetBase(base_type type); - const uint8* DataAt(int32 start); + const uint8* DataAt(int32 start); - static int32 WidthForFontSize(float size); + static int32 WidthForFontSize(float size); private: - BRect DataBounds(bool inView = false) const; - BRect SelectionFrame(view_focus which, int32 start, - int32 end); - int32 PositionAt(view_focus focus, BPoint point, - view_focus* _newFocus = NULL); + BRect DataBounds(bool inView = false) const; + BRect SelectionFrame(view_focus which, int32 start, + int32 end); + int32 PositionAt(view_focus focus, BPoint point, + view_focus* _newFocus = NULL); - void DrawSelectionFrame(view_focus which); - void DrawSelectionBlock(view_focus which, int32 start, - int32 end); - void DrawSelectionBlock(view_focus which); - void DrawSelection(bool frameOnly = false); - void SetActive(bool active); - void SetFocus(view_focus which); + void DrawSelectionFrame(view_focus which); + void DrawSelectionBlock(view_focus which, + int32 start, int32 end); + void DrawSelectionBlock(view_focus which); + void DrawSelection(bool frameOnly = false); + void SetActive(bool active); + void SetFocus(view_focus which); - void UpdateFromEditor(BMessage* message = NULL); - void ConvertLine(char* line, off_t offset, - const uint8* buffer, size_t size); + void UpdateFromEditor(BMessage* message = NULL); + void ConvertLine(char* line, off_t offset, + const uint8* buffer, size_t size); - bool AcceptsDrop(const BMessage* message); - void InitiateDrag(view_focus focus); - void Copy(); - void Paste(); + bool AcceptsDrop(const BMessage* message); + void InitiateDrag(view_focus focus); + void Copy(); + void Paste(); - DataEditor& fEditor; - uint8* fData; - size_t fDataSize; - off_t fFileSize; - size_t fSizeInView; - off_t fOffset; - float fAscent; - int32 fFontHeight; - float fCharWidth; - view_focus fFocus; - base_type fBase; - bool fIsActive; - int32 fStart, fEnd; - int32 fMouseSelectionStart; - int32 fKeySelectionStart; - int32 fBitPosition; - bool fFitFontSize; - int32 fDragMessageSize; - int32 fStoredStart, fStoredEnd; +private: + DataEditor& fEditor; + uint8* fData; + size_t fDataSize; + off_t fFileSize; + size_t fSizeInView; + off_t fOffset; + float fAscent; + int32 fFontHeight; + float fCharWidth; + view_focus fFocus; + base_type fBase; + bool fIsActive; + int32 fStart; + int32 fEnd; + int32 fMouseSelectionStart; + int32 fKeySelectionStart; + int32 fBitPosition; + bool fFitFontSize; + int32 fDragMessageSize; + int32 fStoredStart; + int32 fStoredEnd; }; + static const uint32 kMsgBaseType = 'base'; static const uint32 kMsgUpdateData = 'updt'; static const uint32 kMsgSetSelection = 'ssel'; @@ -126,4 +131,5 @@ static const uint32 kDataViewPreferredSize = 'dvps'; extern bool is_valid_utf8(uint8* data, size_t size); + #endif /* DATA_VIEW_H */ diff --git a/src/apps/diskprobe/DiskProbe.cpp b/src/apps/diskprobe/DiskProbe.cpp index 3891fe373c..c64a146ca2 100644 --- a/src/apps/diskprobe/DiskProbe.cpp +++ b/src/apps/diskprobe/DiskProbe.cpp @@ -1,6 +1,6 @@ /* - * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ @@ -36,7 +36,7 @@ #define B_TRANSLATION_CONTEXT "DiskProbe" -const char *kSignature = "application/x-vnd.Haiku-DiskProbe"; +const char* kSignature = "application/x-vnd.Haiku-DiskProbe"; static const uint32 kMsgDiskProbeSettings = 'DPst'; static const uint32 kCascadeOffset = 20; @@ -51,50 +51,54 @@ struct disk_probe_settings { 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, }; class Settings { - public: - Settings(); - ~Settings(); +public: + Settings(); + ~Settings(); - const BMessage &Message() const { return fMessage; } - void UpdateFrom(BMessage *message); + const BMessage& Message() const { return fMessage; } + void UpdateFrom(BMessage* message); - private: - status_t Open(BFile *file, int32 mode); +private: + status_t Open(BFile* file, int32 mode); - BMessage fMessage; - bool fUpdated; +private: + BMessage fMessage; + bool fUpdated; }; class DiskProbe : public BApplication { - public: - DiskProbe(); - virtual ~DiskProbe(); +public: + DiskProbe(); + virtual ~DiskProbe(); - virtual void ReadyToRun(); + virtual void ReadyToRun(); - virtual void RefsReceived(BMessage *message); - virtual void ArgvReceived(int32 argc, char **argv); - virtual void MessageReceived(BMessage *message); + virtual void RefsReceived(BMessage* message); + virtual void ArgvReceived(int32 argc, char** argv); + virtual void MessageReceived(BMessage* message); - virtual bool QuitRequested(); + virtual bool QuitRequested(); - private: - status_t Probe(BEntry &entry, const char *attribute = NULL); +private: + status_t Probe(BEntry& entry, + const char* attribute = NULL); - Settings fSettings; - BFilePanel *fFilePanel; - BWindow *fOpenWindow; - FindWindow *fFindWindow; - uint32 fWindowCount; - BRect fWindowFrame; - BMessenger fFindTarget; +private: + Settings fSettings; + BFilePanel* fFilePanel; + BWindow* fOpenWindow; + FindWindow* fFindWindow; + uint32 fWindowCount; + BRect fWindowFrame; + BMessenger fFindTarget; }; @@ -123,7 +127,7 @@ Settings::Settings() if (Open(&file, B_READ_ONLY) != B_OK) 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 disk_probe_settings settings; @@ -200,7 +204,7 @@ Settings::~Settings() status_t -Settings::Open(BFile *file, int32 mode) +Settings::Open(BFile* file, int32 mode) { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) @@ -213,7 +217,7 @@ Settings::Open(BFile *file, int32 mode) void -Settings::UpdateFrom(BMessage *message) +Settings::UpdateFrom(BMessage* message) { BRect frame; if (message->FindRect("window_frame", &frame) == B_OK) @@ -271,27 +275,26 @@ DiskProbe::ReadyToRun() } -/** 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 - * be opened. - * It will check if there already is a window that probes the - * file in question and will activate it in that case. - * This function must be called with the application looper locked. - */ - +/*! 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 + be opened. + It will check if there already is a window that probes the + file in question and will activate it in that case. + This function must be called with the application looper locked. +*/ status_t -DiskProbe::Probe(BEntry &entry, const char *attribute) +DiskProbe::Probe(BEntry& entry, const char* attribute) { entry_ref ref; status_t status = entry.GetRef(&ref); if (status < B_OK) return status; - ProbeWindow *lastWindow(NULL); + ProbeWindow* lastWindow(NULL); // Do we already have that window open? for (int32 i = CountWindows(); i-- > 0; ) { - ProbeWindow *window = dynamic_cast(WindowAt(i)); + ProbeWindow* window = dynamic_cast(WindowAt(i)); if (window == NULL) continue; @@ -318,16 +321,17 @@ DiskProbe::Probe(BEntry &entry, const char *attribute) rect.OffsetBy(kCascadeOffset, kCascadeOffset); - BWindow *window; - if (attribute != NULL) - window = new AttributeWindow(rect, &ref, attribute, &fSettings.Message()); - else + BWindow* window; + if (attribute != NULL) { + window = new AttributeWindow(rect, &ref, attribute, + &fSettings.Message()); + } else window = new FileWindow(rect, &ref, &fSettings.Message()); window->Show(); - /* adjust the cascading... we can only do this after the window was created - * to adjust to the real size */ + // Adjust the cascading... we can only do this after the window was created + // to adjust to the real size. rect.right = window->Frame().right; rect.bottom = window->Frame().bottom; @@ -352,14 +356,14 @@ DiskProbe::Probe(BEntry &entry, const char *attribute) void -DiskProbe::RefsReceived(BMessage *message) +DiskProbe::RefsReceived(BMessage* message) { bool traverseLinks = (modifiers() & B_SHIFT_KEY) == 0; int32 index = 0; entry_ref ref; while (message->FindRef("refs", index++, &ref) == B_OK) { - const char *attribute = NULL; + const char* attribute = NULL; if (message->FindString("attributes", index - 1, &attribute) == B_OK) traverseLinks = false; @@ -389,9 +393,9 @@ DiskProbe::RefsReceived(BMessage *message) void -DiskProbe::ArgvReceived(int32 argc, char **argv) +DiskProbe::ArgvReceived(int32 argc, char** argv) { - BMessage *message = CurrentMessage(); + BMessage* message = CurrentMessage(); BDirectory currentDirectory; if (message) @@ -425,7 +429,7 @@ DiskProbe::ArgvReceived(int32 argc, char **argv) void -DiskProbe::MessageReceived(BMessage *message) +DiskProbe::MessageReceived(BMessage* message) { switch (message->what) { case kMsgOpenOpenWindow: @@ -472,8 +476,8 @@ DiskProbe::MessageReceived(BMessage *message) if (fFindWindow == NULL) { // open it! - fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80), *message, - target, &fSettings.Message()); + fFindWindow = new FindWindow(fWindowFrame.OffsetByCopy(80, 80), + *message, target, &fSettings.Message()); fFindWindow->Show(); } else fFindWindow->Activate(); @@ -506,7 +510,7 @@ DiskProbe::QuitRequested() int -main(int argc, char **argv) +main(int argc, char** argv) { DiskProbe probe; diff --git a/src/apps/diskprobe/DiskProbe.h b/src/apps/diskprobe/DiskProbe.h index a9ab0c8f91..5a1f60643d 100644 --- a/src/apps/diskprobe/DiskProbe.h +++ b/src/apps/diskprobe/DiskProbe.h @@ -1,7 +1,7 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the MIT License. -*/ +/* + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. + */ #ifndef DISK_PROBE_H #define DISK_PROBE_H @@ -9,7 +9,7 @@ #include -extern const char *kSignature; +extern const char* kSignature; static const uint32 kMsgOpenFilePanel = 'opFp'; static const uint32 kMsgOpenOpenWindow = 'opOw'; @@ -22,4 +22,5 @@ static const uint32 kMsgFindWindowClosed = 'clFw'; static const uint32 kMsgFindTarget = 'FTgt'; static const uint32 kMsgFind = 'find'; + #endif /* DISK_PROBE_H */ diff --git a/src/apps/diskprobe/FileWindow.h b/src/apps/diskprobe/FileWindow.h index 2893eced2a..19e5022e76 100644 --- a/src/apps/diskprobe/FileWindow.h +++ b/src/apps/diskprobe/FileWindow.h @@ -1,25 +1,29 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the MIT License. -*/ +/* + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. + */ #ifndef FILE_WINDOW_H #define FILE_WINDOW_H #include "ProbeWindow.h" + class ProbeView; class FileWindow : public ProbeWindow { - public: - FileWindow(BRect rect, entry_ref *ref, const BMessage *settings = NULL); +public: + FileWindow(BRect rect, entry_ref* ref, + const BMessage* settings = NULL); - virtual bool QuitRequested(); - virtual bool Contains(const entry_ref &ref, const char *attribute); + virtual bool QuitRequested(); + virtual bool Contains(const entry_ref& ref, + const char* attribute); - private: - ProbeView *fProbeView; +private: + ProbeView* fProbeView; }; + #endif /* FILE_WINDOW_H */ diff --git a/src/apps/diskprobe/FindWindow.h b/src/apps/diskprobe/FindWindow.h index 09df172853..da496404fc 100644 --- a/src/apps/diskprobe/FindWindow.h +++ b/src/apps/diskprobe/FindWindow.h @@ -1,6 +1,6 @@ /* - * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef FIND_WINDOW_H #define FIND_WINDOW_H @@ -9,6 +9,7 @@ #include #include + class BCheckBox; class BMenu; @@ -22,23 +23,25 @@ enum find_mode { class FindWindow : public BWindow { - public: - FindWindow(BRect rect, BMessage &previous, BMessenger &target, - const BMessage *settings = NULL); - virtual ~FindWindow(); +public: + FindWindow(BRect rect, BMessage& previous, + BMessenger& target, + const BMessage* settings = NULL); + virtual ~FindWindow(); - virtual void WindowActivated(bool active); - virtual void MessageReceived(BMessage *message); - virtual bool QuitRequested(); - virtual void Show(); + virtual void WindowActivated(bool active); + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + virtual void Show(); - void SetTarget(BMessenger &target); + void SetTarget(BMessenger& target); - private: - BMessenger fTarget; - FindTextView *fTextView; - BCheckBox *fCaseCheckBox; - BMenu *fMenu; +private: + BMessenger fTarget; + FindTextView* fTextView; + BCheckBox* fCaseCheckBox; + BMenu* fMenu; }; + #endif /* FIND_WINDOW_H */ diff --git a/src/apps/diskprobe/OpenWindow.h b/src/apps/diskprobe/OpenWindow.h index 4df1c635ce..d372da2ddf 100644 --- a/src/apps/diskprobe/OpenWindow.h +++ b/src/apps/diskprobe/OpenWindow.h @@ -1,6 +1,6 @@ /* - * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef OPEN_WINDOW_H #define OPEN_WINDOW_H @@ -8,6 +8,7 @@ #include + class BEntry; class BMenu; @@ -27,4 +28,5 @@ private: BMenu* fDevicesMenu; }; + #endif /* OPEN_WINDOW_H */ diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index b8683f93a0..b9ee59579a 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -73,138 +73,148 @@ static const uint32 kMsgStopFind = 'sfnd'; class IconView : public BView { - public: - IconView(const entry_ref *ref, bool isDevice); - virtual ~IconView(); +public: + IconView(const entry_ref* ref, bool isDevice); + virtual ~IconView(); - virtual void AttachedToWindow(); - virtual void Draw(BRect updateRect); + virtual void AttachedToWindow(); + virtual void Draw(BRect updateRect); - void UpdateIcon(); + void UpdateIcon(); - private: - entry_ref fRef; - bool fIsDevice; - BBitmap *fBitmap; +private: + entry_ref fRef; + bool fIsDevice; + BBitmap* fBitmap; }; class PositionSlider : public BSlider { - public: - PositionSlider(const char *name, BMessage *message, off_t size, - uint32 blockSize); - virtual ~PositionSlider(); +public: + PositionSlider(const char* name, + BMessage* message, off_t size, + uint32 blockSize); + virtual ~PositionSlider(); #ifdef DRAW_SLIDER_BAR - virtual void DrawBar(); + virtual void DrawBar(); #endif - off_t Position() const; - off_t Size() const { return fSize; } - uint32 BlockSize() const { return fBlockSize; } + off_t Position() const; + off_t Size() const { return fSize; } + uint32 BlockSize() const { return fBlockSize; } - virtual void SetPosition(float position); - void SetPosition(off_t position); - void SetSize(off_t size); - void SetBlockSize(uint32 blockSize); + virtual void SetPosition(float position); + void SetPosition(off_t position); + void SetSize(off_t size); + void SetBlockSize(uint32 blockSize); - private: - void Reset(); +private: + void Reset(); - static const int32 kMaxSliderLimit = 0x7fffff80; - // this is the maximum value that BSlider seem to work with fine +private: + static const int32 kMaxSliderLimit = 0x7fffff80; + // this is the maximum value that BSlider seem to work with fine - off_t fSize; - uint32 fBlockSize; + off_t fSize; + uint32 fBlockSize; }; class HeaderView : public BGridView, public BInvoker { - public: - HeaderView(const entry_ref *ref, DataEditor &editor); - virtual ~HeaderView(); +public: + HeaderView(const entry_ref* ref, + DataEditor& editor); + virtual ~HeaderView(); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MessageReceived(BMessage *message); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + virtual void MessageReceived(BMessage* message); - base_type Base() const { return fBase; } - void SetBase(base_type); + base_type Base() const { return fBase; } + void SetBase(base_type); - off_t CursorOffset() const { return fPosition % fBlockSize; } - off_t Position() const { return fPosition; } - uint32 BlockSize() const { return fBlockSize; } - void SetTo(off_t position, uint32 blockSize); + off_t CursorOffset() const + { return fPosition % fBlockSize; } + off_t Position() const { return fPosition; } + uint32 BlockSize() const { return fBlockSize; } + void SetTo(off_t position, uint32 blockSize); - void UpdateIcon(); + void UpdateIcon(); - private: - void FormatValue(char *buffer, size_t bufferSize, off_t value); - void UpdatePositionViews(bool all = true); - void UpdateOffsetViews(bool all = true); - void UpdateFileSizeView(); - void NotifyTarget(); +private: + void FormatValue(char* buffer, size_t bufferSize, + off_t value); + void UpdatePositionViews(bool all = true); + void UpdateOffsetViews(bool all = true); + void UpdateFileSizeView(); + void NotifyTarget(); - const char *fAttribute; - off_t fFileSize; - uint32 fBlockSize; - base_type fBase; - off_t fPosition; - off_t fLastPosition; +private: + const char* fAttribute; + off_t fFileSize; + uint32 fBlockSize; + base_type fBase; + off_t fPosition; + off_t fLastPosition; - BTextControl *fTypeControl; - BTextControl *fPositionControl; - BStringView *fPathView; - BStringView *fSizeView; - BTextControl *fOffsetControl; - BTextControl *fFileOffsetControl; - PositionSlider *fPositionSlider; - IconView *fIconView; - BButton *fStopButton; + BTextControl* fTypeControl; + BTextControl* fPositionControl; + BStringView* fPathView; + BStringView* fSizeView; + BTextControl* fOffsetControl; + BTextControl* fFileOffsetControl; + PositionSlider* fPositionSlider; + IconView* fIconView; + BButton* fStopButton; }; class TypeMenuItem : public BMenuItem { - public: - TypeMenuItem(const char *name, const char *type, BMessage *message); +public: + TypeMenuItem(const char* name, const char* type, + BMessage* message); - virtual void GetContentSize(float *_width, float *_height); - virtual void DrawContent(); + virtual void GetContentSize(float* _width, float* _height); + virtual void DrawContent(); - private: - BString fType; +private: + BString fType; }; class EditorLooper : public BLooper { - public: - EditorLooper(const char *name, DataEditor &editor, BMessenger messenger); - virtual ~EditorLooper(); +public: + EditorLooper(const char* name, + DataEditor& editor, BMessenger messenger); + virtual ~EditorLooper(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage* message); - bool FindIsRunning() const { return !fQuitFind; } - void Find(off_t startAt, const uint8 *data, size_t dataSize, - bool caseInsensitive, BMessenger progressMonitor); - void QuitFind(); + bool FindIsRunning() const { return !fQuitFind; } + void Find(off_t startAt, const uint8* data, + size_t dataSize, bool caseInsensitive, + BMessenger progressMonitor); + void QuitFind(); - private: - DataEditor &fEditor; - BMessenger fMessenger; - volatile bool fQuitFind; +private: + DataEditor& fEditor; + BMessenger fMessenger; + volatile bool fQuitFind; }; class TypeView : public BView { - public: - TypeView(BRect rect, const char* name, int32 index, - DataEditor& editor, int32 resizingMode); - virtual ~TypeView(); +public: + TypeView(BRect rect, const char* name, + int32 index, DataEditor& editor, + int32 resizingMode); + virtual ~TypeView(); - virtual void FrameResized(float width, float height); + virtual void FrameResized(float width, float height); - private: - BView* fTypeEditorView; +private: + BView* fTypeEditorView; }; @@ -212,7 +222,7 @@ class TypeView : public BView { static void -get_type_string(char *buffer, size_t bufferSize, type_code type) +get_type_string(char* buffer, size_t bufferSize, type_code type) { for (int32 i = 0; i < 4; i++) { buffer[i] = type >> (24 - 8 * i); @@ -228,7 +238,7 @@ get_type_string(char *buffer, size_t bufferSize, type_code type) // #pragma mark - IconView -IconView::IconView(const entry_ref *ref, bool isDevice) +IconView::IconView(const entry_ref* ref, bool isDevice) : BView(NULL, B_WILL_DRAW), fRef(*ref), fIsDevice(isDevice), @@ -309,9 +319,10 @@ IconView::UpdateIcon() // #pragma mark - PositionSlider -PositionSlider::PositionSlider(const char *name, BMessage *message, +PositionSlider::PositionSlider(const char* name, BMessage* message, off_t size, uint32 blockSize) - : BSlider(name, NULL, message, 0, kMaxSliderLimit, B_HORIZONTAL, + : + BSlider(name, NULL, message, 0, kMaxSliderLimit, B_HORIZONTAL, B_TRIANGLE_THUMB), fSize(size), fBlockSize(blockSize) @@ -334,7 +345,7 @@ PositionSlider::~PositionSlider() void PositionSlider::DrawBar() { - BView *view = OffscreenView(); + BView* view = OffscreenView(); BRect barFrame = BarFrame(); BRect frame = barFrame.InsetByCopy(1, 1); @@ -471,7 +482,7 @@ PositionSlider::SetBlockSize(uint32 blockSize) // #pragma mark - HeaderView -HeaderView::HeaderView(const entry_ref *ref, DataEditor &editor) +HeaderView::HeaderView(const entry_ref* ref, DataEditor& editor) : BGridView("probeHeader", B_USE_SMALL_SPACING, B_USE_SMALL_SPACING), fAttribute(editor.Attribute()), fFileSize(editor.FileSize()), @@ -495,7 +506,7 @@ HeaderView::HeaderView(const entry_ref *ref, DataEditor &editor) boldFont.SetSize(plainFont.Size() * 0.83); plainFont.SetSize(plainFont.Size() * 0.83); - BStringView *stringView = new BStringView( + BStringView* stringView = new BStringView( B_EMPTY_STRING, editor.IsAttribute() ? B_TRANSLATE("Attribute: ") : editor.IsDevice() ? B_TRANSLATE("Device: ") : B_TRANSLATE("File: ")); @@ -620,7 +631,7 @@ HeaderView::AttachedToWindow() fFileOffsetControl->SetTarget(this); fPositionSlider->SetTarget(this); - BMessage *message; + BMessage* message; Window()->AddShortcut(B_HOME, B_COMMAND_KEY, message = new BMessage(kMsgPositionUpdate), this); message->AddInt64("block", 0); @@ -654,7 +665,7 @@ HeaderView::UpdateIcon() void -HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value) +HeaderView::FormatValue(char* buffer, size_t bufferSize, off_t value) { snprintf(buffer, bufferSize, fBase == kHexBase ? "0x%" B_PRIxOFF : "%" B_PRIdOFF, value); @@ -740,7 +751,7 @@ HeaderView::NotifyTarget() void -HeaderView::MessageReceived(BMessage *message) +HeaderView::MessageReceived(BMessage* message) { switch (message->what) { case B_OBSERVER_NOTICE_CHANGE: { @@ -910,16 +921,17 @@ HeaderView::MessageReceived(BMessage *message) It is used to display the attribute and type in the attributes menu. It does not mix nicely with short cuts. */ -TypeMenuItem::TypeMenuItem(const char *name, const char *type, - BMessage *message) - : BMenuItem(name, message), +TypeMenuItem::TypeMenuItem(const char* name, const char* type, + BMessage* message) + : + BMenuItem(name, message), fType(type) { } void -TypeMenuItem::GetContentSize(float *_width, float *_height) +TypeMenuItem::GetContentSize(float* _width, float* _height) { BMenuItem::GetContentSize(_width, _height); @@ -963,7 +975,7 @@ TypeMenuItem::DrawContent() this looper. Also, it will run the find action in the editor. */ -EditorLooper::EditorLooper(const char *name, DataEditor &editor, +EditorLooper::EditorLooper(const char* name, DataEditor& editor, BMessenger target) : BLooper(name), fEditor(editor), @@ -981,7 +993,7 @@ EditorLooper::~EditorLooper() void -EditorLooper::MessageReceived(BMessage *message) +EditorLooper::MessageReceived(BMessage* message) { switch (message->what) { case kMsgPositionUpdate: @@ -1038,8 +1050,8 @@ EditorLooper::MessageReceived(BMessage *message) bool caseInsensitive = !message->FindBool("case_sensitive"); ssize_t dataSize; - const uint8 *data; - if (message->FindData("data", B_RAW_TYPE, (const void **)&data, + const uint8* data; + if (message->FindData("data", B_RAW_TYPE, (const void**)&data, &dataSize) == B_OK) Find(startAt, data, dataSize, caseInsensitive, progressMonitor); } @@ -1052,7 +1064,7 @@ EditorLooper::MessageReceived(BMessage *message) void -EditorLooper::Find(off_t startAt, const uint8 *data, size_t dataSize, +EditorLooper::Find(off_t startAt, const uint8* data, size_t dataSize, bool caseInsensitive, BMessenger progressMonitor) { fQuitFind = false; @@ -1062,7 +1074,7 @@ EditorLooper::Find(off_t startAt, const uint8 *data, size_t dataSize, bigtime_t startTime = system_time(); off_t foundAt = fEditor.Find(startAt, data, dataSize, caseInsensitive, - true, progressMonitor, &fQuitFind); + true, progressMonitor, &fQuitFind); if (foundAt >= B_OK) { fEditor.SetViewOffset(foundAt); @@ -1151,8 +1163,8 @@ TypeView::FrameResized(float width, float height) // #pragma mark - ProbeView -ProbeView::ProbeView(entry_ref *ref, const char *attribute, - const BMessage *settings) +ProbeView::ProbeView(entry_ref* ref, const char* attribute, + const BMessage* settings) : BView("probeView", B_WILL_DRAW), fPrintSettings(NULL), fTypeView(NULL), @@ -1209,7 +1221,7 @@ ProbeView::DetachedFromWindow() void -ProbeView::_UpdateAttributesMenu(BMenu *menu) +ProbeView::_UpdateAttributesMenu(BMenu* menu) { // remove old contents @@ -1241,7 +1253,7 @@ ProbeView::_UpdateAttributesMenu(BMenu *menu) break; } - BMessage *message = new BMessage(B_REFS_RECEIVED); + BMessage* message = new BMessage(B_REFS_RECEIVED); message->AddRef("refs", &fEditor.AttributeRef()); message->AddString("attributes", attribute); @@ -1252,7 +1264,7 @@ ProbeView::_UpdateAttributesMenu(BMenu *menu) if (menu->CountItems() == 0) { // if there are no attributes, add an item to the menu // that says so - BMenuItem *item = new BMenuItem(B_TRANSLATE_COMMENT("none", + BMenuItem* item = new BMenuItem(B_TRANSLATE_COMMENT("none", "No attributes"), NULL); item->SetEnabled(false); menu->AddItem(item); @@ -1276,7 +1288,7 @@ ProbeView::AddSaveMenuItems(BMenu* menu, int32 index) void ProbeView::AddPrintMenuItems(BMenu* menu, int32 index) { - BMenuItem *item; + BMenuItem* item; menu->AddItem(item = new BMenuItem(B_TRANSLATE("Page setup" B_UTF8_ELLIPSIS), new BMessage(kMsgPageSetup)), index++); item->SetTarget(this); @@ -1343,45 +1355,47 @@ ProbeView::AttachedToWindow() // Add menu to window - BMenuBar *bar = Window()->KeyMenuBar(); + BMenuBar* bar = Window()->KeyMenuBar(); if (bar == NULL) { // there is none? Well, but we really want to have one bar = new BMenuBar(""); Window()->AddChild(bar); - BMenu *menu = new BMenu(fEditor.IsAttribute() - ? B_TRANSLATE("Attribute") : fEditor.IsDevice() ? B_TRANSLATE("Device") : B_TRANSLATE("File")); + BMenu* menu = new BMenu(fEditor.IsAttribute() + ? B_TRANSLATE("Attribute") : fEditor.IsDevice() + ? B_TRANSLATE("Device") : B_TRANSLATE("File")); AddSaveMenuItems(menu, 0); menu->AddSeparatorItem(); AddPrintMenuItems(menu, menu->CountItems()); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_CLOSE_REQUESTED), - 'W')); + menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), + new BMessage(B_CLOSE_REQUESTED), 'W')); bar->AddItem(menu); } // "Edit" menu - BMenu *menu = new BMenu(B_TRANSLATE("Edit")); - BMenuItem *item; - menu->AddItem(fUndoMenuItem = new BMenuItem(B_TRANSLATE("Undo"), new BMessage(B_UNDO), - 'Z')); + BMenu* menu = new BMenu(B_TRANSLATE("Edit")); + BMenuItem* item; + menu->AddItem(fUndoMenuItem = new BMenuItem(B_TRANSLATE("Undo"), + new BMessage(B_UNDO), 'Z')); fUndoMenuItem->SetEnabled(fEditor.CanUndo()); fUndoMenuItem->SetTarget(fDataView); - menu->AddItem(fRedoMenuItem = new BMenuItem(B_TRANSLATE("Redo"), new BMessage(B_REDO), - 'Z', B_SHIFT_KEY)); + menu->AddItem(fRedoMenuItem = new BMenuItem(B_TRANSLATE("Redo"), + new BMessage(B_REDO), 'Z', B_SHIFT_KEY)); fRedoMenuItem->SetEnabled(fEditor.CanRedo()); fRedoMenuItem->SetTarget(fDataView); 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()); - menu->AddItem(fPasteMenuItem = new BMenuItem(B_TRANSLATE("Paste"), new BMessage(B_PASTE), - 'V')); + menu->AddItem(fPasteMenuItem = new BMenuItem(B_TRANSLATE("Paste"), + new BMessage(B_PASTE), 'V')); fPasteMenuItem->SetTarget(NULL, Window()); _CheckClipboard(); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"), new BMessage(B_SELECT_ALL), - 'A')); + menu->AddItem(item = new BMenuItem(B_TRANSLATE("Select all"), + new BMessage(B_SELECT_ALL), 'A')); item->SetTarget(NULL, Window()); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS), @@ -1396,19 +1410,21 @@ ProbeView::AttachedToWindow() // "Block" menu menu = new BMenu(B_TRANSLATE("Block")); - BMessage *message = new BMessage(kMsgPositionUpdate); + BMessage* message = new BMessage(kMsgPositionUpdate); 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); message = new BMessage(kMsgPositionUpdate); 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); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("Back"), new BMessage(kMsgLastPosition), - 'J')); + menu->AddItem(item = new BMenuItem(B_TRANSLATE("Back"), + new BMessage(kMsgLastPosition), 'J')); item->SetTarget(fHeaderView); - BMenu *subMenu = new BMenu(B_TRANSLATE("Selection")); + BMenu* subMenu = new BMenu(B_TRANSLATE("Selection")); message = new BMessage(kMsgPositionUpdate); message->AddInt64("block", 0); subMenu->AddItem(fNativeMenuItem = new BMenuItem("", message, 'K')); @@ -1565,7 +1581,7 @@ void ProbeView::_UpdateSelectionMenuItems(int64 start, int64 end) { int64 position = 0; - const uint8 *data = fDataView->DataAt(start); + const uint8* data = fDataView->DataAt(start); if (data == NULL) { fNativeMenuItem->SetEnabled(false); fSwappedMenuItem->SetEnabled(false); @@ -1620,11 +1636,11 @@ void ProbeView::_UpdateBookmarkMenuItems() { for (int32 i = 2; i < fBookmarkMenu->CountItems(); i++) { - BMenuItem *item = fBookmarkMenu->ItemAt(i); + BMenuItem* item = fBookmarkMenu->ItemAt(i); if (item == NULL) break; - BMessage *message = item->Message(); + BMessage* message = item->Message(); if (message == NULL) break; @@ -1656,10 +1672,10 @@ ProbeView::_AddBookmark(off_t position) off_t block = position / fEditor.BlockSize(); off_t bookmark = -1; - BMenuItem *item; + BMenuItem* item; int32 i; for (i = 2; (item = fBookmarkMenu->ItemAt(i)) != NULL; i++) { - BMessage *message = item->Message(); + BMessage* message = item->Message(); if (message != NULL && message->FindInt64("block", &bookmark) == B_OK) { if (block <= bookmark) break; @@ -1676,7 +1692,7 @@ ProbeView::_AddBookmark(off_t position) else snprintf(buffer, sizeof(buffer), B_TRANSLATE("Block %Ld (0x%Lx)"), block, block); - BMessage *message; + BMessage* message; item = new BMenuItem(buffer, message = new BMessage(kMsgPositionUpdate)); item->SetTarget(fHeaderView); if (count < 12) @@ -1737,9 +1753,9 @@ ProbeView::_CheckClipboard() return; bool hasData = false; - BMessage *clip; + BMessage* clip; if ((clip = be_clipboard->Data()) != NULL) { - const void *data; + const void* data; ssize_t size; if (clip->FindData(B_FILE_MIME_TYPE, B_MIME_TYPE, &data, &size) == B_OK || clip->FindData("text/plain", B_MIME_TYPE, &data, &size) == B_OK) @@ -1848,7 +1864,7 @@ ProbeView::QuitRequested() void -ProbeView::MessageReceived(BMessage *message) +ProbeView::MessageReceived(BMessage* message) { switch (message->what) { case B_SAVE_REQUESTED: @@ -1961,13 +1977,14 @@ ProbeView::MessageReceived(BMessage *message) case kMsgFind: { - const uint8 *data; + const uint8* data; 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 - BMessage *itemMessage = fFindAgainMenuItem->Message(); - if (itemMessage == NULL - || itemMessage->FindData("data", B_RAW_TYPE, (const void **)&data, &size) != B_OK) { + BMessage* itemMessage = fFindAgainMenuItem->Message(); + if (itemMessage == NULL || itemMessage->FindData("data", + B_RAW_TYPE, (const void**)&data, &size) != B_OK) { // this shouldn't ever happen, but well... beep(); break; @@ -2000,7 +2017,7 @@ ProbeView::MessageReceived(BMessage *message) break; case B_ATTR_CHANGED: { - const char *name; + const char* name; if (message->FindString("attr", &name) != B_OK) break; @@ -2008,9 +2025,9 @@ ProbeView::MessageReceived(BMessage *message) if (!strcmp(name, fEditor.Attribute())) fEditor.ForceUpdate(); } else { - BMenuBar *bar = Window()->KeyMenuBar(); + BMenuBar* bar = Window()->KeyMenuBar(); if (bar != NULL) { - BMenuItem *item = bar->FindItem("Attributes"); + BMenuItem* item = bar->FindItem("Attributes"); if (item != NULL && item->Submenu() != NULL) _UpdateAttributesMenu(item->Submenu()); } diff --git a/src/apps/diskprobe/ProbeView.h b/src/apps/diskprobe/ProbeView.h index 65cada0393..191cf0c041 100644 --- a/src/apps/diskprobe/ProbeView.h +++ b/src/apps/diskprobe/ProbeView.h @@ -1,6 +1,6 @@ /* - * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef PROBE_VIEW_H #define PROBE_VIEW_H @@ -23,55 +23,59 @@ class EditorLooper; class ProbeView : public BView { - public: - ProbeView(entry_ref* ref, const char* attribute = NULL, - const BMessage* settings = NULL); - virtual ~ProbeView(); +public: + ProbeView(entry_ref* ref, + const char* attribute = NULL, + const BMessage* settings = NULL); + virtual ~ProbeView(); - virtual void DetachedFromWindow(); - virtual void AttachedToWindow(); - virtual void AllAttached(); - virtual void WindowActivated(bool active); - virtual void MessageReceived(BMessage* message); + virtual void DetachedFromWindow(); + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void WindowActivated(bool active); + virtual void MessageReceived(BMessage* message); - void AddSaveMenuItems(BMenu* menu, int32 index); - void AddPrintMenuItems(BMenu* menu, int32 index); - void AddViewAsMenuItems(); + void AddSaveMenuItems(BMenu* menu, int32 index); + void AddPrintMenuItems(BMenu* menu, int32 index); + void AddViewAsMenuItems(); - bool QuitRequested(); + bool QuitRequested(); - DataEditor& Editor() { return fEditor; } + DataEditor& Editor() { return fEditor; } - private: - void _UpdateAttributesMenu(BMenu* menu); - void _UpdateSelectionMenuItems(int64 start, int64 end); - void _UpdateBookmarkMenuItems(); - void _AddBookmark(off_t position); - void _RemoveTypeEditor(); - void _SetTypeEditor(int32 index); - void _CheckClipboard(); - status_t _PageSetup(); - void _Print(); - status_t _Save(); +private: + void _UpdateAttributesMenu(BMenu* menu); + void _UpdateSelectionMenuItems(int64 start, + int64 end); + void _UpdateBookmarkMenuItems(); + void _AddBookmark(off_t position); + void _RemoveTypeEditor(); + void _SetTypeEditor(int32 index); + void _CheckClipboard(); + status_t _PageSetup(); + void _Print(); + status_t _Save(); - DataEditor fEditor; - EditorLooper* fEditorLooper; - HeaderView* fHeaderView; - DataView* fDataView; - BScrollView* fScrollView; - BMenuItem* fPasteMenuItem; - BMenuItem* fUndoMenuItem; - BMenuItem* fRedoMenuItem; - BMenuItem* fNativeMenuItem; - BMenuItem* fSwappedMenuItem; - BMenuItem* fSaveMenuItem; - BMessage* fPrintSettings; - BMenu* fBookmarkMenu; - BView* fTypeView; +private: + DataEditor fEditor; + EditorLooper* fEditorLooper; + HeaderView* fHeaderView; + DataView* fDataView; + BScrollView* fScrollView; + BMenuItem* fPasteMenuItem; + BMenuItem* fUndoMenuItem; + BMenuItem* fRedoMenuItem; + BMenuItem* fNativeMenuItem; + BMenuItem* fSwappedMenuItem; + BMenuItem* fSaveMenuItem; + BMessage* fPrintSettings; + BMenu* fBookmarkMenu; + BView* fTypeView; - BMenuItem* fFindAgainMenuItem; - const uint8* fLastSearch; - size_t fLastSearchSize; + BMenuItem* fFindAgainMenuItem; + const uint8* fLastSearch; + size_t fLastSearchSize; }; + #endif /* PROBE_VIEW_H */ diff --git a/src/apps/diskprobe/ProbeWindow.cpp b/src/apps/diskprobe/ProbeWindow.cpp index a39e4a6104..e8bd0d4277 100644 --- a/src/apps/diskprobe/ProbeWindow.cpp +++ b/src/apps/diskprobe/ProbeWindow.cpp @@ -1,18 +1,33 @@ /* - * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * 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 "DiskProbe.h" #include #include +#include "DiskProbe.h" -ProbeWindow::ProbeWindow(BRect rect, entry_ref *ref) - : BWindow(rect, ref->name, B_DOCUMENT_WINDOW, + +ProbeWindow::ProbeWindow(BRect rect, entry_ref* ref) + : + BWindow(rect, ref->name, B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fRef(*ref) { @@ -25,11 +40,11 @@ ProbeWindow::~ProbeWindow() void -ProbeWindow::MessageReceived(BMessage *message) +ProbeWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_MOUSE_WHEEL_CHANGED: - if (BView *view = FindView("dataView")) + if (BView* view = FindView("dataView")) view->MessageReceived(message); break; diff --git a/src/apps/diskprobe/ProbeWindow.h b/src/apps/diskprobe/ProbeWindow.h index e762f903cc..5e974c590b 100644 --- a/src/apps/diskprobe/ProbeWindow.h +++ b/src/apps/diskprobe/ProbeWindow.h @@ -1,7 +1,7 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the MIT License. -*/ +/* + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. + */ #ifndef PROBE_WINDOW_H #define PROBE_WINDOW_H @@ -11,20 +11,22 @@ class ProbeWindow : public BWindow { - public: - ProbeWindow(BRect rect, entry_ref *ref); - virtual ~ProbeWindow(); +public: + ProbeWindow(BRect rect, entry_ref* ref); + virtual ~ProbeWindow(); - virtual void MessageReceived(BMessage *message); - virtual bool QuitRequested(); + virtual void MessageReceived(BMessage* message); + 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: - const entry_ref &Ref() const { return fRef; } +protected: + const entry_ref& Ref() const { return fRef; } - private: - entry_ref fRef; +private: + entry_ref fRef; }; + #endif /* PROBE_WINDOW_H */ diff --git a/src/apps/diskprobe/TypeEditors.h b/src/apps/diskprobe/TypeEditors.h index f3c63a0da2..907c312fae 100644 --- a/src/apps/diskprobe/TypeEditors.h +++ b/src/apps/diskprobe/TypeEditors.h @@ -1,6 +1,6 @@ /* - * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. + * Copyright 2004-2018, Axel Dörfler, axeld@pinc-software.de. + * All rights reserved. Distributed under the terms of the MIT license. */ #ifndef TYPE_EDITORS_H #define TYPE_EDITORS_H @@ -8,26 +8,31 @@ #include + class DataEditor; class TypeEditorView : public BView { - public: - TypeEditorView(BRect rect, const char* name, uint32 resizingMode, - uint32 flags, DataEditor& editor); - TypeEditorView(const char* name, uint32 flags, DataEditor& editor); - ~TypeEditorView(); +public: + TypeEditorView(BRect rect, const char* name, + uint32 resizingMode, uint32 flags, + DataEditor& editor); + TypeEditorView(const char* name, uint32 flags, + DataEditor& editor); + virtual ~TypeEditorView(); - virtual void CommitChanges(); - virtual bool TypeMatches(); + virtual void CommitChanges(); + virtual bool TypeMatches(); - protected: - DataEditor& fEditor; +protected: + DataEditor& fEditor; }; + extern TypeEditorView* GetTypeEditorFor(BRect rect, DataEditor& editor); extern status_t GetNthTypeEditor(int32 index, const char** _name); extern TypeEditorView* GetTypeEditorAt(int32 index, BRect rect, DataEditor& editor); + #endif /* TYPE_EDITORS_H */