Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXColorRing.h
1 /********************************************************************************
2 * *
3 * C o l o r R i n g W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2005,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXCOLORRING_H
22 #define FXCOLORRING_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXImage;
32 
33 
44 class FXAPI FXColorRing : public FXFrame {
45  FXDECLARE(FXColorRing)
46 protected:
47  FXImage *dial; // HSV dial image
48  FXfloat hsv[3]; // Hue, saturation, value
49  FXint ringwidth; // Width of hue ring
50  FXint ringouter; // Outer radius
51  FXint ringinner; // Inner radius
52  FXint dialx; // Dial x location
53  FXint dialy; // Dial y location
54  FXint satvalx; // Saturation value x
55  FXint satvaly; // Saturation value y
56  FXint huex; // Hue x
57  FXint huey; // Hue y
58  FXint clrx; // Color corner of triangle
59  FXint clry;
60  FXint blkx; // Black corner of triangle
61  FXint blky;
62  FXint whtx; // White corner of triangle
63  FXint whty;
64  FXString tip; // Tooltip value
65  FXString help; // Help value
66  FXuchar mode; // Mode widget is in
67 protected:
68  FXColorRing();
69  void updatering();
70  FXfloat hueFromXY(FXint x,FXint y) const;
71  void hueToXY(FXint& x,FXint& y,FXfloat hue) const;
72  void satValToXY(FXint& x,FXint& y,FXfloat s,FXfloat v) const;
73  void satValFromXY(FXfloat& s,FXfloat& v,FXint x,FXint y) const;
74  FXbool inCorner(FXint x,FXint y) const;
75  FXbool inHueRing(FXint x,FXint y) const;
76  FXbool inTriangle(FXint x,FXint y) const;
77 protected:
78  enum {
79  MOUSE_NONE, // No mouse operation
80  MOUSE_HUE, // Moving in hue-ring
81  MOUSE_SATVAL // Moving in saturation/value triangle
82  };
83 private:
84  FXColorRing(const FXColorRing&);
85  FXColorRing &operator=(const FXColorRing&);
86 public:
87  long onPaint(FXObject*,FXSelector,void*);
88  long onLeftBtnPress(FXObject*,FXSelector,void*);
89  long onLeftBtnRelease(FXObject*,FXSelector,void*);
90  long onMotion(FXObject*,FXSelector,void*);
91  long onMouseWheel(FXObject*,FXSelector,void*);
92  long onCmdSetHelp(FXObject*,FXSelector,void*);
93  long onCmdGetHelp(FXObject*,FXSelector,void*);
94  long onCmdSetTip(FXObject*,FXSelector,void*);
95  long onCmdGetTip(FXObject*,FXSelector,void*);
96  long onQueryHelp(FXObject*,FXSelector,void*);
97  long onQueryTip(FXObject*,FXSelector,void*);
98 public:
99 
101  FXColorRing(FXComposite* p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
102 
104  virtual void create();
105 
107  virtual void detach();
108 
110  virtual void layout();
111 
113  virtual FXint getDefaultWidth();
114 
116  virtual FXint getDefaultHeight();
117 
119  void setHue(FXfloat h);
120 
122  FXfloat getHue() const { return hsv[0]; }
123 
125  void setSat(FXfloat s);
126 
128  FXfloat getSat() const { return hsv[1]; }
129 
131  void setVal(FXfloat v);
132 
134  FXfloat getVal() const { return hsv[2]; }
135 
137  void setHueSatVal(FXfloat h,FXfloat s,FXfloat v);
138 
140  void setRingWidth(FXint rw);
141 
143  FXint getRingWidth() const { return ringwidth; }
144 
146  void setJustify(FXuint style);
147 
149  FXuint getJustify() const;
150 
152  void setHelpText(const FXString& text){ help=text; }
153 
155  const FXString& getHelpText() const { return help; }
156 
158  void setTipText(const FXString& text){ tip=text; }
159 
161  const FXString& getTipText() const { return tip; }
162 
164  virtual void save(FXStream& store) const;
165 
167  virtual void load(FXStream& store);
168 
170  virtual ~FXColorRing();
171  };
172 
173 }
174 
175 #endif
FXint getRingWidth() const
Return width of hue ring.
Definition: FXColorRing.h:143
FXfloat getVal() const
Return value.
Definition: FXColorRing.h:134
FXfloat getHue() const
Return hue.
Definition: FXColorRing.h:122
FXfloat getSat() const
Return saturation.
Definition: FXColorRing.h:128
const FXString & getHelpText() const
Get status line help text for this color well.
Definition: FXColorRing.h:155
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
void setTipText(const FXString &text)
Set tool tip message for this color well.
Definition: FXColorRing.h:158
Definition: FX4Splitter.h:28
void setHelpText(const FXString &text)
Set status line help text for this color well.
Definition: FXColorRing.h:152
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
const FXString & getTipText() const
Get tool tip message for this color well.
Definition: FXColorRing.h:161
A ColorRing widget provides an intuitive way to specify a color.
Definition: FXColorRing.h:44
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp