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.
Source/Windows.c
/****************************/ |
/* WINDOWS */ |
/* By Brian Greenstone */ |
/****************************/ |
/***************/ |
/* EXTERNALS */ |
/***************/ |
#include <Files.h> |
#include <Dialogs.h> |
#include <QD3D.h> |
#include "myglobals.h" |
#include "mywindows.h" |
#include "misc.h" |
extern Boolean gShowContentStructure,gSaveTextToFile; |
extern FSSpec gStreamFSSpec; |
extern short gStreamRefNum; |
/****************************/ |
/* CONSTANTS */ |
/****************************/ |
/**********************/ |
/* VARIABLES */ |
/**********************/ |
Rect gSizeRect; |
short gHtab = 10; |
/*********************** DUMP GWORLD **********************/ |
// |
// |
// |
void DumpGWorld(GWorldPtr thisWorld, WindowPtr thisWindow) |
{ |
Rect tempRect; |
GrafPtr oldPort; |
PixMapHandle pm; |
DoLockPixels(thisWorld); |
GetPort(&oldPort); |
pm = GetGWorldPixMap(thisWorld); |
if ((pm == nil) | (*pm == nil) ) |
DoAlert("\pPixMap Handle or Ptr = Null?!"); |
SetPort(thisWindow); |
tempRect = thisWindow->portRect; |
ForeColor(blackColor); |
BackColor(whiteColor); |
CopyBits((BitMap *)*pm,&(qd.thePort->portBits), |
&(thisWorld->portRect),&tempRect,srcCopy,0); |
SetPort(oldPort); |
} |
/*********************** DUMP GWORLD 2 **********************/ |
// |
// copies to a destination RECT |
// |
void DumpGWorld2(GWorldPtr thisWorld, WindowPtr thisWindow,Rect *destRect) |
{ |
PixMapHandle pm; |
DoLockPixels(thisWorld); |
pm = GetGWorldPixMap(thisWorld); |
if ((pm == nil) | (*pm == nil) ) |
DoAlert("\pPixMap Handle or Ptr = Null?!"); |
ForeColor(blackColor); |
BackColor(whiteColor); |
CopyBits((BitMap *)*pm,&(thisWindow->portBits), |
destRect,destRect,srcCopy,0); |
DoUnlockPixels(thisWorld); |
} |
/*********************** DUMP GWORLD 3 **********************/ |
// |
// copies RECT to RECT |
// |
void DumpGWorld3(GWorldPtr thisWorld, WindowPtr thisWindow,Rect *srcRect,Rect *destRect) |
{ |
PixMapHandle pm; |
DoLockPixels(thisWorld); |
pm = GetGWorldPixMap(thisWorld); |
if ((pm == nil) | (*pm == nil) ) |
DoAlert("\pPixMap Handle or Ptr = Null?!"); |
ForeColor(blackColor); |
BackColor(whiteColor); |
CopyBits((BitMap *)*pm,&(thisWindow->portBits), |
srcRect,destRect,srcCopy,0); |
// DoUnlockPixels(thisWorld); |
} |
/*********************** DUMP GWORLD TO GWORLD **********************/ |
// |
// copies RECT to RECT |
// |
void DumpGWorldToGWorld(GWorldPtr thisWorld, GWorldPtr destWorld,Rect *srcRect,Rect *destRect) |
{ |
PixMapHandle pm,pm2; |
GDHandle oldGD; |
GWorldPtr oldGW; |
GetGWorld (&oldGW,&oldGD); |
SetGWorld(destWorld,nil); |
ForeColor(blackColor); |
BackColor(whiteColor); |
SetGWorld(thisWorld,nil); |
ForeColor(blackColor); |
BackColor(whiteColor); |
DoLockPixels(destWorld); |
DoLockPixels(thisWorld); |
pm = GetGWorldPixMap(thisWorld); |
if ((pm == nil) | (*pm == nil) ) |
DoAlert("\pPixMap Handle or Ptr = Null?!"); |
pm2 = GetGWorldPixMap(destWorld); |
if ((pm2 == nil) | (*pm2 == nil) ) |
DoAlert("\pPixMap Handle or Ptr = Null?!"); |
CopyBits((BitMap *)*pm,(BitMap *)*pm2, |
srcRect,destRect,srcCopy,0); |
SetGWorld(oldGW,oldGD); // restore gworld |
} |
/******************* DO LOCK PIXELS **************/ |
void DoLockPixels(GWorldPtr world) |
{ |
PixMapHandle pm; |
pm = GetGWorldPixMap(world); |
if (LockPixels(pm) == false) |
DoFatalAlert("\pPixMap Went Bye,Bye?!"); |
} |
/***************** DO UNLOCK PIXELS **************/ |
void DoUnlockPixels(GWorldPtr world) |
{ |
PixMapHandle pm; |
pm = GetGWorldPixMap(world); |
UnlockPixels(pm); |
} |
/*============================================================================== |
* Dobold () |
* this is the user item procedure to make the thick outline around the default |
* button (assumed to be item 1) |
*=============================================================================*/ |
pascal void DoBold (WindowPtr dlogPtr, short item) |
{ |
short itype; |
Handle ihandle; |
Rect irect; |
GetDialogItem (dlogPtr, item, &itype, (Handle *)&ihandle, &irect); /* get the buttons rect */ |
PenSize (3, 3); /* make thick lines */ |
InsetRect (&irect, -4, -4); /* grow rect a little */ |
FrameRoundRect (&irect, 16, 16); /* frame the button now */ |
PenNormal (); |
} |
/*============================================================================== |
* DoOutline () |
* this is the user item procedure to make the thin outline around the given useritem |
*=============================================================================*/ |
pascal void DoOutline (WindowPtr dlogPtr, short item) |
{ |
short itype; |
Handle ihandle; |
Rect irect; |
GetDialogItem (dlogPtr, item, &itype, (Handle *)&ihandle, &irect); // get the user item's rect |
FrameRect (&irect); // frame the button now |
PenNormal(); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14