#include "wx/combobox.h"
#endif
-#include "wx/validate.h"
+#include "wx/splitter.h"
+#include "wx/toolbar.h"
+#include "wx/validate.h"
#include "wx/log.h"
+#include "wx/module.h"
#include <ctype.h>
#include <math.h>
#include "wx/deprecated/resource.h"
#include "wx/deprecated/wxexpr.h"
+#if !WXWIN_COMPATIBILITY_2_4
+static inline wxChar* copystring(const wxChar* s)
+ { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }
+#endif
+
// Forward (private) declarations
bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db);
-wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = FALSE);
+wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel = false);
wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr);
wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr);
wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr);
void wxInitializeResourceSystem()
{
- wxDefaultResourceTable = new wxResourceTable;
+ if (!wxDefaultResourceTable)
+ wxDefaultResourceTable = new wxResourceTable;
}
void wxCleanUpResourceSystem()
delete[] wxResourceBuffer;
}
-#if 0
-void wxLogWarning(char *msg)
+// Module to ensure the resource system data gets initialized
+// and cleaned up.
+
+class wxResourceModule: public wxModule
{
- wxMessageBox(msg, _("Warning"), wxOK);
-}
-#endif
+public:
+ wxResourceModule() : wxModule() {}
+ virtual bool OnInit() { wxInitializeResourceSystem(); return true; }
+ virtual void OnExit() { wxCleanUpResourceSystem(); }
+
+ DECLARE_DYNAMIC_CLASS(wxResourceModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxResourceModule, wxModule)
+
IMPLEMENT_DYNAMIC_CLASS(wxItemResource, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
wxItemResource::~wxItemResource()
{
- wxNode *node = m_children.First();
+ wxNode *node = m_children.GetFirst();
while (node)
{
- wxItemResource *item = (wxItemResource *)node->Data();
+ wxItemResource *item = (wxItemResource *)node->GetData();
delete item;
delete node;
- node = m_children.First();
+ node = m_children.GetFirst();
}
}
// See if any resource has this as its child; if so, delete from
// parent's child list.
BeginFind();
- wxNode *node = (wxNode *) NULL;
- node = Next();
+ wxHashTable::Node *node = Next();
while (node != NULL)
{
- wxItemResource *parent = (wxItemResource *)node->Data();
+ wxItemResource *parent = (wxItemResource *)node->GetData();
if (parent->GetChildren().Member(item))
{
parent->GetChildren().DeleteObject(item);
}
delete item;
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxResourceTable::ParseResourceFile( wxInputStream *is )
wxExprDatabase db;
int len = is->GetSize() ;
- bool eof = FALSE;
+ bool eof = false;
while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF
{
wxResourceReadOneResource(is, db, &eof, this) ;
FILE *fd = wxFopen(filename, wxT("r"));
if (!fd)
- return FALSE;
- bool eof = FALSE;
+ return false;
+ bool eof = false;
while (wxResourceReadOneResource(fd, db, &eof, this) && !eof)
{
// Loop
if (!db.ReadFromString(data))
{
wxLogWarning(_("Ill-formed resource file syntax."));
- return FALSE;
+ return false;
}
return wxResourceInterpretResources(*this, db);
item->SetValue2((long)width);
item->SetValue3((long)height);
AddResource(item);
- return TRUE;
+ return true;
}
bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **data)
item->SetName(name);
item->SetValue1((long)data);
AddResource(item);
- return TRUE;
+ return true;
}
bool wxResourceTable::SaveResource(const wxString& WXUNUSED(filename))
{
- return FALSE;
+ return false;
}
void wxResourceTable::ClearTable()
{
BeginFind();
- wxNode *node = Next();
+ wxHashTable::Node *node = Next();
while (node)
{
- wxNode *next = Next();
- wxItemResource *item = (wxItemResource *)node->Data();
+ wxHashTable::Node *next = Next();
+ wxItemResource *item = (wxItemResource *)node->GetData();
delete item;
delete node;
node = next;
((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
*/
((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(),
- (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE);
+ (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),false);
}
#endif
wxStringList& stringList = childResource->GetStringValues();
wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList.Number() > 0)
+ if (stringList.GetCount() > 0)
{
- noStrings = stringList.Number();
+ noStrings = stringList.GetCount();
strings = new wxString[noStrings];
- wxNode *node = stringList.First();
+ wxStringListNode *node = stringList.GetFirst();
int i = 0;
while (node)
{
- strings[i] = (wxChar *)node->Data();
+ strings[i] = (wxChar *)node->GetData();
i ++;
- node = node->Next();
+ node = node->GetNext();
}
}
control = new wxListBox(parent, id, pos, size,
wxStringList& stringList = childResource->GetStringValues();
wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList.Number() > 0)
+ if (stringList.GetCount() > 0)
{
- noStrings = stringList.Number();
+ noStrings = stringList.GetCount();
strings = new wxString[noStrings];
- wxNode *node = stringList.First();
+ wxStringListNode *node = stringList.GetFirst();
int i = 0;
while (node)
{
- strings[i] = (wxChar *)node->Data();
+ strings[i] = (wxChar *)node->GetData();
i ++;
- node = node->Next();
+ node = node->GetNext();
}
}
control = new wxChoice(parent, id, pos, size,
wxStringList& stringList = childResource->GetStringValues();
wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList.Number() > 0)
+ if (stringList.GetCount() > 0)
{
- noStrings = stringList.Number();
+ noStrings = stringList.GetCount();
strings = new wxString[noStrings];
- wxNode *node = stringList.First();
+ wxStringListNode *node = stringList.GetFirst();
int i = 0;
while (node)
{
- strings[i] = (wxChar *)node->Data();
+ strings[i] = (wxChar *)node->GetData();
i ++;
- node = node->Next();
+ node = node->GetNext();
}
}
control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size,
wxStringList& stringList = childResource->GetStringValues();
wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList.Number() > 0)
+ if (stringList.GetCount() > 0)
{
- noStrings = stringList.Number();
+ noStrings = stringList.GetCount();
strings = new wxString[noStrings];
- wxNode *node = stringList.First();
+ wxStringListNode *node = stringList.GetFirst();
int i = 0;
while (node)
{
- strings[i] = (wxChar *)node->Data();
+ strings[i] = (wxChar *)node->GetData();
i ++;
- node = node->Next();
+ node = node->GetNext();
}
}
control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size,
// Force the layout algorithm since the size changes the layout
if (control->IsKindOf(CLASSINFO(wxRadioBox)))
{
- control->SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT);
+ control->SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT);
}
#endif
}
bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db)
{
- wxNode *node = db.First();
+ wxNode *node = db.GetFirst();
while (node)
{
- wxExpr *clause = (wxExpr *)node->Data();
+ wxExpr *clause = (wxExpr *)node->GetData();
wxString functor(clause->Functor());
wxItemResource *item = (wxItemResource *) NULL;
if (functor == wxT("dialog"))
item = wxResourceInterpretDialog(table, clause);
else if (functor == wxT("panel"))
- item = wxResourceInterpretDialog(table, clause, TRUE);
+ item = wxResourceInterpretDialog(table, clause, true);
else if (functor == wxT("menubar"))
item = wxResourceInterpretMenuBar(table, clause);
else if (functor == wxT("menu"))
table.DeleteResource(item->GetName());
table.AddResource(item);
}
- node = node->Next();
+ node = node->GetNext();
}
- return TRUE;
+ return true;
}
static const wxChar *g_ValidControlClasses[] =
for ( size_t i = 0; i < WXSIZEOF(g_ValidControlClasses); i++ )
{
if ( c == g_ValidControlClasses[i] )
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel)
if (isPanel)
windowStyle = 0;
- int x = 0; int y = 0; int width = -1; int height = -1;
+ int x = 0; int y = 0; int width = wxDefaultCoord; int height = wxDefaultCoord;
int isModal = 0;
wxExpr *labelFontExpr = (wxExpr *) NULL;
wxExpr *buttonFontExpr = (wxExpr *) NULL;
}
dialogItem->SetStyle(windowStyle);
dialogItem->SetValue1(isModal);
- if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2
- dialogItem->SetValue1(TRUE);
+#ifdef __VMS
+#pragma message disable CODCAUUNR
+#endif
+ if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2
+ dialogItem->SetValue1(true);
+#ifdef __VMS
+#pragma message enable CODCAUUNR
+#endif
dialogItem->SetName(name);
dialogItem->SetTitle(title);
dialogItem->SetSize(x, y, width, height);
// Check for wxWin 1.68-style specifications
- if (style.Find(wxT("VERTICAL_LABEL")) != -1)
+ if (style.Find(wxT("VERTICAL_LABEL")) != wxNOT_FOUND)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL);
- else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1)
+ else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
if (backColourHex != wxT(""))
wxString name;
int id = 0;
long windowStyle = 0;
- int x = 0; int y = 0; int width = -1; int height = -1;
+ int x = 0; int y = 0; int width = wxDefaultCoord; int height = wxDefaultCoord;
int count = 0;
wxExpr *expr1 = expr->Nth(0);
controlItem->SetId(id);
// Check for wxWin 1.68-style specifications
- if (style.Find(wxT("VERTICAL_LABEL")) != -1)
+ if (style.Find(wxT("VERTICAL_LABEL")) != wxNOT_FOUND)
controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL);
- else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1)
+ else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND)
controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
if (controlType == wxT("wxButton"))
(underline != 0), faceName);
}
-// Separate file for the remainder of this, for BC++/Win16
-
-#if !((defined(__BORLANDC__) || defined(__SC__)) && defined(__WIN16__))
/*
* (Re)allocate buffer for reading in from resource file
*/
{
wxResourceBufferSize = 1000;
wxResourceBuffer = new char[wxResourceBufferSize];
- return TRUE;
+ return true;
}
if (wxResourceBuffer)
{
wxResourceBuffer = tmp;
wxResourceBufferSize = newSize;
}
- return TRUE;
+ return true;
}
static bool wxEatWhiteSpace(FILE *fd)
{
- int ch = 0;
+ int ch;
while ((ch = getc(fd)) != EOF)
{
if (ch == EOF)
{
ungetc(prev_ch, fd);
- return TRUE;
+ return true;
}
if (ch == '*')
{
ungetc(prev_ch, fd);
ungetc(ch, fd);
- return TRUE;
+ return true;
}
}
break;
default:
ungetc(ch, fd);
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
static bool wxEatWhiteSpace(wxInputStream *is)
{
if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
{
is->Ungetch(ch);
- return TRUE;
+ return true;
}
// Eat whitespace
ch = is->GetC();
if (ch == '*')
{
- bool finished = FALSE;
+ bool finished = false;
while (!finished)
{
ch = is->GetC();
if (ch == EOF)
- return FALSE;
+ return false;
if (ch == '*')
{
int newCh = is->GetC();
if (newCh == '/')
- finished = TRUE;
+ finished = true;
else
{
is->Ungetch(ch);
}
}
else // False alarm
- return FALSE;
+ return false;
}
else
is->Ungetch(ch);
if (ch == EOF)
{
wxResourceBuffer[wxResourceBufferCount] = 0;
- return FALSE;
+ return false;
}
// Escaped characters
else if (ch == '\\')
}
wxResourceBuffer[wxResourceBufferCount] = 0;
if (ch == EOF)
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
bool wxGetResourceToken(wxInputStream *is)
if (ch == EOF)
{
wxResourceBuffer[wxResourceBufferCount] = 0;
- return FALSE;
+ return false;
}
// Escaped characters
else if (ch == '\\')
}
wxResourceBuffer[wxResourceBufferCount] = 0;
if (ch == EOF)
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/*
// static or #define
if (!wxGetResourceToken(fd))
{
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "#define") == 0)
wxLogWarning(_("#define %s must be an integer."), name);
delete[] name;
delete[] value;
- return FALSE;
+ return false;
}
delete[] name;
delete[] value;
- return TRUE;
+ return true;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
{
wxLogWarning(_("Could not find resource include file %s."), actualName);
}
delete[] name;
- return TRUE;
+ return true;
}
else if (strcmp(wxResourceBuffer, "static") != 0)
{
wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
wxLogWarning(buf);
- return FALSE;
+ return false;
}
// char
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
- return FALSE;
+ return false;
}
// *name
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
- return FALSE;
+ return false;
}
wxChar nameBuf[100];
wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
- return FALSE;
+ return false;
}
// String
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
else
{
if (!db.ReadPrologFromString(wxResourceBuffer))
{
wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf);
- return FALSE;
+ return false;
}
}
// Semicolon
if (!wxGetResourceToken(fd))
{
- *eof = TRUE;
+ *eof = true;
}
- return TRUE;
+ return true;
}
bool wxResourceReadOneResource(wxInputStream *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table)
// static or #define
if (!wxGetResourceToken(fd))
{
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "#define") == 0)
wxLogWarning(_("#define %s must be an integer."), name);
delete[] name;
delete[] value;
- return FALSE;
+ return false;
}
delete[] name;
delete[] value;
- return TRUE;
+ return true;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
{
wxLogWarning(_("Could not find resource include file %s."), actualName);
}
delete[] name;
- return TRUE;
+ return true;
}
else if (strcmp(wxResourceBuffer, "static") != 0)
{
wxStrncat(buf, wxConvLibc.cMB2WX(wxResourceBuffer), 30);
wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
wxLogWarning(buf);
- return FALSE;
+ return false;
}
// char
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
- return FALSE;
+ return false;
}
// *name
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
- return FALSE;
+ return false;
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
- return FALSE;
+ return false;
}
// String
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
else
{
if (!db.ReadPrologFromString(wxResourceBuffer))
{
wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf);
- return FALSE;
+ return false;
}
}
// Semicolon
if (!wxGetResourceToken(fd))
{
- *eof = TRUE;
+ *eof = true;
}
- return TRUE;
+ return true;
}
/*
word = wxResourceParseWord(WXSTRINGCAST bitListString, &i);
while (word != NULL)
{
- bool found = FALSE;
+ bool found = false;
int j;
for (j = 0; j < wxResourceBitListCount; j++)
if (wxStrcmp(wxResourceBitListTable[j].word, word) == 0)
{
bitList |= wxResourceBitListTable[j].bits;
- found = TRUE;
+ found = true;
break;
}
if (!found)
}
/*
-* Load a bitmap from a wxWindows resource, choosing an optimum
+* Load a bitmap from a wxWidgets resource, choosing an optimum
* depth and appropriate type.
*/
wxItemResource *optResource = (wxItemResource *) NULL;
// Try to find optimum bitmap for this platform/colour depth
- wxNode *node = item->GetChildren().First();
+ wxNode *node = item->GetChildren().GetFirst();
while (node)
{
- wxItemResource *child = (wxItemResource *)node->Data();
+ wxItemResource *child = (wxItemResource *)node->GetData();
int platform = (int)child->GetValue2();
int noColours = (int)child->GetValue3();
/*
default:
break;
}
- node = node->Next();
+ node = node->GetNext();
}
// If no matching resource, fail.
if (!optResource)
}
/*
-* Load an icon from a wxWindows resource, choosing an optimum
+* Load an icon from a wxWidgets resource, choosing an optimum
* depth and appropriate type.
*/
wxItemResource *optResource = (wxItemResource *) NULL;
// Try to find optimum icon for this platform/colour depth
- wxNode *node = item->GetChildren().First();
+ wxNode *node = item->GetChildren().GetFirst();
while (node)
{
- wxItemResource *child = (wxItemResource *)node->Data();
+ wxItemResource *child = (wxItemResource *)node->GetData();
int platform = (int)child->GetValue2();
int noColours = (int)child->GetValue3();
/*
default:
break;
}
- node = node->Next();
+ node = node->GetNext();
}
// If no matching resource, fail.
if (!optResource)
}
case wxBITMAP_TYPE_XPM_DATA:
{
- // *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
+ // *** XPM ICON NOT YET IMPLEMENTED IN wxWidgets ***
/*
wxItemResource *item = table->FindResource(name);
if (!item)
wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource);
break;
#else
- return wxIcon(name, bitmapType);
+ return wxIcon(name, (wxBitmapType) bitmapType);
#endif
}
}
wxMenu *wxResourceCreateMenu(wxItemResource *item)
{
wxMenu *menu = new wxMenu;
- wxNode *node = item->GetChildren().First();
+ wxNode *node = item->GetChildren().GetFirst();
while (node)
{
- wxItemResource *child = (wxItemResource *)node->Data();
+ wxItemResource *child = (wxItemResource *)node->GetData();
if ((child->GetType() != wxT("")) && (child->GetType() == wxT("wxMenuSeparator")))
menu->AppendSeparator();
- else if (child->GetChildren().Number() > 0)
+ else if (child->GetChildren().GetCount() > 0)
{
wxMenu *subMenu = wxResourceCreateMenu(child);
if (subMenu)
{
menu->Append((int)child->GetValue1(), child->GetTitle(), child->GetValue4(), (child->GetValue2() != 0));
}
- node = node->Next();
+ node = node->GetNext();
}
return menu;
}
{
if (!menuBar)
menuBar = new wxMenuBar;
- wxNode *node = menuResource->GetChildren().First();
+ wxNode *node = menuResource->GetChildren().GetFirst();
while (node)
{
- wxItemResource *child = (wxItemResource *)node->Data();
+ wxItemResource *child = (wxItemResource *)node->GetData();
wxMenu *menu = wxResourceCreateMenu(child);
if (menu)
menuBar->Append(menu, child->GetTitle());
- node = node->Next();
+ node = node->GetNext();
}
return menuBar;
}
table = wxDefaultResourceTable;
table->identifiers.Put(name, (wxObject *)(long)value);
- return TRUE;
+ return true;
}
int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table)
FILE *fd = wxFopen(f, wxT("r"));
if (!fd)
{
- return FALSE;
+ return false;
}
while (wxGetResourceToken(fd))
{
}
}
fclose(fd);
- return TRUE;
+ return true;
}
/*
bool wxEatWhiteSpaceString(char *s)
{
- int ch = 0;
+ int ch;
while ((ch = getc_string(s)) != EOF)
{
break;
case '/':
{
- int prev_ch = ch;
ch = getc_string(s);
if (ch == EOF)
{
ungetc_string();
- return TRUE;
+ return true;
}
if (ch == '*')
{
// Eat C comment
- prev_ch = 0;
+ int prev_ch = 0;
while ((ch = getc_string(s)) != EOF)
{
if (ch == '/' && prev_ch == '*')
{
ungetc_string();
ungetc_string();
- return TRUE;
+ return true;
}
}
break;
default:
ungetc_string();
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
bool wxGetResourceTokenString(char *s)
if (ch == EOF)
{
wxResourceBuffer[wxResourceBufferCount] = 0;
- return FALSE;
+ return false;
}
// Escaped characters
else if (ch == '\\')
}
wxResourceBuffer[wxResourceBufferCount] = 0;
if (ch == EOF)
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/*
// static or #define
if (!wxGetResourceTokenString(s))
{
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "#define") == 0)
wxLogWarning(_("#define %s must be an integer."), name);
delete[] name;
delete[] value;
- return FALSE;
+ return false;
}
delete[] name;
delete[] value;
- return TRUE;
+ return true;
}
/*
else if (strcmp(wxResourceBuffer, "#include") == 0)
wxLogWarning(buf);
}
delete[] name;
- return TRUE;
+ return true;
}
*/
else if (strcmp(wxResourceBuffer, "static") != 0)
wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
wxLogWarning(buf);
- return FALSE;
+ return false;
}
// char
if (!wxGetResourceTokenString(s))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
- return FALSE;
+ return false;
}
// *name
if (!wxGetResourceTokenString(s))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
- return FALSE;
+ return false;
}
wxChar nameBuf[100];
wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
if (!wxGetResourceTokenString(s))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
- return FALSE;
+ return false;
}
// String
if (!wxGetResourceTokenString(s))
{
wxLogWarning(_("Unexpected end of file whilst parsing resource."));
- *eof = TRUE;
- return FALSE;
+ *eof = true;
+ return false;
}
else
{
if (!db.ReadPrologFromString(wxResourceBuffer))
{
wxLogWarning(_("%s: ill-formed resource file syntax."), nameBuf);
- return FALSE;
+ return false;
}
}
// Semicolon
if (!wxGetResourceTokenString(s))
{
- *eof = TRUE;
+ *eof = true;
}
- return TRUE;
+ return true;
}
-bool wxResourceParseString(const wxString& s, wxResourceTable *table)
+bool wxResourceParseString(const wxString& s, wxResourceTable *WXUNUSED(table))
{
#if wxUSE_UNICODE
return wxResourceParseString( (char*)s.mb_str().data() );
table = wxDefaultResourceTable;
if (!s)
- return FALSE;
+ return false;
// Turn backslashes into spaces
if (s)
wxExprDatabase db;
wxResourceStringPtr = 0;
- bool eof = FALSE;
+ bool eof = false;
while (wxResourceReadOneResourceString(s, db, &eof, table) && !eof)
{
// Loop
* resource loading facility
*/
-bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
+bool wxLoadFromResource(wxWindow* thisWindow, wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
if (!resource || (resource->GetType() == wxT("")) ||
! ((resource->GetType() == wxT("wxDialog")) || (resource->GetType() == wxT("wxPanel"))))
- return FALSE;
+ return false;
wxString title(resource->GetTitle());
long theWindowStyle = resource->GetStyle();
wxString name = resource->GetName();
// this is used for loading wxWizard pages from WXR
- if ( parent != this )
+ if ( parent != thisWindow )
{
- if (IsKindOf(CLASSINFO(wxDialog)))
+ if (thisWindow->IsKindOf(CLASSINFO(wxDialog)))
{
- wxDialog *dialogBox = (wxDialog *)this;
+ wxDialog *dialogBox = (wxDialog *)thisWindow;
long modalStyle = isModal ? wxDIALOG_MODAL : 0;
- if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
- return FALSE;
+ if (!dialogBox->Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
+ return false;
// Only reset the client size if we know we're not going to do it again below.
if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0)
dialogBox->SetClientSize(width, height);
}
- else if (IsKindOf(CLASSINFO(wxPanel)))
+ else if (thisWindow->IsKindOf(CLASSINFO(wxPanel)))
{
- wxPanel* panel = (wxPanel *)this;
- if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name))
- return FALSE;
+ wxPanel* panel = (wxPanel *)thisWindow;
+ if (!panel->Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name))
+ return false;
}
else
{
- if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
- return FALSE;
+ if (!((wxWindow *)thisWindow)->Create(parent, wxID_ANY, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
+ return false;
}
}
else
{
if (resource->GetFont().Ok())
- SetFont(resource->GetFont());
+ thisWindow->SetFont(resource->GetFont());
if (resource->GetBackgroundColour().Ok())
- SetBackgroundColour(resource->GetBackgroundColour());
+ thisWindow->SetBackgroundColour(resource->GetBackgroundColour());
}
// Should have some kind of font at this point
- if (!GetFont().Ok())
- SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- if (!GetBackgroundColour().Ok())
- SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
+ if (!thisWindow->GetFont().Ok())
+ thisWindow->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+ if (!thisWindow->GetBackgroundColour().Ok())
+ thisWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
// Only when we've created the window and set the font can we set the correct size,
// if based on dialog units.
if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
{
- wxSize sz = ConvertDialogToPixels(wxSize(width, height));
- SetClientSize(sz.x, sz.y);
+ wxSize sz = thisWindow->ConvertDialogToPixels(wxSize(width, height));
+ thisWindow->SetClientSize(sz.x, sz.y);
- wxPoint pt = ConvertDialogToPixels(wxPoint(x, y));
- Move(pt.x, pt.y);
+ wxPoint pt = thisWindow->ConvertDialogToPixels(wxPoint(x, y));
+ thisWindow->Move(pt.x, pt.y);
}
// Now create children
- wxNode *node = resource->GetChildren().First();
+ wxNode *node = resource->GetChildren().GetFirst();
while (node)
{
- wxItemResource *childResource = (wxItemResource *)node->Data();
+ wxItemResource *childResource = (wxItemResource *)node->GetData();
- (void) CreateItem(childResource, resource, table);
+ (void) wxCreateItem(thisWindow, childResource, resource, table);
- node = node->Next();
+ node = node->GetNext();
}
- return TRUE;
+ return true;
}
-wxControl *wxWindowBase::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table)
+wxControl *wxCreateItem(wxWindow* thisWindow, const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
- return table->CreateItem((wxWindow *)this, resource, parentResource);
+ return table->CreateItem(thisWindow, resource, parentResource);
}
#ifdef __VISUALC__
#pragma warning(default:4706) // assignment within conditional expression
#endif // VC++
-#endif
-// BC++/Win16
-
#endif // wxUSE_WX_RESOURCES
+