home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / VideoToolbox 94.11.17 / VideoToolboxSources / MaximizeConsoleHeight.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-17  |  4.2 KB  |  96 lines  |  [TEXT/KAHL]

  1. /*
  2. MaximizeConsoleHeight.c
  3. THINK C provides a built-in console. That console is less useful than it might
  4. be because it opens to only a small size, presumably designed to fit on the tiny
  5. screen of a Mac Plus, i.e. the lowest common denominator, for portability. This
  6. routine requests that the console open to the full height of your main screen.
  7. This makes good use of your screen, while maintaining the portability of your
  8. application. Call MaximizeConsoleHeight() BEFORE opening the console in THINK C,
  9. i.e. before your first printf().
  10.  
  11. To change the WIDTH of your THINK C console do this:
  12. #include <console.h>
  13. ...
  14. console_options.ncols=100;
  15.  
  16. LIMITATION:
  17. In June 1994 Mike Garver reported that on a Mac Plus running System 6.07 with an
  18. attached big screen the console window appears on the Mac Plus screen, as it
  19. should, but extends well past the bottom, "so I could see none of the text
  20. unless I moved the window onto the large screen." This happens because, when
  21. Color QuickDraw is not available, MaximizeConsoleHeight() resorts to using the
  22. CrsrPin rect to estimate the height of the main screen. (CrsrPin is the
  23. rectangle to which the cursor is confined. When the desktop isn't rectangular
  24. CrsrPin is the smallest rectangle that contains the desktop.) I don't know how
  25. to fix this. If Color QuickDraw were running then the program would have
  26. correctly gotten the bounds of the main device, but the computer lacks Color
  27. QuickDraw, so there are no video device records, nor a GrayRgn structure to
  28. consult. Since MaximizeConsoleHeight() is typically called before QuickDraw is
  29. initialized we can't use qd.screenBits.bounds (which is probably the same as
  30. CrsrPin rect anyway). I can't think of any way for this program to find out the
  31. correct height of the main screen under these circumstances. So I blame this on
  32. the necessary cludge implicit in having two screens in a computer lacking Color
  33. QuickDraw, since 1-bit QuickDraw doesn't really support multiple screens. I
  34. believe, but didn't confirm, that System 7 provides 32-bit QuickDraw (which
  35. includes Color QuickDraw) on all computers.
  36.  
  37. HISTORY:
  38. 1/92    dgp wrote it.
  39. 8/27/92    dgp    check for 8-bit quickdraw before using GDevices.
  40. 10/10/92 dgp Reduced maximum console height by one pixel, so as not to clip 
  41.             displayed text.
  42. 2/22/93    dgp replaced GetMBarHeight() by MBarHeight.
  43. 4/16/93    dgp    enhanced to actively support 1-bit QD, rather than doing nothing.
  44. 6/3/94    dgp    replaced low-memory global MBarHeight by GetMBarHeight().
  45. 6/21/94 dgp documented limitation above.
  46. 6/28/94 dgp use gdRect instead of pixmap bounds, which is correct for any device,
  47. not just the main device.
  48. 10/10/94 dgp added support for Metrowerks CodeWarrior C.
  49. 11/17/94 dgp Eliminated need for THINK C's LoMem.h by defining LMGetCrsrPin().
  50. */
  51.  
  52. #include "VideoToolbox.h"
  53. #if UNIVERSAL_HEADERS
  54.     #include <LowMem.h>
  55. #else
  56.     #define LMGetMBarHeight() (* (short *) 0x0BAA)
  57.     #define LMSetMBarHeight(MBarHeightValue) ((* (short *) 0x0BAA) = (MBarHeightValue))
  58. #endif
  59. // NOTE: Apple's Universal Headers fail to provide any access to CrsrPin, so I rolled my own.
  60. #define LMGetCrsrPin() (* (Rect *) 0x834)
  61. #if (THINK_C || THINK_CPLUS)
  62.     #include <console.h>
  63. #endif
  64.  
  65. void MaximizeConsoleHeight(void)
  66. {
  67. #if (THINK_C || THINK_CPLUS)
  68.     long qD;
  69.     Rect r;
  70.     
  71.     Gestalt(gestaltQuickdrawVersion,&qD);
  72.     if(qD>=gestalt8BitQD) r=(*GetMainDevice())->gdRect;
  73.     else r=LMGetCrsrPin();    // Can't use qd.screenBits.bounds 'cause qd may not yet be inited.
  74.     console_options.top=LMGetMBarHeight()+19;    // allow for menu bar and title bar
  75.     console_options.left=1;
  76.     console_options.nrows=r.bottom-4-console_options.top;
  77.     console_options.nrows/=console_options.txSize*4/3-1; /* estimate line spacing */
  78. #endif
  79. #if __MWERKS__
  80.     extern long __SIOUXtextWindow;
  81.     Rect r;
  82.     GDHandle device;
  83.  
  84.     if(__SIOUXtextWindow==NULL)printf("\n");
  85.     device=GetWindowDevice((WindowPtr)__SIOUXtextWindow);
  86.     if(device==NULL)return;
  87.     r=(**device).gdRect;
  88.     if(GetMainDevice()==device)r.top+=LMGetMBarHeight();
  89.     r.top+=19;        // allow for title bar
  90.     r.bottom-=1;    // allow for 1-pixel frame
  91.     r.left+=1;        // allow for 1-pixel frame
  92.     if(r.right-r.left>500)r.right=r.left+500;
  93. //    SizeWindow((WindowPtr)__SIOUXtextWindow,r.right-r.left,r.bottom-r.top,1);
  94.     MoveWindow((WindowPtr)__SIOUXtextWindow,r.left,r.top,1);
  95. #endif
  96. }