Wtx ~ Wt Extension Library
WtxLib
FieldDefBase.h
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 #ifndef __WTX_DBO_FIELDDEFBASE_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
47 #define __WTX_DBO_FIELDDEFBASE_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
48 
49 #include <memory>
50 #include <string>
51 
52 #include <Wt/WObject.h>
53 #include <Wt/WFlags.h>
54 #include <Wt/WLineEdit.h>
55 #include "Session.h"
56 
57 namespace Wt {
58  class WWidget;
59  class WItemDelegate;
60 }
61 
62 namespace Wtx {
63  namespace Dbo {
64 
65 class TableDef;
66 
89 : Wt::WObject
90 {
91  public:
92 
101  enum Flags
102  {
104  None = 0x0000,
105 
107  Required = 0x0001,
108 
110  ReadOnly = 0x0002,
111 
113  Password = 0x0004,
114 
116  ShowOnly = 0x0008,
117 
119  NoUi = 0x0010,
120 
122  Unique = 0x0020,
123 
125  Search = 0x0040
126  };
127 
133  (
134  TableDef & td,
135  const char * fn,
136  int w = -1,
137  int h = -1,
138  Flags f = Flags::None,
139  std::string lb = "",
140  std::string ph = "",
141  std::string inf = "",
142  std::string tt = "",
143  int ht = -1
144  );
145 
151  (
152  TableDef & td,
153  const char * fn,
154  std::string lb = "",
155  std::string ph = "",
156  std::string inf = "",
157  std::string tt = "",
158  int ht = -1
159  );
160 
161 #ifdef NEVER
162 
166  FieldDef
167  (
168  TableDef & td,
169  const char * fn,
170  Flags f = Flags::None
171 // int w = -1, /// width
172 // int h = -1, /// height
173 // std::string lb = "", /// label
174 // std::string ph = "", /// placeholder text
175 // std::string inf = "", /// info
176 // std::string tt = "", /// tooltipText
177 // int ht = -1 /// help topic
178  );
179 #endif
180 
181  virtual ~FieldDefBase() {}
182 
183  virtual Wtx::Dbo::TableDef & tableDef() const;
184 
185  virtual const char * fieldName() const;
186 
187  /*
188  ** this alias name is useful for when implementing new database
189  ** systems, when importing data from some other system, it is
190  ** sometimes useful to encode the foreign column name here so
191  ** that import/export can be more seamless.
192  **
193  */
194  virtual const std::string & aliasName() const;
195 
196  virtual int width() const;
197  virtual void setWidth( int value );
198 
199  virtual int height() const;
200  virtual void setHeight( int value );
201 
202  virtual bool isVisible() const;
203  virtual void setIsVisible( bool value=true );
204 
205  virtual bool isReadOnly() const;
206  virtual void setIsReadOnly( bool value=true );
207 
208  virtual bool isUnique() const;
209  virtual void setIsUnique( bool value=true );
210 
211  virtual const std::string & label() const;
212  virtual void setLabel( const std::string & value );
213 
214  virtual const std::string & placeholderText() const;
215  virtual void setPlaceholderText( const std::string & value );
216 
217  virtual const std::string & info() const;
218  virtual void setInfo( const std::string & value );
219 
220  virtual const std::string & toolTip() const;
221  virtual void setToolTip( const std::string & value );
222 
223  virtual int helpTopic() const;
224  virtual void setHelpTopic( int value );
225 
226  virtual const Flags & flags() const;
227  virtual void setFlags( const Flags value );
228 
229  virtual const std::string & defaultValue() const;
230  virtual void setDefaultValue( const std::string & value );
231 
232  virtual bool forceUppercase() const;
233  virtual void setForceUppercase( bool value = true );
234 
235  virtual const std::string & inputMask() const;
236  virtual void setInputMask( const std::string & mask = "", Wt::WFlags< Wt::InputMaskFlag > flags = Wt::None );
237 
238  virtual std::unique_ptr<Wt::WItemDelegate> createItemDelegate( int sid, Wtx::Dbo::Session & session ) const;
239  virtual std::unique_ptr<Wt::WWidget> createLabelWidget( int sid, Wtx::Dbo::Session & session ) const;
240  virtual std::unique_ptr<Wt::WWidget> createEditWidget( int sid, Wtx::Dbo::Session & session ) const;
241  virtual std::unique_ptr<Wt::WWidget> createDisplayWidget( int sid, Wtx::Dbo::Session & session ) const;
242 
243  virtual std::string toJson() const;
244  virtual void fromJson( const std::string & valud );
245 
246  private:
247 
248  void init();
249 
250  TableDef & m_tableDef;
251  const char * m_fieldName;
252  std::string m_aliasName;
253 
254  int m_width = -1;
255  int m_height = -1;
256  bool m_isReadOnly = false;
257  bool m_isVisible = true;
258  bool m_isUnique = false;
259  bool m_forceUppercase = false;
260  Flags m_flags = None;
261  std::string m_label;
262  std::string m_placeholderText;
263  std::string m_info;
264  std::string m_toolTip;
265  std::string m_defaultValue;
266  std::string m_inputMask;
267  Wt::WFlags< Wt::InputMaskFlag > m_inputMaskFlags;
268  int m_helpTopic = 0;
269 
270 
271 }; // endclass Wtx::Dbo::FieldDef
272 
273  } // endnamespace Dbo
274 } // endnamespace Wtx
275 
276 #endif // #ifndef __WTX_DBO_FIELDDEF_H___
277 
Table Definition.
Definition: TableDef.h:72
Flags
Field Definition Flags.
Definition: FieldDefBase.h:101
witty extension library
Definition: Activity.h:51