hrev52478 adds 2 changesets to branch 'master'
old head: bae2263db95cf674bfe4cd40046c9e3eca2485a5
new head: e85413ad6cca690cadd97dd407455e1de24600ba
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=e85413ad6cca+%5Ebae2263db95c
----------------------------------------------------------------------------
49135c955bc5: desklink: Replaced muted speaker icon with stippi's version
* Replaced the muted speaker icon with a new one, thanks Stephan!
* Moved speaker icons into resources.
e85413ad6cca: DiskProbe: Coding style cleanup
* Not complete, no functional changes intended.
[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
18 files changed, 718 insertions(+), 651 deletions(-)
data/artwork/icons/Misc_Speaker_Box_Muted | Bin 0 -> 17715 bytes
src/apps/diskprobe/AttributeWindow.h | 38 +--
src/apps/diskprobe/DataEditor.h | 220 +++++++++--------
src/apps/diskprobe/DataView.h | 152 ++++++------
src/apps/diskprobe/DiskProbe.cpp | 130 +++++-----
src/apps/diskprobe/DiskProbe.h | 11 +-
src/apps/diskprobe/FileWindow.h | 24 +-
src/apps/diskprobe/FindWindow.h | 41 +--
src/apps/diskprobe/OpenWindow.h | 6 +-
src/apps/diskprobe/ProbeView.cpp | 343 ++++++++++++++------------
src/apps/diskprobe/ProbeView.h | 106 ++++----
src/apps/diskprobe/ProbeWindow.cpp | 29 ++-
src/apps/diskprobe/ProbeWindow.h | 30 +--
src/apps/diskprobe/TypeEditors.h | 31 ++-
src/bin/desklink/Jamfile | 2 +-
src/bin/desklink/MediaReplicant.cpp | 61 ++++-
src/bin/desklink/SpeakerBox.rdef | 40 +++
src/bin/desklink/iconfile.h | 105 --------
############################################################################
Commit: 49135c955bc5cf13a7880b573da82f6253d24b05
URL: https://git.haiku-os.org/haiku/commit/?id=49135c955bc5
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Sat Nov 3 12:39:15 2018 UTC
desklink: Replaced muted speaker icon with stippi's version
* Replaced the muted speaker icon with a new one, thanks Stephan!
* Moved speaker icons into resources.
----------------------------------------------------------------------------
diff --git a/data/artwork/icons/Misc_Speaker_Box_Muted
b/data/artwork/icons/Misc_Speaker_Box_Muted
new file mode 100644
index 0000000000..8c6783601e
Binary files /dev/null and b/data/artwork/icons/Misc_Speaker_Box_Muted differ
diff --git a/src/bin/desklink/Jamfile b/src/bin/desklink/Jamfile
index 2bf3c4629c..4a47906ee5 100644
--- a/src/bin/desklink/Jamfile
+++ b/src/bin/desklink/Jamfile
@@ -13,7 +13,7 @@ BinCommand desklink :
VolumeWindow.cpp
: be libmedia.so localestub [ TargetLibsupc++ ]
- : desklink.rdef
+ : desklink.rdef SpeakerBox.rdef
;
DoCatalogs desklink :
diff --git a/src/bin/desklink/MediaReplicant.cpp
b/src/bin/desklink/MediaReplicant.cpp
index 6f06b93f90..ac1866ffbc 100644
--- a/src/bin/desklink/MediaReplicant.cpp
+++ b/src/bin/desklink/MediaReplicant.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2013, Haiku. All rights reserved.
+ * Copyright 2003-2018, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -29,6 +29,7 @@
#include <MenuItem.h>
#include <Path.h>
#include <PopUpMenu.h>
+#include <Resources.h>
#include <Roster.h>
#include <String.h>
#include <StringView.h>
@@ -37,7 +38,6 @@
#include <ToolTipManager.h>
#include "desklink.h"
-#include "iconfile.h"
#include "MixerControl.h"
#include "VolumeWindow.h"
@@ -141,6 +141,7 @@ private:
void _LoadSettings();
void _SaveSettings();
void _Init();
+ BBitmap* _LoadIcon(BResources&
resources, const char* name);
void _DisconnectMixer();
status_t _ConnectMixer();
@@ -158,6 +159,23 @@ private:
};
+status_t
+our_image(image_info& image)
+{
+ int32 cookie = 0;
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &image) == B_OK) {
+ if ((char*)our_image >= (char*)image.text
+ && (char*)our_image <= (char*)image.text +
image.text_size)
+ return B_OK;
+ }
+
+ return B_ERROR;
+}
+
+
+// #pragma mark -
+
+
MediaReplicant::MediaReplicant(BRect frame, const char* name,
uint32 resizeMask, uint32 flags)
:
@@ -527,14 +545,20 @@ MediaReplicant::_SaveSettings()
void
MediaReplicant::_Init()
{
- fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1),
- B_RGBA32);
- BIconUtils::GetVectorIcon(kSpeakerIcon, sizeof(kSpeakerIcon), fIcon);
+ image_info info;
+ if (our_image(info) != B_OK)
+ return;
- fMutedIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight
- 1),
- B_RGBA32);
- BIconUtils::GetVectorIcon(kMutedSpeakerIcon, sizeof(kMutedSpeakerIcon),
- fMutedIcon);
+ BFile file(info.name, B_READ_ONLY);
+ if (file.InitCheck() != B_OK)
+ return;
+
+ BResources resources(&file);
+ if (resources.InitCheck() != B_OK)
+ return;
+
+ fIcon = _LoadIcon(resources, "Speaker");
+ fMutedIcon = _LoadIcon(resources, "SpeakerMuted");
_LoadSettings();
@@ -542,6 +566,25 @@ MediaReplicant::_Init()
}
+BBitmap*
+MediaReplicant::_LoadIcon(BResources& resources, const char* name)
+{
+ size_t size;
+ const void* data = resources.LoadResource(B_VECTOR_ICON_TYPE, name,
&size);
+ if (data == NULL)
+ return NULL;
+
+ // Scale tray icon
+ BBitmap* icon = new BBitmap(Bounds(), B_RGBA32);
+ if (icon->InitCheck() != B_OK
+ || BIconUtils::GetVectorIcon((const uint8*)data, size, icon) !=
B_OK) {
+ delete icon;
+ return NULL;
+ }
+ return icon;
+}
+
+
void
MediaReplicant::_DisconnectMixer()
{
diff --git a/src/bin/desklink/SpeakerBox.rdef b/src/bin/desklink/SpeakerBox.rdef
new file mode 100644
index 0000000000..71152e35f6
--- /dev/null
+++ b/src/bin/desklink/SpeakerBox.rdef
@@ -0,0 +1,40 @@
+resource(42, "Speaker") #'VICN' array {
+ $"6E6369660B0401740500020016023BEC7C3D464BBDC2113C40664A53A4492170"
+ $"00DDFFC5020016023B9E032FED63B0F24F3CB6C14A533F3ABE8400FFFFC50200"
+ $"1602395E1E32DB49B6921A3D07D74A57904908D60064FF8C050102031604BEBE"
+ $"2BBEE9573EE957BEBE2B48B7784A2FD30001C270D073FFFF020116033B400000"
+ $"00000000003C200048400049E000BE4B0084FF32020316023C4E213D44DABD44"
+ $"DA3C4E214926894A428EA143FFFF02031603BC6B27BD2F9C3D2F9CBC6B2748B0"
+ $"FD4A3D7C2A01B228FFFF0300FF00070A0446604E60604C54470A04262B264E46"
+ $"5E46340A044635465E564E562A0A04262B4635562A39220A06262B264E465E56"
+ $"4E562A39220204B9A5BB36BC06BA55B744BC17B77347B649BF5FB89EC5B6BDDE"
+ $"C6B1BB7DC792C03FC5D0C011BF5DC13BC288BEE6BC310204C01CC7C1C06DC7A8"
+ $"BFCBC7DABFC6C8B1BFA5C845BFE8C91CC095C946C044C95FC0E6C92DC0EBC856"
+ $"C10CC8C2C0C9C7EB0C0A0001002021210A0101041001178400040A020101000A"
+ $"030103000A040102000A0501051001178400040A060105000A070105023DBBBB"
+ $"0000000000003DBBBB4744444862220A0801051A3FA0000000000000003FA000"
+ $"41FFFB42FFFD13FF01178100040A0901051A3F38270000000000003F3DFB4432"
+ $"8545595C13FF01178200040A0101061001178200040A0A010600"
+};
+
+resource(43, "SpeakerMuted") #'VICN' array {
+ $"6E6369660E0401740500020016023BEC7C3D464BBDC2113C40664A53A4492170"
+ $"00DDFFC5020016023B9E032FED63B0F24F3CB6C14A533F3ABE8400FFFFC50200"
+ $"1602395E1E32DB49B6921A3D07D74A57904908D60064FF8C050102031604BEBE"
+ $"2BBEE9573EE957BEBE2B48B7784A2FD30001C270D073FFFF020116033B400000"
+ $"00000000003C200048400049E000BE4B0084FF32020316023C4E213D44DABD44"
+ $"DA3C4E214926894A428EA143FFFF02031603BC6B27BD2F9C3D2F9CBC6B2748B0"
+ $"FD4A3D7C2A01B228FFFF0300FF0004003903800000020006020000003B4000C0"
+ $"00000000004C00004AB00000FFABABFFEA0606080A0446604E60604C54470A04"
+ $"262B264E465E46340A044635465E564E562A0A04262B4635562A39220A06262B"
+ $"264E465E564E562A39220204B9A5BB36BC06BA55B744BC17B77347B649BF5FB8"
+ $"9EC5B6BDDEC6B1BB7DC792C03FC5D0C011BF5DC13BC288BEE6BC310204C01CC7"
+ $"C1C06DC7A8BFCBC7DABFC6C8B1BFA5C845BFE8C91CC095C946C044C95FC0E6C9"
+ $"2DC0EBC856C10CC8C2C0C9C7EB0A0C4A4C4056445A4E50585A5C56524C5C4258"
+ $"3E4E48443E40420E0A0001002021210A0101041001178400040A020101000A03"
+ $"0103000A040102000A0501051001178400040A060105000A070105023DBBBB00"
+ $"00000000003DBBBB4744444862220A0801051A3FA0000000000000003FA00041"
+ $"FFFB42FFFD13FF01178100040A0901051A3F38270000000000003F3DFB443285"
+ $"45595C13FF01178200040A0101061001178200040A0A0106000A0C0107100117"
+ $"8422040A0D010700"
+};
diff --git a/src/bin/desklink/iconfile.h b/src/bin/desklink/iconfile.h
deleted file mode 100644
index c8280f3fc6..0000000000
--- a/src/bin/desklink/iconfile.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2003-2010, Haiku. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Jérôme Duval
- * Stephan Aßmus <superstippi@xxxxxx>
- */
-
-const int32 kSpeakerWidth = 16;
-const int32 kSpeakerHeight = 16;
-
-const unsigned char kSpeakerIcon[] = {
- 0x6e, 0x63, 0x69, 0x66, 0x0b, 0x04, 0x01, 0x74, 0x05, 0x00, 0x02, 0x00,
- 0x16, 0x02, 0x3b, 0xec, 0x7c, 0x3d, 0x46, 0x4b, 0xbd, 0xc2, 0x11, 0x3c,
- 0x40, 0x66, 0x4a, 0x53, 0xa4, 0x49, 0x21, 0x70, 0x00, 0xdd, 0xff, 0xc5,
- 0x02, 0x00, 0x16, 0x02, 0x3b, 0x9e, 0x03, 0x2f, 0xed, 0x63, 0xb0, 0xf2,
- 0x4f, 0x3c, 0xb6, 0xc1, 0x4a, 0x53, 0x3f, 0x3a, 0xbe, 0x84, 0x00, 0xff,
- 0xff, 0xc5, 0x02, 0x00, 0x16, 0x02, 0x39, 0x5e, 0x1e, 0x32, 0xdb, 0x49,
- 0xb6, 0x92, 0x1a, 0x3d, 0x07, 0xd7, 0x4a, 0x57, 0x90, 0x49, 0x08, 0xd6,
- 0x00, 0x64, 0xff, 0x8c, 0x05, 0x01, 0x02, 0x03, 0x16, 0x04, 0xbe, 0xbe,
- 0x2b, 0xbe, 0xe9, 0x57, 0x3e, 0xe9, 0x57, 0xbe, 0xbe, 0x2b, 0x48, 0xb7,
- 0x78, 0x4a, 0x2f, 0xd3, 0x00, 0x01, 0xc2, 0x70, 0xd0, 0x73, 0xff, 0xff,
- 0x02, 0x01, 0x16, 0x03, 0x3b, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x20, 0x00, 0x48, 0x40, 0x00, 0x49, 0xe0, 0x00, 0xbe, 0x4b,
- 0x00, 0x84, 0xff, 0x32, 0x02, 0x03, 0x16, 0x02, 0x3c, 0x4e, 0x21, 0x3d,
- 0x44, 0xda, 0xbd, 0x44, 0xda, 0x3c, 0x4e, 0x21, 0x49, 0x26, 0x89, 0x4a,
- 0x42, 0x8e, 0xa1, 0x43, 0xff, 0xff, 0x02, 0x03, 0x16, 0x03, 0xbc, 0x6b,
- 0x27, 0xbd, 0x2f, 0x9c, 0x3d, 0x2f, 0x9c, 0xbc, 0x6b, 0x27, 0x48, 0xb0,
- 0xfd, 0x4a, 0x3d, 0x7c, 0x2a, 0x01, 0xb2, 0x28, 0xff, 0xff, 0x03, 0x00,
- 0xff, 0x00, 0x07, 0x0a, 0x04, 0x46, 0x60, 0x4e, 0x60, 0x60, 0x4c, 0x54,
- 0x47, 0x0a, 0x04, 0x26, 0x2b, 0x26, 0x4e, 0x46, 0x5e, 0x46, 0x34, 0x0a,
- 0x04, 0x46, 0x35, 0x46, 0x5e, 0x56, 0x4e, 0x56, 0x2a, 0x0a, 0x04, 0x26,
- 0x2b, 0x46, 0x35, 0x56, 0x2a, 0x39, 0x22, 0x0a, 0x06, 0x26, 0x2b, 0x26,
- 0x4e, 0x46, 0x5e, 0x56, 0x4e, 0x56, 0x2a, 0x39, 0x22, 0x02, 0x04, 0xb9,
- 0xa5, 0xbb, 0x36, 0xbc, 0x06, 0xba, 0x55, 0xb7, 0x44, 0xbc, 0x17, 0xb7,
- 0x73, 0x47, 0xb6, 0x49, 0xbf, 0x5f, 0xb8, 0x9e, 0xc5, 0xb6, 0xbd, 0xde,
- 0xc6, 0xb1, 0xbb, 0x7d, 0xc7, 0x92, 0xc0, 0x3f, 0xc5, 0xd0, 0xc0, 0x11,
- 0xbf, 0x5d, 0xc1, 0x3b, 0xc2, 0x88, 0xbe, 0xe6, 0xbc, 0x31, 0x02, 0x04,
- 0xc0, 0x1c, 0xc7, 0xc1, 0xc0, 0x6d, 0xc7, 0xa8, 0xbf, 0xcb, 0xc7, 0xda,
- 0xbf, 0xc6, 0xc8, 0xb1, 0xbf, 0xa5, 0xc8, 0x45, 0xbf, 0xe8, 0xc9, 0x1c,
- 0xc0, 0x95, 0xc9, 0x46, 0xc0, 0x44, 0xc9, 0x5f, 0xc0, 0xe6, 0xc9, 0x2d,
- 0xc0, 0xeb, 0xc8, 0x56, 0xc1, 0x0c, 0xc8, 0xc2, 0xc0, 0xc9, 0xc7, 0xeb,
- 0x0c, 0x0a, 0x00, 0x01, 0x00, 0x20, 0x21, 0x21, 0x0a, 0x01, 0x01, 0x04,
- 0x10, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x02, 0x01, 0x01, 0x00, 0x0a,
- 0x03, 0x01, 0x03, 0x00, 0x0a, 0x04, 0x01, 0x02, 0x00, 0x0a, 0x05, 0x01,
- 0x05, 0x10, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x06, 0x01, 0x05, 0x00,
- 0x0a, 0x07, 0x01, 0x05, 0x02, 0x3d, 0xbb, 0xbb, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x3d, 0xbb, 0xbb, 0x47, 0x44, 0x44, 0x48, 0x62, 0x22, 0x0a,
- 0x08, 0x01, 0x05, 0x1a, 0x3f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3f, 0xa0, 0x00, 0x41, 0xff, 0xfb, 0x42, 0xff, 0xfd, 0x13, 0xff,
- 0x01, 0x17, 0x81, 0x00, 0x04, 0x0a, 0x09, 0x01, 0x05, 0x1a, 0x3f, 0x38,
- 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3d, 0xfb, 0x44, 0x32,
- 0x85, 0x45, 0x59, 0x5c, 0x13, 0xff, 0x01, 0x17, 0x82, 0x00, 0x04, 0x0a,
- 0x01, 0x01, 0x06, 0x10, 0x01, 0x17, 0x82, 0x00, 0x04, 0x0a, 0x0a, 0x01,
- 0x06, 0x00
-};
-
-const unsigned char kMutedSpeakerIcon[] = {
- 0x6e, 0x63, 0x69, 0x66, 0x0b, 0x04, 0x01, 0x74, 0x05, 0x00, 0x02, 0x00,
- 0x16, 0x02, 0x3b, 0xec, 0x7c, 0x3d, 0x46, 0x4b, 0xbd, 0xc2, 0x11, 0x3c,
- 0x40, 0x66, 0x4a, 0x53, 0xa4, 0x49, 0x21, 0x70, 0x00, 0xdd, 0xff, 0xc5,
- 0x02, 0x00, 0x16, 0x02, 0x3b, 0x9e, 0x03, 0x2f, 0xed, 0x63, 0xb0, 0xf2,
- 0x4f, 0x3c, 0xb6, 0xc1, 0x4a, 0x53, 0x3f, 0x3a, 0xbe, 0x84, 0x00, 0xff,
- 0xff, 0xc5, 0x02, 0x00, 0x16, 0x02, 0x39, 0x5e, 0x1e, 0x32, 0xdb, 0x49,
- 0xb6, 0x92, 0x1a, 0x3d, 0x07, 0xd7, 0x4a, 0x57, 0x90, 0x49, 0x08, 0xd6,
- 0x00, 0x64, 0xff, 0x8c, 0x05, 0x01, 0x02, 0x03, 0x16, 0x04, 0xbe, 0xbe,
- 0x2b, 0xbe, 0xe9, 0x57, 0x3e, 0xe9, 0x57, 0xbe, 0xbe, 0x2b, 0x48, 0xb7,
- 0x78, 0x4a, 0x2f, 0xd3, 0x00, 0x01, 0xc2, 0x70, 0xd0, 0x73, 0xff, 0xff,
- 0x02, 0x01, 0x16, 0x03, 0x3b, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3c, 0x20, 0x00, 0x48, 0x40, 0x00, 0x49, 0xe0, 0x00, 0x00, 0x84,
- 0xbe, 0x4b, 0xff, 0x32, 0x02, 0x03, 0x16, 0x02, 0x3c, 0x4e, 0x21, 0x3d,
- 0x44, 0xda, 0xbd, 0x44, 0xda, 0x3c, 0x4e, 0x21, 0x49, 0x26, 0x89, 0x4a,
- 0x42, 0x8e, 0xa1, 0x43, 0xff, 0xff, 0x02, 0x03, 0x16, 0x03, 0xbc, 0x6b,
- 0x27, 0xbd, 0x2f, 0x9c, 0x3d, 0x2f, 0x9c, 0xbc, 0x6b, 0x27, 0x48, 0xb0,
- 0xfd, 0x4a, 0x3d, 0x7c, 0x2a, 0x01, 0xb2, 0x28, 0xff, 0xff, 0x03, 0xff,
- 0x00, 0x00, 0x09, 0x0a, 0x04, 0x46, 0x60, 0x4e, 0x60, 0x60, 0x4c, 0x54,
- 0x47, 0x0a, 0x04, 0x26, 0x2b, 0x26, 0x4e, 0x46, 0x5e, 0x46, 0x34, 0x0a,
- 0x04, 0x46, 0x35, 0x46, 0x5e, 0x56, 0x4e, 0x56, 0x2a, 0x0a, 0x04, 0x26,
- 0x2b, 0x46, 0x35, 0x56, 0x2a, 0x39, 0x22, 0x0a, 0x06, 0x26, 0x2b, 0x26,
- 0x4e, 0x46, 0x5e, 0x56, 0x4e, 0x56, 0x2a, 0x39, 0x22, 0x02, 0x04, 0xb9,
- 0xa4, 0xbb, 0x36, 0xbc, 0x05, 0xba, 0x54, 0xb7, 0x43, 0xbc, 0x17, 0xb7,
- 0x73, 0x47, 0xb6, 0x49, 0xbf, 0x5e, 0xb8, 0x9e, 0xc5, 0xb6, 0xbd, 0xdd,
- 0xc6, 0xb1, 0xbb, 0x7c, 0xc7, 0x92, 0xc0, 0x3f, 0xc5, 0xd0, 0xc0, 0x10,
- 0xbf, 0x5c, 0xc1, 0x3b, 0xc2, 0x88, 0xbe, 0xe6, 0xbc, 0x31, 0x02, 0x04,
- 0xc0, 0x1c, 0xc7, 0xc0, 0xc0, 0x6d, 0xc7, 0xa7, 0xbf, 0xca, 0xc7, 0xd9,
- 0xbf, 0xc5, 0xc8, 0xb1, 0xbf, 0xa5, 0xc8, 0x45, 0xbf, 0xe8, 0xc9, 0x1c,
- 0xc0, 0x94, 0xc9, 0x46, 0xc0, 0x43, 0xc9, 0x5f, 0xc0, 0xe6, 0xc9, 0x2d,
- 0xc0, 0xeb, 0xc8, 0x55, 0xc1, 0x0b, 0xc8, 0xc1, 0xc0, 0xc8, 0xc7, 0xeb,
- 0x0a, 0x02, 0x28, 0x4d, 0x43, 0x38, 0x08, 0x02, 0x29, 0x30, 0x43, 0x5a,
- 0x0e, 0x0a, 0x00, 0x01, 0x00, 0x20, 0x21, 0x21, 0x0a, 0x01, 0x01, 0x04,
- 0x10, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x02, 0x01, 0x01, 0x00, 0x0a,
- 0x03, 0x01, 0x03, 0x00, 0x0a, 0x04, 0x01, 0x02, 0x00, 0x0a, 0x05, 0x01,
- 0x05, 0x10, 0x01, 0x17, 0x84, 0x00, 0x04, 0x0a, 0x06, 0x01, 0x05, 0x00,
- 0x0a, 0x07, 0x01, 0x05, 0x02, 0x3d, 0xbb, 0xbb, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x3d, 0xbb, 0xbb, 0x47, 0x44, 0x44, 0x48, 0x62, 0x22, 0x0a,
- 0x08, 0x01, 0x05, 0x1a, 0x3f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3f, 0xa0, 0x00, 0x41, 0xff, 0xfb, 0x42, 0xff, 0xfd, 0x13, 0xff,
- 0x01, 0x17, 0x81, 0x00, 0x04, 0x0a, 0x09, 0x01, 0x05, 0x1a, 0x3f, 0x38,
- 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3d, 0xfb, 0x44, 0x32,
- 0x85, 0x45, 0x59, 0x5c, 0x13, 0xff, 0x01, 0x17, 0x82, 0x00, 0x04, 0x0a,
- 0x01, 0x01, 0x06, 0x10, 0x01, 0x17, 0x82, 0x00, 0x04, 0x0a, 0x0a, 0x01,
- 0x06, 0x00, 0x0a, 0x0a, 0x01, 0x07, 0x10, 0x01, 0x17, 0x86, 0x22, 0x04,
- 0x0a, 0x0a, 0x01, 0x08, 0x10, 0x01, 0x17, 0x86, 0x20, 0x04
-};
############################################################################
Revision: hrev52478
Commit: e85413ad6cca690cadd97dd407455e1de24600ba
URL: https://git.haiku-os.org/haiku/commit/?id=e85413ad6cca
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Sat Nov 3 12:41:13 2018 UTC
DiskProbe: Coding style cleanup
* Not complete, no functional changes intended.
----------------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx. All rights reserved.
-** Distributed under the terms of the MIT License.
-*/
+/*
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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();
-
- 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;
+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);
+
+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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef DATA_EDITOR_H
#define DATA_EDITOR_H
@@ -11,6 +11,7 @@
#include <Locker.h>
#include <ObjectList.h>
+
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();
-
- 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();
-
- 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; }
-
- 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 MoveBy(int32 bytes);
- status_t MoveTo(off_t offset);
-
- status_t Undo();
- status_t Redo();
-
- bool CanUndo() const;
- bool CanRedo() const;
-
- 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 SetViewSize(size_t size);
- size_t ViewSize() const { return fViewSize; }
-
- 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 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);
-
- BFile &File() { return fFile; }
- const entry_ref &AttributeRef() const { return fAttributeRef; }
- const entry_ref &Ref() const { return fRef; }
-
- 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();
-
- BObjectList<BMessenger> fObservers;
-
- entry_ref fRef, fAttributeRef;
- BFile fFile;
- const char *fAttribute;
- type_code fType;
- bool fIsDevice, fIsReadOnly;
- off_t fRealSize, fSize;
-
- BObjectList<DataChange> fChanges;
- DataChange *fFirstChange;
- DataChange *fLastChange;
- int32 fChangesFromSaved;
-
- uint8 *fView;
- off_t fRealViewOffset, fViewOffset;
- size_t fRealViewSize, fViewSize;
- bool fNeedsUpdate;
-
- size_t fBlockSize;
+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 Save();
+
+ 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; }
+
+ 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 MoveBy(int32 bytes);
+ status_t MoveTo(off_t offset);
+
+ status_t Undo();
+ status_t Redo();
+
+ bool CanUndo() const;
+ bool CanRedo() const;
+
+ 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 SetViewSize(size_t
size);
+ size_t ViewSize() const {
return fViewSize; }
+
+ 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
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);
+
+ BFile& File() { return fFile; }
+ const entry_ref& AttributeRef() const { return
fAttributeRef; }
+ const entry_ref& Ref() const { return fRef; }
+
+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();
+
+private:
+ BObjectList<BMessenger> fObservers;
+
+ 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<DataChange> fChanges;
+ DataChange* fFirstChange;
+ DataChange* fLastChange;
+ int32 fChangesFromSaved;
+
+ uint8* fView;
+ off_t fRealViewOffset;
+ off_t fViewOffset;
+ size_t fRealViewSize;
+ size_t fViewSize;
+ bool fNeedsUpdate;
+
+ 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@xxxxxxxxxxxxxxxx.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
* 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);
-
- 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);
-
- 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;
+ 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
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();
+
+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@xxxxxxxxxxxxxxxx.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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();
-
- virtual void ReadyToRun();
-
- virtual void RefsReceived(BMessage *message);
- virtual void ArgvReceived(int32 argc, char **argv);
- virtual void MessageReceived(BMessage *message);
-
- virtual bool QuitRequested();
-
- private:
- status_t Probe(BEntry &entry, const char *attribute = NULL);
-
- Settings fSettings;
- BFilePanel *fFilePanel;
- BWindow *fOpenWindow;
- FindWindow *fFindWindow;
- uint32 fWindowCount;
- BRect fWindowFrame;
- BMessenger fFindTarget;
+public:
+ DiskProbe();
+ virtual ~DiskProbe();
+
+ virtual void ReadyToRun();
+
+ virtual void RefsReceived(BMessage* message);
+ virtual void ArgvReceived(int32 argc, char**
argv);
+ virtual void MessageReceived(BMessage*
message);
+
+ virtual bool QuitRequested();
+
+private:
+ status_t Probe(BEntry& entry,
+ const
char* attribute = NULL);
+
+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<ProbeWindow *>(WindowAt(i));
+ ProbeWindow* window = dynamic_cast<ProbeWindow*>(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@xxxxxxxxxxxxxxxx. All rights reserved.
-** Distributed under the terms of the MIT License.
-*/
+/*
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * All rights reserved. Distributed under the terms of the MIT license.
+ */
#ifndef DISK_PROBE_H
#define DISK_PROBE_H
@@ -9,7 +9,7 @@
#include <SupportDefs.h>
-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@xxxxxxxxxxxxxxxx. All rights reserved.
-** Distributed under the terms of the MIT License.
-*/
+/*
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef FIND_WINDOW_H
#define FIND_WINDOW_H
@@ -9,6 +9,7 @@
#include <Window.h>
#include <Messenger.h>
+
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();
-
- virtual void WindowActivated(bool active);
- virtual void MessageReceived(BMessage *message);
- virtual bool QuitRequested();
- virtual void Show();
-
- void SetTarget(BMessenger &target);
-
- private:
- BMessenger fTarget;
- FindTextView *fTextView;
- BCheckBox *fCaseCheckBox;
- BMenu *fMenu;
+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();
+
+ void SetTarget(BMessenger&
target);
+
+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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef OPEN_WINDOW_H
#define OPEN_WINDOW_H
@@ -8,6 +8,7 @@
#include <Window.h>
+
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@xxxxxxxxxxxxxxxx.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
* 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();
-
- virtual void AttachedToWindow();
- virtual void DetachedFromWindow();
- virtual void MessageReceived(BMessage *message);
-
- 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);
-
- 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();
-
- 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;
+public:
+
HeaderView(const entry_ref* ref,
+
DataEditor& editor);
+ virtual ~HeaderView();
+
+ virtual void AttachedToWindow();
+ virtual void DetachedFromWindow();
+ virtual void MessageReceived(BMessage*
message);
+
+ 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);
+
+ 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:
+ 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;
};
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();
-
- 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();
-
- private:
- DataEditor &fEditor;
- BMessenger fMessenger;
- volatile bool fQuitFind;
+public:
+
EditorLooper(const char* name,
+
DataEditor& editor, BMessenger messenger);
+ virtual ~EditorLooper();
+
+ 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();
+
+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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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();
-
- 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();
-
- bool QuitRequested();
-
- 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();
-
- 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;
+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);
+
+ void AddSaveMenuItems(BMenu*
menu, int32 index);
+ void
AddPrintMenuItems(BMenu* menu, int32 index);
+ void AddViewAsMenuItems();
+
+ bool QuitRequested();
+
+ 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:
+ 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;
};
+
#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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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 <Application.h>
#include <View.h>
+#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@xxxxxxxxxxxxxxxx. All rights reserved.
-** Distributed under the terms of the MIT License.
-*/
+/*
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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@xxxxxxxxxxxxxxxx. All rights
reserved.
- * Distributed under the terms of the MIT License.
+ * Copyright 2004-2018, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef TYPE_EDITORS_H
#define TYPE_EDITORS_H
@@ -8,26 +8,31 @@
#include <View.h>
+
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();
-
- virtual void CommitChanges();
- virtual bool TypeMatches();
-
- protected:
- DataEditor& fEditor;
+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();
+
+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 */