]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/applet/echovar.cpp
some basic docs for wxBase
[wxWidgets.git] / contrib / src / applet / echovar.cpp
1 /****************************************************************************
2 *
3 * wxWindows HTML Applet Package
4 *
5 * Copyright (C) 1991-2001 SciTech Software, Inc.
6 * All rights reserved.
7 *
8 * ========================================================================
9 *
10 * The contents of this file are subject to the wxWindows License
11 * Version 3.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.wxwindows.org/licence3.txt
14 *
15 * Software distributed under the License is distributed on an
16 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
19 *
20 * ========================================================================
21 *
22 * Language: ANSI C++
23 * Environment: Any
24 *
25 * Description: Implementation of wxEchoVariable Class, Dynamically constructed
26 * objects representing variables in SSI #echo directive
27 *
28 ****************************************************************************/
29
30 // For compilers that support precompilation
31 #include "wx/wxprec.h"
32 #include "wx/html/forcelnk.h"
33
34 // Include private headers
35 #include "wx/applet/echovar.h"
36
37 /*---------------------------- Global variables ---------------------------*/
38
39 // Implement the dynamic class so it can be constructed dynamically
40 IMPLEMENT_ABSTRACT_CLASS(wxEchoVariable, wxObject);
41
42 /*----------------------------- Implementation ----------------------------*/
43
44 /****************************************************************************
45 PARAMETERS:
46 cls - The String name of the class
47 parms - an optional parameter string to pass off to the child class
48
49 RETURNS:
50 The string value of the variable
51
52 REMARKS:
53 To grab a value from any class which is derived from this one simple use this
54 static function and the name of the derived class to get the value.
55 This static function is the only function implemented in this base class
56 basically this is provided for an easier method of grabbing a variable. We
57 keep all the dynamic object handling in this class to avoid confusing the source
58 where these are used.
59
60 SEE ALSO:
61 wxEchoPrep
62 ****************************************************************************/
63 static wxString wxEchoVariable::FindValue(
64 const wxString &cls,
65 const char *parms)
66 {
67 wxObject * tmpclass;
68
69 tmpclass = wxCreateDynamicObject(wxString("wxEchoVariable") + cls);
70 if (!tmpclass) {
71 #ifdef CHECKED
72 wxMessageBox(wxString("wxHTML #echo error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR);
73 #endif
74 return wxString("");
75 }
76
77 wxEchoVariable * ev = wxDynamicCast(tmpclass, wxEchoVariable);
78
79 if (!ev) {
80 #ifdef CHECKED
81 wxMessageBox(wxString("wxHTML #echo error: Class is not a valid echo variable (") + cls + wxString(")."),"Error",wxICON_ERROR);
82 #endif
83 return wxString("");
84 }
85
86 return ev->GetValue(parms);
87 }
88
89
90 /*------------------------ Macro Documentation ---------------------------*/
91
92 // Here we declare some fake functions to get doc-jet to properly document the macros
93
94 #undef ECHO_PARM
95 /****************************************************************************
96 RETURNS:
97 The value of the parameter string from the HTML parm= field
98
99 REMARKS:
100 This is a macro to retrieve the parameter string passed in the parm= field.
101 Use this macro to get the correct variable within a BEGIN_ECHO_VARIABLE and
102 END_ECHO_VARIABLE block.
103
104 SEE ALSO:
105 wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
106 ****************************************************************************/
107 wxString ECHO_PARM();
108
109
110 #undef BEGIN_ECHO_VARIABLE
111 /****************************************************************************
112 PARAMETERS:
113 name - The name of the variable to create
114
115 REMARKS:
116 This macro is used to create variables for use by the #echo directive
117 the HTML preprocessor.
118 To create a new variable include the code necessary to get the value of the
119 variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
120 Use the ECHO_PARM macro to grab the optional parameter string passed from the
121 'parm=' field in the html file.
122
123 EXAMPLE:
124 BEGIN_ECHO_VARIABLE(UserName)
125 // Get username from nucleus
126 wxString tmp = GA_GetUserName();
127 END_ECHO_VARIABLE(UserName, tmp)
128
129 SEE ALSO:
130 wxEchoVariable, wxEchoPrep, END_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
131 ****************************************************************************/
132 void BEGIN_ECHO_VARIABLE(
133 const char *name);
134
135 #undef END_ECHO_VARIABLE
136 /****************************************************************************
137 PARAMETERS:
138 name - The name of the variable to end
139 returnval - The value which should be sent back as the value of the variable
140
141 REMARKS:
142 This macro is used to create variables for use by the #echo directive
143 the HTML preprocessor.
144 To create a new variable include the code necessary to get the value of the
145 variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
146
147 EXAMPLE:
148 BEGIN_ECHO_VARIABLE(UserName)
149 // Get username from nucleus
150 wxString tmp = GA_GetUserName();
151 END_ECHO_VARIABLE(UserName, tmp)
152
153 SEE ALSO:
154 wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
155 ****************************************************************************/
156 void END_ECHO_VARIABLE(
157 const char *name,
158 wxString returnval);
159
160 #undef STRING_ECHO_VARIABLE
161 /****************************************************************************
162 PARAMETERS:
163 name - The name of the variable
164 returnval - String to return as the value of the variable
165
166 REMARKS:
167 This macro is used to create constant string variables for use by the #echo
168 directive in the HTML preprocessor.
169 This MACRO creates a variable that simply returns the given string and is
170 not modifiable.
171
172 SEE ALSO:
173 wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
174 ****************************************************************************/
175 void STRING_ECHO_VARIABLE(
176 const char *name,
177 wxString string);
178
179 // hack to make this file link
180 FORCE_LINK_ME(echovar)