/* C version */ #include <stdio.h> #include <stdlib.h> #include "mgui.h" void ExitCB(MOBJECT obj, void *a, void *b) { MShellDestroy((MOBJECT)b); MGUITerm(); exit(0); } void MGUIMain(int argc, char **argv) { MOBJECT shell, sform, rform, cform, pb, lbl; shell = MCreateShell("Example 4", SF_NO_CLOSE); sform = MCreateScrolledRowForm(shell, 120, 80); rform = MCreateRowForm(sform); lbl = MCreateLabel(rform, "This Label establishes the width", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); lbl = MCreateLabel(rform, "Small Label", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); lbl = MCreateLabel(rform, "Not resizeable Label", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); MObjectSetResize(lbl, False, False); cform = MCreateColForm(sform); pb = MCreatePButton(cform, "dummy", TIMES_MEDIUM); pb = MCreatePButton(cform, "Quit", TIMES_MEDIUM); MObjectSetAttachment(pb, True, True, False, True); MPButtonSetCallback(pb, ExitCB, shell); MShellRealize(shell); MMainLoop(); }
// C++ version
#include <stdio.h>
#include "mguipp.h"
class CaAppl : public CmAppl {
public:
void start(int, char **);
};
CaAppl appInstance;
class CaMainWindow : public CmShell {
public:
CaMainWindow(const char *title, int flags);
void exitCB(void);
};
void CaMainWindow::exitCB(void)
{
delete this;
CmAppl::end(0);
}
void CaAppl::start(int argc, char **argv)
{
CaMainWindow *win = new CaMainWindow("Example 3", SF_NO_CLOSE);
win->realize();
mainLoop();
}
CaMainWindow::CaMainWindow(const char *title, int flags)
: CmShell(title, flags)
{
CmScrolledRowForm *sform;
CmRowForm *rform;
CmColForm *cform;
CmPushButton *pb;
CmLabel *lbl;
sform = new CmScrolledRowForm(this, 120, 80);
rform = new CmRowForm(sform);
lbl = new CmLabel(rform, "This Label establishes the window width", HELV_MEDIUM);
lbl->setShadow(WS_SHADOW_IN, 1, 0);
lbl = new CmLabel(rform, "Small resizeable Label", HELV_MEDIUM);
lbl->setShadow(WS_SHADOW_IN, 1, 0);
lbl = new CmLabel(rform, "Unresizeable Label", HELV_MEDIUM);
lbl->setShadow(WS_SHADOW_IN, 1, 0);
lbl->setResize(False, False);
cform = new CmColForm(sform);
pb = new CmPushButton(cform, "dummy", TIMES_MEDIUM);
pb = new CmPushButton(cform, "Quit", TIMES_MEDIUM);
pb->setAttachment(True, True, False, True);
pb->setCallback(this, (VOID_CB)exitCB);
}