1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2008 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC 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.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef BOINC_SKINMANAGER_H
19 #define BOINC_SKINMANAGER_H
20 
21 #if defined(__GNUG__) && !defined(__APPLE__)
22 #pragma interface "SkinManager.cpp"
23 #endif
24 
25 #include "miofile.h"
26 
27 enum {
28     BKGD_ANCHOR_HORIZ_LEFT,
29     BKGD_ANCHOR_HORIZ_CENTER,
30     BKGD_ANCHOR_HORIZ_RIGHT
31 };
32 
33 enum {
34     BKGD_ANCHOR_VERT_TOP,
35     BKGD_ANCHOR_VERT_CENTER,
36     BKGD_ANCHOR_VERT_BOTTOM
37 };
38 
39 class CSkinItem : public wxObject
40 {
41     DECLARE_DYNAMIC_CLASS( CSkinItem )
42 
43 public:
44     CSkinItem();
45     ~CSkinItem();
46 
47     static wxColour ParseColor(wxString strColor);
48 };
49 
50 
51 class CSkinImage : public CSkinItem
52 {
53     DECLARE_DYNAMIC_CLASS( CSkinImage )
54 
55 public:
56     CSkinImage();
57     ~CSkinImage();
58 
59     void Clear();
60     int  Parse(MIOFILE& in);
61 
62     wxBitmap* GetBitmap();
63     wxColour* GetBackgroundColor();
GetHorizontalAnchor()64     int  GetHorizontalAnchor() { return m_iAnchorHorizontal; }
GetVerticalAnchor()65     int  GetVerticalAnchor() { return m_iAnchorVertical; }
66 
67     bool SetDefaults(
68         wxString strComponentName,
69         const char** ppDefaultImage
70     );
71 
72     bool SetDefaults(
73         wxString strComponentName,
74         const char** ppDefaultImage,
75         wxString strBackgroundColor,
76         int horizontalAnchor = BKGD_ANCHOR_HORIZ_LEFT,
77         int verticalAnchor = BKGD_ANCHOR_VERT_TOP
78     );
79 
80     bool Validate();
81 
82 private:
83     wxString     m_strComponentName;
84     wxString     m_strDesiredBitmap;
85     wxString     m_strDesiredBackgroundColor;
86     const char** m_ppDefaultBitmap;
87     wxString     m_strDefaultBackgroundColor;
88     wxBitmap     m_bmpBitmap;
89     wxColour     m_colBackgroundColor;
90     // Anchors are used only by m_BackgroundImage and m_DialogBackgroundImage
91     int          m_iAnchorHorizontal;
92     int          m_iAnchorVertical;
93 };
94 
95 
96 class CSkinIcon : public CSkinItem
97 {
98     DECLARE_DYNAMIC_CLASS( CSkinIcon )
99 
100 public:
101     CSkinIcon();
102     ~CSkinIcon();
103 
104     void Clear();
105     int  Parse(MIOFILE& in);
106     int  Parse32(MIOFILE& in);
107 
108     wxIconBundle* GetIcon();
109 
110     bool SetDefaults(
111         wxString strComponentName,
112         wxString strIcon
113     );
114 
115     bool SetDefaults(
116         wxString strComponentName,
117         const char** m_ppIcon,
118         const char** m_ppIcon32
119     );
120 
121     bool Validate();
122 
123 private:
124     wxString     m_strComponentName;
125     wxString     m_strDesiredIcon;
126     wxString     m_strDesiredTransparencyMask;
127     wxIconBundle m_icoDefaultIcon;
128     wxString     m_strDesiredIcon32;
129     wxString     m_strDesiredTransparencyMask32;
130     wxIconBundle m_icoDefaultIcon32;
131     wxIconBundle m_icoIcon;
132 };
133 
134 
135 // Default opacity for Simple View white panels
136 // is 60% (153 on a scale of 0 - 255).
137 #define MAX_OPACITY 255
138 #define DEFAULT_OPACITY 153
139 
140 class CSkinSimple : public CSkinItem
141 {
142     DECLARE_DYNAMIC_CLASS( CSkinSimple )
143 
144 public:
145     CSkinSimple();
146     ~CSkinSimple();
147 
148     void Clear();
149     int  Parse(MIOFILE& in);
150 
151     bool InitializeDelayedValidation();
152 
GetBackgroundImage()153     CSkinImage*         GetBackgroundImage() { return &m_BackgroundImage; }
GetDialogBackgroundImage()154     CSkinImage*         GetDialogBackgroundImage() { return &m_DialogBackgroundImage; }
GetProjectImage()155     CSkinImage*         GetProjectImage() { return &m_ProjectImage; }
GetStaticLineColor()156     wxColour            GetStaticLineColor() { return m_StaticLineColor; }
GetNoticeAlertColor()157     wxColour            GetNoticeAlertColor() { return m_NoticeAlertColor; }
GetWorkunitAnimationImage()158     CSkinImage*         GetWorkunitAnimationImage() { return &m_WorkunitAnimationImage; }
GetWorkunitRunningImage()159     CSkinImage*         GetWorkunitRunningImage() { return &m_WorkunitRunningImage; }
GetWorkunitSuspendedImage()160     CSkinImage*         GetWorkunitSuspendedImage() { return &m_WorkunitSuspendedImage; }
GetWorkunitWaitingImage()161     CSkinImage*         GetWorkunitWaitingImage() { return &m_WorkunitWaitingImage; }
GetPanelOpacity()162     int                 GetPanelOpacity() { return m_iPanelOpacity; }
163 
164 private:
165 	CSkinImage          m_BackgroundImage;
166     CSkinImage          m_DialogBackgroundImage;
167     CSkinImage          m_ProjectImage;
168 	wxColour            m_StaticLineColor;
169 	wxColour            m_NoticeAlertColor;
170     CSkinImage          m_WorkunitAnimationImage;
171     CSkinImage          m_WorkunitRunningImage;
172     CSkinImage          m_WorkunitSuspendedImage;
173     CSkinImage          m_WorkunitWaitingImage;
174     int                 m_iPanelOpacity;
175 };
176 
177 
178 class CSkinAdvanced : public CSkinItem
179 {
180     DECLARE_DYNAMIC_CLASS( CSkinAdvanced )
181 
182 public:
183     CSkinAdvanced();
184     ~CSkinAdvanced();
185 
186     void Clear();
187     int  Parse(MIOFILE& in);
188 
189     bool InitializeDelayedValidation();
190 
191     wxString      GetApplicationName();
192     wxString      GetApplicationShortName();
193     wxIconBundle* GetApplicationIcon();
194     wxIconBundle* GetApplicationDisconnectedIcon();
195     wxIconBundle* GetApplicationSnoozeIcon();
196     wxBitmap*     GetApplicationLogo();
197     wxString      GetOrganizationName();
198     wxString      GetOrganizationWebsite();
199     wxString      GetOrganizationHelpUrl();
200     int           GetDefaultTab();
201     wxString      GetExitMessage();
202     bool          IsBranded();
203 
204 private:
205     bool          m_bIsBranded;
206     wxString      m_strApplicationName;
207     wxString      m_strApplicationShortName;
208     CSkinIcon     m_iconApplicationIcon;
209     CSkinIcon     m_iconApplicationIcon32;
210     CSkinIcon     m_iconApplicationDisconnectedIcon;
211     CSkinIcon     m_iconApplicationSnoozeIcon;
212     wxBitmap      m_bitmapApplicationLogo;
213     wxString      m_strOrganizationName;
214     wxString      m_strOrganizationWebsite;
215     wxString      m_strOrganizationHelpUrl;
216     bool          m_bDefaultTabSpecified;
217     int           m_iDefaultTab;
218     wxString      m_strExitMessage;
219 };
220 
221 
222 class CSkinWizardATP : public CSkinItem
223 {
224     DECLARE_DYNAMIC_CLASS( CSkinWizardATP )
225 
226 public:
227     CSkinWizardATP();
228     ~CSkinWizardATP();
229 
230     void Clear();
231     int  Parse(MIOFILE& in);
232 
233     bool InitializeDelayedValidation();
234 
GetWizardTitle()235     wxString    GetWizardTitle() { return m_strTitle; }
236 
237 private:
238     wxString    m_strTitle;
239 };
240 
241 
242 class CSkinWizardATAM : public CSkinItem
243 {
244     DECLARE_DYNAMIC_CLASS( CSkinWizardATAM )
245 
246 public:
247     CSkinWizardATAM();
248     ~CSkinWizardATAM();
249 
250     void Clear();
251     int  Parse(MIOFILE& in);
252 
253     bool InitializeDelayedValidation();
254 
GetAccountInfoMessage()255     wxString    GetAccountInfoMessage() { return m_strAccountInfoMessage; }
256 
257 private:
258     wxString    m_strAccountInfoMessage;
259 };
260 
261 
262 class CSkinWizards : public CSkinItem
263 {
264     DECLARE_DYNAMIC_CLASS( CSkinWizards )
265 
266 public:
267     CSkinWizards();
268     ~CSkinWizards();
269 
270     void Clear();
271     int  Parse(MIOFILE& in);
272 
273     bool InitializeDelayedValidation();
274 
GetWizardATP()275     CSkinWizardATP*     GetWizardATP() { return &m_AttachToProjectWizard; }
GetWizardATAM()276     CSkinWizardATAM*    GetWizardATAM() { return &m_AttachToAccountManagerWizard; }
277 
278 private:
279     CSkinWizardATP      m_AttachToProjectWizard;
280     CSkinWizardATAM     m_AttachToAccountManagerWizard;
281 };
282 
283 
284 class CSkinManager : public CSkinItem
285 {
286     DECLARE_DYNAMIC_CLASS( CSkinManager )
287 
288 public:
289     CSkinManager();
290     CSkinManager(bool debugSkins);
291     ~CSkinManager();
292 
293     bool                ReloadSkin(wxString strSkin);
294 
295     wxArrayString&      GetCurrentSkins();
296     wxString            GetDefaultSkinName();
GetSelectedSkin()297     wxString            GetSelectedSkin() { return m_strSelectedSkin; }
298 
299     wxString            ConstructSkinFileName();
300     wxString            ConstructSkinPath();
301     wxString            GetSkinFileName();
302     wxString            GetSkinsLocation();
303 
GetSimple()304     CSkinSimple*        GetSimple() { return &m_SimpleSkin; }
GetAdvanced()305     CSkinAdvanced*      GetAdvanced() { return &m_AdvancedSkin; }
GetWizards()306     CSkinWizards*       GetWizards() { return &m_WizardsSkin; }
307 
308 private:
309     CSkinSimple         m_SimpleSkin;
310     CSkinAdvanced       m_AdvancedSkin;
311     CSkinWizards        m_WizardsSkin;
312 
313     wxArrayString       m_astrSkins;
314     wxString            m_strSelectedSkin;
315 
316     void Clear();
317     int  Parse(MIOFILE& in, wxString strDesiredLocale);
318 
319     bool InitializeDelayedValidation();
320 };
321 
322 #endif
323