Debian Codegraph @

code/apis/SkinManager.h

raw
1 /*
2 Copyright (C) 2009-2010 wxLauncher Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef SKIN_H
20 #define SKIN_H
21
22 #include <wx/wx.h>
23 #include <wx/filename.h>
24
25 #include "apis/EventHandlers.h"
26 #include "datastructures/NewsSource.h"
27
28 /** TC skin has changed. */
29 LAUNCHER_DECLARE_EVENT_TYPE(EVT_TC_SKIN_CHANGED);
30
31 /** Holds a skin's information. */
32 /** The Set() functions return true on success, false otherwise. */
33 class Skin {
34 public:
35 Skin();
36
37 const wxString& GetWindowTitle() const { return this->windowTitle; }
38 bool SetWindowTitle(const wxString& windowTitle);
39
40 const wxIcon& GetWindowIcon() const { return this->windowIcon; }
41 bool SetWindowIcon(const wxIcon& windowIcon);
42
43 const wxBitmap& GetBanner() const { return this->banner; }
44 bool SetBanner(const wxBitmap& banner);
45
46 const wxString& GetWelcomeText() const { return this->welcomeText; }
47 bool SetWelcomeText(const wxString& welcomeText);
48
49 const wxBitmap& GetModImage() const { return this->modImage; }
50 bool SetModImage(const wxBitmap& modImage);
51
52 const wxBitmap& GetSmallModImage() const { return this->smallModImage; }
53 bool SetSmallModImage(const wxBitmap& smallModImage);
54
55 const wxBitmap& GetOkIcon() const { return this->okIcon; }
56 bool SetOkIcon(const wxBitmap& okIcon);
57
58 const wxBitmap& GetWarningIcon() const { return this->warningIcon; }
59 bool SetWarningIcon(const wxBitmap& warningIcon);
60
61 const wxBitmap& GetBigWarningIcon() const { return this->bigWarningIcon; }
62 bool SetBigWarningIcon(const wxBitmap& bigWarningIcon);
63
64 const wxBitmap& GetErrorIcon() const { return this->errorIcon; }
65 bool SetErrorIcon(const wxBitmap& errorIcon);
66
67 const wxBitmap& GetInfoIcon() const { return this->infoIcon; }
68 bool SetInfoIcon(const wxBitmap& infoIcon);
69
70 const wxBitmap& GetBigInfoIcon() const { return this->bigInfoIcon; }
71 bool SetBigInfoIcon(const wxBitmap& bigInfoIcon);
72
73 const wxBitmap& GetHelpIcon() const { return this->helpIcon; }
74 bool SetHelpIcon(const wxBitmap& helpIcon);
75
76 const wxBitmap& GetBigHelpIcon() const { return this->bigHelpIcon; }
77 bool SetBigHelpIcon(const wxBitmap& bigHelpIcon);
78
79 const wxBitmap& GetIdealIcon() const { return this->idealIcon; }
80 bool SetIdealIcon(const wxBitmap& idealIcon);
81
82 const NewsSource* GetNewsSource() const { return this->newsSource; }
83 bool SetNewsSource(const NewsSource* newsSource);
84
85 private:
86 static bool CheckStatusBarIconDimensions(const wxBitmap& icon);
87 static bool CheckBigIconDimensions(const wxBitmap& icon);
88
89 wxString windowTitle;
90 wxIcon windowIcon;
91 wxBitmap banner;
92 wxString welcomeText;
93
94 /** The 255x112 and 182x80 versions of the default mod image. */
95 wxBitmap modImage;
96 wxBitmap smallModImage;
97
98 wxBitmap okIcon;
99 wxBitmap warningIcon;
100 wxBitmap bigWarningIcon;
101 wxBitmap errorIcon;
102 wxBitmap infoIcon;
103 wxBitmap bigInfoIcon;
104 wxBitmap helpIcon;
105 wxBitmap bigHelpIcon;
106 wxBitmap idealIcon;
107
108 const NewsSource* newsSource;
109 };
110
111 /** Class used to manage the skinning of the launcher. The skinnable parts of
112 the app register with the skin system, so that when the skin changes, they can
113 be updated if needed. */
114 class SkinSystem {
115 public:
116 static bool Initialize();
117 static void DeInitialize();
118 static bool IsInitialized();
119 static SkinSystem* GetSkinSystem();
120
121 ~SkinSystem();
122
123 static void RegisterTCSkinChanged(wxEvtHandler *handler);
124 static void UnRegisterTCSkinChanged(wxEvtHandler *handler);
125
126 const wxString& GetWindowTitle() const;
127 const wxIcon& GetWindowIcon() const;
128 const wxBitmap& GetBanner() const;
129 const wxString& GetWelcomeText() const;
130
131 const wxBitmap& GetModImage() const;
132 const wxBitmap& GetSmallModImage() const;
133
134 const wxBitmap& GetOkIcon() const;
135 const wxBitmap& GetWarningIcon() const;
136 const wxBitmap& GetBigWarningIcon() const;
137 const wxBitmap& GetErrorIcon() const;
138 const wxBitmap& GetInfoIcon() const;
139 const wxBitmap& GetBigInfoIcon() const;
140 const wxBitmap& GetHelpIcon() const;
141 const wxBitmap& GetBigHelpIcon() const;
142 const wxBitmap& GetIdealIcon() const;
143
144 const NewsSource& GetNewsSource() const;
145
146 const wxFont& GetFont() const { return this->font; }
147 const wxFont& GetMessageFont() const { return this->messageFont; }
148
149 void SetTCSkin(const Skin* skin);
150 void ResetTCSkin();
151
152 static wxBitmap MakeModListImage(const wxBitmap &orig);
153 static wxBitmap MakeModInfoDialogImage(const wxBitmap &orig);
154
155 static bool SearchFile(wxFileName& filename, wxString currentTC,
156 wxString shortmodname, wxString filepath);
157
158 /** Dimensions for banner image on welcome page. */
159 static const int BannerMaxWidth = 630;
160 static const int BannerHeight = 150;
161
162 /** Dimensions for mod images, depending on where the image appears. */
163 static const int ModInfoDialogImageWidth = 255;
164 static const int ModInfoDialogImageHeight = 112;
165 static const int ModListImageWidth = 182;
166 static const int ModListImageHeight = 80;
167
168 static const int StatusBarIconWidth = 24;
169 static const int StatusBarIconHeight = 24;
170 static const int BigIconWidth = 64;
171 static const int BigIconHeight = 64;
172 static const int HelpIconWidth = 32;
173 static const int HelpIconHeight = 32;
174 static const int IdealIconWidth = 24;
175 static const int IdealIconHeight = 24;
176
177 private:
178 SkinSystem();
179 static SkinSystem* skinSystem;
180
181 static EventHandlers TCSkinChangedHandlers;
182
183 static void GenerateTCSkinChanged();
184
185 void InitializeDefaultSkin();
186
187 Skin defaultSkin;
188 const Skin* TCSkin;
189
190 wxFont font;
191 wxFont messageFont;
192 };
193
194 #endif