OpenCPN Partial API docs
Loading...
Searching...
No Matches
styles.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 Jesper Weissglas *
3 * Copyright (C) 2010 by David S. Register bdbcat@yahoo.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef STYLES_H_
26#define STYLES_H_
27
28#include <wx/bitmap.h>
29#include <wx/colour.h>
30#include <wx/dynarray.h>
31#include <wx/gdicmn.h>
32#include <wx/string.h>
33
34#include "model/ocpn_types.h"
35#include "color_types.h"
36
37enum StyleToolIconTypes {
38 TOOLICON_NORMAL,
39 TOOLICON_TOGGLED,
40 TOOLICON_DISABLED,
41 TOOLICON_ACTIVE
42};
43
44namespace ocpnStyle {
45
46class StyleManager; // forward
47
48WX_DECLARE_STRING_HASH_MAP(int, intHash);
49
50} // namespace ocpnStyle
51
54wxBitmap MergeBitmaps(wxBitmap back, wxBitmap front, wxSize offset);
55
56wxBitmap ConvertTo24Bit(wxColor bgColor, wxBitmap front);
57
58namespace ocpnStyle {
59
60class Tool {
61public:
62 wxString name;
63 wxPoint iconLoc;
64 wxPoint rolloverLoc;
65 wxPoint disabledLoc;
66 wxPoint activeLoc;
67 wxBitmap icon;
68 wxBitmap rollover;
69 wxBitmap rolloverToggled;
70 wxBitmap disabled;
71 wxBitmap active;
72 wxBitmap toggled;
73 bool iconLoaded;
74 bool rolloverLoaded;
75 bool rolloverToggledLoaded;
76 bool disabledLoaded;
77 bool activeLoaded;
78 bool toggledLoaded;
79 wxSize customSize;
80
81 void Unload() {
82 iconLoaded = false;
83 rolloverLoaded = false;
84 rolloverToggledLoaded = false;
85 disabledLoaded = false;
86 activeLoaded = false;
87 toggledLoaded = false;
88 customSize = wxSize(32, 32);
89 }
90
91 Tool() { Unload(); }
92};
93
94class Icon {
95public:
96 wxString name;
97 wxPoint iconLoc;
98 wxSize size;
99 wxBitmap icon;
100 bool loaded;
101
102 void Unload() { loaded = false; }
103
104 Icon() { Unload(); }
105};
106
107class Style {
108public:
109 Style();
110 ~Style();
111
112 wxBitmap GetNormalBG();
113 wxBitmap GetActiveBG();
114 wxBitmap GetToggledBG();
115 wxBitmap GetToolbarStart();
116 wxBitmap GetToolbarEnd();
117 bool HasBackground() const { return hasBackground; }
118 void HasBackground(bool b) { hasBackground = b; }
119 wxBitmap GetIcon(const wxString& name, int width = -1, int height = -1,
120 bool bforceReload = false);
121 wxBitmap GetIconScaled(const wxString& name, double scaleFactor,
122 bool bforceReload = false);
123
124 wxBitmap GetToolIcon(const wxString& toolname, int iconType = TOOLICON_NORMAL,
125 bool rollover = false, int width = -1, int height = -1);
126 wxBitmap BuildPluginIcon(wxBitmap& bm, int iconType, double scale = 1.0);
127 bool NativeToolIconExists(const wxString& name);
128
129 int GetTopMargin() const { return toolMarginTop[currentOrientation]; }
130 int GetRightMargin() const { return toolMarginRight[currentOrientation]; }
131 int GetBottomMargin() const { return toolMarginBottom[currentOrientation]; }
132 int GetLeftMargin() const { return toolMarginLeft[currentOrientation]; }
133 int GetToolbarCornerRadius();
134
135 int GetCompassTopMargin() const { return compassMarginTop; }
136 int GetCompassRightMargin() const { return compassMarginRight; }
137 int GetCompassBottomMargin() const { return compassMarginBottom; }
138 int GetCompassLeftMargin() const { return compassMarginLeft; }
139 int GetCompassCornerRadius() const { return compasscornerRadius; }
140 int GetCompassXOffset() const { return compassXoffset; }
141 int GetCompassYOffset() const { return compassYoffset; }
142
143 int GetToolSeparation() const { return toolSeparation[currentOrientation]; }
144 wxSize GetToolSize() const { return toolSize[currentOrientation]; }
145 wxSize GetToggledToolSize() const {
146 return toggledBGSize[currentOrientation];
147 }
148
149 bool HasToolbarStart() const {
150 return toolbarStartLoc[currentOrientation] != wxPoint(0, 0);
151 }
152 bool HasToolbarEnd() const {
153 return toolbarEndLoc[currentOrientation] != wxPoint(0, 0);
154 }
155 void DrawToolbarLineStart(wxBitmap& bmp, double scale = 1.0);
156 void DrawToolbarLineEnd(wxBitmap& bmp, double scale = 1.0);
157
158 static wxBitmap SetBitmapBrightness(wxBitmap& bitmap, ColorScheme cs);
159 static wxBitmap SetBitmapBrightnessAbs(wxBitmap& bitmap, double level);
160
161 void SetOrientation(long orient);
162 int GetOrientation();
163 void SetColorScheme(ColorScheme cs);
164 void Unload();
165
166 wxString name;
167 wxString sysname;
168 wxString description;
169 wxString graphicsFile;
170 int toolMarginTop[2];
171 int toolMarginRight[2];
172 int toolMarginBottom[2];
173 int toolMarginLeft[2];
174 int toolSeparation[2];
175 int cornerRadius[2];
176 int compassMarginTop;
177 int compassMarginRight;
178 int compassMarginBottom;
179 int compassMarginLeft;
180 int compasscornerRadius;
181 int compassXoffset;
182 int compassYoffset;
183
184 wxSize toolSize[2];
185 wxSize toggledBGSize[2];
186 wxPoint toggledBGlocation[2];
187 wxPoint activeBGlocation[2];
188 wxPoint normalBGlocation[2];
189 wxSize verticalIconOffset;
190 wxArrayPtrVoid tools;
191 intHash toolIndex;
192 wxArrayPtrVoid icons;
193 intHash iconIndex;
194 wxBitmap* graphics;
195
196 wxColor consoleFontColor;
197 wxPoint consoleTextBackgroundLoc;
198 wxSize consoleTextBackgroundSize;
199 wxPoint toolbarStartLoc[2];
200 wxSize toolbarStartSize[2];
201 wxPoint toolbarEndLoc[2];
202 wxSize toolbarEndSize[2];
203 wxBitmap consoleTextBackground;
204 wxBitmap toolbarStart[2];
205 wxBitmap toolbarEnd[2];
206
207 bool marginsInvisible;
208
209 int chartStatusIconWidth;
210 bool chartStatusWindowTransparent;
211
212 wxString embossFont;
213 int embossHeight;
214
215 wxString myConfigFileDir;
216
217private:
218 int currentOrientation;
219 ColorScheme colorscheme;
220 bool hasBackground;
221};
222
224public:
225 StyleManager();
227 StyleManager(const wxString& configDir);
228
229 bool IsOK() const { return isOK; }
230 void Init(const wxString& fromPath);
231 void SetStyle(wxString name);
232 void SetStyleNextInvocation(const wxString& name) {
233 nextInvocationStyle = name;
234 }
235 const wxString& GetStyleNextInvocation() const { return nextInvocationStyle; }
236 Style* GetCurrentStyle();
237 wxArrayPtrVoid GetArrayOfStyles() { return styles; };
238
239private:
240 bool isOK;
241 wxArrayPtrVoid styles;
242 Style* currentStyle;
243 wxString nextInvocationStyle;
244};
245
246} // namespace ocpnStyle
247
248#endif // STYLES_H_
Navigation data types.
wxBitmap MergeBitmaps(wxBitmap back, wxBitmap front, wxSize offset)
Definition styles.cpp:66
ocpnStyle::StyleManager * g_StyleManager
Global instance.
Definition styles.cpp:53