The dialog manager class.
The dialog manager class. Dialogs in MASkinG are nothing but widgets that can contain other widgets. You should always have one main dialog to which you can add widgets and other dialogs. Normally you should derive your own dialog class from Dialog and implement some of the virtual functions that define the apearance and behaviour of your dialog. In almost all cases you will need to implement the HandleEvent() and MsgInitSkin().The most common practice to create dialogs is to define widgets as data members of their parent dialog and add them to the dialog in the constructor. The widgets may of course also be added and removed dynamically. Once the dialog is constructed it can be executed with the Execute() function.
The dialog class should also be used as a baseclass for all compound widgets, that is widgets that are made by combining several other more low level widgets.
NONE - do nothing (usually when the mouse is inside the dialog
MOVE - move the dialog (usually when the mouse is on the caption bar)
RESIZE_UP_LEFT - resize the dialog (usually when the mouse is on the
RESIZE_UP_RIGHT dialog border; the actual action depend on the exact
RESIZE_DOWN_LEFT position on the border)
RESIZE_DOWN_RIGHT
RESIZE_UP
RESIZE_DOWN
RESIZE_LEFT
RESIZE_RIGHT
The most common way to write the event handler is to write a large switch statement in which you call functions that correspond to the event. Here's a small example:
void MyDialog::HandleEvent(Widget &obj, int msg, int arg1, int arg2) {
pass the event up the class hierarchy
Dialog::HandleEvent(obj, msg, arg1, arg2);
handle different messages
switch (msg) {
case MSG_ACTIVATE:
if (obj == button1) OnButton1(); else
if (obj == button2) OnButton2(); else
if (obj == button3) OnButton3();
break;
case MSG_RPRESS:
if (obj == desktop) OnPopupMenu();
break;
case MSG_MOUSEMOVE:
if (obj == desktop) OnMouseMove(Point(arg1, arg2));
break;
case MSG_SCROLL:
if (object == slider1) OnChangeVolume(int arg1);
break;
};
}
Note that it is illegal to delete a widget in HandleEvent() or in a function
called from HandleEven(). If you want to remove and delete a dynamically
created widget (e.g. in response to MSG_CLOSE), call Remove(obj, true) instead.
Alphabetic index Hierarchy of classes