BControl: Style fixes, variable renaming for consistency, docs.

Also some other style fixes, no functional changes intended.
This commit is contained in:
John Scipione 2014-05-28 14:05:22 -04:00
parent 9c244999df
commit 092e3093c3
2 changed files with 55 additions and 52 deletions

View File

@ -33,10 +33,9 @@ public:
BMessage* message, uint32 flags); BMessage* message, uint32 flags);
virtual ~BControl(); virtual ~BControl();
BControl(BMessage* archive); BControl(BMessage* data);
static BArchivable* Instantiate(BMessage* archive); static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* archive, virtual status_t Archive(BMessage* data, bool deep = true) const;
bool deep = true) const;
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);
@ -49,10 +48,10 @@ public:
virtual void MakeFocus(bool focused = true); virtual void MakeFocus(bool focused = true);
virtual void KeyDown(const char* bytes, int32 numBytes); virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void MouseDown(BPoint point); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint point); virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint point, uint32 transit, virtual void MouseMoved(BPoint where, uint32 code,
const BMessage *message); const BMessage* dragMessage);
virtual void SetLabel(const char* string); virtual void SetLabel(const char* string);
const char* Label() const; const char* Label() const;

View File

@ -7,7 +7,8 @@
* Ingo Weinhold, ingo_weinhold@gmx.de * Ingo Weinhold, ingo_weinhold@gmx.de
*/ */
/*! BControl is the base class for user-event handling objects. */
// BControl is the base class for user-event handling objects.
#include <stdlib.h> #include <stdlib.h>
@ -47,9 +48,10 @@ static property_info sPropertyList[] = {
}; };
BControl::BControl(BRect frame, const char *name, const char *label, BControl::BControl(BRect frame, const char* name, const char* label,
BMessage *message, uint32 resizingMode, uint32 flags) BMessage* message, uint32 resizingMode, uint32 flags)
: BView(frame, name, resizingMode, flags) :
BView(frame, name, resizingMode, flags)
{ {
InitData(NULL); InitData(NULL);
@ -58,9 +60,10 @@ BControl::BControl(BRect frame, const char *name, const char *label,
} }
BControl::BControl(const char *name, const char *label, BMessage *message, BControl::BControl(const char* name, const char* label, BMessage* message,
uint32 flags) uint32 flags)
: BView(name, flags) :
BView(name, flags)
{ {
InitData(NULL); InitData(NULL);
@ -77,58 +80,59 @@ BControl::~BControl()
} }
BControl::BControl(BMessage *archive) BControl::BControl(BMessage* data)
: BView(archive) :
BView(data)
{ {
InitData(archive); InitData(data);
BMessage message; BMessage message;
if (archive->FindMessage("_msg", &message) == B_OK) if (data->FindMessage("_msg", &message) == B_OK)
SetMessage(new BMessage(message)); SetMessage(new BMessage(message));
const char *label; const char* label;
if (archive->FindString("_label", &label) == B_OK) if (data->FindString("_label", &label) == B_OK)
SetLabel(label); SetLabel(label);
int32 value; int32 value;
if (archive->FindInt32("_val", &value) == B_OK) if (data->FindInt32("_val", &value) == B_OK)
SetValue(value); SetValue(value);
bool toggle; bool toggle;
if (archive->FindBool("_disable", &toggle) == B_OK) if (data->FindBool("_disable", &toggle) == B_OK)
SetEnabled(!toggle); SetEnabled(!toggle);
if (archive->FindBool("be:wants_nav", &toggle) == B_OK) if (data->FindBool("be:wants_nav", &toggle) == B_OK)
fWantsNav = toggle; fWantsNav = toggle;
} }
BArchivable * BArchivable*
BControl::Instantiate(BMessage *archive) BControl::Instantiate(BMessage* data)
{ {
if (validate_instantiation(archive, "BControl")) if (validate_instantiation(data, "BControl"))
return new BControl(archive); return new BControl(data);
return NULL; return NULL;
} }
status_t status_t
BControl::Archive(BMessage *archive, bool deep) const BControl::Archive(BMessage* data, bool deep) const
{ {
status_t status = BView::Archive(archive, deep); status_t status = BView::Archive(data, deep);
if (status == B_OK && Message()) if (status == B_OK && Message())
status = archive->AddMessage("_msg", Message()); status = data->AddMessage("_msg", Message());
if (status == B_OK && fLabel) if (status == B_OK && fLabel)
status = archive->AddString("_label", fLabel); status = data->AddString("_label", fLabel);
if (status == B_OK && fValue != B_CONTROL_OFF) if (status == B_OK && fValue != B_CONTROL_OFF)
status = archive->AddInt32("_val", fValue); status = data->AddInt32("_val", fValue);
if (status == B_OK && !fEnabled) if (status == B_OK && !fEnabled)
status = archive->AddBool("_disable", true); status = data->AddBool("_disable", true);
return status; return status;
} }
@ -190,7 +194,7 @@ BControl::AllDetached()
void void
BControl::MessageReceived(BMessage *message) BControl::MessageReceived(BMessage* message)
{ {
if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) { if (message->what == B_GET_PROPERTY || message->what == B_SET_PROPERTY) {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
@ -199,7 +203,7 @@ BControl::MessageReceived(BMessage *message)
BMessage specifier; BMessage specifier;
int32 index; int32 index;
int32 form; int32 form;
const char *property; const char* property;
if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) { if (message->GetCurrentSpecifier(&index, &specifier, &form, &property) == B_OK) {
if (strcmp(property, "Label") == 0) { if (strcmp(property, "Label") == 0) {
if (message->what == B_GET_PROPERTY) { if (message->what == B_GET_PROPERTY) {
@ -207,7 +211,7 @@ BControl::MessageReceived(BMessage *message)
handled = true; handled = true;
} else { } else {
// B_SET_PROPERTY // B_SET_PROPERTY
const char *label; const char* label;
if (message->FindString("data", &label) == B_OK) { if (message->FindString("data", &label) == B_OK) {
SetLabel(label); SetLabel(label);
reply.AddInt32("error", B_OK); reply.AddInt32("error", B_OK);
@ -271,7 +275,7 @@ BControl::MakeFocus(bool focused)
void void
BControl::KeyDown(const char *bytes, int32 numBytes) BControl::KeyDown(const char* bytes, int32 numBytes)
{ {
if (*bytes == B_ENTER || *bytes == B_SPACE) { if (*bytes == B_ENTER || *bytes == B_SPACE) {
if (!fEnabled) if (!fEnabled)
@ -285,28 +289,28 @@ BControl::KeyDown(const char *bytes, int32 numBytes)
void void
BControl::MouseDown(BPoint point) BControl::MouseDown(BPoint where)
{ {
BView::MouseDown(point); BView::MouseDown(where);
} }
void void
BControl::MouseUp(BPoint point) BControl::MouseUp(BPoint where)
{ {
BView::MouseUp(point); BView::MouseUp(where);
} }
void void
BControl::MouseMoved(BPoint point, uint32 transit, const BMessage *message) BControl::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
{ {
BView::MouseMoved(point, transit, message); BView::MouseMoved(where, code, dragMessage);
} }
void void
BControl::SetLabel(const char *label) BControl::SetLabel(const char* label)
{ {
if (label != NULL && !label[0]) if (label != NULL && !label[0])
label = NULL; label = NULL;
@ -324,7 +328,7 @@ BControl::SetLabel(const char *label)
} }
const char * const char*
BControl::Label() const BControl::Label() const
{ {
return fLabel; return fLabel;
@ -387,7 +391,7 @@ BControl::IsEnabled() const
void void
BControl::GetPreferredSize(float *_width, float *_height) BControl::GetPreferredSize(float* _width, float* _height)
{ {
BView::GetPreferredSize(_width, _height); BView::GetPreferredSize(_width, _height);
} }
@ -401,7 +405,7 @@ BControl::ResizeToPreferred()
status_t status_t
BControl::Invoke(BMessage *message) BControl::Invoke(BMessage* message)
{ {
bool notify = false; bool notify = false;
uint32 kind = InvokeKind(&notify); uint32 kind = InvokeKind(&notify);
@ -436,9 +440,9 @@ BControl::Invoke(BMessage *message)
} }
BHandler * BHandler*
BControl::ResolveSpecifier(BMessage *message, int32 index, BControl::ResolveSpecifier(BMessage* message, int32 index,
BMessage *specifier, int32 what, const char *property) BMessage* specifier, int32 what, const char* property)
{ {
BPropertyInfo propInfo(sPropertyList); BPropertyInfo propInfo(sPropertyList);
@ -451,7 +455,7 @@ BControl::ResolveSpecifier(BMessage *message, int32 index,
status_t status_t
BControl::GetSupportedSuites(BMessage *message) BControl::GetSupportedSuites(BMessage* message)
{ {
message->AddString("suites", "suite/vnd.Be-control"); message->AddString("suites", "suite/vnd.Be-control");
@ -604,7 +608,7 @@ BControl::operator=(const BControl &)
void void
BControl::InitData(BMessage *data) BControl::InitData(BMessage* data)
{ {
fLabel = NULL; fLabel = NULL;
SetLabel(B_EMPTY_STRING); SetLabel(B_EMPTY_STRING);