home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-09 | 7.0 KB | 166 lines | [TEXT/R*ch] |
- { /*
-
- Extensions Strip Programming Notes
- by Ammon Skidmore 10/95, 11/95, 12/95
-
- Despite what the title may imply, this document does not explain the new API.
- The purpose of the file at this point in time is to give out tips and explain
- special issues to be concerned with when programming modules for use with
- Extensions Strip.
-
- To learn more about the API, please read the header file and source code since
- they are both heavily commented. The whole of the Control Strip API is
- documented in the New Technical Notes OS 6 – Control Strip Modules (this
- information originally appeared in the PowerBook 500 series Developer Note.)
-
- NB: at the time of this writing, free registrations of Extensions Strip are
- being offered to programmers who support ES' API in their modules. Also, if
- someone wants to convert the ESDemo source code to MW Pascal, I would be very
- grateful in the same manner. Yes, I care about Pascal even though ES was
- totally written in C and 68K assembly. I also want to cut back on new (and
- seasoned) programmers asking: "What the %[^\n]%* is this?" :-)
-
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- • How to make module programming lots of fun!
-
- Create an alias to your module's project folder and add the alias to the root
- module folder. Whenever you build your module, click on the strip's title bar
- with the command & option keys down to get the new compile to load. You will
- never have to leave your development application to try the latest build!
-
-
- • Gestalt info:
-
- Extensions Strip implements its own features selector, as well as the Control
- Strip & Desktop Strip selectors. Here are the selectors and what they return:
-
- 'CsEs'(gestaltExtensionsStripAttr) - returns bits:
- 0 (gestaltExtensionsStripExists) when Extensions Strip is launched.
- 1 (gestaltSupportsFontTraps) returned by ES 1.1 and later because the
- CS gestalt selector in ES 1.0 returned that fonts were
- supported, yet the font traps were not.
- 2 (gestaltHasSBResolveAliasFile) returned by ES 1.2 and later. Means
- that ES contains the new alias resolving trap
- SBResolveAliasFileMountOption. This bit also signifies
- that ES can only be run as a regular application.
-
- 'csvr'(gestaltControlStripVersion) - current version of Extensions Strip in
- the standard System format. Ex, version 1.2.3 would be returned as $0123.
-
- 'sdev'(gestaltControlStripAttr) - currently returned bits:
- 0 (gestaltControlStripExists)
- 1 (gestaltControlStripVersionFixed)
- 2 (gestaltControlStripUserFont)
-
- 'CsWT'(gestaltDesktopStripAttr) - currently returns bits 0 and 1. I don't
- know what these bits signify, but they are returned anyway since that's
- what Desktop Strip 1.2.1 returns.
-
-
- • PowerPC notes:
-
- ExtensionsStripLib, the shared library that the control strip traps are linked
- to, is distributed for programmers in its regular shared library form. This
- allows you to easily drag and drop it onto a CodeWarrior project, among other
- things. For the end user however, they never see ExtensionsStripLib because
- it is embedded into Extensions Strip Control version 1.2 and later.
-
- Remember to use 'weak' links to libraries that are not guaranteed to be present.
- Not doing so will crash the computer if the lib cannot be found.
- ExtensionsStripLib and the InterfaceLib are always guaranteed to be present so
- do not require 'weak' links.
-
- Calling SBSafeToAccessStartupDisk() from PPC code will always return true
- regardless of the state of the hard disk. This is because I do not have Apple's
- shared library to link the required calls to. Has Apple has even made a library
- for this yet? If anyone out there has a copy of this library, or know if one
- exists, could you please e-mail me?
-
-
- • Intelligent Alias Resolving:
-
- AppleShare login dialog boxes create alias resolving difficulties for control
- strip modules. To combat this problem, ES 1.2 and later contain the trap
- SBResolveAliasFileMountOption.
-
- SBResolveAliasFileMountOption works like the Apple trap call ResolveAliasFile,
- except that you can tell it not to mount remote volumes. If you do tell it
- to mount volumes, however, and the current process is not the front process,
- then the front process will be temporarily switched to the front one so that
- AppleShare login dialogs (if any) will be in front of all other windows. This
- is very nice if you call the trap from sdevInAppContext.
-
- Now that I've said the above, do NOT flag to mount remote volumes from drag
- handlers if the current process is not the frontmost one. This is because
- AppleShare login boxes will appear inside the current process, which the user
- will not be able to switch to because you can't switch processes while TrackDrag
- is being called. My Process Manager module does the following from its
- drag receive handler to prevent this nasty situation:
-
- if ((**globH).hasESResolveAliasTrap)
- // if we have it, call a friendly alias resolver
- err = SBResolveAliasFileMountOption(&hfsData.fileSpec, TRUE, &targetIsFolder,
- &wasAliased, IsCurProcessInFront());
- else
- // if not, live on the wild side
- err = ResolveAliasFile(&hfsData.fileSpec, TRUE, &targetIsFolder, &wasAliased);
-
- /******************************************************************************
- IsCurProcessInFront return true if the current process is in front
- ******************************************************************************/
- static Boolean IsCurProcessInFront(void)
- {
- Boolean result = FALSE;
- ProcessSerialNumber curPSN, frontPSN;
-
- if ( (GetCurrentProcess(&curPSN) == noErr) &&
- (GetFrontProcess(&frontPSN) == noErr) )
- {
- SameProcess(&curPSN, &frontPSN, &result);
- }
-
- return(result);
- }
-
-
- • ModalDialog() notes:
-
- With Extensions Strip, your dialogs may call ModalDialog() instead of
- SBModalDialogInContext(). The only real benefit to this is that the user gains
- access to the edit menu. Note though, that as of this writing, Desktop Strip
- crashes when ModalDialog() is called so if you are concerned with compatibility,
- stick with SBModalDialogInContext().
-
-
- • Crashes:
-
- Tip: If a module crashes your computer, but you are able to resume using your
- computer (usually through the use of MacsBug's 'es' command), then clicking on
- any strip will result in a beep. You could resume the use of Extensions Strip
- by turning it off and back on, but if you are sure that the "crash" was not
- serious (ex. you felt like force-quitting), then you can resume the use of ES by
- dragging something onto any strip.
-
- Note that I have left in the debugging names to Extensions Strip's functions.
- This helps me to locate possible bugs that you may encounter (nobody's perfect!)
- So, if ES crashes while you are using a low level debugger, and you don't think
- that it's your module's fault, then kindly e-mail me a dump to disk of at the
- following things:
- ---------------
- log esCrash1
-
- stat;sc6;sc7;ip;hc;td;ir
-
- log
- ---------------
- BTW, if you are wondering what some of these commands do, just snap into
- MacsBug and type 'help' followed by the command. Happy hacking!
-
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- "The Windows API has done more to retard skill development
- than anything since COBOL maintenance." --Larry O'Brien
-
- */ }
-