summaryrefslogtreecommitdiffstats
path: root/kig/misc/kiginputdialog.h
blob: 60f2ba54230dd6b678496b93423c214483ffead1 (plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
 This file is part of Kig, a KDE program for Interactive Geometry...
 Copyright (C) 2005  Pino Toscano <toscano.pino@tiscali.it>

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA
**/

#ifndef KIG_MISC_KIGINPUTDIALOG_H
#define KIG_MISC_KIGINPUTDIALOG_H

class TQString;
class Coordinate;
class Goniometry;
class KigDocument;
class KigInputDialogPrivate;

#include <kdialogbase.h>

/**
 * The KigInputDialog class provides easy ways of interaction with the user.
 * For example, it provides a flexible way to get one or two coordinates at
 * once.
 *
 * It provides several static convenience functions: getCoordinate(),
 * getTwoCoordinates(), getAngle().
 */
class KigInputDialog
  : KDialogBase
{
Q_OBJECT
  TQ_OBJECT

public:

private:
  KigInputDialog( const TQString& caption, const TQString& label, TQWidget* tqparent,
        const KigDocument& doc, Coordinate* c1, Coordinate* c2 );
  KigInputDialog( TQWidget* tqparent, const Goniometry& g );

  virtual void keyPressEvent( TQKeyEvent* e );

  KigInputDialogPrivate* const d;
  friend class KInputDialogPrivate;

  Coordinate coordinateFirst() const;
  Coordinate coordinateSecond() const;
  Goniometry goniometry() const;

private slots:
  void slotCoordsChanged( const TQString& );
  void slotGonioSystemChanged( int index );
  void slotGonioTextChanged( const TQString& txt );

public:
  /**
   * Static convenience function to get a Coordinate from the user.
   *
   * \param caption caption of the dialog
   * \param label text of the label of the dialog
   * \param tqparent tqparent of the dialog widget
   * \param ok it will be set to true if the user pressed Ok after inserting a
   *           well-formatted Coordinate
   * \param doc the actual Kig document
   * \param cvalue a pointer to a Coordinate class. If the user inserted
   *               successfully a new Coordinate, the value will be stored
   *               here. If this points to a valid Coordinate, then it will be
   *               displayed as initial value of the correspondenting text edit
   */
  static void getCoordinate( const TQString& caption, const TQString& label,
        TQWidget* tqparent, bool* ok, const KigDocument& doc, Coordinate* cvalue );

  /**
   * Static convenience function to get two Coordinates at once from the user.
   *
   * \param caption caption of the dialog
   * \param label text of the label of the dialog
   * \param tqparent tqparent of the dialog widget
   * \param ok it will be set to true if the user pressed Ok after inserting
   *           well-formatted Coordinates
   * \param doc the actual Kig document
   * \param cvalue a pointer to a Coordinate class. If the user inserted
   *               successfully new Coordinates, the value of the first
   *               Coordinate will be stored here. If this points to a valid
   *               Coordinate, then it will be displayed as initial value of
   *               the text edit representing the first Coordinate.
   * \param cvalue2 a pointer to a Coordinate class. If the user inserted
   *                successfully new Coordinates, the value of the second
   *                Coordinate will be stored here. If this points to a valid
   *                Coordinate, then it will be displayed as initial value of
   *                the text edit representing the second Coordinate.
   */
  static void getTwoCoordinates( const TQString& caption, const TQString& label,
        TQWidget* tqparent, bool* ok, const KigDocument& doc, Coordinate* cvalue,
        Coordinate* cvalue2 );

  /**
   * Static convenience function to get an angle incapsulated in a Goniometry
   * class.
   *
   * \param tqparent tqparent of the dialog widget
   * \param ok it will be set to true if the user pressed Ok after inserting a
   *           well-formatted angle
   * \param g the Goniometry class containing the original angle we are going
   *          to modify.
   *
   * \return a Goniometry class containing the new angle
   */
  static Goniometry getAngle( TQWidget* tqparent, bool* ok, const Goniometry& g );
};

#endif