* 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
This commit is contained in:
@@ -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.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Graham MacDonald ([email protected])
|
|
||||||
*/
|
*/
|
||||||
#ifndef _PICTURE_BUTTON_H
|
#ifndef _PICTURE_BUTTON_H
|
||||||
#define _PICTURE_BUTTON_H
|
#define _PICTURE_BUTTON_H
|
||||||
@@ -20,85 +17,88 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BPictureButton : public BControl
|
class BPictureButton : public BControl {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
BPictureButton(BRect frame, const char* name, BPicture* off,
|
BPictureButton(BRect frame, const char* name,
|
||||||
BPicture* on, BMessage* message,
|
BPicture* off, BPicture* on,
|
||||||
uint32 behavior = B_ONE_STATE_BUTTON,
|
BMessage* message,
|
||||||
uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 behavior = B_ONE_STATE_BUTTON,
|
||||||
uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
|
uint32 resizeMask = B_FOLLOW_LEFT
|
||||||
BPictureButton(BMessage* data);
|
| 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 void AttachedToWindow();
|
||||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
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 WindowActivated(bool state);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void MakeFocus(bool state = true);
|
||||||
|
|
||||||
virtual void SetEnabledOn(BPicture* on);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void SetEnabledOff(BPicture* off);
|
|
||||||
virtual void SetDisabledOn(BPicture* on);
|
|
||||||
virtual void SetDisabledOff(BPicture* off);
|
|
||||||
|
|
||||||
BPicture* EnabledOn() const;
|
virtual void MessageReceived(BMessage* message);
|
||||||
BPicture* EnabledOff() const;
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
BPicture* DisabledOn() const;
|
virtual void MouseDown(BPoint where);
|
||||||
BPicture* DisabledOff() const;
|
virtual void MouseUp(BPoint where);
|
||||||
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* message);
|
||||||
|
|
||||||
virtual void SetBehavior(uint32 behavior);
|
virtual void SetEnabledOn(BPicture* on);
|
||||||
uint32 Behavior() const;
|
virtual void SetEnabledOff(BPicture* off);
|
||||||
|
virtual void SetDisabledOn(BPicture* on);
|
||||||
|
virtual void SetDisabledOff(BPicture* off);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
BPicture* EnabledOn() const;
|
||||||
virtual void MouseUp(BPoint point);
|
BPicture* EnabledOff() const;
|
||||||
virtual void WindowActivated(bool state);
|
BPicture* DisabledOn() const;
|
||||||
virtual void MouseMoved(BPoint pt, uint32 code,
|
BPicture* DisabledOff() const;
|
||||||
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);
|
|
||||||
|
|
||||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
virtual void SetBehavior(uint32 behavior);
|
||||||
BMessage* specifier, int32 form, const char* p);
|
uint32 Behavior() const;
|
||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
|
||||||
|
|
||||||
virtual void ResizeToPreferred();
|
virtual void SetValue(int32 value);
|
||||||
virtual void GetPreferredSize(float* width, float* height);
|
virtual status_t Invoke(BMessage* message = NULL);
|
||||||
virtual void MakeFocus(bool state = true);
|
|
||||||
virtual void AllAttached();
|
|
||||||
virtual void AllDetached();
|
|
||||||
|
|
||||||
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:
|
private:
|
||||||
|
// FBC padding and forbidden methods
|
||||||
|
virtual void _ReservedPictureButton1();
|
||||||
|
virtual void _ReservedPictureButton2();
|
||||||
|
virtual void _ReservedPictureButton3();
|
||||||
|
|
||||||
virtual void _ReservedPictureButton1();
|
BPictureButton& operator=(const BPictureButton& other);
|
||||||
virtual void _ReservedPictureButton2();
|
|
||||||
virtual void _ReservedPictureButton3();
|
|
||||||
|
|
||||||
BPictureButton &operator=(const BPictureButton &);
|
private:
|
||||||
|
BPicture* fEnabledOff;
|
||||||
|
BPicture* fEnabledOn;
|
||||||
|
BPicture* fDisabledOff;
|
||||||
|
BPicture* fDisabledOn;
|
||||||
|
|
||||||
void _Redraw();
|
bool unused;
|
||||||
void _InitData();
|
|
||||||
|
|
||||||
BPicture* fEnabledOff;
|
uint32 fBehavior;
|
||||||
BPicture* fEnabledOn;
|
|
||||||
BPicture* fDisabledOff;
|
|
||||||
BPicture* fDisabledOn;
|
|
||||||
|
|
||||||
bool unused;
|
uint32 _reserved[4];
|
||||||
|
|
||||||
uint32 fBehavior;
|
|
||||||
uint32 _reserved[4];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // _PICTURE_BUTTON_H
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -8,26 +8,28 @@
|
|||||||
|
|
||||||
#include <PictureButton.h>
|
#include <PictureButton.h>
|
||||||
|
|
||||||
#include <binary_compatibility/Interface.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <binary_compatibility/Interface.h>
|
||||||
|
|
||||||
|
|
||||||
BPictureButton::BPictureButton(BRect frame, const char* name,
|
BPictureButton::BPictureButton(BRect frame, const char* name,
|
||||||
BPicture* off, BPicture* on, BMessage* message,
|
BPicture* off, BPicture* on, BMessage* message,
|
||||||
uint32 behavior, uint32 resizeMask, uint32 flags)
|
uint32 behavior, uint32 resizeMask, uint32 flags)
|
||||||
: BControl(frame, name, "", message, resizeMask, flags),
|
:
|
||||||
fDisabledOff(NULL),
|
BControl(frame, name, "", message, resizeMask, flags),
|
||||||
fDisabledOn(NULL),
|
fEnabledOff(new(std::nothrow) BPicture(*off)),
|
||||||
fBehavior(behavior)
|
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)
|
BPictureButton::BPictureButton(BMessage* data)
|
||||||
: BControl(data),
|
:
|
||||||
|
BControl(data),
|
||||||
fEnabledOff(NULL),
|
fEnabledOff(NULL),
|
||||||
fEnabledOn(NULL),
|
fEnabledOn(NULL),
|
||||||
fDisabledOff(NULL),
|
fDisabledOff(NULL),
|
||||||
@@ -41,16 +43,16 @@ BPictureButton::BPictureButton(BMessage* data)
|
|||||||
|
|
||||||
// Now expand the pictures:
|
// Now expand the pictures:
|
||||||
if (data->FindMessage("_e_on", &pictureArchive) == B_OK)
|
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)
|
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)
|
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)
|
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*
|
BArchivable*
|
||||||
BPictureButton::Instantiate(BMessage* data)
|
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
|
void
|
||||||
BPictureButton::Draw(BRect updateRect)
|
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
|
void
|
||||||
BPictureButton::MouseDown(BPoint point)
|
BPictureButton::MouseDown(BPoint point)
|
||||||
{
|
{
|
||||||
@@ -195,30 +312,7 @@ BPictureButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
// #pragma mark -
|
||||||
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
|
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
|
void
|
||||||
BPictureButton::SetValue(int32 value)
|
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*
|
BHandler*
|
||||||
BPictureButton::ResolveSpecifier(BMessage* msg, int32 index,
|
BPictureButton::ResolveSpecifier(BMessage* msg, int32 index,
|
||||||
BMessage* specifier, int32 form, const char* property)
|
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
|
status_t
|
||||||
BPictureButton::Perform(perform_code code, void* _data)
|
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,
|
BPictureButton::GetHeightForWidth(data->width, &data->min, &data->max,
|
||||||
&data->preferred);
|
&data->preferred);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
case PERFORM_CODE_SET_LAYOUT:
|
case PERFORM_CODE_SET_LAYOUT:
|
||||||
{
|
{
|
||||||
perform_data_set_layout* data = (perform_data_set_layout*)_data;
|
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::_ReservedPictureButton1() {}
|
||||||
void BPictureButton::_ReservedPictureButton2() {}
|
void BPictureButton::_ReservedPictureButton2() {}
|
||||||
void BPictureButton::_ReservedPictureButton3() {}
|
void BPictureButton::_ReservedPictureButton3() {}
|
||||||
@@ -468,15 +488,3 @@ BPictureButton::operator=(const BPictureButton &button)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BPictureButton::_Redraw()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
BPictureButton::_InitData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user