#pragma hdrstop
#endif
+#if wxUSE_WX_RESOURCES
+
+#ifdef _MSC_VER
+ #pragma warning(disable:4706) // assignment within conditional expression
+#endif // VC++
+
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/setup.h"
#include "wx/log.h"
-#if wxUSE_WX_RESOURCES
-
#include <ctype.h>
#include <math.h>
#include <stdlib.h>
/*
* Resource table
*/
-
+
wxResourceTable::wxResourceTable():wxHashTable(wxKEY_STRING), identifiers(wxKEY_STRING)
{
}
{
ClearTable();
}
-
+
wxItemResource *wxResourceTable::FindResource(const wxString& name) const
{
wxItemResource *item = (wxItemResource *)Get((char *)(const char *)name);
break;
}
}
-
+
delete item;
return TRUE;
}
{
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"))
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;
dialogItem->SetName(name);
dialogItem->SetTitle(title);
dialogItem->SetSize(x, y, width, height);
-
+
if (backColourHex != "")
{
int r = 0;
controlItem->SetValue4(str);
count ++;
-
+
wxExpr *valueList = (wxExpr *) NULL;
// Check for default value list
if ((valueList = expr->Nth(count)) && (valueList->Type() == PrologList))
return controlItem;
}
-// Forward declaration
+// Forward declaration
wxItemResource *wxResourceInterpretMenu1(wxResourceTable& table, wxExpr *expr);
/*
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 *subMenuExpr = expr->GetFirst();
while (subMenuExpr && (subMenuExpr->Type() != PrologList))
subMenuExpr = subMenuExpr->GetNext();
-
+
while (subMenuExpr)
{
wxItemResource *child = wxResourceInterpretMenuItem(table, subMenuExpr);
expr->GetAttributeValue("menu", &listExpr);
if (!listExpr)
return (wxItemResource *) NULL;
-
+
wxItemResource *menuResource = wxResourceInterpretMenuItem(table, listExpr);
if (!menuResource)
{
menuResource->SetName(name);
}
-
+
return menuResource;
}
wxItemResource *resource = new wxItemResource;
resource->SetType("wxMenu");
// resource->SetType(wxTYPE_MENU);
-
+
wxExpr *element = listExpr->GetFirst();
while (element)
{
{
resource->SetName(name);
}
-
+
return resource;
}
}
else
bitmapSpec->SetValue1(0);
-
+
if (platformExpr && platformExpr->StringValue())
{
wxString plat(platformExpr->StringValue());
if (yresExpr)
yres = (int)yresExpr->IntegerValue();
bitmapSpec->SetSize(0, 0, xres, yres);
-
+
bitmapItem->GetChildren().Append(bitmapSpec);
}
}
}
bitmapExpr = bitmapExpr->GetNext();
}
-
+
return bitmapItem;
}
int weight = wxNORMAL;
int underline = 0;
wxString faceName("");
-
+
wxExpr *pointExpr = expr->Nth(0);
wxExpr *familyExpr = expr->Nth(1);
wxExpr *styleExpr = expr->Nth(2);
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc(fd);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
static char *name = "....";
with possible comments.
*/
-
+
bool wxResourceReadOneResource(FILE *fd, wxExprDatabase& db, bool *eof, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceToken(fd))
{
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
else if (strcmp(wxResourceBuffer, "#include") == 0)
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceToken(fd))
{
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+
// =
if (!wxGetResourceToken(fd))
{
/*
* Parses string window style into integer window style
*/
-
+
/*
* Style flag parsing, e.g.
* "wxSYSTEM_MENU | wxBORDER" -> integer
{ "wxLB_SORT", wxLB_SORT },
{ "wxLB_OWNERDRAW", wxLB_OWNERDRAW },
{ "wxLB_HSCROLL", wxLB_HSCROLL },
-
+
/* wxComboxBox */
{ "wxCB_SIMPLE", wxCB_SIMPLE },
{ "wxCB_DROPDOWN", wxCB_DROPDOWN },
{ "wxCB_READONLY", wxCB_READONLY },
{ "wxCB_SORT", wxCB_SORT },
-
+
/* wxGauge */
{ "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR },
{ "wxGA_HORIZONTAL", wxGA_HORIZONTAL },
{ "wxALIGN_CENTRE", wxALIGN_CENTRE},
{ "wxALIGN_RIGHT", wxALIGN_RIGHT},
{ "wxCOLOURED", wxCOLOURED},
-
+
/* wxToolBar */
{ "wxTB_3DBUTTONS", wxTB_3DBUTTONS},
{ "wxTB_HORIZONTAL", wxTB_HORIZONTAL},
{ "wxMINIMIZE_BOX", wxMINIMIZE_BOX},
{ "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX},
{ "wxRESIZE_BOX", wxRESIZE_BOX},
- { "wxDEFAULT_FRAME", wxDEFAULT_FRAME},
+ { "wxDEFAULT_FRAME_STYLE", wxDEFAULT_FRAME_STYLE},
+ { "wxDEFAULT_FRAME", wxDEFAULT_FRAME_STYLE},
{ "wxDEFAULT_DIALOG_STYLE", wxDEFAULT_DIALOG_STYLE},
{ "wxBORDER", wxBORDER},
{ "wxRETAINED", wxRETAINED},
* Load a bitmap from a wxWindows resource, choosing an optimum
* depth and appropriate type.
*/
-
+
wxBitmap wxResourceCreateBitmap(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
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)
{
wxLogWarning(_("Failed to find XBM resource %s.\n"
"Forgot to use wxResourceLoadBitmapData?"), (const char*) name);
- return (wxBitmap *) NULL;
+ return wxNullBitmap;
}
return wxBitmap(item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()) ;
#else
{
wxLogWarning(_("Failed to find XPM resource %s.\n"
"Forgot to use wxResourceLoadBitmapData?"), (const char*) name);
- return (wxBitmap *) NULL;
+ return wxNullBitmap;
}
return wxBitmap(item->GetValue1());
#else
* Load an icon from a wxWindows resource, choosing an optimum
* depth and appropriate type.
*/
-
+
wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *item = table->FindResource(resource);
if (item)
{
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)
{
wxLogWarning(_("Failed to find XBM resource %s.\n"
"Forgot to use wxResourceLoadIconData?"), (const char*) name);
- return (wxIcon *) NULL;
+ return wxNullIcon;
}
- return 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
else
{
wxLogWarning(_("Icon resource specification %s not found."), (const char*) resource);
- return (wxIcon *) NULL;
+ return wxNullIcon;
}
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu"))
{
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *menuResource = table->FindResource(resource);
if (menuResource && (menuResource->GetType() != "") && (menuResource->GetType() == "wxMenu"))
// if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
{
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;
-
+
table->identifiers.Put(name, (wxObject *)value);
return TRUE;
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
return (int)table->identifiers.Get(name);
}
{
if (!table)
table = wxDefaultResourceTable;
-
+
FILE *fd = fopen(f, "r");
if (!fd)
{
int ch = getc_string(s);
if (ch == EOF)
return TRUE;
-
+
if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
{
ungetc_string();
wxReallocateResourceBuffer();
wxResourceBuffer[wxResourceBufferCount] = (char)ch;
wxResourceBufferCount ++;
-
+
ch = getc_string(s);
}
wxResourceBuffer[wxResourceBufferCount] = 0;
static char *name = "....";
with possible comments.
*/
-
+
bool wxResourceReadOneResourceString(char *s, wxExprDatabase& db, bool *eof, wxResourceTable *table)
{
if (!table)
table = wxDefaultResourceTable;
-
+
// static or #define
if (!wxGetResourceTokenString(s))
{
}
delete[] name;
delete[] value;
-
+
return TRUE;
}
/*
wxLogWarning(_("Expected 'char' whilst parsing resource."));
return FALSE;
}
-
+
// *name
if (!wxGetResourceTokenString(s))
{
}
char nameBuf[100];
strncpy(nameBuf, wxResourceBuffer+1, 99);
-
+
// =
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);
{
if (!table)
table = wxDefaultResourceTable;
-
+
wxItemResource *resource = table->FindResource((const char *)resourceName);
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
if (!resource || !resource->GetType() ||
}
// Should have some kind of font at this point
- if (!GetFont()->Ok())
+ if (!GetFont().Ok())
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
if (!GetBackgroundColour().Ok())
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
while (node)
{
wxItemResource *childResource = (wxItemResource *)node->Data();
-
+
(void) CreateItem(childResource, resource, table);
node = node->Next();
return table->CreateItem((wxWindow *)this, resource, parentResource);
}
+#ifdef _MSC_VER
+ #pragma warning(default:4706) // assignment within conditional expression
+#endif // VC++
+
#endif // wxUSE_WX_RESOURCES