#include "wx/intl.h"
#endif
+#include "wx/treebase.h"
+#include "wx/listctrl.h"
+
#if wxUSE_RADIOBTN
#include "wx/radiobut.h"
#endif
name = item->GetTitle();
if (name == wxT(""))
name = wxT("no name");
-
+
// Delete existing resource, if any.
Delete(name);
-
+
Put(name, item);
}
}
node = Next();
}
-
+
delete item;
return TRUE;
}
{
wxExprDatabase db;
int len = is->StreamSize() ;
-
+
bool eof = FALSE;
while ( is->TellI() + 10 < len) // it's a hack because the streams dont support EOF
{
bool wxResourceTable::ParseResourceFile(const wxString& filename)
{
wxExprDatabase db;
-
-#if defined(__WXMAC__) && !defined(__UNIX__)
- FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
-#else
+
FILE *fd = wxFopen(filename, _T("r"));
-#endif
if (!fd)
return FALSE;
bool eof = FALSE;
wxLogWarning(_("Ill-formed resource file syntax."));
return FALSE;
}
-
+
return wxResourceInterpretResources(*this, db);
}
int id = childResource->GetId();
if ( id == 0 )
id = -1;
-
+
bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0);
-
+
wxControl *control = (wxControl *) NULL;
wxString itemType(childResource->GetType());
-
+
wxPoint pos;
wxSize size;
if (dlgUnits)
pos = wxPoint(childResource->GetX(), childResource->GetY());
size = wxSize(childResource->GetWidth(), childResource->GetHeight());
}
-
+
if (itemType == wxString(wxT("wxButton")) || itemType == wxString(wxT("wxBitmapButton")))
{
if (childResource->GetValue4() != wxT(""))
if (!bitmap.Ok())
bitmap.LoadFile("cross_bmp", wxBITMAP_TYPE_BMP_RESOURCE);
#endif
-
+
if (bitmap.Ok())
control = new wxStaticBitmap(parent, id, bitmap, pos, size,
childResource->GetStyle(), childResource->GetName());
{
control = new wxCheckBox(parent, id, childResource->GetTitle(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
-
+
((wxCheckBox *)control)->SetValue((childResource->GetValue1() != 0));
}
#if wxUSE_GAUGE
{
control = new wxGauge(parent, id, (int)childResource->GetValue2(), pos, size,
childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
-
+
((wxGauge *)control)->SetValue((int)childResource->GetValue1());
}
#endif
*/
((wxScrollBar *)control)->SetScrollbar((int)childResource->GetValue1(),(int)childResource->GetValue2(),
(int)childResource->GetValue3(),(int)(long)childResource->GetValue5(),FALSE);
-
+
}
#endif
else if (itemType == wxString(wxT("wxSlider")))
}
control = new wxListBox(parent, id, pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
-
+
if (strings)
delete[] strings;
}
}
control = new wxChoice(parent, id, pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
-
+
if (strings)
delete[] strings;
}
}
control = new wxComboBox(parent, id, childResource->GetValue4(), pos, size,
noStrings, strings, childResource->GetStyle(), wxDefaultValidator, childResource->GetName());
-
+
if (strings)
delete[] strings;
}
control = new wxRadioBox(parent, (wxWindowID) id, wxString(childResource->GetTitle()), pos, size,
noStrings, strings, (int)childResource->GetValue1(), childResource->GetStyle(), wxDefaultValidator,
childResource->GetName());
-
+
if (strings)
delete[] strings;
}
-
+
if ((parentResource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
{
// Don't set font; will be inherited from parent.
if (control && childResource->GetFont().Ok())
{
control->SetFont(childResource->GetFont());
-
+
#ifdef __WXMSW__
// Force the layout algorithm since the size changes the layout
if (control->IsKindOf(CLASSINFO(wxRadioBox)))
{
wxExpr *clause = (wxExpr *)node->Data();
wxString functor(clause->Functor());
-
+
wxItemResource *item = (wxItemResource *) NULL;
if (functor == wxT("dialog"))
item = wxResourceInterpretDialog(table, clause);
item = wxResourceInterpretBitmap(table, clause);
else if (functor == wxT("icon"))
item = wxResourceInterpretIcon(table, clause);
-
+
if (item)
{
// Remove any existing resource of same name
wxString backColourHex = wxT("");
wxString labelColourHex = wxT("");
wxString buttonColourHex = wxT("");
-
+
long windowStyle = wxDEFAULT_DIALOG_STYLE;
if (isPanel)
windowStyle = 0;
-
+
int x = 0; int y = 0; int width = -1; int height = -1;
int isModal = 0;
wxExpr *labelFontExpr = (wxExpr *) NULL;
expr->GetAttributeValue(wxT("background_colour"), backColourHex);
expr->GetAttributeValue(wxT("label_colour"), labelColourHex);
expr->GetAttributeValue(wxT("button_colour"), buttonColourHex);
-
+
int useDialogUnits = 0;
expr->GetAttributeValue(wxT("use_dialog_units"), useDialogUnits);
if (useDialogUnits != 0)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_DIALOG_UNITS);
-
+
int useDefaults = 0;
expr->GetAttributeValue(wxT("use_system_defaults"), useDefaults);
if (useDefaults != 0)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_USE_DEFAULTS);
-
+
int id = 0;
expr->GetAttributeValue(wxT("id"), id);
dialogItem->SetId(id);
-
+
if (style != wxT(""))
{
windowStyle = wxParseWindowStyle(style);
dialogItem->SetValue1(isModal);
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 (style.Find(wxT("VERTICAL_LABEL")) != -1)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL);
else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1)
- dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
-
+ dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
+
if (backColourHex != wxT(""))
{
int r = 0;
b = wxHexToDec(buttonColourHex.Mid(4, 2));
dialogItem->SetButtonColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
-
+
if (fontExpr)
dialogItem->SetFont(wxResourceInterpretFontSpec(fontExpr));
else if (buttonFontExpr)
dialogItem->SetFont(wxResourceInterpretFontSpec(buttonFontExpr));
else if (labelFontExpr)
dialogItem->SetFont(wxResourceInterpretFontSpec(labelFontExpr));
-
+
// Now parse all controls
wxExpr *controlExpr = expr->GetFirst();
while (controlExpr)
wxItemResource *wxResourceInterpretControl(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *controlItem = new wxItemResource;
-
+
// First, find the standard features of a control definition:
// [optional integer/string id], control name, title, style, name, x, y, width, height
-
+
wxString controlType;
wxString style;
wxString title;
long windowStyle = 0;
int x = 0; int y = 0; int width = -1; int height = -1;
int count = 0;
-
+
wxExpr *expr1 = expr->Nth(0);
-
+
if ( expr1->Type() == PrologString || expr1->Type() == PrologWord )
{
if ( wxIsValidControlClass(expr1->StringValue()) )
controlType = expr->Nth(1)->StringValue();
count = 2;
}
-
+
expr1 = expr->Nth(count);
count ++;
if ( expr1 )
title = expr1->StringValue();
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
style = expr1->StringValue();
windowStyle = wxParseWindowStyle(style);
}
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
name = expr1->StringValue();
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
x = (int)expr1->IntegerValue();
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
y = (int)expr1->IntegerValue();
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
width = (int)expr1->IntegerValue();
-
+
expr1 = expr->Nth(count);
count ++;
if (expr1)
height = (int)expr1->IntegerValue();
-
+
controlItem->SetStyle(windowStyle);
controlItem->SetName(name);
controlItem->SetTitle(title);
controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_VERTICAL_LABEL);
else if (style.Find(wxT("HORIZONTAL_LABEL")) != -1)
controlItem->SetResourceStyle(controlItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
-
+
if (controlType == wxT("wxButton"))
{
// Check for bitmap resource name (in case loading old-style resource file)
{
wxString str(expr->Nth(count)->StringValue());
count ++;
-
+
if (str != wxT(""))
{
controlItem->SetValue4(str);
wxString str(expr->Nth(count)->StringValue());
controlItem->SetValue4(str);
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
{
controlItem->SetValue1(expr->Nth(count)->IntegerValue());
count ++;
-
+
// Check for range
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
controlItem->SetValue2(expr->Nth(count)->IntegerValue());
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// Skip past the obsolete label font spec if there are two consecutive specs
{
controlItem->SetValue1(expr->Nth(count)->IntegerValue());
count ++;
-
+
// Check for min
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
controlItem->SetValue2(expr->Nth(count)->IntegerValue());
count ++;
-
+
// Check for max
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
controlItem->SetValue3(expr->Nth(count)->IntegerValue());
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// controlItem->SetLabelFont(wxResourceInterpretFontSpec(expr->Nth(count)));
// do nothing
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
controlItem->SetFont(wxResourceInterpretFontSpec(expr->Nth(count)));
}
{
controlItem->SetValue1(expr->Nth(count)->IntegerValue());
count ++;
-
+
// PAGE LENGTH
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
controlItem->SetValue2(expr->Nth(count)->IntegerValue());
count ++;
-
+
// OBJECT LENGTH
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
controlItem->SetValue3(expr->Nth(count)->IntegerValue());
count ++;
-
+
// VIEW LENGTH
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
controlItem->SetValue5(expr->Nth(count)->IntegerValue());
else if (controlType == wxT("wxListBox"))
{
wxExpr *valueList = (wxExpr *) NULL;
-
- if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
+
+ if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList))
{
wxStringList stringList;
wxExpr *stringExpr = valueList->GetFirst();
/*
controlItem->SetValue1(wxLB_SINGLE);
*/
- if ((mult = expr->Nth(count)) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord)))
+ if (((mult = expr->Nth(count)) != 0) && ((mult->Type() == PrologString)||(mult->Type() == PrologWord)))
{
/*
wxString m(mult->StringValue());
{
wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
- if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
+ if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList))
{
wxStringList stringList;
wxExpr *stringExpr = valueList->GetFirst();
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
-
+
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// Skip past the obsolete label font spec if there are two consecutive specs
{
wxString str(textValue->StringValue());
controlItem->SetValue4(str);
-
+
count ++;
-
+
wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
- if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
+ if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList))
{
wxStringList stringList;
wxExpr *stringExpr = valueList->GetFirst();
stringExpr = stringExpr->GetNext();
}
controlItem->SetStringValues(stringList);
-
+
count ++;
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// Skip past the obsolete label font spec if there are two consecutive specs
{
wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
- if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
+ if (((valueList = expr->Nth(count)) != 0) && (valueList->Type() == PrologList))
{
wxStringList stringList;
wxExpr *stringExpr = valueList->GetFirst();
}
controlItem->SetStringValues(stringList);
count ++;
-
+
// majorDim (number of rows or cols)
if (expr->Nth(count) && (expr->Nth(count)->Type() == PrologInteger))
{
}
else
controlItem->SetValue1(0);
-
+
if (expr->Nth(count) && expr->Nth(count)->Type() == PrologList)
{
// Skip past the obsolete label font spec if there are two consecutive specs
wxItemResource *wxResourceInterpretMenuItem(wxResourceTable& table, wxExpr *expr)
{
wxItemResource *item = new wxItemResource;
-
+
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)
{
}
if (checkableExpr)
item->SetValue2(checkableExpr->IntegerValue());
-
+
// Find the first expression that's a list, for submenu
wxExpr *subMenuExpr = expr->GetFirst();
while (subMenuExpr && (subMenuExpr->Type() != PrologList))
subMenuExpr = subMenuExpr->GetNext();
-
+
while (subMenuExpr)
{
wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr);
expr->GetAttributeValue(wxT("menu"), &listExpr);
if (!listExpr)
return (wxItemResource *) NULL;
-
+
wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr);
-
+
if (!menuResource)
return (wxItemResource *) NULL;
-
+
wxString name;
if (expr->GetAttributeValue(wxT("name"), name))
{
menuResource->SetName(name);
}
-
+
return menuResource;
}
expr->GetAttributeValue(wxT("menu"), &listExpr);
if (!listExpr)
return (wxItemResource *) NULL;
-
+
wxItemResource *resource = new wxItemResource;
resource->SetType(wxT("wxMenu"));
// resource->SetType(wxTYPE_MENU);
-
+
wxExpr *element = listExpr->GetFirst();
while (element)
{
resource->GetChildren().Append(menuResource);
element = element->GetNext();
}
-
+
wxString name;
if (expr->GetAttributeValue(wxT("name"), name))
{
resource->SetName(name);
}
-
+
return resource;
}
wxItemResource *bitmapSpec = new wxItemResource;
// bitmapSpec->SetType(wxTYPE_BITMAP);
bitmapSpec->SetType(wxT("wxBitmap"));
-
+
// List is of form: [filename, bitmaptype, platform, colours, xresolution, yresolution]
// where everything after 'filename' is optional.
wxExpr *nameExpr = listExpr->Nth(0);
}
else
bitmapSpec->SetValue1(0);
-
+
if (platformExpr && platformExpr->StringValue() != wxT(""))
{
wxString plat(platformExpr->StringValue());
}
else
bitmapSpec->SetValue2(RESOURCE_PLATFORM_ANY);
-
+
if (coloursExpr)
bitmapSpec->SetValue3(coloursExpr->IntegerValue());
int xres = 0;
if (yresExpr)
yres = (int)yresExpr->IntegerValue();
bitmapSpec->SetSize(0, 0, xres, yres);
-
+
bitmapItem->GetChildren().Append(bitmapSpec);
}
}
}
bitmapExpr = bitmapExpr->GetNext();
}
-
+
return bitmapItem;
}
{
if (expr->Type() != PrologList)
return wxNullFont;
-
+
int point = 10;
int family = wxSWISS;
int style = wxNORMAL;
int weight = wxNORMAL;
int underline = 0;
wxString faceName(wxT(""));
-
+
wxExpr *pointExpr = expr->Nth(0);
wxExpr *familyExpr = expr->Nth(1);
wxExpr *styleExpr = expr->Nth(2);
wxExpr *faceNameExpr = expr->Nth(5);
if (pointExpr)
point = (int)pointExpr->IntegerValue();
-
+
wxString str;
if (familyExpr)
{
underline = (int)underlineExpr->IntegerValue();
if (faceNameExpr)
faceName = faceNameExpr->StringValue();
-
+
wxFont font(point, family, style, weight, (underline != 0), faceName);
return font;
}
static bool wxEatWhiteSpace(FILE *fd)
{
int ch = 0;
-
+
while ((ch = getc(fd)) != EOF)
{
switch (ch)
ungetc(prev_ch, fd);
return TRUE;
}
-
+
if (ch == '*')
{
// Eat C comment
default:
ungetc(ch, fd);
return TRUE;
-
+
}
}
return FALSE;
is->Ungetch(ch);
return TRUE;
}
-
+
// Eat whitespace
while (ch == ' ' || ch == 10 || ch == 13 || ch == 9)
ch = is->GetC();
wxReallocateResourceBuffer();
wxResourceBuffer[0] = 0;
wxEatWhiteSpace(fd);
-
+
int ch = getc(fd);
if (ch == '"')
{
ungetc(newCh, fd);
}
}
-
+
if (wxResourceBufferCount >= wxResourceBufferSize-1)
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)actualCh;
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc(fd);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
wxReallocateResourceBuffer();
wxResourceBuffer[0] = 0;
wxEatWhiteSpace(is);
-
+
int ch = is->GetC() ;
if (ch == '"')
{
is->Ungetch(newCh);
}
}
-
+
if (wxResourceBufferCount >= wxResourceBufferSize-1)
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)actualCh;
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = is->GetC();
}
wxResourceBuffer[wxResourceBufferCount] = 0;
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceToken(fd);
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
wxLogWarning(buf);
return FALSE;
}
-
+
// char
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
wxChar nameBuf[100];
wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
nameBuf[99] = 0;
-
+
// =
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
return FALSE;
}
-
+
// String
if (!wxGetResourceToken(fd))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceToken(fd);
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
wxLogWarning(buf);
return FALSE;
}
-
+
// char
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+
// =
if (!wxGetResourceToken(fd))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
return FALSE;
}
-
+
// String
if (!wxGetResourceToken(fd))
{
{
if (!s)
return (wxChar*) NULL;
-
+
static wxChar buf[150];
int len = wxStrlen(s);
int j = 0;
ii ++;
}
buf[j] = 0;
-
+
// Eat whitespace and conjunction characters
while ((ii < len) &&
((s[ii] == wxT(' ')) || (s[ii] == wxT('|')) || (s[ii] == wxT(','))))
{ wxT("wxLB_SORT"), wxLB_SORT },
{ wxT("wxLB_OWNERDRAW"), wxLB_OWNERDRAW },
{ wxT("wxLB_HSCROLL"), wxLB_HSCROLL },
-
+
/* wxComboxBox */
{ wxT("wxCB_SIMPLE"), wxCB_SIMPLE },
{ wxT("wxCB_DROPDOWN"), wxCB_DROPDOWN },
{ wxT("wxCB_READONLY"), wxCB_READONLY },
{ wxT("wxCB_SORT"), wxCB_SORT },
-
+
/* wxGauge */
{ wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR },
{ wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL },
{ wxT("wxGA_VERTICAL"), wxGA_VERTICAL },
-
+
/* wxTextCtrl */
{ wxT("wxPASSWORD"), wxPASSWORD},
{ wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER},
{ wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER},
{ wxT("wxTE_MULTILINE"), wxTE_MULTILINE},
{ wxT("wxTE_NO_VSCROLL"), wxTE_NO_VSCROLL},
-
+
/* wxRadioBox/wxRadioButton */
{ wxT("wxRB_GROUP"), wxRB_GROUP },
{ wxT("wxRA_SPECIFY_COLS"), wxRA_SPECIFY_COLS },
{ wxT("wxRA_SPECIFY_ROWS"), wxRA_SPECIFY_ROWS },
{ wxT("wxRA_HORIZONTAL"), wxRA_HORIZONTAL },
{ wxT("wxRA_VERTICAL"), wxRA_VERTICAL },
-
+
/* wxSlider */
{ wxT("wxSL_HORIZONTAL"), wxSL_HORIZONTAL },
{ wxT("wxSL_VERTICAL"), wxSL_VERTICAL },
{ wxT("wxSL_BOTTOM"), wxSL_BOTTOM },
{ wxT("wxSL_BOTH"), wxSL_BOTH },
{ wxT("wxSL_SELRANGE"), wxSL_SELRANGE },
-
+
/* wxScrollBar */
{ wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL },
{ wxT("wxSB_VERTICAL"), wxSB_VERTICAL },
-
+
/* wxButton */
{ wxT("wxBU_AUTODRAW"), wxBU_AUTODRAW },
{ wxT("wxBU_NOAUTODRAW"), wxBU_NOAUTODRAW },
-
+
/* wxTreeCtrl */
{ wxT("wxTR_HAS_BUTTONS"), wxTR_HAS_BUTTONS },
{ wxT("wxTR_EDIT_LABELS"), wxTR_EDIT_LABELS },
{ wxT("wxTR_LINES_AT_ROOT"), wxTR_LINES_AT_ROOT },
-
+
/* wxListCtrl */
{ wxT("wxLC_ICON"), wxLC_ICON },
{ wxT("wxLC_SMALL_ICON"), wxLC_SMALL_ICON },
{ wxT("wxLC_SINGLE_SEL"), wxLC_SINGLE_SEL },
{ wxT("wxLC_SORT_ASCENDING"), wxLC_SORT_ASCENDING },
{ wxT("wxLC_SORT_DESCENDING"), wxLC_SORT_DESCENDING },
-
+
/* wxSpinButton */
{ wxT("wxSP_VERTICAL"), wxSP_VERTICAL},
{ wxT("wxSP_HORIZONTAL"), wxSP_HORIZONTAL},
{ wxT("wxSP_ARROW_KEYS"), wxSP_ARROW_KEYS},
{ wxT("wxSP_WRAP"), wxSP_WRAP},
-
+
/* wxSplitterWnd */
{ wxT("wxSP_NOBORDER"), wxSP_NOBORDER},
{ wxT("wxSP_3D"), wxSP_3D},
{ wxT("wxSP_BORDER"), wxSP_BORDER},
-
+
/* wxTabCtrl */
{ wxT("wxTC_MULTILINE"), wxTC_MULTILINE},
{ wxT("wxTC_RIGHTJUSTIFY"), wxTC_RIGHTJUSTIFY},
{ wxT("wxTC_FIXEDWIDTH"), wxTC_FIXEDWIDTH},
{ wxT("wxTC_OWNERDRAW"), wxTC_OWNERDRAW},
-
+
/* wxStatusBar95 */
{ wxT("wxST_SIZEGRIP"), wxST_SIZEGRIP},
-
+
/* wxControl */
{ wxT("wxFIXED_LENGTH"), wxFIXED_LENGTH},
{ wxT("wxALIGN_LEFT"), wxALIGN_LEFT},
{ wxT("wxALIGN_CENTRE"), wxALIGN_CENTRE},
{ wxT("wxALIGN_RIGHT"), wxALIGN_RIGHT},
{ wxT("wxCOLOURED"), wxCOLOURED},
-
+
/* wxToolBar */
{ wxT("wxTB_3DBUTTONS"), wxTB_3DBUTTONS},
{ wxT("wxTB_HORIZONTAL"), wxTB_HORIZONTAL},
{ wxT("wxTB_VERTICAL"), wxTB_VERTICAL},
{ wxT("wxTB_FLAT"), wxTB_FLAT},
-
+
/* wxDialog */
{ wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL },
-
+
/* Generic */
{ wxT("wxVSCROLL"), wxVSCROLL },
{ wxT("wxHSCROLL"), wxHSCROLL },
{ wxT("wxCLIP_CHILDREN"), wxCLIP_CHILDREN},
{ wxT("wxCLIP_SIBLINGS"), wxCLIP_SIBLINGS},
{ wxT("wxTAB_TRAVERSAL"), 0}, // Compatibility only
-
+
{ wxT("wxTINY_CAPTION_HORIZ"), wxTINY_CAPTION_HORIZ},
{ wxT("wxTINY_CAPTION_VERT"), wxTINY_CAPTION_VERT},
-
+
// Text font families
{ wxT("wxDEFAULT"), wxDEFAULT},
{ wxT("wxDECORATIVE"), wxDECORATIVE},
{ wxT("wxCAP_ROUND"), wxCAP_ROUND},
{ wxT("wxCAP_PROJECTING"), wxCAP_PROJECTING},
{ wxT("wxCAP_BUTT"), wxCAP_BUTT},
-
+
// Logical ops
{ wxT("wxCLEAR"), wxCLEAR},
{ wxT("wxXOR"), wxXOR},
{ wxT("wxNAND"), wxNAND},
{ wxT("wxOR"), wxOR},
{ wxT("wxSET"), wxSET},
-
+
{ wxT("wxFLOOD_SURFACE"), wxFLOOD_SURFACE},
{ wxT("wxFLOOD_BORDER"), wxFLOOD_BORDER},
{ wxT("wxODDEVEN_RULE"), wxODDEVEN_RULE},
{ wxT("wxUSER_COLOURS"), wxUSER_COLOURS},
{ wxT("wxVERTICAL_LABEL"), 0},
{ wxT("wxHORIZONTAL_LABEL"), 0},
-
+
// Bitmap types (not strictly styles)
{ wxT("wxBITMAP_TYPE_XPM"), wxBITMAP_TYPE_XPM},
{ wxT("wxBITMAP_TYPE_XBM"), wxBITMAP_TYPE_XBM},
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
}
int thisDepth = wxDisplayDepth();
long thisNoColours = (long)pow(2.0, (double)thisDepth);
-
+
wxItemResource *optResource = (wxItemResource *) NULL;
-
+
// Try to find optimum bitmap for this platform/colour depth
wxNode *node = item->GetChildren().First();
while (node)
int xRes = child->GetWidth();
int yRes = child->GetHeight();
*/
-
+
switch (platform)
{
case RESOURCE_PLATFORM_ANY:
// If no matching resource, fail.
if (!optResource)
return wxNullBitmap;
-
+
wxString name = optResource->GetName();
int bitmapType = (int)optResource->GetValue1();
switch (bitmapType)
}
case wxBITMAP_TYPE_XPM_DATA:
{
-#if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
wxItemResource *item = table->FindResource(name);
if (!item)
{
return wxNullBitmap;
}
return wxBitmap((char **)item->GetValue1());
-#else
- wxLogWarning(_("No XPM facility available!"));
- break;
-#endif
}
default:
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
}
int thisDepth = wxDisplayDepth();
long thisNoColours = (long)pow(2.0, (double)thisDepth);
-
+
wxItemResource *optResource = (wxItemResource *) NULL;
-
+
// Try to find optimum icon for this platform/colour depth
wxNode *node = item->GetChildren().First();
while (node)
int xRes = child->GetWidth();
int yRes = child->GetHeight();
*/
-
+
switch (platform)
{
case RESOURCE_PLATFORM_ANY:
// If no matching resource, fail.
if (!optResource)
return wxNullIcon;
-
+
wxString name = optResource->GetName();
int bitmapType = (int)optResource->GetValue1();
switch (bitmapType)
{
// *** XPM ICON NOT YET IMPLEMENTED IN WXWINDOWS ***
/*
- #if (defined(__WXGTK__)) || (defined(__WXMSW__) && wxUSE_XPM_IN_MSW)
wxItemResource *item = table->FindResource(name);
if (!item)
{
return NULL;
}
return wxIcon((char **)item->GetValue1());
- #else
- wxLogWarning(_("No XPM facility available!"));
- #endif
*/
wxLogWarning(_("No XPM icon facility available!"));
break;
{
#ifdef __WXGTK__
wxLogWarning(_("Icon resource specification %s not found."), (const wxChar*) resource);
+ break;
#else
return wxIcon(name, bitmapType);
#endif
- break;
}
}
return wxNullIcon;
}
}
+#if wxUSE_MENUS
+
wxMenu *wxResourceCreateMenu(wxItemResource *item)
{
wxMenu *menu = new wxMenu;
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu")))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu")))
// if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
return (wxMenu *) NULL;
}
+#endif // wxUSE_MENUS
+
// Global equivalents (so don't have to refer to default table explicitly)
bool wxResourceParseData(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceData(resource);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->ParseResourceFile(filename);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->RegisterResourceBitmapData(name, bits, width, height);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return table->RegisterResourceBitmapData(name, data);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
table->ClearTable();
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
table->identifiers.Put(name, (wxObject *)(long)value);
return TRUE;
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return (int)(long)table->identifiers.Get(name);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
FILE *fd = wxFopen(f, _T("r"));
if (!fd)
{
bool wxEatWhiteSpaceString(char *s)
{
int ch = 0;
-
+
while ((ch = getc_string(s)) != EOF)
{
switch (ch)
ungetc_string();
return TRUE;
}
-
+
if (ch == '*')
{
// Eat C comment
default:
ungetc_string();
return TRUE;
-
+
}
}
return FALSE;
wxReallocateResourceBuffer();
wxResourceBuffer[0] = 0;
wxEatWhiteSpaceString(s);
-
+
int ch = getc_string(s);
if (ch == '"')
{
ungetc_string();
}
}
-
+
if (wxResourceBufferCount >= wxResourceBufferSize-1)
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)actualCh;
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc_string(s);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceTokenString(s))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "#define") == 0)
{
wxGetResourceTokenString(s);
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
/*
wxLogWarning(buf);
return FALSE;
}
-
+
// char
if (!wxGetResourceTokenString(s))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "char") != 0)
{
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceTokenString(s))
{
*eof = TRUE;
return FALSE;
}
-
+
if (wxResourceBuffer[0] != '*')
{
wxLogWarning(_("Expected '*' whilst parsing resource."));
wxChar nameBuf[100];
wxMB2WX(nameBuf, wxResourceBuffer+1, 99);
nameBuf[99] = 0;
-
+
// =
if (!wxGetResourceTokenString(s))
{
*eof = TRUE;
return FALSE;
}
-
+
if (strcmp(wxResourceBuffer, "=") != 0)
{
wxLogWarning(_("Expected '=' whilst parsing resource."));
return FALSE;
}
-
+
// String
if (!wxGetResourceTokenString(s))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
if (!s)
return FALSE;
-
+
// Turn backslashes into spaces
if (s)
{
s[i+1] = ' ';
}
}
-
+
wxExprDatabase db;
wxResourceStringPtr = 0;
-
+
bool eof = FALSE;
while (wxResourceReadOneResourceString(s, db, &eof, table) && !eof)
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *resource = table->FindResource((const wxChar *)resourceName);
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
if (!resource || (resource->GetType() == wxT("")) ||
! ((resource->GetType() == wxT("wxDialog")) || (resource->GetType() == wxT("wxPanel"))))
return FALSE;
-
+
wxString title(resource->GetTitle());
long theWindowStyle = resource->GetStyle();
bool isModal = (resource->GetValue1() != 0) ;
int width = resource->GetWidth();
int height = resource->GetHeight();
wxString name = resource->GetName();
-
- if (IsKindOf(CLASSINFO(wxDialog)))
- {
- wxDialog *dialogBox = (wxDialog *)this;
- long modalStyle = isModal ? wxDIALOG_MODAL : 0;
- if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
- return FALSE;
-
- // Only reset the client size if we know we're not going to do it again below.
- if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0)
- dialogBox->SetClientSize(width, height);
- }
- else if (IsKindOf(CLASSINFO(wxPanel)))
- {
- wxPanel* panel = (wxPanel *)this;
- if (!panel->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle | wxTAB_TRAVERSAL, name))
- return FALSE;
- }
- else
+
+ // this is used for loading wxWizard pages from WXR
+ if ( parent != this )
{
- if (!((wxWindow *)this)->Create(parent, -1, wxPoint(x, y), wxSize(width, height), theWindowStyle, name))
- return FALSE;
+ if (IsKindOf(CLASSINFO(wxDialog)))
+ {
+ wxDialog *dialogBox = (wxDialog *)this;
+ long modalStyle = isModal ? wxDIALOG_MODAL : 0;
+ if (!dialogBox->Create(parent, -1, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
+ return FALSE;
+
+ // Only reset the client size if we know we're not going to do it again below.
+ if ((resource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) == 0)
+ dialogBox->SetClientSize(width, height);
+ }
+ else if (IsKindOf(CLASSINFO(wxPanel)))
+ {
+ wxPanel* panel = (wxPanel *)this;
+ 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))
+ return FALSE;
+ }
}
-
+
if ((resource->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
{
// No need to do this since it's done in wxPanel or wxDialog constructor.
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));
-
+
// 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);
}
-
+
// Now create children
wxNode *node = resource->GetChildren().First();
while (node)
{
wxItemResource *childResource = (wxItemResource *)node->Data();
-
+
(void) CreateItem(childResource, resource, table);
-
+
node = node->Next();
}
return TRUE;