Photon microGUI widgets library 0.6.0
Basic.h
1#ifndef PHWIDGETS_BASIC_H
2#define PHWIDGETS_BASIC_H
3
4#include <photon/PtBasic.h>
5
6#include "./Widget.h"
7#include "./Drawing/Color.h"
8
9
10namespace PhWidgets
11{
18
39 class Basic:
40 public Widget
41 {
42 public:
43
45 template<class T = void, class Disabled = Widget::ResourceTypeTag<-1>, bool Dummy = false>
46 struct Arguments
47 {
48 typedef void type;
49 };
50
51 template<class T, int TypeID>
52 struct Arguments<T, Widget::ResourceTypeTag<TypeID> >
53 : Basic::Arguments<T, Widget::ResourceTag::Alloc>
54 , Basic::Arguments<T, Widget::ResourceTag::Callback>
55 , Basic::Arguments<T, Widget::ResourceTag::Color>
56 , Basic::Arguments<T, Widget::ResourceTag::Flag>
57 , Basic::Arguments<T, Widget::ResourceTag::Scalar>
58 , Basic::Arguments<T, Widget::ResourceTag::String>
59 , Basic::Arguments<T, Widget::ResourceTag::Struct>
60 { };
61
62 template<class T>
63 struct Arguments<Basic, T, false>
65 { };
66
68 template<bool Dummy>
69 struct Arguments<unsigned short, ResourceTag::Scalar, Dummy>
70 {
72
80 typedef enum Scalar
81 {
82 MarginHeight = Pt_ARG_MARGIN_HEIGHT,
83 MarginWidth = Pt_ARG_MARGIN_WIDTH
84 } type;
85 };
86
88 template<bool Dummy>
89 struct Arguments<unsigned long, ResourceTag::Scalar, Dummy>
90 {
92
100 typedef enum Scalar
101 {
102 BandwidthThreshold = Pt_ARG_BANDWIDTH_THRESHOLD,
103 BasicFlags = Pt_ARG_BASIC_FLAGS
104 } type;
105 };
106
108 template<bool Dummy>
109 struct Arguments<PgColor_t, ResourceTag::Color, Dummy>
110 {
112
120 typedef enum Color
121 {
122 BevelColor = Pt_ARG_BEVEL_COLOR,
123 Color = Pt_ARG_COLOR,
124 DarkBevelColor = Pt_ARG_DARK_BEVEL_COLOR,
125 DarkFillColor = Pt_ARG_DARK_FILL_COLOR,
126 FillColor = Pt_ARG_FILL_COLOR,
127 InlineColor = Pt_ARG_INLINE_COLOR,
128 LightBevelColor = Pt_ARG_LIGHT_BEVEL_COLOR,
129 LightFillColor = Pt_ARG_LIGHT_FILL_COLOR,
130 OutlineColor = Pt_ARG_OUTLINE_COLOR
131
132 , DrawingColor = Color
133 } type, ColorResource;
134 };
135
137 template<bool Dummy>
138 struct Arguments<char, ResourceTag::Scalar, Dummy>
139 {
141
149 typedef enum Scalar
150 {
151 BevelContrast = Pt_ARG_BEVEL_CONTRAST,
152 Contrast = Pt_ARG_CONTRAST
153 } type;
154 };
155
157 template<bool Dummy>
158 struct Arguments<PgPattern_t, ResourceTag::Struct, Dummy>
159 {
161
169 typedef enum Struct
170 {
171 FillPattern = Pt_ARG_FILL_PATTERN,
172 TransPattern = Pt_ARG_TRANS_PATTERN
173 } type;
174 };
175
177 template<bool Dummy>
178 struct Arguments<unsigned char, ResourceTag::Scalar, Dummy>
179 {
181
189 typedef enum Scalar
190 {
191 HighlihgtRoundness = Pt_ARG_HIGHLIGHT_ROUNDNESS
192 } type;
193 };
194
196 template<bool Dummy>
197 struct Arguments<char*, ResourceTag::String, Dummy>
198 {
200
209 {
210 Style = Pt_ARG_STYLE
211 } type;
212 };
213
215 template<class T = void, class Disabled = void, bool Dummy = false>
217 {
218 typedef Callbacks<> type;
219 };
220
221 template<class T>
222 struct Callbacks<Basic, T>
223 : Callbacks<T>
224 { };
225
226 template<class T, bool Dummy>
227 struct Callbacks<T, void, Dummy>
228 : Callbacks<T, ResourceTag::Callback, Dummy>
229 { };
230
232 template<bool Dummy>
233 struct Callbacks<PtCallback_t, ResourceTag::Callback, Dummy>
234 {
236
243 typedef enum Callback
244 {
245 Activate = Pt_CB_ACTIVATE,
247
248 Arm = Pt_CB_ARM,
250
251 Disarm = Pt_CB_DISARM,
253
254 GotFocus = Pt_CB_GOT_FOCUS,
256
257 LostFocus = Pt_CB_LOST_FOCUS,
258
259 Menu = Pt_CB_MENU,
260
261 Repeat = Pt_CB_REPEAT
263 } type;
264 };
265
267 struct Flags
269 {
271 struct Basic
272 {
274
279 enum type
280 {
281
282 // Edge-control bits:
283
284 TopEtch = Pt_TOP_ETCH,
285 BottomEtch = Pt_BOTTOM_ETCH,
286 LeftEtch = Pt_LEFT_ETCH,
287 RightEtch = Pt_RIGHT_ETCH, // Render a single alpha line on an edge of the widget. The top and left lines are dark, and the bottom and right lines are light. This can make a widget look like it's slightly inset.
288 BlankEtches = Pt_BLANK_ETCHES,
289 OpaqueEtches = Pt_OPAQUE_ETCHES,
290 TopOutline = Pt_TOP_OUTLINE,
291 BottomOutline = Pt_BOTTOM_OUTLINE,
292 LeftOutline = Pt_LEFT_OUTLINE,
293 RightOutline = Pt_RIGHT_OUTLINE, // Render a single-pixel outline on an edge of the widget.
294 TopBevel = Pt_TOP_BEVEL,
295 BottomBevel = Pt_BOTTOM_BEVEL,
296 LeftBevel = Pt_LEFT_BEVEL,
297 RightBevel = Pt_RIGHT_BEVEL, // Render a bevel Pt_ARG_BEVEL_WIDTH pixels wide on an edge of the widget.
298 FullBevels = Pt_FULL_BEVELS, // Render a full bevel (i.e. half-round) instead of a half bevel (quarter-round).
299 TopInline = Pt_TOP_INLINE,
300 BottomInline = Pt_BOTTOM_INLINE,
301 LeftInline = Pt_LEFT_INLINE,
302 RightInline = Pt_RIGHT_INLINE, // Render a single-pixel inline on an edge of the widget.
303
304 // These convenience manifests make working with these bits easier:
305
306 TopLeftEtch = Pt_TOP_LEFT_ETCH,
307 BottomRightEtch = Pt_BOTTOM_RIGHT_ETCH,
308 AllEtches = Pt_ALL_ETCHES,
309 TopLeftOutline = Pt_TOP_LEFT_OUTLINE,
310 BottomRightOutline = Pt_BOTTOM_RIGHT_OUTLINE,
311 AllOutlines = Pt_ALL_OUTLINES,
312 TopLeftBevel = Pt_TOP_LEFT_BEVEL,
313 BottomRightBevel = Pt_BOTTOM_RIGHT_BEVEL,
314 AllBevels = Pt_ALL_BEVELS,
315 TopLeftInline = Pt_TOP_LEFT_INLINE,
316 BottomRightInline= Pt_BOTTOM_RIGHT_INLINE,
317 AllInlines = Pt_ALL_INLINES,
318 AllTop = Pt_ALL_TOP,
319 AllBottom = Pt_ALL_BOTTOM,
320 AllLeft = Pt_ALL_LEFT,
321 AllRight = Pt_ALL_RIGHT,
322 All = Pt_ALL,
323
324 // Fill-control bits:
325
326 FlatFill = Pt_FLAT_FILL,
327 HorizontalGradient = Pt_HORIZONTAL_GRADIENT,
328 ReverseGradient = Pt_REVERSE_GRADIENT,
329 StaticBevelColors = Pt_STATIC_BEVEL_COLORS,
330 PreventFill = Pt_BASIC_PREVENT_FILL,
331
332 // Behavior on state change:
333
334 // These bits affect how the widget behaves when set (depressed) or unset (raised):
335
336 StaticGradient = Pt_STATIC_GRADIENT,
337 StaticBevels = Pt_STATIC_BEVELS
338 };
339 };
340 };
341
342 template<int TypeID>
343 struct Arguments<void, Widget::ResourceTypeTag<TypeID> >
344 : Basic::Arguments<unsigned short, Widget::ResourceTypeTag<__LINE__>>
345 , Basic::Arguments<unsigned long, Widget::ResourceTypeTag<__LINE__>>
346 , Basic::Arguments<PgColor_t, Widget::ResourceTypeTag<__LINE__>>
347 , Basic::Arguments<char, Widget::ResourceTypeTag<__LINE__>>
348 , Basic::Arguments<PgPattern_t, Widget::ResourceTypeTag<__LINE__>>
349 , Basic::Arguments<unsigned char, Widget::ResourceTypeTag<__LINE__>>
350 , Basic::Arguments<char*, Widget::ResourceTypeTag<__LINE__>>
352 { };
353
354 template<bool Dummy>
355 struct Callbacks<void, void, Dummy>
356 : Basic::Callbacks<PtCallback_t, ResourceTag::Callback>
357 , Widget::Callbacks<>
358 { };
359
360 protected:
361
362 typedef ResourceFrom<Widget::WidgetResourcesSingleton>::
363 Define::String<Arguments<char*>::String>::
364 Define::Color<Arguments<PgColor_t>::ColorResource>::
365 Define::Scalar<Arguments<unsigned short>::Scalar, unsigned short>::
366 Define::Scalar<Arguments<char>::Scalar, char>::
367 //Define::Flag<ThisArgs::ArgLong::eArgLong, long>::
368 Define::Flag<Arguments<unsigned long>::Scalar, unsigned long>::
369 //Define::Flag<ThisArgs::ArgUnsigned::eArgUnsigned, unsigned>::
370
371 Define::Link<Callbacks<PtCallback_t>::type, PtCallback_t*>::
372
373 resource_type WidgetResourcesSingleton;
374
375 virtual void check();
376
377 public:
379
383 explicit Basic(int abn);
384
386
390 explicit Basic(PtWidget_t *wdg);
391
393
397 Basic(const Basic &other);
398
400
404 Basic &operator=(const Basic &other);
405
407
411 WidgetResourcesSingleton resource;
412
415
417
429
431
461
463
487
489
515
517
556
558
574
576
600
602
628
630
640
642
652
654
670
671 phbitmask<unsigned long, Flags::Basic::type>::
672 bind<Basic, Arguments<unsigned long>::Scalar, Arguments<>::BasicFlags> BasicFlags;
673
675
685
687
697
699 };
700
701
702
703} // namespace PhWidgets
704
705cppbitmasks::bitmask<unsigned long, PhWidgets::Basic::Flags::Basic::type> operator|(const PhWidgets::Basic::Flags::Basic::type &flag1, const PhWidgets::Basic::Flags::Basic::type &flag2);
706cppbitmasks::bitmask<unsigned long, PhWidgets::Basic::Flags::Basic::type> operator&(const PhWidgets::Basic::Flags::Basic::type &flag1, const PhWidgets::Basic::Flags::Basic::type &flag2);
707cppbitmasks::bitmask<unsigned long, PhWidgets::Basic::Flags::Basic::type> operator^(const PhWidgets::Basic::Flags::Basic::type &flag1, const PhWidgets::Basic::Flags::Basic::type &flag2);
708
709
710#endif // PHWIDGETS_BASIC_H
A superclass of basic resources for most widgets.
Definition: Basic.h:41
phwidgets_event< Basic, Basic::Callbacks<>::Arm > Arm
Occurs when you press the left pointer button while pointing at the widget.
Definition: Basic.h:679
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::InlineColor > InlineColor
Gets or sets the color of the inline of the border.
Definition: Basic.h:573
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::DarkBevelColor > DarkBevelColor
Gets or sets the dark outermost color used when applying a bevel to a widget.
Definition: Basic.h:486
phwidgets_event< Basic, Basic::Callbacks<>::Repeat > Repeat
Documentation in progress...
Definition: Basic.h:684
phwidgets_event< Basic, Basic::Callbacks<>::Activate > Activate
Occurs when you release the left pointer button while pointing at an armed widget.
Definition: Basic.h:678
void OnRepeat(PtCallbackInfo_t *info)
Raises the Basic::Repeat event.
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::BevelColor > BevelColor
Gets or sets the main color of the bevel.
Definition: Basic.h:428
WidgetResourcesSingleton resource
Resources of the Basic.
Definition: Basic.h:411
void OnDisarmed(PtCallbackInfo_t *info)
Raises the Basic::Disarm event.
phwidgets_event< Basic, Basic::Callbacks<>::GotFocus > GotFocus
Occurs when a widget gets focus or its focus status changes.
Definition: Basic.h:681
Basic(int abn)
(constructor)
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::LightBevelColor > LightBevelColor
Gets or sets the light outermost color used when applying a bevel to a widget.
Definition: Basic.h:599
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::DarkFillColor > DarkFillColor
Gets or sets the dark color with which a gradient (if applied) goes.
Definition: Basic.h:514
Basic(const Basic &other)
(copy constructor)
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::OutlineColor > OutlineColor
Gets or sets the color of the outline of the border.
Definition: Basic.h:669
phwidgets_event< Basic, Basic::Callbacks<>::LostFocus > LostFocus
Occurs when a widget loses focus.
Definition: Basic.h:682
phwidgets_event< Basic, Basic::Callbacks<>::Menu > Menu
Occurs when you press the right button while the pointer is on top of the widget.
Definition: Basic.h:683
phproperty< unsigned short >::bind< Basic, Arguments< unsigned short >::Scalar, Arguments<>::MarginHeight > MarginHeight
Gets or sets the amount of vertical space between the widget's canvas and the widget's border.
Definition: Basic.h:639
phproperty< unsigned short >::bind< Basic, Arguments< unsigned short >::Scalar, Arguments<>::MarginWidth > MarginWidth
Gets or sets the amount of horizontal space between the widget's canvas and the widget's border.
Definition: Basic.h:651
void OnLostFocus(PtCallbackInfo_t *info)
Raises the Basic::LostFocus event.
void OnMenu(PtCallbackInfo_t *info)
Raises the Basic::Menu event.
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::DrawingColor > Color
Gets or sets the foreground or drawing color for the widget.
Definition: Basic.h:460
void OnGotFocused(PtCallbackInfo_t *info)
Raises the Basic::GotFocus event.
Basic & operator=(const Basic &other)
Assigns value in Basic widget.
phbitmask< unsigned long, Flags::Basic::type >::bind< Basic, Arguments< unsigned long >::Scalar, Arguments<>::BasicFlags > BasicFlags
Gets or sets basic flags inherited by all widgets. See Flags::Basic::type.
Definition: Basic.h:672
void OnActivated(PtCallbackInfo_t *info)
Raises the Basic::Activate event.
void OnArmed(PtCallbackInfo_t *info)
Raises the Basic::Arm event.
phwidgets_event< Basic, Basic::Callbacks<>::Disarm > Disarm
Occurs when you release the left pointer button when not pointing at an armed widget.
Definition: Basic.h:680
Basic(PtWidget_t *wdg)
(constructor)
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::FillColor > FillColor
Gets or sets the fill color for the widget.
Definition: Basic.h:555
phproperty< Drawing::Color >::bind< Basic, Arguments< PgColor_t >::ColorResource, Arguments<>::LightFillColor > LightFillColor
Gets or sets the light color with which a gradient (if applied) goes.
Definition: Basic.h:627
An event, which raise a notification to registered subscribers (event handlers) that something of int...
Definition: Widget.h:132
Superclass for all widgets.
Definition: Widget.h:110
The main namespace for all widgets.
Definition: Basic.h:11
Color
Resource IDs for Basic arguments of type PgColor_t.
Definition: Basic.h:121
Struct
Resource IDs for Basic arguments of type PgPattern_t.
Definition: Basic.h:170
Scalar
Resource IDs for Basic arguments of type char.
Definition: Basic.h:150
String
Resource IDs for Widget arguments of type char*.
Definition: Basic.h:209
Scalar
Resource IDs for Basic arguments of type unsigned char.
Definition: Basic.h:190
Scalar
Resource IDs for Basic arguments of type unsigned long.
Definition: Basic.h:101
Scalar
Resource IDs for Basic arguments of type unsigned short.
Definition: Basic.h:81
Contains resource IDs for Basic arguments.
Definition: Basic.h:47
Callback
Resource IDs for Basic arguments of type PtCallback_t.
Definition: Basic.h:244
Contains resource IDs for Basic callbacks.
Definition: Basic.h:217
Contains flags for Basic resource Basic::Arguments<>::BasicFlags.
Definition: Basic.h:272
type
Cursor flags for Basic resource Basic::Arguments<>::BasicFlags.
Definition: Basic.h:280
@ TopLeftOutline
Adjust the outline on the top/left edges.
Definition: Basic.h:309
@ StaticBevels
If set, the rendered bevels don't change when the widget is set or unset.
Definition: Basic.h:337
@ ReverseGradient
If set and Pt_FLAT_FILL is clear, the gradient rendered is reversed (i.e. begin with the dark fill co...
Definition: Basic.h:328
@ StaticBevelColors
If set, the bevel color doesn't change when you set ArgColor::FillColor.
Definition: Basic.h:329
@ StaticGradient
If set, the gradient doesn't reverse when the widget is set or unset.
Definition: Basic.h:336
@ AllInlines
Adjust the inline on the all edges.
Definition: Basic.h:317
@ BottomRightInline
Adjust the inline on the bottom/right edges.
Definition: Basic.h:316
@ FlatFill
If set, the widget is filled with a solid color as given by ArgColor::FillColor. If clear,...
Definition: Basic.h:326
@ All
Adjust all edge decorations (etch, outline, bevel, and inline) on the all edges.
Definition: Basic.h:322
@ BottomRightBevel
Adjust the bevel on the bottom/right edges.
Definition: Basic.h:313
@ HorizontalGradient
If set, and Pt_FLAT_FILL is clear, the fill gradient changes colors on the horizontal axis....
Definition: Basic.h:327
@ AllBevels
Adjust the bevel on the all edges.
Definition: Basic.h:314
@ TopLeftInline
Adjust the inline on the top/left edges.
Definition: Basic.h:315
@ BottomRightEtch
Adjust the etching on the bottom/right edges.
Definition: Basic.h:307
@ TopLeftBevel
Adjust the bevel on the top/left edges.
Definition: Basic.h:312
@ BlankEtches
Don't draw the etched lines.
Definition: Basic.h:288
@ AllLeft
Adjust all edge decorations (etch, outline, bevel, and inline) on the left edge.
Definition: Basic.h:320
@ OpaqueEtches
Use a solid line, instead of an alpha line, for the etching. The color is calculated based on the wid...
Definition: Basic.h:289
@ AllBottom
Adjust all edge decorations (etch, outline, bevel, and inline) on the bottom edge.
Definition: Basic.h:319
@ AllRight
Adjust all edge decorations (etch, outline, bevel, and inline) on the right edge.
Definition: Basic.h:321
@ AllTop
Adjust all edge decorations (etch, outline, bevel, and inline) on the top edge.
Definition: Basic.h:318
@ AllOutlines
Adjust the outline on the all edges.
Definition: Basic.h:311
@ PreventFill
If set, the widget isn't filled. This is useful when you want to set the base color for borders and e...
Definition: Basic.h:330
@ BottomRightOutline
Adjust the outline on the bottom/right edges.
Definition: Basic.h:310
@ TopLeftEtch
Adjust the etching on the top/left edges.
Definition: Basic.h:306
@ AllEtches
Adjust the etching on the all edges.
Definition: Basic.h:308
Contains flags for all Basic resources.
Definition: Basic.h:269
Contains resource IDs for all Widget arguments.
Definition: Widget.h:239
Contains flags for Widget resources.
Definition: Widget.h:692