From 8cc8b1b7e9ce69b3367fe1499d40b319ee05c415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 26 Aug 2009 14:53:06 +0000 Subject: [PATCH] * Updated indentation style * Fixed copyright * Reordered inherited virtuals to improve the grouping +alphabranch git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32718 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/PictureButton.h | 128 ++++++------- src/kits/interface/PictureButton.cpp | 262 ++++++++++++++------------- 2 files changed, 199 insertions(+), 191 deletions(-) diff --git a/headers/os/interface/PictureButton.h b/headers/os/interface/PictureButton.h index 5d50de3cf3..3f6286866f 100644 --- a/headers/os/interface/PictureButton.h +++ b/headers/os/interface/PictureButton.h @@ -1,9 +1,6 @@ /* - * Copyright 2001-2008, Haiku, Inc. + * Copyright 2001-2008, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. - * - * Authors: - * Graham MacDonald (macdonag@btopenworld.com) */ #ifndef _PICTURE_BUTTON_H #define _PICTURE_BUTTON_H @@ -20,85 +17,88 @@ enum { }; -class BPictureButton : public BControl -{ +class BPictureButton : public BControl { public: - BPictureButton(BRect frame, const char* name, BPicture* off, - BPicture* on, BMessage* message, - uint32 behavior = B_ONE_STATE_BUTTON, - uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 flgs = B_WILL_DRAW | B_NAVIGABLE); - BPictureButton(BMessage* data); + BPictureButton(BRect frame, const char* name, + BPicture* off, BPicture* on, + BMessage* message, + uint32 behavior = B_ONE_STATE_BUTTON, + uint32 resizeMask = B_FOLLOW_LEFT + | B_FOLLOW_TOP, + uint32 flgs = B_WILL_DRAW | B_NAVIGABLE); + BPictureButton(BMessage* archive); - virtual ~BPictureButton(); + virtual ~BPictureButton(); + static BArchivable* Instantiate(BMessage* archive); + virtual status_t Archive(BMessage* archive, + bool deep = true) const; - static BArchivable* Instantiate(BMessage* data); - virtual status_t Archive(BMessage* data, bool deep = true) const; + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + virtual void AllAttached(); + virtual void AllDetached(); - virtual void Draw(BRect updateRect); + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* _width, + float* _height); + virtual void FrameMoved(BPoint position); + virtual void FrameResized(float width, float height); - virtual void MouseDown(BPoint point); - virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void WindowActivated(bool state); + virtual void MakeFocus(bool state = true); - virtual void SetEnabledOn(BPicture* on); - virtual void SetEnabledOff(BPicture* off); - virtual void SetDisabledOn(BPicture* on); - virtual void SetDisabledOff(BPicture* off); + virtual void Draw(BRect updateRect); - BPicture* EnabledOn() const; - BPicture* EnabledOff() const; - BPicture* DisabledOn() const; - BPicture* DisabledOff() const; + virtual void MessageReceived(BMessage* message); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* message); - virtual void SetBehavior(uint32 behavior); - uint32 Behavior() const; + virtual void SetEnabledOn(BPicture* on); + virtual void SetEnabledOff(BPicture* off); + virtual void SetDisabledOn(BPicture* on); + virtual void SetDisabledOff(BPicture* off); - virtual void MessageReceived(BMessage* message); - virtual void MouseUp(BPoint point); - virtual void WindowActivated(bool state); - virtual void MouseMoved(BPoint pt, uint32 code, - const BMessage* message); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void SetValue(int32 value); - virtual status_t Invoke(BMessage* message = NULL); - virtual void FrameMoved(BPoint newPosition); - virtual void FrameResized(float newWidth, float newHeight); + BPicture* EnabledOn() const; + BPicture* EnabledOff() const; + BPicture* DisabledOn() const; + BPicture* DisabledOff() const; - virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, const char* p); - virtual status_t GetSupportedSuites(BMessage* data); + virtual void SetBehavior(uint32 behavior); + uint32 Behavior() const; - virtual void ResizeToPreferred(); - virtual void GetPreferredSize(float* width, float* height); - virtual void MakeFocus(bool state = true); - virtual void AllAttached(); - virtual void AllDetached(); + virtual void SetValue(int32 value); + virtual status_t Invoke(BMessage* message = NULL); - virtual status_t Perform(perform_code d, void* arg); + virtual BHandler* ResolveSpecifier(BMessage* message, + int32 index, BMessage* specifier, + int32 form, const char* property); + virtual status_t GetSupportedSuites(BMessage* data); + + virtual status_t Perform(perform_code code, void* data); private: + // FBC padding and forbidden methods + virtual void _ReservedPictureButton1(); + virtual void _ReservedPictureButton2(); + virtual void _ReservedPictureButton3(); - virtual void _ReservedPictureButton1(); - virtual void _ReservedPictureButton2(); - virtual void _ReservedPictureButton3(); + BPictureButton& operator=(const BPictureButton& other); - BPictureButton &operator=(const BPictureButton &); +private: + BPicture* fEnabledOff; + BPicture* fEnabledOn; + BPicture* fDisabledOff; + BPicture* fDisabledOn; - void _Redraw(); - void _InitData(); + bool unused; - BPicture* fEnabledOff; - BPicture* fEnabledOn; - BPicture* fDisabledOff; - BPicture* fDisabledOn; + uint32 fBehavior; - bool unused; - - uint32 fBehavior; - uint32 _reserved[4]; + uint32 _reserved[4]; }; - -#endif +#endif // _PICTURE_BUTTON_H diff --git a/src/kits/interface/PictureButton.cpp b/src/kits/interface/PictureButton.cpp index ae638d2329..dca02529ac 100644 --- a/src/kits/interface/PictureButton.cpp +++ b/src/kits/interface/PictureButton.cpp @@ -8,26 +8,28 @@ #include -#include - #include +#include + BPictureButton::BPictureButton(BRect frame, const char* name, BPicture* off, BPicture* on, BMessage* message, uint32 behavior, uint32 resizeMask, uint32 flags) - : BControl(frame, name, "", message, resizeMask, flags), - fDisabledOff(NULL), - fDisabledOn(NULL), - fBehavior(behavior) + : + BControl(frame, name, "", message, resizeMask, flags), + fEnabledOff(new(std::nothrow) BPicture(*off)), + fEnabledOn(new(std::nothrow) BPicture(*on)), + fDisabledOff(NULL), + fDisabledOn(NULL), + fBehavior(behavior) { - fEnabledOff = new (std::nothrow)BPicture(*off); - fEnabledOn = new (std::nothrow) BPicture(*on); } BPictureButton::BPictureButton(BMessage* data) - : BControl(data), + : + BControl(data), fEnabledOff(NULL), fEnabledOn(NULL), fDisabledOff(NULL), @@ -41,16 +43,16 @@ BPictureButton::BPictureButton(BMessage* data) // Now expand the pictures: if (data->FindMessage("_e_on", &pictureArchive) == B_OK) - fEnabledOn = new (std::nothrow) BPicture(&pictureArchive); + fEnabledOn = new(std::nothrow) BPicture(&pictureArchive); if (data->FindMessage("_e_off", &pictureArchive) == B_OK) - fEnabledOff = new (std::nothrow) BPicture(&pictureArchive); + fEnabledOff = new(std::nothrow) BPicture(&pictureArchive); if (data->FindMessage("_d_on", &pictureArchive) == B_OK) - fDisabledOn = new (std::nothrow) BPicture(&pictureArchive); + fDisabledOn = new(std::nothrow) BPicture(&pictureArchive); if (data->FindMessage("_d_off", &pictureArchive) == B_OK) - fDisabledOff = new (std::nothrow) BPicture(&pictureArchive); + fDisabledOff = new(std::nothrow) BPicture(&pictureArchive); } @@ -63,6 +65,9 @@ BPictureButton::~BPictureButton() } +// #pragma mark - + + BArchivable* BPictureButton::Instantiate(BMessage* data) { @@ -113,6 +118,85 @@ BPictureButton::Archive(BMessage* data, bool deep) const } +// #pragma mark - + + +void +BPictureButton::AttachedToWindow() +{ + BControl::AttachedToWindow(); +} + + +void +BPictureButton::DetachedFromWindow() +{ + BControl::DetachedFromWindow(); +} + + +void +BPictureButton::AllAttached() +{ + BControl::AllAttached(); +} + + +void +BPictureButton::AllDetached() +{ + BControl::AllDetached(); +} + + +// #pragma mark - + + +void +BPictureButton::ResizeToPreferred() +{ + BControl::ResizeToPreferred(); +} + + +void +BPictureButton::GetPreferredSize(float* _width, float* _height) +{ + BControl::GetPreferredSize(_width, _height); +} + + +void +BPictureButton::FrameMoved(BPoint newPosition) +{ + BControl::FrameMoved(newPosition); +} + + +void +BPictureButton::FrameResized(float newWidth, float newHeight) +{ + BControl::FrameResized(newWidth, newHeight); +} + + +// #pragma mark - + + +void +BPictureButton::WindowActivated(bool state) +{ + BControl::WindowActivated(state); +} + + +void +BPictureButton::MakeFocus(bool state) +{ + BControl::MakeFocus(state); +} + + void BPictureButton::Draw(BRect updateRect) { @@ -140,6 +224,39 @@ BPictureButton::Draw(BRect updateRect) } +void +BPictureButton::MessageReceived(BMessage* msg) +{ + BControl::MessageReceived(msg); +} + + +void +BPictureButton::KeyDown(const char* bytes, int32 numBytes) +{ + if (numBytes == 1) { + switch (bytes[0]) { + case B_ENTER: + case B_SPACE: + if (fBehavior == B_ONE_STATE_BUTTON) { + SetValue(B_CONTROL_ON); + snooze(50000); + SetValue(B_CONTROL_OFF); + } else { + if (Value() == B_CONTROL_ON) + SetValue(B_CONTROL_OFF); + else + SetValue(B_CONTROL_ON); + } + Invoke(); + return; + } + } + + BControl::KeyDown(bytes, numBytes); +} + + void BPictureButton::MouseDown(BPoint point) { @@ -195,30 +312,7 @@ BPictureButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) } -void -BPictureButton::KeyDown(const char* bytes, int32 numBytes) -{ - if (numBytes == 1) { - switch (bytes[0]) { - case B_ENTER: - case B_SPACE: - if (fBehavior == B_ONE_STATE_BUTTON) { - SetValue(B_CONTROL_ON); - snooze(50000); - SetValue(B_CONTROL_OFF); - } else { - if (Value() == B_CONTROL_ON) - SetValue(B_CONTROL_OFF); - else - SetValue(B_CONTROL_ON); - } - Invoke(); - return; - } - } - - BControl::KeyDown(bytes, numBytes); -} +// #pragma mark - void @@ -295,34 +389,6 @@ BPictureButton::Behavior() const } -void -BPictureButton::MessageReceived(BMessage* msg) -{ - BControl::MessageReceived(msg); -} - - -void -BPictureButton::WindowActivated(bool state) -{ - BControl::WindowActivated(state); -} - - -void -BPictureButton::AttachedToWindow() -{ - BControl::AttachedToWindow(); -} - - -void -BPictureButton::DetachedFromWindow() -{ - BControl::DetachedFromWindow(); -} - - void BPictureButton::SetValue(int32 value) { @@ -337,20 +403,6 @@ BPictureButton::Invoke(BMessage* msg) } -void -BPictureButton::FrameMoved(BPoint newPosition) -{ - BControl::FrameMoved(newPosition); -} - - -void -BPictureButton::FrameResized(float newWidth, float newHeight) -{ - BControl::FrameResized(newWidth, newHeight); -} - - BHandler* BPictureButton::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, int32 form, const char* property) @@ -366,41 +418,6 @@ BPictureButton::GetSupportedSuites(BMessage* data) } -void -BPictureButton::ResizeToPreferred() -{ - BControl::ResizeToPreferred(); -} - - -void -BPictureButton::GetPreferredSize(float* _width, float* _height) -{ - BControl::GetPreferredSize(_width, _height); -} - - -void -BPictureButton::MakeFocus(bool state) -{ - BControl::MakeFocus(state); -} - - -void -BPictureButton::AllAttached() -{ - BControl::AllAttached(); -} - - -void -BPictureButton::AllDetached() -{ - BControl::AllDetached(); -} - - status_t BPictureButton::Perform(perform_code code, void* _data) { @@ -432,7 +449,7 @@ BPictureButton::Perform(perform_code code, void* _data) BPictureButton::GetHeightForWidth(data->width, &data->min, &data->max, &data->preferred); return B_OK; -} + } case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; @@ -457,6 +474,9 @@ BPictureButton::Perform(perform_code code, void* _data) } +// #pragma mark - + + void BPictureButton::_ReservedPictureButton1() {} void BPictureButton::_ReservedPictureButton2() {} void BPictureButton::_ReservedPictureButton3() {} @@ -468,15 +488,3 @@ BPictureButton::operator=(const BPictureButton &button) return *this; } - -void -BPictureButton::_Redraw() -{ -} - - -void -BPictureButton::_InitData() -{ -} -