kt@msor.msor (Keith Tizzard) (12/08/90)
I am trying to use C++ under MPW and would welcome some advice and help. The C++ language creates no problem since I have used it in other environments. The problem comes when I try to find out about the MacApp classes and their methods. Where do I look for a clear description? Do I need to acquire and read all the volumes of Inside Macintosh? Is there a class browser to enable me to find out, quickly and easily what classes are available to inherit and what member functions they contain? Basically I am comfortable with obejct orientated programming and C++ but am new to programming the Mac. Any advice about how to proceed would be most welcome. In the APDAlog I note the publications: C++ Programming with MacApp by David Wilson, Larry Rosenstein and Dan Shafer Elements of C++ Macintosh Programming by Dan Weston Has anybody read and used these? Are they helpful for the novice? Let me illustrate my difficulty. The following code is taken from ShapesApp.cp, one of the files in the distributed C++ examples which come with MPW. Reading the code is difficult and the thought of creating new code is awe inspiring. Within the class constructors and member functions very little appears to be object orientated. In the constructor TShapesApp, shown below, are SetMenuBar(), DisposHandle(), DrawMenuBar() ... external functions (i.e. C) or are they inherited member functions? Why does it not say: menuBar->Set() or maybe menuBar.Set() and menuBar->DisposeHandle the code does not appear to be very object orientated. Where do I look, on the system, to find out where these functions are? Do I Search the 17 include files at the top of TApplication.cp ?? TShapesApp::TShapesApp(void) { Handle menuBar; menuBar = GetNewMBar(rMenuBar); SetMenuBar(menuBar); DisposHandle(menuBar); AddResMenu(GetMHandle(mApple), 'DRVR'); DrawMenuBar(); fMouseRgn = NewRgn(); DoNew(); } In the following member function why do we have: ? EnableItem(menu, iNew); instead of menu->EnableItem(iNew) DisableItem(menu, iClose); instead of menu->DisableItem(iClose); menu = GetMHandle(mFile); instead of menu = mFile->GetMHandle(); void TShapesApp::AdjustMenus(void) { WindowPtr frontmost; MenuHandle menu; TShapesDocument* fShapesCurDoc = (TShapesDocument*) fCurDoc; frontmost = FrontWindow(); menu = GetMHandle(mFile); if ( fDocList->NumDocs() < kMaxOpenDocuments ) EnableItem(menu, iNew); else DisableItem(menu, iNew); if ( frontmost != (WindowPtr) nil ) EnableItem(menu, iClose); else DisableItem(menu, iClose); // stuff deleted } When using a set of existing classes, easily accessible documentation is needed. By that I mean, a list of all the classes together with their member functions plus a clear description of what each one does. How can one program effectively in an OO language without a class browser? Is there one available?? -- Keith Tizzard MSOR Dept, University of Exeter, Streatham Court, EXETER EX4 4PU, UK tel: (+44) 392 264463 email: kt@msor.exeter.ac.uk kt@msor.UUCP
ksand@Apple.COM (Kent Sandvik) (12/12/90)
In article <1082@exua.exeter.ac.uk> kt@msor.msor (Keith Tizzard) writes: >I am trying to use C++ under MPW and would welcome some advice and help. >The C++ language creates no problem since I have used it in other environments. >The problem comes when I try to find out about the MacApp classes and their >methods. >Where do I look for a clear description? >Do I need to acquire and read all the volumes of Inside Macintosh? You don't need to learn all the internals of Mac, but it sure helps to understand how the drawing (QuickDraw), memory management (Memory Manager), the file system (File Manager) and the resources (Resource Manager) works. This because you need to use these in your MacApp source code. The rest is taken care by MacApp. >Is there a class browser to enable me to find out, quickly and easily >what classes are available to inherit and what member functions they contain? MacBrowse is part of the MacApp 2.0 release. It's very, very useful. >In the APDAlog I note the publications: >C++ Programming with MacApp by David Wilson, Larry Rosenstein and Dan Shafer >Elements of C++ Macintosh Programming by Dan Weston Get both! >Let me illustrate my difficulty. >The following code is taken from ShapesApp.cp, one of the files in the >distributed C++ examples which come with MPW. Reading the code is difficult >and the thought of creating new code is awe inspiring. Within the class >constructors and member functions very little appears to be object orientated. >In the following member function why do we have: ? > >EnableItem(menu, iNew); instead of menu->EnableItem(iNew) >DisableItem(menu, iClose); instead of menu->DisableItem(iClose); > >menu = GetMHandle(mFile); instead of menu = mFile->GetMHandle(); Some parts of the MacApp framework are not so object oriented, there are many reasons for this, like historical ones, or performance reasons. And ultimately the framework must call the Toolbox, which is not layered in an object oriented way. >When using a set of existing classes, easily accessible documentation is needed. >By that I mean, a list of all the classes together with their member functions >plus a clear description of what each one does. The document called "MacApp 2.0 Class and Method Reference" contains this information. In general I would recommend to order all the APDA MacApp documentation. And speaking from personal experience learning new frameworks, using a browser (MacBrowse) is the best tool for this. Hope this helped a little bit. Regards, Kent Sandvik -- Kent Sandvik, Apple Computer Inc, Developer Technical Support NET:ksand@apple.com, AppleLink: KSAND DISCLAIMER: Private mumbo-jumbo Zippy says: "With C++ we now do have the possibilities to inherit dangling pointer problems"
lsr@Apple.com (Larry Rosenstein) (12/12/90)
In article <47268@apple.Apple.COM>, ksand@Apple.COM (Kent Sandvik) writes: > > In article <1082@exua.exeter.ac.uk> kt@msor.msor (Keith Tizzard) writes: > >In the following member function why do we have: ? > > > >EnableItem(menu, iNew); instead of menu->EnableItem(iNew) > >DisableItem(menu, iClose); instead of menu->DisableItem(iClose); > > > >menu = GetMHandle(mFile); instead of menu = mFile->GetMHandle(); > > Some parts of the MacApp framework are not so object oriented, there Note that the examples that Keith was using were from the MPW C++ examples, and not MacApp. MacApp doesn't provide menu/menubar objects either, but it does take care of more of the details (e.g., you normally don't have to know about GetMHandle). You specify the menus in your resource file, and MacApp takes care of reading them in properly. Larry Rosenstein
Bruce.Hoult@bbs.actrix.gen.nz (12/12/90)
Keith Tizzard writes: >I am trying to use C++ under MPW and would welcome some advice and help. >The C++ language creates no problem since I have used it in other environments. >The problem comes when I try to find out about the MacApp classes and their >methods. > >Where do I look for a clear description? >Do I need to acquire and read all the volumes of Inside Macintosh? >Is there a class browser to enable me to find out, quickly and easily >what classes are available to inherit and what member functions they contain? I you have a version of MacApp that works with C++ then you also have the MacApp documentation and the program "Mouser" -- a browser that works with both C++ and Object Pascal code. You should also get Inside Mac available for reference. >The following code is taken from ShapesApp.cp, one of the files in the >distributed C++ examples which come with MPW. Reading the code is difficult >and the thought of creating new code is awe inspiring. Within the class >constructors and member functions very little appears to be object orientated. ShapesApp doesn't use MacApp. It is directly using the facilities in the Mac ROMs and O/S. These facilities aren't object oriented. >In the constructor TShapesApp, shown below, are SetMenuBar(), DisposHandle(), >DrawMenuBar() ... external functions (i.e. C) or are they inherited member >functions? Why does it not say: They are all functions built into the ROMs of every Mac since the 128K machine in 1984. You'll find that they are implemented as inline code that compiles to 68000 "TRAP" instructions. >In the following member function why do we have: ? > >EnableItem(menu, iNew); instead of menu->EnableItem(iNew) >DisableItem(menu, iClose); instead of menu->DisableItem(iClose); Once again, these are calls to non-object oriented stuff in the Mac ROMs. >When using a set of existing classes, easily accessible documentation is >needed. By that I mean, a list of all the classes together with their >member functions plus a clear description of what each one does. The ShapesApp example doesn't use MacApp. It doesn't use a set of existing classes. Perhaps you should look at the C++ MacApp examples (Nothing, DemoText and DemoDialogs) in the :MPW:MacApp:Examples:CPlusExamples: folder... -- Bruce -- Bruce.Hoult@bbs.actrix.gen.nz Twisted pair: +64 4 772 116 BIX: brucehoult Last Resort: PO Box 4145 Wellington, NZ
Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (12/13/90)
Keith Tizzard writes in a message to All KT> In the following member function why do we have: ? KT> EnableItem(menu, iNew); instead of menu->EnableItem(iNew) KT> DisableItem(menu, iClose); instead of menu->DisableItem(iClose); KT> menu = GetMHandle(mFile); instead of menu = mFile->GetMHandle() Are you ready to blush? Those are all ToolBox calls, part of the ROM routines built into the Mac, not member functions of an object. (the Mac kinda jumps up and bites us all some time...) ( "I don't remeber how to initialize a Mac program anymore: I just copy 'n' paste from some of my old code into my new program" --Bill Atkinson) Lawson -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English Internet: Lawson.English@p88.f15.n300.z1.fidonet.org