]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/applet/echovar.cpp
compilation fix for Watcom
[wxWidgets.git] / contrib / src / applet / echovar.cpp
CommitLineData
716cd410
KB
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
40IMPLEMENT_ABSTRACT_CLASS(wxEchoVariable, wxObject);
41
42/*----------------------------- Implementation ----------------------------*/
43
44/****************************************************************************
45PARAMETERS:
46cls - The String name of the class
47parms - an optional parameter string to pass off to the child class
48
49RETURNS:
50The string value of the variable
51
52REMARKS:
53To grab a value from any class which is derived from this one simple use this
54static function and the name of the derived class to get the value.
55This static function is the only function implemented in this base class
56basically this is provided for an easier method of grabbing a variable. We
57keep all the dynamic object handling in this class to avoid confusing the source
58where these are used.
59
60SEE ALSO:
61wxEchoPrep
62****************************************************************************/
d699f48b 63static wxString wxEchoVariable::FindValue(
716cd410
KB
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/****************************************************************************
96RETURNS:
97The value of the parameter string from the HTML parm= field
98
99REMARKS:
100This is a macro to retrieve the parameter string passed in the parm= field.
101Use this macro to get the correct variable within a BEGIN_ECHO_VARIABLE and
102END_ECHO_VARIABLE block.
103
104SEE ALSO:
105wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
106****************************************************************************/
107wxString ECHO_PARM();
108
109
110#undef BEGIN_ECHO_VARIABLE
111/****************************************************************************
112PARAMETERS:
113name - The name of the variable to create
114
115REMARKS:
116This macro is used to create variables for use by the #echo directive
117the HTML preprocessor.
118To create a new variable include the code necessary to get the value of the
119variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
120Use the ECHO_PARM macro to grab the optional parameter string passed from the
121'parm=' field in the html file.
122
123EXAMPLE:
124BEGIN_ECHO_VARIABLE(UserName)
125 // Get username from nucleus
126 wxString tmp = GA_GetUserName();
127END_ECHO_VARIABLE(UserName, tmp)
128
129SEE ALSO:
130wxEchoVariable, wxEchoPrep, END_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
131****************************************************************************/
132void BEGIN_ECHO_VARIABLE(
133 const char *name);
134
135#undef END_ECHO_VARIABLE
136/****************************************************************************
137PARAMETERS:
138name - The name of the variable to end
139returnval - The value which should be sent back as the value of the variable
140
141REMARKS:
142This macro is used to create variables for use by the #echo directive
143the HTML preprocessor.
144To create a new variable include the code necessary to get the value of the
145variable between a block of BEGIN_ECHO_VARIABLE and END_ECHO_VARIABLE macros.
146
147EXAMPLE:
148BEGIN_ECHO_VARIABLE(UserName)
149 // Get username from nucleus
150 wxString tmp = GA_GetUserName();
151END_ECHO_VARIABLE(UserName, tmp)
152
153SEE ALSO:
154wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, ECHO_PARM, STRING_ECHO_VARIABLE
155****************************************************************************/
156void END_ECHO_VARIABLE(
157 const char *name,
158 wxString returnval);
159
160#undef STRING_ECHO_VARIABLE
161/****************************************************************************
162PARAMETERS:
163name - The name of the variable
164returnval - String to return as the value of the variable
165
166REMARKS:
167This macro is used to create constant string variables for use by the #echo
168directive in the HTML preprocessor.
169This MACRO creates a variable that simply returns the given string and is
170not modifiable.
171
172SEE ALSO:
173wxEchoVariable, wxEchoPrep, BEGIN_ECHO_VARIABLE, END_ECHO_VARIABLE
174****************************************************************************/
175void STRING_ECHO_VARIABLE(
176 const char *name,
177 wxString string);
178
179// hack to make this file link
180FORCE_LINK_ME(echovar)