/////////////////////////////////////////////////////////////////////////////
-// Name: resource.cpp
+// Name: contrib/src/deprecated/resource.cpp
// Purpose: Resource system
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "resource.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#endif // VC++
#ifndef WX_PRECOMP
-#include "wx/defs.h"
-#include "wx/setup.h"
-#include "wx/list.h"
-#include "wx/hash.h"
-#include "wx/gdicmn.h"
-#include "wx/utils.h"
-#include "wx/types.h"
-#include "wx/menu.h"
-#include "wx/stattext.h"
-#include "wx/button.h"
-#include "wx/bmpbuttn.h"
-#include "wx/radiobox.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"
-#include "wx/statbmp.h"
-#include "wx/gauge.h"
-#include "wx/textctrl.h"
-#include "wx/msgdlg.h"
-#include "wx/intl.h"
+ #include "wx/list.h"
+ #include "wx/hash.h"
+ #include "wx/gdicmn.h"
+ #include "wx/utils.h"
+ #include "wx/types.h"
+ #include "wx/menu.h"
+ #include "wx/stattext.h"
+ #include "wx/button.h"
+ #include "wx/bmpbuttn.h"
+ #include "wx/radiobox.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"
+ #include "wx/statbmp.h"
+ #include "wx/gauge.h"
+ #include "wx/textctrl.h"
+ #include "wx/msgdlg.h"
+ #include "wx/intl.h"
#endif
#include "wx/treebase.h"
wxItemResource::wxItemResource()
{
- m_itemType = wxT("");
- m_title = wxT("");
- m_name = wxT("");
+ m_itemType = wxEmptyString;
+ m_title = wxEmptyString;
+ m_name = wxEmptyString;
m_windowStyle = 0;
m_x = m_y = m_width = m_height = 0;
m_value1 = m_value2 = m_value3 = m_value5 = 0;
- m_value4 = wxT("");
+ m_value4 = wxEmptyString;
m_windowId = 0;
m_exStyle = 0;
}
void wxResourceTable::AddResource(wxItemResource *item)
{
wxString name = item->GetName();
- if (name == wxT(""))
+ if (name.empty())
name = item->GetTitle();
- if (name == wxT(""))
+ if (name.empty())
name = wxT("no name");
// Delete existing resource, if any.
{
wxExprDatabase db;
- FILE *fd = wxFopen(filename.fn_str(), wxT("r"));
+ FILE *fd = wxFopen(filename, wxT("r"));
if (!fd)
return false;
bool eof = false;
{
int id = childResource->GetId();
if ( id == 0 )
- id = -1;
+ id = wxID_ANY;
bool dlgUnits = ((parentResource->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0);
if (itemType == wxString(wxT("wxButton")) || itemType == wxString(wxT("wxBitmapButton")))
{
- if (childResource->GetValue4() != wxT(""))
+ if (!childResource->GetValue4().empty())
{
// Bitmap button
wxBitmap bitmap = childResource->GetBitmap();
else if (itemType == wxString(wxT("wxMessage")) || itemType == wxString(wxT("wxStaticText")) ||
itemType == wxString(wxT("wxStaticBitmap")))
{
- if (childResource->GetValue4() != wxT("") || itemType == wxString(wxT("wxStaticBitmap")) )
+ if (!childResource->GetValue4().empty() || itemType == wxString(wxT("wxStaticBitmap")) )
{
// Bitmap message
wxBitmap bitmap = childResource->GetBitmap();
if (item)
{
// Remove any existing resource of same name
- if (item->GetName() != wxT(""))
+ if (!item->GetName().empty())
table.DeleteResource(item->GetName());
table.AddResource(item);
}
dialogItem->SetType(wxT("wxPanel"));
else
dialogItem->SetType(wxT("wxDialog"));
- wxString style = wxT("");
- wxString title = wxT("");
- wxString name = wxT("");
- wxString backColourHex = wxT("");
- wxString labelColourHex = wxT("");
- wxString buttonColourHex = wxT("");
+ wxString style = wxEmptyString;
+ wxString title = wxEmptyString;
+ wxString name = wxEmptyString;
+ wxString backColourHex = wxEmptyString;
+ wxString labelColourHex = wxEmptyString;
+ wxString buttonColourHex = wxEmptyString;
long windowStyle = wxDEFAULT_DIALOG_STYLE;
if (isPanel)
expr->GetAttributeValue(wxT("id"), id);
dialogItem->SetId(id);
- if (style != wxT(""))
+ if (!style.empty())
{
windowStyle = wxParseWindowStyle(style);
}
dialogItem->SetStyle(windowStyle);
dialogItem->SetValue1(isModal);
+
+#if WXWIN_COMPATIBILITY_2_6
+
#ifdef __VMS
#pragma message disable CODCAUUNR
#endif
#pragma message enable CODCAUUNR
#endif
+#endif // WXWIN_COMPATIBILITY_2_6
+
dialogItem->SetName(name);
dialogItem->SetTitle(title);
dialogItem->SetSize(x, y, width, height);
else if (style.Find(wxT("HORIZONTAL_LABEL")) != wxNOT_FOUND)
dialogItem->SetResourceStyle(dialogItem->GetResourceStyle() | wxRESOURCE_HORIZONTAL_LABEL);
- if (backColourHex != wxT(""))
+ if (!backColourHex.empty())
{
int r = 0;
int g = 0;
b = wxHexToDec(backColourHex.Mid(4, 2));
dialogItem->SetBackgroundColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
- if (labelColourHex != wxT(""))
+ if (!labelColourHex.empty())
{
int r = 0;
int g = 0;
b = wxHexToDec(labelColourHex.Mid(4, 2));
dialogItem->SetLabelColour(wxColour((unsigned char)r,(unsigned char)g,(unsigned char)b));
}
- if (buttonColourHex != wxT(""))
+ if (!buttonColourHex.empty())
{
int r = 0;
int g = 0;
if (controlExpr->Number() == 3)
{
wxString controlKeyword(controlExpr->Nth(1)->StringValue());
- if (controlKeyword != wxT("") && controlKeyword == wxT("control"))
+ if (!controlKeyword.empty() && controlKeyword == wxT("control"))
{
// The value part: always a list.
wxExpr *listExpr = controlExpr->Nth(2);
wxString str(expr->Nth(count)->StringValue());
count ++;
- if (str != wxT(""))
+ if (!str.empty())
{
controlItem->SetValue4(str);
controlItem->SetType(wxT("wxBitmapButton"));
wxExpr *coloursExpr = listExpr->Nth(3);
wxExpr *xresExpr = listExpr->Nth(4);
wxExpr *yresExpr = listExpr->Nth(5);
- if (nameExpr && nameExpr->StringValue() != wxT(""))
+ if (nameExpr && !nameExpr->StringValue().empty())
{
bitmapSpec->SetName(nameExpr->StringValue());
}
- if (typeExpr && typeExpr->StringValue() != wxT(""))
+ if (typeExpr && !typeExpr->StringValue().empty())
{
bitmapSpec->SetValue1(wxParseWindowStyle(typeExpr->StringValue()));
}
else
bitmapSpec->SetValue1(0);
- if (platformExpr && platformExpr->StringValue() != wxT(""))
+ if (platformExpr && !platformExpr->StringValue().empty())
{
wxString plat(platformExpr->StringValue());
if (plat == wxT("windows") || plat == wxT("WINDOWS"))
int style = wxNORMAL;
int weight = wxNORMAL;
int underline = 0;
- wxString faceName(wxT(""));
+ wxString faceName;
wxExpr *pointExpr = expr->Nth(0);
wxExpr *familyExpr = expr->Nth(1);
}
static bool wxEatWhiteSpace(wxInputStream *is)
{
- int ch = is->GetC() ;
+ char ch = is->GetC() ;
if ((ch != ' ') && (ch != '/') && (ch != ' ') && (ch != 10) && (ch != 13) && (ch != 9))
{
is->Ungetch(ch);
while (!finished)
{
ch = is->GetC();
- if (ch == EOF)
+ if (is->LastRead() == 0)
return false;
if (ch == '*')
{
// Escaped characters
else if (ch == '\\')
{
- int newCh = is->GetC();
+ char newCh = is->GetC();
if (newCh == '"')
actualCh = '"';
else if (newCh == 10)
wxChar buf[300];
wxStrcpy(buf, _("Found "));
wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
- wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource."));
wxLogWarning(buf);
return false;
}
// char
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
- wxLogWarning(_("Expected 'char' whilst parsing resource."));
+ wxLogWarning(_("Expected 'char' while parsing resource."));
return false;
}
// *name
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (wxResourceBuffer[0] != '*')
{
- wxLogWarning(_("Expected '*' whilst parsing resource."));
+ wxLogWarning(_("Expected '*' while parsing resource."));
return false;
}
wxChar nameBuf[100];
// =
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
- wxLogWarning(_("Expected '=' whilst parsing resource."));
+ wxLogWarning(_("Expected '=' while parsing resource."));
return false;
}
// String
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
wxChar buf[300];
wxStrcpy(buf, _("Found "));
wxStrncat(buf, wxConvLibc.cMB2WX(wxResourceBuffer), 30);
- wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource."));
wxLogWarning(buf);
return false;
}
// char
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
- wxLogWarning(_("Expected 'char' whilst parsing resource."));
+ wxLogWarning(_("Expected 'char' while parsing resource."));
return false;
}
// *name
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (wxResourceBuffer[0] != '*')
{
- wxLogWarning(_("Expected '*' whilst parsing resource."));
+ wxLogWarning(_("Expected '*' while parsing resource."));
return false;
}
char nameBuf[100];
// =
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
- wxLogWarning(_("Expected '=' whilst parsing resource."));
+ wxLogWarning(_("Expected '=' while parsing resource."));
return false;
}
// String
if (!wxGetResourceToken(fd))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
{ wxT("wxCB_SORT"), wxCB_SORT },
/* wxGauge */
+#if WXWIN_COMPATIBILITY_2_6
{ wxT("wxGA_PROGRESSBAR"), wxGA_PROGRESSBAR },
+#endif // WXWIN_COMPATIBILITY_2_6
{ wxT("wxGA_HORIZONTAL"), wxGA_HORIZONTAL },
{ wxT("wxGA_VERTICAL"), wxGA_VERTICAL },
/* wxTextCtrl */
- { wxT("wxPASSWORD"), wxPASSWORD},
- { wxT("wxPROCESS_ENTER"), wxPROCESS_ENTER},
+#if WXWIN_COMPATIBILITY_2_6
+ { wxT("wxPASSWORD"), wxTE_PASSWORD},
+ { wxT("wxPROCESS_ENTER"), wxTE_PROCESS_ENTER},
+#endif
{ wxT("wxTE_PASSWORD"), wxTE_PASSWORD},
{ wxT("wxTE_READONLY"), wxTE_READONLY},
{ wxT("wxTE_PROCESS_ENTER"), wxTE_PROCESS_ENTER},
{ wxT("wxTB_VERTICAL"), wxTB_VERTICAL},
{ wxT("wxTB_FLAT"), wxTB_FLAT},
+#if WXWIN_COMPATIBILITY_2_6
/* wxDialog */
{ wxT("wxDIALOG_MODAL"), wxDIALOG_MODAL },
+#endif // WXWIN_COMPATIBILITY_2_6
/* Generic */
{ wxT("wxVSCROLL"), wxVSCROLL },
{ wxT("wxSDI"), 0},
{ wxT("wxMDI_PARENT"), 0},
{ wxT("wxMDI_CHILD"), 0},
- { wxT("wxTHICK_FRAME"), wxTHICK_FRAME},
+ { wxT("wxTHICK_FRAME"), wxRESIZE_BORDER},
{ wxT("wxRESIZE_BORDER"), wxRESIZE_BORDER},
{ wxT("wxSYSTEM_MENU"), wxSYSTEM_MENU},
{ wxT("wxMINIMIZE_BOX"), wxMINIMIZE_BOX},
{ wxT("wxMAXIMIZE_BOX"), wxMAXIMIZE_BOX},
+#if WXWIN_COMPATIBILITY_2_6
{ wxT("wxRESIZE_BOX"), wxRESIZE_BOX},
+#endif // WXWIN_COMPATIBILITY_2_6
{ wxT("wxDEFAULT_FRAME_STYLE"), wxDEFAULT_FRAME_STYLE},
{ wxT("wxDEFAULT_FRAME"), wxDEFAULT_FRAME_STYLE},
{ wxT("wxDEFAULT_DIALOG_STYLE"), wxDEFAULT_DIALOG_STYLE},
{ wxT("wxICON_MASK"), wxICON_MASK},
{ wxT("wxCENTRE"), wxCENTRE},
{ wxT("wxCENTER"), wxCENTRE},
+#if WXWIN_COMPATIBILITY_2_6
{ wxT("wxUSER_COLOURS"), wxUSER_COLOURS},
+#endif // WXWIN_COMPATIBILITY_2_6
{ wxT("wxVERTICAL_LABEL"), 0},
{ wxT("wxHORIZONTAL_LABEL"), 0},
}
if (!found)
{
- wxLogWarning(_("Unrecognized style %s whilst parsing resource."), word);
+ wxLogWarning(_("Unrecognized style %s while parsing resource."), word);
return 0;
}
word = wxResourceParseWord(WXSTRINGCAST bitListString, &i);
wxItemResource *item = table->FindResource(resource);
if (item)
{
- if ((item->GetType() == wxT("")) || (item->GetType() != wxT("wxBitmap")))
+ if ((item->GetType().empty()) || (item->GetType() != wxT("wxBitmap")))
{
wxLogWarning(_("%s not a bitmap resource specification."), (const wxChar*) resource);
return wxNullBitmap;
wxItemResource *item = table->FindResource(resource);
if (item)
{
- if ((item->GetType() == wxT("")) || wxStrcmp(item->GetType(), wxT("wxIcon")) != 0)
+ if ((item->GetType().empty()) || wxStrcmp(item->GetType(), wxT("wxIcon")) != 0)
{
wxLogWarning(_("%s not an icon resource specification."), (const wxChar*) resource);
return wxNullIcon;
while (node)
{
wxItemResource *child = (wxItemResource *)node->GetData();
- if ((child->GetType() != wxT("")) && (child->GetType() == wxT("wxMenuSeparator")))
+ if ((!child->GetType().empty()) && (child->GetType() == wxT("wxMenuSeparator")))
menu->AppendSeparator();
else if (child->GetChildren().GetCount() > 0)
{
table = wxDefaultResourceTable;
wxItemResource *menuResource = table->FindResource(resource);
- if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu")))
+ if (menuResource && (!menuResource->GetType().empty()) && (menuResource->GetType() == wxT("wxMenu")))
{
if (!menuBar)
menuBar = new wxMenuBar;
table = wxDefaultResourceTable;
wxItemResource *menuResource = table->FindResource(resource);
- if (menuResource && (menuResource->GetType() != wxT("")) && (menuResource->GetType() == wxT("wxMenu")))
+ if (menuResource && (!menuResource->GetType().empty()) && (menuResource->GetType() == wxT("wxMenu")))
// if (menuResource && (menuResource->GetType() == wxTYPE_MENU))
return wxResourceCreateMenu(menuResource);
return (wxMenu *) NULL;
if (!table)
table = wxDefaultResourceTable;
- FILE *fd = wxFopen(f.fn_str(), wxT("r"));
+ FILE *fd = wxFopen(f, wxT("r"));
if (!fd)
{
return false;
wxChar buf[300];
wxStrcpy(buf, _("Found "));
wxStrncat(buf, wxConvCurrent->cMB2WX(wxResourceBuffer), 30);
- wxStrcat(buf, _(", expected static, #include or #define\nwhilst parsing resource."));
+ wxStrcat(buf, _(", expected static, #include or #define\nwhile parsing resource."));
wxLogWarning(buf);
return false;
}
// char
if (!wxGetResourceTokenString(s))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "char") != 0)
{
- wxLogWarning(_("Expected 'char' whilst parsing resource."));
+ wxLogWarning(_("Expected 'char' while parsing resource."));
return false;
}
// *name
if (!wxGetResourceTokenString(s))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (wxResourceBuffer[0] != '*')
{
- wxLogWarning(_("Expected '*' whilst parsing resource."));
+ wxLogWarning(_("Expected '*' while parsing resource."));
return false;
}
wxChar nameBuf[100];
// =
if (!wxGetResourceTokenString(s))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
if (strcmp(wxResourceBuffer, "=") != 0)
{
- wxLogWarning(_("Expected '=' whilst parsing resource."));
+ wxLogWarning(_("Expected '=' while parsing resource."));
return false;
}
// String
if (!wxGetResourceTokenString(s))
{
- wxLogWarning(_("Unexpected end of file whilst parsing resource."));
+ wxLogWarning(_("Unexpected end of file while parsing resource."));
*eof = true;
return false;
}
wxItemResource *resource = table->FindResource((const wxChar *)resourceName);
// if (!resource || (resource->GetType() != wxTYPE_DIALOG_BOX))
- if (!resource || (resource->GetType() == wxT("")) ||
+ if (!resource || (resource->GetType().empty()) ||
! ((resource->GetType() == wxT("wxDialog")) || (resource->GetType() == wxT("wxPanel"))))
return false;
if (thisWindow->IsKindOf(CLASSINFO(wxDialog)))
{
wxDialog *dialogBox = (wxDialog *)thisWindow;
- long modalStyle = isModal ? wxDIALOG_MODAL : 0;
+ long modalStyle = isModal ?
+#if WXWIN_COMPATIBILITY_2_6
+ wxDIALOG_MODAL
+#else
+ 0
+#endif // WXWIN_COMPATIBILITY_2_6
+ : 0;
if (!dialogBox->Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, height), theWindowStyle|modalStyle, name))
return false;
#endif // VC++
#endif // wxUSE_WX_RESOURCES
-