KrWinComm

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.

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);

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 ;

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.

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.

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.

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 is 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 < > on a KrWinComm object and evaluates the user input. public: KrWinComm & display (KrWinComm & aWinComm);