DrawCode.c

/*
    File:       DrawCode.c
 
    Contains:   This shows how to obtain the color that the Drag Manager uses to
                hilite regions when ShowDragHilite is called.  Check out GetDragHilite.c
                for the code.  
 
                Please note this is only how it's done presently.  Since it is undocumented
                it can and will change in the future.
 
    Written by: Nitin Ganatra   
 
    Copyright:  Copyright © 1994-1999 by Apple Computer, Inc., All Rights Reserved.
    
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
#include <Windows.h>
#include <QuickDraw.h>
#include <TextUtils.h>
#include <Fonts.h>
 
extern void SetupDragHiliteColor(WindowPtr);
void DrawIt(WindowPtr win);
pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin);
void MyCreateNewWindow(void);
void PreEventLoop(void);
void DoUpdate(WindowPtr thisWindow);
void PostEventLoop(void);
 
 
/*-------------------------------------------------------------------------------------*/
 
void DrawIt(WindowPtr win)
{
    short       origFont, origSize;
    
    origFont = win->txFont;
    origSize = win->txSize;
    TextFont(kFontIDHelvetica);
    TextFace(bold);
    TextSize(14);
 
    SetupDragHiliteColor(win);
    PaintRect(&(*win).portRect);
    ForeColor(blackColor);
 
    MoveTo(10, 30);
    DrawString("\pThis is the hilite color used for drags");
 
    TextFont(origFont);
    TextSize(origSize);
    TextFace(0);
}
 
 
/*-------------------------------------------------------------------------------------*/
 
pascal void DrawWindowContent(short pixelDepth, short dFlags, GDHandle theDevice, long theWin)
{
#pragma unused (pixelDepth, dFlags, theDevice)
    GrafPtr     savePort;
 
    GetPort(&savePort);
    SetPort((GrafPtr)theWin);
 
    DrawIt((WindowPtr)theWin);
 
    SetPort(savePort);
}
 
 
/*-------------------------------------------------------------------------------------*/
 
void MyCreateNewWindow(void)
{
    Rect winDimension;
    
    SetRect(&winDimension, 60, 60, 360, 160);
    (void)NewCWindow(0L, &winDimension, "\pSample", true, noGrowDocProc,
                            (WindowPtr)-1L, true, 0L);
}
 
 
/*-------------------------------------------------------------------------------------*/
 
void PreEventLoop(void)
{
    MyCreateNewWindow();
}
 
 
/*-------------------------------------------------------------------------------------*/
 
void DoUpdate(WindowPtr thisWindow)
{
    static DeviceLoopDrawingUPP procForDeviceLoop = nil;
 
    SetPort(thisWindow);
 
    if ( procForDeviceLoop == nil )
        procForDeviceLoop = NewDeviceLoopDrawingProc(DrawWindowContent);    
    
    BeginUpdate(thisWindow);
    DeviceLoop(thisWindow->visRgn, procForDeviceLoop, (long)thisWindow, singleDevices);
    EndUpdate(thisWindow);
}
 
 
/*-------------------------------------------------------------------------------------*/
 
void PostEventLoop(void)
{
}