Tracker: style fixes to Utilities
This commit is contained in:
@@ -241,7 +241,6 @@ PeriodicUpdatePoses::DoPeriodicUpdate(bool forceRedraw)
|
|||||||
|
|
||||||
PeriodicUpdatePoses gPeriodicUpdatePoses;
|
PeriodicUpdatePoses gPeriodicUpdatePoses;
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
@@ -276,7 +275,7 @@ PoseInfo::PrintToStream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - ExtendedPoseInfo
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@@ -296,8 +295,7 @@ ExtendedPoseInfo::Size(int32 count)
|
|||||||
size_t
|
size_t
|
||||||
ExtendedPoseInfo::SizeWithHeadroom() const
|
ExtendedPoseInfo::SizeWithHeadroom() const
|
||||||
{
|
{
|
||||||
return sizeof(ExtendedPoseInfo) + (fNumFrames + 1)
|
return sizeof(ExtendedPoseInfo) + (fNumFrames + 1) * sizeof(FrameLocation);
|
||||||
* sizeof(FrameLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -394,7 +392,7 @@ ExtendedPoseInfo::PrintToStream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - OffscreenBitmap
|
||||||
|
|
||||||
|
|
||||||
OffscreenBitmap::OffscreenBitmap(BRect frame)
|
OffscreenBitmap::OffscreenBitmap(BRect frame)
|
||||||
@@ -475,7 +473,7 @@ OffscreenBitmap::View() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - BPrivate functions
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
@@ -553,7 +551,7 @@ FadeRGBA32Vertical(uint32* bits, int32 width, int32 height, int32 from,
|
|||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - DraggableIcon
|
||||||
|
|
||||||
|
|
||||||
DraggableIcon::DraggableIcon(BRect rect, const char* name,
|
DraggableIcon::DraggableIcon(BRect rect, const char* name,
|
||||||
@@ -657,7 +655,7 @@ DraggableIcon::Draw(BRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - FlickerFreeStringView
|
||||||
|
|
||||||
|
|
||||||
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
@@ -695,7 +693,7 @@ FlickerFreeStringView::Draw(BRect)
|
|||||||
|
|
||||||
BView* offscreen = fBitmap->BeginUsing(bounds);
|
BView* offscreen = fBitmap->BeginUsing(bounds);
|
||||||
|
|
||||||
if (Parent()) {
|
if (Parent() != NULL) {
|
||||||
fViewColor = Parent()->ViewColor();
|
fViewColor = Parent()->ViewColor();
|
||||||
fLowColor = Parent()->ViewColor();
|
fLowColor = Parent()->ViewColor();
|
||||||
}
|
}
|
||||||
@@ -714,7 +712,7 @@ FlickerFreeStringView::Draw(BRect)
|
|||||||
else
|
else
|
||||||
offscreen->FillRect(bounds, B_SOLID_LOW);
|
offscreen->FillRect(bounds, B_SOLID_LOW);
|
||||||
|
|
||||||
if (Text()) {
|
if (Text() != NULL) {
|
||||||
BPoint loc;
|
BPoint loc;
|
||||||
|
|
||||||
font_height height;
|
font_height height;
|
||||||
@@ -762,7 +760,7 @@ void
|
|||||||
FlickerFreeStringView::AttachedToWindow()
|
FlickerFreeStringView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
_inherited::AttachedToWindow();
|
_inherited::AttachedToWindow();
|
||||||
if (Parent()) {
|
if (Parent() != NULL) {
|
||||||
fViewColor = Parent()->ViewColor();
|
fViewColor = Parent()->ViewColor();
|
||||||
fLowColor = Parent()->ViewColor();
|
fLowColor = Parent()->ViewColor();
|
||||||
}
|
}
|
||||||
@@ -793,7 +791,7 @@ FlickerFreeStringView::SetLowColor(rgb_color color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - TitledSeparatorItem
|
||||||
|
|
||||||
|
|
||||||
TitledSeparatorItem::TitledSeparatorItem(const char* label)
|
TitledSeparatorItem::TitledSeparatorItem(const char* label)
|
||||||
@@ -925,7 +923,7 @@ TitledSeparatorItem::Draw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - ShortcutFilter
|
||||||
|
|
||||||
|
|
||||||
ShortcutFilter::ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier,
|
ShortcutFilter::ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier,
|
||||||
@@ -970,12 +968,11 @@ ShortcutFilter::Filter(BMessage* message, BHandler**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - BPrivate functions
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume)
|
EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume)
|
||||||
{
|
{
|
||||||
@@ -1522,6 +1519,9 @@ EachMenuItem(const BMenu* menu, bool recursive,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - PositionPassingMenuItem
|
||||||
|
|
||||||
|
|
||||||
PositionPassingMenuItem::PositionPassingMenuItem(const char* title,
|
PositionPassingMenuItem::PositionPassingMenuItem(const char* title,
|
||||||
BMessage* message, char shortcut, uint32 modifiers)
|
BMessage* message, char shortcut, uint32 modifiers)
|
||||||
:
|
:
|
||||||
@@ -1581,6 +1581,9 @@ PositionPassingMenuItem::Invoke(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - BPrivate functions
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BootedInSafeMode()
|
BootedInSafeMode()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -94,12 +94,11 @@ extern bool gLocalizedNamePreferred;
|
|||||||
|
|
||||||
// misc typedefs, constants and structs
|
// misc typedefs, constants and structs
|
||||||
|
|
||||||
// Periodically updated poses (ones with a volume space bar) register
|
|
||||||
// themselfs in this global list. This way they can be iterated over instead
|
|
||||||
// of sending around update messages.
|
|
||||||
|
|
||||||
class PeriodicUpdatePoses {
|
class PeriodicUpdatePoses {
|
||||||
public:
|
// Periodically updated poses (ones with a volume space bar) register
|
||||||
|
// themselfs in this global list. This way they can be iterated over instead
|
||||||
|
// of sending around update messages.
|
||||||
|
public:
|
||||||
PeriodicUpdatePoses();
|
PeriodicUpdatePoses();
|
||||||
~PeriodicUpdatePoses();
|
~PeriodicUpdatePoses();
|
||||||
|
|
||||||
@@ -111,7 +110,7 @@ class PeriodicUpdatePoses {
|
|||||||
|
|
||||||
void DoPeriodicUpdate(bool forceRedraw);
|
void DoPeriodicUpdate(bool forceRedraw);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct periodic_pose {
|
struct periodic_pose {
|
||||||
BPose* pose;
|
BPose* pose;
|
||||||
BPoseView* pose_view;
|
BPoseView* pose_view;
|
||||||
@@ -126,10 +125,10 @@ class PeriodicUpdatePoses {
|
|||||||
extern PeriodicUpdatePoses gPeriodicUpdatePoses;
|
extern PeriodicUpdatePoses gPeriodicUpdatePoses;
|
||||||
|
|
||||||
|
|
||||||
// PoseInfo is the structure that gets saved as attributes for every node on
|
|
||||||
// disk, defining the node's position and visibility
|
|
||||||
class PoseInfo {
|
class PoseInfo {
|
||||||
public:
|
// PoseInfo is the structure that gets saved as attributes for every node
|
||||||
|
// on disk, defining the node's position and visibility
|
||||||
|
public:
|
||||||
static void EndianSwap(void* castToThis);
|
static void EndianSwap(void* castToThis);
|
||||||
void PrintToStream();
|
void PrintToStream();
|
||||||
|
|
||||||
@@ -145,10 +144,10 @@ class PoseInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// extends PoseInfo adding workspace support; used for desktop
|
|
||||||
// poses only
|
|
||||||
class ExtendedPoseInfo {
|
class ExtendedPoseInfo {
|
||||||
public:
|
// extends PoseInfo adding workspace support; used for desktop
|
||||||
|
// poses only
|
||||||
|
public:
|
||||||
size_t Size() const;
|
size_t Size() const;
|
||||||
static size_t Size(int32);
|
static size_t Size(int32);
|
||||||
size_t SizeWithHeadroom() const;
|
size_t SizeWithHeadroom() const;
|
||||||
@@ -224,7 +223,7 @@ extern void FadeRGBA32Vertical(uint32* bits, int32 width, int32 height,
|
|||||||
class FlickerFreeStringView : public BStringView {
|
class FlickerFreeStringView : public BStringView {
|
||||||
// adds support for offscreen bitmap drawing for string views that update
|
// adds support for offscreen bitmap drawing for string views that update
|
||||||
// often this would be better implemented as an option of BStringView
|
// often this would be better implemented as an option of BStringView
|
||||||
public:
|
public:
|
||||||
FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
const char* text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
const char* text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
@@ -238,7 +237,7 @@ class FlickerFreeStringView : public BStringView {
|
|||||||
virtual void SetViewColor(rgb_color);
|
virtual void SetViewColor(rgb_color);
|
||||||
virtual void SetLowColor(rgb_color);
|
virtual void SetLowColor(rgb_color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OffscreenBitmap* fBitmap;
|
OffscreenBitmap* fBitmap;
|
||||||
rgb_color fViewColor;
|
rgb_color fViewColor;
|
||||||
rgb_color fLowColor;
|
rgb_color fLowColor;
|
||||||
@@ -250,7 +249,7 @@ class FlickerFreeStringView : public BStringView {
|
|||||||
|
|
||||||
class DraggableIcon : public BView {
|
class DraggableIcon : public BView {
|
||||||
// used to determine a save location for a file
|
// used to determine a save location for a file
|
||||||
public:
|
public:
|
||||||
DraggableIcon(BRect, const char*, const char* mimeType, icon_size,
|
DraggableIcon(BRect, const char*, const char* mimeType, icon_size,
|
||||||
const BMessage*, BMessenger,
|
const BMessage*, BMessenger,
|
||||||
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
@@ -260,14 +259,14 @@ class DraggableIcon : public BView {
|
|||||||
static BRect PreferredRect(BPoint offset, icon_size);
|
static BRect PreferredRect(BPoint offset, icon_size);
|
||||||
void SetTarget(BMessenger);
|
void SetTarget(BMessenger);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MouseDown(BPoint);
|
virtual void MouseDown(BPoint);
|
||||||
virtual void Draw(BRect);
|
virtual void Draw(BRect);
|
||||||
|
|
||||||
virtual bool DragStarted(BMessage* dragMessage);
|
virtual bool DragStarted(BMessage* dragMessage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BBitmap* fBitmap;
|
BBitmap* fBitmap;
|
||||||
BMessage fMessage;
|
BMessage fMessage;
|
||||||
BMessenger fTarget;
|
BMessenger fTarget;
|
||||||
@@ -275,24 +274,24 @@ class DraggableIcon : public BView {
|
|||||||
|
|
||||||
|
|
||||||
class PositionPassingMenuItem : public BMenuItem {
|
class PositionPassingMenuItem : public BMenuItem {
|
||||||
public:
|
public:
|
||||||
PositionPassingMenuItem(const char* title, BMessage*,
|
PositionPassingMenuItem(const char* title, BMessage*,
|
||||||
char shortcut = 0, uint32 modifiers = 0);
|
char shortcut = 0, uint32 modifiers = 0);
|
||||||
|
|
||||||
PositionPassingMenuItem(BMenu*, BMessage*);
|
PositionPassingMenuItem(BMenu*, BMessage*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual status_t Invoke(BMessage* = 0);
|
virtual status_t Invoke(BMessage* = 0);
|
||||||
// appends the invoke location for NewFolder, etc. to use
|
// appends the invoke location for NewFolder, etc. to use
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BMenuItem _inherited;
|
typedef BMenuItem _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Benaphore {
|
class Benaphore {
|
||||||
// aka benaphore
|
// aka benaphore
|
||||||
public:
|
public:
|
||||||
Benaphore(const char* name = "Light Lock")
|
Benaphore(const char* name = "Light Lock")
|
||||||
: fSemaphore(create_sem(0, name)),
|
: fSemaphore(create_sem(0, name)),
|
||||||
fCount(1)
|
fCount(1)
|
||||||
@@ -323,37 +322,37 @@ class Benaphore {
|
|||||||
return fCount <= 0;
|
return fCount <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sem_id fSemaphore;
|
sem_id fSemaphore;
|
||||||
int32 fCount;
|
int32 fCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SeparatorLine : public BView {
|
class SeparatorLine : public BView {
|
||||||
public:
|
public:
|
||||||
SeparatorLine(BPoint, float, bool vertical, const char* name = "");
|
SeparatorLine(BPoint, float, bool vertical, const char* name = "");
|
||||||
virtual void Draw(BRect bounds);
|
virtual void Draw(BRect bounds);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TitledSeparatorItem : public BMenuItem {
|
class TitledSeparatorItem : public BMenuItem {
|
||||||
public:
|
public:
|
||||||
TitledSeparatorItem(const char*);
|
TitledSeparatorItem(const char*);
|
||||||
virtual ~TitledSeparatorItem();
|
virtual ~TitledSeparatorItem();
|
||||||
|
|
||||||
virtual void SetEnabled(bool state);
|
virtual void SetEnabled(bool state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void GetContentSize(float* width, float* height);
|
virtual void GetContentSize(float* width, float* height);
|
||||||
virtual void Draw();
|
virtual void Draw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BMenuItem _inherited;
|
typedef BMenuItem _inherited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class LooperAutoLocker {
|
class LooperAutoLocker {
|
||||||
public:
|
public:
|
||||||
LooperAutoLocker(BHandler* handler)
|
LooperAutoLocker(BHandler* handler)
|
||||||
: fHandler(handler),
|
: fHandler(handler),
|
||||||
fHasLock(handler->LockLooper())
|
fHasLock(handler->LockLooper())
|
||||||
@@ -376,27 +375,28 @@ class LooperAutoLocker {
|
|||||||
return fHasLock;
|
return fHasLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BHandler* fHandler;
|
BHandler* fHandler;
|
||||||
bool fHasLock;
|
bool fHasLock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ShortcutFilter : public BMessageFilter {
|
class ShortcutFilter : public BMessageFilter {
|
||||||
public:
|
public:
|
||||||
ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier,
|
ShortcutFilter(uint32 shortcutKey, uint32 shortcutModifier,
|
||||||
uint32 shortcutWhat, BHandler* target);
|
uint32 shortcutWhat, BHandler* target);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
filter_result Filter(BMessage*, BHandler**);
|
filter_result Filter(BMessage*, BHandler**);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 fShortcutKey;
|
uint32 fShortcutKey;
|
||||||
uint32 fShortcutModifier;
|
uint32 fShortcutModifier;
|
||||||
uint32 fShortcutWhat;
|
uint32 fShortcutWhat;
|
||||||
BHandler* fTarget;
|
BHandler* fTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// iterates over all the refs in a message
|
// iterates over all the refs in a message
|
||||||
entry_ref* EachEntryRef(BMessage*, entry_ref* (*)(entry_ref*, void*),
|
entry_ref* EachEntryRef(BMessage*, entry_ref* (*)(entry_ref*, void*),
|
||||||
void* passThru = 0);
|
void* passThru = 0);
|
||||||
@@ -447,6 +447,7 @@ bool operator!=(const rgb_color&, const rgb_color&);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
inline rgb_color
|
inline rgb_color
|
||||||
Color(int32 r, int32 g, int32 b, int32 alpha = 255)
|
Color(int32 r, int32 g, int32 b, int32 alpha = 255)
|
||||||
{
|
{
|
||||||
@@ -561,9 +562,10 @@ inline void PrintDirToStream(const BDirectory*, const char* = 0) {}
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WRITELOG(_ARGS_) \
|
#define WRITELOG(_ARGS_) \
|
||||||
if (logFile == 0) \
|
if (logFile == 0) \
|
||||||
logFile = fopen("/var/log/tracker.log", "a+"); \
|
logFile = fopen("/var/log/tracker.log", "a+"); \
|
||||||
|
\
|
||||||
if (logFile != 0) { \
|
if (logFile != 0) { \
|
||||||
thread_info info; \
|
thread_info info; \
|
||||||
get_thread_info(find_thread(NULL), &info); \
|
get_thread_info(find_thread(NULL), &info); \
|
||||||
@@ -605,4 +607,5 @@ float ComputeTypeAheadScore(const char* text, const char* match,
|
|||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif // _UTILITIES_H
|
#endif // _UTILITIES_H
|
||||||
|
|||||||
Reference in New Issue
Block a user