/* C version */ #include <stdio.h> #include <stdlib.h> #include "mgui.h"
/* Program termination callback */ void ExitCB(MOBJECT obj, void *a, void *b) { MShellDestroy((MOBJECT)b); MGUITerm(); exit(0); } void MGUIMain(int argc, char **argv) { MOBJECT shell, rform, cform, pb, lbl; shell = MCreateShell("Example 3", SF_NO_CLOSE); rform = MCreateRowForm(shell); lbl = MCreateLabel(rform, "This Label establishes the window width", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); lbl = MCreateLabel(rform, "Small resizeable Label", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); lbl = MCreateLabel(rform, "Unresizeable Label", HELV_MEDIUM); MObjectSetShadow(lbl, WS_SHADOW_IN, 1, 0); MObjectSetResize(lbl, False, False); cform = MCreateColForm(shell); 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(); }Objects which have a SHELL as parent are actually contained in a main FORM (SHELL's child), so 'cform' is arranged on bottom of 'rform'. The window dimensions equal the main FORM ones, increased by its margins. The FORM width is determined by its largest child Object, while its height is equal to the sum of all children heights plus the spacing offsets.
// 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) { CmRowForm *rform; CmColForm *cform; CmPushButton *pb; CmLabel *lbl; rform = new CmRowForm(this); 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(this); 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); }