本文整理汇总了C++中StyleSet::parseSet方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleSet::parseSet方法的具体用法?C++ StyleSet::parseSet怎么用?C++ StyleSet::parseSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StyleSet
的用法示例。
在下文中一共展示了StyleSet::parseSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadCustomStyles
/* StyleSet::loadCustomStyles
* Loads all text styles from the user text style directory
*******************************************************************/
bool StyleSet::loadCustomStyles()
{
// If the custom stylesets directory doesn't exist, create it
if (!wxDirExists(appPath("text_styles", DIR_USER)))
wxMkdir(appPath("text_styles", DIR_USER));
// Open the custom stylesets directory
wxDir res_dir;
res_dir.Open(appPath("text_styles", DIR_USER));
// Go through each file in the directory
string filename = wxEmptyString;
bool files = res_dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
while (files)
{
// Read file into tokenizer
Tokenizer tz;
tz.openFile(res_dir.GetName() + "/" + filename);
// Parse it
ParseTreeNode root;
root.allowDup(true);
root.parse(tz);
// Read any styleset definitions
vector<STreeNode*> nodes = root.getChildren("styleset");
for (unsigned b = 0; b < nodes.size(); b++)
{
StyleSet* newset = new StyleSet();
if (newset->parseSet((ParseTreeNode*)nodes[b]))
style_sets.push_back(newset);
else
delete newset;
}
// Next file
files = res_dir.GetNext(&filename);
}
return true;
}
示例2: loadResourceStyles
/* StyleSet::loadResourceStyles
* Loads all text styles from the slade resource archive (slade.pk3)
*******************************************************************/
bool StyleSet::loadResourceStyles()
{
// Get 'config/text_styles' directory in slade.pk3
ArchiveTreeNode* dir = theArchiveManager->programResourceArchive()->getDir("config/text_styles");
// Check it exists
if (!dir)
{
wxLogMessage("Warning: No 'config/text_styles' directory exists in slade.pk3");
return false;
}
// Read default style set first
ArchiveEntry* default_style = dir->getEntry("default.sss");
if (default_style)
{
// Read entry data into tokenizer
Tokenizer tz;
tz.openMem(&default_style->getMCData(), default_style->getName());
// Parse it
ParseTreeNode root;
root.allowDup(true);
root.parse(tz);
// Read any styleset definitions
vector<STreeNode*> nodes = root.getChildren("styleset");
for (unsigned b = 0; b < nodes.size(); b++)
{
StyleSet* newset = new StyleSet();
if (newset->parseSet((ParseTreeNode*)nodes[b]))
style_sets.push_back(newset);
else
delete newset;
}
}
// Go through all entries within it
for (unsigned a = 0; a < dir->numEntries(); a++)
{
ArchiveEntry* entry = dir->getEntry(a);
// Skip default
if (entry->getName(true) == "default")
continue;
// Read entry data into tokenizer
Tokenizer tz;
tz.openMem(&entry->getMCData(), entry->getName());
// Parse it
ParseTreeNode root;
root.allowDup(true);
root.parse(tz);
// Read any styleset definitions
vector<STreeNode*> nodes = root.getChildren("styleset");
for (unsigned b = 0; b < nodes.size(); b++)
{
StyleSet* newset = new StyleSet();
if (newset->parseSet((ParseTreeNode*)nodes[b]))
style_sets.push_back(newset);
else
delete newset;
}
}
return true;
}