Photon microGUI widgets library 0.6.0
Loading...
Searching...
No Matches
Label.h
1#ifndef PHWIDGETS_LABEL_H
2#define PHWIDGETS_LABEL_H
3
4#include <photon/PtLabel.h>
5
6#include <string>
7
8#include "./Basic.h"
9#include "./Drawing/Font.h"
10#include "./Drawing/Image.h"
11
12
13namespace PhWidgets
14{
16
26 {
28
34 {
35 Inplace = Pt_BALLOON_INPLACE,
36 Top = Pt_BALLOON_TOP,
37 Left = Pt_BALLOON_LEFT,
38 Right = Pt_BALLOON_RIGHT,
39 Bottom = Pt_BALLOON_BOTTOM
40 };
41 };
42
44
55 struct LabelType
56 {
58
66 {
67 String = Pt_Z_STRING,
68 Image = Pt_IMAGE,
69 TextImage = Pt_TEXT_IMAGE
71 };
72 };
73
75
87 {
89
97 {
98 NoUline = Pt_NO_ULINE,
99 DoubleUline = Pt_DOUBLE_ULINE,
100 SingleUline = Pt_SINGLE_ULINE,
101 UlineEtchedIn = Pt_ULINE_ETCHED_IN,
102 UlineEtchedOut = Pt_ULINE_ETCHED_OUT
103 };
104 };
105
106 namespace Drawing
107 {
109
116 {
117 #define PHWIDGETS_VH(v,h) (((short)((v) & 0xFF) << 8) | (short)((h) & 0xFF))
120 {
121 BottomCenter = PHWIDGETS_VH(Pt_BOTTOM, Pt_CENTER),
122 BottomLeft = PHWIDGETS_VH(Pt_BOTTOM, Pt_LEFT),
123 BottomRight = PHWIDGETS_VH(Pt_BOTTOM, Pt_RIGHT),
124 MiddleCenter = PHWIDGETS_VH(Pt_CENTER, Pt_CENTER),
125 MiddleLeft = PHWIDGETS_VH(Pt_CENTER, Pt_LEFT),
126 MiddleRight = PHWIDGETS_VH(Pt_CENTER, Pt_RIGHT),
127 TopCenter = PHWIDGETS_VH(Pt_TOP , Pt_CENTER),
128 TopLeft = PHWIDGETS_VH(Pt_TOP , Pt_LEFT),
129 TopRight = PHWIDGETS_VH(Pt_TOP , Pt_RIGHT)
130 };
131 #undef PHWIDGETS_VH
132 };
133 } // namespace Drawing
134
139
141
149 class Label:
150 public Basic
151 {
152 public:
153
155 struct ThisArgs
156 {
158 struct ArgPChar
159 {
161
171 {
172 accel_key = Pt_ARG_ACCEL_KEY,
173 balloon_text = Pt_ARG_BALLOON_TEXT,
174 text_font = Pt_ARG_TEXT_FONT,
175 text_string = Pt_ARG_TEXT_STRING
177 };
178 };
179
181 struct ArgColor
182 {
184
194 {
195 balloon_color = Pt_ARG_BALLOON_COLOR,
196 balloon_fill_color = Pt_ARG_BALLOON_FILL_COLOR,
197 underline1 = Pt_ARG_UNDERLINE1,
198 underline2 = Pt_ARG_UNDERLINE2
199 };
200 };
201
203 struct ArgShort
204 {
206
216 {
217 balloon_position = Pt_ARG_BALLOON_POSITION
218 };
219 };
220
223 {
225
235 {
236 line_spacing = Pt_ARG_LINE_SPACING,
237 margin_botton = Pt_ARG_MARGIN_BOTTOM,
238 margin_left = Pt_ARG_MARGIN_LEFT,
239 margin_right = Pt_ARG_MARGIN_RIGHT,
240 margin_top = Pt_ARG_MARGIN_TOP,
241 undeline_type = Pt_ARG_UNDERLINE_TYPE
242 };
243 };
244
247 {
249
259 {
260 secondary_h_align = Pt_ARG_SECONDARY_H_ALIGN,
261 secondary_v_align = Pt_ARG_SECONDARY_V_ALIGN
262 };
263 };
264
267 {
269
279 {
280 horizontal_alignment = Pt_ARG_HORIZONTAL_ALIGNMENT,
281 vertical_alingment = Pt_ARG_VERTICAL_ALIGNMENT
282 };
283 };
284
287 {
289
299 {
300 label_baloon = Pt_ARG_LABEL_BALLOON
302 };
303 };
304
306 struct ArgChar
307 {
309
319 {
320 label_flags = Pt_ARG_LABEL_FLAGS,
321 label_type = Pt_ARG_LABEL_TYPE
322 };
323 };
324
327 {
329
339 {
340 label_image = Pt_ARG_LABEL_IMAGE
341 };
342 };
343
345 struct ArgInt
346 {
348
358 {
359 image_spacing = Pt_ARG_TEXT_IMAGE_SPACING
360 };
361 };
362
363
364 };
365
367 struct ArgPChar:
368 public ArgumentsEx<Basic::ArgPChar>,
369 public ThisArgs::ArgPChar
370 {
371 typedef ThisArgs::ArgPChar::eArgPChar eArgPChar;
372 };
373
375 struct ArgColor:
376 public ArgumentsEx<Basic::ArgColor>,
377 public ThisArgs::ArgColor
378 {
379 typedef ThisArgs::ArgColor::eArgColor eArgColor;
380 };
381
383 struct ArgShort:
384 public ThisArgs::ArgShort
385 { };
386
389 public ArgumentsEx<Basic::ArgUnsignedShort>,
391 {
392 typedef ThisArgs::ArgUnsignedShort::eArgUnsignedShort eArgUnsignedShort;
393 };
394
398 { };
399
402 public ArgumentsEx<Basic::ArgUnsignedChar>,
404 {
405 typedef ThisArgs::ArgUnsignedChar::eArgUnsignedChar eArgUnsignedChar;
406 };
407
411 { };
412
414 struct ArgChar:
415 public ArgumentsEx<Basic::ArgChar>,
416 public ThisArgs::ArgChar
417 {
418 typedef ThisArgs::ArgChar::eArgChar eArgChar;
419 };
420
422 struct ArgPImage:
424 { };
425
427 struct ArgInt:
428 public ThisArgs::ArgInt
429 { };
430
431
433 struct Arguments:
434 public ArgPChar,
435 public ArgColor,
436 public ArgShort,
437 public ArgUnsignedShort,
438 public ArgSignedShort,
439 public ArgUnsignedChar,
440 public ArgPWidgetFunc,
441 public ArgChar,
442 public ArgPImage,
443 public ArgInt,
444 public Basic::Arguments
445 {
446
447 };
448
449 protected:
450
451 typedef ResourceFrom<Basic::WidgetResourcesSingleton>::
452 Define::Image<ArgPImage::eArgPImage>::
453 Define::String<ThisArgs::ArgPChar::eArgPChar>::
454 Define::Color<ThisArgs::ArgColor::eArgColor>::
455 Define::Scalar<ThisArgs::ArgUnsignedShort::eArgUnsignedShort, unsigned short>::
456 Define::Scalar<ThisArgs::ArgShort::eArgShort, short>::
457 Define::Scalar<ThisArgs::ArgSignedShort::eArgSignedShort, signed short>::
458 Define::Scalar<ThisArgs::ArgUnsignedChar::eArgUnsignedChar, unsigned char>::
459 Define::Scalar<ThisArgs::ArgChar::eArgChar, char>::
460
461 resource_type WidgetResourcesSingleton;
462
463 Drawing::Image getImage() const;
464 void setImage(Drawing::Image);
465
466 std::string getText() const;
467 void setText(std::string);
468
469 Drawing::Font getFont() const;
470 void setFont(Drawing::Font);
471
472 void setBalloonPosition(PhWidgets::BalloonPosition::eBalloonPosition);
473 PhWidgets::BalloonPosition::eBalloonPosition getBalloonPosition() const;
474
476 PhWidgets::LabelType::eLabelType getType() const;
477
478 void setUnderlineType(PhWidgets::UnderlineType::eUnderlineType);
479 PhWidgets::UnderlineType::eUnderlineType getUnderlineType() const;
480
483
484 void setTextClippedAlign(Drawing::ContentAlignment::eContentAlignment);
485 Drawing::ContentAlignment::eContentAlignment getTextClippedAlign() const;
486
487 virtual void check();
488
489 public:
491
495 WidgetResourcesSingleton resource;
496
498
502 explicit Label(int abn);
503
505
509 explicit Label(PtWidget_t *wdg);
510
512
516 Label(const Label &other);
517
519
523 Label &operator=(const Label &other);
524
527
528
530
540 property<Drawing::Image>::bind<Label, &Label::getImage, &Label::setImage> Image;
541
543
553 property<std::string>::bind<Label, &Label::getText, &Label::setText> Text;
554
556
576 property<Drawing::Font>::bind<Label, &Label::getFont, &Label::setFont> Font;
577
579
590 phproperty<Drawing::Color>::bind<Label, ArgColor::eArgColor, Arguments::balloon_color> BalloonColor;
591
593
604 phproperty<Drawing::Color>::bind<Label, ArgColor::eArgColor, Arguments::balloon_fill_color> BalloonFillColor;
605
607
627 property<PhWidgets::BalloonPosition::eBalloonPosition>::
628 bind<Label, &Label::getBalloonPosition, &Label::setBalloonPosition> BalloonPosition;
629
631
648 property<Drawing::ContentAlignment::eContentAlignment>::
649 bind<Label, &Label::getTextAlign, &Label::setTextAlign> TextAlign;
650
652
670 property<Drawing::ContentAlignment::eContentAlignment>::
671 bind<Label, &Label::getTextClippedAlign, &Label::setTextClippedAlign> TextClippedAlign;
672
674
688 property<PhWidgets::LabelType::eLabelType>::
689 bind<Label, &Label::getType, &Label::setType> Type;
690
692
705 phproperty<Drawing::Color>::bind<Label, ArgColor::eArgColor, Arguments::underline1> UnderlineColor1;
706
708
721 phproperty<Drawing::Color>::bind<Label, ArgColor::eArgColor, Arguments::underline2> UnderlineColor2;
722
724
740 property<PhWidgets::UnderlineType::eUnderlineType>::
741 bind<Label, &Label::getUnderlineType, &Label::setUnderlineType> UnderlineType;
743 };
744
745} // namespace PhWidgets
746
747
748#endif // PHWIDGETS_LABEL_H
Basic(int abn)
(constructor)
Defines a particular format for text, including font face, size, and style attributes....
Definition Font.h:232
An abstract base class that provides functionality for the Drawing::Bitmap class.
Definition Image.h:185
property< std::string >::bind< Label, &Label::getText, &Label::setText > Text
Gets or sets the text associated with this widget.
Definition Label.h:553
WidgetResourcesSingleton resource
Resources of the Label.
Definition Label.h:495
property< Drawing::ContentAlignment::eContentAlignment >::bind< Label, &Label::getTextClippedAlign, &Label::setTextClippedAlign > TextClippedAlign
Gets or sets the alignment of text in the label if the text string is clipped.
Definition Label.h:671
phproperty< Drawing::Color >::bind< Label, ArgColor::eArgColor, Arguments::balloon_color > BalloonColor
Gets or sets the balloon color of the Label.
Definition Label.h:590
Label(PtWidget_t *wdg)
(constructor)
property< Drawing::Font >::bind< Label, &Label::getFont, &Label::setFont > Font
Gets or sets the font of the text displayed by the widget.
Definition Label.h:576
phproperty< Drawing::Color >::bind< Label, ArgColor::eArgColor, Arguments::underline1 > UnderlineColor1
Gets or sets the underline color for the first line of the Label.
Definition Label.h:705
property< Drawing::ContentAlignment::eContentAlignment >::bind< Label, &Label::getTextAlign, &Label::setTextAlign > TextAlign
Gets or sets the alignment of text in the label.
Definition Label.h:649
Label & operator=(const Label &other)
Assigns value in Label widget.
phproperty< Drawing::Color >::bind< Label, ArgColor::eArgColor, Arguments::underline2 > UnderlineColor2
Gets or sets the underline color for the second line of the Label.
Definition Label.h:721
Label(int abn)
(constructor)
property< PhWidgets::BalloonPosition::eBalloonPosition >::bind< Label, &Label::getBalloonPosition, &Label::setBalloonPosition > BalloonPosition
Gets or sets where the balloon with the label's text pops up.
Definition Label.h:628
property< Drawing::Image >::bind< Label, &Label::getImage, &Label::setImage > Image
Gets or sets the Image associated with this widget.
Definition Label.h:540
phproperty< Drawing::Color >::bind< Label, ArgColor::eArgColor, Arguments::balloon_fill_color > BalloonFillColor
Gets or sets the balloon fill color of the Label.
Definition Label.h:604
property< PhWidgets::LabelType::eLabelType >::bind< Label, &Label::getType, &Label::setType > Type
Gets or sets the type of information displayed by the Label.
Definition Label.h:689
property< PhWidgets::UnderlineType::eUnderlineType >::bind< Label, &Label::getUnderlineType, &Label::setUnderlineType > UnderlineType
Gets or sets the type of underline.
Definition Label.h:741
Label(const Label &other)
(copy constructor)
The main namespace for all widgets.
Definition Basic.h:11
Indicates where the balloon with the Label 's text pops up.
Definition Label.h:26
eBalloonPosition
Possible Label balloon positions.
Definition Label.h:34
@ Top
place Label balloon to top.
Definition Label.h:36
@ Inplace
keep Label balloon inplace.
Definition Label.h:35
@ Bottom
place Label balloon to bottom.
Definition Label.h:39
@ Left
place Label balloon to left.
Definition Label.h:37
@ Right
place Label balloon to right.
Definition Label.h:38
Contains resource IDs for Basic arguments.
Definition Basic.h:47
Specifies alignment of content on the drawing surface.
Definition Label.h:116
eContentAlignment
Possible alignment of content on the drawing surface.
Definition Label.h:120
@ MiddleCenter
Content is vertically aligned in the middle, and horizontally aligned at the center.
Definition Label.h:124
@ TopCenter
Content is vertically aligned at the top, and horizontally aligned at the center.
Definition Label.h:127
@ BottomLeft
Content is vertically aligned at the bottom, and horizontally aligned on the left.
Definition Label.h:122
@ MiddleRight
Content is vertically aligned in the middle, and horizontally aligned on the right.
Definition Label.h:126
@ MiddleLeft
Content is vertically aligned in the middle, and horizontally aligned on the left.
Definition Label.h:125
@ TopLeft
Content is vertically aligned at the top, and horizontally aligned on the left.
Definition Label.h:128
@ TopRight
Content is vertically aligned at the top, and horizontally aligned on the right.
Definition Label.h:129
@ BottomRight
Content is vertically aligned at the bottom, and horizontally aligned on the right.
Definition Label.h:123
@ BottomCenter
Content is vertically aligned at the bottom, and horizontally aligned at the center.
Definition Label.h:121
Contains resource IDs for arguments of type char.
Definition Label.h:417
Contains resource IDs for arguments of type PgColor_t.
Definition Label.h:378
Contains resource IDs for arguments of type int.
Definition Label.h:429
Contains resource IDs for arguments of type char*.
Definition Label.h:370
Contains resource IDs for arguments of type PhImage_t.
Definition Label.h:424
Contains resource IDs for arguments of type PtWidget_t * (*)().
Definition Label.h:411
Contains resource IDs for arguments of type short.
Definition Label.h:385
Contains resource IDs for arguments of type signed short.
Definition Label.h:398
Contains resource IDs for arguments of type unsigned char.
Definition Label.h:404
Contains resource IDs for arguments of type unsigned short.
Definition Label.h:391
Contains resource IDs for all Label arguments.
Definition Label.h:445
Contains resource IDs for Label arguments of type char.
Definition Label.h:307
eArgChar
Resource IDs for Label arguments of type char.
Definition Label.h:319
Contains resource IDs for Label arguments of type PgColor_t.
Definition Label.h:182
eArgColor
Resource IDs for Label arguments of type PgColor_t.
Definition Label.h:194
@ balloon_fill_color
The balloon's fill color. See Label::BalloonFillColor.
Definition Label.h:196
@ underline1
The underline color for the first line. See Label::UnderlineColor1.
Definition Label.h:197
@ balloon_color
The balloon's text color. See Label::BalloonColor.
Definition Label.h:195
@ underline2
The underline color for the second line. See Label::UnderlineColor2.
Definition Label.h:198
Contains resource IDs for Label arguments of type int.
Definition Label.h:346
eArgInt
Resource IDs for Label arguments of type long.
Definition Label.h:358
Contains resource IDs for Label arguments of type char*.
Definition Label.h:159
eArgPChar
Resource IDs for Label arguments of type char*.
Definition Label.h:171
@ text_font
The font used for the label's text string. See Label::Font.
Definition Label.h:174
@ accel_key
The accelerator key to underline within the widget's text string. You typically use this resource for...
Definition Label.h:172
@ text_string
Definition Label.h:175
@ balloon_text
The text string to display in the balloon. If left blank, the Label::Text is used for balloons.
Definition Label.h:173
Contains resource IDs for Label arguments of type PhImage_t.
Definition Label.h:327
eArgPImage
Resource IDs for Label arguments of type PhImage_t.
Definition Label.h:339
Contains resource IDs for Label arguments of type PtWidget_t * (*)().
Definition Label.h:287
eArgPWidgetFunc
Resource IDs for Label arguments of type PtWidget_t * (*)().
Definition Label.h:299
Contains resource IDs for Label arguments of type short.
Definition Label.h:204
eArgShort
Resource IDs for Label arguments of type short.
Definition Label.h:216
@ balloon_position
Indicates where the balloon with the label's text pops up. See Label::BalloonPosition.
Definition Label.h:217
Contains resource IDs for Label arguments of type signed short.
Definition Label.h:247
eArgSignedShort
Resource IDs for Label arguments of type signed short.
Definition Label.h:259
@ secondary_h_align
The horizontal alignment for the text string, if the text string is clipped. See Label::TextClippedAl...
Definition Label.h:260
@ secondary_v_align
The vertical alignment for the text string, if the text string is clipped. See Label::TextClippedAlig...
Definition Label.h:261
Contains resource IDs for Label arguments of type unsigned char.
Definition Label.h:267
eArgUnsignedChar
Resource IDs for Label arguments of type unsigned char.
Definition Label.h:279
@ horizontal_alignment
The horizontal alignment for the text string. See Label::TextAlign.
Definition Label.h:280
@ vertical_alingment
The vertical alignment for the text string. See Label::TextAlign.
Definition Label.h:281
Contains resource IDs for Label arguments of type unsigned short.
Definition Label.h:223
eArgUnsignedShort
Resource IDs for Label arguments of type unsigned short.
Definition Label.h:235
@ margin_top
The amount of space between the top of the label's canvas and the canvas defined by the Basic widget.
Definition Label.h:240
@ margin_right
The amount of space between the right side of the label's canvas and the canvas defined by the Basic ...
Definition Label.h:239
@ margin_left
The amount of space between the left side of the label's canvas and the canvas defined by the Basic w...
Definition Label.h:238
@ margin_botton
The amount of space between the bottom of the label's canvas and the canvas defined by the Basic widg...
Definition Label.h:237
@ line_spacing
The space, in pixels, between the lines of text in the label.
Definition Label.h:236
@ undeline_type
The type of underline. See Label::UnderlineType.
Definition Label.h:241
Contains resource IDs for Label arguments.
Definition Label.h:156
The type of information displayed by the Label.
Definition Label.h:56
eLabelType
Possible type of information displayed by the Label.
Definition Label.h:66
@ TextImage
Definition Label.h:69
@ String
Use Label::Text (Label::Argument::text_string resource) to display the text.
Definition Label.h:67
@ Image
Use Label::Image (Label::Argument::label_image resource) to display an image.
Definition Label.h:68
The type of Label underline.
Definition Label.h:87
eUnderlineType
Possible type of Label underline.
Definition Label.h:97
@ SingleUline
(use with underline color)
Definition Label.h:100
@ DoubleUline
(use with underline color)
Definition Label.h:99
@ NoUline
no
Definition Label.h:98
@ UlineEtchedOut
(use with border color)
Definition Label.h:102
@ UlineEtchedIn
(use with border color)
Definition Label.h:101