SCDoc: Use proper static string constants instead of comparing string literals.
[supercollider.git] / QtCollider / style / style.hpp
blob3708a71ea679d9d1dc5a0cb814e7a3eb13b39e69
1 #ifndef QC_STYLE_H
2 #define QC_STYLE_H
4 #include "ProxyStyle.hpp"
5 #include "routines.hpp"
7 #include <QStyleOptionComplex>
9 class QcSlider;
11 namespace QtCollider {
12 namespace Style {
14 enum ColorRole {
15 Focus = 0,
16 Groove,
18 ColorRoleCount
21 class StyleImpl : public ProxyStyle
23 Q_OBJECT
25 public:
27 StyleImpl( QStyle *s = 0 ) : ProxyStyle( s ) {}
29 virtual void polish ( QPalette & );
31 QColor color( ColorRole role ) {
32 Q_ASSERT(role < ColorRoleCount);
33 return _colors[role];
36 private:
37 QColor _colors[ColorRoleCount];
40 struct Client {
41 Client( QWidget *w ) : _widget(w) {}
43 QColor focusColor() const { return color(Focus); }
44 void setFocusColor( const QColor & c ) { setColor(Focus, c); }
46 QColor grooveColor() const { return color(Groove); }
47 void setGrooveColor( const QColor & c ) { setColor(Groove, c); }
49 QColor color ( ColorRole role ) const {
50 Q_ASSERT(role < ColorRoleCount);
51 QColor c( _colors[role] );
52 if( c.isValid() )
53 return c;
54 else {
55 StyleImpl *style = qobject_cast<StyleImpl*>(_widget->style());
56 return style ? style->color(role) : QColor();
60 void setColor( ColorRole role, const QColor & color ) {
61 Q_ASSERT( role < ColorRoleCount );
62 _colors[role] = color;
63 _widget->update();
66 private:
67 QColor _colors[ColorRoleCount];
68 QWidget *_widget;
71 } // namespace QtCollider
72 } // namespace Style
74 #endif