#include <libraries/mui.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/muimaster.h>
#ifdef __PPC__
#include <ppcinline/exec.h>
#include <ppcinline/muimaster.h>
#endif
// Custom IDs for menu items
#define MENU_FILE_QUIT 100
int main(void)
{
struct Library *MUIMasterBase;
Object *app, *mainWin, *menu, *quitButton;
ULONG result;
// Open MUI master library
MUIMasterBase = OpenLibrary("muimaster.library", 0);
if (!MUIMasterBase) {
printf("Cannot open muimaster.library!\n");
return 1;
}
// --- Create Application ---
app = ApplicationObject,
MUIA_Application_Title, "Skeleton App",
MUIA_Application_Version, "$VER: SkeletonApp 1.0",
End;
if (!app) {
printf("Failed to create application object.\n");
CloseLibrary(MUIMasterBase);
return 1;
}
// --- Create Menu Bar ---
menu = MenuObject,
MUIA_Menu_Title, "File",
SubMenu, MUI_MENUNAME, "Quit",
MUIA_Menuitem_ID, MENU_FILE_QUIT,
End,
End;
// --- Create Quit Button ---
quitButton = ButtonObject,
MUIA_Button_Title, "Quit",
MUIA_Button_ReturnId, MENU_FILE_QUIT,
End;
// --- Create Main Window ---
mainWin = WindowObject,
MUIA_Window_Title, "Main Window",
MUIA_Window_Activate, TRUE,
MUIA_Window_ID, 1,
WindowContents, VGroup,
Child, TextObject,
MUIA_Text_Contents, "Hello World! This is a skeleton app.",
End,
Child, quitButton,
End,
WindowMenu, menu,
End;
if (!mainWin) {
printf("Failed to create window.\n");
MUI_DisposeObject(app);
CloseLibrary(MUIMasterBase);
return 1;
}
// Add window to application
DoMethod(app, MUIM_Application_AddWindow, mainWin);
// --- Event Loop ---
while ((result = DoMethod(app, MUIM_Application_Pend, 0, 0, 0))) {
switch(result) {
case MENU_FILE_QUIT: // Quit menu or button
case MUIV_Application_ReturnID_Quit: // Window close
goto cleanup;
default:
// Handle other events here
break;
}
}
cleanup:
// --- Cleanup ---
MUI_DisposeObject(app);
CloseLibrary(MUIMasterBase);
return 0;
}