Files
haiku-beta6/headers/os/interface/ColorControl.h
T

144 lines
4.0 KiB
C++
Raw Normal View History

2005-11-15 02:45:19 +00:00
/*
2013-05-31 00:19:10 -04:00
* Copyright 2005-2013 Haiku, Inc. All Rights Reserved.
2005-11-15 02:45:19 +00:00
* Distributed under the terms of the MIT License.
*/
2002-10-23 13:54:44 +00:00
#ifndef _COLOR_CONTROL_H
#define _COLOR_CONTROL_H
2005-11-15 02:45:19 +00:00
2002-10-23 13:54:44 +00:00
#include <Control.h>
enum color_control_layout {
2005-11-15 02:45:19 +00:00
B_CELLS_4x64 = 4,
B_CELLS_8x32 = 8,
B_CELLS_16x16 = 16,
B_CELLS_32x8 = 32,
B_CELLS_64x4 = 64,
2002-10-23 13:54:44 +00:00
};
2013-05-31 00:19:10 -04:00
class BBitmap;
2002-10-23 13:54:44 +00:00
class BTextControl;
class BColorControl : public BControl {
2008-11-21 00:15:22 +00:00
public:
BColorControl(BPoint start,
color_control_layout layout,
float cellSize, const char* name,
BMessage* message = NULL,
bool useOffscreen = false);
2014-06-11 19:00:46 -04:00
BColorControl(BMessage* data);
2008-11-21 00:15:22 +00:00
virtual ~BColorControl();
2014-06-11 19:00:46 -04:00
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data,
2008-11-21 00:15:22 +00:00
bool deep = true) const;
virtual void SetLayout(BLayout* layout);
virtual void SetValue(int32 color_value);
void SetValue(rgb_color color);
rgb_color ValueAsColor();
virtual void SetEnabled(bool state);
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);
color_control_layout Layout() const;
virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 code,
const BMessage* dragMessage);
virtual void DetachedFromWindow();
2009-08-26 10:32:41 +00:00
virtual void GetPreferredSize(float* _width,
float* _height);
2008-11-21 00:15:22 +00:00
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage* message = NULL);
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float newWidth, float newHeight);
2009-08-26 10:32:41 +00:00
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 what, const char* property);
2008-11-21 00:15:22 +00:00
virtual status_t GetSupportedSuites(BMessage* data);
2013-08-17 03:14:38 -04:00
virtual void MakeFocus(bool focused = true);
2008-11-21 00:15:22 +00:00
virtual void AllAttached();
virtual void AllDetached();
2013-12-22 02:31:47 +01:00
virtual status_t SetIcon(const BBitmap* icon, uint32 flags = 0);
2008-11-21 00:15:22 +00:00
private:
virtual status_t Perform(perform_code d, void *arg);
// this can be made public again if needed
virtual void _ReservedColorControl1();
virtual void _ReservedColorControl2();
virtual void _ReservedColorControl3();
virtual void _ReservedColorControl4();
BColorControl& operator=(const BColorControl &other);
void _InitData(color_control_layout layout,
float size, bool useOffscreen,
2014-06-11 19:00:46 -04:00
BMessage* data = NULL);
2008-11-21 00:15:22 +00:00
void _LayoutView();
void _InitOffscreen();
2013-08-17 03:14:38 -04:00
void _InvalidateSelector(int16 ramp,
rgb_color color, bool focused);
2008-11-21 00:15:22 +00:00
void _DrawColorArea(BView* target, BRect update);
2013-05-31 00:19:10 -04:00
void _DrawSelectors(BView* target);
void _DrawColorRamp(BRect rect, BView* target,
rgb_color baseColor, rgb_color compColor,
int16 flag, bool focused,
BRect updateRect);
2008-11-21 00:15:22 +00:00
BPoint _SelectorPosition(const BRect& rampRect,
uint8 shade) const;
BRect _PaletteFrame() const;
2013-05-31 00:19:10 -04:00
BRect _PaletteSelectorFrame(uint8 colorIndex) const;
2008-11-21 00:15:22 +00:00
BRect _RampFrame(uint8 rampIndex) const;
2013-05-31 00:43:15 -04:00
void _SetCellSize(float size);
float _TextRectOffset();
2013-05-31 00:43:15 -04:00
2005-11-15 02:45:19 +00:00
private:
2008-11-21 00:15:22 +00:00
BRect fPaletteFrame;
int16 fSelectedPaletteColorIndex;
int16 fPreviousSelectedPaletteColorIndex;
float fCellSize;
int32 fRows;
int32 fColumns;
bool fPaletteMode;
bool _unused[3];
BTextControl* fRedText;
BTextControl* fGreenText;
BTextControl* fBlueText;
BBitmap* fBitmap;
BView* fOffscreenView;
2013-08-17 03:14:38 -04:00
int16 fFocusedRamp;
int16 fClickedRamp;
uint32 _reserved[2];
2002-10-23 13:54:44 +00:00
};
2005-11-15 02:45:19 +00:00
inline void
BColorControl::SetValue(rgb_color color)
2002-10-23 13:54:44 +00:00
{
int32 c = (color.red << 24) + (color.green << 16) + (color.blue << 8);
SetValue(c);
}
2009-08-26 10:32:41 +00:00
#endif // _COLOR_CONTROL_H