home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Ken Long / NewControl-p / Buggy C Port / ScrollControls.µ.c < prev    next >
Encoding:
Text File  |  1994-12-04  |  16.2 KB  |  111 lines  |  [TEXT/MMCC]

  1.     //• Show the watch while we wait for inits & setups to finish.
  2. //    SetCursor (&clockCursor);
  3.  
  4.     //• Init everything in case the app is the Startup App.
  5.     InitFonts ();                //• Startup the fonts manager.
  6.     InitWindows ();                //• Startup the window manager.
  7.     InitMenus ();                //• Startup the menu manager.
  8.     TEInit ();                    //• Startup the text edit manager.
  9.     InitDialogs (0L);            //• Startup the dialog manager.
  10.  
  11.     finished = false;            //• Set program terminator to false.
  12.     FlushEvents (everyEvent, 0);//• Clear events from previous program.
  13. }
  14.  
  15. //• -----------------------------------------------------------------------------.
  16.  
  17. void SetupLimits ()
  18. {
  19.     screen = qd.screenBits.bounds;   //• set the size of the screen.
  20.     SetRect (&dragArea, screen.left + 4, screen.top + 24, screen.right - 4, screen.bottom - 4);
  21.     SetRect (&growArea, screen.left, screen.top + 24, screen.right, screen.bottom);
  22. }
  23.  
  24. //• -----------------------------------------------------------------------------.
  25.  
  26. void SetupMenus ()
  27. {
  28.     MenuHandle MenuTopic;
  29.  
  30.     MenuTopic = GetMenu (appleMenu);  //• get the apple desk accessories menu.
  31.     AddResMenu (MenuTopic, 'DRVR');    //• adds all names into item list.
  32.     InsertMenu (MenuTopic, 0);        //• put in list held by menu manager.
  33.  
  34.     MenuTopic = GetMenu (fileMenu);   //• always need this for Quiting.
  35.     InsertMenu (MenuTopic, 0);
  36.  
  37.     MenuTopic = GetMenu (editMenu);   //• always need for editing Desk Accessories.
  38.     InsertMenu (MenuTopic, 0);
  39.  
  40.     DrawMenuBar ();        //• all done so show the menu bar.
  41. }
  42.  
  43. //• -----------------------------------------------------------------------------.
  44.  
  45. void SetupWindows ()
  46. {
  47.     ControlHandle vScroll;  //• used to create control.
  48.     ControlHandle hScroll;  //• same thing, we could put them in 
  49.                             //• global but the the window is 
  50.                             //• global and it will have them.
  51.                             
  52.     oneWindow = GetNewWindow (WindResID, 0L, (WindowPtr)-1L);
  53.     SetPort (oneWindow);  //• so usableArea is correct.
  54.  
  55. //• now setup the usable window area.
  56.     usableArea = oneWindow->portRect;                        //• initialize it.
  57.     usableArea.right = usableArea.right - VSBarWidth;
  58.     usableArea.bottom = usableArea.bottom - HSBarHeight;
  59.  
  60. //• now set up the scroll bar controls that this window will use.
  61.     vScroll = GetNewControl (VScrollBar, oneWindow);  //• get vertical scroll bar.
  62.     hScroll = GetNewControl (HScrollBar, oneWindow);  //• get horizontal scroll bar.
  63.  
  64.     //• Our display is going to be 700 by 700 pixels so set min & max values.
  65.     //• Note: the window is 290 by 490.
  66.     SetCtlMin (hScroll, 0);        //• set the minimum value in vertical direction.
  67.     SetCtlMax (hScroll, 210);    //• set the maximum value in vertical direction.
  68.     SetCtlMin (vScroll, 0);        //• set the minimum value in horizontal direction.
  69.     SetCtlMax (vScroll, 410);    //• set the maximum value in horizontal direction.
  70.  
  71.     //• the current origin will be stored in the refcon of the window.
  72.     //•   NOTE: its already been set in the resource file}
  73.     //• SetWRefCon (oneWindow, 0);    //• Initialize it to zero*.
  74.     
  75.     //• all set so show the window.
  76.     ShowWindow (oneWindow);
  77.  
  78.     //• Note that the controls are brought in invisibily, show them.
  79.     //• when the window becomes active, hide them when its inactive.
  80. }
  81.  
  82. //• -----------------------------------------------------------------------------.
  83.  
  84. void SetUpThings ()
  85. {
  86.     SetupWindows ();        //• do first so its low in heap.
  87.     SetupMenus ();
  88.     SetupLimits ();
  89.  
  90.     InitCursor ();        //• ready to go, so show the Arrow cursor.
  91. }
  92.  
  93. //• -----------------------------------------------------------------------------.
  94.  
  95. void CloseThings ()
  96. {
  97.     //• close files, if you changed sys resources, UNchange them 
  98.     //• here be careful about changing sys things, remember the 
  99.     //• Switcher could be around.
  100. }
  101.  
  102. //• -----------------------------------------------------------------------------.
  103. main ()
  104. {
  105.     InitThings ();
  106.     SetUpThings ();
  107.     MainEventLoop ();
  108.     CloseThings ();
  109. }
  110.  
  111.