#ifndef __CtrlLib_DlgColor__ #define __CtrlLib_DlgColor__ class WheelRampCtrl : public Ctrl { public: WheelRampCtrl(bool ramp); ~WheelRampCtrl(); virtual void Layout(); virtual void Paint(Draw& draw); virtual void SetData(const Value& value); virtual Value GetData() const { return color; } virtual void LeftDown(Point pt, dword keyflags); virtual void LeftUp(Point pt, dword keyflags); virtual void LeftDouble(Point pt, dword keyflags); virtual void MouseMove(Point pt, dword keyflags); Callback WhenLeftDouble; private: void SetColor(Color color, bool set_norm, bool set_hsv); Image PaintRamp(Size size); Image PaintWheel(Size size); void PaintColumn(Draw& draw); int ClientToLevel(int y) const; int LevelToClient(int l) const; private: // double gamma; bool ramp; Color color; Color normalized_color; int h16, s16, v16; int round_step; int wheel_style; enum STYLE { S_WHEEL, S_RECT, S_HEXAGON }; STYLE style; Image cache; int cache_level; Image wheel_cache; Rect wheel_rect; Rect column_rect; int firstclick; struct WheelBuff { int arg; int l; }; }; struct ColorWheelCtrl : public WheelRampCtrl { ColorWheelCtrl() : WheelRampCtrl(false) {} }; struct ColorRampCtrl : public WheelRampCtrl { ColorRampCtrl() : WheelRampCtrl(true) {} }; class ColorSelector : public Ctrl { public: ColorSelector(bool not_null = true); ColorSelector& NotNull(bool nn = true) { impl->NotNull(nn); return *this; } ColorSelector& NoNotNull() { return NotNull(false); } bool IsNotNull() const { return impl->IsNotNull(); } Color Get() const { return impl->Get(); } void Set(Color c) { impl->Set(c); } Vector GetPalette() const { return impl->GetPalette(); } void SetPalette(const Vector& palette) { impl->SetPalette(palette); } void SerializeConfig(Stream& stream) { impl->SerializeConfig(stream); } virtual void SetData(const Value& color) { Set(color); } virtual Value GetData() const { return Get(); } Ctrl& GetImplCtrl() { return impl->GetCtrl(); } public: Callback WhenSetColor; public: class Impl { public: virtual ~Impl() {} virtual void Set(Color c) = 0; virtual Color Get() const = 0; virtual void NotNull(bool nn) = 0; virtual bool IsNotNull() const = 0; virtual Vector GetPalette() const = 0; virtual void SetPalette(const Vector& pal) = 0; virtual void SerializeConfig(Stream& stream) = 0; virtual Ctrl& GetCtrl() = 0; protected: Impl() {} }; protected: One impl; }; class ColorCtrl : public DataPusher { public: typedef ColorCtrl CLASSNAME; ColorCtrl(bool not_null = true); virtual ~ColorCtrl(); ColorCtrl& NotNull(bool _nn = true) { empty.Show(!_nn); return *this; } ColorCtrl& NoNotNull() { return NotNull(false); } bool IsNotNull() const { return !empty.IsVisible(); } protected: virtual void DoAction(); void OnClear() { SetDataAction(Null); } protected: FrameRight