|
Change History Occasionally (usually coinciding with a product validation by the ClubMacApp staff) the most recent changes to the MacApp source code will be summarized here. Should you discover a change that you would like to have you simply need to perform a checkout using the MacCVS Pro session file provided in your Subscription Kit. August 8, 2002 Mach-O Framework Bundle SupportAdded support for calling Mach-O framework bundle libraries from CFM Carbon applications. CFrameworkBundle_AC provides access to a framework bundle. The constructor creates a reference to the bundle and loads it. The bundle may be specified as a CFBundleRef, a URL, or a framework name. The destructor unloads the bundle. The GetFunction method gets the function with the specified name. The GetFunctionOrThrow method is similar to GetFunction except it will throw an exception if the function can't be found. CFrameworkFunction_AC is a template for type-safe access to a framework bundle function. The template parameter is the type of the function. The constructor arguments are the executable bundle containing the function, and the function name. The constructor gets the function pointer from the bundle, or throws if the function can't be found. The * operator provides access to the function pointer. For example, CGContextFillRect is in a Mach-O bundle so it can't be linked to from a Carbon CFM application. Here's a glue function that allows a CFM application to call the bundle function transparently.
void CGContextFillRect(CGContextRef ctx, CGRect rect)
{
static CFrameworkFunction_AC<void (*)(CGContextRef, CGRect)>
f(AppServices_AC(), CFSTR("CGContextFillRect"));
(*f)(ctx, rect);
}
The first time the glue function is called, 'f' will be constructed and it will look up CGContextFillRect in ApplicationServices.framework. After that, it's a simple matter of calling through the function pointer to the implementation in the bundle. AppServices_AC() returns a reference to a singleton framework bundle for ApplicationServices.framework. Core Graphics SupportCQuartz_AC is a new unit providing support for Core Graphics on Mac OS X. CGContext defines C++ interfaces for CGContextRef. If you have a CGContextRef, simply include CQuartz_AC.h and you can use C++ syntax, such as ctx->FillRect(r) instead of CGContextFillRect(ctx, r). CAutoCGContext is a smart pointer that owns a CGContextRef. CQuartz_AC also provides C++ interfaces for CGColorSpace, CAutoCGColorSpace, CGDataProvider, CAutoCGDataProvider, CGImage and CAutoCGImage. Not all of these interfaces are complete. If there is a function you need that does not have a C++ interface, you can still call it the old way. A few Core Graphics functions have glue code in CarbonFrameworkLib. CQuartz_AC provides glue for several more functions. It is far from complete, but it is a good start. If there is a function you need that doesn't already have glue provided, it is easy to create your own glue using the support in CFrameworkBundle_AC. CSaveGState_AC is a utility class that automatically saves and restores the graphics state for a CGContext. If you need to call CGContextSaveGState and CGContextRestoreGState, you should use this class because it makes restoring the state exception-safe. CBeginCGContext_AC is a utility class that helps work around an issue with Core Graphics and printing. It creates a temporary CGContext that allows Core Graphics calls to show up in the printing port. The temporary CGContext is created only if the port is not buffered. Buffered ports, such as Mac OS X window server windows, work just fine already and don't require a temporary context. CBeginCGContext_AC has an operator CGContextRef that provides access to the temporary context. Here is an example of how it is used: CBeginCGContext_AC context; err = DrawThemeTextBox(textCFString, kThemeCurrentPortFont, kThemeStateActive, autoWrap, &newBox, itsJust, context); This call to DrawThemeTextBox was originally passing in NULL for the context parameter. That worked fine for drawing to a window, but the text didn't show up when printing. Adding the CBeginCGContext_AC solves the problem because it provides a context that works for printing. When drawing to a buffered port such as a window, the CGContextRef is NULL, allowing DrawThemeTextBox to work the way it did before.
Launch Services SupportCLaunchServices_AC provides some simple support for Launch Services on Mac OS X. CLSLaunchFSRefSpec_AC is a LSLaunchFSRefSpec structure that automatically initializes its fields to safe values. It also provides a convenient constructor for if you just want to specify an application. CLSLaunchURLSpec_AC does the same thing for LSLaunchURLSpec. The Launch Services APIs are designed so that for every function on an FSRef, there's an equivalent one that works on a URL. CLaunchServices_AC provides overloaded functions that have short simple names and make it easier to remember and type the correct function. Because the FSRef and CFURLRef parameters are always pointers, not objects, any object-oriented API for Launch Services would necessarily involve compromises. It is not clear if an object-oriented API for Launch Services would be useful in ACS. Where it would make sense is in MacApp, which can have higher level abstractions. DemoMachO ExampleDemoMachO is a new MacApp example that demonstrates calling MachO functions from a CFM application. It draws using Core Graphics, and it uses Launch Services to find and open an application. Yet Another Reference Counted Pointer TemplateCRefCounted_AC is a smart pointer that works with reference counted objects. It is more general than CRefCountingPtr_AC and TemplateAutoRef_AC in that it doesn't require the counted object to be a MRefCountable_AC or a CFObject. Instead, the object's retention policy is defined in a retainer class. This doesn't mean that CRefCounted_AC is the best long term solution for MacApp and ACS. Loki:: SmartPtr, boost:: shared_ptr and boost:: scoped_ptr are better candidates and at least one of them may become a C++ standard. Session Printing SupportUCarbonPrinting has been rewritten to use the session printing APIs. In order to keep things simple, UCarbonPrinting does not attempt to support simultaneous multiple sessions. There is a global variable for the current session, and that is it. In the future it may possible to support multiple sessions in MacApp, if there is a need for printing to more than one destination at the same time. MacAppSwitches.h now defaults PM_USE_SESSION_APIS to 1, unless it has already been otherwise specified. MacApp now supports the NoDialog session printing calls on Mac OS X. Applications that need to receive Apple Events during printing should use the NoDialog calls. The print manager dialogs on Mac OS X eat Apple Events sent to the host application. The NoDialog calls suppress the print manager's status dialog that displays the current page being printed. CSessionPrinting_AC provides the necessary glue to the Mach-O library functions. TCarbonPrintJob has a SetNoDialog method so it can be told to use the NoDialog functions. The default is to use the old functions that display a status dialog. When the NoDialog flag is set, TCarbonPrintJob will display a phPrintStatusDialog instead of the usual phSpoolPrintDialog. The phPrintStatusDialog resource is in Printing.r. It has an item for the current page number, and TCarbonPrintJob updates it during printing so the user still gets some feedback even though the print manager isn't showing any status. The print idle function was never being called by the print manager, which is good because it had some crashing bugs. Now it is okay, and it is called by TCarbonPrintJob to update the phPrintStatusDialog. The UnFlattenSettingsAndFormat function has been changed to print a debug warning instead of throwing an exception if it has an error releasing the settings or format data. The function is correct to release the data, but if there is an error, it is better to leak the data than to cause printing to completely fail. Anti-aliased TextUsed CBeginCGContext_AC in TextBox_AC and MADrawString so that the calls to DrawThemeTextBox will show up when printing.
All the CW Pro 7 projects for the MacApp examples have been updated to include CarbonFrameworkLib. UDemoDialogs.cpp was updated to use MADrawString so it can have anti-aliased text on Mac OS X. The workaround for getting DrawThemeTextBox to draw line breaks in non-wrapped text happened to work only for left justified text. Right justified and centered text seemed to disappear because it was being drawn outside the original box. TextBox_AC was fixed to extend the new box in the right direction depending on the justification. It turns out that using CBeginCGContext_AC doesn't work for creating pictures. This is probably because QDBeginCGContext and OpenPicture both patch the QD bottlenecks. Anyway, TextBox_AC and MADrawString have been fixed to check if a picture is being defined, and in that case to use QuickDraw instead of DrawThemeTextBox to draw the text. Graphics Device IteratorsCGDIterator_AC has been changed to fix a problem where some views would not show up in a Mac OS X buffered window if they had been drawn while their part of the window was off the edge of the display. MacApp has several places where it uses a CGDIterator_AC device loop to draw with the appropriate color and depth for each intersecting GDevice. That's how we're supposed to draw in Mac OS 9 and earlier. It appears that approach is actually the opposite of what should be done on Mac OS X. With buffered windows the operating system takes care of blitting to each GDevice from the buffer. If a window is partially off the screen, the system expects that the application will always draw the entire contents. Clipping to the GDevice just means that contents will be missing when the window is moved back on screen. Removing CGDIterator_AC was not an option because it is still a good thing to have for drawing on Mac OS 9 and earlier. The fix was to add a flag to the iterator allowing it to be disabled. In addition, the constructor checks if the current port is buffered, offscreen, or is being used to define a picture. In that case, CGDIterator_AC disables itself. When the iterator is disabled it iterates once, points at the current GDevice, and doesn't clip.
Even with CGDIterator_AC, there still was a problem drawing icons when they were off the edge of the screen. This appears to be a problem inside the implementation of PlotIconSuite (Radar #2894442). A new function PlotIconSuiteHack has been added to UIcon to work around the problem. If the current port is buffered, it plots the icon to an offscreen GWorld, then copies the GWorld contents to the current port. The function is written to work for icons up to 128x128 pixels in size. For efficiency, the GWorld is allocated once and not disposed. TIcon uses PlotIconSuiteHack. Applications that call PlotIconSuite directly should consider using the workaround. MiscellaneousFixed CFile_AC::ExchangeFile that caused a MacOSX kernal panic after writing to a MS DOS floppy disk and FSpExchangeFiles is invoked Modified TDispatcher::DoCommandKeyEvent so that ::MenuEvent is invoked instead of MenuKey. References to Mercutio (RIP) have been removed. Fixed CCFURL_AC and CCFUUID_AC to have const methods so they work with the way CFURLRef and CFUUIDRef are defined. Fixed the TypeID_AC specialization in CCFSet_AC so it is consistent with the other Foundation suite units. Promoted CGraphicsWorld from the DemoWDEF example into the imaging suite, and CMatrix into the QuickTime suite. CPascalString_AC: Replaced all 'unsigned char x' parameters with 'int x' to solve a problem with passing in values larger than 256. Solves a corruption bug when appending to a full pascal string. TDialogBehavior: Support for allowing dialogs to set the event mask in PoseModally. TFileBasedDocument: Save As had a problem if you replaced a file with a different file type than the one you want to save. Now the type/creator info is replaced correctly. TMenuMgr: Fix a bug that caused menu titles to be enabled even though all menu items are disabled. TView: If the root view is not a window the clip was set to the empty rectangle. Now the clip is set to the largest rectangle we can have. Stop GetClipRegion from going into an infinite loop. TButton: In TButton::SetDefaultOutline(), change from deleting the first round rect adorner to deleting every one. This works around a bug in IcePick that adds multiple RRectAdorners on a button. In debug mode, extra adorners generate a ProgramBreak_AC() with the goal of being annoying enough to get fixed. TCheckbox, TPopup and TRadio: Added GetValue(), SetValue(), and DeleteControl() to maintain setting without a real control. TTECommand: Make sure fOldStyles exists before trying to use it. TTEView: The caret is not showing up when the text is right justified and the caret is rightmost. This can be fixed by reserving one pixel in the destination rect. Modified CalcMinFrame so the min vertical size is the scroller / superview size. DemoDialogs now has a test case for AsPict. The "As Picture" command makes a picture of the target window and puts it in a new window. TView:: AsPict was fixed to set the fore and back colors to black and white before drawing into the picture. This fixed a bug where AsPict was using whatever colors were left in gWorkPort. TEditText:: ValidationFailed has been changed to call RestartEdit before displaying the alert instead of after. This way, if the alert has side-effects such as activate events that can affect the window being edited, the value will be restored to what it should be, before anything can happen.
__CFString: Fixed infinite recursion bug in
__CFString::CreateWithBytes(CFAllocatorRef, const char*, CFIndex, CFStringEncoding, bool).
TDragDropSession: Work around a problem where DragSendDataProc would not always be called, so the drop location was not being updated, and the target from the previous drop was being reused. March 7, 2002 Theme Backgrounds These changes provide better support for drawing the correct background appearance on Mac OS X. To associate a theme background with a view in Ad Lib, select the view, choose "View Components" (command-B). If it doesn't already have a drawing environment, drag in a generic drawing environment from the Adorners palette. Double-click on the drawing environment for the view. This will bring up a dialog to edit the drawing environment parameters. Change the name to one of the registered drawing environments in UThemeEnvironment. For example, TThemeListViewEnvironment. If there is a container view, such as a list view, that has its own background, and also contains controls, the controls will not use the view's background. That is because controls get their background only from a containing control, or from the window. You can get the controls to use the background you want by putting a TUserPane around the container view and associating the background with the TUserPane. The TUserPane creates a user pane control, and the embedded controls will get their background from it. To create a TUserPane in Ad Lib, drag a TControl in from the Views palette and change the class name to TUserPane. The control embedding code in MacApp worked only if the controls were created in a window that was already open, as in the tab panels test in the Appearance Sample. Now it's fixed so it will work all the time. Gave TDrawingEnvironment a pointer back to its owning view. This makes it easier to tell whether it should use the active theme brush or the inactive one. Move CDrawingEnvironmentManager to its own unit, so it can be used outside of UView.cpp. Printing UCarbonPrinting: Fixed major memory leak when unflattening print settings. Miscellaneous Fixed a crash when cutting or copying text in a TWEView. Changed TDispatcher so in Carbon it won't redirect activate events from a floating window to the front non-floating window. This fixes a problem with modal dialogs coming up deactivated when a floater is present. Cleaned up the implementation of MAShowWindow. Fixed a crash where TWindowMenuBehavior was trying to set up the menu with a reference to a closed window. This happened in DemoDialogs with a floater open and closing the last non-floating window. Now windows send a mClosed event when they close, so the application and its behaviors can easily tell when a window is going away. Fixed various crash bugs when event tracing is enabled in the debug flags window. TDragDropSession : Changed ClearDrag to always call DisposeDrag unless running on MacOS X 1.0.0 through 10.0.4. The previous behavior was to call DisposeDrag except if built with Project Builder. CDynamicArray_AC : Added assignment operator. UDispatcher: Allow the user to double-click in an inactive window. When using the carbon event model return eventNotHandledErr if we get an unrecognized menu command so that the default handler can get a chance to process it. This allows us to use PopupMenuSelect (in most cases) without having to add an extra carbon event handler to the menu. January 30, 2002 Menu View On Mac OS X, menu definition functions are not allowed to draw during tracking (as in kMenuFindItemMsg or the old mChooseMsg). Also, the menu is expected to draw in the current port. Since the menu has to draw in the system's port, it has to be extremely careful to respect the port's origin and clip. TMenuView has been fixed so it now works correctly on Mac OS 9 PPC (Classic) and Carbon, and on Mac OS X. The following changes were made:
For more information on custom menu definitions, see the comments in a recent version of <Menus.h>, and look up MenuDefProcPtr in the Carbon developer documentation. Anti-aliased Text Changed MADrawString and TextBox_AC to use DrawThemeTextBox so that text on Mac OS X is anti-aliased. For those who don't want smooth text, the old implementation are available as OldMADrawString and OldTextBox_AC. Add an overloaded version of MADrawString that works just like DrawString. If you have code that calls DrawString and you want it to draw anti-aliased text on Mac OS X, switch to the MA version. Printing UCarbonPrinting: Don't throw if no printer is chosen. UPrintMgr: Provide a reasonable default for fViewPerPage. This prevents an infinite loop in CalcPageStrips if no printer is chosen. UStdPrintHandler: If printing cannot be initialized, gDefaultPrintInfo may be null. In Update, fPrintInfo may be null. Miscellaneous CDrawingEnvironment_AC: Added a new class CTempQDProcs_AC. It makes the code for installing a QuickDraw bottleneck simpler and exception safe. CStream_AC: Fix WriteString(const char*) and (const unsigned char*) to write all the characters in the string. CString_AC: CString_AC(ResNumber) needs to process the resource as a handle to a pascal string, not just a handle of characters. Also, CString_AC(ResNumber, short) can use the equivalent assign method. UDispatcher: Don't enable cCantUndo. UApplication: Fix memory leak in ChooseDocumentWithNavSvcs. Also, CanOpenDocument was not deleting defaultLocation when done. Set stationery attribute in GetFilesListFromNavReply. Limitations & Issues Features Not Implemented
Features Not to be Supported
Known Issues In addition to the Limitations listed above you should be aware of these issues:
|
|||||||
|
|
|