Wtx ~ Wt Extension Library
WtxLib
TemplateFormView.cpp
1 /**************************************************************************
2 ###########################################################################
3 ##
4 ## $SHOWOFFDB_BEGIN_LICENSE$
5 ## Copyright (C) 2011 Lorimark Solutions, LLC and/or its subsidiary(-ies).
6 ## All rights reserved.
7 ## Contact: Lorimark Solutions, LLC (info@showoff-db.org)
8 ##
9 ## This file is part of the Showoff Database Application Framework.
10 ##
11 ## Commercial Usage
12 ## Licensees holding valid ShowoffDB Commercial licenses may use this file in
13 ## accordance with the ShowoffDB Commercial License Agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and Lorimark Solutions, LLC.
16 ##
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ##
25 ## In addition, as a special exception, Lorimark Solutions, LLC gives
26 ## you certain additional rights. These rights are described in the
27 ## Lorimark Solutions, LLC ShowoffDB LGPL Exception version 1.0, included in
28 ## the file LGPL_EXCEPTION.txt in this package.
29 ##
30 ## GNU General Public License Usage
31 ## Alternatively, this file may be used under the terms of the GNU
32 ## General Public License version 3.0 as published by the Free Software
33 ## Foundation and appearing in the file LICENSE.GPL included in the
34 ## packaging of this file. Please review the following information to
35 ## ensure the GNU General Public License version 3.0 requirements will be
36 ## met: http://www.gnu.org/copyleft/gpl.html.
37 ##
38 ## If you have questions regarding the use of this file, please contact
39 ## Lorimark Solutions, LLC at info@showoff-db.org.
40 ## $SHOWOFFDB_END_LICENSE$
41 ##
42 #############################################################################
43 ****************************************************************************/
44 
45 
46 #include <Wt/WWidget.h>
47 #include <Wt/WLineEdit.h>
48 
49 #include "TemplateFormView.h"
50 
51 #ifdef DEBUG_TRACE
52 #define COUT_LINE std::cout << __FILE__ << ":" << __LINE__ << " " << __PRETTY_FUNCTION__ << std::endl
53 #define COUT_(x) std::cout << __FILE__ << ":" << __LINE__ << " " << __PRETTY_FUNCTION__ << " " << x << std::endl;
54 #else
55 #define COUT_LINE
56 #define COUT_(x)
57 #endif
58 
139 Wtx::TemplateFormView::~TemplateFormView()
140 {
141  COUT_LINE;
142 }
143 
144 Wtx::TemplateFormView::TemplateFormView( const Wt::WString & text )
145 : Wt::WTemplateFormView(text)
146 {
147  COUT_LINE;
148 }
149 
150 std::unique_ptr<Wt::WWidget> Wtx::TemplateFormView::createFormWidget( Wt::WFormModel::Field field )
151 {
152  return nullptr;
153 // COUT_(field);
154 // return createEditWidget( field );
155 }
156 
157 std::unique_ptr<Wt::WWidget> Wtx::TemplateFormView::createEditWidget( Wt::WFormModel::Field field )
158 {
159  COUT_(field);
160  return std::make_unique<Wt::WLineEdit>();
161 }
162 
163 /*
164 ** base class virtual overrides
165 **
166 */
167 void Wtx::TemplateFormView::updateView( Wt::WFormModel *model )
168 {
169  COUT_LINE;
170  Wt::WTemplateFormView::updateView( model );
171 }
172 
173 
174 void Wtx::TemplateFormView::updateViewField( Wt::WFormModel *model, Wt::WFormModel::Field field )
175 {
176  COUT_(field);
177  Wt::WTemplateFormView::updateViewField( model, field );
178 }
179 
180 
181 void Wtx::TemplateFormView::updateViewValue( Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit )
182 {
183  COUT_(field);
184  Wt::WTemplateFormView::updateViewValue( model, field, edit );
185 }
186 
187 
188 bool Wtx::TemplateFormView::updateViewValue( Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit )
189 {
190  COUT_(field);
191  return Wt::WTemplateFormView::updateViewValue( model, field, edit );
192 }
193 
194 
195 void Wtx::TemplateFormView::updateModel( Wt::WFormModel *model )
196 {
197  COUT_LINE;
198  Wt::WTemplateFormView::updateModel( model );
199 }
200 
201 
202 void Wtx::TemplateFormView::updateModelField( Wt::WFormModel *model, Wt::WFormModel::Field field )
203 {
204  COUT_(field);
205  Wt::WTemplateFormView::updateModelField( model, field );
206 }
207 
208 
209 void Wtx::TemplateFormView::updateModelValue( Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WFormWidget *edit )
210 {
211  COUT_(field);
212  Wt::WTemplateFormView::updateModelValue( model, field, edit );
213 }
214 
215 
216 bool Wtx::TemplateFormView::updateModelValue( Wt::WFormModel *model, Wt::WFormModel::Field field, Wt::WWidget *edit )
217 {
218  COUT_(field);
219  return Wt::WTemplateFormView::updateModelValue( model, field, edit );
220 }
221 
222 /*
223 ** Template class overrides
224 **
225 */
226 void Wtx::TemplateFormView::bindString( const std::string & varName, const Wt::WString & value, Wt::TextFormat textFormat )
227 {
228  COUT_( varName << "=" << value );
229  Wt::WTemplateFormView::bindString( varName, value, textFormat );
230 }
231 
232 void Wtx::TemplateFormView::bindWidget( const std::string & varName, std::unique_ptr< Wt::WWidget > widget )
233 {
234  COUT_(varName);
235  Wt::WTemplateFormView::bindWidget( varName, std::move(widget) );
236 }
237 
238 std::unique_ptr< Wt::WWidget > Wtx::TemplateFormView::removeWidget( Wt::WWidget *widget )
239 {
240  COUT_LINE;
241  return Wt::WTemplateFormView::removeWidget( widget );
242 }
243 
244 bool Wtx::TemplateFormView::conditionValue( const std::string & name ) const
245 {
246  bool retVal = Wt::WTemplateFormView::conditionValue( name );
247  COUT_(name);
248  COUT_(retVal);
249  return retVal;
250 }
251 
252 void Wtx::TemplateFormView::resolveString( const std::string & varName, const std::vector< Wt::WString > & args, std::ostream & result )
253 {
254  COUT_(varName);
255  Wt::WTemplateFormView::resolveString( varName, args, result );
256 }
257 
258 void Wtx::TemplateFormView::handleUnresolvedVariable( const std::string & varName, const std::vector< Wt::WString > & args, std::ostream & result )
259 {
260  COUT_(varName);
261  Wt::WTemplateFormView::handleUnresolvedVariable( varName, args, result );
262 }
263 
264 Wt::WWidget * Wtx::TemplateFormView::resolveWidget( const std::string & varName )
265 {
266  Wt::WWidget * w = Wt::WTemplateFormView::resolveWidget( varName );
267 
268 // if( !w )
269 // w = createEditWidget( varName );
270 // w = std::make_unique<Wt::WLineEdit>();
271 
272  return w;
273 }
274 
275 bool Wtx::TemplateFormView::resolveFunction( const std::string & name, const std::vector< Wt::WString > & args, std::ostream & result )
276 {
277  if( name == "widget" )
278  {
279  if( args.size() > 0 )
280  {
281  if( args.at(0) == "WTabWidget" )
282  {
283  return true;
284  }
285  }
286  }
287 
288  return Wt::WTemplateFormView::resolveFunction( name, args, result );
289 }
290 
291 void Wtx::TemplateFormView::refresh()
292 {
293  COUT_LINE;
294  Wt::WTemplateFormView::refresh();
295 }
296 
297 void Wtx::TemplateFormView::renderTemplate( std::ostream & result )
298 {
299  COUT_LINE;
300  Wt::WTemplateFormView::renderTemplate( result );
301 }
302 
303 
304 
std::unique_ptr< Wt::WWidget > createEditWidget(Wt::WFormModel::Field f)
Create Edit Widget.
std::unique_ptr< Wt::WWidget > createFormWidget(Wt::WFormModel::Field f)
Create Form Widget.