home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Snippets / Toolbox / GetDragHiliteColor / Source / DrawCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-17  |  2.2 KB  |  99 lines  |  [TEXT/CWIE]

  1. #include <Windows.h>
  2. #include <QuickDraw.h>
  3. #include <TextUtils.h>
  4. #include <Fonts.h>
  5.  
  6. extern void SetupDragHiliteColor(WindowPtr);
  7. void DrawIt(WindowPtr win);
  8. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin);
  9. void CreateNewWindow(void);
  10. void PreEventLoop(void);
  11. void DoUpdate(WindowPtr thisWindow);
  12. void PostEventLoop(void);
  13.  
  14.  
  15. /*-------------------------------------------------------------------------------------*/
  16.  
  17. void DrawIt(WindowPtr win)
  18. {
  19.     short         origFont, origSize;
  20.     
  21.     origFont = win->txFont;
  22.     origSize = win->txSize;
  23.     TextFont(helvetica);
  24.     TextFace(bold);
  25.     TextSize(14);
  26.  
  27.     SetupDragHiliteColor(win);
  28.     PaintRect(&(*win).portRect);
  29.     ForeColor(blackColor);
  30.  
  31.     MoveTo(10, 30);
  32.     DrawString("\pThis is the hilite color used for drags");
  33.  
  34.     TextFont(origFont);
  35.     TextSize(origSize);
  36.     TextFace(0);
  37. }
  38.  
  39.  
  40. /*-------------------------------------------------------------------------------------*/
  41.  
  42. pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin)
  43. {
  44. #pragma unused (pixelDepth, dFlags, theDevice)
  45.     GrafPtr        savePort;
  46.  
  47.     GetPort(&savePort);
  48.     SetPort((GrafPtr)theWin);
  49.  
  50.     DrawIt((WindowPtr)theWin);
  51.  
  52.     SetPort(savePort);
  53. }
  54.  
  55.  
  56. /*-------------------------------------------------------------------------------------*/
  57.  
  58. void CreateNewWindow(void)
  59. {
  60.     Rect winDimension;
  61.     
  62.     SetRect(&winDimension, 60, 60, 360, 160);
  63.     (void)NewCWindow(0L, &winDimension, "\pSample", true, noGrowDocProc,
  64.                             (WindowPtr)-1L, true, 0L);
  65. }
  66.  
  67.  
  68. /*-------------------------------------------------------------------------------------*/
  69.  
  70. void PreEventLoop(void)
  71. {
  72.     CreateNewWindow();
  73. }
  74.  
  75.  
  76. /*-------------------------------------------------------------------------------------*/
  77.  
  78. void DoUpdate(WindowPtr thisWindow)
  79. {
  80.     static DeviceLoopDrawingUPP    procForDeviceLoop = nil;
  81.  
  82.     SetPort(thisWindow);
  83.  
  84.     if ( procForDeviceLoop == nil )
  85.         procForDeviceLoop = NewDeviceLoopDrawingProc(DrawWindowContent);    
  86.     
  87.     BeginUpdate(thisWindow);
  88.     DeviceLoop(thisWindow->visRgn, procForDeviceLoop, (long)thisWindow, singleDevices);
  89.     EndUpdate(thisWindow);
  90. }
  91.  
  92.  
  93. /*-------------------------------------------------------------------------------------*/
  94.  
  95. void PostEventLoop(void)
  96. {
  97. }
  98.  
  99.