* cleanup
* use std::nothrow git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28886 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,62 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: PictureButton.h
|
||||
// Author: Graham MacDonald ([email protected])
|
||||
// Description: BPictureButton displays and controls a picture button in a
|
||||
// window.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Copyright 2001-2008, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Graham MacDonald ([email protected])
|
||||
*/
|
||||
#ifndef _PICTURE_BUTTON_H
|
||||
#define _PICTURE_BUTTON_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <BeBuild.h>
|
||||
#include <Control.h>
|
||||
#include <Picture.h> /* For convenience */
|
||||
#include <Picture.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
enum {
|
||||
B_ONE_STATE_BUTTON,
|
||||
B_TWO_STATE_BUTTON
|
||||
};
|
||||
|
||||
|
||||
// BPictureButton class --------------------------------------------------------
|
||||
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 flgs = B_WILL_DRAW | B_NAVIGABLE);
|
||||
@@ -66,7 +34,6 @@ public:
|
||||
|
||||
|
||||
static BArchivable* Instantiate(BMessage* data);
|
||||
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
@@ -87,22 +54,20 @@ public:
|
||||
virtual void SetBehavior(uint32 behavior);
|
||||
uint32 Behavior() const;
|
||||
|
||||
virtual void MessageReceived (BMessage *msg);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseMoved (BPoint pt, uint32 code, const BMessage *msg);
|
||||
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 *msg = NULL);
|
||||
virtual void FrameMoved (BPoint new_position);
|
||||
virtual void FrameResized (float new_width, float new_height);
|
||||
virtual status_t Invoke(BMessage* message = NULL);
|
||||
virtual void FrameMoved(BPoint newPosition);
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
|
||||
virtual BHandler *ResolveSpecifier (BMessage *msg,
|
||||
int32 index,
|
||||
BMessage *specifier,
|
||||
int32 form,
|
||||
const char *property);
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 form, const char* p);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
@@ -111,11 +76,8 @@ public:
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
|
||||
// Private or reserved -----------------------------------------------------
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedPictureButton1();
|
||||
@@ -124,28 +86,19 @@ private:
|
||||
|
||||
BPictureButton &operator=(const BPictureButton &);
|
||||
|
||||
void Redraw ();
|
||||
void InitData ();
|
||||
void _Redraw();
|
||||
void _InitData();
|
||||
|
||||
BPicture* fEnabledOff;
|
||||
BPicture* fEnabledOn;
|
||||
BPicture* fDisabledOff;
|
||||
BPicture* fDisabledOn;
|
||||
|
||||
bool fOutlined;
|
||||
bool unused;
|
||||
|
||||
uint32 fBehavior;
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif /* _PICTURE_BUTTON_H */
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku, Inc.
|
||||
* Copyright 2001-2009, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Graham MacDonald ([email protected])
|
||||
*/
|
||||
|
||||
/** BPictureButton displays and controls a picture button in a window. */
|
||||
|
||||
|
||||
#include <PictureButton.h>
|
||||
|
||||
#include <binary_compatibility/Interface.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
BPictureButton::BPictureButton(BRect frame, const char* name,
|
||||
BPicture* off, BPicture* on, BMessage* message,
|
||||
@@ -20,11 +19,10 @@ BPictureButton::BPictureButton(BRect frame, const char* name,
|
||||
: BControl(frame, name, "", message, resizeMask, flags),
|
||||
fDisabledOff(NULL),
|
||||
fDisabledOn(NULL),
|
||||
fOutlined(false),
|
||||
fBehavior(behavior)
|
||||
{
|
||||
fEnabledOff = new BPicture(*off);
|
||||
fEnabledOn = new BPicture(*on);
|
||||
fEnabledOff = new (std::nothrow)BPicture(*off);
|
||||
fEnabledOn = new (std::nothrow) BPicture(*on);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,16 +41,16 @@ BPictureButton::BPictureButton(BMessage *data)
|
||||
|
||||
// Now expand the pictures:
|
||||
if (data->FindMessage("_e_on", &pictureArchive) == B_OK)
|
||||
fEnabledOn = new BPicture(&pictureArchive);
|
||||
fEnabledOn = new (std::nothrow) BPicture(&pictureArchive);
|
||||
|
||||
if (data->FindMessage("_e_off", &pictureArchive) == B_OK)
|
||||
fEnabledOff = new BPicture(&pictureArchive);
|
||||
fEnabledOff = new (std::nothrow) BPicture(&pictureArchive);
|
||||
|
||||
if (data->FindMessage("_d_on", &pictureArchive) == B_OK)
|
||||
fDisabledOn = new BPicture(&pictureArchive);
|
||||
fDisabledOn = new (std::nothrow) BPicture(&pictureArchive);
|
||||
|
||||
if (data->FindMessage("_d_off", &pictureArchive) == B_OK)
|
||||
fDisabledOff = new BPicture(&pictureArchive);
|
||||
fDisabledOff = new (std::nothrow) BPicture(&pictureArchive);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +67,7 @@ BArchivable *
|
||||
BPictureButton::Instantiate(BMessage* data)
|
||||
{
|
||||
if ( validate_instantiation(data, "BPictureButton"))
|
||||
return new BPictureButton(data);
|
||||
return new (std::nothrow) BPictureButton(data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -118,11 +116,6 @@ BPictureButton::Archive(BMessage *data, bool deep) const
|
||||
void
|
||||
BPictureButton::Draw(BRect updateRect)
|
||||
{
|
||||
BRect rect = Bounds();
|
||||
|
||||
// We should request the view's base color which normaly is (216,216,216)
|
||||
rgb_color color = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
|
||||
if (IsEnabled()) {
|
||||
if (Value() == B_CONTROL_ON)
|
||||
DrawPicture(fEnabledOn);
|
||||
@@ -142,7 +135,7 @@ BPictureButton::Draw(BRect updateRect)
|
||||
|
||||
if (IsFocus()) {
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
StrokeRect(rect, B_SOLID_HIGH);
|
||||
StrokeRect(Bounds(), B_SOLID_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +225,7 @@ void
|
||||
BPictureButton::SetEnabledOn(BPicture* on)
|
||||
{
|
||||
delete fEnabledOn;
|
||||
fEnabledOn = new BPicture(*on);
|
||||
fEnabledOn = new (std::nothrow) BPicture(*on);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +233,7 @@ void
|
||||
BPictureButton::SetEnabledOff(BPicture* off)
|
||||
{
|
||||
delete fEnabledOff;
|
||||
fEnabledOff = new BPicture(*off);
|
||||
fEnabledOff = new (std::nothrow) BPicture(*off);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +241,7 @@ void
|
||||
BPictureButton::SetDisabledOn(BPicture* on)
|
||||
{
|
||||
delete fDisabledOn;
|
||||
fDisabledOn = new BPicture(*on);
|
||||
fDisabledOn = new (std::nothrow) BPicture(*on);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +249,7 @@ void
|
||||
BPictureButton::SetDisabledOff(BPicture* off)
|
||||
{
|
||||
delete fDisabledOff;
|
||||
fDisabledOff = new BPicture(*off);
|
||||
fDisabledOff = new (std::nothrow) BPicture(*off);
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +376,6 @@ BPictureButton::ResizeToPreferred()
|
||||
void
|
||||
BPictureButton::GetPreferredSize(float* _width, float* _height)
|
||||
{
|
||||
// Need to do some test to see what the Be method returns...
|
||||
BControl::GetPreferredSize(_width, _height);
|
||||
}
|
||||
|
||||
@@ -478,13 +470,13 @@ BPictureButton::operator=(const BPictureButton &button)
|
||||
|
||||
|
||||
void
|
||||
BPictureButton::Redraw()
|
||||
BPictureButton::_Redraw()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BPictureButton::InitData()
|
||||
BPictureButton::_InitData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user