Styler.h
1/*
2 Copyright (C) 2015 Marc Boris Duerner
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 As a special exception, you may use this file as part of a free
10 software library without restriction. Specifically, if other files
11 instantiate templates or use macros or inline functions from this
12 file, or you compile this file and link it with other files to
13 produce an executable, this file does not by itself cause the
14 resulting executable to be covered by the GNU General Public
15 License. This exception does not however invalidate any other
16 reasons why the executable file might be covered by the GNU Library
17 General Public License.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, write to the:
26 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301 USA
28*/
29
30#ifndef Pt_Forms_Styler_h
31#define Pt_Forms_Styler_h
32
33#include <Pt/Forms/Api.h>
34#include <Pt/Forms/Renderer.h>
35#include <Pt/Forms/StyleOptions.h>
36#include <Pt/NonCopyable.h>
37
38namespace Pt {
39
40namespace Forms {
41
66class PT_FORMS_API Styler : private NonCopyable
67{
68 public:
72
75 virtual ~Styler();
76
82 bool bind(const Style& style, const StyleOptions& styleOptions);
83
86 bool isBound() const;
87
88 protected:
95 void init(Renderer* renderer);
96
102 virtual StyleOptions& onBindOptions(const StyleOptions& global) = 0;
103
108 virtual Renderer* onStyleRenderer(const Style& style) = 0;
109
114 virtual Renderer* onCreateRenderer(const Style& style) = 0;
115
116 private:
117 bool isStyleChanged(const Style& style,
118 const StyleOptions& styleOptions,
119 const StyleOptions& localOptions) const;
120
121 bool isOptionsChanged(const StyleOptions& localOptions) const;
122
123 private:
124 FacetPtr<Renderer> _renderer;
125 std::size_t _styleGeneration;
126 std::size_t _optionsGeneration;
127 bool _isRenderer;
128 bool _isDefaultOptions;
129};
130
131} // namespace
132
133} // namespace
134
135#endif
Manages a reference-counted Style::Facet.
Definition Style.h:79
Provides cloneable drawing for one control family.
Definition Renderer.h:61
Stores named appearance options.
Definition StyleOptions.h:646
Stores renderer facets for the active theme.
Definition Style.h:203
bool isBound() const
Returns true if a renderer is bound.
bool bind(const Style &style, const StyleOptions &styleOptions)
Binds this styler to style and styleOptions.
void init(Renderer *renderer)
Replaces the bound renderer with renderer.
virtual Renderer * onStyleRenderer(const Style &style)=0
Returns the shared style renderer, or 0.
Styler()
Constructor.
virtual StyleOptions & onBindOptions(const StyleOptions &global)=0
Binds the overlay to global and returns it.
virtual ~Styler()
Destructor.
virtual Renderer * onCreateRenderer(const Style &style)=0
Creates an independent clone of the style renderer, or 0.
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33