6 #ifndef TB_WIDGETS_COMMON_H
7 #define TB_WIDGETS_COMMON_H
9 #include "tb_widgets.h"
10 #include "tb_layout.h"
43 bool SetText(
const TBStr & text) {
return m_text.Set(text); }
44 bool GetText(
TBStr &text)
const {
return text.Set(m_text); }
46 bool IsEmpty()
const {
return m_text.IsEmpty(); }
69 virtual bool GetText(
TBStr &text)
const {
return m_text.GetText(text); }
79 bool IsEmpty()
const {
return m_text.IsEmpty(); }
84 TB_TEXT_ALIGN GetTextAlign()
const {
return m_text.GetTextAlign(); }
89 bool GetSqueezable()
const {
return m_squeezable; }
93 const TBStr & GetFormat()
const {
return m_format; }
95 virtual void OnInflate(
const INFLATE_INFO &info);
96 virtual void OnDeflate(
const INFLATE_INFO &info);
99 virtual void OnPaint(
const PaintProps &paint_props);
101 TBWidgetString m_text;
128 bool GetSqueezable() {
return m_textfield.GetSqueezable(); }
131 void SetAutoRepeat(
bool auto_repeat_click) { m_auto_repeat_click = auto_repeat_click; }
132 bool GetAutoRepeat() {
return m_auto_repeat_click; }
137 bool GetToggleMode()
const {
return m_toggle_mode; }
140 virtual bool SetText(
const TBStr & text);
163 void UpdateTextFieldVisibility();
164 bool CanToggle() {
return m_toggle_mode ||
GetGroupID(); }
167 virtual void OnChildAdded(
TBWidget *child);
168 virtual void OnChildRemove(
TBWidget *child);
172 bool m_auto_repeat_click;
264 virtual void OnPaint(
const PaintProps &paint_props);
337 void SetLimits(
double min,
double max,
double visible);
348 double GetMinValue()
const {
return m_min; }
349 double GetMaxValue()
const {
return m_max; }
350 double GetVisible()
const {
return m_visible; }
361 virtual void OnResized(
int old_w,
int old_h);
366 double m_min, m_max, m_visible;
367 double m_to_pixel_factor;
375 template <
typename VAL_T>
390 void SetLimits(VAL_T min, VAL_T max,
int nstep = 100);
392 VAL_T GetMinValue()
const {
return m_min; }
393 VAL_T GetMaxValue()
const {
return m_max; }
397 void SetSmallStep(VAL_T step) { m_step = step; }
401 virtual VAL_T GetValueVal()
const {
return m_value; }
415 virtual void OnResized(
int old_w,
int old_h);
420 VAL_T m_min, m_max, m_step;
421 double m_to_pixel_factor;
424 typedef TBSliderX<double> TBSlider;
425 typedef TBSliderX<int> TBSliderInt;
426 typedef TBSliderX<long> TBSliderLong;
478 #endif // TB_WIDGETS_COMMON_H
AXIS
Definition: tb_widgets.h:251
TBTextField is a one line text field that is not editable.
Definition: tb_widgets_common.h:59
virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &)
< Make all versions in base class available.
Definition: tb_widgets_common.h:200
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_widgets_common.h:387
virtual void OnPaint(const PaintProps &paint_props)
Callback for painting this widget.
Definition: tb_widgets_common.cpp:139
virtual void SetValue(long value)
Give SetValue corrent precision.
Definition: tb_widgets_common.h:404
virtual PreferredSize OnCalculatePreferredSize(const SizeConstraints &constraints)
Calculate the preferred size for this widget.
Definition: tb_widgets_common.cpp:455
void SetTextAlign(TB_TEXT_ALIGN align)
Set which alignment the text should have if the space given when painting is larger than the text...
Definition: tb_widgets_common.h:83
TBRadioCheckBox has shared functionality for TBCheckBox and TBRadioButton.
Definition: tb_widgets_common.h:275
virtual void SetAxis(AXIS axis)
Set along which axis the content should be layed out (If the label has more content than the text) ...
Definition: tb_widgets_common.h:192
virtual bool GetText(TBStr &text) const
Get the text of this widget.
Definition: tb_widgets_common.h:69
virtual long GetValue() const
See TBWidget::SetValue.
Definition: tb_widgets_common.h:284
virtual void OnFontChanged()
Called when the font has changed.
Definition: tb_widgets_common.cpp:133
TB_TEXT_ALIGN
TB_TEXT_ALIGN specifies horizontal text alignment.
Definition: tb_widgets_common.h:22
virtual void OnDeflate(const INFLATE_INFO &info)
Called when this widget is deflated to a node, before any children have been deflated.
Definition: tb_widgets_reader.cpp:644
bool IsRunning() const
Return true if the animation is running.
Definition: tb_widgets_common.h:251
virtual void SetAxis(AXIS axis)
Set along which axis the scrollbar should scroll.
Definition: tb_widgets_common.cpp:650
virtual bool SetText(const TBStr &text)
Set the text of the text field.
Definition: tb_widgets_common.cpp:84
virtual void SetValueVal(VAL_T value)
Same as SetValue, but with double precision.
Definition: tb_widgets_common.cpp:682
virtual void OnMessageReceived(TBMessage *msg)
Called when a message is delivered.
Definition: tb_widgets_common.cpp:407
TBProgressSpinner is a animation that is running while its value is 1.
Definition: tb_widgets_common.h:242
TBClickLabel has a text field in its internal layout by default.
Definition: tb_widgets_common.h:181
Aligned left.
Definition: tb_widgets_common.h:23
TBSeparator is a widget only showing a skin.
Definition: tb_widgets_common.h:231
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_widgets_common.cpp:463
double atof() const
Call atof() on the string.
Definition: tb_str.h:96
void Begin()
Begin/End are used to start or stop the animation in a incremental way.
Definition: tb_widgets_common.h:256
TBDimmer dim widgets in the background and block input.
Definition: tb_widgets_common.h:463
virtual void OnInflate(const INFLATE_INFO &info)
Called when this widget is inflated from resources, before any children have been inflated...
Definition: tb_widgets_reader.cpp:711
TBSkinImage is a widget showing a skin element, constrained in size to its skin.
Definition: tb_widgets_common.h:217
Specifies size constraints used during size calculations.
Definition: tb_widgets.h:321
TBContainer is just a TBWidget with border and padding (using skin "TBContainer") ...
Definition: tb_widgets_common.h:429
virtual PreferredSize OnCalculatePreferredSize(const SizeConstraints &constraints)
Calculate the preferred size for this widget.
Definition: tb_widgets_common.cpp:336
virtual void OnInflate(const INFLATE_INFO &info)
Called when this widget is inflated from resources, before any children have been inflated...
Definition: tb_widgets_reader.cpp:630
virtual long GetValue() const
See TBWidget::SetValue.
Definition: tb_widgets_common.h:262
TBCheckBox is a box toggling a check mark on click.
Definition: tb_widgets_common.h:297
virtual void SetValue(long value)
Setting the value to 1 will start the spinner.
Definition: tb_widgets_common.cpp:368
virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints)
Calculate the preferred content size for this widget.
Definition: tb_widgets_common.cpp:117
void SetFormat(TBStr format)
The printf formatting string, used for formatting Set*Value().
Definition: tb_widgets_common.cpp:110
virtual void SetValue(long value)
Set the value of this widget.
Definition: tb_widgets_common.cpp:440
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_widgets_common.h:193
TBID is a wrapper for a uint32_t to be used as ID.
Definition: tb_id.h:18
virtual double GetValueDouble() const
Return the value in double precision.
Definition: tb_widgets_common.h:76
Aligned center.
Definition: tb_widgets_common.h:25
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_widgets_common.cpp:830
virtual double GetValueDouble() const
Same as GetValue, but with double precision.
Definition: tb_widgets_common.h:410
virtual void OnDeflate(const INFLATE_INFO &info)
Called when this widget is deflated to a node, before any children have been deflated.
Definition: tb_widgets_reader.cpp:723
virtual void SetValueDouble(double value)
< Make all versions in base class available.
Definition: tb_widgets_common.cpp:94
virtual WIDGET_HIT_STATUS GetHitStatus(int x, int y)
Get hit status tests if this widget should be hit at the given coordinate.
Definition: tb_widgets_common.cpp:821
Aligned right.
Definition: tb_widgets_common.h:24
WIDGET_HIT_STATUS
Hit status return value for TBWidget::GetHitStatus.
Definition: tb_widgets.h:398
virtual void OnPaint(const PaintProps &paint_props)
Callback for painting this widget.
Definition: tb_widgets_common.cpp:392
virtual void OnAdded()
Called when this widget has been added to a parent (after calling OnChildAdded on parent)...
Definition: tb_widgets_common.cpp:861
virtual void OnResized(int old_w, int old_h)
Called when this widget has been resized.
Definition: tb_widgets_common.cpp:766
INFLATE_INFO contains info passed to TBWidget::OnInflate during resource loading. ...
Definition: tb_widgets_reader.h:21
TBMessageHandler handles a list of pending messages posted to itself.
Definition: tb_msg.h:72
virtual bool GetText(TBStr &text) const
Get the text of this widget.
Definition: tb_widgets_common.h:197
void SetLimits(VAL_T min, VAL_T max, int nstep=100)
Set the min, max limits for the slider.
Definition: tb_widgets_common.cpp:669
TBStr is a simple string class.
Definition: tb_str.h:62
Simple rectangle class.
Definition: tb_geometry.h:25
virtual bool SetText(const TBStr &text)
Set the text of the label.
Definition: tb_widgets_common.h:196
virtual void SetAxis(AXIS axis)
Set along which axis the content should be layouted.
Definition: tb_layout.cpp:30
TBMessage is a message created and owned by TBMessageHandler.
Definition: tb_msg.h:47
TBResizer is a lower right corner resize grip.
Definition: tb_widgets_common.h:451
virtual TBWidget * GetContentRoot()
Get this widget or a child widget that should be root for other children.
Definition: tb_widgets_common.h:204
TBColor contains a 32bit color.
Definition: tb_color.h:21
void SetSqueezable(bool squeezable)
Set if this text field should be allowed to squeeze below its preferred size.
Definition: tb_widgets_common.cpp:101
virtual void SetValueDouble(double value)
Same as SetValue, but with double precision.
Definition: tb_widgets_common.h:408
virtual AXIS GetAxis() const
See TBWidget::SetAxis.
Definition: tb_layout.h:106
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_widgets_common.cpp:789
virtual long GetValue() const
Give GetValue corrent precision.
Definition: tb_widgets_common.h:406
PreferredSize contains size preferences for a TBWidget.
Definition: tb_widgets.h:277
TBSlider is a horizontal or vertical slider for a number within a range.
Definition: tb_widgets_common.h:376
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_widgets_common.cpp:305
static void UpdateGroupWidgets(TBWidget *new_leader)
Make sure all widgets sharing the same group as new_leader are set to value 0.
Definition: tb_widgets_common.cpp:426
VAL_T GetSmallStep() const
Get a small value (depending on the min and max limits) for stepping by f.ex.
Definition: tb_widgets_common.h:396
TBLayout layouts its children along the given axis.
Definition: tb_layout.h:96
TBMover is moving its parent widget when dragged.
Definition: tb_widgets_common.h:439
int m_cached_text_width
Cached width of m_text.
Definition: tb_widgets_common.h:103
bool IsEmpty() const
Is the text empty?
Definition: tb_widgets_common.h:79
virtual bool OnEvent(const TBWidgetEvent &ev)
Callback for handling events.
Definition: tb_widgets_common.cpp:695