// -------------------------------------------------------------------------------------- void HandleDrawContent(WindowRef prefsWindow) { RgnHandle visibleRegion; ListHandle iconList; GetWindowProperty(prefsWindow, kAppSignature, kIconListTag, sizeof(ListHandle), NULL, &iconList); visibleRegion = NewRgn(); GetPortVisibleRegion(GetWindowPort(prefsWindow), visibleRegion); if (visibleRegion != NULL) { Boolean active = IsWindowHilited(prefsWindow); SInt16 pixelDepth; Boolean isColorDevice; if (active) SetThemeWindowBackground(prefsWindow, kThemeBrushModelessDialogBackgroundActive, false); else SetThemeWindowBackground(prefsWindow, kThemeBrushModelessDialogBackgroundInactive, false); EraseRgn(visibleRegion); UpdateControls(prefsWindow, visibleRegion); GetWindowDeviceDepthAndColor(prefsWindow, &pixelDepth, &isColorDevice); SetThemeBackground(kThemeBrushWhite, pixelDepth, isColorDevice); LUpdate(visibleRegion, iconList); drawFrameAndFocus(iconList, active, prefsWindow); DisposeRgn(visibleRegion); } }
void Init(void) { Str255 winTitle; OSErr err = noErr; Str255 instMode; Ptr pinstMode; gDone = false; InitManagers(); InitControlsObject(); CleanTemp(); ParseInstall(); gWPtr = GetNewCWindow(rRootWin, NULL, (WindowPtr) -1); GetIndString( instMode, rTitleStrList, sNSInstTitle); pinstMode = PascalToC(instMode); #if MOZILLA == 0 GetResourcedString(winTitle, rInstList, sNsTitle); #else GetResourcedString(winTitle, rInstList, sMoTitle); #endif SetWTitle( gWPtr, winTitle ); SetWRefCon(gWPtr, kMIWMagic); MakeMenus(); ParseConfig(); InitOptObject(); ShowWelcomeWin(); SetThemeWindowBackground(gWPtr, kThemeBrushDialogBackgroundActive, true); /* Set menu */ InitNewMenu(); }
// -------------------------------------------------------------------------------------- static void drawFrameAndFocus(ListHandle list, Boolean active, WindowRef window) { Rect borderRect; GetListViewBounds(list, &borderRect); borderRect.right += kScrollBarWidth; if (active) { SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundActive, false); DrawThemeListBoxFrame(&borderRect, kThemeStateActive); DrawThemeFocusRect(&borderRect, true); } else { SetThemeWindowBackground(window, kThemeBrushModelessDialogBackgroundInactive, false); DrawThemeFocusRect(&borderRect, false); DrawThemeListBoxFrame(&borderRect, kThemeStateInactive); } }
static boolean statsnewwindow (void) { WindowPtr w; hdlwindowinfo hw; bigstring bstitle; Rect rzoom, rwindow; hdlwindowinfo hparent; Handle hdata; if (!shellgetfrontrootinfo (&hparent)) /*our parent is the frontmost root window*/ return (false); shellgetwindowcenter (hparent, &rzoom); if (!newclearhandle (sizeof (tystatsrecord), &hdata)) return (false); rwindow.top = -1; /*accept default*/ getstatsstring (idwindowtitle, bstitle); if (!newchildwindow (idstatsconfig, hparent, &rwindow, &rzoom, bstitle, &w)) { disposehandle ((Handle) hdata); return (false); } getwindowinfo (w, &hw); (**hw).hdata = hdata; /*ccnewsubwindow (messagewindowinfo, ixmsginfo);*/ // shellpushglobals (statswindow); #if TARGET_API_MAC_CARBON == 1 SetThemeWindowBackground (w, kThemeBrushModelessDialogBackgroundActive, false); #endif windowzoom (w); // shellpopglobals (); statswindow = w; return (true); } /*statsnewwindow*/
static boolean newaboutwindow (boolean flbootsplash) { /* 5.0.2b20 dmb: don't reset window pos for negative values */ WindowPtr w; hdlwindowinfo hw; bigstring bstitle; Rect rzoom, rwindow; hdlaboutrecord hdata; short ixaboutconfig; if (!newclearhandle (sizeof (tyaboutrecord), (Handle *) &hdata)) return (false); shellfindcallbacks (idaboutconfig, &ixaboutconfig); if (flbootsplash) { globalsarray [ixaboutconfig].config.templateresnum = 131;//config.fldialog (**hdata).flbootsplash = true; } else globalsarray [ixaboutconfig].config.templateresnum = 129; //restore // get bigwindow setting with current root // (**hdata).flbigwindow = (cancoonglobals == nil) || (**cancoonglobals).flbigwindow; ccgetwindowrect (ixaboutinfo, &rwindow); // if (rwindow.top <= 0 || rwindow.left <= 0) // rwindow.top = -1; getsystemoriginrect (&rzoom); // getstringlist (aboutlistnumber, abouttitlestring, bstitle); copystring (aboutstrings [frontieritem], bstitle); if (!flbootsplash) insertstring (BIGSTRING ("\x06" "About "), bstitle); /* 2006-02-04 aradke: eliminated titleitem */ if (!newchildwindow (idaboutconfig, nil, &rwindow, &rzoom, bstitle, &w)) { disposehandle ((Handle) hdata); return (false); } #if TARGET_API_MAC_CARBON == 1 SetThemeWindowBackground (w, kThemeBrushModelessDialogBackgroundActive, false); #endif getwindowinfo (w, &hw); (**hw).hdata = (Handle) hdata; shellpushglobals (w); aboutwindowsetup (); aboutresetrects (hw); if (!flbootsplash) { aboutresizeafterfontchange (); aboutsetconfigminimum (); } shellpopglobals (); windowzoom (w); return (true); } /*newaboutwindow*/
//-------------------------------------------------------------------------------------------------// void OSXCarbonWindow::create( const String& name, unsigned int width, unsigned int height, bool fullScreen, const NameValuePairList *miscParams ) { bool hasDepthBuffer; String title = name; size_t fsaa_samples = 0; int left = 0; int top = 0; int depth = 32; if( miscParams ) { NameValuePairList::const_iterator opt = NULL; // Full screen anti aliasing opt = miscParams->find( "FSAA" ); if( opt != miscParams->end() ) fsaa_samples = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "left" ); if( opt != miscParams->end() ) left = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "top" ); if( opt != miscParams->end() ) top = StringConverter::parseUnsignedInt( opt->second ); opt = miscParams->find( "title" ); if( opt != miscParams->end() ) title = opt->second; opt = miscParams->find( "depthBuffer" ); if( opt != miscParams->end() ) hasDepthBuffer = StringConverter::parseBool( opt->second ); opt = miscParams->find( "colourDepth" ); if( opt != miscParams->end() ) depth = StringConverter::parseUnsignedInt( opt->second ); } if(fullScreen) { GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); OSXContext *mainContext = (OSXContext*)rs->_getMainContext(); CGLContextObj share = NULL; if(mainContext == 0) { share = NULL; } else if(mainContext->getContextType() == "AGL") { OSXCarbonContext* aglShare = static_cast<OSXCarbonContext*>(mainContext); aglGetCGLContext(aglShare->getContext(), &((void*)share)); } else if(mainContext->getContextType() == "CGL") { OSXCGLContext* cglShare = static_cast<OSXCGLContext*>(mainContext); share = cglShare->getContext(); } // create the context createCGLFullscreen(width, height, depth, fsaa_samples, share); } else { int i = 0; AGLPixelFormat pixelFormat; GLint attribs[ 20 ]; attribs[ i++ ] = AGL_NO_RECOVERY; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_ACCELERATED; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_RGBA; attribs[ i++ ] = AGL_DOUBLEBUFFER; attribs[ i++ ] = AGL_ALPHA_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_STENCIL_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_DEPTH_SIZE; attribs[ i++ ] = depth; if(fsaa_samples > 1) { attribs[ i++ ] = AGL_MULTISAMPLE; attribs[ i++ ] = 1; attribs[ i++ ] = AGL_SAMPLE_BUFFERS_ARB; attribs[ i++ ] = fsaa_samples; } attribs[ i++ ] = AGL_NONE; pixelFormat = aglChoosePixelFormat( NULL, 0, attribs ); // Create the AGLContext from our pixel format // Share it with main GLRenderSystem *rs = static_cast<GLRenderSystem*>(Root::getSingleton().getRenderSystem()); OSXContext* mainContext = static_cast<OSXContext*>( rs->_getMainContext() ); if(mainContext == 0) { mAGLContext = aglCreateContext(pixelFormat, NULL); } else if(mainContext->getContextType() == "AGL") { OSXCarbonContext* context = static_cast<OSXCarbonContext*>( rs->_getMainContext() ); AGLContext shared = context->getContext(); mAGLContext = aglCreateContext(pixelFormat, context->getContext()); } else { // If we do not have an AGL, we can not clone it using this window LogManager::getSingleton().logMessage( "Warning: You asked to create a second window, " "when the previous window was not of this type. OgreOSXCarbonWindow can only share " "with an AGL context."); } NameValuePairList::const_iterator opt = 0; if(miscParams) opt = miscParams->find("externalWindowHandle"); if(!miscParams || opt == miscParams->end()) { // create the window rect in global coords ::Rect windowRect; windowRect.left = 0; windowRect.top = 0; windowRect.right = width; windowRect.bottom = height; // set the default attributes for the window WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize" if (miscParams) { opt = miscParams->find("border"); if( opt != miscParams->end() ) { String borderType = opt->second; if( borderType == "none" ) windowAttrs = kWindowNoTitleBarAttribute; else if( borderType == "fixed" ) windowAttrs = kWindowStandardFloatingAttributes; } } windowAttrs |= kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowHideOnFullScreenAttribute; // Create the window CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow); // Color the window background black SetThemeWindowBackground (mWindow, kThemeBrushBlack, true); // Set the title of our window CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII ); SetWindowTitleWithCFString( mWindow, titleRef ); // Center our window on the screen RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen ); // Get our view HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView ); // Set up our UPP for Window Events EventTypeSpec eventSpecs[] = { {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowClosed}, {kEventClassWindow, kEventWindowClose} }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler); // Install the standard event handler for the window EventTargetRef target = GetWindowEventTarget(mWindow); InstallStandardEventHandler(target); // We also need to install the WindowEvent Handler, we pass along the window with our requests InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef); // Display and select our window ShowWindow(mWindow); SelectWindow(mWindow); // Add our window to the window event listener class WindowEventUtilities::_addRenderWindow(this); } else { // TODO: The Contol is going to report the incorrect location with a // Metalic / Textured window. The default windows work just fine. // First get the HIViewRef / ControlRef mView = (HIViewRef)StringConverter::parseUnsignedLong(opt->second); mWindow = GetControlOwner(mView); // Lets try hiding the HIView //HIViewSetVisible(mView, false); // Get the rect bounds ::Rect ctrlBounds; GetControlBounds(mView, &ctrlBounds); GLint bufferRect[4]; bufferRect[0] = ctrlBounds.left; // left edge bufferRect[1] = ctrlBounds.bottom; // bottom edge bufferRect[2] = ctrlBounds.right - ctrlBounds.left; // width of buffer rect bufferRect[3] = ctrlBounds.bottom - ctrlBounds.top; // height of buffer rect aglSetInteger(mAGLContext, AGL_BUFFER_RECT, bufferRect); aglEnable (mAGLContext, AGL_BUFFER_RECT); mIsExternal = true; } // Set the drawable, and current context // If you do this last, there is a moment before the rendering window pops-up // This could go once inside each case above, before the window is displayed, // if desired. aglSetDrawable(mAGLContext, GetWindowPort(mWindow)); aglSetCurrentContext(mAGLContext); // Give a copy of our context to the render system mContext = new OSXCarbonContext(mAGLContext, pixelFormat); } mName = name; mWidth = width; mHeight = height; mActive = true; mClosed = false; mCreated = true; mIsFullScreen = fullScreen; }
void OSXCarbonWindow::createNewWindow(unsigned int width, unsigned int height, String title) { if(!mWindow) { // Create the window rect in global coords ::Rect windowRect; windowRect.left = 0; windowRect.top = 0; windowRect.right = width; windowRect.bottom = height; // Set the default attributes for the window WindowAttributes windowAttrs = kWindowStandardDocumentAttributes; // default: "resize" windowAttrs |= kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowHideOnFullScreenAttribute | kWindowNoShadowAttribute; // Create the window CreateNewWindow(kDocumentWindowClass, windowAttrs, &windowRect, &mWindow); // Color the window background black SetThemeWindowBackground(mWindow, kThemeBrushBlack, true); // Set the title of our window CFStringRef titleRef = CFStringCreateWithCString( kCFAllocatorDefault, title.c_str(), kCFStringEncodingASCII ); SetWindowTitleWithCFString( mWindow, titleRef ); CFRelease(titleRef); mWindowTitle = title; // Center our window on the screen RepositionWindow( mWindow, NULL, kWindowCenterOnMainScreen ); // Get our view HIViewFindByID( HIViewGetRoot( mWindow ), kHIViewWindowContentID, &mView ); // Set up our UPP for Window Events EventTypeSpec eventSpecs[] = { {kEventClassWindow, kEventWindowActivated}, {kEventClassWindow, kEventWindowDeactivated}, {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowDragCompleted}, {kEventClassWindow, kEventWindowBoundsChanged}, {kEventClassWindow, kEventWindowExpanded}, {kEventClassWindow, kEventWindowCollapsed}, {kEventClassWindow, kEventWindowClosed}, {kEventClassWindow, kEventWindowClose} }; EventHandlerUPP handlerUPP = NewEventHandlerUPP(WindowEventUtilities::_CarbonWindowHandler); // Install the standard event handler for the window EventTargetRef target = GetWindowEventTarget(mWindow); InstallStandardEventHandler(target); // We also need to install the WindowEvent Handler, we pass along the window with our requests InstallEventHandler(target, handlerUPP, 10, eventSpecs, (void*)this, &mEventHandlerRef); } HIRect winBounds = CGRectZero; HIViewRef root = HIViewGetRoot(HIViewGetWindow(mView)); HIViewGetBounds(root, &winBounds); HIRect viewBounds = CGRectZero; HIViewGetBounds(mView, &viewBounds); // Display and select our window if(!mHidden && mVisible) { ShowWindow(mWindow); SelectWindow(mWindow); } // Add our window to the window event listener class WindowEventUtilities::_addRenderWindow(this); }
// True for OK, false for cancel bool Configure_ChaseCam(ChaseCamData &Data) { short ItemType; Rect Bounds; DialogPtr Dialog = myGetNewDialog(ChaseCam_Dialog, NULL, (WindowPtr)(-1), 0); assert(Dialog); ControlHandle Behind_CHdl; GetDialogItem(Dialog, Behind_Item, &ItemType, (Handle *)&Behind_CHdl, &Bounds); SetFloat(Behind_CHdl,Data.Behind/FLOAT_WORLD_ONE); ControlHandle Upward_CHdl; GetDialogItem(Dialog, Upward_Item, &ItemType, (Handle *)&Upward_CHdl, &Bounds); SetFloat(Upward_CHdl,Data.Upward/FLOAT_WORLD_ONE); ControlHandle Rightward_CHdl; GetDialogItem(Dialog, Rightward_Item, &ItemType, (Handle *)&Rightward_CHdl, &Bounds); SetFloat(Rightward_CHdl,Data.Rightward/FLOAT_WORLD_ONE); MacCheckbox PassThruWall_CB(Dialog, PassThruWall_Item, TEST_FLAG(Data.Flags,_ChaseCam_ThroughWalls)); MacCheckbox NeverActive_CB(Dialog, NeverActive_Item, TEST_FLAG(Data.Flags,_ChaseCam_NeverActive)); MacCheckbox OnWhenEntering_CB(Dialog, OnWhenEntering_Item, TEST_FLAG(Data.Flags,_ChaseCam_OnWhenEntering)); ControlHandle Damping_CHdl; GetDialogItem(Dialog, Damping_Item, &ItemType, (Handle *)&Damping_CHdl, &Bounds); SetFloat(Damping_CHdl,Data.Damping); ControlHandle Spring_CHdl; GetDialogItem(Dialog, Spring_Item, &ItemType, (Handle *)&Spring_CHdl, &Bounds); SetFloat(Spring_CHdl,Data.Spring); ControlHandle Opacity_CHdl; GetDialogItem(Dialog, CC_Opacity_Item, &ItemType, (Handle *)&Opacity_CHdl, &Bounds); SetFloat(Opacity_CHdl,Data.Opacity); // Where to make the color picker Point Center = {-1,-1}; RGBColor NewColor; // Get void color from OpenGL-parameters data OGL_ConfigureData& OGLData = Get_OGL_ConfigureData(); MacCheckbox VoidColorOnOff_CB(Dialog, VoidColorOnOff_Item, TEST_FLAG(OGLData.Flags,OGL_Flag_VoidColor)); // Reveal it #if USE_SHEETS SetThemeWindowBackground(GetDialogWindow(Dialog), kThemeBrushSheetBackgroundTransparent, false); ShowSheetWindow(GetDialogWindow(Dialog), ActiveNonFloatingWindow()); #else SelectWindow(GetDialogWindow(Dialog)); ShowWindow(GetDialogWindow(Dialog)); #endif bool WillQuit = false; bool IsOK = false; short New_Behind = 0, New_Upward = 0, New_Rightward = 0; float FloatTemp = 0; bool BadValue; float New_Damping, New_Spring, New_Opacity; while(!WillQuit) { short ItemHit; ModalDialog(NULL, &ItemHit); switch(ItemHit) { case OK_Item: // Check before quitting BadValue = false; // Now doing roundoff correctly // Using a modification of AlexJLS's corrected version if (GetFloat(Behind_CHdl,FloatTemp)) New_Behind = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Upward_CHdl,FloatTemp)) New_Upward = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Rightward_CHdl,FloatTemp)) New_Rightward = FloatRoundoff(WORLD_ONE * FloatTemp); else BadValue = true; if (GetFloat(Damping_CHdl,FloatTemp)) { // Simple validation of the damping factor New_Damping = PIN(FloatTemp,-1,1); if (New_Damping != FloatTemp) { BadValue = true; SetFloat(Damping_CHdl,New_Damping); } } else BadValue = true; if (GetFloat(Spring_CHdl,FloatTemp)) { New_Spring = FloatTemp; } else BadValue = true; if (GetFloat(Opacity_CHdl,FloatTemp)) { New_Opacity = PIN(FloatTemp,0,1); if (New_Opacity != FloatTemp) { BadValue = true; SetFloat(Opacity_CHdl,New_Opacity); } } else BadValue = true; // Do validation: will the chase cam be unstable? if (!BadValue) { if (New_Spring >= 0) { // Oscillatory case float NewDampSq = New_Damping*New_Damping; BadValue = ((NewDampSq + New_Spring) >= 1); if (BadValue) { New_Spring = 1 - NewDampSq; SetFloat(Spring_CHdl,New_Spring); } } else { // Overdamped case float NewDampAbs = fabs(New_Damping); BadValue = ((NewDampAbs + sqrt(-New_Spring)) >= 1); if (BadValue) { float Temp = 1 - NewDampAbs; New_Spring = - Temp*Temp; SetFloat(Spring_CHdl,New_Spring); } } } if (BadValue) { SysBeep(30); break; } IsOK = true; WillQuit = true; break; case Cancel_Item: IsOK = false; WillQuit = true; break; case VoidColorSelect_Item: // Need to set color here so the preview can work properly if (GetColor(Center,"\pWhat color for the void?",&OGLData.VoidColor,&NewColor)) OGLData.VoidColor = NewColor; break; default: if (PassThruWall_CB.ToggleIfHit(ItemHit)) break; if (NeverActive_CB.ToggleIfHit(ItemHit)) break; if (OnWhenEntering_CB.ToggleIfHit(ItemHit)) break; if (VoidColorOnOff_CB.ToggleIfHit(ItemHit)) break; break; } } if (IsOK) { Data.Behind = New_Behind; Data.Upward = New_Upward; Data.Rightward = New_Rightward; SET_FLAG(Data.Flags,_ChaseCam_ThroughWalls,PassThruWall_CB.GetState()); SET_FLAG(Data.Flags,_ChaseCam_NeverActive,NeverActive_CB.GetState()); SET_FLAG(Data.Flags,_ChaseCam_OnWhenEntering,OnWhenEntering_CB.GetState()); SET_FLAG(OGLData.Flags,OGL_Flag_VoidColor,VoidColorOnOff_CB.GetState()); Data.Damping = New_Damping; Data.Spring = New_Spring; Data.Opacity = New_Opacity; } // Clean up #if USE_SHEETS HideSheetWindow(GetDialogWindow(Dialog)); #else HideWindow(GetDialogWindow(Dialog)); #endif DisposeDialog(Dialog); return IsOK; }
// -------------------------------------------------------------------------------------- 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