This is xmMenu.m in view mode; [Download] [Up]
/* Motif WidgetSet category for implementation of Menu class * * Copyright (C) 1994, 1995 The Board of Trustees of * The Leland Stanford Junior University. All Rights Reserved. * * Authors: Scott Francis, Paul Kunz, Tom Pavel, Imran Qureshi, * and Libing Wang (SLAC) * Mike Kienenberger (Alaska) * * This file is part of an Objective-C class library for X/Motif * * xmMenu.m,v 1.5 1995/04/24 16:14:41 pfkeb Exp * */ #include "Menu.h" #include "xtResponder.h" /* Required for implementation: */ #include "Motif.h" #include <Xm/RowColumn.h> /* for XmCreateMenuBar and * XmCreatePulldownMenu */ #include "MenuCell.h" #include "Matrix.h" #include <objc/List.h> char *MenuInstanceName(void) { return "Menu"; } @implementation Menu(WidgetSet) - _init { classname = xmPrimitiveWidgetClass; return self; } - _getSizeAdjust:(NXSize *)size { /* Since a Menu is treated like a Cell in PopUpList, this method * is implemented */ if ( size ) { size->width = 10; size->height = 8; } return self; } - _managedBy:parent wid:(void*)widget /* Creates the menu, pulldown, etc. The problem with this implementation, as I see it, is that it's implementation depends on the developer only creating one "MENU", ie the main menu of the app, and that all other menus are submenus, in fact. This clearly needs to be more general to allow multiple menus to be created. Its just not good functionality for a library of classes. */ { List *cellList = [matrix cellList]; int i, count; /* * This line is key! It is what creates the dependency on the * NXApp for its main menu! */ if ([self _isMain]) { /* Creates the menubar across top of window */ widgetid = XmCreateMenuBar(widget, instancename, [self _arglist], [self _numargs]); XtManageChild(widgetid); } else { /* Creates submenus that pull down... */ widgetid = XmCreatePulldownMenu(widget, instancename, [self _arglist], [self _numargs]); } /* The order is important */ count = [cellList count]; for ( i = 0; i < count; i++ ) { [[cellList objectAt:i] _managedBy:self]; } if (_helpSubmenu) { XtVaSetValues(widgetid, XmNmenuHelpWidget, [_helpSubmenu _widget], NULL); } return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.