#pragma hdrstop
#endif
+#if wxUSE_WX_RESOURCES
+
+#ifdef __VISUALC__
+ #pragma warning(disable:4706) // assignment within conditional expression
+#endif // VC++
+
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/setup.h"
#include "wx/listbox.h"
#include "wx/choice.h"
#include "wx/checkbox.h"
+#include "wx/settings.h"
#include "wx/slider.h"
+#include "wx/icon.h"
#include "wx/statbox.h"
-#if USE_GAUGE
+#include "wx/statbmp.h"
#include "wx/gauge.h"
-#endif
#include "wx/textctrl.h"
#include "wx/msgdlg.h"
#include "wx/intl.h"
#endif
-#if USE_SCROLLBAR
+#if wxUSE_RADIOBTN
+#include "wx/radiobut.h"
+#endif
+
+#if wxUSE_SCROLLBAR
#include "wx/scrolbar.h"
#endif
-#if USE_COMBOBOX
+#if wxUSE_COMBOBOX
#include "wx/combobox.h"
#endif
#include "wx/log.h"
-#if USE_WX_RESOURCES
-
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#include "wx/string.h"
#include "wx/wxexpr.h"
+#include "wx/settings.h"
+
// Forward (private) declarations
-bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db);
-wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel = FALSE);
-wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr);
-wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr);
-wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr);
-wxItemResource *wxResourceInterpretString(wxResourceTable& table, PrologExpr *expr);
-wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, PrologExpr *expr);
-wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr);
+bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db);
+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);
+wxItemResource *wxResourceInterpretString(wxResourceTable& table, wxExpr *expr);
+wxItemResource *wxResourceInterpretBitmap(wxResourceTable& table, wxExpr *expr);
+wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr);
// Interpret list expression
-wxFont *wxResourceInterpretFontSpec(PrologExpr *expr);
+wxFont wxResourceInterpretFontSpec(wxExpr *expr);
-bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table = NULL);
-bool wxResourceParseIncludeFile(char *f, wxResourceTable *table = NULL);
+bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table = (wxResourceTable *) NULL);
+bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table = (wxResourceTable *) NULL);
-wxResourceTable *wxDefaultResourceTable = NULL;
+wxResourceTable *wxDefaultResourceTable = (wxResourceTable *) NULL;
-static char *wxResourceBuffer = NULL;
-static long wxResourceBufferSize = 0;
-static long wxResourceBufferCount = 0;
-static int wxResourceStringPtr = 0;
+char *wxResourceBuffer = (char *) NULL;
+long wxResourceBufferSize = 0;
+long wxResourceBufferCount = 0;
+int wxResourceStringPtr = 0;
-void wxInitializeResourceSystem(void)
+void wxInitializeResourceSystem()
{
wxDefaultResourceTable = new wxResourceTable;
}
-void wxCleanUpResourceSystem(void)
+void wxCleanUpResourceSystem()
{
delete wxDefaultResourceTable;
+ if (wxResourceBuffer)
+ delete[] wxResourceBuffer;
}
void wxLogWarning(char *msg)
IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable)
#endif
-wxItemResource::wxItemResource(void)
+wxItemResource::wxItemResource()
{
- itemType = NULL;
- title = NULL;
- name = NULL;
- windowStyle = 0;
- x = y = width = height = 0;
- value1 = value2 = value3 = value5 = 0;
- value4 = NULL;
- stringValues = NULL;
- bitmap = NULL;
- backgroundColour = labelColour = buttonColour = NULL;
- windowFont = NULL;
+ m_itemType = "";
+ m_title = "";
+ m_name = "";
+ m_windowStyle = 0;
+ m_x = m_y = m_width = m_height = 0;
+ m_value1 = m_value2 = m_value3 = m_value5 = 0;
+ m_value4 = "";
m_windowId = 0;
+ m_exStyle = 0;
}
-wxItemResource::~wxItemResource(void)
+wxItemResource::~wxItemResource()
{
- if (itemType) delete[] itemType;
- if (title) delete[] title;
- if (name) delete[] name;
- if (value4) delete[] value4;
- if (stringValues)
- delete stringValues;
- if (bitmap)
- delete bitmap;
- if (backgroundColour)
- delete backgroundColour;
- if (labelColour)
- delete labelColour;
- if (buttonColour)
- delete buttonColour;
- wxNode *node = children.First();
+ wxNode *node = m_children.First();
while (node)
{
wxItemResource *item = (wxItemResource *)node->Data();
delete item;
delete node;
- node = children.First();
+ node = m_children.First();
}
}
-void wxItemResource::SetTitle(char *t)
-{
- if (t == title)
- return;
-
- if (title) delete[] title;
- if (t)
- title = copystring(t);
- else
- title = NULL;
-}
-
-void wxItemResource::SetType(char *t)
-{
- if (itemType == t)
- return;
-
- if (itemType) delete[] itemType;
- if (t)
- itemType = copystring(t);
- else
- itemType = NULL;
-}
-
-void wxItemResource::SetName(char *n)
-{
- if (n == name)
- return;
-
- if (name) delete[] name;
- if (n)
- name = copystring(n);
- else
- name = NULL;
-}
-
-void wxItemResource::SetStringValues(wxStringList *svalues)
-{
- if (stringValues)
- delete stringValues;
- if (svalues)
- stringValues = svalues;
- else
- stringValues = NULL;
-}
-
-void wxItemResource::SetValue4(char *v)
-{
- if (value4 == v)
- return;
-
- if (value4) delete[] value4;
- if (v)
- value4 = copystring(v);
- else
- value4 = NULL;
-}
-
/*
* Resource table
*/
-
-wxResourceTable::wxResourceTable(void):wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING)
+
+wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING)
{
}
-wxResourceTable::~wxResourceTable(void)
+wxResourceTable::~wxResourceTable()
{
ClearTable();
}
-
+
wxItemResource *wxResourceTable::FindResource(const wxString& name) const
{
- wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name);
+ wxItemResource *item = (wxItemResource *)Get(WXSTRINGCAST name);
return item;
}
void wxResourceTable::AddResource(wxItemResource *item)
{
- char *name = item->GetName();
- if (!name)
+ wxString name = item->GetName();
+ if (name == T(""))
name = item->GetTitle();
- if (!name)
- name = "no name";
+ if (name == T(""))
+ name = T("no name");
// Delete existing resource, if any.
Delete(name);
bool wxResourceTable::DeleteResource(const wxString& name)
{
- wxItemResource *item = (wxItemResource *)Delete((char *)(const char *)name);
+ wxItemResource *item = (wxItemResource *)Delete(WXSTRINGCAST name);
if (item)
{
// See if any resource has this as its child; if so, delete from
// parent's child list.
BeginFind();
- wxNode *node = NULL;
- while ((node = Next()))
+ wxNode *node = (wxNode *) NULL;
+ node = Next();
+ while (node != NULL)
{
wxItemResource *parent = (wxItemResource *)node->Data();
if (parent->GetChildren().Member(item))
parent->GetChildren().DeleteObject(item);
break;
}
+ node = Next();
}
-
+
delete item;
return TRUE;
}
return FALSE;
}
-bool wxResourceTable::ParseResourceFile(char *filename)
+bool wxResourceTable::ParseResourceFile(const wxString& filename)
{
- PrologDatabase db;
+ wxExprDatabase db;
- FILE *fd = fopen(filename, "r");
+ FILE *fd = fopen(filename.fn_str(), "r");
if (!fd)
return FALSE;
bool eof = FALSE;
return wxResourceInterpretResources(*this, db);
}
-bool wxResourceTable::ParseResourceData(char *data)
+bool wxResourceTable::ParseResourceData(const wxString& data)
{
- PrologDatabase db;
- if (!db.ReadPrologFromString(data))
+ wxExprDatabase db;
+ if (!db.ReadFromString(data))
{
wxLogWarning(_("Ill-formed resource file syntax."));
return FALSE;
return wxResourceInterpretResources(*this, db);
}
-bool wxResourceTable::RegisterResourceBitmapData(char *name, char bits[], int width, int height)
+bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char bits[], int width, int height)
{
// Register pre-loaded bitmap data
wxItemResource *item = new wxItemResource;
// item->SetType(wxRESOURCE_TYPE_XBM_DATA);
- item->SetType("wxXBMData");
+ item->SetType(T("wxXBMData"));
item->SetName(name);
item->SetValue1((long)bits);
item->SetValue2((long)width);
return TRUE;
}
-bool wxResourceTable::RegisterResourceBitmapData(char *name, char **data)
+bool wxResourceTable::RegisterResourceBitmapData(const wxString& name, char **data)
{
// Register pre-loaded bitmap data
wxItemResource *item = new wxItemResource;
// item->SetType(wxRESOURCE_TYPE_XPM_DATA);
- item->SetType("wxXPMData");
+ item->SetType(T("wxXPMData"));
item->SetName(name);
item->SetValue1((long)data);
AddResource(item);
return TRUE;
}
-bool wxResourceTable::SaveResource(char *WXUNUSED(filename))
+bool wxResourceTable::SaveResource(const wxString& WXUNUSED(filename))
{
return FALSE;
}
-void wxResourceTable::ClearTable(void)
+void wxResourceTable::ClearTable()
{
BeginFind();
wxNode *node = Next();
}
}
-wxControl *wxResourceTable::CreateItem(wxWindow *parent, wxItemResource *childResource) const
+wxControl *wxResourceTable::CreateItem(wxWindow *parent, const wxItemResource* childResource, const wxItemResource* parentResource) const
{
int id = childResource->GetId();
if ( id == 0 )
id = -1;
- wxControl *control = NULL;
+ bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0);
+
+ wxControl *control = (wxControl *) NULL;
wxString itemType(childResource->GetType());
- if (itemType == wxString("wxButton") || itemType == wxString("wxBitmapButton"))
+
+ wxPoint pos;
+ wxSize size;
+ if (dlgUnits)
+ {
+ pos = parent->ConvertDialogToPixels(wxPoint(childResource->GetX(), childResource->GetY()));
+ size = parent->ConvertDialogToPixels(wxSize(childResource->GetWidth(), childResource->GetHeight()));
+ }
+ else
+ {
+ pos = wxPoint(childResource->GetX(), childResource->GetY());
+ size = wxSize(childResource->GetWidth(), childResource->GetHeight());
+ }
+
+ if (itemType == wxString(T("wxButton")) || itemType == wxString(T("wxBitmapButton")))
{
- if (childResource->GetValue4())
+ if (childResource->GetValue4() != T(""))
{
// Bitmap button
- wxBitmap *bitmap = childResource->GetBitmap();
- if (!bitmap)
+ wxBitmap bitmap = childResource->GetBitmap();
+ if (!bitmap.Ok())
{
bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this);
- childResource->SetBitmap(bitmap);
+ ((wxItemResource*) childResource)->SetBitmap(bitmap);
}
- if (bitmap)
- control = new wxBitmapButton(parent, id, *bitmap,
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ if (bitmap.Ok())
+ control = new wxBitmapButton(parent, id, bitmap, pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
}
else
// Normal, text button
- control = new wxButton(parent, id, childResource->GetTitle(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxButton(parent, id, childResource->GetTitle(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
}
- else if (itemType == wxString("wxMessage") || itemType == wxString("wxStaticText") ||
- itemType == wxString("wxStaticBitmap"))
+ else if (itemType == wxString(T("wxMessage")) || itemType == wxString(T("wxStaticText")) ||
+ itemType == wxString(T("wxStaticBitmap")))
{
- if (childResource->GetValue4())
+ if (childResource->GetValue4() != T(""))
{
// Bitmap message
- wxBitmap *bitmap = childResource->GetBitmap();
- if (!bitmap)
+ wxBitmap bitmap = childResource->GetBitmap();
+ if (!bitmap.Ok())
{
bitmap = wxResourceCreateBitmap(childResource->GetValue4(), (wxResourceTable *)this);
- childResource->SetBitmap(bitmap);
+ ((wxItemResource*) childResource)->SetBitmap(bitmap);
}
-#if USE_BITMAP_MESSAGE
- if (bitmap)
- control = new wxStaticBitmap(parent, id, *bitmap,
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+#if wxUSE_BITMAP_MESSAGE
+ if (bitmap.Ok())
+ control = new wxStaticBitmap(parent, id, bitmap, pos, size,
childResource->GetStyle(), childResource->GetName());
#endif
}
else
{
- control = new wxStaticText(parent, id, childResource->GetTitle(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxStaticText(parent, id, childResource->GetTitle(), pos, size,
childResource->GetStyle(), childResource->GetName());
}
}
- else if (itemType == wxString("wxText") || itemType == wxString("wxTextCtrl") || itemType == wxString("wxMultiText"))
+ else if (itemType == wxString(T("wxText")) || itemType == wxString(T("wxTextCtrl")) || itemType == wxString(T("wxMultiText")))
{
- control = new wxTextCtrl(parent, id, childResource->GetValue4(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxTextCtrl(parent, id, childResource->GetValue4(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
}
- else if (itemType == wxString("wxCheckBox"))
+ else if (itemType == wxString(T("wxCheckBox")))
{
- control = new wxCheckBox(parent, id, childResource->GetTitle(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxCheckBox(parent, id, childResource->GetTitle(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
((wxCheckBox *)control)->SetValue((childResource->GetValue1() != 0));
}
-#if USE_GAUGE
- else if (itemType == wxString("wxGauge"))
+#if wxUSE_GAUGE
+ else if (itemType == wxString(T("wxGauge")))
{
- control = new wxGauge(parent, id, (int)childResource->GetValue2(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxGauge(parent, id, (int)childResource->GetValue2(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
((wxGauge *)control)->SetValue((int)childResource->GetValue1());
}
#endif
-#if USE_RADIOBUTTON
- else if (itemType == wxString("wxRadioButton"))
+#if wxUSE_RADIOBTN
+ else if (itemType == wxString(T("wxRadioButton")))
{
control = new wxRadioButton(parent, id, childResource->GetTitle(), // (int)childResource->GetValue1(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
}
#endif
-#if USE_SCROLLBAR
- else if (itemType == wxString("wxScrollBar"))
+#if wxUSE_SCROLLBAR
+ else if (itemType == wxString(T("wxScrollBar")))
{
- control = new wxScrollBar(parent, id,
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxScrollBar(parent, id, pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
+/*
((wxScrollBar *)control)->SetValue((int)childResource->GetValue1());
((wxScrollBar *)control)->SetPageSize((int)childResource->GetValue2());
((wxScrollBar *)control)->SetObjectLength((int)childResource->GetValue3());
((wxScrollBar *)control)->SetViewLength((int)(long)childResource->GetValue5());
+*/
+ ((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(),
+ (int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE);
+
}
#endif
- else if (itemType == wxString("wxSlider"))
+ else if (itemType == wxString(T("wxSlider")))
{
control = new wxSlider(parent, id, (int)childResource->GetValue1(),
- (int)childResource->GetValue2(), (int)childResource->GetValue3(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ (int)childResource->GetValue2(), (int)childResource->GetValue3(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
}
- else if (itemType == wxString("wxGroupBox") || itemType == wxString("wxStaticBox"))
+ else if (itemType == wxString(T("wxGroupBox")) || itemType == wxString(T("wxStaticBox")))
{
- control = new wxStaticBox(parent, id, childResource->GetTitle(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxStaticBox(parent, id, childResource->GetTitle(), pos, size,
childResource->GetStyle(), childResource->GetName());
}
- else if (itemType == wxString("wxListBox"))
+ else if (itemType == wxString(T("wxListBox")))
{
- wxStringList *stringList = childResource->GetStringValues();
- wxString *strings = NULL;
+ wxStringList& stringList = childResource->GetStringValues();
+ wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList && (stringList->Number() > 0))
+ if (stringList.Number() > 0)
{
- noStrings = stringList->Number();
+ noStrings = stringList.Number();
strings = new wxString[noStrings];
- wxNode *node = stringList->First();
+ wxNode *node = stringList.First();
int i = 0;
while (node)
{
- strings[i] = (char *)node->Data();
+ strings[i] = (wxChar *)node->Data();
i ++;
node = node->Next();
}
}
- control = new wxListBox(parent, id,
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxListBox(parent, id, pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
if (strings)
delete[] strings;
}
- else if (itemType == wxString("wxChoice"))
+ else if (itemType == wxString(T("wxChoice")))
{
- wxStringList *stringList = childResource->GetStringValues();
- wxString *strings = NULL;
+ wxStringList& stringList = childResource->GetStringValues();
+ wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList && (stringList->Number() > 0))
+ if (stringList.Number() > 0)
{
- noStrings = stringList->Number();
+ noStrings = stringList.Number();
strings = new wxString[noStrings];
- wxNode *node = stringList->First();
+ wxNode *node = stringList.First();
int i = 0;
while (node)
{
- strings[i] = (char *)node->Data();
+ strings[i] = (wxChar *)node->Data();
i ++;
node = node->Next();
}
}
- control = new wxChoice(parent, id,
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxChoice(parent, id, pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
if (strings)
delete[] strings;
}
-#if USE_COMBOBOX
- else if (itemType == wxString("wxComboBox"))
+#if wxUSE_COMBOBOX
+ else if (itemType == wxString(T("wxComboBox")))
{
- wxStringList *stringList = childResource->GetStringValues();
- wxString *strings = NULL;
+ wxStringList& stringList = childResource->GetStringValues();
+ wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList && (stringList->Number() > 0))
+ if (stringList.Number() > 0)
{
- noStrings = stringList->Number();
+ noStrings = stringList.Number();
strings = new wxString[noStrings];
- wxNode *node = stringList->First();
+ wxNode *node = stringList.First();
int i = 0;
while (node)
{
- strings[i] = (char *)node->Data();
+ strings[i] = (wxChar *)node->Data();
i ++;
node = node->Next();
}
}
- control = new wxComboBox(parent, id, childResource->GetValue4(),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
if (strings)
delete[] strings;
}
#endif
- else if (itemType == wxString("wxRadioBox"))
+ else if (itemType == wxString(T("wxRadioBox")))
{
- wxStringList *stringList = childResource->GetStringValues();
- wxString *strings = NULL;
+ wxStringList& stringList = childResource->GetStringValues();
+ wxString *strings = (wxString *) NULL;
int noStrings = 0;
- if (stringList && (stringList->Number() > 0))
+ if (stringList.Number() > 0)
{
- noStrings = stringList->Number();
+ noStrings = stringList.Number();
strings = new wxString[noStrings];
- wxNode *node = stringList->First();
+ wxNode *node = stringList.First();
int i = 0;
while (node)
{
- strings[i] = (char *)node->Data();
+ strings[i] = (wxChar *)node->Data();
i ++;
node = node->Next();
}
}
- control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()),
- wxPoint(childResource->GetX(), childResource->GetY()),
- wxSize(childResource->GetWidth(), childResource->GetHeight()),
+ control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size,
noStrings, strings, (int)childResource->GetValue1(), childResource->GetStyle(), wxDefaultValidator,
childResource->GetName());
delete[] strings;
}
- if (control && childResource->GetFont())
- control->SetFont(*childResource->GetFont());
+ if ((parentResource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
+ {
+ // Don't set font; will be inherited from parent.
+ }
+ else
+ {
+ if (control && childResource->GetFont().Ok())
+ control->SetFont(childResource->GetFont());
+ }
return control;
}
* Interpret database as a series of resources
*/
-bool wxResourceInterpretResources(wxResourceTable& table, PrologDatabase& db)
+bool wxResourceInterpretResources(wxResourceTable& table, wxExprDatabase& db)
{
wxNode *node = db.First();
while (node)
{
- PrologExpr *clause = (PrologExpr *)node->Data();
+ wxExpr *clause = (wxExpr *)node->Data();
wxString functor(clause->Functor());
- wxItemResource *item = NULL;
- if (functor == "dialog")
+ wxItemResource *item = (wxItemResource *) NULL;
+ if (functor == T("dialog"))
item = wxResourceInterpretDialog(table, clause);
- else if (functor == "panel")
+ else if (functor == T("panel"))
item = wxResourceInterpretDialog(table, clause, TRUE);
- else if (functor == "menubar")
+ else if (functor == T("menubar"))
item = wxResourceInterpretMenuBar(table, clause);
- else if (functor == "menu")
+ else if (functor == T("menu"))
item = wxResourceInterpretMenu(table, clause);
- else if (functor == "string")
+ else if (functor == T("string"))
item = wxResourceInterpretString(table, clause);
- else if (functor == "bitmap")
+ else if (functor == T("bitmap"))
item = wxResourceInterpretBitmap(table, clause);
- else if (functor == "icon")
+ else if (functor == T("icon"))
item = wxResourceInterpretIcon(table, clause);
if (item)
{
// Remove any existing resource of same name
- if (item->GetName())
+ if (item->GetName() != T(""))
table.DeleteResource(item->GetName());
table.AddResource(item);
}
return TRUE;
}
-static char *g_ValidControlClasses[] = { "wxButton", "wxBitmapButton", "wxMessage",
- "wxStaticText", "wxStaticBitmap", "wxText", "wxTextCtrl", "wxMultiText",
- "wxListBox", "wxRadioBox", "wxRadioButton", "wxCheckBox", "wxBitmapCheckBox",
- "wxGroupBox", "wxStaticBox", "wxSlider", "wxGauge", "wxScrollBar",
- "wxChoice", "wxComboBox" } ;
-static int g_ValidControlClassesCount = sizeof(g_ValidControlClasses) / sizeof(char *) ;
+static const wxChar *g_ValidControlClasses[] =
+{
+ T("wxButton"),
+ T("wxBitmapButton"),
+ T("wxMessage"),
+ T("wxStaticText"),
+ T("wxStaticBitmap"),
+ T("wxText"),
+ T("wxTextCtrl"),
+ T("wxMultiText"),
+ T("wxListBox"),
+ T("wxRadioBox"),
+ T("wxRadioButton"),
+ T("wxCheckBox"),
+ T("wxBitmapCheckBox"),
+ T("wxGroupBox"),
+ T("wxStaticBox"),
+ T("wxSlider"),
+ T("wxGauge"),
+ T("wxScrollBar"),
+ T("wxChoice"),
+ T("wxComboBox")
+};
static bool wxIsValidControlClass(const wxString& c)
{
- int i;
- for ( i = 0; i < g_ValidControlClassesCount; i++)
+ for ( size_t i = 0; i < WXSIZEOF(g_ValidControlClasses); i++ )
{
if ( c == g_ValidControlClasses[i] )
return TRUE;
return FALSE;
}
-wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, PrologExpr *expr, bool isPanel)
+wxItemResource *wxResourceInterpretDialog(wxResourceTable& table, wxExpr *expr, bool isPanel)
{
wxItemResource *dialogItem = new wxItemResource;
if (isPanel)
- dialogItem->SetType("wxPanel");
+ dialogItem->SetType(T("wxPanel"));
else
- dialogItem->SetType("wxDialog");
- char *style = NULL;
- char *title = NULL;
- char *name = NULL;
- char *backColourHex = NULL;
- char *labelColourHex = NULL;
- char *buttonColourHex = NULL;
+ dialogItem->SetType(T("wxDialog"));
+ wxString style = T("");
+ wxString title = T("");
+ wxString name = T("");
+ wxString backColourHex = T("");
+ wxString labelColourHex = T("");
+ wxString buttonColourHex = T("");
long windowStyle = wxDEFAULT_DIALOG_STYLE;
if (isPanel)
windowStyle = 0;
-
+
int x = 0; int y = 0; int width = -1; int height = -1;
int isModal = 0;
- PrologExpr *labelFontExpr = NULL;
- PrologExpr *buttonFontExpr = NULL;
- PrologExpr *fontExpr = NULL;
- expr->AssignAttributeValue("style", &style);
- expr->AssignAttributeValue("name", &name);
- expr->AssignAttributeValue("title", &title);
- expr->AssignAttributeValue("x", &x);
- expr->AssignAttributeValue("y", &y);
- expr->AssignAttributeValue("width", &width);
- expr->AssignAttributeValue("height", &height);
- expr->AssignAttributeValue("modal", &isModal);
- expr->AssignAttributeValue("label_font", &labelFontExpr);
- expr->AssignAttributeValue("button_font", &buttonFontExpr);
- expr->AssignAttributeValue("font", &fontExpr);
- expr->AssignAttributeValue("background_colour", &backColourHex);
- expr->AssignAttributeValue("label_colour", &labelColourHex);
- expr->AssignAttributeValue("button_colour", &buttonColourHex);
+ wxExpr *labelFontExpr = (wxExpr *) NULL;
+ wxExpr *buttonFontExpr = (wxExpr *) NULL;
+ wxExpr *fontExpr = (wxExpr *) NULL;
+ expr->GetAttributeValue(T("style"), style);
+ expr->GetAttributeValue(T("name"), name);
+ expr->GetAttributeValue(T("title"), title);
+ expr->GetAttributeValue(T("x"), x);
+ expr->GetAttributeValue(T("y"), y);
+ expr->GetAttributeValue(T("width"), width);
+ expr->GetAttributeValue(T("height"), height);
+ expr->GetAttributeValue(T("modal"), isModal);
+ expr->GetAttributeValue(T("label_font"), &labelFontExpr);
+ expr->GetAttributeValue(T("button_font"), &buttonFontExpr);
+ expr->GetAttributeValue(T("font"), &fontExpr);
+ expr->GetAttributeValue(T("background_colour"), backColourHex);
+ expr->GetAttributeValue(T("label_colour"), labelColourHex);
+ expr->GetAttributeValue(T("button_colour"), buttonColourHex);
+
+ int useDialogUnits = 0;
+ expr->GetAttributeValue(T("use_dialog_units"), useDialogUnits);
+ if (useDialogUnits != 0)
+ dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS);
+
+ int useDefaults = 0;
+ expr->GetAttributeValue(T("use_system_defaults"), useDefaults);
+ if (useDefaults != 0)
+ dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS);
long id = 0;
- expr->GetAttributeValue("id", id);
+ expr->GetAttributeValue(T("id"), id);
dialogItem->SetId(id);
- if (style)
+ if (style != T(""))
{
windowStyle = wxParseWindowStyle(style);
}
dialogItem->SetStyle(windowStyle);
dialogItem->SetValue1(isModal);
- if (name)
- dialogItem->SetName(name);
- if (title)
- dialogItem->SetTitle(title);
+ if (windowStyle & wxDIALOG_MODAL) // Uses style in wxWin 2
+ dialogItem->SetValue1(TRUE);
+
+ dialogItem->SetName(name);
+ dialogItem->SetTitle(title);
dialogItem->SetSize(x, y, width, height);
-
- if (backColourHex)
+
+ if (backColourHex != T(""))
{
int r = 0;
int g = 0;
int b = 0;
- r = wxHexToDec(backColourHex);
- g = wxHexToDec(backColourHex+2);
- b = wxHexToDec(backColourHex+4);
- dialogItem->SetBackgroundColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
- delete[] backColourHex;
+ r = wxHexToDec(backColourHex.Mid(0, 2));
+ g = wxHexToDec(backColourHex.Mid(2, 2));
+ b = wxHexToDec(backColourHex.Mid(4, 2));
+ dialogItem->SetBackgroundColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
- if (labelColourHex)
+ if (labelColourHex != T(""))
{
int r = 0;
int g = 0;
int b = 0;
- r = wxHexToDec(labelColourHex);
- g = wxHexToDec(labelColourHex+2);
- b = wxHexToDec(labelColourHex+4);
- dialogItem->SetLabelColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
- delete[] labelColourHex;
+ r = wxHexToDec(labelColourHex.Mid(0, 2));
+ g = wxHexToDec(labelColourHex.Mid(2, 2));
+ b = wxHexToDec(labelColourHex.Mid(4, 2));
+ dialogItem->SetLabelColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
- if (buttonColourHex)
+ if (buttonColourHex != T(""))
{
int r = 0;
int g = 0;
int b = 0;
- r = wxHexToDec(buttonColourHex);
- g = wxHexToDec(buttonColourHex+2);
- b = wxHexToDec(buttonColourHex+4);
- dialogItem->SetButtonColour(new wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
- delete[] buttonColourHex;
+ r = wxHexToDec(buttonColourHex.Mid(0, 2));
+ g = wxHexToDec(buttonColourHex.Mid(2, 2));
+ b = wxHexToDec(buttonColourHex.Mid(4, 2));
+ dialogItem->SetButtonColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
- if (name)
- delete[] name;
- if (title)
- delete[] title;
- if (style)
- delete[] style;
-
if (fontExpr)
dialogItem->SetFont(wxResourceInterpretFontSpec(fontExpr));
else if (buttonFontExpr)
dialogItem->SetFont(wxResourceInterpretFontSpec(labelFontExpr));
// Now parse all controls
- PrologExpr *controlExpr = expr->GetFirst();
+ wxExpr *controlExpr = expr->GetFirst();
while (controlExpr)
{
if (controlExpr->Number() == 3)
{
wxString controlKeyword(controlExpr->Nth(1)->StringValue());
- if (controlKeyword != "" && controlKeyword == "control")
+ if (controlKeyword != T("") && controlKeyword == T("control"))
{
// The value part: always a list.
- PrologExpr *listExpr = controlExpr->Nth(2);
+ wxExpr *listExpr = controlExpr->Nth(2);
if (listExpr->Type() == PrologList)
{
wxItemResource *controlItem = wxResourceInterpretControl(table, listExpr);
return dialogItem;
}
-wxItemResource *wxResourceInterpretControl(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *controlItem = new wxItemResource;
int x = 0; int y = 0; int width = -1; int height = -1;
int count = 0;
- PrologExpr *expr1 = expr->Nth(0);
+ wxExpr *expr1 = expr->Nth(0);
if ( expr1->Type() == PrologString || expr1->Type() == PrologWord )
{
else
{
wxString str(expr1->StringValue());
- id = wxResourceGetIdentifier(WXSTRINGCAST str, &table);
+ id = wxResourceGetIdentifier(str, &table);
if (id == 0)
{
wxLogWarning(_("Could not resolve control class or id '%s'. "
"Use (non-zero) integer instead\n or provide #define "
"(see manual for caveats)"),
- (const char*) expr1->StringValue());
+ (const wxChar*) expr1->StringValue());
delete controlItem;
- return NULL;
+ return (wxItemResource *) NULL;
}
else
{
if (expr1)
{
style = expr1->StringValue();
- windowStyle = wxParseWindowStyle(WXSTRINGCAST style);
+ windowStyle = wxParseWindowStyle(style);
}
expr1 = expr->Nth(count);
height = (int)expr1->IntegerValue();
controlItem->SetStyle(windowStyle);
- controlItem->SetName(WXSTRINGCAST name);
- controlItem->SetTitle(WXSTRINGCAST title);
+ controlItem->SetName(name);
+ controlItem->SetTitle(title);
controlItem->SetSize(x, y, width, height);
- controlItem->SetType(WXSTRINGCAST controlType);
+ controlItem->SetType(controlType);
controlItem->SetId(id);
- if (controlType == "wxButton")
+ if (controlType == T("wxButton"))
+ {
+ // Check for bitmap resource name (in case loading old-style resource file)
+ if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord)))
+ {
+ wxString str(expr->Nth(count)->StringValue());
+ count ++;
+
+ if (str != T(""))
+ {
+ controlItem->SetValue4(str);
+ controlItem->SetType(T("wxBitmapButton"));
+ }
+ }
+ if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
+ controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
+ }
+ else if (controlType == T("wxBitmapButton"))
{
// Check for bitmap resource name
if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord)))
{
wxString str(expr->Nth(count)->StringValue());
- controlItem->SetValue4(WXSTRINGCAST str);
+ controlItem->SetValue4(str);
count ++;
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
}
- else if (controlType == "wxCheckBox")
+ else if (controlType == T("wxCheckBox"))
{
// Check for default value
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
}
-#if USE_RADIOBUTTON
- else if (controlType == "wxRadioButton")
+#if wxUSE_RADIOBTN
+ else if (controlType == T("wxRadioButton"))
{
// Check for default value
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
}
}
#endif
- else if (controlType == "wxText" || controlType == "wxTextCtrl")
+ else if (controlType == T("wxText") || controlType == T("wxTextCtrl") || controlType == T("wxMultiText"))
{
// Check for default value
if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord)))
{
wxString str(expr->Nth(count)->StringValue());
- controlItem->SetValue4(WXSTRINGCAST str);
+ controlItem->SetValue4(str);
count ++;
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
}
}
}
- else if (controlType == "wxMessage" || controlType == "wxStaticText")
+ else if (controlType == T("wxMessage") || controlType == T("wxStaticText"))
+ {
+ // Check for bitmap resource name (in case it's an old-style .wxr file)
+ if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord)))
+ {
+ wxString str(expr->Nth(count)->StringValue());
+ controlItem->SetValue4(str);
+ count ++;
+ controlItem->SetType(T("wxStaticText"));
+ }
+ if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
+ controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
+ }
+ else if (controlType == T("wxStaticBitmap"))
{
// Check for bitmap resource name
if (expr->Nth(count) && ((expr->Nth(count)->Type() == PrologString) || (expr->Nth(count)->Type() == PrologWord)))
{
wxString str(expr->Nth(count)->StringValue());
- controlItem->SetValue4(WXSTRINGCAST str);
+ controlItem->SetValue4(str);
count ++;
- if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
- controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
+ if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
+ controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
- else if (controlType == "wxGroupBox" || controlType == "wxStaticBox")
+ else if (controlType == T("wxGroupBox") || controlType == T("wxStaticBox"))
{
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
- else if (controlType == "wxGauge")
+ else if (controlType == T("wxGauge"))
{
// Check for default value
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
}
}
}
- else if (controlType == "wxSlider")
+ else if (controlType == T("wxSlider"))
{
// Check for default value
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
}
}
}
- else if (controlType == "wxScrollBar")
+ else if (controlType == T("wxScrollBar"))
{
// DEFAULT VALUE
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
}
}
}
- else if (controlType == "wxListBox")
+ else if (controlType == T("wxListBox"))
{
- PrologExpr *valueList = NULL;
+ wxExpr *valueList = (wxExpr *) NULL;
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
{
- wxStringList *stringList = new wxStringList;
- PrologExpr *stringExpr = valueList->GetFirst();
+ wxStringList stringList;
+ wxExpr *stringExpr = valueList->GetFirst();
while (stringExpr)
{
- stringList->Add(stringExpr->StringValue());
+ stringList.Add(stringExpr->StringValue());
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
count ++;
-
+// This is now obsolete: it's in the window style.
// Check for wxSINGLE/wxMULTIPLE
- PrologExpr *mult = NULL;
+ wxExpr *mult = (wxExpr *) NULL;
+/*
controlItem->SetValue1(wxLB_SINGLE);
+*/
if ((mult = expr->Nth(count)) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord)))
{
+/*
wxString m(mult->StringValue());
- if (m == "wxMULTIPLE")
+ if (m == "wxLB_MULTIPLE")
controlItem->SetValue1(wxLB_MULTIPLE);
- else if (m == "wxEXTENDED")
+ else if (m == "wxLB_EXTENDED")
controlItem->SetValue1(wxLB_EXTENDED);
+*/
+ // Ignore the value
count ++;
- if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
- {
- // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
+ }
+ if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
+ {
+ // controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
count ++;
- if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
- controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
- }
- }
+ if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
+ controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
+ }
}
}
- else if (controlType == "wxChoice")
+ else if (controlType == T("wxChoice"))
{
- PrologExpr *valueList = NULL;
+ wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
{
- wxStringList *stringList = new wxStringList;
- PrologExpr *stringExpr = valueList->GetFirst();
+ wxStringList stringList;
+ wxExpr *stringExpr = valueList->GetFirst();
while (stringExpr)
{
- stringList->Add(stringExpr->StringValue());
+ stringList.Add(stringExpr->StringValue());
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
}
}
}
-#if USE_COMBOBOX
- else if (controlType == "wxComboBox")
+#if wxUSE_COMBOBOX
+ else if (controlType == T("wxComboBox"))
{
- PrologExpr *textValue = expr->Nth(count);
+ wxExpr *textValue = expr->Nth(count);
if (textValue && (textValue->Type() == PrologString || textValue->Type() == PrologWord))
{
wxString str(textValue->StringValue());
- controlItem->SetValue4(WXSTRINGCAST str);
+ controlItem->SetValue4(str);
count ++;
-
- PrologExpr *valueList = NULL;
+
+ wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
{
- wxStringList *stringList = new wxStringList;
- PrologExpr *stringExpr = valueList->GetFirst();
+ wxStringList stringList;
+ wxExpr *stringExpr = valueList->GetFirst();
while (stringExpr)
{
- stringList->Add(stringExpr->StringValue());
+ stringList.Add(stringExpr->StringValue());
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
}
}
#endif
-#if 0
- else if (controlType == "wxRadioBox")
+#if 1
+ else if (controlType == T("wxRadioBox"))
{
- PrologExpr *valueList = NULL;
+ wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
{
- wxStringList *stringList = new wxStringList;
- PrologExpr *stringExpr = valueList->GetFirst();
+ wxStringList stringList;
+ wxExpr *stringExpr = valueList->GetFirst();
while (stringExpr)
{
- stringList->Add(stringExpr->StringValue());
+ stringList.Add(stringExpr->StringValue());
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
else
{
delete controlItem;
- return NULL;
+ return (wxItemResource *) NULL;
}
return controlItem;
}
-// Forward declaration
-wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr);
+// Forward declaration
+wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr);
/*
* Interpet a menu item
*/
-wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *item = new wxItemResource;
-
- PrologExpr *labelExpr = expr->Nth(0);
- PrologExpr *idExpr = expr->Nth(1);
- PrologExpr *helpExpr = expr->Nth(2);
- PrologExpr *checkableExpr = expr->Nth(3);
+
+ wxExpr *labelExpr = expr->Nth(0);
+ wxExpr *idExpr = expr->Nth(1);
+ wxExpr *helpExpr = expr->Nth(2);
+ wxExpr *checkableExpr = expr->Nth(3);
// Further keywords/attributes to follow sometime...
if (expr->Number() == 0)
{
// item->SetType(wxRESOURCE_TYPE_SEPARATOR);
- item->SetType("wxMenuSeparator");
+ item->SetType(T("wxMenuSeparator"));
return item;
}
else
{
// item->SetType(wxTYPE_MENU); // Well, menu item, but doesn't matter.
- item->SetType("wxMenu"); // Well, menu item, but doesn't matter.
+ item->SetType(T("wxMenu")); // Well, menu item, but doesn't matter.
if (labelExpr)
{
wxString str(labelExpr->StringValue());
- item->SetTitle(WXSTRINGCAST str);
+ item->SetTitle(str);
}
if (idExpr)
{
if ((idExpr->Type() == PrologString) || (idExpr->Type() == PrologWord))
{
wxString str(idExpr->StringValue());
- id = wxResourceGetIdentifier(WXSTRINGCAST str, &table);
+ id = wxResourceGetIdentifier(str, &table);
if (id == 0)
{
wxLogWarning(_("Could not resolve menu id '%s'. "
"Use (non-zero) integer instead\n"
"or provide #define (see manual for caveats)"),
- (const char*) idExpr->StringValue());
+ (const wxChar*) idExpr->StringValue());
}
}
else if (idExpr->Type() == PrologInteger)
if (helpExpr)
{
wxString str(helpExpr->StringValue());
- item->SetValue4(WXSTRINGCAST str);
+ item->SetValue4(str);
}
if (checkableExpr)
item->SetValue2(checkableExpr->IntegerValue());
// Find the first expression that's a list, for submenu
- PrologExpr *subMenuExpr = expr->GetFirst();
+ wxExpr *subMenuExpr = expr->GetFirst();
while (subMenuExpr && (subMenuExpr->Type() != PrologList))
subMenuExpr = subMenuExpr->GetNext();
-
+
while (subMenuExpr)
{
wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr);
* Interpret a nested list as a menu
*/
/*
-wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *menu = new wxItemResource;
// menu->SetType(wxTYPE_MENU);
menu->SetType("wxMenu");
- PrologExpr *element = expr->GetFirst();
+ wxExpr *element = expr->GetFirst();
while (element)
{
wxItemResource *item = wxResourceInterpretMenuItem(table, element);
}
*/
-wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretMenu(wxResourceTable& table, wxExpr *expr)
{
- PrologExpr *listExpr = NULL;
- expr->AssignAttributeValue("menu", &listExpr);
+ wxExpr *listExpr = (wxExpr *) NULL;
+ expr->GetAttributeValue(T("menu"), &listExpr);
if (!listExpr)
- return NULL;
-
+ return (wxItemResource *) NULL;
+
wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr);
if (!menuResource)
- return NULL;
-
- char *name = NULL;
- expr->AssignAttributeValue("name", &name);
- if (name)
+ return (wxItemResource *) NULL;
+
+ wxString name;
+ if (expr->GetAttributeValue(T("name"), name))
{
menuResource->SetName(name);
- delete[] name;
}
-
+
return menuResource;
}
-wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretMenuBar(wxResourceTable& table, wxExpr *expr)
{
- PrologExpr *listExpr = NULL;
- expr->AssignAttributeValue("menu", &listExpr);
+ wxExpr *listExpr = (wxExpr *) NULL;
+ expr->GetAttributeValue(T("menu"), &listExpr);
if (!listExpr)
- return NULL;
+ return (wxItemResource *) NULL;
wxItemResource *resource = new wxItemResource;
- resource->SetType("wxMenu");
+ resource->SetType(T("wxMenu"));
// resource->SetType(wxTYPE_MENU);
-
- PrologExpr *element = listExpr->GetFirst();
+
+ wxExpr *element = listExpr->GetFirst();
while (element)
{
wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr);
element = element->GetNext();
}
- char *name = NULL;
- expr->AssignAttributeValue("name", &name);
- if (name)
+ wxString name;
+ if (expr->GetAttributeValue(T("name"), name))
{
resource->SetName(name);
- delete[] name;
}
-
+
return resource;
}
-wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), PrologExpr *WXUNUSED(expr))
+wxItemResource *wxResourceInterpretString(wxResourceTable& WXUNUSED(table), wxExpr *WXUNUSED(expr))
{
- return NULL;
+ return (wxItemResource *) NULL;
}
-wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), PrologExpr *expr)
+wxItemResource *wxResourceInterpretBitmap(wxResourceTable& WXUNUSED(table), wxExpr *expr)
{
wxItemResource *bitmapItem = new wxItemResource;
// bitmapItem->SetType(wxTYPE_BITMAP);
- bitmapItem->SetType("wxBitmap");
- char *name = NULL;
- expr->AssignAttributeValue("name", &name);
- if (name)
+ bitmapItem->SetType(T("wxBitmap"));
+ wxString name;
+ if (expr->GetAttributeValue(T("name"), name))
{
bitmapItem->SetName(name);
- delete[] name;
}
// Now parse all bitmap specifications
- PrologExpr *bitmapExpr = expr->GetFirst();
+ wxExpr *bitmapExpr = expr->GetFirst();
while (bitmapExpr)
{
if (bitmapExpr->Number() == 3)
{
wxString bitmapKeyword(bitmapExpr->Nth(1)->StringValue());
- if (bitmapKeyword == "bitmap" || bitmapKeyword == "icon")
+ if (bitmapKeyword == T("bitmap") || bitmapKeyword == T("icon"))
{
// The value part: always a list.
- PrologExpr *listExpr = bitmapExpr->Nth(2);
+ wxExpr *listExpr = bitmapExpr->Nth(2);
if (listExpr->Type() == PrologList)
{
wxItemResource *bitmapSpec = new wxItemResource;
// bitmapSpec->SetType(wxTYPE_BITMAP);
- bitmapSpec->SetType("wxBitmap");
+ bitmapSpec->SetType(T("wxBitmap"));
// List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
// where everything after 'filename' is optional.
- PrologExpr *nameExpr = listExpr->Nth(0);
- PrologExpr *typeExpr = listExpr->Nth(1);
- PrologExpr *platformExpr = listExpr->Nth(2);
- PrologExpr *coloursExpr = listExpr->Nth(3);
- PrologExpr *xresExpr = listExpr->Nth(4);
- PrologExpr *yresExpr = listExpr->Nth(5);
- if (nameExpr && nameExpr->StringValue())
+ wxExpr *nameExpr = listExpr->Nth(0);
+ wxExpr *typeExpr = listExpr->Nth(1);
+ wxExpr *platformExpr = listExpr->Nth(2);
+ wxExpr *coloursExpr = listExpr->Nth(3);
+ wxExpr *xresExpr = listExpr->Nth(4);
+ wxExpr *yresExpr = listExpr->Nth(5);
+ if (nameExpr && nameExpr->StringValue() != T(""))
{
- wxString str(nameExpr->StringValue());
- bitmapSpec->SetName(WXSTRINGCAST str);
+ bitmapSpec->SetName(nameExpr->StringValue());
}
- if (typeExpr && typeExpr->StringValue())
+ if (typeExpr && typeExpr->StringValue() != T(""))
{
- wxString str(typeExpr->StringValue());
- bitmapSpec->SetValue1(wxParseWindowStyle(WXSTRINGCAST str));
+ bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue()));
}
else
bitmapSpec->SetValue1(0);
-
- if (platformExpr && platformExpr->StringValue())
+
+ if (platformExpr && platformExpr->StringValue() != T(""))
{
wxString plat(platformExpr->StringValue());
- if (plat == "windows" || plat == "WINDOWS")
+ if (plat == T("windows") || plat == T("WINDOWS"))
bitmapSpec->SetValue2(RESOURCE_PLATFORM_WINDOWS);
- else if (plat == "x" || plat == "X")
+ else if (plat == T("x") || plat == T("X"))
bitmapSpec->SetValue2(RESOURCE_PLATFORM_X);
- else if (plat == "mac" || plat == "MAC")
+ else if (plat == T("mac") || plat == T("MAC"))
bitmapSpec->SetValue2(RESOURCE_PLATFORM_MAC);
else
bitmapSpec->SetValue2(RESOURCE_PLATFORM_ANY);
if (yresExpr)
yres = (int)yresExpr->IntegerValue();
bitmapSpec->SetSize(0, 0, xres, yres);
-
+
bitmapItem->GetChildren().Append(bitmapSpec);
}
}
}
bitmapExpr = bitmapExpr->GetNext();
}
-
+
return bitmapItem;
}
-wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, PrologExpr *expr)
+wxItemResource *wxResourceInterpretIcon(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *item = wxResourceInterpretBitmap(table, expr);
if (item)
{
// item->SetType(wxTYPE_ICON);
- item->SetType("wxIcon");
+ item->SetType(T("wxIcon"));
return item;
}
else
- return NULL;
+ return (wxItemResource *) NULL;
}
// Interpret list expression as a font
-wxFont *wxResourceInterpretFontSpec(PrologExpr *expr)
+wxFont wxResourceInterpretFontSpec(wxExpr *expr)
{
if (expr->Type() != PrologList)
- return NULL;
+ return wxNullFont;
int point = 10;
int family = wxSWISS;
int style = wxNORMAL;
int weight = wxNORMAL;
int underline = 0;
- wxString faceName("");
-
- PrologExpr *pointExpr = expr->Nth(0);
- PrologExpr *familyExpr = expr->Nth(1);
- PrologExpr *styleExpr = expr->Nth(2);
- PrologExpr *weightExpr = expr->Nth(3);
- PrologExpr *underlineExpr = expr->Nth(4);
- PrologExpr *faceNameExpr = expr->Nth(5);
+ wxString faceName(T(""));
+
+ wxExpr *pointExpr = expr->Nth(0);
+ wxExpr *familyExpr = expr->Nth(1);
+ wxExpr *styleExpr = expr->Nth(2);
+ wxExpr *weightExpr = expr->Nth(3);
+ wxExpr *underlineExpr = expr->Nth(4);
+ wxExpr *faceNameExpr = expr->Nth(5);
if (pointExpr)
point = (int)pointExpr->IntegerValue();
if (familyExpr)
{
str = familyExpr->StringValue();
- family = (int)wxParseWindowStyle(WXSTRINGCAST str);
+ family = (int)wxParseWindowStyle(str);
}
if (styleExpr)
{
str = styleExpr->StringValue();
- style = (int)wxParseWindowStyle(WXSTRINGCAST str);
+ style = (int)wxParseWindowStyle(str);
}
if (weightExpr)
{
str = weightExpr->StringValue();
- weight = (int)wxParseWindowStyle(WXSTRINGCAST str);
+ weight = (int)wxParseWindowStyle(str);
}
if (underlineExpr)
underline = (int)underlineExpr->IntegerValue();
if (faceNameExpr)
faceName = faceNameExpr->StringValue();
- char *faceName1 = NULL;
- if (faceName != "")
- faceName1 = WXSTRINGCAST faceName;
- wxFont *font = wxTheFontList->FindOrCreateFont(point, family, style, weight, (underline != 0), faceName1);
+ wxFont font(point, family, style, weight, (underline != 0), faceName);
return font;
}
+// 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
*/
-bool wxReallocateResourceBuffer(void)
+bool wxReallocateResourceBuffer()
{
if (!wxResourceBuffer)
{
static bool wxEatWhiteSpace(FILE *fd)
{
- int ch = getc(fd);
- if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
- {
- ungetc(ch, fd);
- return TRUE;
- }
+ int ch = 0;
- // Eat whitespace
- while (ch == ' ' || ch == 10 || ch == 13 || ch == 9)
- ch = getc(fd);
- // Check for comment
- if (ch == '/')
- {
- ch = getc(fd);
- if (ch == '*')
- {
- bool finished = FALSE;
- while (!finished)
+ while ((ch = getc(fd)) != EOF)
{
- ch = getc(fd);
- if (ch == EOF)
- return FALSE;
- if (ch == '*')
- {
- int newCh = getc(fd);
- if (newCh == '/')
- finished = TRUE;
- else
- {
- ungetc(newCh, fd);
- }
- }
+ switch (ch)
+ {
+ case ' ':
+ case 0x0a:
+ case 0x0d:
+ case 0x09:
+ break;
+ case '/':
+ {
+ int prev_ch = ch;
+ ch = getc(fd);
+ if (ch == EOF)
+ {
+ ungetc(prev_ch, fd);
+ return TRUE;
+ }
+
+ if (ch == '*')
+ {
+ // Eat C comment
+ prev_ch = 0;
+ while ((ch = getc(fd)) != EOF)
+ {
+ if (ch == '/' && prev_ch == '*')
+ break;
+ prev_ch = ch;
+ }
+ }
+ else if (ch == '/')
+ {
+ // Eat C++ comment
+ static char buffer[255];
+ fgets(buffer, 255, fd);
+ }
+ else
+ {
+ ungetc(prev_ch, fd);
+ ungetc(ch, fd);
+ return TRUE;
+ }
+ }
+ break;
+ default:
+ ungetc(ch, fd);
+ return TRUE;
+
+ }
}
- }
- else // False alarm
- return FALSE;
- }
- else
- ungetc(ch, fd);
- return wxEatWhiteSpace(fd);
+ return FALSE;
}
bool wxGetResourceToken(FILE *fd)
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc(fd);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
static char *name = "....";
with possible comments.
*/
-
-bool wxResourceReadOneResource(FILE *fd, PrologDatabase& db, bool *eof, wxResourceTable *table)
+
+bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceToken(fd))
{
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceToken(fd);
- char *name = copystring(wxResourceBuffer);
+ wxChar *name = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
wxGetResourceToken(fd);
- char *value = copystring(wxResourceBuffer);
- if (isalpha(value[0]))
+ wxChar *value = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
+ if (wxIsdigit(value[0]))
{
- int val = (int)atol(value);
+ int val = (int)wxAtol(value);
wxResourceAddIdentifier(name, val, table);
}
else
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
{
wxGetResourceToken(fd);
- char *name = copystring(wxResourceBuffer);
- char *actualName = name;
- if (name[0] == '"')
+ wxChar *name = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
+ wxChar *actualName = name;
+ if (name[0] == T('"'))
actualName = name + 1;
- int len = strlen(name);
- if ((len > 0) && (name[len-1] == '"'))
+ int len = wxStrlen(name);
+ if ((len > 0) && (name[len-1] == T('"')))
name[len-1] = 0;
if (!wxResourceParseIncludeFile(actualName, table))
{
}
else if (strcmp(wxResourceBuffer, "static") != 0)
{
- char buf[300];
- strcpy(buf, _("Found "));
- strncat(buf, wxResourceBuffer, 30);
- strcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxChar buf[300];
+ wxStrcpy(buf, _("Found "));
+ wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
+ wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
wxLogWarning(buf);
return FALSE;
}
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceToken(fd))
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
return FALSE;
}
- char nameBuf[100];
- strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+ wxChar nameBuf[100];
+ wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
+ nameBuf[99] = 0;
+
// =
if (!wxGetResourceToken(fd))
{
/*
* Parses string window style into integer window style
*/
-
+
/*
* Style flag parsing, e.g.
* "wxSYSTEM_MENU | wxBORDER" -> integer
*/
-char *wxResourceParseWord(char *s, int *i)
+wxChar* wxResourceParseWord(wxChar*s, int *i)
{
if (!s)
- return NULL;
+ return (wxChar*) NULL;
- static char buf[150];
- int len = strlen(s);
+ static wxChar buf[150];
+ int len = wxStrlen(s);
int j = 0;
int ii = *i;
- while ((ii < len) && (isalpha(s[ii]) || (s[ii] == '_')))
+ while ((ii < len) && (wxIsalpha(s[ii]) || (s[ii] == T('_'))))
{
buf[j] = s[ii];
j ++;
// Eat whitespace and conjunction characters
while ((ii < len) &&
- ((s[ii] == ' ') || (s[ii] == '|') || (s[ii] == ',')))
+ ((s[ii] == T(' ')) || (s[ii] == T('|')) || (s[ii] == T(','))))
{
ii ++;
}
*i = ii;
if (j == 0)
- return NULL;
+ return (wxChar*) NULL;
else
return buf;
}
struct wxResourceBitListStruct
{
- char *word;
+ wxChar *word;
long bits;
};
static wxResourceBitListStruct wxResourceBitListTable[] =
{
/* wxListBox */
- { "wxSINGLE", wxLB_SINGLE },
- { "wxMULTIPLE", wxLB_MULTIPLE },
- { "wxEXTENDED", wxLB_EXTENDED },
- { "wxLB_SINGLE", wxLB_SINGLE },
- { "wxLB_MULTIPLE", wxLB_MULTIPLE },
- { "wxLB_EXTENDED", wxLB_EXTENDED },
- { "wxLB_NEEDED_SB", wxLB_NEEDED_SB },
- { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB },
- { "wxLB_SORT", wxLB_SORT },
- { "wxLB_OWNERDRAW", wxLB_OWNERDRAW },
- { "wxLB_HSCROLL", wxLB_HSCROLL },
-
+ { T("wxSINGLE"), wxLB_SINGLE },
+ { T("wxMULTIPLE"), wxLB_MULTIPLE },
+ { T("wxEXTENDED"), wxLB_EXTENDED },
+ { T("wxLB_SINGLE"), wxLB_SINGLE },
+ { T("wxLB_MULTIPLE"), wxLB_MULTIPLE },
+ { T("wxLB_EXTENDED"), wxLB_EXTENDED },
+ { T("wxLB_NEEDED_SB"), wxLB_NEEDED_SB },
+ { T("wxLB_ALWAYS_SB"), wxLB_ALWAYS_SB },
+ { T("wxLB_SORT"), wxLB_SORT },
+ { T("wxLB_OWNERDRAW"), wxLB_OWNERDRAW },
+ { T("wxLB_HSCROLL"), wxLB_HSCROLL },
+
/* wxComboxBox */
- { "wxCB_SIMPLE", wxCB_SIMPLE },
- { "wxCB_DROPDOWN", wxCB_DROPDOWN },
- { "wxCB_READONLY", wxCB_READONLY },
- { "wxCB_SORT", wxCB_SORT },
-
+ { T("wxCB_SIMPLE"), wxCB_SIMPLE },
+ { T("wxCB_DROPDOWN"), wxCB_DROPDOWN },
+ { T("wxCB_READONLY"), wxCB_READONLY },
+ { T("wxCB_SORT"), wxCB_SORT },
+
/* wxGauge */
- { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR },
- { "wxGA_HORIZONTAL", wxGA_HORIZONTAL },
- { "wxGA_VERTICAL", wxGA_VERTICAL },
+ { T("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR },
+ { T("wxGA_HORIZONTAL"), wxGA_HORIZONTAL },
+ { T("wxGA_VERTICAL"), wxGA_VERTICAL },
/* wxTextCtrl */
- { "wxPASSWORD", wxPASSWORD},
- { "wxPROCESS_ENTER", wxPROCESS_ENTER},
- { "wxTE_PASSWORD", wxTE_PASSWORD},
- { "wxTE_READONLY", wxTE_READONLY},
- { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER},
- { "wxTE_MULTILINE", wxTE_MULTILINE},
+ { T("wxPASSWORD"), wxPASSWORD},
+ { T("wxPROCESS_ENTER"), wxPROCESS_ENTER},
+ { T("wxTE_PASSWORD"), wxTE_PASSWORD},
+ { T("wxTE_READONLY"), wxTE_READONLY},
+ { T("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER},
+ { T("wxTE_MULTILINE"), wxTE_MULTILINE},
+ { T("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL},
/* wxRadioBox/wxRadioButton */
- { "wxRB_GROUP", wxRB_GROUP },
- { "wxRA_HORIZONTAL", wxRA_HORIZONTAL },
- { "wxRA_VERTICAL", wxRA_VERTICAL },
+ { T("wxRB_GROUP"), wxRB_GROUP },
+ { T("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS },
+ { T("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS },
+ { T("wxRA_HORIZONTAL"), wxRA_HORIZONTAL },
+ { T("wxRA_VERTICAL"), wxRA_VERTICAL },
/* wxSlider */
- { "wxSL_HORIZONTAL", wxSL_HORIZONTAL },
- { "wxSL_VERTICAL", wxSL_VERTICAL },
- { "wxSL_AUTOTICKS", wxSL_AUTOTICKS },
- { "wxSL_LABELS", wxSL_LABELS },
- { "wxSL_LEFT", wxSL_LEFT },
- { "wxSL_TOP", wxSL_TOP },
- { "wxSL_RIGHT", wxSL_RIGHT },
- { "wxSL_BOTTOM", wxSL_BOTTOM },
- { "wxSL_BOTH", wxSL_BOTH },
- { "wxSL_SELRANGE", wxSL_SELRANGE },
+ { T("wxSL_HORIZONTAL"), wxSL_HORIZONTAL },
+ { T("wxSL_VERTICAL"), wxSL_VERTICAL },
+ { T("wxSL_AUTOTICKS"), wxSL_AUTOTICKS },
+ { T("wxSL_LABELS"), wxSL_LABELS },
+ { T("wxSL_LEFT"), wxSL_LEFT },
+ { T("wxSL_TOP"), wxSL_TOP },
+ { T("wxSL_RIGHT"), wxSL_RIGHT },
+ { T("wxSL_BOTTOM"), wxSL_BOTTOM },
+ { T("wxSL_BOTH"), wxSL_BOTH },
+ { T("wxSL_SELRANGE"), wxSL_SELRANGE },
/* wxScrollBar */
- { "wxSB_HORIZONTAL", wxSB_HORIZONTAL },
- { "wxSB_VERTICAL", wxSB_VERTICAL },
+ { T("wxSB_HORIZONTAL"), wxSB_HORIZONTAL },
+ { T("wxSB_VERTICAL"), wxSB_VERTICAL },
/* wxButton */
- { "wxBU_AUTODRAW", wxBU_AUTODRAW },
- { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW },
+ { T("wxBU_AUTODRAW"), wxBU_AUTODRAW },
+ { T("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW },
/* wxTreeCtrl */
- { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS },
- { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS },
- { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT },
+ { T("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS },
+ { T("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS },
+ { T("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT },
/* wxListCtrl */
- { "wxLC_ICON", wxLC_ICON },
- { "wxLC_SMALL_ICON", wxLC_SMALL_ICON },
- { "wxLC_LIST", wxLC_LIST },
- { "wxLC_REPORT", wxLC_REPORT },
- { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP },
- { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT },
- { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE },
- { "wxLC_USER_TEXT", wxLC_USER_TEXT },
- { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS },
- { "wxLC_NO_HEADER", wxLC_NO_HEADER },
- { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER },
- { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL },
- { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING },
- { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING },
+ { T("wxLC_ICON"), wxLC_ICON },
+ { T("wxLC_SMALL_ICON"), wxLC_SMALL_ICON },
+ { T("wxLC_LIST"), wxLC_LIST },
+ { T("wxLC_REPORT"), wxLC_REPORT },
+ { T("wxLC_ALIGN_TOP"), wxLC_ALIGN_TOP },
+ { T("wxLC_ALIGN_LEFT"), wxLC_ALIGN_LEFT },
+ { T("wxLC_AUTOARRANGE"), wxLC_AUTOARRANGE },
+ { T("wxLC_USER_TEXT"), wxLC_USER_TEXT },
+ { T("wxLC_EDIT_LABELS"), wxLC_EDIT_LABELS },
+ { T("wxLC_NO_HEADER"), wxLC_NO_HEADER },
+ { T("wxLC_NO_SORT_HEADER"), wxLC_NO_SORT_HEADER },
+ { T("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL },
+ { T("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING },
+ { T("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING },
/* wxSpinButton */
- { "wxSP_VERTICAL", wxSP_VERTICAL},
- { "wxSP_HORIZONTAL", wxSP_HORIZONTAL},
- { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS},
- { "wxSP_WRAP", wxSP_WRAP},
+ { T("wxSP_VERTICAL"), wxSP_VERTICAL},
+ { T("wxSP_HORIZONTAL"), wxSP_HORIZONTAL},
+ { T("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS},
+ { T("wxSP_WRAP"), wxSP_WRAP},
/* wxSplitterWnd */
- { "wxSP_NOBORDER", wxSP_NOBORDER},
- { "wxSP_3D", wxSP_3D},
- { "wxSP_BORDER", wxSP_BORDER},
+ { T("wxSP_NOBORDER"), wxSP_NOBORDER},
+ { T("wxSP_3D"), wxSP_3D},
+ { T("wxSP_BORDER"), wxSP_BORDER},
/* wxTabCtrl */
- { "wxTC_MULTILINE", wxTC_MULTILINE},
- { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY},
- { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH},
- { "wxTC_OWNERDRAW", wxTC_OWNERDRAW},
+ { T("wxTC_MULTILINE"), wxTC_MULTILINE},
+ { T("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY},
+ { T("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH},
+ { T("wxTC_OWNERDRAW"), wxTC_OWNERDRAW},
/* wxStatusBar95 */
- { "wxST_SIZEGRIP", wxST_SIZEGRIP},
+ { T("wxST_SIZEGRIP"), wxST_SIZEGRIP},
/* wxControl */
- { "wxFIXED_LENGTH", wxFIXED_LENGTH},
- { "wxALIGN_LEFT", wxALIGN_LEFT},
- { "wxALIGN_CENTER", wxALIGN_CENTER},
- { "wxALIGN_CENTRE", wxALIGN_CENTRE},
- { "wxALIGN_RIGHT", wxALIGN_RIGHT},
- { "wxCOLOURED", wxCOLOURED},
-
+ { T("wxFIXED_LENGTH"), wxFIXED_LENGTH},
+ { T("wxALIGN_LEFT"), wxALIGN_LEFT},
+ { T("wxALIGN_CENTER"), wxALIGN_CENTER},
+ { T("wxALIGN_CENTRE"), wxALIGN_CENTRE},
+ { T("wxALIGN_RIGHT"), wxALIGN_RIGHT},
+ { T("wxCOLOURED"), wxCOLOURED},
+
/* wxToolBar */
- { "wxTB_3DBUTTONS", wxTB_3DBUTTONS},
- { "wxTB_HORIZONTAL", wxTB_HORIZONTAL},
- { "wxTB_VERTICAL", wxTB_VERTICAL},
- { "wxTB_FLAT", wxTB_FLAT},
+ { T("wxTB_3DBUTTONS"), wxTB_3DBUTTONS},
+ { T("wxTB_HORIZONTAL"), wxTB_HORIZONTAL},
+ { T("wxTB_VERTICAL"), wxTB_VERTICAL},
+ { T("wxTB_FLAT"), wxTB_FLAT},
+
+ /* wxDialog */
+ { T("wxDIALOG_MODAL"), wxDIALOG_MODAL },
/* Generic */
- { "wxVSCROLL", wxVSCROLL },
- { "wxHSCROLL", wxHSCROLL },
- { "wxCAPTION", wxCAPTION },
- { "wxSTAY_ON_TOP", wxSTAY_ON_TOP},
- { "wxICONIZE", wxICONIZE},
- { "wxMINIMIZE", wxICONIZE},
- { "wxMAXIMIZE", wxMAXIMIZE},
- { "wxSDI", 0},
- { "wxMDI_PARENT", 0},
- { "wxMDI_CHILD", 0},
- { "wxTHICK_FRAME", wxTHICK_FRAME},
- { "wxRESIZE_BORDER", wxRESIZE_BORDER},
- { "wxSYSTEM_MENU", wxSYSTEM_MENU},
- { "wxMINIMIZE_BOX", wxMINIMIZE_BOX},
- { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX},
- { "wxRESIZE_BOX", wxRESIZE_BOX},
- { "wxDEFAULT_FRAME", wxDEFAULT_FRAME},
- { "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE},
- { "wxBORDER", wxBORDER},
- { "wxRETAINED", wxRETAINED},
- { "wxNATIVE_IMPL", 0},
- { "wxEXTENDED_IMPL", 0},
- { "wxBACKINGSTORE", wxBACKINGSTORE},
-// { "wxFLAT", wxFLAT},
-// { "wxMOTIF_RESIZE", wxMOTIF_RESIZE},
- { "wxFIXED_LENGTH", 0},
- { "wxDOUBLE_BORDER", wxDOUBLE_BORDER},
- { "wxSUNKEN_BORDER", wxSUNKEN_BORDER},
- { "wxRAISED_BORDER", wxRAISED_BORDER},
- { "wxSIMPLE_BORDER", wxSIMPLE_BORDER},
- { "wxSTATIC_BORDER", wxSTATIC_BORDER},
- { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW},
- { "wxNO_BORDER", wxNO_BORDER},
- { "wxCLIP_CHILDREN", wxCLIP_CHILDREN},
-
- { "wxTINY_CAPTION_HORIZ", wxTINY_CAPTION_HORIZ},
- { "wxTINY_CAPTION_VERT", wxTINY_CAPTION_VERT},
+ { T("wxVSCROLL"), wxVSCROLL },
+ { T("wxHSCROLL"), wxHSCROLL },
+ { T("wxCAPTION"), wxCAPTION },
+ { T("wxSTAY_ON_TOP"), wxSTAY_ON_TOP},
+ { T("wxICONIZE"), wxICONIZE},
+ { T("wxMINIMIZE"), wxICONIZE},
+ { T("wxMAXIMIZE"), wxMAXIMIZE},
+ { T("wxSDI"), 0},
+ { T("wxMDI_PARENT"), 0},
+ { T("wxMDI_CHILD"), 0},
+ { T("wxTHICK_FRAME"), wxTHICK_FRAME},
+ { T("wxRESIZE_BORDER"), wxRESIZE_BORDER},
+ { T("wxSYSTEM_MENU"), wxSYSTEM_MENU},
+ { T("wxMINIMIZE_BOX"), wxMINIMIZE_BOX},
+ { T("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX},
+ { T("wxRESIZE_BOX"), wxRESIZE_BOX},
+ { T("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE},
+ { T("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE},
+ { T("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE},
+ { T("wxBORDER"), wxBORDER},
+ { T("wxRETAINED"), wxRETAINED},
+ { T("wxNATIVE_IMPL"), 0},
+ { T("wxEXTENDED_IMPL"), 0},
+ { T("wxBACKINGSTORE"), wxBACKINGSTORE},
+// { T("wxFLAT"), wxFLAT},
+// { T("wxMOTIF_RESIZE"), wxMOTIF_RESIZE},
+ { T("wxFIXED_LENGTH"), 0},
+ { T("wxDOUBLE_BORDER"), wxDOUBLE_BORDER},
+ { T("wxSUNKEN_BORDER"), wxSUNKEN_BORDER},
+ { T("wxRAISED_BORDER"), wxRAISED_BORDER},
+ { T("wxSIMPLE_BORDER"), wxSIMPLE_BORDER},
+ { T("wxSTATIC_BORDER"), wxSTATIC_BORDER},
+ { T("wxTRANSPARENT_WINDOW"), wxTRANSPARENT_WINDOW},
+ { T("wxNO_BORDER"), wxNO_BORDER},
+ { T("wxCLIP_CHILDREN"), wxCLIP_CHILDREN},
+ { T("wxTAB_TRAVERSAL"), 0}, // Compatibility only
+
+ { T("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ},
+ { T("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT},
// Text font families
- { "wxDEFAULT", wxDEFAULT},
- { "wxDECORATIVE", wxDECORATIVE},
- { "wxROMAN", wxROMAN},
- { "wxSCRIPT", wxSCRIPT},
- { "wxSWISS", wxSWISS},
- { "wxMODERN", wxMODERN},
- { "wxTELETYPE", wxTELETYPE},
- { "wxVARIABLE", wxVARIABLE},
- { "wxFIXED", wxFIXED},
- { "wxNORMAL", wxNORMAL},
- { "wxLIGHT", wxLIGHT},
- { "wxBOLD", wxBOLD},
- { "wxITALIC", wxITALIC},
- { "wxSLANT", wxSLANT},
- { "wxSOLID", wxSOLID},
- { "wxDOT", wxDOT},
- { "wxLONG_DASH", wxLONG_DASH},
- { "wxSHORT_DASH", wxSHORT_DASH},
- { "wxDOT_DASH", wxDOT_DASH},
- { "wxUSER_DASH", wxUSER_DASH},
- { "wxTRANSPARENT", wxTRANSPARENT},
- { "wxSTIPPLE", wxSTIPPLE},
- { "wxBDIAGONAL_HATCH", wxBDIAGONAL_HATCH},
- { "wxCROSSDIAG_HATCH", wxCROSSDIAG_HATCH},
- { "wxFDIAGONAL_HATCH", wxFDIAGONAL_HATCH},
- { "wxCROSS_HATCH", wxCROSS_HATCH},
- { "wxHORIZONTAL_HATCH", wxHORIZONTAL_HATCH},
- { "wxVERTICAL_HATCH", wxVERTICAL_HATCH},
- { "wxJOIN_BEVEL", wxJOIN_BEVEL},
- { "wxJOIN_MITER", wxJOIN_MITER},
- { "wxJOIN_ROUND", wxJOIN_ROUND},
- { "wxCAP_ROUND", wxCAP_ROUND},
- { "wxCAP_PROJECTING", wxCAP_PROJECTING},
- { "wxCAP_BUTT", wxCAP_BUTT},
+ { T("wxDEFAULT"), wxDEFAULT},
+ { T("wxDECORATIVE"), wxDECORATIVE},
+ { T("wxROMAN"), wxROMAN},
+ { T("wxSCRIPT"), wxSCRIPT},
+ { T("wxSWISS"), wxSWISS},
+ { T("wxMODERN"), wxMODERN},
+ { T("wxTELETYPE"), wxTELETYPE},
+ { T("wxVARIABLE"), wxVARIABLE},
+ { T("wxFIXED"), wxFIXED},
+ { T("wxNORMAL"), wxNORMAL},
+ { T("wxLIGHT"), wxLIGHT},
+ { T("wxBOLD"), wxBOLD},
+ { T("wxITALIC"), wxITALIC},
+ { T("wxSLANT"), wxSLANT},
+ { T("wxSOLID"), wxSOLID},
+ { T("wxDOT"), wxDOT},
+ { T("wxLONG_DASH"), wxLONG_DASH},
+ { T("wxSHORT_DASH"), wxSHORT_DASH},
+ { T("wxDOT_DASH"), wxDOT_DASH},
+ { T("wxUSER_DASH"), wxUSER_DASH},
+ { T("wxTRANSPARENT"), wxTRANSPARENT},
+ { T("wxSTIPPLE"), wxSTIPPLE},
+ { T("wxBDIAGONAL_HATCH"), wxBDIAGONAL_HATCH},
+ { T("wxCROSSDIAG_HATCH"), wxCROSSDIAG_HATCH},
+ { T("wxFDIAGONAL_HATCH"), wxFDIAGONAL_HATCH},
+ { T("wxCROSS_HATCH"), wxCROSS_HATCH},
+ { T("wxHORIZONTAL_HATCH"), wxHORIZONTAL_HATCH},
+ { T("wxVERTICAL_HATCH"), wxVERTICAL_HATCH},
+ { T("wxJOIN_BEVEL"), wxJOIN_BEVEL},
+ { T("wxJOIN_MITER"), wxJOIN_MITER},
+ { T("wxJOIN_ROUND"), wxJOIN_ROUND},
+ { T("wxCAP_ROUND"), wxCAP_ROUND},
+ { T("wxCAP_PROJECTING"), wxCAP_PROJECTING},
+ { T("wxCAP_BUTT"), wxCAP_BUTT},
// Logical ops
- { "wxCLEAR", wxCLEAR},
- { "wxXOR", wxXOR},
- { "wxINVERT", wxINVERT},
- { "wxOR_REVERSE", wxOR_REVERSE},
- { "wxAND_REVERSE", wxAND_REVERSE},
- { "wxCOPY", wxCOPY},
- { "wxAND", wxAND},
- { "wxAND_INVERT", wxAND_INVERT},
- { "wxNO_OP", wxNO_OP},
- { "wxNOR", wxNOR},
- { "wxEQUIV", wxEQUIV},
- { "wxSRC_INVERT", wxSRC_INVERT},
- { "wxOR_INVERT", wxOR_INVERT},
- { "wxNAND", wxNAND},
- { "wxOR", wxOR},
- { "wxSET", wxSET},
-
- { "wxFLOOD_SURFACE", wxFLOOD_SURFACE},
- { "wxFLOOD_BORDER", wxFLOOD_BORDER},
- { "wxODDEVEN_RULE", wxODDEVEN_RULE},
- { "wxWINDING_RULE", wxWINDING_RULE},
- { "wxHORIZONTAL", wxHORIZONTAL},
- { "wxVERTICAL", wxVERTICAL},
- { "wxBOTH", wxBOTH},
- { "wxCENTER_FRAME", wxCENTER_FRAME},
- { "wxOK", wxOK},
- { "wxYES_NO", wxYES_NO},
- { "wxCANCEL", wxCANCEL},
- { "wxYES", wxYES},
- { "wxNO", wxNO},
- { "wxICON_EXCLAMATION", wxICON_EXCLAMATION},
- { "wxICON_HAND", wxICON_HAND},
- { "wxICON_QUESTION", wxICON_QUESTION},
- { "wxICON_INFORMATION", wxICON_INFORMATION},
- { "wxICON_STOP", wxICON_STOP},
- { "wxICON_ASTERISK", wxICON_ASTERISK},
- { "wxICON_MASK", wxICON_MASK},
- { "wxCENTRE", wxCENTRE},
- { "wxCENTER", wxCENTRE},
- { "wxUSER_COLOURS", wxUSER_COLOURS},
- { "wxVERTICAL_LABEL", 0},
- { "wxHORIZONTAL_LABEL", 0},
+ { T("wxCLEAR"), wxCLEAR},
+ { T("wxXOR"), wxXOR},
+ { T("wxINVERT"), wxINVERT},
+ { T("wxOR_REVERSE"), wxOR_REVERSE},
+ { T("wxAND_REVERSE"), wxAND_REVERSE},
+ { T("wxCOPY"), wxCOPY},
+ { T("wxAND"), wxAND},
+ { T("wxAND_INVERT"), wxAND_INVERT},
+ { T("wxNO_OP"), wxNO_OP},
+ { T("wxNOR"), wxNOR},
+ { T("wxEQUIV"), wxEQUIV},
+ { T("wxSRC_INVERT"), wxSRC_INVERT},
+ { T("wxOR_INVERT"), wxOR_INVERT},
+ { T("wxNAND"), wxNAND},
+ { T("wxOR"), wxOR},
+ { T("wxSET"), wxSET},
+
+ { T("wxFLOOD_SURFACE"), wxFLOOD_SURFACE},
+ { T("wxFLOOD_BORDER"), wxFLOOD_BORDER},
+ { T("wxODDEVEN_RULE"), wxODDEVEN_RULE},
+ { T("wxWINDING_RULE"), wxWINDING_RULE},
+ { T("wxHORIZONTAL"), wxHORIZONTAL},
+ { T("wxVERTICAL"), wxVERTICAL},
+ { T("wxBOTH"), wxBOTH},
+ { T("wxCENTER_FRAME"), wxCENTER_FRAME},
+ { T("wxOK"), wxOK},
+ { T("wxYES_NO"), wxYES_NO},
+ { T("wxCANCEL"), wxCANCEL},
+ { T("wxYES"), wxYES},
+ { T("wxNO"), wxNO},
+ { T("wxICON_EXCLAMATION"), wxICON_EXCLAMATION},
+ { T("wxICON_HAND"), wxICON_HAND},
+ { T("wxICON_QUESTION"), wxICON_QUESTION},
+ { T("wxICON_INFORMATION"), wxICON_INFORMATION},
+ { T("wxICON_STOP"), wxICON_STOP},
+ { T("wxICON_ASTERISK"), wxICON_ASTERISK},
+ { T("wxICON_MASK"), wxICON_MASK},
+ { T("wxCENTRE"), wxCENTRE},
+ { T("wxCENTER"), wxCENTRE},
+ { T("wxUSER_COLOURS"), wxUSER_COLOURS},
+ { T("wxVERTICAL_LABEL"), 0},
+ { T("wxHORIZONTAL_LABEL"), 0},
// Bitmap types (not strictly styles)
- { "wxBITMAP_TYPE_XPM", wxBITMAP_TYPE_XPM},
- { "wxBITMAP_TYPE_XBM", wxBITMAP_TYPE_XBM},
- { "wxBITMAP_TYPE_BMP", wxBITMAP_TYPE_BMP},
- { "wxBITMAP_TYPE_RESOURCE", wxBITMAP_TYPE_BMP_RESOURCE},
- { "wxBITMAP_TYPE_BMP_RESOURCE", wxBITMAP_TYPE_BMP_RESOURCE},
- { "wxBITMAP_TYPE_GIF", wxBITMAP_TYPE_GIF},
- { "wxBITMAP_TYPE_TIF", wxBITMAP_TYPE_TIF},
- { "wxBITMAP_TYPE_ICO", wxBITMAP_TYPE_ICO},
- { "wxBITMAP_TYPE_ICO_RESOURCE", wxBITMAP_TYPE_ICO_RESOURCE},
- { "wxBITMAP_TYPE_CUR", wxBITMAP_TYPE_CUR},
- { "wxBITMAP_TYPE_CUR_RESOURCE", wxBITMAP_TYPE_CUR_RESOURCE},
- { "wxBITMAP_TYPE_XBM_DATA", wxBITMAP_TYPE_XBM_DATA},
- { "wxBITMAP_TYPE_XPM_DATA", wxBITMAP_TYPE_XPM_DATA},
- { "wxBITMAP_TYPE_ANY", wxBITMAP_TYPE_ANY}
+ { T("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM},
+ { T("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM},
+ { T("wxBITMAP_TYPE_BMP"), wxBITMAP_TYPE_BMP},
+ { T("wxBITMAP_TYPE_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE},
+ { T("wxBITMAP_TYPE_BMP_RESOURCE"), wxBITMAP_TYPE_BMP_RESOURCE},
+ { T("wxBITMAP_TYPE_GIF"), wxBITMAP_TYPE_GIF},
+ { T("wxBITMAP_TYPE_TIF"), wxBITMAP_TYPE_TIF},
+ { T("wxBITMAP_TYPE_ICO"), wxBITMAP_TYPE_ICO},
+ { T("wxBITMAP_TYPE_ICO_RESOURCE"), wxBITMAP_TYPE_ICO_RESOURCE},
+ { T("wxBITMAP_TYPE_CUR"), wxBITMAP_TYPE_CUR},
+ { T("wxBITMAP_TYPE_CUR_RESOURCE"), wxBITMAP_TYPE_CUR_RESOURCE},
+ { T("wxBITMAP_TYPE_XBM_DATA"), wxBITMAP_TYPE_XBM_DATA},
+ { T("wxBITMAP_TYPE_XPM_DATA"), wxBITMAP_TYPE_XPM_DATA},
+ { T("wxBITMAP_TYPE_ANY"), wxBITMAP_TYPE_ANY}
};
static int wxResourceBitListCount = (sizeof(wxResourceBitListTable)/sizeof(wxResourceBitListStruct));
-long wxParseWindowStyle(char *bitListString)
+long wxParseWindowStyle(const wxString& bitListString)
{
int i = 0;
- char *word;
+ wxChar *word;
long bitList = 0;
- while ((word = wxResourceParseWord(bitListString, &i)))
+ word = wxResourceParseWord(WXSTRINGCAST bitListString, &i);
+ while (word != NULL)
{
bool found = FALSE;
int j;
for (j = 0; j < wxResourceBitListCount; j++)
- if (strcmp(wxResourceBitListTable[j].word, word) == 0)
+ if (wxStrcmp(wxResourceBitListTable[j].word, word) == 0)
{
bitList |= wxResourceBitListTable[j].bits;
found = TRUE;
wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word);
return 0;
}
+ word = wxResourceParseWord(WXSTRINGCAST bitListString, &i);
}
return bitList;
}
* Load a bitmap from a wxWindows resource, choosing an optimum
* depth and appropriate type.
*/
-
-wxBitmap *wxResourceCreateBitmap(char *resource, wxResourceTable *table)
+
+wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
- if (!item->GetType() || strcmp(item->GetType(), "wxBitmap") != 0)
+ if ((item->GetType() == T("")) || (item->GetType() != T("wxBitmap")))
{
- wxLogWarning(_("%s not a bitmap resource specification."), resource);
- return NULL;
+ wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar*) resource);
+ return wxNullBitmap;
}
int thisDepth = wxDisplayDepth();
long thisNoColours = (long)pow(2.0, (double)thisDepth);
- wxItemResource *optResource = NULL;
-
+ wxItemResource *optResource = (wxItemResource *) NULL;
+
// Try to find optimum bitmap for this platform/colour depth
wxNode *node = item->GetChildren().First();
while (node)
}
// If no matching resource, fail.
if (!optResource)
- return NULL;
+ return wxNullBitmap;
- char *name = optResource->GetName();
+ wxString name = optResource->GetName();
int bitmapType = (int)optResource->GetValue1();
- wxBitmap *bitmap = NULL;
switch (bitmapType)
{
case wxBITMAP_TYPE_XBM_DATA:
if (!item)
{
wxLogWarning(_("Failed to find XBM resource %s.\n"
- "Forgot to use wxResourceLoadBitmapData?"), name);
- return NULL;
+ "Forgot to use wxResourceLoadBitmapData?"), (const wxChar*) name);
+ return wxNullBitmap;
}
- bitmap = new wxBitmap((char *)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3());
+ return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ;
#else
wxLogWarning(_("No XBM facility available!"));
#endif
}
case wxBITMAP_TYPE_XPM_DATA:
{
-#if (defined(__WXGTK__)) || (defined(__WXMSW__) && USE_XPM_IN_MSW)
+#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
wxItemResource *item = table->FindResource(name);
if (!item)
{
wxLogWarning(_("Failed to find XPM resource %s.\n"
- "Forgot to use wxResourceLoadBitmapData?"), name);
- return NULL;
+ "Forgot to use wxResourceLoadBitmapData?"), (const wxChar*) name);
+ return wxNullBitmap;
}
- bitmap = new wxBitmap(item->GetValue1());
+ return wxBitmap((char **)item->GetValue1());
#else
wxLogWarning(_("No XPM facility available!"));
#endif
}
default:
{
- bitmap = new wxBitmap(name, bitmapType);
+ return wxBitmap(name, bitmapType);
break;
}
}
- if (!bitmap)
- return NULL;
-
- if (bitmap->Ok())
- {
- return bitmap;
- }
- else
- {
- delete bitmap;
- return NULL;
- }
+ return wxNullBitmap;
}
else
{
- wxLogWarning(_("Bitmap resource specification %s not found."), resource);
- return NULL;
+ wxLogWarning(_("Bitmap resource specification %s not found."), (const wxChar*) resource);
+ return wxNullBitmap;
}
}
* Load an icon from a wxWindows resource, choosing an optimum
* depth and appropriate type.
*/
-
-wxIcon *wxResourceCreateIcon(char *resource, wxResourceTable *table)
+
+wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table)
{
if (!table)
- table = wxDefaultResourceTable;
-
+ table = wxDefaultResourceTable;
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
- if (!item->GetType() || strcmp(item->GetType(), "wxIcon") != 0)
+ if ((item->GetType() == T("")) || wxStrcmp(item->GetType(), T("wxIcon")) != 0)
{
- wxLogWarning(_("%s not an icon resource specification."), resource);
- return NULL;
+ wxLogWarning(_("%s not an icon resource specification."), (const wxChar*) resource);
+ return wxNullIcon;
}
int thisDepth = wxDisplayDepth();
long thisNoColours = (long)pow(2.0, (double)thisDepth);
- wxItemResource *optResource = NULL;
-
+ wxItemResource *optResource = (wxItemResource *) NULL;
+
// Try to find optimum icon for this platform/colour depth
wxNode *node = item->GetChildren().First();
while (node)
}
// If no matching resource, fail.
if (!optResource)
- return NULL;
+ return wxNullIcon;
- char *name = optResource->GetName();
+ wxString name = optResource->GetName();
int bitmapType = (int)optResource->GetValue1();
- wxIcon *icon = NULL;
switch (bitmapType)
{
case wxBITMAP_TYPE_XBM_DATA:
if (!item)
{
wxLogWarning(_("Failed to find XBM resource %s.\n"
- "Forgot to use wxResourceLoadIconData?"), name);
- return NULL;
+ "Forgot to use wxResourceLoadIconData?"), (const wxChar*) name);
+ return wxNullIcon;
}
- icon = new wxIcon((char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3());
+ return wxIcon((const char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3());
#else
wxLogWarning(_("No XBM facility available!"));
#endif
{
// *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
/*
-#if (defined(__WXGTK__)) || (defined(__WXMSW__) && USE_XPM_IN_MSW)
+#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
wxItemResource *item = table->FindResource(name);
if (!item)
{
wxLogWarning(buf);
return NULL;
}
- icon = new wxIcon((char **)item->GetValue1());
+ return wxIcon((char **)item->GetValue1());
#else
wxLogWarning(_("No XPM facility available!"));
#endif
default:
{
#ifdef __WXGTK__
- wxLogWarning(_("Icon resource specification %s not found."), resource);
+ wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource);
#else
- icon = new wxIcon(name, bitmapType);
+ return wxIcon(name, bitmapType);
#endif
break;
}
}
- if (!icon)
- return NULL;
-
- if (icon->Ok())
- {
- return icon;
- }
- else
- {
- delete icon;
- return NULL;
- }
+ return wxNullIcon;
}
else
{
- wxLogWarning(_("Icon resource specification %s not found."), resource);
- return NULL;
+ wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource);
+ return wxNullIcon;
}
}
while (node)
{
wxItemResource *child = (wxItemResource *)node->Data();
- if (child->GetType() && strcmp(child->GetType(), "wxMenuSeparator") == 0)
+ if ((child->GetType() != T("")) && (child->GetType() == T("wxMenuSeparator")))
menu->AppendSeparator();
else if (child->GetChildren().Number() > 0)
{
return menu;
}
-wxMenuBar *wxResourceCreateMenuBar(char *resource, wxResourceTable *table, wxMenuBar *menuBar)
+wxMenuBar *wxResourceCreateMenuBar(const wxString& resource, wxResourceTable *table, wxMenuBar *menuBar)
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
- if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0)
+ if (menuResource && (menuResource->GetType() != T("")) && (menuResource->GetType() == T("wxMenu")))
{
if (!menuBar)
menuBar = new wxMenuBar;
}
return menuBar;
}
- return NULL;
+ return (wxMenuBar *) NULL;
}
-wxMenu *wxResourceCreateMenu(char *resource, wxResourceTable *table)
+wxMenu *wxResourceCreateMenu(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
- if (menuResource && menuResource->GetType() && strcmp(menuResource->GetType(), "wxMenu") == 0)
+ if (menuResource && (menuResource->GetType() != T("")) && (menuResource->GetType() == T("wxMenu")))
// if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
return wxResourceCreateMenu(menuResource);
- return NULL;
+ return (wxMenu *) NULL;
}
// Global equivalents (so don't have to refer to default table explicitly)
-bool wxResourceParseData(char *resource, wxResourceTable *table)
+bool wxResourceParseData(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceData(resource);
}
-bool wxResourceParseFile(char *filename, wxResourceTable *table)
+bool wxResourceParseFile(const wxString& filename, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceFile(filename);
}
// Register XBM/XPM data
-bool wxResourceRegisterBitmapData(char *name, char bits[], int width, int height, wxResourceTable *table)
+bool wxResourceRegisterBitmapData(const wxString& name, char bits[], int width, int height, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->RegisterResourceBitmapData(name, bits, width, height);
}
-bool wxResourceRegisterBitmapData(char *name, char **data, wxResourceTable *table)
+bool wxResourceRegisterBitmapData(const wxString& name, char **data, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
* Identifiers
*/
-bool wxResourceAddIdentifier(char *name, int value, wxResourceTable *table)
+bool wxResourceAddIdentifier(const wxString& name, int value, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
- table->identifiers.Put(name, (wxObject *)value);
+
+ table->identifiers.Put(name, (wxObject *)(long)value);
return TRUE;
}
-int wxResourceGetIdentifier(char *name, wxResourceTable *table)
+int wxResourceGetIdentifier(const wxString& name, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
- return (int)table->identifiers.Get(name);
+
+ return (int)(long)table->identifiers.Get(name);
}
/*
* Parse #include file for #defines (only)
*/
-bool wxResourceParseIncludeFile(char *f, wxResourceTable *table)
+bool wxResourceParseIncludeFile(const wxString& f, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
- FILE *fd = fopen(f, "r");
+
+ FILE *fd = fopen(f.fn_str(), "r");
if (!fd)
{
return FALSE;
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceToken(fd);
- char *name = copystring(wxResourceBuffer);
+ wxChar *name = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
wxGetResourceToken(fd);
- char *value = copystring(wxResourceBuffer);
- if (isdigit(value[0]))
+ wxChar *value = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
+ if (wxIsdigit(value[0]))
{
- int val = (int)atol(value);
+ int val = (int)wxAtol(value);
wxResourceAddIdentifier(name, val, table);
}
delete[] name;
}
}
-static int ungetc_string(void)
+static int ungetc_string()
{
wxResourceStringPtr --;
return 0;
bool wxEatWhiteSpaceString(char *s)
{
- int ch = getc_string(s);
- if (ch == EOF)
- return TRUE;
-
- if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
- {
- ungetc_string();
- return TRUE;
- }
+ int ch = 0;
- // Eat whitespace
- while (ch == ' ' || ch == 10 || ch == 13 || ch == 9)
- ch = getc_string(s);
- // Check for comment
- if (ch == '/')
- {
- ch = getc_string(s);
- if (ch == '*')
- {
- bool finished = FALSE;
- while (!finished)
+ while ((ch = getc_string(s)) != EOF)
{
- ch = getc_string(s);
- if (ch == EOF)
- return FALSE;
- if (ch == '*')
- {
- int newCh = getc_string(s);
- if (newCh == '/')
- finished = TRUE;
- else
- {
+ switch (ch)
+ {
+ case ' ':
+ case 0x0a:
+ case 0x0d:
+ case 0x09:
+ break;
+ case '/':
+ {
+ int prev_ch = ch;
+ ch = getc_string(s);
+ if (ch == EOF)
+ {
+ ungetc_string();
+ return TRUE;
+ }
+
+ if (ch == '*')
+ {
+ // Eat C comment
+ prev_ch = 0;
+ while ((ch = getc_string(s)) != EOF)
+ {
+ if (ch == '/' && prev_ch == '*')
+ break;
+ prev_ch = ch;
+ }
+ }
+ else
+ {
+ ungetc_string();
+ ungetc_string();
+ return TRUE;
+ }
+ }
+ break;
+ default:
ungetc_string();
- }
- }
+ return TRUE;
+
+ }
}
- }
- else // False alarm
- return FALSE;
- }
- else if (ch != EOF)
- ungetc_string();
- return wxEatWhiteSpaceString(s);
+ return FALSE;
}
bool wxGetResourceTokenString(char *s)
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc_string(s);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
static char *name = "....";
with possible comments.
*/
-
-bool wxResourceReadOneResourceString(char *s, PrologDatabase& db, bool *eof, wxResourceTable *table)
+
+bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceTokenString(s))
{
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceTokenString(s);
- char *name = copystring(wxResourceBuffer);
+ wxChar *name = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
wxGetResourceTokenString(s);
- char *value = copystring(wxResourceBuffer);
- if (isalpha(value[0]))
+ wxChar *value = copystring(wxConvCurrent->cMB2WX(wxResourceBuffer));
+ if (wxIsdigit(value[0]))
{
- int val = (int)atol(value);
+ int val = (int)wxAtol(value);
wxResourceAddIdentifier(name, val, table);
}
else
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
/*
*/
else if (strcmp(wxResourceBuffer, "static") != 0)
{
- char buf[300];
- strcpy(buf, _("Found "));
- strncat(buf, wxResourceBuffer, 30);
- strcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxChar buf[300];
+ wxStrcpy(buf, _("Found "));
+ wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
+ wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
wxLogWarning(buf);
return FALSE;
}
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceTokenString(s))
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
return FALSE;
}
- char nameBuf[100];
- strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+ wxChar nameBuf[100];
+ wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
+ nameBuf[99] = 0;
+
// =
if (!wxGetResourceTokenString(s))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
if (!s)
return FALSE;
-
- // Turn backslashes into spaces
+
+ // Turn backslashes into spaces
if (s)
{
int len = strlen(s);
}
}
- PrologDatabase db;
+ wxExprDatabase db;
wxResourceStringPtr = 0;
bool eof = FALSE;
* resource loading facility
*/
-bool wxWindow::LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
+bool wxWindowBase::LoadFromResource(wxWindow *parent, const wxString& resourceName, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
- wxItemResource *resource = table->FindResource((const char *)resourceName);
+
+ wxItemResource *resource = table->FindResource((const wxChar *)resourceName);
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
- if (!resource || !resource->GetType() ||
- ! ((strcmp(resource->GetType(), "wxDialog") == 0) || (strcmp(resource->GetType(), "wxPanel") == 0)))
+ if (!resource || (resource->GetType() == T("")) ||
+ ! ((resource->GetType() == T("wxDialog")) || (resource->GetType() == T("wxPanel"))))
return FALSE;
- char *title = resource->GetTitle();
+ wxString title(resource->GetTitle());
long theWindowStyle = resource->GetStyle();
bool isModal = (resource->GetValue1() != 0);
int x = resource->GetX();
int y = resource->GetY();
int width = resource->GetWidth();
int height = resource->GetHeight();
- char *name = resource->GetName();
-
- wxFont *theFont = resource->GetFont();
+ wxString name = resource->GetName();
if (IsKindOf(CLASSINFO(wxDialog)))
{
wxDialog *dialogBox = (wxDialog *)this;
- long modalStyle = isModal ? wxDIALOG_MODAL : 0;
+ long modalStyle = isModal ? wxDIALOG_MODAL : 0;
if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
return FALSE;
- dialogBox->SetClientSize(width, height);
+
+ // 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)))
+ {
+ wxPanel* panel = (wxPanel *)this;
+ if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
+ return FALSE;
}
else
{
return FALSE;
}
- if (theFont)
- SetFont(*theFont);
+ if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
+ {
+ // No need to do this since it's done in wxPanel or wxDialog constructor.
+ // SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ }
+ else
+ {
+ if (resource->GetFont().Ok())
+ SetFont(resource->GetFont());
+ if (resource->GetBackgroundColour().Ok())
+ SetBackgroundColour(resource->GetBackgroundColour());
+ }
+
+ // Should have some kind of font at this point
+ if (!GetFont().Ok())
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ if (!GetBackgroundColour().Ok())
+ SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
- if (resource->GetBackgroundColour())
- SetBackgroundColour(*resource->GetBackgroundColour());
+ // 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);
+
+ wxPoint pt = ConvertDialogToPixels(wxPoint(x, y));
+ Move(pt.x, pt.y);
+ }
- // TODO
- if (resource->GetLabelColour())
- SetForegroundColour(*resource->GetLabelColour());
- else if (resource->GetButtonColour())
- SetForegroundColour(*resource->GetButtonColour());
-
// Now create children
wxNode *node = resource->GetChildren().First();
while (node)
{
wxItemResource *childResource = (wxItemResource *)node->Data();
-
- (void) CreateItem(childResource, table);
+
+ (void) CreateItem(childResource, resource, table);
node = node->Next();
}
return TRUE;
}
-wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxResourceTable *table)
+wxControl *wxWindowBase::CreateItem(const wxItemResource *resource, const wxItemResource* parentResource, const wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
- return table->CreateItem((wxWindow *)this, (wxItemResource *)resource);
+ return table->CreateItem((wxWindow *)this, resource, parentResource);
}
-#endif // USE_WX_RESOURCES
+#ifdef __VISUALC__
+ #pragma warning(default:4706) // assignment within conditional expression
+#endif // VC++
+
+#endif
+ // BC++/Win16
+
+#endif // wxUSE_WX_RESOURCES