30 #ifndef Pt_Forms_PushButton_H
31 #define Pt_Forms_PushButton_H
33 #include <Pt/Forms/Button.h>
34 #include <Pt/Forms/Icon.h>
35 #include <Pt/Forms/PixmapSurface.h>
36 #include <Pt/Gfx/Image.h>
37 #include <Pt/Gfx/Brush.h>
38 #include <Pt/Gfx/Pen.h>
39 #include <Pt/SmartPtr.h>
47 class PT_FORMS_API PushButton :
public Button
63 virtual ~PushButton();
65 bool isPressed()
const;
67 void setPressed(
bool pressed);
69 bool isToggle()
const;
71 void setToggle(
bool toggle);
73 void setIcon(
const Icon& icon,
const Gfx::SizeF& iconSize);
79 void setLayout(Direction d);
82 const Gfx::Brush& foreground()
const;
84 void setForeground(
const Gfx::Brush& b);
86 const Gfx::Pen& contour()
const;
88 void setContour(
const Gfx::Pen& p);
90 const Gfx::Color& accentColor()
const;
92 void setAccentColor(
const Gfx::Color& color);
94 const Gfx::Color& highlightColor()
const;
96 void setHighlightColor(
const Gfx::Color& c);
98 const Gfx::Color& textColor()
const;
100 void setTextColor(
const Gfx::Color& color);
102 const Gfx::Font& font()
const;
104 void setFont(
const Gfx::Font& font);
106 void setFontSize(std::size_t size);
108 void setFontWeight(Gfx::Font::Weight weight);
110 void setFontSlant(Gfx::Font::Slant slant);
112 void setRenderer(ButtonRenderer* renderer);
115 virtual void onPressed();
117 virtual void onReleased();
119 virtual void onCanceled();
122 virtual void onSetStyleOptions(
const StyleOptions& options);
124 virtual Gfx::SizeF onMeasure(
const SizePolicy& policy);
126 virtual void onLayout(
const Gfx::RectF& rect);
128 virtual void onInvalidate();
130 virtual void onPaint(PaintSurface& surface,
const Gfx::RectF& updateRect);
133 void onIconChanged();
135 Gfx::Font getFont()
const;
138 enum FontOverride :
unsigned
141 OverrideWeight = 0x02,
142 OverrideSlant = 0x04,
149 bool _isBeingToggled;
151 Direction _direction;
153 Gfx::SizeF _iconSize;
154 Gfx::PointF _iconPos;
155 Gfx::PointF _textPos;
156 Gfx::TextMetrics _textMetrics;
157 Gfx::FontMetrics _fontMetrics;
159 FacetPtr<ButtonRenderer> _renderer;
162 AutoPtr<Gfx::Brush> _foreground;
163 AutoPtr<Gfx::Pen> _contour;
164 AutoPtr<Gfx::Color> _accentColor;
165 AutoPtr<Gfx::Color> _highlightColor;
166 AutoPtr<Gfx::Color> _textColor;
167 Gfx::Font _customFont;
168 unsigned _fontOverride;
169 std::size_t _styleGeneration;
175 PixmapSurface _picture;