]>
Commit | Line | Data |
---|---|---|
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 wxIfElseVariable Class, Dynamically constructed | |
26 | * objects representing variables in SSI #if, #else, and #endif directives | |
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/ifelsevar.h" | |
36 | ||
37 | /*---------------------------- Global variables ---------------------------*/ | |
38 | ||
39 | // Implement the dynamic class so it can be constructed dynamically | |
40 | IMPLEMENT_ABSTRACT_CLASS(wxIfElseVariable, wxObject); | |
41 | ||
42 | /*----------------------------- Implementation ----------------------------*/ | |
43 | ||
44 | /**************************************************************************** | |
45 | PARAMETERS: | |
46 | cls - The String name of the class | |
47 | ||
48 | RETURNS: | |
49 | The boolean value of the variable | |
50 | ||
51 | REMARKS: | |
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 | |
57 | where these are used. | |
58 | ||
59 | SEE ALSO: | |
60 | wxIfElsePrep | |
61 | ****************************************************************************/ | |
62 | static bool wxIfElseVariable::FindValue( | |
63 | const wxString &cls) | |
64 | { | |
65 | wxObject * tmpclass; | |
66 | ||
67 | tmpclass = wxCreateDynamicObject(wxString("wxIfElseVariable") + cls); | |
68 | if (!tmpclass) { | |
69 | #ifdef CHECKED | |
70 | wxMessageBox(wxString("wxHTML #if error: Class not found (") + cls + wxString(")."),"Error",wxICON_ERROR); | |
71 | #endif | |
72 | return wxString(""); | |
73 | } | |
74 | ||
75 | wxIfElseVariable * ev = wxDynamicCast(tmpclass, wxIfElseVariable); | |
76 | ||
77 | if (!ev) { | |
78 | #ifdef CHECKED | |
79 | wxMessageBox(wxString("wxHTML #if error: Class is not a valid ifelse variable (") + cls + wxString(")."),"Error",wxICON_ERROR); | |
80 | #endif | |
81 | return wxString(""); | |
82 | } | |
83 | ||
84 | return ev->GetValue(); | |
85 | } | |
86 | ||
87 | /*------------------------ Macro Documentation ---------------------------*/ | |
88 | ||
89 | // Here we declare some fake functions to get doc-jet to properly document the macros | |
90 | ||
91 | #undef BEGIN_IFELSE_VARIABLE | |
92 | /**************************************************************************** | |
93 | PARAMETERS: | |
94 | name - The name of the variable to create | |
95 | ||
96 | REMARKS: | |
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. | |
101 | ||
102 | EXAMPLE: | |
103 | BEGIN_IFELSE_VARIABLE(UserName) | |
104 | // Get username from nucleus | |
105 | bool tmp = GA_HasRegistered(); | |
106 | END_IFELSE_VARIABLE(UserName, tmp) | |
107 | ||
108 | SEE ALSO: | |
109 | wxIfElseVariable, wxIfElsePrep, END_IFELSE_VARIABLE, IFELSE_VARIABLE | |
110 | ****************************************************************************/ | |
111 | void BEGIN_IFELSE_VARIABLE( | |
112 | const char *name); | |
113 | ||
114 | #undef END_IFELSE_VARIABLE | |
115 | /**************************************************************************** | |
116 | PARAMETERS: | |
117 | name - The name of the variable to end | |
118 | returnval - The boolean value which is the value of the variable | |
119 | ||
120 | REMARKS: | |
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. | |
125 | ||
126 | EXAMPLE: | |
127 | BEGIN_IFELSE_VARIABLE(UserName) | |
128 | // Get username from nucleus | |
129 | bool tmp = GA_HasRegistered(); | |
130 | END_IFELSE_VARIABLE(UserName, tmp) | |
131 | ||
132 | SEE ALSO: | |
133 | wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, IFELSE_VARIABLE | |
134 | ****************************************************************************/ | |
135 | void END_IFELSE_VARIABLE( | |
136 | const char *name, | |
137 | bool returnval); | |
138 | ||
139 | #undef IFELSE_VARIABLE | |
140 | /**************************************************************************** | |
141 | PARAMETERS: | |
142 | name - The name of the variable | |
143 | state - value of the variable | |
144 | ||
145 | REMARKS: | |
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 | |
149 | not modifiable. | |
150 | ||
151 | SEE ALSO: | |
152 | wxIfElseVariable, wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE | |
153 | ****************************************************************************/ | |
154 | void IFELSE_VARIABLE( | |
155 | const char *name, | |
156 | bool state); | |
157 | ||
158 | ||
159 | FORCE_LINK_ME(ifelsevar) |