• IKE
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    IKE
    Posts: 146 from 2009/11/7
    From: Southern CA
    Thanks for the insight! This simple window example with menu items works now.

    Code:
    //simple window example
    #import <mui/MUIFramework.h>
    #import <proto/dos.h>
    #import <proto/graphics.h>
    #import <proto/muimaster.h>
    #import <proto/layers.h>

    @interface MyArea : MUIArea {

    MUIObject *_aboutbox;
    }
    @end

    @implementation MyArea

    + (MyArea *) myArea {

    return [[self new] autorelease];
    }

    - (id) init {

    if ((self = [super init])) {

    [self setFillArea:YES];
    [self setFrame:MUIV_Frame_Text];
    }
    return self;
    }

    - (void) dealloc {
    [super dealloc];
    }

    - (void) askMinMax:(struct MUI_MinMax *) minmax {

    minmax->MinWidth += 300;
    minmax->MinHeight += 300;
    minmax->DefWidth += 300;
    minmax->DefHeight += 300;
    minmax->MaxWidth+=600;
    minmax->MaxHeight+=600;
    }

    - (void) about {

    if (nil == _aboutbox) {

    _aboutbox = [[MCCAboutbox new] autorelease];
    [[MUIApplication currentApplication] addObject:_aboutbox];
    }

    [_aboutbox setValue:TRUE forAttribute:MUIA_Window_Open];
    }

    - (void) setMenuAction:(ULONG) menuaction {

    switch (menuaction) {

    case 666:
    [[OBApplication currentApplication] quit];
    break;

    case 668:
    [self about];
    break;
    }
    }
    @end

    int muiMain(int argc, char *argv[]) {

    MUIApplication *mapp = [[MUIApplication alloc] init];

    [mapp setTitle:@"Simple Obj-c Window Example"];
    [mapp setDescription:@"Wow!"];
    [mapp setApplicationVersion:@"$VER:Window 0.1 (12.20.2020) © IKE"];
    [mapp setAuthor:@"IKE"];
    [mapp setBase:@"Simple Obj-c Window Example"];
    [mapp setCopyright:@"2020 IKE"];

    MyArea *ma;

    MUIGroup *g = [MUIGroup groupWithObjects:ma = [MyArea myArea], nil];

    MUIWindow *w = [[MUIWindow new] autorelease];

    w.title = @"Simple Obj-c Window Example";
    w.rootObject = g;

    w.menustrip = [MUIMenustrip menustripWithObjects:
    [MUIMenu menuWithTitle:OBL(@"Project", @"Main menu title") objects:
    [MUIMenuitem itemWithTitle:OBL(@"About ...", @"Menu About") shortcut:OBL(@"?", @"Menu about shortcut") userData:668],
    [MUIMenuitem barItem],
    [MUIMenuitem itemWithTitle:OBL(@"Quit", @"Menu quit") shortcut:OBL(@"Q", @"Menu quit option") userData:666],
    nil],
    nil];

    [mapp instantiateWithWindows:w, NULL];

    [w notify:@selector(closeRequest) performSelector:@selector(quit) withTarget:[OBApplication currentApplication]];
    [w notify:@selector(menuAction) performSelector:@selector(setMenuAction:) withRawTriggerValueTarget:ma];

    [w setOpen: YES];
    [mapp run];

    [w setOpen: NO];
    [mapp release];

    return 0;
    }
    IKE

    MacMini G4 1.5Ghz/PowerBook G4 1.67Ghz/PowerMac G5 2.0Ghz DP 7,2 Radeon 9650/256MB

    Join the conversation @ r/morphos
  • »20.12.20 - 20:57
    Profile Visit Website