BDeskbar: Style fixes
Update Copyright in cpp, add myself, alphabetize, standardize Pointer style in cpp Update some comments Some 80 char stuff pragma section headers whitespace
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
|
|
||||||
class BMessenger;
|
class BMessenger;
|
||||||
class BView;
|
class BView;
|
||||||
struct entry_ref;
|
struct entry_ref;
|
||||||
@@ -22,6 +23,7 @@ enum deskbar_location {
|
|||||||
B_DESKBAR_RIGHT_BOTTOM
|
B_DESKBAR_RIGHT_BOTTOM
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BDeskbar {
|
class BDeskbar {
|
||||||
public:
|
public:
|
||||||
BDeskbar();
|
BDeskbar();
|
||||||
@@ -29,24 +31,24 @@ public:
|
|||||||
|
|
||||||
bool IsRunning() const;
|
bool IsRunning() const;
|
||||||
|
|
||||||
// Location member functions
|
// Location methods
|
||||||
BRect Frame() const;
|
BRect Frame() const;
|
||||||
deskbar_location Location(bool* _isExpanded = NULL) const;
|
deskbar_location Location(bool* _isExpanded = NULL) const;
|
||||||
status_t SetLocation(deskbar_location location,
|
status_t SetLocation(deskbar_location location,
|
||||||
bool expanded = false);
|
bool expanded = false);
|
||||||
|
|
||||||
|
// Other state methods
|
||||||
bool IsExpanded() const;
|
bool IsExpanded() const;
|
||||||
status_t Expand(bool expand);
|
status_t Expand(bool expand);
|
||||||
|
|
||||||
// Item querying member functions
|
// Item querying methods
|
||||||
status_t GetItemInfo(int32 id,
|
status_t GetItemInfo(int32 id, const char** _name) const;
|
||||||
const char** _name) const;
|
status_t GetItemInfo(const char* name, int32* _id) const;
|
||||||
status_t GetItemInfo(const char* name,
|
|
||||||
int32* _id) const;
|
|
||||||
bool HasItem(int32 id) const;
|
bool HasItem(int32 id) const;
|
||||||
bool HasItem(const char* name) const;
|
bool HasItem(const char* name) const;
|
||||||
uint32 CountItems() const;
|
uint32 CountItems() const;
|
||||||
|
|
||||||
// Item modification member functions
|
// Item modification methods
|
||||||
status_t AddItem(BView* archivableView,
|
status_t AddItem(BView* archivableView,
|
||||||
int32* _id = NULL);
|
int32* _id = NULL);
|
||||||
status_t AddItem(entry_ref* addOn, int32* _id = NULL);
|
status_t AddItem(entry_ref* addOn, int32* _id = NULL);
|
||||||
@@ -58,4 +60,5 @@ private:
|
|||||||
uint32 _reserved[12];
|
uint32 _reserved[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // _DESKBAR_H
|
#endif // _DESKBAR_H
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2017 Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Jeremy Rand ([email protected])
|
|
||||||
* Jérôme Duval
|
* Jérôme Duval
|
||||||
* Axel Dörfler
|
* Axel Dörfler
|
||||||
|
* Jeremy Rand, [email protected]
|
||||||
|
* John Scipione, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
// ToDo: in case the BDeskbar methods are called from a Deskbar add-on,
|
// ToDo: in case the BDeskbar methods are called from a Deskbar add-on,
|
||||||
// they will currently deadlock most of the time (only those that do
|
// they will currently deadlock most of the time (only those that do
|
||||||
// not need a reply will work).
|
// not need a reply will work).
|
||||||
@@ -28,7 +30,8 @@
|
|||||||
// The API in this file should be considered as part of OpenTracker - but
|
// The API in this file should be considered as part of OpenTracker - but
|
||||||
// should work with all versions of Tracker available for Haiku.
|
// should work with all versions of Tracker available for Haiku.
|
||||||
|
|
||||||
static const char *kDeskbarSignature = "application/x-vnd.Be-TSKB";
|
|
||||||
|
static const char* kDeskbarSignature = "application/x-vnd.Be-TSKB";
|
||||||
|
|
||||||
static const uint32 kMsgAddView = 'icon';
|
static const uint32 kMsgAddView = 'icon';
|
||||||
static const uint32 kMsgAddAddOn = 'adon';
|
static const uint32 kMsgAddAddOn = 'adon';
|
||||||
@@ -43,7 +46,7 @@ static const uint32 kMsgExpand = 'sexp';
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_deskbar_frame(BRect *frame)
|
get_deskbar_frame(BRect* frame)
|
||||||
{
|
{
|
||||||
BMessenger deskbar(kDeskbarSignature);
|
BMessenger deskbar(kDeskbarSignature);
|
||||||
|
|
||||||
@@ -56,17 +59,18 @@ get_deskbar_frame(BRect *frame)
|
|||||||
BMessage reply;
|
BMessage reply;
|
||||||
result = deskbar.SendMessage(&request, &reply);
|
result = deskbar.SendMessage(&request, &reply);
|
||||||
if (result == B_OK)
|
if (result == B_OK)
|
||||||
result = reply.FindRect("result", frame);
|
result = reply.FindRect("result", frame);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - BDeskbar
|
||||||
|
|
||||||
|
|
||||||
BDeskbar::BDeskbar()
|
BDeskbar::BDeskbar()
|
||||||
: fMessenger(new BMessenger(kDeskbarSignature))
|
:
|
||||||
|
fMessenger(new BMessenger(kDeskbarSignature))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +88,9 @@ BDeskbar::IsRunning() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Item querying methods
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BDeskbar::Frame() const
|
BDeskbar::Frame() const
|
||||||
{
|
{
|
||||||
@@ -95,7 +102,7 @@ BDeskbar::Frame() const
|
|||||||
|
|
||||||
|
|
||||||
deskbar_location
|
deskbar_location
|
||||||
BDeskbar::Location(bool *_isExpanded) const
|
BDeskbar::Location(bool* _isExpanded) const
|
||||||
{
|
{
|
||||||
deskbar_location location = B_DESKBAR_RIGHT_TOP;
|
deskbar_location location = B_DESKBAR_RIGHT_TOP;
|
||||||
BMessage request(kMsgLocation);
|
BMessage request(kMsgLocation);
|
||||||
@@ -115,8 +122,7 @@ BDeskbar::Location(bool *_isExpanded) const
|
|||||||
if (reply.FindInt32("location", &value) == B_OK)
|
if (reply.FindInt32("location", &value) == B_OK)
|
||||||
location = static_cast<deskbar_location>(value);
|
location = static_cast<deskbar_location>(value);
|
||||||
|
|
||||||
if (_isExpanded
|
if (_isExpanded && reply.FindBool("expanded", _isExpanded) != B_OK)
|
||||||
&& reply.FindBool("expanded", _isExpanded) != B_OK)
|
|
||||||
*_isExpanded = true;
|
*_isExpanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,16 +141,20 @@ BDeskbar::SetLocation(deskbar_location location, bool expanded)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Other state methods
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BDeskbar::IsExpanded(void) const
|
BDeskbar::IsExpanded() const
|
||||||
{
|
{
|
||||||
BMessage request(kMsgIsExpanded);
|
BMessage request(kMsgIsExpanded);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
bool isExpanded;
|
bool isExpanded;
|
||||||
|
|
||||||
if (fMessenger->SendMessage(&request, &reply) != B_OK
|
if (fMessenger->SendMessage(&request, &reply) != B_OK
|
||||||
|| reply.FindBool("expanded", &isExpanded) != B_OK)
|
|| reply.FindBool("expanded", &isExpanded) != B_OK) {
|
||||||
isExpanded = true;
|
isExpanded = true;
|
||||||
|
}
|
||||||
|
|
||||||
return isExpanded;
|
return isExpanded;
|
||||||
}
|
}
|
||||||
@@ -160,8 +170,11 @@ BDeskbar::Expand(bool expand)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Item querying methods
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDeskbar::GetItemInfo(int32 id, const char **_name) const
|
BDeskbar::GetItemInfo(int32 id, const char** _name) const
|
||||||
{
|
{
|
||||||
if (_name == NULL)
|
if (_name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -176,7 +189,7 @@ BDeskbar::GetItemInfo(int32 id, const char **_name) const
|
|||||||
BMessage reply;
|
BMessage reply;
|
||||||
status_t result = fMessenger->SendMessage(&request, &reply);
|
status_t result = fMessenger->SendMessage(&request, &reply);
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
const char *name;
|
const char* name;
|
||||||
result = reply.FindString("name", &name);
|
result = reply.FindString("name", &name);
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
*_name = strdup(name);
|
*_name = strdup(name);
|
||||||
@@ -184,12 +197,13 @@ BDeskbar::GetItemInfo(int32 id, const char **_name) const
|
|||||||
result = B_NO_MEMORY;
|
result = B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDeskbar::GetItemInfo(const char *name, int32 *_id) const
|
BDeskbar::GetItemInfo(const char* name, int32* _id) const
|
||||||
{
|
{
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -221,7 +235,7 @@ BDeskbar::HasItem(int32 id) const
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BDeskbar::HasItem(const char *name) const
|
BDeskbar::HasItem(const char* name) const
|
||||||
{
|
{
|
||||||
BMessage request(kMsgHasItem);
|
BMessage request(kMsgHasItem);
|
||||||
request.AddString("name", name);
|
request.AddString("name", name);
|
||||||
@@ -247,8 +261,11 @@ BDeskbar::CountItems(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Item querying methods
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDeskbar::AddItem(BView *view, int32 *_id)
|
BDeskbar::AddItem(BView* view, int32* _id)
|
||||||
{
|
{
|
||||||
BMessage archive;
|
BMessage archive;
|
||||||
status_t result = view->Archive(&archive);
|
status_t result = view->Archive(&archive);
|
||||||
@@ -272,7 +289,7 @@ BDeskbar::AddItem(BView *view, int32 *_id)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDeskbar::AddItem(entry_ref *addon, int32 *_id)
|
BDeskbar::AddItem(entry_ref* addon, int32* _id)
|
||||||
{
|
{
|
||||||
BMessage request(kMsgAddAddOn);
|
BMessage request(kMsgAddAddOn);
|
||||||
request.AddRef("addon", addon);
|
request.AddRef("addon", addon);
|
||||||
@@ -305,7 +322,7 @@ BDeskbar::RemoveItem(int32 id)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BDeskbar::RemoveItem(const char *name)
|
BDeskbar::RemoveItem(const char* name)
|
||||||
{
|
{
|
||||||
BMessage request(kMsgRemoveItem);
|
BMessage request(kMsgRemoveItem);
|
||||||
request.AddString("name", name);
|
request.AddString("name", name);
|
||||||
@@ -315,6 +332,4 @@ BDeskbar::RemoveItem(const char *name)
|
|||||||
// message was sent to the Deskbar
|
// message was sent to the Deskbar
|
||||||
|
|
||||||
return fMessenger->SendMessage(&request);
|
return fMessenger->SendMessage(&request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user