📄 theme.cpp
字号:
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <DialControl> tag needs a Name attribute");
return kError_ParseError;
}
if (oAttrMap.find("NumFrames") == oAttrMap.end())
{
m_oLastError = string("the <DialControl> tag needs a NumFrames attribute");
return kError_ParseError;
}
if (oAttrMap.find("PixelsPerFrame") == oAttrMap.end())
{
m_oLastError = string("the <DialControl> tag needs a PixelsPerFrame attribute");
return kError_ParseError;
}
m_eCurrentControl = eDialControl;
m_pCurrentControl = new DialControl(m_pCurrentWindow,
oAttrMap["Name"],
atoi(oAttrMap["NumFrames"].c_str()),
atoi(oAttrMap["PixelsPerFrame"].c_str()));
return kError_NoErr;
}
if (oElement == string("MultiStateControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <MultiStateControl> tag needs a Name attribute");
return kError_ParseError;
}
if (oAttrMap.find("NumStates") == oAttrMap.end())
{
m_oLastError = string("the <MultiStateControl> tag needs a NumStates attribute");
return kError_ParseError;
}
m_eCurrentControl = eMultiStateControl;
m_pCurrentControl = new MultiStateControl(m_pCurrentWindow,
oAttrMap["Name"],
atoi(oAttrMap["NumStates"].
c_str()));
return kError_NoErr;
}
if (oElement == string("PixSliderControl"))
{
bool reveal = true;
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <PixSliderControl> tag needs a Name attribute");
return kError_ParseError;
}
if (oAttrMap.find("NumStates") == oAttrMap.end())
{
m_oLastError = string("the <PixSliderControl> tag needs a NumStates attribute");
return kError_ParseError;
}
if (oAttrMap.find("Reveal") != oAttrMap.end())
{
reveal = strcasecmp(oAttrMap["Reveal"].c_str(), "yes") == 0;
}
m_eCurrentControl = ePixSliderControl;
m_pCurrentControl = new PixSliderControl(m_pCurrentWindow,
oAttrMap["Name"],
atoi(oAttrMap["NumStates"].
c_str()), reveal);
return kError_NoErr;
}
if (oElement == string("SliderControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
int iThumbStates = 1, iNumFrames = 3;
int iNotch = -1, iNotchWidth = -1;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <SliderControl> tag needs a Name attribute");
return kError_ParseError;
}
if (oAttrMap.find("ThumbStates") != oAttrMap.end())
{
iThumbStates = atoi(oAttrMap["ThumbStates"].c_str());
}
if (oAttrMap.find("Frames") != oAttrMap.end())
{
iNumFrames = atoi(oAttrMap["Frames"].c_str());
}
if (oAttrMap.find("Notch") != oAttrMap.end())
{
iNotch = atoi(oAttrMap["Notch"].c_str());
}
if (oAttrMap.find("NotchWidth") != oAttrMap.end())
{
iNotchWidth = atoi(oAttrMap["NotchWidth"].c_str());
}
m_eCurrentControl = eSliderControl;
m_pCurrentControl = new SliderControl(m_pCurrentWindow,
oAttrMap["Name"],
iThumbStates, iNumFrames,
iNotch, iNotchWidth);
return kError_NoErr;
}
if (oElement == string("VSliderControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
int iThumbStates = 1, iNumFrames = 3;
int iNotch = -1, iNotchWidth = -1;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <VSliderControl> tag needs a Name attribute");
return kError_ParseError;
}
if (oAttrMap.find("ThumbStates") != oAttrMap.end())
{
iThumbStates = atoi(oAttrMap["ThumbStates"].c_str());
}
if (oAttrMap.find("Frames") != oAttrMap.end())
{
iNumFrames = atoi(oAttrMap["Frames"].c_str());
}
if (oAttrMap.find("Notch") != oAttrMap.end())
{
iNotch = atoi(oAttrMap["Notch"].c_str());
}
if (oAttrMap.find("NotchWidth") != oAttrMap.end())
{
iNotchWidth = atoi(oAttrMap["NotchWidth"].c_str());
}
m_eCurrentControl = eVSliderControl;
m_pCurrentControl = new VSliderControl(m_pCurrentWindow,
oAttrMap["Name"],
iThumbStates, iNumFrames,
iNotch, iNotchWidth);
return kError_NoErr;
}
if (oElement == string("TextControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <TextControl> tag needs a Name attribute");
return kError_ParseError;
}
m_eCurrentControl = eTextControl;
m_pCurrentControl = new TextControl(m_pCurrentWindow,
oAttrMap["Name"]);
return kError_NoErr;
}
if (oElement == string("PixmapFontControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <PixmapFontControl> tag needs a Name attribute");
return kError_ParseError;
}
m_eCurrentControl = ePixFontControl;
m_pCurrentControl = new PixFontControl(m_pCurrentWindow,
oAttrMap["Name"]);
bool bCase = false;
if (oAttrMap.find("IgnoreCase") != oAttrMap.end())
bCase = strcasecmp(oAttrMap["IgnoreCase"].c_str(), "yes") == 0;
if (bCase)
((PixFontControl *)m_pCurrentControl)->SetIgnoreCase(true);
return kError_NoErr;
}
if (oElement == string("FontMap"))
{
char *row;
if (m_pCurrentControl == NULL || m_eCurrentControl != ePixFontControl)
{
m_oLastError = string("The <FontMap> tag must be inside of a "
"<PixFontControl> tag");
return kError_InvalidParam;
}
if (oAttrMap.find("Map") == oAttrMap.end())
{
m_oLastError = string("the <FontMap> tag needs a Map attribute");
return kError_ParseError;
}
row = (char *)oAttrMap["Map"].c_str();
((PixFontControl *)m_pCurrentControl)->AddMapRow(row);
return kError_NoErr;
}
if (oElement == string("PixmapTimeControl"))
{
m_bPosDefined = m_bBitmapDefined = m_bInfoDefined = false;
if (m_pCurrentControl)
{
m_oLastError = string("Controls cannot be nested");
return kError_InvalidParam;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <PixmapTimeControl> tag needs a Name attribute");
return kError_ParseError;
}
m_eCurrentControl = ePixTimeControl;
m_pCurrentControl = new PixTimeControl(m_pCurrentWindow,
oAttrMap["Name"]);
return kError_NoErr;
}
if (oElement == string("PartName"))
{
if (m_pCurrentControl == NULL || m_eCurrentControl != ePixTimeControl)
{
m_oLastError = string("The <PartName> tag must be inside of a "
"<PixmapTimeControl> tag");
return kError_InvalidParam;
}
if (oAttrMap.find("Part") == oAttrMap.end())
{
m_oLastError = string("the <PartName> tag needs a Part attribute");
return kError_ParseError;
}
if (oAttrMap.find("Name") == oAttrMap.end())
{
m_oLastError = string("the <PartName> tag needs a Name attribute");
return kError_ParseError;
}
((PixTimeControl *)m_pCurrentControl)->SetPartName(oAttrMap["Part"],
oAttrMap["Name"]);
return kError_NoErr;
}
if (oElement == string("Style"))
{
Color oColor(0, 0, 0);
Font *pFont;
bool bBold = false, bItalic = false, bUnderline = false;
string oAlign("");
if (m_pCurrentControl == NULL || m_eCurrentControl != eTextControl)
{
m_oLastError = string("The <Style> tag must be inside of a "
"<TextControl> tag");
return kError_InvalidParam;
}
if (oAttrMap.find("Font") == oAttrMap.end())
{
m_oLastError = string("the <Style> tag needs a Font attribute");
return kError_ParseError;
}
pFont = FindFont(oAttrMap["Font"]);
if (pFont == NULL)
{
m_oLastError = string("Undefined font ") +
oAttrMap["Name"] +
string("in tag <Style>");
return kError_InvalidParam;
}
#ifdef HAVE_GTK
pFont = new GTKFont(*(GTKFont *)pFont);
#endif
if (oAttrMap.find("Color") != oAttrMap.end() &&
oAttrMap["Color"] != string(""))
{
eRet = ParseColor(oAttrMap["Color"], oColor);
if (eRet != kError_NoErr)
{
m_oLastError = string("Improperly formatted color info: ") +
oAttrMap["Color"];
return kError_InvalidParam;
}
}
if (oAttrMap.find("Bold") != oAttrMap.end())
bBold = strcasecmp(oAttrMap["Bold"].c_str(), "yes") == 0;
if (oAttrMap.find("Italic") != oAttrMap.end())
bItalic = strcasecmp(oAttrMap["Italic"].c_str(), "yes") == 0;
if (oAttrMap.find("Underline") != oAttrMap.end())
bUnderline = strcasecmp(oAttrMap["Underline"].c_str(), "yes") == 0;
if (oAttrMap.find("Align") != oAttrMap.end())
oAlign = oAttrMap["Align"];
((TextControl *)m_pCurrentControl)->SetStyle(pFont, oAlign,
oColor, bBold, bItalic, bUnderline);
return kError_NoErr;
}
if (oElement == string("ChangeWindow"))
{
if (m_pCurrentControl == NULL || m_eCurrentControl != eButtonControl)
{
m_oLastError = string("The <ChangeWindow> tag must be inside of a "
"<ButtonControl> tag");
return kError_InvalidParam;
}
if (oAttrMap.find("Window") == oAttrMap.end())
{
m_oLastError = string("the <ChangeWindow> tag needs a Window attribute");
return kError_ParseError;
}
((ButtonControl *)m_pCurrentControl)->SetTargetWindow(oAttrMap["Window"]);
return kError_NoErr;
}
if (oElement == string("TogglePanel"))
{
Panel *pPanel;
if (m_pCurrentControl == NULL || m_eCurrentControl != eButtonControl)
{
m_oLastError = string("The <TogglePanel> tag must be inside of a "
"<ButtonControl> tag");
return kError_InvalidParam;
}
if (oAttrMap.find("Panel") == oAttrMap.end())
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -