2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2006-10-18 09:02:36 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2006-10-18 09:02:36 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2006-10-18 09:02:36 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2006-10-18 09:02:36 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2006-10-18 09:02:36 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "SkinManager.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "miofile.h"
|
2006-10-25 14:09:47 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "BOINCBaseFrame.h"
|
2006-10-18 09:02:36 +00:00
|
|
|
#include "SkinManager.h"
|
2008-04-17 16:18:16 +00:00
|
|
|
#include "version.h"
|
2006-10-18 09:02:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
#include "res/skins/default/graphic/background_image.xpm"
|
|
|
|
#include "res/skins/default/graphic/workunit_animation_image.xpm"
|
|
|
|
#include "res/skins/default/graphic/project_image.xpm"
|
2006-11-14 10:12:24 +00:00
|
|
|
#include "res/skins/default/graphic/dialog_background_image.xpm"
|
2006-10-18 09:02:36 +00:00
|
|
|
#include "res/boinc.xpm"
|
2008-06-23 17:54:44 +00:00
|
|
|
#include "res/boinc32.xpm"
|
2006-10-18 09:02:36 +00:00
|
|
|
#include "res/boincdisconnect.xpm"
|
|
|
|
#include "res/boincsnooze.xpm"
|
2006-10-20 15:00:14 +00:00
|
|
|
#include "res/boinc_logo.xpm"
|
2006-10-18 09:02:36 +00:00
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
|
2009-01-30 09:25:35 +00:00
|
|
|
// Flag to enable the various error messages
|
|
|
|
static bool show_error_msgs = false;
|
2007-08-02 20:03:21 +00:00
|
|
|
|
|
|
|
|
2006-10-18 09:02:36 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinItem, wxObject)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinItem::CSkinItem() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinItem::~CSkinItem() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxColour CSkinItem::ParseColor(wxString strColor) {
|
2008-05-16 16:45:54 +00:00
|
|
|
long red, green, blue;
|
2006-10-18 09:02:36 +00:00
|
|
|
wxStringTokenizer tkz(strColor, wxT(":"), wxTOKEN_RET_EMPTY);
|
2008-05-16 16:45:54 +00:00
|
|
|
wxString(tkz.GetNextToken()).ToLong(&red);
|
|
|
|
wxString(tkz.GetNextToken()).ToLong(&green);
|
|
|
|
wxString(tkz.GetNextToken()).ToLong(&blue);
|
2006-10-23 06:48:48 +00:00
|
|
|
return wxColour((unsigned char)red, (unsigned char)green, (unsigned char)blue);
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinImage, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinImage::CSkinImage() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinImage::~CSkinImage() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinImage::Clear() {
|
2006-10-29 11:30:33 +00:00
|
|
|
m_strDesiredBitmap.Clear();
|
|
|
|
m_strDesiredBackgroundColor.Clear();
|
2006-10-18 09:02:36 +00:00
|
|
|
m_bmpBitmap = wxNullBitmap;
|
|
|
|
m_colBackgroundColor = wxNullColour;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinImage::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</image>")) break;
|
|
|
|
else if (parse_str(buf, "<imagesrc>", strBuffer)) {
|
2006-10-25 14:09:47 +00:00
|
|
|
if (strBuffer.length()) {
|
2006-10-29 09:30:29 +00:00
|
|
|
m_strDesiredBitmap = wxString(
|
2006-10-25 14:09:47 +00:00
|
|
|
wxGetApp().GetSkinManager()->ConstructSkinPath() +
|
|
|
|
wxString(strBuffer.c_str(), wxConvUTF8)
|
|
|
|
);
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<background_color>", strBuffer)) {
|
2006-10-29 09:30:29 +00:00
|
|
|
if (strBuffer.length()) {
|
|
|
|
m_strDesiredBackgroundColor = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return BOINC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxBitmap* CSkinImage::GetBitmap() {
|
|
|
|
Validate();
|
|
|
|
return &m_bmpBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxColour* CSkinImage::GetBackgroundColor() {
|
|
|
|
Validate();
|
|
|
|
return &m_colBackgroundColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CSkinImage::SetDefaults(wxString strComponentName, const char** ppDefaultBitmap) {
|
|
|
|
m_strComponentName = strComponentName;
|
|
|
|
m_ppDefaultBitmap = ppDefaultBitmap;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CSkinImage::SetDefaults(wxString strComponentName, const char** ppDefaultBitmap, wxString strBackgroundColor) {
|
|
|
|
m_strComponentName = strComponentName;
|
|
|
|
m_ppDefaultBitmap = ppDefaultBitmap;
|
|
|
|
m_strDefaultBackgroundColor = strBackgroundColor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CSkinImage::Validate() {
|
|
|
|
if (!m_bmpBitmap.Ok()) {
|
2006-10-29 11:30:33 +00:00
|
|
|
if (!m_strDesiredBitmap.IsEmpty()) {
|
|
|
|
m_bmpBitmap = wxBitmap(wxImage(m_strDesiredBitmap, wxBITMAP_TYPE_ANY));
|
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
if (!m_bmpBitmap.Ok()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2010-09-06 16:12:59 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Failed to load '%s' image. Using default.\n", (const char *)m_strComponentName.mb_str());
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
m_bmpBitmap = wxBitmap(m_ppDefaultBitmap);
|
|
|
|
wxASSERT(m_bmpBitmap.Ok());
|
|
|
|
}
|
|
|
|
}
|
2006-10-29 11:30:33 +00:00
|
|
|
if (!m_colBackgroundColor.Ok()) {
|
|
|
|
if (!m_strDesiredBackgroundColor.IsEmpty()) {
|
|
|
|
m_colBackgroundColor = ParseColor(m_strDesiredBackgroundColor);
|
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
if (!m_colBackgroundColor.Ok()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2010-09-06 16:12:59 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Failed to load '%s' background color. Using default.\n", (const char *)m_strComponentName.mb_str());
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
m_colBackgroundColor = ParseColor(m_strDefaultBackgroundColor);
|
|
|
|
wxASSERT(m_colBackgroundColor.Ok());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinIcon, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinIcon::CSkinIcon() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinIcon::~CSkinIcon() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinIcon::Clear() {
|
2006-10-29 11:30:33 +00:00
|
|
|
m_strDesiredIcon.Clear();
|
|
|
|
m_strDesiredTransparencyMask.Clear();
|
2006-10-29 09:30:29 +00:00
|
|
|
m_icoIcon = wxNullIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinIcon::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</image>")) break;
|
|
|
|
else if (parse_str(buf, "<imagesrc>", strBuffer)) {
|
|
|
|
if (strBuffer.length()) {
|
|
|
|
m_strDesiredIcon = wxString(
|
|
|
|
wxGetApp().GetSkinManager()->ConstructSkinPath() +
|
|
|
|
wxString(strBuffer.c_str(), wxConvUTF8)
|
|
|
|
);
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<transparency_mask>", strBuffer)) {
|
2006-10-29 09:30:29 +00:00
|
|
|
if (strBuffer.length()) {
|
|
|
|
m_strDesiredTransparencyMask = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return BOINC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-10-18 09:02:36 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
wxIcon* CSkinIcon::GetIcon() {
|
|
|
|
Validate();
|
|
|
|
return &m_icoIcon;
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinIcon::SetDefaults(wxString strComponentName, const char** ppDefaultIcon) {
|
|
|
|
m_strComponentName = strComponentName;
|
|
|
|
m_ppDefaultIcon = ppDefaultIcon;
|
2006-10-18 09:02:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinIcon::Validate() {
|
|
|
|
if (!m_icoIcon.Ok()) {
|
2006-10-29 11:30:33 +00:00
|
|
|
if (!m_strDesiredIcon.IsEmpty()) {
|
|
|
|
// Configure bitmap object with optional transparency mask
|
|
|
|
wxBitmap bmp = wxBitmap(wxImage(m_strDesiredIcon, wxBITMAP_TYPE_ANY));
|
|
|
|
if (!m_strDesiredTransparencyMask.IsEmpty()) {
|
|
|
|
bmp.SetMask(new wxMask(bmp, ParseColor(m_strDesiredTransparencyMask)));
|
|
|
|
}
|
|
|
|
// Now set the icon object using the newly created bitmap with optional transparency mask
|
|
|
|
m_icoIcon.CopyFromBitmap(bmp);
|
2006-10-29 09:30:29 +00:00
|
|
|
}
|
|
|
|
if (!m_icoIcon.Ok()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2010-09-06 16:12:59 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Failed to load '%s' icon. Using default.\n", (const char *)m_strComponentName.mb_str());
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
m_icoIcon = wxIcon(m_ppDefaultIcon);
|
|
|
|
wxASSERT(m_icoIcon.Ok());
|
|
|
|
}
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinSimple, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinSimple::CSkinSimple() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinSimple::~CSkinSimple() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinSimple::Clear() {
|
|
|
|
m_BackgroundImage.Clear();
|
|
|
|
m_StaticLineColor = wxNullColour;
|
|
|
|
|
|
|
|
m_WorkunitAnimationImage.Clear();
|
|
|
|
m_ProjectImage.Clear();
|
2006-11-14 10:12:24 +00:00
|
|
|
m_DialogBackgroundImage.Clear();
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinSimple::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</simple>")) break;
|
|
|
|
else if (match_tag(buf, "<background_image>")) {
|
|
|
|
m_BackgroundImage.Parse(in);
|
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<static_line_color>", strBuffer)) {
|
|
|
|
m_StaticLineColor = ParseColor(wxString(strBuffer.c_str(), wxConvUTF8));
|
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<workunit_animation_image>")) {
|
|
|
|
m_WorkunitAnimationImage.Parse(in);
|
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<project_image>")) {
|
|
|
|
m_ProjectImage.Parse(in);
|
|
|
|
continue;
|
2006-11-14 10:12:24 +00:00
|
|
|
} else if (match_tag(buf, "<dialog_background_image>")) {
|
|
|
|
m_DialogBackgroundImage.Parse(in);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-18 09:02:36 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinSimple::InitializeDelayedValidation() {
|
|
|
|
m_BackgroundImage.SetDefaults(
|
2011-01-12 21:18:50 +00:00
|
|
|
wxT("background"), (const char**)background_image_xpm, wxT("0:0:0")
|
2006-10-29 09:30:29 +00:00
|
|
|
);
|
2011-03-10 10:25:54 +00:00
|
|
|
m_WorkunitAnimationImage.SetDefaults(
|
2006-10-29 09:30:29 +00:00
|
|
|
wxT("workunit animation"), (const char**)workunit_animation_image_xpm
|
|
|
|
);
|
|
|
|
m_ProjectImage.SetDefaults(
|
|
|
|
wxT("project"), (const char**)project_image_xpm
|
|
|
|
);
|
2006-11-14 10:12:24 +00:00
|
|
|
m_DialogBackgroundImage.SetDefaults(
|
|
|
|
wxT("dialog background"), (const char**)dialog_background_image_xpm
|
2006-10-29 09:30:29 +00:00
|
|
|
);
|
2006-10-18 09:02:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinAdvanced, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinAdvanced::CSkinAdvanced() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinAdvanced::~CSkinAdvanced() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinAdvanced::Clear() {
|
2006-10-20 15:00:14 +00:00
|
|
|
m_bIsBranded = false;
|
2006-10-18 09:02:36 +00:00
|
|
|
m_strApplicationName = wxEmptyString;
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strApplicationShortName = wxEmptyString;
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationIcon.Clear();
|
2008-06-23 17:54:44 +00:00
|
|
|
m_iconApplicationIcon32.Clear();
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationDisconnectedIcon.Clear();
|
|
|
|
m_iconApplicationSnoozeIcon.Clear();
|
2006-10-18 09:02:36 +00:00
|
|
|
m_bitmapApplicationLogo = wxNullBitmap;
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationName = wxEmptyString;
|
|
|
|
m_strOrganizationWebsite = wxEmptyString;
|
|
|
|
m_strOrganizationHelpUrl = wxEmptyString;
|
2006-10-18 09:02:36 +00:00
|
|
|
m_bDefaultTabSpecified = false;
|
|
|
|
m_iDefaultTab = 0;
|
|
|
|
m_strExitMessage = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinAdvanced::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</advanced>")) break;
|
2006-10-20 15:00:14 +00:00
|
|
|
else if (parse_bool(buf, "is_branded", m_bIsBranded)) continue;
|
2006-10-18 09:02:36 +00:00
|
|
|
else if (parse_str(buf, "<application_name>", strBuffer)) {
|
|
|
|
m_strApplicationName = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
continue;
|
2007-08-16 18:53:42 +00:00
|
|
|
} else if (parse_str(buf, "<application_short_name>", strBuffer)) {
|
|
|
|
m_strApplicationShortName = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
continue;
|
2006-10-18 09:02:36 +00:00
|
|
|
} else if (match_tag(buf, "<application_icon>")) {
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationIcon.Parse(in);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
2008-06-23 17:54:44 +00:00
|
|
|
} else if (match_tag(buf, "<application_icon32>")) {
|
|
|
|
m_iconApplicationIcon32.Parse(in);
|
|
|
|
continue;
|
2006-10-18 09:02:36 +00:00
|
|
|
} else if (match_tag(buf, "<application_disconnected_icon>")) {
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationDisconnectedIcon.Parse(in);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<application_snooze_icon>")) {
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationSnoozeIcon.Parse(in);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<application_logo>", strBuffer)) {
|
2006-10-25 14:09:47 +00:00
|
|
|
if(strBuffer.length()) {
|
|
|
|
wxString str = wxString(
|
|
|
|
wxGetApp().GetSkinManager()->ConstructSkinPath() +
|
|
|
|
wxString(strBuffer.c_str(), wxConvUTF8)
|
|
|
|
);
|
|
|
|
m_bitmapApplicationLogo = wxBitmap(wxImage(str.c_str(), wxBITMAP_TYPE_ANY));
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
2008-10-23 04:10:12 +00:00
|
|
|
} else if (parse_str(buf, "<organization_name>", strBuffer)) {
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationName = wxString(strBuffer.c_str(), wxConvUTF8);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
2008-10-23 04:10:12 +00:00
|
|
|
} else if (parse_str(buf, "<organization_website>", strBuffer)) {
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationWebsite = wxString(strBuffer.c_str(), wxConvUTF8);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
2008-10-23 04:10:12 +00:00
|
|
|
} else if (parse_str(buf, "<organization_help_url>", strBuffer)) {
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationHelpUrl = wxString(strBuffer.c_str(), wxConvUTF8);
|
2006-10-18 09:02:36 +00:00
|
|
|
continue;
|
|
|
|
} else if (parse_int(buf, "<open_tab>", m_iDefaultTab)) {
|
|
|
|
m_bDefaultTabSpecified = true;
|
|
|
|
continue;
|
|
|
|
} else if (parse_str(buf, "<exit_message>", strBuffer)) {
|
|
|
|
m_strExitMessage = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-18 09:02:36 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinAdvanced::GetApplicationName() {
|
2008-04-17 16:18:16 +00:00
|
|
|
wxString strApplicationName = m_strApplicationName;
|
|
|
|
#ifdef BOINC_PRERELEASE
|
|
|
|
strApplicationName += wxT(" (Pre-release)");
|
|
|
|
#endif
|
|
|
|
return strApplicationName;
|
2006-10-29 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 18:53:42 +00:00
|
|
|
wxString CSkinAdvanced::GetApplicationShortName() {
|
|
|
|
return m_strApplicationShortName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
wxIcon* CSkinAdvanced::GetApplicationIcon() {
|
|
|
|
return m_iconApplicationIcon.GetIcon();
|
|
|
|
}
|
|
|
|
|
2008-06-23 17:54:44 +00:00
|
|
|
wxIcon* CSkinAdvanced::GetApplicationIcon32() {
|
|
|
|
return m_iconApplicationIcon32.GetIcon();
|
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
|
|
|
|
wxIcon* CSkinAdvanced::GetApplicationDisconnectedIcon() {
|
|
|
|
return m_iconApplicationDisconnectedIcon.GetIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxIcon* CSkinAdvanced::GetApplicationSnoozeIcon() {
|
|
|
|
return m_iconApplicationSnoozeIcon.GetIcon();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxBitmap* CSkinAdvanced::GetApplicationLogo() {
|
|
|
|
return &m_bitmapApplicationLogo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 18:53:42 +00:00
|
|
|
wxString CSkinAdvanced::GetOrganizationName() {
|
|
|
|
return m_strOrganizationName;
|
2006-10-29 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 18:53:42 +00:00
|
|
|
wxString CSkinAdvanced::GetOrganizationWebsite() {
|
|
|
|
return m_strOrganizationWebsite;
|
2006-10-29 09:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 18:53:42 +00:00
|
|
|
wxString CSkinAdvanced::GetOrganizationHelpUrl() {
|
|
|
|
return m_strOrganizationHelpUrl;
|
2006-10-29 09:30:29 +00:00
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
|
|
|
|
int CSkinAdvanced::GetDefaultTab() {
|
|
|
|
return m_iDefaultTab;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinAdvanced::GetExitMessage() {
|
|
|
|
return m_strExitMessage;
|
|
|
|
}
|
2006-11-03 22:29:19 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
|
|
|
|
bool CSkinAdvanced::IsBranded() {
|
|
|
|
return m_bIsBranded;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CSkinAdvanced::InitializeDelayedValidation() {
|
2006-10-18 09:02:36 +00:00
|
|
|
if (m_strApplicationName.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-02 20:03:21 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Application name was not defined. Using default.\n");
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
m_strApplicationName = wxT("BOINC Manager");
|
|
|
|
wxASSERT(!m_strApplicationName.IsEmpty());
|
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
if (m_strApplicationShortName.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-16 18:53:42 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Application short name was not defined. Using default.\n");
|
|
|
|
}
|
|
|
|
m_strApplicationShortName = wxT("BOINC");
|
|
|
|
wxASSERT(!m_strApplicationShortName.IsEmpty());
|
|
|
|
}
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationIcon.SetDefaults(wxT("application"), (const char**)boinc_xpm);
|
2008-06-23 17:54:44 +00:00
|
|
|
m_iconApplicationIcon32.SetDefaults(wxT("application"), (const char**)boinc32_xpm);
|
2006-10-29 09:30:29 +00:00
|
|
|
m_iconApplicationDisconnectedIcon.SetDefaults(wxT("application disconnected"), (const char**)boincdisconnect_xpm);
|
|
|
|
m_iconApplicationSnoozeIcon.SetDefaults(wxT("application snooze"), (const char**)boincsnooze_xpm);
|
2006-10-18 09:02:36 +00:00
|
|
|
if (!m_bitmapApplicationLogo.Ok()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-02 20:03:21 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Failed to load application logo. Using default.\n");
|
|
|
|
}
|
2006-10-20 15:00:14 +00:00
|
|
|
m_bitmapApplicationLogo = wxBitmap((const char**)boinc_logo_xpm);
|
2006-10-18 09:02:36 +00:00
|
|
|
wxASSERT(m_bitmapApplicationLogo.Ok());
|
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
if (m_strOrganizationName.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-16 18:53:42 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Organization name was not defined. Using default.\n");
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationName = wxT("Space Sciences Laboratory, U.C. Berkeley");
|
|
|
|
wxASSERT(!m_strOrganizationName.IsEmpty());
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
if (m_strOrganizationWebsite.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-16 18:53:42 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Organization web site was not defined. Using default.\n");
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationWebsite = wxT("http://boinc.berkeley.edu");
|
|
|
|
wxASSERT(!m_strOrganizationWebsite.IsEmpty());
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
if (m_strOrganizationHelpUrl.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-16 18:53:42 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Organization help url was not defined. Using default.\n");
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2007-08-16 18:53:42 +00:00
|
|
|
m_strOrganizationHelpUrl = wxT("http://boinc.berkeley.edu/manager_links.php");
|
|
|
|
wxASSERT(!m_strOrganizationHelpUrl.IsEmpty());
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
if (!m_bDefaultTabSpecified) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-02 20:03:21 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Default tab was not defined. Using default.\n");
|
|
|
|
}
|
2006-10-18 09:02:36 +00:00
|
|
|
m_bDefaultTabSpecified = true;
|
|
|
|
m_iDefaultTab = 0;
|
|
|
|
}
|
2006-10-20 15:00:14 +00:00
|
|
|
if (m_strExitMessage.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2007-08-02 20:03:21 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Exit message was not defined. Using default.\n");
|
|
|
|
}
|
2008-11-04 08:08:16 +00:00
|
|
|
m_strExitMessage = wxEmptyString;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinWizardATP, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizardATP::CSkinWizardATP() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizardATP::~CSkinWizardATP() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinWizardATP::Clear() {
|
|
|
|
m_strTitle = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinWizardATP::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</attach_to_project>")) break;
|
|
|
|
else if (parse_str(buf, "<title>", strBuffer)) {
|
|
|
|
m_strTitle = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinWizardATP::InitializeDelayedValidation() {
|
2006-10-20 15:00:14 +00:00
|
|
|
if (m_strTitle.IsEmpty()) {
|
2009-01-30 09:25:35 +00:00
|
|
|
if (show_error_msgs) {
|
2010-08-01 03:37:17 +00:00
|
|
|
fprintf(stderr, "Skin Manager: Add project wizard title was not defined. Using default.\n");
|
2007-08-02 20:03:21 +00:00
|
|
|
}
|
2006-10-20 15:00:14 +00:00
|
|
|
m_strTitle = wxT("BOINC Manager");
|
|
|
|
wxASSERT(!m_strTitle.IsEmpty());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinWizardATAM, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizardATAM::CSkinWizardATAM() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizardATAM::~CSkinWizardATAM() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinWizardATAM::Clear() {
|
|
|
|
m_strAccountInfoMessage = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinWizardATAM::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
std::string strBuffer;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</attach_to_account_manager>")) break;
|
2011-03-10 10:25:54 +00:00
|
|
|
else if (parse_str(buf, "<account_info_message>", strBuffer)) {
|
2006-10-20 15:00:14 +00:00
|
|
|
m_strAccountInfoMessage = wxString(strBuffer.c_str(), wxConvUTF8);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinWizardATAM::InitializeDelayedValidation() {
|
2006-10-20 15:00:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinWizards, CSkinItem)
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizards::CSkinWizards() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinWizards::~CSkinWizards() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinWizards::Clear() {
|
|
|
|
m_AttachToProjectWizard.Clear();
|
|
|
|
m_AttachToAccountManagerWizard.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinWizards::Parse(MIOFILE& in) {
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
|
|
|
if (match_tag(buf, "</wizards>")) break;
|
|
|
|
else if (match_tag(buf, "<attach_to_project>")) {
|
|
|
|
m_AttachToProjectWizard.Parse(in);
|
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<attach_to_account_manager>")) {
|
|
|
|
m_AttachToAccountManagerWizard.Parse(in);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinWizards::InitializeDelayedValidation() {
|
|
|
|
return m_AttachToProjectWizard.InitializeDelayedValidation() &&
|
|
|
|
m_AttachToAccountManagerWizard.InitializeDelayedValidation();
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(CSkinManager, CSkinItem)
|
|
|
|
|
|
|
|
|
2009-01-30 09:25:35 +00:00
|
|
|
CSkinManager::CSkinManager() {}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinManager::CSkinManager(bool debugSkins) {
|
|
|
|
show_error_msgs = debugSkins;
|
2006-10-20 15:00:14 +00:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CSkinManager::~CSkinManager() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
2011-03-10 10:25:54 +00:00
|
|
|
bool CSkinManager::ReloadSkin(wxString strSkin) {
|
|
|
|
int retval = ERR_XML_PARSE;
|
2006-10-25 23:17:47 +00:00
|
|
|
FILE* p;
|
|
|
|
MIOFILE mf;
|
|
|
|
|
2006-12-09 10:46:18 +00:00
|
|
|
// This fixes a (rare) crash bug
|
2007-08-02 20:03:21 +00:00
|
|
|
if (strSkin.IsEmpty()) {
|
|
|
|
strSkin = GetDefaultSkinName();
|
|
|
|
}
|
2006-12-09 10:46:18 +00:00
|
|
|
|
2006-10-27 23:34:24 +00:00
|
|
|
// Check to make sure that we are not trying to load the skin we
|
|
|
|
// are already using.
|
|
|
|
if (m_strSelectedSkin == strSkin) return true;
|
2006-10-25 23:17:47 +00:00
|
|
|
|
|
|
|
// Clear out all the old stuff
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
// Set the default skin back to Default
|
2006-10-25 14:09:47 +00:00
|
|
|
m_strSelectedSkin = strSkin;
|
|
|
|
|
|
|
|
// Check to see if the skin we want to change to is the default skin
|
2011-01-28 09:16:42 +00:00
|
|
|
if (GetDefaultSkinName() == m_strSelectedSkin || GetDefaultBOINCSkinName() == m_strSelectedSkin) {
|
|
|
|
m_strSelectedSkin = GetDefaultSkinName();
|
2006-10-25 14:09:47 +00:00
|
|
|
}
|
|
|
|
|
2011-03-10 10:25:54 +00:00
|
|
|
// TODO: Eliminate the <en> tags: localization is no longer in skin files.
|
2007-06-08 15:49:37 +00:00
|
|
|
p = fopen((const char*)ConstructSkinFileName().mb_str(wxConvUTF8), "r");
|
2006-10-25 14:09:47 +00:00
|
|
|
if (p) {
|
|
|
|
mf.init_file(p);
|
2011-03-10 10:25:54 +00:00
|
|
|
retval = Parse(mf, wxT("en"));
|
2006-10-25 14:09:47 +00:00
|
|
|
fclose(p);
|
|
|
|
}
|
|
|
|
|
2011-02-08 17:47:09 +00:00
|
|
|
if (retval && show_error_msgs) {
|
|
|
|
fprintf(stderr, "Skin Manager: Failed to load skin '%s'.\n", (const char *)ConstructSkinFileName().mb_str(wxConvUTF8));
|
2006-10-25 14:09:47 +00:00
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-25 14:09:47 +00:00
|
|
|
|
2006-10-30 03:41:32 +00:00
|
|
|
// Tell whichever UI elements that are loaded to reload the
|
|
|
|
// skinable resources they use.
|
|
|
|
wxGetApp().FireReloadSkin();
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxArrayString& CSkinManager::GetCurrentSkins() {
|
|
|
|
unsigned int i;
|
|
|
|
wxString strSkinLocation = wxString(GetSkinsLocation() + wxFileName::GetPathSeparator());
|
|
|
|
wxString strSkinFileName = wxString(wxFileName::GetPathSeparator() + GetSkinFileName());
|
|
|
|
|
|
|
|
// Initialize array
|
|
|
|
m_astrSkins.Clear();
|
|
|
|
|
|
|
|
// Go get all the valid skin directories.
|
|
|
|
wxDir::GetAllFiles(strSkinLocation, &m_astrSkins, wxString(wxT("*") + GetSkinFileName()));
|
|
|
|
|
|
|
|
// Trim out the path information for all the entries
|
|
|
|
for (i = 0; i < m_astrSkins.GetCount(); i++) {
|
|
|
|
m_astrSkins[i] =
|
|
|
|
m_astrSkins[i].Remove(0, strSkinLocation.Length());
|
|
|
|
m_astrSkins[i] =
|
|
|
|
m_astrSkins[i].Remove(m_astrSkins[i].Find(strSkinFileName.c_str()), strSkinFileName.Length());
|
|
|
|
|
|
|
|
// Special case: 'Default' to mean the embedded default skin.
|
|
|
|
// remove any duplicate entries
|
|
|
|
if (GetDefaultSkinName() == m_astrSkins[i]) {
|
|
|
|
m_astrSkins.RemoveAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert the 'Default' entry into the skins list.
|
|
|
|
m_astrSkins.Insert(GetDefaultSkinName(), 0);
|
|
|
|
|
|
|
|
// return the current list of skins
|
|
|
|
return m_astrSkins;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinManager::GetDefaultSkinName() {
|
|
|
|
return wxString(wxT("Default"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-28 19:23:57 +00:00
|
|
|
wxString CSkinManager::GetDefaultBOINCSkinName() {
|
|
|
|
return wxString(wxT("BOINC"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-25 14:09:47 +00:00
|
|
|
wxString CSkinManager::ConstructSkinFileName() {
|
|
|
|
return wxString(
|
|
|
|
GetSkinsLocation() +
|
|
|
|
wxString(wxFileName::GetPathSeparator()) +
|
|
|
|
m_strSelectedSkin +
|
|
|
|
wxString(wxFileName::GetPathSeparator()) +
|
|
|
|
GetSkinFileName()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinManager::ConstructSkinPath() {
|
|
|
|
return wxString(
|
|
|
|
GetSkinsLocation() +
|
|
|
|
wxString(wxFileName::GetPathSeparator()) +
|
|
|
|
m_strSelectedSkin +
|
|
|
|
wxString(wxFileName::GetPathSeparator())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinManager::GetSkinFileName() {
|
|
|
|
// Construct path to skins directory
|
|
|
|
return wxString(wxT("skin.xml"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString CSkinManager::GetSkinsLocation() {
|
|
|
|
// Construct path to skins directory
|
2007-11-30 18:52:41 +00:00
|
|
|
wxString strSkinLocation = wxEmptyString;
|
|
|
|
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
strSkinLocation = wxGetApp().GetRootDirectory();
|
|
|
|
strSkinLocation += wxFileName::GetPathSeparator();
|
|
|
|
strSkinLocation += wxT("skins");
|
|
|
|
#else
|
|
|
|
strSkinLocation = wxString(wxGetCwd() + wxString(wxFileName::GetPathSeparator()) + wxT("skins"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return strSkinLocation;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSkinManager::Clear() {
|
|
|
|
m_SimpleSkin.Clear();
|
|
|
|
m_AdvancedSkin.Clear();
|
|
|
|
m_WizardsSkin.Clear();
|
2006-10-25 14:09:47 +00:00
|
|
|
|
|
|
|
m_astrSkins.Clear();
|
|
|
|
m_strSelectedSkin.Clear();
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int CSkinManager::Parse(MIOFILE& in, wxString strDesiredLocale) {
|
|
|
|
char buf[256];
|
|
|
|
wxString strLocaleStartTag;
|
|
|
|
wxString strLocaleEndTag;
|
|
|
|
bool bLocaleFound = false;
|
|
|
|
|
|
|
|
// Construct the start and end tags for the locale we want.
|
2006-11-22 09:51:59 +00:00
|
|
|
strLocaleStartTag.Printf(wxT("<%s>"), strDesiredLocale.c_str());
|
|
|
|
strLocaleEndTag.Printf(wxT("</%s>"), strDesiredLocale.c_str());
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2011-03-10 10:25:54 +00:00
|
|
|
// TODO: Eliminate the <en> tags: localization is no longer in skin files.
|
2006-10-20 15:00:14 +00:00
|
|
|
// Look for the begining of the desired locale.
|
|
|
|
while (in.fgets(buf, 256)) {
|
2007-06-08 15:49:37 +00:00
|
|
|
if (match_tag(buf, (const char*)strLocaleStartTag.mb_str(wxConvUTF8))) {
|
2006-10-20 15:00:14 +00:00
|
|
|
bLocaleFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bLocaleFound) return ERR_XML_PARSE;
|
|
|
|
|
|
|
|
while (in.fgets(buf, 256)) {
|
2007-06-08 15:49:37 +00:00
|
|
|
if (match_tag(buf, (const char*)strLocaleStartTag.mb_str(wxConvUTF8))) break;
|
2006-10-20 15:00:14 +00:00
|
|
|
else if (match_tag(buf, "<simple>")) {
|
|
|
|
m_SimpleSkin.Parse(in);
|
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<advanced>")) {
|
|
|
|
m_AdvancedSkin.Parse(in);
|
|
|
|
continue;
|
|
|
|
} else if (match_tag(buf, "<wizards>")) {
|
|
|
|
m_WizardsSkin.Parse(in);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
InitializeDelayedValidation();
|
2006-10-20 15:00:14 +00:00
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
return 0;
|
2006-10-20 15:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 09:30:29 +00:00
|
|
|
bool CSkinManager::InitializeDelayedValidation() {
|
|
|
|
return m_SimpleSkin.InitializeDelayedValidation() &&
|
|
|
|
m_AdvancedSkin.InitializeDelayedValidation() &&
|
|
|
|
m_WizardsSkin.InitializeDelayedValidation();
|
2006-10-18 09:02:36 +00:00
|
|
|
}
|
|
|
|
|