home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / intuition / windows / borderless.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  4.8 KB  |  164 lines

  1.  
  2. /* borderless.c - Opens a borderless backdrop window, writes a message. */
  3. /* Compiled with Lattice C v5.02                                     */
  4. /* Compiler invoked with: lc -b1 -cfist -L -v -w                     */
  5.  
  6. /* Copyright (c) 1990 Commodore-Amiga, Inc.
  7.  *
  8.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  9.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  10.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  11.  * information on the correct usage of the techniques and operating system
  12.  * functions presented in this example.  The source and executable code of
  13.  * this example may only be distributed in free electronic form, via bulletin
  14.  * board or as part of a fully non-commercial and freely redistributable
  15.  * diskette.  Both the source and executable code (including comments) must
  16.  * be included, without modification, in any copy.  This example may not be
  17.  * published in printed form or distributed with any commercial product.
  18.  * However, the programming techniques and support routines set forth in
  19.  * this example may be used in the development of original executable
  20.  * software products for Commodore Amiga computers.
  21.  * All other rights reserved.
  22.  * This example is provided "as-is" and is subject to change; no warranties
  23.  * are made.  All use is at your own risk.  No liability or responsibility
  24.  * is assumed.
  25.  */
  26.  
  27. #include <exec/types.h>
  28. #include <intuition/intuition.h>
  29. #include <libraries/dos.h>
  30. #ifdef LATTICE
  31. #include <proto/all.h>
  32. #include <stdlib.h>
  33. int CXBRK(void) {return(0);}
  34. #endif
  35.  
  36. /* Include user-written header files here.  */
  37. #include "hires.h"
  38. #include "agateWindow.h"
  39. #include "hellotext.h"
  40.  
  41. /* Use lowest non-obselete version that supplies the functions you need. */
  42. #define INTUITION_REV 33
  43. #define GRAPHICS_REV  33
  44.  
  45. /* TICKS_PER_SECOND is defined in libraries/dos.h
  46.    NEVER call Delay() with an argument of 0 !
  47. */
  48. #define PAUSE(seconds)    (Delay((seconds) * TICKS_PER_SECOND))
  49.  
  50. extern VOID cleanExit( struct Screen *, struct Window *, int );
  51.  
  52. struct IntuitionBase *IntuitionBase = NULL;
  53. struct GfxBase *GfxBase = NULL;
  54.  
  55. /* The next two declarations are for redirecting system requesters. */
  56. struct Process *myProcess = NULL;
  57. APTR oldwindowptr = NULL;
  58.  
  59.         
  60. VOID main(int argc, char *argv[])
  61. {
  62.     /* Declare variables here */
  63.     SHORT i;
  64.     SHORT txWidth;
  65.     struct Screen *screen1 = NULL;
  66.     struct Window *window1 = NULL;
  67.  
  68.  
  69.     /* Save the old window pointer now, so that cleanExit() has it
  70.      * if it needs it.
  71.      */
  72.     oldwindowptr = myProcess->pr_WindowPtr;
  73.  
  74.     /* Open the Intuition Library */
  75.     IntuitionBase = (struct IntuitionBase *)
  76.                     OpenLibrary( "intuition.library",INTUITION_REV );
  77.  
  78.     if (IntuitionBase == NULL)
  79.         cleanExit(screen1, window1, RETURN_WARN);
  80.  
  81.  
  82.     /* Open any other required libraries */
  83.     GfxBase = (struct GfxBase *)
  84.                      OpenLibrary("graphics.library",GRAPHICS_REV);
  85.  
  86.     if (GfxBase == NULL)
  87.         cleanExit(screen1, window1, RETURN_WARN);
  88.  
  89.  
  90.     /* Open the screen */
  91.     screen1 = OpenScreen(&fullHires);
  92.     if (screen1 == NULL)
  93.         cleanExit(screen1, window1, RETURN_WARN);
  94.  
  95.  
  96.     /* Attach the window to the open screen ... */
  97.     agateWindow.Screen = screen1;
  98.  
  99.  
  100.     /* Conceal the screen title */
  101.     ShowTitle( screen1, (BOOL)FALSE );
  102.  
  103.  
  104.     /* ... and open the window */
  105.     window1 = OpenWindow(&agateWindow);
  106.     if (window1 == NULL)
  107.         cleanExit(screen1, window1, RETURN_WARN);
  108.  
  109.  
  110.     /* Now is the time to redirect system requesters. */
  111.     myProcess = (struct Process *)FindTask(NULL);   /* Finds our process */
  112.     myProcess->pr_WindowPtr = (APTR)window1;
  113.  
  114.  
  115.     /* Write at the top edge of the window                */
  116.     /* Get the text width to space the greeting properly. */
  117.     txWidth = IntuiTextLength(&hello);
  118.  
  119.  
  120.     /* Print text five times, one pixel down from the top. */
  121.     for ( i = 0; i < 5; i++ )
  122.         PrintIText( window1->RPort, &hello, i*txWidth, 1 );
  123.  
  124.     PAUSE( 6 );
  125.  
  126.     /* Set up the signals that you want to hear about ... */
  127.     /* No signals in this program                         */
  128.  
  129.  
  130.     /* Exit the program */
  131.     cleanExit(screen1, window1, RETURN_OK);
  132.  
  133.  
  134. }
  135.  
  136. VOID cleanExit( scrn, wind, returnValue )
  137. struct Screen *scrn;
  138. struct Window *wind;
  139. int returnValue;
  140. {
  141.     /* Close things in the reverse order of opening */
  142.  
  143.  
  144.     /* Restore the old window pointer to our process. */
  145.     /* Don't test 'oldwindowptr', since NULL is a valid
  146.      * value for pr_WindowPtr.
  147.      */
  148.     myProcess->pr_WindowPtr = oldwindowptr;
  149.  
  150.     /* Close the window and screen. */
  151.     if (wind) CloseWindow( wind );
  152.     if (scrn) CloseScreen( scrn );
  153.  
  154.  
  155.     /* Close the library, and then exit */
  156.     if (GfxBase) CloseLibrary( (struct Library *)GfxBase );
  157.     if (IntuitionBase) CloseLibrary( (struct Library *)IntuitionBase );
  158.  
  159.  
  160.     exit(returnValue);
  161.  
  162. }
  163.  
  164.