static void HandleStartEvent(NavCBRecPtr callBackParms, CustomData *data)
{
   data->context = callBackParms->context;

   CreateUserPaneControl(callBackParms->window, &data->bounds, kControlSupportsEmbedding, &data->userpane);

   InstallControlEventHandler(data->userpane,
                              GetHandlePaneEventsUPP(),
                              GetEventTypeCount(namedAttrsList),
                              namedAttrsList,
                              data,
                              NULL);

   EmbedControl(data->choice, data->userpane);
   EmbedControl(data->button, data->userpane);
   
   NavCustomControl(callBackParms->context, kNavCtlAddControl, data->userpane);
   
   HandleAdjustRect(callBackParms, data);
   
   if (data && !(data->defaultLocation).IsEmpty())
   {
      // Set default location for the modern Navigation APIs
      // Apple Technical Q&A 1151
      FSSpec theFSSpec;
      wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec);
      AEDesc theLocation = {typeNull, NULL};
      if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
         ::NavCustomControl(callBackParms->context, kNavCtlSetLocation, (void *) &theLocation);
   }
}
Esempio n. 2
0
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Name:	MyPDEInitialize

	Input Parameters:
		context				:	The plugins context
		parentUserPane		:	the user pane to your your controls into
		ref					:	the reference to this PDE
		printSession		:	this holds the PM tickets

	Output Parameters:
		flags				:	feature flags that are supported by this PDE
		err					:	returns the error status

	Description:
		Initializes client interface. Creates controls and sets initial values



	Change History (most recent first):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
static
OSStatus MyPDEInitialize(	PMPDEContext	context,
                            PMPDEFlags*		flags,
                            PMPDERef		ref,
                            ControlRef		parentUserPane,
                            PMPrintSession	printSession)
{
    OSStatus err = noErr;
    PrintDialogPDEOnlyContextPtr myContext = NULL;	// Pointer to our context data.

    DebugMessage("PrintDialogPDE MyPDEInitialize called\n");

    myContext = (PrintDialogPDEOnlyContextPtr) context;

    if ((myContext != NULL) && (printSession != NULL))
    {
        WindowRef theWindow = NULL;
        short savedResFile = CurResFile();
        UseResFile(myContext->theResFile);
        theWindow = GetControlOwner(parentUserPane);	// get the windowref from the user pane

        // the user panes rect is the rect we should use to draw our
        // controls into. The printing system calculates the user pane
        // size based on the maxh and maxv sizes returned from the
        // Prologue function

        // Note that we are using the AutoToggleProc variant of the Radio Button control
        // This allows a hit on this control to be automatically processed by the ControlMgr

        // get controls
        myContext->thePrintSelTextOnlyControlRef = GetNewControl(kPrintDialogPDEControlID, theWindow);

        // embed controls
        EmbedControl(myContext->thePrintSelTextOnlyControlRef, parentUserPane);

        // set controls as visible
        SetControlVisibility(myContext->thePrintSelTextOnlyControlRef, true, false);

        // Set default value
        SetControlValue(myContext->thePrintSelTextOnlyControlRef, 0);

        // Set flags
        *flags = kPMPDENoFlags;

        // Initialize this plugins controls based on the information in the
        // PageSetup or PrintSettings ticket.
        err = MyPDESync(context, printSession, kSyncDirectionSetUserInterface);
        if (err == kPMKeyNotFound)
            err = noErr;

        UseResFile(savedResFile);
    }
    else
        err = kPMInvalidPDEContext;

    DebugPrintErr(err, "PrintDialogPDE Error from MyPDEInitialize returned %d\n");

    return (err);
}
void	AUCarbonViewBase::AddCarbonControl(AUCarbonViewControl::ControlType type, const CAAUParameter &param, ControlRef control)
{
	verify_noerr(EmbedControl(control));
    
	AUCarbonViewControl *auvc = new AUCarbonViewControl(this, mParameterListener, type, param, control);
	auvc->Bind();
	AddControl(auvc);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AUDiskStreamingCheckbox::AUDiskStreamingCheckbox
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, 
				Point 					inLocation,  
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top;
	r.left = inLocation.h;		r.right = r.left;
	
    // localize as necessary
    if (!sLocalized) {
		sLocalized = true;
        CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
        if (mainBundle) {
            kStringStreamFromDisk =	CFCopyLocalizedStringFromTableInBundle(
                                        kAUViewLocalizedStringKey_StreamFromDisk, kLocalizedStringTable_AUView,
                                        mainBundle, CFSTR("'Stream From Disk' checkbox title string"));
        }
    }
    
	verify_noerr(CreateCheckBoxControl(	GetCarbonWindow(), 
										&r, 
										kStringStreamFromDisk, 
										0, 
										true, 
										&mControl));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	ControlSize smallSize = kControlSizeSmall;
	verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize));

	AUCarbonViewControl::SizeControlToFit(mControl, NULL, &mHeight);
	if (mHeight < 0) mHeight = 0;
	
	EmbedControl(mControl);
	
	UInt32 value = 0;
	UInt32 size = sizeof(value);
	verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size));
	
	HandlePropertyChange (value);
	
	RegisterEvents();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AUDiskStreamingCheckbox::AUDiskStreamingCheckbox
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDiskStreamingCheckbox::AUDiskStreamingCheckbox (AUCarbonViewBase *inBase, 
				Point 					inLocation, 
				int 					inRightEdge, 
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top + 16;
	r.left = inLocation.h;		r.right = r.left + inRightEdge;
	
	verify_noerr(CreateCheckBoxControl(mView->GetCarbonWindow(), 
										&r, 
										CFSTR("Disk Streaming"), 
										0, 
										true, 
										&mControl));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	ControlSize smallSize = kControlSizeSmall;
	verify_noerr (SetControlData (mControl, kControlEntireControl, kControlSizeTag, sizeof (ControlSize), &smallSize));

	SInt16 baseLineOffset;
	verify_noerr (GetBestControlRect (mControl, &r, &baseLineOffset));
	r.bottom += baseLineOffset;
	SInt16 difference = (r.left + inRightEdge) - r.right;
	r.right += difference;
	r.left += difference;
	SetControlBounds (mControl, &r);
	EmbedControl(mControl);
	verify_noerr (AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, DiskStreamingListener, this));
	UInt32 value;
	UInt32 size = sizeof(value);
	verify_noerr (AudioUnitGetProperty (mView->GetEditAudioUnit(), kMusicDeviceProperty_StreamFromDisk, kAudioUnitScope_Global, 0, &value, &size));
	
	HandlePropertyChange (value);
	
	RegisterEvents();

}
Esempio n. 6
0
IGraphicsCarbon::IGraphicsCarbon(IGraphicsMac* pGraphicsMac,
                                 WindowRef pWindow,
                                 ControlRef pParentControl,
                                 short leftOffset,
                                 short topOffset)
  : mGraphicsMac(pGraphicsMac)
  , mWindow(pWindow)
  , mView(0)
  , mTimer(0)
  , mControlHandler(0)
  , mWindowHandler(0)
  , mCGC(0)
  , mTextEntryView(0)
  , mTextEntryHandler(0)
  , mEdControl(0)
  , mEdParam(0)
  , mPrevX(0)
  , mPrevY(0)
//, mRgn(NewRgn())
  , mLeftOffset(leftOffset)
  , mTopOffset(topOffset)
{
  TRACE;

  Rect r;   // Client.
  r.left = r.top = 0;
  r.right = pGraphicsMac->Width();
  r.bottom = pGraphicsMac->Height();

  WindowAttributes winAttrs = 0;
  GetWindowAttributes(pWindow, &winAttrs);
  mIsComposited = (winAttrs & kWindowCompositingAttribute);

  UInt32 features =  kControlSupportsFocus | kControlHandlesTracking | kControlSupportsEmbedding;

  if (mIsComposited)
  {
    features |= kHIViewIsOpaque | kHIViewFeatureDoesNotUseSpecialParts;
  }

  CreateUserPaneControl(pWindow, &r, features, &mView);

  const EventTypeSpec controlEvents[] =
  {
    { kEventClassControl, kEventControlDraw },
  };

  InstallControlEventHandler(mView, MainEventHandler, GetEventTypeCount(controlEvents), controlEvents, this, &mControlHandler);

  const EventTypeSpec windowEvents[] =
  {
    { kEventClassMouse, kEventMouseDown },
    { kEventClassMouse, kEventMouseUp },
    { kEventClassMouse, kEventMouseMoved },
    { kEventClassMouse, kEventMouseDragged },
    { kEventClassMouse, kEventMouseWheelMoved },

    { kEventClassKeyboard, kEventRawKeyDown },

    { kEventClassWindow, kEventWindowDeactivated }
  };

  InstallWindowEventHandler(mWindow, MainEventHandler, GetEventTypeCount(windowEvents), windowEvents, this, &mWindowHandler);

  double t = kEventDurationSecond / (double) pGraphicsMac->FPS();

  OSStatus s = InstallEventLoopTimer(GetMainEventLoop(), 0., t, TimerHandler, this, &mTimer);

  if (mIsComposited)
  {
    if (!pParentControl)
    {
      HIViewRef hvRoot = HIViewGetRoot(pWindow);
      s = HIViewFindByID(hvRoot, kHIViewWindowContentID, &pParentControl);
    }

    s = HIViewAddSubview(pParentControl, mView);
  }
  else
  {
    if (!pParentControl)
    {
      if (GetRootControl(pWindow, &pParentControl) != noErr)
      {
        CreateRootControl(pWindow, &pParentControl);
      }
    }
    s = EmbedControl(mView, pParentControl);
  }

  if (s == noErr)
  {
    SizeControl(mView, r.right, r.bottom);  // offset?
  }
}
Esempio n. 7
0
OSStatus ElCAJASView::CreateUI(Float32 xoffset, Float32 yoffset) {

    int xoff = (int)xoffset;
    int yoff = (int)yoffset;
    
        	
#define kLabelWidth 80
#define kLabelHeight 18
#define kEditTextWidth 40
#define kMinMaxWidth 45
	ControlRef newControl;
	ControlFontStyleRec fontStyle;
	fontStyle.flags = kControlUseFontMask | kControlUseJustMask;
	fontStyle.font = kControlFontSmallSystemFont;
	fontStyle.just = teFlushRight;
	
	Rect r;
	Point labelSize, textSize;
	labelSize.v = textSize.v = kLabelHeight;
	labelSize.h = kMinMaxWidth;
	textSize.h = kEditTextWidth;
	
	
        
	
	{
		AUVParameter auvp(mEditAudioUnit, kDryLevel, kAudioUnitScope_Global, 0);
		
		r.top = 10 + yoff;
        r.bottom = r.top + kLabelHeight;
		r.left = 10;
        r.right = r.left + kLabelWidth;
		verify_noerr(CreateStaticTextControl(mCarbonWindow, &r, auvp.GetName(), &fontStyle, &newControl));
                
	}

         {
		
		r.top = 50 + yoff;
        r.bottom = r.top + 80;
		r.left = xoff;
        r.right = r.left + 350;
		verify_noerr(CreateStaticTextControl(mCarbonWindow, &r, CFSTR("Johnny Petrantoni JACK-insert, (c) 2003 - 2004.    ") , &fontStyle, &newControl));
		verify_noerr(EmbedControl(newControl));
		r.top = 75 + yoff;
        r.bottom = r.top + 80;
		r.left = xoff;
        r.right = r.left + 350;
		verify_noerr(CreateStaticTextControl(mCarbonWindow, &r, CFSTR("[email protected]    ") , &fontStyle, &newControl));
		verify_noerr(EmbedControl(newControl));
		r.top = 100 + yoff;
        r.bottom = r.top + 80;
		r.left = xoff;
        r.right = r.left + 350;
		verify_noerr(CreateStaticTextControl(mCarbonWindow, &r, CFSTR("http://www.jackosx.com/    ") , &fontStyle, &newControl));
		verify_noerr(EmbedControl(newControl));

		
	}
        
            
        
	
	
	SizeControl(mCarbonPane, mBottomRight.h + 15, mBottomRight.v - 30);
	return noErr;

}
Esempio n. 8
0
AUVPresets::AUVPresets (AUCarbonViewBase* 		inParentView, 
						CFArrayRef& 			inPresets,
						Point 					inLocation, 
						int 					nameWidth, 
						int 					controlWidth, 
						ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inParentView),
	  mPresets (inPresets),
	  mView (inParentView)
{
#if !__LP64__
	Rect r;
	
	// ok we now have an array of factory presets
	// get their strings and display them

	r.top = inLocation.v;		r.bottom = r.top;
	r.left = inLocation.h;		r.right = r.left;
	
    // localize as necessary
    if (!sAUVPresetLocalized) {
        CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
        if (mainBundle) {
            kStringFactoryPreset =	CFCopyLocalizedStringFromTableInBundle(
                                        kAUViewLocalizedStringKey_FactoryPreset, kLocalizedStringTable_AUView,
                                        mainBundle, CFSTR("FactoryPreset title string"));
            sAUVPresetLocalized = true;
        }
    }
    
    // create localized title string
    CFMutableStringRef factoryPresetsTitle = CFStringCreateMutable(NULL, 0);
    CFStringAppend(factoryPresetsTitle, kStringFactoryPreset);
    CFStringAppend(factoryPresetsTitle, kAUViewUnlocalizedString_TitleSeparator);
    
	ControlRef theControl;
    verify_noerr(CreateStaticTextControl(mView->GetCarbonWindow(), &r, factoryPresetsTitle, &inFontStyle, &theControl));
	SInt16 width = 0;
	AUCarbonViewControl::SizeControlToFit(theControl, &width, &mHeight);
    CFRelease(factoryPresetsTitle);
	EmbedControl(theControl);
	
	r.top -= 2;
	r.left += width + 10;
	r.right = r.left;
	r.bottom = r.top;
	
	verify_noerr(CreatePopupButtonControl (	mView->GetCarbonWindow(), &r, NULL, 
											-12345,	// DON'T GET MENU FROM RESOURCE mMenuID,!!!
											FALSE,	// variableWidth, 
											0,		// titleWidth, 
											0,		// titleJustification, 
											0,		// titleStyle, 
											&mControl));
	
	MenuRef menuRef;
	verify_noerr(CreateNewMenu(1, 0, &menuRef));
	
	int numPresets = CFArrayGetCount(mPresets);
	
	for (int i = 0; i < numPresets; ++i)
	{
		AUPreset* preset = (AUPreset*) CFArrayGetValueAtIndex (mPresets, i);
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, preset->presetName, 0, 0, 0));
	}
	
	verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef));
	verify_noerr (SetControlFontStyle (mControl, &inFontStyle));
	
	SetControl32BitMaximum (mControl, numPresets);
	
	// size popup
	SInt16 height = 0;
	
	AUCarbonViewControl::SizeControlToFit(mControl, &width, &height);
	
	if (height > mHeight) mHeight = height;
	if (mHeight < 0) mHeight = 0;
	
	// find which menu item is the Default preset
	UInt32 propertySize = sizeof(AUPreset);
	AUPreset defaultPreset;
	OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), 
									kAudioUnitProperty_PresentPreset,
									kAudioUnitScope_Global, 
									0, 
									&defaultPreset, 
									&propertySize);
	
	mPropertyID = kAudioUnitProperty_PresentPreset;
#endif	
#ifndef __LP64__
	if (result != noErr) {	// if the PresentPreset property is not implemented, fall back to the CurrentPreset property
		OSStatus result = AudioUnitGetProperty (mView->GetEditAudioUnit(), 
									kAudioUnitProperty_CurrentPreset,
									kAudioUnitScope_Global, 
									0, 
									&defaultPreset, 
									&propertySize);
		mPropertyID = kAudioUnitProperty_CurrentPreset;
		if (result == noErr)
			CFRetain (defaultPreset.presetName);
	} 
#endif
#if !__LP64__		
	EmbedControl (mControl);
	
	HandlePropertyChange(defaultPreset);
	
	RegisterEvents();
#endif
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//	AURenderQualityPopup::AURenderQualityPopup
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AURenderQualityPopup::AURenderQualityPopup (AUCarbonViewBase *inBase, 
				Point 					inLocation, 
				int 					inRightEdge, 
				ControlFontStyleRec & 	inFontStyle)
	: AUPropertyControl (inBase)
{
	Rect r;
	r.top = inLocation.v;		r.bottom = r.top + 17;
	r.left = inLocation.h;		r.right = r.left + inRightEdge;
	
	ControlFontStyleRec fontStyle = inFontStyle;
	inFontStyle.just = teFlushRight;

	ControlRef			ref;
		
	CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.audio.units.Components"));
	if (mainBundle != NULL) {
		CFMutableStringRef renderTitle = CFStringCreateMutable(NULL, 0);
		CFStringAppend(renderTitle, CFCopyLocalizedStringFromTableInBundle(
			CFSTR("Render Quality"), CFSTR("CustomUI"), mainBundle,
			CFSTR("The Render Quality Popup menu title")));
		CFStringAppend(renderTitle, CFSTR(":"));
	
		OSErr theErr =  CreateStaticTextControl (GetCarbonWindow(), &r, renderTitle, &inFontStyle, &ref);
		if (theErr == noErr)
			EmbedControl(ref);
		
		r.left = r.right + 8;
		r.right = r.left + 100;

		short bundleRef = CFBundleOpenBundleResourceMap (mainBundle);
		
		theErr = CreatePopupButtonControl (mView->GetCarbonWindow(), &r, NULL,
			/*kQualityMenuID*/ -12345, false, -1, 0, 0, &mControl);	
			
		MenuRef menuRef;
		verify_noerr(CreateNewMenu(kQualityMenuID, 0, &menuRef));
		
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Maximum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0));
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("High"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0));
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Medium"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0));
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Low"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0));
		verify_noerr(AppendMenuItemTextWithCFString (menuRef, CFCopyLocalizedStringFromTableInBundle(CFSTR("Minimum"), CFSTR("CustomUI"), mainBundle, CFSTR("")), 0, kChangeRenderQualityCmd, 0));
																
		verify_noerr(SetControlData(mControl, 0, kControlPopupButtonMenuRefTag, sizeof(menuRef), &menuRef));
					
		verify_noerr(SetControlFontStyle (mControl, &inFontStyle));
			
		SetControl32BitMaximum(mControl, 5);
		UInt32 renderQuality;
		UInt32 size = sizeof(UInt32);
		AudioUnitGetProperty (mView->GetEditAudioUnit(), 
							kAudioUnitProperty_RenderQuality,
							kAudioUnitScope_Global, 
							0, 
							&renderQuality, 
							&size);
							
		HandlePropertyChange(renderQuality);

		EmbedControl(mControl);
		theErr = AudioUnitAddPropertyListener(mView->GetEditAudioUnit(), kAudioUnitProperty_RenderQuality, RenderQualityListener, this);
		CFBundleCloseBundleResourceMap (mainBundle, bundleRef);
		CFRelease(renderTitle);
	}
	RegisterEvents();
}
Esempio n. 10
0
// --------------------------------------------------------------------------------------
void OpenPrefsWindow(void)
{
    OSStatus error;
    SInt16 windowResourceID, visibleUserPaneResourceID, invisibleUserPaneResourceID, pixelDepth;
    WindowRef window;
    ControlRef containerControl, embeddedControl;
    short iconListBottom;
    Rect iconListRect;
    Boolean isColorDevice;
    ListHandle iconList;
    EventTypeSpec windowEvents[] = {
        {kEventClassWindow, kEventWindowActivated},
        {kEventClassWindow, kEventWindowDeactivated},
        {kEventClassWindow, kEventWindowHandleContentClick},
        {kEventClassWindow, kEventWindowGetMinimumSize},
        {kEventClassWindow, kEventWindowResizeCompleted},
        {kEventClassWindow, kEventWindowClose},
        {kEventClassWindow, kEventWindowDrawContent},
        {kEventClassWindow, kEventWindowContextualMenuSelect},
        {kEventClassControl, kEventControlClick},
        {kEventClassMouse, kEventMouseWheelMoved},
        {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent}
    };

    if (!RunningInMacOSX())
    {
        windowResourceID = rPrefsWindowPlatinum;
        visibleUserPaneResourceID = cPlatinumWindowUserPaneVisible;
        invisibleUserPaneResourceID = cPlatinumWindowUserPaneInvisible;

        gPrefsWindowHeight = kPrefsWindowPlatinumHeight;
        gPrefsWindowWidth = kPrefsWindowPlatinumWidth;
        gMinimumSpacing = kPlatinumMinimumSpacing;
        gWindowEdgeSpacing = kPlatinumWindowEdgeSpacing;
    }
    else
    {
        windowResourceID = rPrefsWindowAqua;
        visibleUserPaneResourceID = cAquaWindowUserPaneVisible;
        invisibleUserPaneResourceID = cAquaWindowUserPaneInvisible;

        gPrefsWindowHeight = kPrefsWindowAquaHeight;
        gPrefsWindowWidth = kPrefsWindowAquaWidth;
        gMinimumSpacing = kAquaMinimumSpacing;
        gWindowEdgeSpacing = kAquaWindowEdgeSpacing;
    }

    error = CreateWindowFromResource(windowResourceID, &window);
    if (error != noErr)
        ExitToShell();
    RepositionWindow(window, NULL, kWindowCascadeOnMainScreen);		// CreateWindowFromResource
    // doesn't call this for you like GetNewCWindow does
#if TARGET_API_MAC_CARBON	// we would just set the standard handler attribute in the Carbon 
    // Platinum 'wind' resource but that makes it not work under CarbonLib for some reason
    ChangeWindowAttributes(window, kWindowStandardHandlerAttribute, kWindowNoAttributes);
#endif

    SetPortWindowPort(window);

    SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundActive, true);

    CreateRootControl(window, &containerControl);

    /* Get each user pane and embed each preference panel's controls (for the
       demonstration there is only some static text identifying each panel number).
       We could just as easily have used AutoEmbedControl but why make the system
       figure out which control to use as the embedder when we already know? */
    containerControl = GetNewControl(visibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 1");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 2");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 3");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 4");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 5");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 6");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 7");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 8");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 7,
                   "Panel 9");

    containerControl = GetNewControl(invisibleUserPaneResourceID, window);
    embeddedControl = GetNewControl(cStaticText, window);
    EmbedControl(embeddedControl, containerControl);
    SetControlData(embeddedControl, kControlEntireControl, kControlStaticTextTextTag, 8,
                   "Panel 10");

    gPanelNumber = 1;

    GetWindowDeviceDepthAndColor(window, &pixelDepth, &isColorDevice);	// draw the list with a
    SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice);	// white background
    // get the bottom-most
    iconListBottom = gPrefsWindowHeight - gWindowEdgeSpacing;	// coordinate we can use
    iconListBottom -= (gPrefsWindowHeight - gWindowEdgeSpacing - gWindowEdgeSpacing) %
                      kCellHeight;	// then subtract out the partial cell height that would
    // be drawn on the bottom so that it's not actually drawn
    SetRect(&iconListRect, gWindowEdgeSpacing, gWindowEdgeSpacing,
            gWindowEdgeSpacing + kListWidth, iconListBottom);
    iconList = createIconList(window, iconListRect);
    SetWindowProperty(window, kAppSignature, kIconListTag, sizeof(ListHandle), &iconList);

#if TARGET_API_MAC_OS8
    CalculateBalloonHelpRects(window);
#else
    gWindowEventHandler = NewEventHandlerUPP(windowEventHandler);
    InstallWindowEventHandler(window, gWindowEventHandler, GetEventTypeCount(windowEvents),
                              windowEvents, NULL, NULL);
    InstallPrefsWindowHelpTags(window);
#endif

    DisableMenuItem(GetMenuRef(mDemonstration), iPrefsWindow);
    EnableMenuItem(GetMenuRef(mFile), iClose);

    ShowWindow(window);
} // OpenPrefsWindow