1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
|
<HTML>
<head><title>wxWindows resource functions</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="resourcefuncs"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx264.htm#functions"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx272.htm#macros"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx274.htm#logfunctions"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxWindows resource functions</H2>
<P>
<A HREF="wx303.htm#resourceformats">wxWindows resource system</A><P>
This section details functions for manipulating wxWindows (.WXR) resource
files and loading user interface elements from resources.<P>
<HR>
Please note that this use of the word 'resource' is different from that used when talking
about initialisation file resource reading and writing, using such functions
as wxWriteResource and wxGetResource. It's just an unfortunate clash of terminology.<HR><P>
<P>
For an overview of the wxWindows resource mechanism, see <A HREF="wx303.htm#resourceformats">the wxWindows resource system</A>.<P>
See also <A HREF="wx260.htm#wxwindowloadfromresource">wxWindow::LoadFromResource</A> for
loading from resource data.<P>
<B>Warning:</B> this needs updating for wxWindows 2.<P>
<A HREF="#wxresourceaddidentifier">::wxResourceAddIdentifier</A><BR>
<A HREF="#topic1113">::wxResourceClear</A><BR>
<A HREF="#topic1114">::wxResourceCreateBitmap</A><BR>
<A HREF="#topic1115">::wxResourceCreateIcon</A><BR>
<A HREF="#topic1116">::wxResourceCreateMenuBar</A><BR>
<A HREF="#topic1117">::wxResourceGetIdentifier</A><BR>
<A HREF="#wxresourcedata">::wxResourceParseData</A><BR>
<A HREF="#topic1118">::wxResourceParseFile</A><BR>
<A HREF="#wxresourceparsestring">::wxResourceParseString</A><BR>
<A HREF="#registerbitmapdata">::wxResourceRegisterBitmapData</A><BR>
<A HREF="#topic1119">::wxResourceRegisterIconData</A><BR>
<P>
<HR>
<A NAME="wxresourceaddidentifier"></A>
<H3>::wxResourceAddIdentifier</H3>
<P>
<B>bool</B> <B>wxResourceAddIdentifier</B>(<B>const wxString& </B><I>name</I>, <B>int </B><I>value</I>)<P>
Used for associating a name with an integer identifier (equivalent to dynamically
<TT>#</TT>defining a name to an integer). Unlikely to be used by an application except
perhaps for implementing resource functionality for interpreted languages.<P>
<HR>
<A NAME="topic1113"></A>
<H3>::wxResourceClear</H3>
<P>
<B>void</B> <B>wxResourceClear</B>()<P>
Clears the wxWindows resource table.<P>
<HR>
<A NAME="topic1114"></A>
<H3>::wxResourceCreateBitmap</H3>
<P>
<B>wxBitmap *</B> <B>wxResourceCreateBitmap</B>(<B>const wxString& </B><I>resource</I>)<P>
Creates a new bitmap from a file, static data, or Windows resource, given a valid
wxWindows bitmap resource identifier. For example, if the .WXR file contains
the following:<P>
<PRE>
static const wxString\& aiai_resource = "bitmap(name = 'aiai_resource',\
bitmap = ['aiai', wxBITMAP_TYPE_BMP_RESOURCE, 'WINDOWS'],\
bitmap = ['aiai.xpm', wxBITMAP_TYPE_XPM, 'X']).";
</PRE>
then this function can be called as follows:<P>
<PRE>
wxBitmap *bitmap = wxResourceCreateBitmap("aiai_resource");
</PRE>
<HR>
<A NAME="topic1115"></A>
<H3>::wxResourceCreateIcon</H3>
<P>
<B>wxIcon *</B> <B>wxResourceCreateIcon</B>(<B>const wxString& </B><I>resource</I>)<P>
Creates a new icon from a file, static data, or Windows resource, given a valid
wxWindows icon resource identifier. For example, if the .WXR file contains
the following:<P>
<PRE>
static const wxString\& aiai_resource = "icon(name = 'aiai_resource',\
icon = ['aiai', wxBITMAP_TYPE_ICO_RESOURCE, 'WINDOWS'],\
icon = ['aiai', wxBITMAP_TYPE_XBM_DATA, 'X']).";
</PRE>
then this function can be called as follows:<P>
<PRE>
wxIcon *icon = wxResourceCreateIcon("aiai_resource");
</PRE>
<HR>
<A NAME="topic1116"></A>
<H3>::wxResourceCreateMenuBar</H3>
<P>
<B>wxMenuBar *</B> <B>wxResourceCreateMenuBar</B>(<B>const wxString& </B><I>resource</I>)<P>
Creates a new menu bar given a valid wxWindows menubar resource
identifier. For example, if the .WXR file contains the following:<P>
<PRE>
static const wxString\& menuBar11 = "menu(name = 'menuBar11',\
menu = \
[\
['&File', 1, '', \
['&Open File', 2, 'Open a file'],\
['&Save File', 3, 'Save a file'],\
[],\
['E&xit', 4, 'Exit program']\
],\
['&Help', 5, '', \
['&About', 6, 'About this program']\
]\
]).";
</PRE>
then this function can be called as follows:<P>
<PRE>
wxMenuBar *menuBar = wxResourceCreateMenuBar("menuBar11");
</PRE>
<HR>
<A NAME="topic1117"></A>
<H3>::wxResourceGetIdentifier</H3>
<P>
<B>int</B> <B>wxResourceGetIdentifier</B>(<B>const wxString& </B><I>name</I>)<P>
Used for retrieving the integer value associated with an identifier.
A zero value indicates that the identifier was not found.<P>
See <A HREF="wx273.htm#wxresourceaddidentifier">wxResourceAddIdentifier</A>.<P>
<HR>
<A NAME="wxresourcedata"></A>
<H3>::wxResourceParseData</H3>
<P>
<B>bool</B> <B>wxResourceParseData</B>(<B>const wxString& </B><I>resource</I>, <B>wxResourceTable *</B><I>table = NULL</I>)<P>
Parses a string containing one or more wxWindows resource objects. If
the resource objects are global static data that are included into the
C++ program, then this function must be called for each variable
containing the resource data, to make it known to wxWindows.<P>
<I>resource</I> should contain data in the following form:<P>
<PRE>
dialog(name = 'dialog1',
style = 'wxCAPTION | wxDEFAULT_DIALOG_STYLE',
title = 'Test dialog box',
x = 312, y = 234, width = 400, height = 300,
modal = 0,
control = [wxGroupBox, 'Groupbox', '0', 'group6', 5, 4, 380, 262,
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]],
control = [wxMultiText, 'Multitext', 'wxVERTICAL_LABEL', 'multitext3',
156, 126, 200, 70, 'wxWindows is a multi-platform, GUI toolkit.',
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0],
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]]).
</PRE>
This function will typically be used after including a <TT>.wxr</TT> file into
a C++ program as follows:<P>
<PRE>
#include "dialog1.wxr"
</PRE>
Each of the contained resources will declare a new C++ variable, and each
of these variables should be passed to wxResourceParseData.<P>
<HR>
<A NAME="topic1118"></A>
<H3>::wxResourceParseFile</H3>
<P>
<B>bool</B> <B>wxResourceParseFile</B>(<B>const wxString& </B><I>filename</I>, <B>wxResourceTable *</B><I>table = NULL</I>)<P>
Parses a file containing one or more wxWindows resource objects
in C++-compatible syntax. Use this function to dynamically load
wxWindows resource data.<P>
<HR>
<A NAME="wxresourceparsestring"></A>
<H3>::wxResourceParseString</H3>
<P>
<B>bool</B> <B>wxResourceParseString</B>(<B>const wxString& </B><I>resource</I>, <B>wxResourceTable *</B><I>table = NULL</I>)<P>
Parses a string containing one or more wxWindows resource objects. If
the resource objects are global static data that are included into the
C++ program, then this function must be called for each variable
containing the resource data, to make it known to wxWindows.<P>
<I>resource</I> should contain data with the following form:<P>
<PRE>
static const wxString\& dialog1 = "dialog(name = 'dialog1',\
style = 'wxCAPTION | wxDEFAULT_DIALOG_STYLE',\
title = 'Test dialog box',\
x = 312, y = 234, width = 400, height = 300,\
modal = 0,\
control = [wxGroupBox, 'Groupbox', '0', 'group6', 5, 4, 380, 262,\
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]],\
control = [wxMultiText, 'Multitext', 'wxVERTICAL_LABEL', 'multitext3',\
156, 126, 200, 70, 'wxWindows is a multi-platform, GUI toolkit.',\
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0],\
[11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]]).";
</PRE>
This function will typically be used after calling <A HREF="wx271.htm#wxloaduserresource">wxLoadUserResource</A> to
load an entire <TT>.wxr file</TT> into a string.<P>
<HR>
<A NAME="registerbitmapdata"></A>
<H3>::wxResourceRegisterBitmapData</H3>
<P>
<B>bool</B> <B>wxResourceRegisterBitmapData</B>(<B>const wxString& </B><I>name</I>, <B>const wxString& </B><I>xbm_data</I>, <B>int </B><I>width</I>,
<B>int </B><I>height</I>, <B>wxResourceTable *</B><I>table = NULL</I>)<P>
<B>bool</B> <B>wxResourceRegisterBitmapData</B>(<B>const wxString& </B><I>name</I>, <B>const wxString& *</B><I>xpm_data</I>)<P>
Makes <TT>#</TT>included XBM or XPM bitmap data known to the wxWindows resource system.
This is required if other resources will use the bitmap data, since otherwise there
is no connection between names used in resources, and the global bitmap data.<P>
<HR>
<A NAME="topic1119"></A>
<H3>::wxResourceRegisterIconData</H3>
<P>
Another name for <A HREF="wx273.htm#registerbitmapdata">wxResourceRegisterBitmapData</A>.<P>
</BODY></HTML>
|