home *** CD-ROM | disk | FTP | other *** search
- /* Cell Proj 1.0 */
-
- #include "Cell_Proto.h"
- #include "Cell_Definitions.h"
- #include "Cell_Variables.h"
-
- ToolBoxInit()
- {
- unsigned long mySeed;
-
- InitGraf( &qd.thePort );
- GetDateTime(&mySeed);
- LMSetRndSeed(mySeed);
- InitFonts();
- FlushEvents( everyEvent, REMOVE_ALL_EVENTS );
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( NIL_POINTER );
- InitCursor();
- }
-
- WindowInit()
- {
- gCellWindow = GetNewWindow( BASE_RES_ID, NIL_POINTER, MOVE_TO_BACK );
-
- gSizeRect.top = MIN_WINDOW_HEIGHT;
- gSizeRect.left = MIN_WINDOW_WIDTH;
- gSizeRect.bottom = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;
- gSizeRect.right = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
- SetPort( gCellWindow );
- SetOrigin( -5, -5 );
- }
-
- DialogInit()
- {
- gCellInfoDialog = GetNewDialog( BASE_RES_ID, NIL_POINTER,
- ( WindowPtr ) MOVE_TO_FRONT );
- ShowWindow( gCellInfoDialog );
- }
-
- MenuBarInit()
- {
- Handle myMenuBar;
-
- myMenuBar = GetNewMBar( BASE_RES_ID );
- SetMenuBar( myMenuBar );
- gAppleMenu = GetMHandle( APPLE_MENU_ID );
- gFileMenu = GetMHandle( FILE_MENU_ID );
-
- AddResMenu( gAppleMenu, 'DRVR' );
- DrawMenuBar();
- }
-
- SetUpDragRect()
- {
- gDragRect = qd.screenBits.bounds;
- gDragRect.left += DRAG_THRESHOLD;
- gDragRect.right -= DRAG_THRESHOLD;
- gDragRect.bottom -= DRAG_THRESHOLD;
- }
-
- DisplayCellWindow()
- {
- ShowWindow( gCellWindow );
- DrawControls( gCellWindow );
- }
-
- PlaceRandomCells()
- {
- int randomLiveCell;
- int count;
-
- for ( count = 0; count < NUMBER_OF_CELLS; count++ )
- {
- gCellStatus[count] = 0;
- }
-
- for ( count = 0; count < 800; count++ )
- {
- randomLiveCell = Randomize( 9999 );
- gCellStatus[randomLiveCell] = 1;
- GraphAlive( randomLiveCell );
- }
-
- }
-
- Randomize( range )
- int range;
- {
- long rawResult;
-
- rawResult = Random();
- if ( rawResult < 0 )
- rawResult *= -1;
- return((( rawResult * ( range )) / 32768 ) + 1 );
- }