forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheme.h
200 lines (162 loc) · 4.89 KB
/
Theme.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/**********************************************************************
Sneedacity: A Digital Audio Editor
Theme.h
James Crook
Sneedacity is free software.
This file is licensed under the wxWidgets license, see License.txt
**********************************************************************/
#ifndef __SNEEDACITY_THEME__
#define __SNEEDACITY_THEME__
#include <vector>
#include <wx/defs.h>
#include <wx/window.h> // to inherit
class wxArrayString;
class wxBitmap;
class wxColour;
class wxFont;
class wxImage;
class wxPen;
class ChoiceSetting;
// JKC: will probably change name from 'teBmps' to 'tIndexBmp';
using teBmps = int; /// The index of a bitmap resource in Theme Resources.
enum teResourceType
{
resTypeColour,
resTypeBitmap,
resTypeImage = resTypeBitmap,
resTypeCursor,
resTypeFont
};
enum teResourceFlags
{
resFlagNone =0x00,
resFlagPaired =0x01,
resFlagCursor =0x02,
resFlagNewLine = 0x04,
resFlagInternal = 0x08, // For image manipulation. Don't save or load.
resFlagSkip = 0x10
};
enum teThemeType
{
themeClassic,
themeDark,
themeLight,
themeHiContrast,
themeFromFile,
};
class SNEEDACITY_DLL_API FlowPacker
{
public:
FlowPacker(){;};
~FlowPacker(){;};
void Init(int width);
void GetNextPosition( int xSize, int ySize );
void SetNewGroup( int iGroupSize );
void SetColourGroup( );
wxRect Rect();
wxRect RectInner();
void RectMid( int &x, int &y );
// These 4 should become private again...
int mFlags;
int mxPos;
int myPos;
int myHeight;
int mBorderWidth;
private:
int iImageGroupSize;
int iImageGroupIndex;
int mOldFlags;
int myPosBase;
int mxWidth;
int mxCacheWidth;
int mComponentWidth;
int mComponentHeight;
};
class SNEEDACITY_DLL_API ThemeBase /* not final */
{
public:
ThemeBase(void);
ThemeBase ( const ThemeBase & ) = delete;
ThemeBase &operator =( const ThemeBase & ) = delete;
public:
virtual ~ThemeBase(void);
public:
virtual void EnsureInitialised()=0;
void LoadTheme( teThemeType Theme );
void RegisterImage( int &iIndex,char const** pXpm, const wxString & Name);
void RegisterImage( int &iIndex, const wxImage &Image, const wxString & Name );
void RegisterColour( int &iIndex, const wxColour &Clr, const wxString & Name );
teThemeType GetFallbackThemeType();
teThemeType ThemeTypeOfTypeName( const wxString & Name );
void CreateImageCache(bool bBinarySave = true);
bool ReadImageCache( teThemeType type = themeFromFile, bool bOkIfNotFound=false);
void LoadComponents( bool bOkIfNotFound =false);
void SaveComponents();
void SaveThemeAsCode();
void WriteImageDefs( );
void WriteImageMap( );
static bool LoadPreferredTheme();
bool IsUsingSystemTextColour(){ return bIsUsingSystemTextColour;};
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
void RecolourTheme();
int ColourDistance( wxColour & From, wxColour & To );
wxColour & Colour( int iIndex );
wxBitmap & Bitmap( int iIndex );
wxImage & Image( int iIndex );
wxCursor & Cursor( int iIndex );
wxFont & Font( int iIndex );
wxSize ImageSize( int iIndex );
bool bRecolourOnLoad; // Request to recolour.
bool bIsUsingSystemTextColour;
void ReplaceImage( int iIndex, wxImage * pImage );
void RotateImageInto( int iTo, int iFrom, bool bClockwise );
void SetBrushColour( wxBrush & Brush, int iIndex );
void SetPenColour( wxPen & Pen, int iIndex );
void SetFlags( int flags ){ mFlow.mFlags = flags;};
// Utility function that combines a bitmap and a mask, both in XPM format.
wxImage MaskedImage( char const ** pXpm, char const ** pMask );
// Utility function that takes a 32 bit bitmap and makes it into an image.
wxImage MakeImageWithAlpha( wxBitmap & Bmp );
protected:
// wxImage, wxBitmap copy cheaply using reference counting
std::vector<wxImage> mImages;
std::vector<wxBitmap> mBitmaps;
wxArrayString mBitmapNames;
std::vector<int> mBitmapFlags;
std::vector<wxColour> mColours;
wxArrayString mColourNames;
FlowPacker mFlow;
};
class SNEEDACITY_DLL_API Theme final : public ThemeBase
{
public:
Theme(void);
public:
~Theme(void);
public:
void EnsureInitialised() override;
void RegisterImages();
void RegisterColours();
bool mbInitialised;
};
// A bit cheeky - putting a themable wxStaticText control into
// theme, rather than in a new file. Saves sorting out makefiles (for now).
class wxWindow;
class wxString;
class wxPaintEvent;
class SNEEDACITY_DLL_API auStaticText : public wxWindow
{
public:
auStaticText(wxWindow* parent, wxString text);
void OnPaint(wxPaintEvent & evt);
bool AcceptsFocus() const override { return false; }
void OnErase(wxEraseEvent& event) {
static_cast<void>(event);
};
DECLARE_EVENT_TABLE();
};
extern SNEEDACITY_DLL_API Theme theTheme;
extern SNEEDACITY_DLL_API ChoiceSetting
GUITheme
;
#endif // __SNEEDACITY_THEME__