// $Id$
#include "stdafx.h"
+#include <vector>
+#include "UnicodeString.h"
#include "SyntaxColors.h"
#include "OptionsDef.h"
#include "OptionsMgr.h"
+using namespace std;
+
/** @brief Setting name for default colors. */
static const TCHAR DefColorsPath[] =_T("DefaultSyntaxColors");
/** @brief Setting name for user-defined custom colors. */
SyntaxColors::SyntaxColors()
: m_pOptionsMgr(NULL)
{
- m_colors.SetSize(COLORINDEX_COUNT);
- m_bolds.SetSize(COLORINDEX_COUNT);
+ m_colors.reserve(COLORINDEX_COUNT);
+ m_bolds.reserve(COLORINDEX_COUNT);
SetDefaults();
}
SyntaxColors::SyntaxColors(const SyntaxColors *pColors)
: m_pOptionsMgr(NULL)
{
- m_colors.SetSize(COLORINDEX_COUNT);
- m_bolds.SetSize(COLORINDEX_COUNT);
- m_colors.Copy(pColors->m_colors);
- m_bolds.Copy(pColors->m_bolds);
+ m_colors.reserve(COLORINDEX_COUNT);
+ m_bolds.reserve(COLORINDEX_COUNT);
+ m_colors = pColors->m_colors;
+ m_bolds = pColors->m_bolds;
}
/**
*/
void SyntaxColors::Clone(const SyntaxColors *pColors)
{
- m_colors.SetSize(COLORINDEX_COUNT);
- m_bolds.SetSize(COLORINDEX_COUNT);
- m_colors.Copy(pColors->m_colors);
- m_bolds.Copy(pColors->m_bolds);
+ m_colors.reserve(COLORINDEX_COUNT);
+ m_bolds.reserve(COLORINDEX_COUNT);
+ m_colors = pColors->m_colors;
+ m_bolds = pColors->m_bolds;
}
/**
color = RGB (128, 0, 0);
break;
}
- m_colors.SetAt(i, color);
+ m_colors[i] = color;
BOOL bBold = FALSE;
if (i == COLORINDEX_KEYWORD)
bBold = TRUE;
- m_bolds.SetAt(i, (int)bBold);
+ m_bolds[i] = bBold;
}
}
*/
void SyntaxColors::SetColor(UINT index, COLORREF color)
{
- m_colors.SetAt(index, color);
+ m_colors[index] = color;
}
/**
*/
void SyntaxColors::SetBold(UINT index, BOOL bold)
{
- m_bolds.SetAt(index, bold);
+ m_bolds[index] = bold;
}
/**
void SyntaxColors::Initialize(COptionsMgr *pOptionsMgr)
{
ASSERT(pOptionsMgr);
- CString valuename(DefColorsPath);
+ String valuename(DefColorsPath);
m_pOptionsMgr = pOptionsMgr;
int count = COLORINDEX_COUNT;
valuename += _T("/Values");
- m_pOptionsMgr->InitOption(valuename, count);
+ m_pOptionsMgr->InitOption(valuename.c_str(), count);
for (unsigned int i = COLORINDEX_NONE; i < COLORINDEX_LAST; i++)
{
// from storage we must set that value to array we use.
int color = 0;
COLORREF ref;
- valuename.Format(_T("%s/Color%02u"), DefColorsPath, i);
- color = m_colors.GetAt(i);
+ valuename.reserve(30);
+ _sntprintf(&*valuename.begin(), 30, _T("%s/Color%02u"),
+ DefColorsPath, i);
+ color = m_colors[i];
// Special handling for themable colors
// These are text colors which by default follow the current system colors
if (m_pOptionsMgr->GetBool(OPT_CLR_DEFAULT_TEXT_COLORING))
serializable = false;
}
- m_pOptionsMgr->InitOption(valuename, color, serializable);
- color = m_pOptionsMgr->GetInt(valuename);
+ m_pOptionsMgr->InitOption(valuename.c_str(), color, serializable);
+ color = m_pOptionsMgr->GetInt(valuename.c_str());
ref = color;
- m_colors.SetAt(i, ref);
+ m_colors[i] = ref;
int nBold = 0;
BOOL bBold = FALSE;
- valuename.Format(_T("%s/Bold%02u"), DefColorsPath, i);
- bBold = m_bolds.GetAt(i);
- m_pOptionsMgr->InitOption(valuename, (int) bBold);
- nBold = m_pOptionsMgr->GetInt(valuename);
+ valuename.reserve(30);
+ _sntprintf(&*valuename.begin(), 30, _T("%s/Bold%02u"),
+ DefColorsPath, i);
+ bBold = m_bolds[i];
+ m_pOptionsMgr->InitOption(valuename.c_str(), (int) bBold);
+ nBold = m_pOptionsMgr->GetInt(valuename.c_str());
bBold = nBold ? TRUE : FALSE;
- m_bolds.SetAt(i, bBold);
+ m_bolds[i] = bBold;
}
-
}
/**
void SyntaxColors::SaveToRegistry()
{
ASSERT(m_pOptionsMgr);
- CString valuename(DefColorsPath);
+ String valuename(DefColorsPath);
int count = COLORINDEX_COUNT;
valuename += _T("/Values");
- m_pOptionsMgr->SetInt(valuename, count);
+ m_pOptionsMgr->SetInt(valuename.c_str(), count);
for (unsigned int i = COLORINDEX_NONE; i < COLORINDEX_LAST; i++)
{
- valuename.Format(_T("%s/Color%02u"), DefColorsPath, i);
- int color = m_colors.GetAt(i);
- m_pOptionsMgr->SetInt(valuename, color);
- valuename.Format(_T("%s/Bold%02u"), DefColorsPath, i);
- BOOL bold = m_bolds.GetAt(i);
- m_pOptionsMgr->SetInt(valuename, bold);
+ valuename.reserve(30);
+ _sntprintf(&*valuename.begin(), 30, _T("%s/Color%02u"),
+ DefColorsPath, i);
+ int color = m_colors[i];
+ m_pOptionsMgr->SetInt(valuename.c_str(), color);
+ valuename.reserve(30);
+ _sntprintf(&*valuename.begin(), 30, _T("%s/Bold%02u"),
+ DefColorsPath, i);
+ BOOL bold = m_bolds[i];
+ m_pOptionsMgr->SetInt(valuename.c_str(), bold);
}
}