* rewrote ColorControl.h
* removed unused stuff. * shuffled methods around in the source, so that you don't have to jump so far when working at a specific thing (ie. all draw functions are grouped together, ...) * ResizeToPreferred() should now work as expected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14934 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,169 +1,117 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: ColorControl.h
|
||||
/
|
||||
/ Description: BColorControl displays a palette of selectable colors.
|
||||
/
|
||||
/ Copyright 1996-98, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright 2005, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _COLOR_CONTROL_H
|
||||
#define _COLOR_CONTROL_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
|
||||
#include <Control.h>
|
||||
|
||||
class BBitmap;
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*----- layout options for the color control -----------------*/
|
||||
|
||||
enum color_control_layout {
|
||||
B_CELLS_4x64 = 4,
|
||||
B_CELLS_8x32 = 8,
|
||||
B_CELLS_16x16 = 16,
|
||||
B_CELLS_32x8 = 32,
|
||||
B_CELLS_64x4 = 64
|
||||
B_CELLS_4x64 = 4,
|
||||
B_CELLS_8x32 = 8,
|
||||
B_CELLS_16x16 = 16,
|
||||
B_CELLS_32x8 = 32,
|
||||
B_CELLS_64x4 = 64,
|
||||
};
|
||||
|
||||
class BTextControl;
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
/*----- BColorControl class --------------------------------------*/
|
||||
|
||||
class BColorControl : public BControl {
|
||||
public:
|
||||
BColorControl( BPoint start,
|
||||
color_control_layout layout,
|
||||
float cell_size,
|
||||
const char *name,
|
||||
BMessage *message = NULL,
|
||||
bool use_offscreen = false);
|
||||
virtual ~BColorControl();
|
||||
public:
|
||||
BColorControl(BPoint start, color_control_layout layout,
|
||||
float cellSize, const char* name,
|
||||
BMessage* message = NULL, bool useOffscreen = false);
|
||||
BColorControl(BMessage* archive);
|
||||
virtual ~BColorControl();
|
||||
|
||||
BColorControl(BMessage *data);
|
||||
static BArchivable *Instantiate(BMessage *data);
|
||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void SetValue(int32 color_value);
|
||||
void SetValue(rgb_color color);
|
||||
rgb_color ValueAsColor();
|
||||
virtual void SetValue(int32 color_value);
|
||||
void SetValue(rgb_color color);
|
||||
rgb_color ValueAsColor();
|
||||
|
||||
virtual void SetEnabled(bool state);
|
||||
virtual void SetEnabled(bool state);
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage *msg);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MouseDown(BPoint where);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
|
||||
virtual void SetCellSize(float size);
|
||||
float CellSize() const;
|
||||
virtual void SetLayout(color_control_layout layout);
|
||||
virtual void SetCellSize(float size);
|
||||
float CellSize() const;
|
||||
virtual void SetLayout(color_control_layout layout);
|
||||
color_control_layout Layout() const;
|
||||
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void GetPreferredSize(float *width, float *height);
|
||||
virtual void ResizeToPreferred();
|
||||
virtual status_t Invoke(BMessage *msg = NULL);
|
||||
virtual void FrameMoved(BPoint new_position);
|
||||
virtual void FrameResized(float new_width, float new_height);
|
||||
virtual void WindowActivated(bool state);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void MouseMoved(BPoint point, uint32 code,
|
||||
const BMessage* dragMessage);
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
virtual void ResizeToPreferred();
|
||||
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 status_t GetSupportedSuites(BMessage *data);
|
||||
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
|
||||
BMessage* specifier, int32 what,
|
||||
const char* property);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
private:
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
// this can be made public again if needed
|
||||
|
||||
/*----- Private or reserved -----------------------------------------*/
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
virtual void _ReservedColorControl1();
|
||||
virtual void _ReservedColorControl2();
|
||||
virtual void _ReservedColorControl3();
|
||||
virtual void _ReservedColorControl4();
|
||||
|
||||
private:
|
||||
BColorControl& operator=(const BColorControl &other);
|
||||
|
||||
virtual void _ReservedColorControl1();
|
||||
virtual void _ReservedColorControl2();
|
||||
virtual void _ReservedColorControl3();
|
||||
virtual void _ReservedColorControl4();
|
||||
void _InitData(color_control_layout layout,
|
||||
float size, bool useOffscreen,
|
||||
BMessage* archive = NULL);
|
||||
void _LayoutView();
|
||||
void _UpdateOffscreen(BRect update);
|
||||
void _DrawColorArea(BView* target, BRect update);
|
||||
void _ColorRamp(BRect rect, BView* target,
|
||||
rgb_color baseColor, int16 flag,
|
||||
bool focused);
|
||||
|
||||
BColorControl &operator=(const BColorControl &);
|
||||
private:
|
||||
float fCellSize;
|
||||
int32 fRows;
|
||||
int32 fColumns;
|
||||
|
||||
void LayoutView(bool calc_frame);
|
||||
void UpdateOffscreen();
|
||||
void UpdateOffscreen(BRect update);
|
||||
void DrawColorArea(BView *target, BRect update);
|
||||
void ColorRamp( BRect r,
|
||||
BRect where,
|
||||
BView *target,
|
||||
rgb_color c,
|
||||
int16 flag,
|
||||
bool focused);
|
||||
void KbAdjustColor(uint32 key);
|
||||
bool key_down32(uint32 key);
|
||||
bool key_down8(uint32 key);
|
||||
static BRect CalcFrame( BPoint start,
|
||||
color_control_layout layout,
|
||||
int32 size);
|
||||
void InitData( color_control_layout layout,
|
||||
float size,
|
||||
bool use_offscreen,
|
||||
BMessage *data = NULL);
|
||||
void DoMouseMoved(BPoint pt);
|
||||
void DoMouseUp(BPoint pt);
|
||||
BTextControl* fRedText;
|
||||
BTextControl* fGreenText;
|
||||
BTextControl* fBlueText;
|
||||
|
||||
float fCellSize;
|
||||
int32 fRows;
|
||||
int32 fColumns;
|
||||
BBitmap* fBitmap;
|
||||
BView* fOffscreenView;
|
||||
|
||||
struct track_state {
|
||||
int32 orig_color;
|
||||
int32 cur_color;
|
||||
int32 prev_color;
|
||||
int32 bar_index;
|
||||
BRect active_area;
|
||||
BRect r;
|
||||
rgb_color rgb;
|
||||
color_space cspace;
|
||||
};
|
||||
|
||||
BTextControl *fRedText;
|
||||
BTextControl *fGreenText;
|
||||
BTextControl *fBlueText;
|
||||
BBitmap *fBitmap;
|
||||
BView *fOffscreenView;
|
||||
color_space fLastMode;
|
||||
float fRound;
|
||||
int32 fFocusedComponent;
|
||||
int32 fCachedIndex;
|
||||
uint32 _reserved[3];
|
||||
track_state *fTState;
|
||||
bool fUnused; // fTracking;
|
||||
bool fFocused;
|
||||
bool fRetainCache;
|
||||
bool fFastSet;
|
||||
int32 fFocusedComponent;
|
||||
uint32 _reserved[8];
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
/*----- inline functions -------------------------------------*/
|
||||
|
||||
inline void BColorControl::SetValue(rgb_color color)
|
||||
inline void
|
||||
BColorControl::SetValue(rgb_color color)
|
||||
{
|
||||
/* OK, no private parts */
|
||||
int32 c = (color.red << 24) + (color.green << 16) + (color.blue << 8);
|
||||
SetValue(c);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
#endif /* _COLOR_CONTROL_H */
|
||||
|
||||
Reference in New Issue
Block a user