]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/applet/ifelsevar.cpp
1 /****************************************************************************
3 * wxWindows HTML Applet Package
5 * Copyright (C) 1991-2001 SciTech Software, Inc.
8 * ========================================================================
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
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.
20 * ========================================================================
25 * Description: Implementation of wxIfElseVariable Class, Dynamically constructed
26 * objects representing variables in SSI #if, #else, and #endif directives
28 ****************************************************************************/
30 // For compilers that support precompilation
31 #include "wx/wxprec.h"
32 #include "wx/html/forcelnk.h"
34 // Include private headers
35 #include "wx/applet/ifelsevar.h"
37 /*---------------------------- Global variables ---------------------------*/
39 // Implement the dynamic class so it can be constructed dynamically
40 IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable
, wxObject
);
42 /*----------------------------- Implementation ----------------------------*/
44 /****************************************************************************
46 cls - The String name of the class
49 The boolean value of the variable
52 To grab a value from any class which is derived from this one simple use this
53 static function and the name of the derived class to get the value.
54 This static function is the only function implemented in this base class
55 basically this is provided for an easier method of grabbing a variable. We
56 keep all the dynamic object handling in this class to avoid confusing the source
61 ****************************************************************************/
62 static bool wxIfElseVariable::GetValue(
67 tmpclass
= wxCreateDynamicObject(wxString("wxIfElseVariable") + cls
);
70 wxMessageBox(wxString("wxHTML #if error: Class not found (") + cls
+ wxString(")."),"Error",wxICON_ERROR
);
75 wxIfElseVariable
* ev
= wxDynamicCast(tmpclass
, wxIfElseVariable
);
79 wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls
+ wxString(")."),"Error",wxICON_ERROR
);
84 return ev
->GetValue();
87 /*------------------------ Macro Documentation ---------------------------*/
89 // Here we declare some fake functions to get doc-jet to properly document the macros
91 #undef BEGIN_IFELSE_VARIABLE
92 /****************************************************************************
94 name - The name of the variable to create
97 This macro is used to create variables for use by the #if, #else and #endif
98 blocks in the HTML preprocessor.
99 To create a new variable include the code necessary to get the value of the
100 variable between a block of BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros.
103 BEGIN_IFELSE_VARIABLE(UserName)
104 // Get username from nucleus
105 bool tmp = GA_HasRegistered();
106 END_IFELSE_VARIABLE(UserName, tmp)
109 wxIfElseVariable, wxIfElsePrep, END_IFELSE_VARIABLE, IFELSE_VARIABLE
110 ****************************************************************************/
111 void BEGIN_IFELSE_VARIABLE(
114 #undef END_IFELSE_VARIABLE
115 /****************************************************************************
117 name - The name of the variable to end
118 returnval - The boolean value which is the value of the variable
121 This macro is used to create variables for use by the #if, #else and #endif
122 blocks in the HTML preprocessor.
123 To create a new variable include the code necessary to get the value of the
124 variable between a block of BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros.
127 BEGIN_IFELSE_VARIABLE(UserName)
128 // Get username from nucleus
129 bool tmp = GA_HasRegistered();
130 END_IFELSE_VARIABLE(UserName, tmp)
133 wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, IFELSE_VARIABLE
134 ****************************************************************************/
135 void END_IFELSE_VARIABLE(
139 #undef IFELSE_VARIABLE
140 /****************************************************************************
142 name - The name of the variable
143 state - value of the variable
146 This macro is used to create constant boolean variables for use by the
147 #if, #else and #endif blocks in the HTML preprocessor.
148 This MACRO creates a variable that simply returns the given state and is
152 wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
153 ****************************************************************************/
154 void IFELSE_VARIABLE(
159 FORCE_LINK_ME(ifelsevar
)