merged 2.2 branch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
#include "symbtabl.h"
|
||||
|
||||
wxResourceSymbolTable::wxResourceSymbolTable():
|
||||
m_hashTable(wxKEY_STRING)
|
||||
m_hashTable(wxKEY_STRING)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,70 +48,70 @@ bool wxResourceSymbolTable::ReadIncludeFile(const wxString& filename)
|
||||
wxFile file;
|
||||
if (!wxFileExists(filename))
|
||||
return FALSE;
|
||||
|
||||
|
||||
if (!file.Open(filename, wxFile::read))
|
||||
return FALSE;
|
||||
|
||||
|
||||
off_t len = file.Length();
|
||||
if (len == -1)
|
||||
return FALSE;
|
||||
|
||||
|
||||
Clear();
|
||||
AddStandardSymbols();
|
||||
|
||||
|
||||
wxString str;
|
||||
char* p = str.GetWriteBuf(len + 1);
|
||||
|
||||
|
||||
if (file.Read(p, len) == wxFile::fd_invalid)
|
||||
{
|
||||
str.UngetWriteBuf();
|
||||
return FALSE;
|
||||
}
|
||||
str.UngetWriteBuf();
|
||||
|
||||
|
||||
// Look for #define occurrences
|
||||
int pos = str.Find("#define");
|
||||
while (pos != -1)
|
||||
{
|
||||
size_t len = str.Length();
|
||||
|
||||
|
||||
size_t i = pos + 8;
|
||||
|
||||
|
||||
// Eat whitespace until symbol
|
||||
while ((str[i] == ' ' || str[i] == '\t') && (i < len))
|
||||
i ++;
|
||||
|
||||
|
||||
size_t start = i;
|
||||
|
||||
|
||||
// Eat symbol
|
||||
while (str[i] != ' ' && str[i] != '\t' && (i < len))
|
||||
i ++;
|
||||
size_t end = i-1;
|
||||
|
||||
|
||||
wxString symbol(str.Mid(start, (end - start + 1)));
|
||||
|
||||
|
||||
// Eat whitespace until number
|
||||
while ((str[i] == ' ' || str[i] == '\t') && (i < len))
|
||||
i ++;
|
||||
|
||||
|
||||
size_t startNum = i;
|
||||
|
||||
|
||||
// Eat number
|
||||
while (str[i] != ' ' && str[i] != '\t' && str[i] != '\n' && (i < len))
|
||||
i ++;
|
||||
|
||||
|
||||
size_t endNum = i-1;
|
||||
|
||||
|
||||
wxString numStr(str.Mid(startNum, (endNum - startNum + 1)));
|
||||
|
||||
|
||||
int id = atol(numStr);
|
||||
|
||||
|
||||
AddSymbol(symbol, id);
|
||||
|
||||
|
||||
str = str.Right(len - i);
|
||||
pos = str.Find("#define");
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -120,30 +120,30 @@ bool wxResourceSymbolTable::WriteIncludeFile(const wxString& filename)
|
||||
wxFile file;
|
||||
if (!file.Open(filename, wxFile::write))
|
||||
return FALSE;
|
||||
|
||||
|
||||
wxString fileOnly(wxFileNameFromPath(filename));
|
||||
wxString line;
|
||||
line.Printf("/*\n * %s\n * Window identifiers file written by Dialog Editor\n */\n\n",
|
||||
(const char*) fileOnly);
|
||||
|
||||
|
||||
file.Write(line, line.Length());
|
||||
|
||||
|
||||
m_hashTable.BeginFind();
|
||||
|
||||
|
||||
wxNode* node = m_hashTable.Next();
|
||||
while (node)
|
||||
{
|
||||
const char* str = node->GetKeyString();
|
||||
int id = (int) node->Data() ;
|
||||
|
||||
|
||||
if (!IsStandardSymbol(str))
|
||||
{
|
||||
wxString line;
|
||||
line.Printf("#define %s %ld\n", str, id);
|
||||
|
||||
|
||||
file.Write(line, line.Length());
|
||||
}
|
||||
|
||||
|
||||
node = m_hashTable.Next();
|
||||
}
|
||||
return TRUE;
|
||||
@@ -177,14 +177,14 @@ bool wxResourceSymbolTable::RemoveSymbol(int id)
|
||||
wxString wxResourceSymbolTable::GetSymbolForId(int id)
|
||||
{
|
||||
m_hashTable.BeginFind();
|
||||
|
||||
|
||||
wxNode* node = m_hashTable.Next();
|
||||
while (node)
|
||||
{
|
||||
const char* str = node->GetKeyString();
|
||||
if (str && ( ((int) node->Data()) == id) )
|
||||
return wxString(str);
|
||||
|
||||
|
||||
node = m_hashTable.Next();
|
||||
}
|
||||
return wxString("");
|
||||
@@ -203,13 +203,13 @@ bool wxResourceSymbolTable::SymbolExists(const wxString& symbol) const
|
||||
bool wxResourceSymbolTable::IdExists(int id)
|
||||
{
|
||||
m_hashTable.BeginFind();
|
||||
|
||||
|
||||
wxNode* node = m_hashTable.Next();
|
||||
while (node)
|
||||
{
|
||||
if ( (((int) node->Data()) == id) )
|
||||
return TRUE;
|
||||
|
||||
|
||||
node = m_hashTable.Next();
|
||||
}
|
||||
return FALSE;
|
||||
@@ -218,19 +218,19 @@ bool wxResourceSymbolTable::IdExists(int id)
|
||||
int wxResourceSymbolTable::FindHighestId()
|
||||
{
|
||||
int highest = 0;
|
||||
|
||||
|
||||
m_hashTable.BeginFind();
|
||||
|
||||
|
||||
wxNode* node = m_hashTable.Next();
|
||||
while (node)
|
||||
{
|
||||
int id = ((int) node->Data());
|
||||
if (id > highest)
|
||||
highest = id;
|
||||
|
||||
|
||||
node = m_hashTable.Next();
|
||||
}
|
||||
|
||||
|
||||
// Make sure we don't clash with future standard wxWindows ids
|
||||
if (highest <= wxID_HIGHEST)
|
||||
highest = wxID_HIGHEST + 1;
|
||||
@@ -238,8 +238,8 @@ int wxResourceSymbolTable::FindHighestId()
|
||||
}
|
||||
|
||||
/*
|
||||
* A table of the standard identifiers
|
||||
*/
|
||||
* A table of the standard identifiers
|
||||
*/
|
||||
|
||||
struct wxStandardSymbolStruct
|
||||
{
|
||||
@@ -256,7 +256,7 @@ static wxStandardSymbolStruct sg_StandardSymbols[] =
|
||||
{ "wxID_STATIC", wxID_STATIC },
|
||||
{ "wxID_YES", wxID_YES },
|
||||
{ "wxID_NO", wxID_NO },
|
||||
|
||||
|
||||
{ "wxID_OPEN", wxID_OPEN },
|
||||
{ "wxID_CLOSE", wxID_CLOSE },
|
||||
{ "wxID_NEW", wxID_NEW },
|
||||
@@ -274,14 +274,14 @@ static wxStandardSymbolStruct sg_StandardSymbols[] =
|
||||
{ "wxID_HELP_COMMANDS", wxID_HELP_COMMANDS },
|
||||
{ "wxID_HELP_PROCEDURES", wxID_HELP_PROCEDURES },
|
||||
{ "wxID_HELP_CONTEXT", wxID_HELP_CONTEXT },
|
||||
|
||||
|
||||
{ "wxID_CUT", wxID_CUT },
|
||||
{ "wxID_COPY", wxID_COPY },
|
||||
{ "wxID_PASTE", wxID_PASTE },
|
||||
{ "wxID_CLEAR", wxID_CLEAR },
|
||||
{ "wxID_FIND", wxID_FIND },
|
||||
{ "wxID_DUPLICATE", wxID_DUPLICATE },
|
||||
|
||||
|
||||
{ "wxID_FILE1", wxID_FILE1 },
|
||||
{ "wxID_FILE2", wxID_FILE2 },
|
||||
{ "wxID_FILE3", wxID_FILE3 },
|
||||
@@ -291,7 +291,7 @@ static wxStandardSymbolStruct sg_StandardSymbols[] =
|
||||
{ "wxID_FILE7", wxID_FILE7 },
|
||||
{ "wxID_FILE8", wxID_FILE8 },
|
||||
{ "wxID_FILE9", wxID_FILE9 }
|
||||
|
||||
|
||||
};
|
||||
|
||||
static int sg_StandardSymbolSize = (sizeof(sg_StandardSymbols)/sizeof(wxStandardSymbolStruct));
|
||||
@@ -319,12 +319,12 @@ bool wxResourceSymbolTable::IsStandardSymbol(const wxString& symbol) const
|
||||
bool wxResourceSymbolTable::FillComboBox(wxComboBox* comboBox)
|
||||
{
|
||||
m_hashTable.BeginFind();
|
||||
|
||||
|
||||
wxNode* node = m_hashTable.Next();
|
||||
while (node)
|
||||
{
|
||||
const char* str = node->GetKeyString();
|
||||
|
||||
|
||||
comboBox->Append(str);
|
||||
node = m_hashTable.Next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user