home *** CD-ROM | disk | FTP | other *** search
-
- /* UsePointer.c */
- /* This is an example program to show how to use the pointer.library */
- /* Any portion of this program may be used freely */
- /* by Luke Wood -- BIX: luke.wood */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <exec/exec.h>
- #include <proto/exec.h>
- #include <intuition/intuition.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include "Pointer.h"
- #include "Pointer_proto.h"
- #include "Pointer_pragmas.h"
- #include <error.h>
-
- struct NewWindow MyNewWindow =
- {
- 0,0,300,100,
- 0,1,
- MOUSEBUTTONS | CLOSEWINDOW,
- ACTIVATE | NOCAREREFRESH | WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | WINDOWSIZING,
- NULL,NULL,
- "MyWindow",
- NULL,NULL,
- 25,20,32767,32767,
- WBENCHSCREEN
- };
-
- struct IntuitionBase *IntuitionBase = NULL;
- struct Library* PointerBase;
- struct Pointer* CrossHair;
-
- int main( int argc, char** argv );
- int main( int argc, char** argv )
- {
- int done;
- int class;
- int code;
- int busy;
- struct Window* MyWindow;
- struct IntuiMessage* mesg;
- int X, Y;
-
- busy = 0;
- done = FALSE;
- GfxBase = (struct GfxBase *)
- OpenLibrary( "graphics.library", 33L );
- if( GfxBase == NULL )
- {
- printf( "Graphics Open failed\n" );
- goto end;
- }
-
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary( "intuition.library", 33L );
- if( IntuitionBase == NULL )
- {
- printf( "Intuition Open failed\n" );
- goto end;
- }
-
-
- /* Open the Pointer library */
-
- PointerBase = OpenLibrary( "pointer.library", 33L );
- printf( "result of InitPointerLib = %d.\n", PointerBase );
- if( PointerBase == NULL )
- {
- printf( "Pointer Library failed to open\n" );
- goto end;
- }
-
- /* Load a Custom Pointer */
- /*CrossHair = LoadPointer( "SYS:Prefs/presets/CrossHair.ilbm" );*/
- CrossHair = LoadPointer( "Pointer.ilbm" );
-
- MyWindow = OpenWindow( &MyNewWindow );
- if( MyWindow == NULL )
- {
- printf( "Window failed to open" );
- goto end;
- }
-
- SetAPen( MyWindow->RPort, 1 );
- Move( MyWindow->RPort, 0,50 );
- Draw( MyWindow->RPort, 300,50 );
- Move( MyWindow->RPort, 150,0 );
- Draw( MyWindow->RPort, 150,100 );
-
- Move( MyWindow->RPort, 190, 33 );
- Text( MyWindow->RPort, "Normal", 6 );
- Move( MyWindow->RPort, 52, 80 );
- Text( MyWindow->RPort, "Normal", 6 );
- Move( MyWindow->RPort, 55, 32 );
- Text( MyWindow->RPort, "Busy", 4 );
- Move( MyWindow->RPort, 180, 80 );
- Text( MyWindow->RPort, "CrossHair", 9 );
-
- while( !done )
- {
- Wait( 1 << MyWindow->UserPort->mp_SigBit );
- mesg = (struct IntuiMessage*)GetMsg( MyWindow->UserPort );
- if( mesg )
- {
- class = mesg->Class;
- code = mesg->Code;
- X = mesg->MouseX-150;
- Y = mesg->MouseY-50;
- ReplyMsg( (struct Message*)mesg );
- if( class == CLOSEWINDOW )
- {
- printf( "message CLOSEWINDOW.\n" );
- done = TRUE;
- }
- else
- {
- if( code == SELECTDOWN )
- {
- printf( "X:%d, Y:%d\n", X, Y );
-
- if( (X*Y) < 0 )
- {
- printf( "Normal Pointer\n" );
- ClearPointer( MyWindow );
- continue;
- }
- if( X < 0 )
- {
- printf( "Busy Pointer\n" );
- SetBusyPointer( MyWindow );
- }
- else
- {
- /* Ask Intuition to Turn on the */
- /* custom Pointer we Loaded earlier */
- if( CrossHair )
- {
- printf( "CrossHair Pointer\n" );
- SetPointer( MyWindow, CrossHair->Data,
- CrossHair->Height, CrossHair->Width,
- CrossHair->XOff, CrossHair->YOff );
- }
- }
- }
- }
- }
- }
-
- end:
- if( CrossHair )
- FreePointer( CrossHair );
- if( MyWindow )
- CloseWindow( MyWindow );
- if( PointerBase )
- CloseLibrary( PointerBase );
- if( IntuitionBase )
- CloseLibrary( (struct Library*)IntuitionBase );
- }
-
-