#include <test_file.h>
Public Member Functions | |
DemoClass () | |
virtual | ~DemoClass () |
virtual void | initCaller () |
This class shall be a base class for all classes that want to display a warning, informational or critical message by means of the MessageDlg class.
MessageDlg is a class with similar functionality as the QMessageBox class. MessageDlg is created because QMessageBox is a modal dialog with a normal window border. The major drawback of such a border is that the when the left mouse is pressed on the title bar no events will be handle any more (no comms events either) until the mouse is released again. This is a safety issue and must be omitted. Therefor MessageDlg is created and is derived from AInteractWnd. Drawback of this approach is that the dialog is not modal. To remove this drawback the following must be taken into account:
When a class wants to show a message by means of the MessageDlg, it must be derived from DemoClass. By doing this a port connection will be made with the MessageDlg at the moment of instantiation of MessageDlg. This connection is necessary because in the MessageDlg several buttons can be placed ( Ok, Cancel, Yes, No, Abort, Retry and Ignore) and the calling class has to know which of the buttons is pressed. This is done by calling messageDlgReply( int id, int reply). This is a method of DemoClass and must be overloaded in the calling class. Because the MessageDlg is a non-modal dialog, it is possible to neglect the message dialog, keep it open and continue working. Therefor it is necessary to check, in some cases, if the message dialog is still open or not. This is done by calling messageDlgShown(). This method of DemoClass returns true if the MessageDlg is still open and it sounds a signal. When one of the buttons of the message dialog is pressed messageDlgReply() is called. In this method the messageDlgShown flag can be cleared by calling messageDlgShown( false );
The next example contains no valid code, it is just ilustrative.
Start of the code example: Include file:
1. #include <widgets/DemoClass.h>
2. class IdentificationDlg : public DemoClass
3. {
// public part
4. public:
5. enum MessageOriginId
6. {
7. EmptyFields = 1,
8. ApplyCorrectValues = 2,
9. OkCorrectValues = 3
10. };
11. IdentificationDlg();
12. virtual ~IdentificationDlg();
13. virtual void ok();
14. virtual void doOk();
15. virtual void cancel();
16. virtual void apply();
17. virtual void doApply();
18. virtual void reset();
19. bool checkEmptyFields ( MessageOriginId originId );
20. bool checkCorrectValues( MessageOriginId originId );
21. virtual void messageDlgReply( int id, int reply);
22. };
To begin of source code from inside pre-tags
To public part from inside pre-tags
To begin of source code from outside pre-tags To public part from outside pre-tagsWhat do we see here:
|
Constructor |
|
Destructor |
|
Initializes the MessageDlgCaller. Reads the settings from messagedlg.xml |
Generated at Wed Jan 19 10:19:12 2005 by doxygen 1.3.8. | ![]() |