• IKE
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    IKE
    Posts: 146 from 2009/11/7
    From: Southern CA
    I am trying to add menu items in this cut down version from the two source code examples in the SDK. It compiles without error and creates the menu items, but no action occurs when menu items are selected. The file is named window.m and the makefile that I am using is pasted below. I am trying to understand what I am doing wrong...any advice appreciated!

    Code:
    //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:@"My First Objc Window"];
    [mapp setDescription:@"wow!"];

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

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

    w.title = @"My First Objc Window";
    w.rootObject = g;

    // added here...I know it's not the right place...
    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 setOpen: YES];
    [mapp run];

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

    return 0;
    }


    Here is the makefile:

    CC = ppc-morphos-gcc-5 -Wall -DDEBUG=0
    CFLAGS = -noixemul -I/SDK/Frameworks/include -fconstant-string-class=OBConstantString -fobjc-exceptions -g -std=gnu99 -Wl,--traditional-format
    # NOTE: make sure NOT to use _debug libraries for builds you intend to redistribute as they will not work without the SDK installed
    # !!! API/ABI not yet stable. Expect your binaries not to work with MorphOS 3.12 - they will need to be recompiled.
    LIBS = -lob.framework -lmui.framework -lobjc -ldebug -noixemul -lm -lmath

    all: Window

    %.mo : %.m
    $(CC) $(CFLAGS) -c $< -o $@

    Window:
    $(CC) $(CFLAGS) window.m $(LIBS) -o Window
    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 - 07:03
    Profile Visit Website