* 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:
parent
15ff16b991
commit
8cc8b1b7e9
@ -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,26 +17,45 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
class BPictureButton : public BControl
|
||||
{
|
||||
class BPictureButton : public BControl {
|
||||
public:
|
||||
BPictureButton(BRect frame, const char* name, BPicture* off,
|
||||
BPicture* on, BMessage* message,
|
||||
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 resizeMask = B_FOLLOW_LEFT
|
||||
| B_FOLLOW_TOP,
|
||||
uint32 flgs = B_WILL_DRAW | B_NAVIGABLE);
|
||||
BPictureButton(BMessage* data);
|
||||
BPictureButton(BMessage* archive);
|
||||
|
||||
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 ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* _width,
|
||||
float* _height);
|
||||
virtual void FrameMoved(BPoint position);
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
virtual void MouseDown(BPoint point);
|
||||
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 SetEnabledOn(BPicture* on);
|
||||
virtual void SetEnabledOff(BPicture* off);
|
||||
@ -54,41 +70,25 @@ public:
|
||||
virtual void SetBehavior(uint32 behavior);
|
||||
uint32 Behavior() const;
|
||||
|
||||
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);
|
||||
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 form, const char* p);
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message,
|
||||
int32 index, BMessage* specifier,
|
||||
int32 form, const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* width, float* height);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
virtual status_t Perform(perform_code code, void* data);
|
||||
|
||||
private:
|
||||
|
||||
// FBC padding and forbidden methods
|
||||
virtual void _ReservedPictureButton1();
|
||||
virtual void _ReservedPictureButton2();
|
||||
virtual void _ReservedPictureButton3();
|
||||
|
||||
BPictureButton &operator=(const BPictureButton &);
|
||||
|
||||
void _Redraw();
|
||||
void _InitData();
|
||||
BPictureButton& operator=(const BPictureButton& other);
|
||||
|
||||
private:
|
||||
BPicture* fEnabledOff;
|
||||
BPicture* fEnabledOn;
|
||||
BPicture* fDisabledOff;
|
||||
@ -97,8 +97,8 @@ private:
|
||||
bool unused;
|
||||
|
||||
uint32 fBehavior;
|
||||
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif // _PICTURE_BUTTON_H
|
||||
|
@ -8,26 +8,28 @@
|
||||
|
||||
#include <PictureButton.h>
|
||||
|
||||
#include <binary_compatibility/Interface.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <binary_compatibility/Interface.h>
|
||||
|
||||
|
||||
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),
|
||||
:
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user