1
0
mirror of https://github.com/antoinevignau/source.git synced 2025-03-05 03:29:50 +00:00

1 line
6.4 KiB
C
Raw Normal View History

2024-08-15 21:27:35 +02:00
/********************************************************************** * * Event.c * * Copyright (c) * Apple Computer, Inc. 1986-1989 * All Rights Reserved. * * This file contains the code which implements the * main event loop used by the scanner program. * **********************************************************************/ #include <types.h> #include <locator.h> #include <quickdraw.h> #include <event.h> #include <menu.h> #include <window.h> #include "Scan.h" extern WmTaskRec event; extern unsigned int quitFlag; extern GrafPortPtr previewWindowPtr; extern GrafPortPtr settingsWindowPtr; static GrafPortPtr lastWindow; /* This private global is used in checkFrontW() ** to prevent extra work when the windows ** have not changed. It is initialized ** at the beginning of mainEvent(). */ /********************************************************************** * * doSetPageScroll * * This procedure is called when an inGrow or inZoom message is returned * by TaskMaster. * * This procedure resets the values used to scroll the content region * when the page areas are clicked on in the scroll bars. * ***********************************************************************/ static void doSetPageScroll() { int tempH, tempV; tempV = lastWindow->portRect.v2-lastWindow->portRect.v1; /* calculate vertical size */ tempH = lastWindow->portRect.h2-lastWindow->portRect.h1; /* calculate width */ SetPage(tempH-10, tempV-10, lastWindow); } /********************************************************************** * * doControls * * This procedure is called when an inControl message is returned * by TaskMaster. * * When this routine gets control, the ID of the control that was * hit is in TaskDATA4. The control handle is in TaskData2 and * the part code is in taskData 3. * **********************************************************************/ void doControls() { LongWord theID, thePartCode; LongWord theControlHandle; theID = event.wmTaskData4; thePartCode = event.wmTaskData3; theControlHandle = event.wmTaskData2; if (( 0 <= theID) && (theID <= 0xFFFFFFFF )) { switch(theID) { case ScanButton: doScanButton(); break; case PreviewButton: doPreviewButton(); break; } } } /********************************************************************** * * doInContent * * This procedure is called when an InContent message is returned * by TaskMaster. * * When this routine gets control, the ID of the control that was * hit is in TaskDATA4. The control handle is in TaskData2 and * the part code is in taskData 3. * **********************************************************************/ void doInContent() { LongWord theID, thePartCode; LongWord theControlHandle; theID = event.wmTaskData4; thePartCode = event.wmTaskData3; theControlHandle = event.wmTaskData2; SelectWindow(event.wmTaskData); #if 0 if (event.what == 0x01) { /* was it a mouse down event? */ if ((GrafPortPtr) event.wmTaskData == previewWindowPtr){ doInPreview(event.where); } } #endif } /********************************************************************** * * checkFrontW * * This routine checks the front window to see if any changes need * to be made to the menu items. * * We do this so that the edit items are only active when a desk * accessory is active. * **********************************************************************/ void checkFrontW() { GrafPortPtr theWindow; extern int cTable[], defCTable[]; theWindow = FrontWindow(); /* Get the front window into local storage.*/ if (theWindow == lastWindow) return; /* If the lastWindow is this window, we are all set. */ /* If there are no windows, everything should be disabled */ if (!theWindow) { SetMenuFlag(0x0080, EditMenuID); HiliteMenu(0,EditMenuID); SetColor