Jump to content

KrWinComm: Difference between revisions

From EDM2
Created page with "==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 ..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
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.


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


===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.


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:
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.


public:
===Input===
Boolean run ();
====addEntryField====
This function prepares the KrWinComm object to input variables of the corresponding type.


The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it.
'''Overload 1'''
public:
void addEntryField (IString & s);


'''Note:'''   It is recommended to use the display modifier instead of this function.
'''Overload 2'''
public:
void addEntryField (double & d);


===Input===
'''Overload 3'''
====addEntryField====
public:
This function prepares the KrWinComm object to input variables of the corresponding type.
void addEntryField (unsigned long & l);


'''Overload 1'''  
'''Overload 4'''
public:
void addEntryField (signed long & l);


  public:  
'''Overload 5'''
  void addEntryField (IString & s);  
  public:
  void addEntryField (KrBitfield & b);


'''Overload 6'''
public:
void addEntryField (KrChoice & c);


'''Overload 2'''  
'''Overload 7'''
public:
void addEntryField (KrUserDataField & f);


  public:  
'''Overload 8'''
  void addEntryField (double & d);  
  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.


'''Overload 3'''  
'''Note:''' Do not use any of these functions. Use the corresponding operator >> instead.


  public:  
===Output===
  void addEntryField (unsigned long & l);  
====addToNextPrompt====
This function appends a string to the introducing line for the next input field.
  public:
  void addToNextPrompt (const IString & title);


'''Overload 4'''  
'''Note:''' It is recommended to use the operator << instead of this function.


  public:  
====setNextPrompt====
  void addEntryField (signed long & l);  
This function sets the introducing line for the next input field.
  public:
  void setNextPrompt (const IString & title);


'''Overload 5'''  
'''Note:''' It is recommended to use the operator << instead of this function.


public:
==Operators==
void addEntryField (KrBitfield & b);
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.


'''Overload 6''' 
===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.


  public:  
'''Overload 1'''
  void addEntryField (KrChoice & c);  
  public:
  KrWinComm & operator << (KrWinComm & aWinComm,
                        const IString & aString);


===operator >>===
Use the overloads of this operator to query input from the user.


'''Overload 7''' 
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.


public:
The other overloads do not delete the objects passed to them as arguments.
void addEntryField (KrUserDataField & f);


'''Overload 1'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        IString & aString);


'''Overload 8'''  
'''Overload 2'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        double & aDouble);


  public:  
'''Overload 3'''
  void addEntryField (KrUserDataField * f);  
  public:
  KrWinComm & operator >> (KrWinComm & aWinComm,
                        unsigned long & aUnsigned);


The function returns true if the user completed the dialog and pressed the OK button, and false if he aborted it.
'''Overload 4'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        signed long & aSigned);


'''Note:'''   Do not use any of these functions. Use the corresponding operator >> instead.
'''Overload 5'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        KrBitfield & aBitfield);


'''Overload 6'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        KrChoice & aChoice);


===Output===
'''Overload 7'''
====addToNextPrompt====
public:
====setNextPrompt====
KrWinComm & operator >> (KrWinComm & aWinComm,
                        KrUserDataField & aUserData);


==Operators==
'''Overload 8'''
public:
KrWinComm & operator >> (KrWinComm & aWinComm,
                        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.
===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);
[[Category:Kronis Classes]]

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