KrWinComm: Difference between revisions
mNo edit summary |
|||
Line 1: | Line 1: | ||
==Description== | ==Description== | ||
'''#include "krwc.hpp"''' | '''#include "krwc.hpp"''' | ||
This class, in combination with some operators, acts similar to an istream object. It queries data from the user by presenting him a dialog box. | This class, in combination with some operators, acts similar to an istream object. It queries data from the user by presenting him a dialog box. | ||
Please note that this class does not really inherit from istream, so that not all types which can be input via an istream can also immediately be input via a KrWinComm object. It is possible, however, to provide that support for arbitrary objects in a convenient way. Have a look at the user's guide and the demo programs dialog3 and demo to learn details. | Please note that this class does not really inherit from istream, so that not all types which can be input via an istream can also immediately be input via a KrWinComm object. It is possible, however, to provide that support for arbitrary objects in a convenient way. Have a look at the user's guide and the demo programs dialog3 and demo to learn details. | ||
==Derivation== | ==Derivation== | ||
KrWinComm inherits from IBase. | KrWinComm inherits from IBase. | ||
==Constructors== | ==Constructors== | ||
You can construct and destruct objects of this class. | You can construct and destruct objects of this class. | ||
public: | '''Overload 1''' | ||
public: | |||
KrWinComm (const IString & aTitle = "Dialog"); | KrWinComm (const IString & aTitle = "Dialog"); | ||
The constructor initializes essential object data, but does not create the dialog window. The window is created when the first input is queried from the KrWinComm object. The dialog title can be changed at a later time using setTitle. | |||
The constructor initializes essential object data, but does not create the dialog window. The window is created when the first input is queried from the KrWinComm object. The dialog title can be changed at a later time using setTitle. | |||
==Public Functions== | ==Public Functions== | ||
===Appearance=== | |||
====setFont==== | |||
Use this function to change the default font used in the dialog window. | |||
public: | |||
void setFont (const IFont & aFont); | |||
====setTitle==== | ====setTitle==== | ||
Use this function to change the dialog window's title. | Use this function to change the dialog window's title. | ||
Line 38: | Line 35: | ||
'''Overload 1''' | '''Overload 1''' | ||
public: | |||
public: | |||
KrWinComm (const IString & aTitle = "Dialog"); | KrWinComm (const IString & aTitle = "Dialog"); | ||
The constructor initializes essential object data, but does not create the dialog window. The window is created when the first input is queried from the KrWinComm object. The dialog title can be changed at a later time using setTitle. | |||
====~KrWinComm==== | ====~KrWinComm==== | ||
public: | public: | ||
~KrWinComm (); | ~KrWinComm (); | ||
===Diagnostics=== | ===Diagnostics=== | ||
====ok==== | ====ok==== | ||
Use this function to find out whether the last dialog has been aborted. | Use this function to find out whether the last dialog has been aborted. | ||
public: | |||
public: | Boolean ok (); | ||
Boolean ok (); | This function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it. | ||
This function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it. | |||
===Display Dialog=== | ===Display Dialog=== | ||
====run==== | ====run==== | ||
This function displays the dialog and waits for the user input. | This function displays the dialog and waits for the user input. | ||
public: | |||
public: | Boolean run (); | ||
Boolean run (); | The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it. | ||
The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it. | |||
'''Note:''' | '''Note:''' It is recommended to use the display modifier instead of this function. | ||
===Input=== | ===Input=== | ||
====addEntryField==== | ====addEntryField==== | ||
This function prepares the KrWinComm object to input variables of the corresponding type. | This function prepares the KrWinComm object to input variables of the corresponding type. | ||
'''Overload 1''' | |||
public: | |||
void addEntryField (IString & s); | |||
'''Overload | '''Overload 2''' | ||
public: | |||
void addEntryField (double & d); | |||
public: | '''Overload 3''' | ||
void addEntryField ( | public: | ||
void addEntryField (unsigned long & l); | |||
'''Overload 4''' | |||
public: | |||
void addEntryField (signed long & l); | |||
'''Overload | '''Overload 5''' | ||
public: | |||
void addEntryField (KrBitfield & b); | |||
public: | '''Overload 6''' | ||
void addEntryField ( | public: | ||
void addEntryField (KrChoice & c); | |||
'''Overload 7''' | |||
public: | |||
void addEntryField (KrUserDataField & f); | |||
''' | '''Overload 8''' | ||
public: | |||
void addEntryField (KrUserDataField * f); | |||
The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it. | |||
'''Note:''' Do not use any of these functions. Use the corresponding operator >> instead. | |||
===Output=== | ===Output=== | ||
====addToNextPrompt==== | ====addToNextPrompt==== | ||
This function appends a string to the introducing line for the next input field. | This function appends a string to the introducing line for the next input field. | ||
public: | |||
public: | void addToNextPrompt (const IString & title); | ||
void addToNextPrompt (const IString & title); | |||
'''Note:''' It is recommended to use the operator << instead of this function. | |||
====setNextPrompt==== | ====setNextPrompt==== | ||
This function sets the introducing line for the next input field. | This function sets the introducing line for the next input field. | ||
public: | |||
public: | void setNextPrompt (const IString & title); | ||
void setNextPrompt (const IString & title); | |||
'''Note:''' | '''Note:''' It is recommended to use the operator << instead of this function. | ||
==Operators== | ==Operators== | ||
For your convenience, overloads to the common input and output operator are provided for the use with KrWinComm. | For your convenience, overloads to the common input and output operator are provided for the use with KrWinComm. | ||
'''Note:''' | '''Note:''' Make sure you do not use any of these operatrs before IApplication::current().run() has been called, since they require the existence of a message queue. | ||
===operator <<=== | ===operator <<=== | ||
This operator lets the programmer add "prompt lines" to the dialog window presented to the user. KrWinComm accumulates all strings directed to it using this operator, until the operator >> is used to input some variable. Then, the accumulated string is used as the prompt line, and its contents | This operator lets the programmer add "prompt lines" to the dialog window presented to the user. KrWinComm accumulates all strings directed to it using this operator, until the operator >> is used to input some variable. Then, the accumulated string is used as the prompt line, and its contents are deleted so that the same can be done for the next input variable. | ||
'''Overload 1''' | '''Overload 1''' | ||
public: | |||
KrWinComm & operator << (KrWinComm & aWinComm, | |||
const IString & aString); | |||
===operator >>=== | |||
Use the overloads of this operator to query input from the user. | |||
===operator >>=== | |||
Use the | Use the last overload, which expects a pointer to a KrUserDataField object, to define the input for objects for which no pre-defined operator exists, and which are not derived from KrUserDataField. The corresponding KrUserDataField will be deleted after the dialog window has been displayed. Have a look at the user's guide and the sample programs display3.cpp and demo.cpp for details on this subject. | ||
The other overloads do not delete the objects passed to them as arguments. | |||
'''Overload 1''' | |||
public: | |||
'''Overload 1''' | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
public: | IString & aString); | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | |||
IString & aString); | |||
'''Overload 2''' | '''Overload 2''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
double & aDouble); | double & aDouble); | ||
'''Overload 3''' | '''Overload 3''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
unsigned long & aUnsigned); | unsigned long & aUnsigned); | ||
'''Overload 4''' | '''Overload 4''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
signed long & aSigned); | signed long & aSigned); | ||
'''Overload 5''' | '''Overload 5''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
KrBitfield & aBitfield); | KrBitfield & aBitfield); | ||
'''Overload 6''' | '''Overload 6''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
KrChoice & aChoice); | KrChoice & aChoice); | ||
'''Overload 7''' | '''Overload 7''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
KrUserDataField & aUserData); | KrUserDataField & aUserData); | ||
'''Overload 8''' | '''Overload 8''' | ||
public: | public: | ||
KrWinComm & operator >> (KrWinComm & aWinComm, | KrWinComm & operator >> (KrWinComm & aWinComm, | ||
KrUserDataField* aUserData); | KrUserDataField* aUserData); | ||
==Manipulators== | ==Manipulators== | ||
The display manipulator will show the dialog on the screen and let the user type his input. Its influence on KrWinComm objects is similar to that of the operator flush on ostream objects. | The display manipulator will show the dialog on the screen and let the user type his input. Its influence on KrWinComm objects is similar to that of the operator flush on ostream objects. | ||
===KrWinComm - Manipulator Display=== | ===KrWinComm - Manipulator Display=== |
Latest revision as of 21:52, 7 October 2022
Description
#include "krwc.hpp"
This class, in combination with some operators, acts similar to an istream object. It queries data from the user by presenting him a dialog box.
Please note that this class does not really inherit from istream, so that not all types which can be input via an istream can also immediately be input via a KrWinComm object. It is possible, however, to provide that support for arbitrary objects in a convenient way. Have a look at the user's guide and the demo programs dialog3 and demo to learn details.
Derivation
KrWinComm inherits from IBase.
Constructors
You can construct and destruct objects of this class.
Overload 1
public: KrWinComm (const IString & aTitle = "Dialog");
The constructor initializes essential object data, but does not create the dialog window. The window is created when the first input is queried from the KrWinComm object. The dialog title can be changed at a later time using setTitle.
Public Functions
Appearance
setFont
Use this function to change the default font used in the dialog window.
public: void setFont (const IFont & aFont);
setTitle
Use this function to change the dialog window's title.
public: void setTitle (const IString & aTitle);
Constructors
KrWinComm
You can construct and destruct objects of this class.
Overload 1
public: KrWinComm (const IString & aTitle = "Dialog");
The constructor initializes essential object data, but does not create the dialog window. The window is created when the first input is queried from the KrWinComm object. The dialog title can be changed at a later time using setTitle.
~KrWinComm
public: ~KrWinComm ();
Diagnostics
ok
Use this function to find out whether the last dialog has been aborted.
public: Boolean ok ();
This function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it.
Display Dialog
run
This function displays the dialog and waits for the user input.
public: Boolean run ();
The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it.
Note: It is recommended to use the display modifier instead of this function.
Input
addEntryField
This function prepares the KrWinComm object to input variables of the corresponding type.
Overload 1
public: void addEntryField (IString & s);
Overload 2
public: void addEntryField (double & d);
Overload 3
public: void addEntryField (unsigned long & l);
Overload 4
public: void addEntryField (signed long & l);
Overload 5
public: void addEntryField (KrBitfield & b);
Overload 6
public: void addEntryField (KrChoice & c);
Overload 7
public: void addEntryField (KrUserDataField & f);
Overload 8
public: void addEntryField (KrUserDataField * f);
The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it.
Note: Do not use any of these functions. Use the corresponding operator >> instead.
Output
addToNextPrompt
This function appends a string to the introducing line for the next input field.
public: void addToNextPrompt (const IString & title);
Note: It is recommended to use the operator << instead of this function.
setNextPrompt
This function sets the introducing line for the next input field.
public: void setNextPrompt (const IString & title);
Note: It is recommended to use the operator << instead of this function.
Operators
For your convenience, overloads to the common input and output operator are provided for the use with KrWinComm.
Note: Make sure you do not use any of these operatrs before IApplication::current().run() has been called, since they require the existence of a message queue.
operator <<
This operator lets the programmer add "prompt lines" to the dialog window presented to the user. KrWinComm accumulates all strings directed to it using this operator, until the operator >> is used to input some variable. Then, the accumulated string is used as the prompt line, and its contents are deleted so that the same can be done for the next input variable.
Overload 1
public: KrWinComm & operator << (KrWinComm & aWinComm, const IString & aString);
operator >>
Use the overloads of this operator to query input from the user.
Use the last overload, which expects a pointer to a KrUserDataField object, to define the input for objects for which no pre-defined operator exists, and which are not derived from KrUserDataField. The corresponding KrUserDataField will be deleted after the dialog window has been displayed. Have a look at the user's guide and the sample programs display3.cpp and demo.cpp for details on this subject.
The other overloads do not delete the objects passed to them as arguments.
Overload 1
public: KrWinComm & operator >> (KrWinComm & aWinComm, IString & aString);
Overload 2
public: KrWinComm & operator >> (KrWinComm & aWinComm, double & aDouble);
Overload 3
public: KrWinComm & operator >> (KrWinComm & aWinComm, unsigned long & aUnsigned);
Overload 4
public: KrWinComm & operator >> (KrWinComm & aWinComm, signed long & aSigned);
Overload 5
public: KrWinComm & operator >> (KrWinComm & aWinComm, KrBitfield & aBitfield);
Overload 6
public: KrWinComm & operator >> (KrWinComm & aWinComm, KrChoice & aChoice);
Overload 7
public: KrWinComm & operator >> (KrWinComm & aWinComm, KrUserDataField & aUserData);
Overload 8
public: KrWinComm & operator >> (KrWinComm & aWinComm, KrUserDataField* aUserData);
Manipulators
The display manipulator will show the dialog on the screen and let the user type his input. Its influence on KrWinComm objects is similar to that of the operator flush on ostream objects.
KrWinComm - Manipulator Display
This manipulator displays the dialog window defined by previous uses of the operators << and >> on a KrWinComm object and evaluates the user input.
public: KrWinComm & display (KrWinComm & aWinComm);