#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);
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();
+ wxNode *node = Next();
while (node != NULL)
{
- wxItemResource *parent = (wxItemResource *)node->Data();
+ wxItemResource *parent = (wxItemResource *)node->GetData();
if (parent->GetChildren().Member(item))
{
parent->GetChildren().DeleteObject(item);
while (node)
{
wxNode *next = Next();
- wxItemResource *item = (wxItemResource *)node->Data();
+ wxItemResource *item = (wxItemResource *)node->GetData();
delete item;
delete node;
node = next;
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,
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;
table.DeleteResource(item->GetName());
table.AddResource(item);
}
- node = node->Next();
+ node = node->GetNext();
}
return TRUE;
}
(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
*/
static bool wxEatWhiteSpace(FILE *fd)
{
- int ch = 0;
+ int ch;
while ((ch = getc(fd)) != EOF)
{
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)
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)
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;
}
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)
{
if (ch == '*')
{
// Eat C comment
- prev_ch = 0;
+ int prev_ch = 0;
while ((ch = getc_string(s)) != EOF)
{
if (ch == '/' && prev_ch == '*')
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() );
* 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;
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 ((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;
+ wxPanel* panel = (wxPanel *)thisWindow;
if (!panel->Create(parent, -1, 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))
+ if (!((wxWindow *)thisWindow)->Create(parent, -1, 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;
}
-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
+