Menu

[r13158]: / trunk / src / sdk / cbcolourmanager.cpp  Maximize  Restore  History

Download this file

98 lines (85 with data), 2.8 kB

 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
/*
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
* http://www.gnu.org/licenses/lgpl-3.0.html
*
* $Revision$
* $Id$
* $HeadURL$
*/
#include "sdk_precomp.h"
#ifndef CB_PRECOMP
#include "configmanager.h"
#endif // CB_PRECOMP
#include "cbcolourmanager.h"
template<> ColourManager* Mgr<ColourManager>::instance = nullptr;
template<> bool Mgr<ColourManager>::isShutdown = false;
void ColourManager::Load()
{
ConfigManager *config = Manager::Get()->GetConfigManager(wxT("colours"));
const wxArrayString &colours = config->EnumerateKeys(wxT("list"));
for (size_t ii = 0; ii < colours.GetCount(); ++ii)
{
const wxString &id = colours[ii].Lower();
const wxColour &colour = config->ReadColour(wxT("list/") + id);
ColourDefMap::iterator it = m_colours.find(id);
if (it != m_colours.end())
it->second.value = colour;
else
{
ColourDef def;
def.value = def.defaultValue = colour;
m_colours[id] = def;
}
}
}
void ColourManager::Save()
{
ConfigManager *config = Manager::Get()->GetConfigManager(wxT("colours"));
for (ColourDefMap::const_iterator it = m_colours.begin(); it != m_colours.end(); ++it)
{
if (it->second.value != it->second.defaultValue)
config->Write(wxT("list/") + it->first, it->second.value);
else
config->UnSet(wxT("list/") + it->first);
}
}
void ColourManager::RegisterColour(const wxString &category, const wxString &name,
const wxString &id, const wxColour &defaultColour)
{
wxString lowerID = id.Lower();
ColourDefMap::iterator it = m_colours.find(lowerID);
if (it != m_colours.end())
{
it->second.name = name;
it->second.category = category;
it->second.defaultValue = defaultColour;
}
else
{
ColourDef def;
def.name = name;
def.category = category;
def.value = def.defaultValue = defaultColour;
m_colours[lowerID] = def;
}
}
wxColour ColourManager::GetColour(const wxString &id) const
{
ColourDefMap::const_iterator it = m_colours.find(id);
return it != m_colours.end() ? it->second.value : *wxBLACK;
}
wxColour ColourManager::GetDefaultColour(const wxString &id) const
{
ColourDefMap::const_iterator it = m_colours.find(id);
return it != m_colours.end() ? it->second.defaultValue : *wxBLACK;
}
void ColourManager::SetColour(const wxString &id, const wxColour &colour)
{
ColourDefMap::iterator it = m_colours.find(id);
if (it != m_colours.end())
it->second.value = colour;
}
const ColourManager::ColourDefMap& ColourManager::GetColourDefinitions() const
{
return m_colours;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.