File: Form.h

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (86 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */

#ifndef FORM_H_
#define FORM_H_

#include <Wt/WTable>

using namespace Wt;

namespace Wt {
  class WContainerWidget;
  class WText;
  class WTextArea;
  class WLineEdit;
  class WComboBox;
  class WFormWidget;
  class WDatePicker;
}

/**
 * @addtogroup formexample
 */
/*@{*/

/*!\brief A simple Form.
 *
 * Shows how a simple form can made, with an emphasis on how
 * to handle validation.
 */
class Form : public WTable
{
public:
  /*!\brief Instantiate a new form.
   */
  Form(WContainerWidget *parent = 0);

private slots:
  /*!\brief The user selected a new country: adjust the cities combo box.
   */
  void countryChanged();

  /*!\brief Submit the form.
   */
  void submit(); 

private:
  void createUI();
 
  WContainerWidget *feedbackMessages_;

  WLineEdit *nameEdit_;
  WLineEdit *firstNameEdit_;

  WComboBox *countryEdit_;
  WComboBox *cityEdit_;

  WDatePicker *birthDateEdit_;
  WLineEdit *childCountEdit_;
  WLineEdit *weightEdit_;

  WTextArea *remarksEdit_;

  /*!\brief Add a validation feedback for a field
   */
  void addValidationStatus(int row, WFormWidget *field);

  /*!\brief Validate the form, and return whether succesfull.
   */
  bool validate();

  /*!\brief Validate a single form field.
   *
   * Checks the given field, and appends the given text to the error
   * messages on problems.
   */
  bool checkValid(WFormWidget *edit, const WString& text);
};

/*@}*/

#endif // FORM_H_