Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
About.cp
// About.cp |
// Copyright © 1992 by Apple Computer, Inc. All rights reserved. |
// Kent Sandvik DTS |
// This file contains the About box code including any adorners/behaviors |
// The resources are placed in the project .r file |
// Version Info (latest first): |
// |
// <1> khs 1.0 First final version |
#ifndef __ABOUT__ |
#include "About.h" |
#endif |
// Functions |
#pragma segment ARes |
void CreateAboutBox() |
{ |
TWindow * aboutBoxWindow; |
CStr255 programName, versionInfo, finalProduct; |
// Yes, I do know this is a waste of resources to 'macroDontDeadStrip' and |
// register the adorner type every time we open the About box. However, for the |
// sake of modularity, where I only need to place a CreateAboutBox() statement |
// inside the TApplication->DoAboutBox(), it made sense - instead of writing all |
// kinds of init methods that need to be called from IApplication. |
macroDontDeadStrip(TMetalBlueFill); |
RegisterStdType("TMetalBlueFill", kBlueMetalLook);// register adorner types |
// Get application name |
gApplication->GetApplicationName(programName); |
// Get version information |
VersRecHndl versInfo = (VersRecHndl)GetResource(kVersInfoType, kVers1InfoID); |
if (versInfo) // short one? |
versionInfo = (**versInfo).shortVersion;// get version info from version 1 |
else |
versionInfo = " "; // nooooothing |
// Create Window |
aboutBoxWindow = gViewServer->NewTemplateWindow(phAboutBox, NULL); |
FailNIL(aboutBoxWindow); |
// Hook in any adorners |
aboutBoxWindow->AddAdorner(NewStdAdorner('blmt', "", 'blmt', kFreeOnDeletion), kAdornBefore, kRedraw); |
// Stuff in the version info to the other status view, but first get a ptr to it... |
TStaticText * versionField = (TStaticText *)aboutBoxWindow->FindSubView('sta2'); |
finalProduct = programName + CStr255(" ") + versionInfo; |
versionField->SetText(finalProduct, TRUE); |
// Open the About box window, and let the user close it whenever... |
aboutBoxWindow->Open(); |
} |
// About Box color adorner |
CRGBColor gMetalBlue(26312, |
14340, |
47359); // Setup the metal-blue color |
// Empty constructor - for avoiding ptabs in global data space |
#undef Inherited |
#define Inherited TAdorner |
#pragma segment ARes |
DefineClass(TMetalBlueFill, TAdorner); |
TMetalBlueFill::TMetalBlueFill() |
{ |
} |
// Draw TGrayFill Adorner method |
#pragma segment ARes |
void TMetalBlueFill::Draw(TView* itsView, |
const VRect& /*area*/) |
{ |
CRGBColor saveColor; |
PenState savePenState; |
VRect adornArea; |
CRect QDArea; |
CRect tempRect; |
GetPenState(&savePenState); // save off the current pen state |
GetIfColor(saveColor); // and the foreground color |
PenNormal(); |
itsView->GetAdornExtent(adornArea); // get area |
itsView->ViewToQDRect(adornArea, QDArea); |
tempRect = QDArea; |
SetIfColor(gMetalBlue); // colorize it |
PaintRect(tempRect); |
SetIfColor(saveColor); // restore the foreground color and the pen |
SetPenState(&savePenState); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14