home *** CD-ROM | disk | FTP | other *** search
- /*~~~~~~~\_______________________________________________________/~~~~~~~~*\
- **********<<<<<<<<<<<<<<<<<<<|---={(~!~)}=---|>>>>>>>>>>>>>>>>>>>>**********
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * test.c 10/31/87
- *
- * This simple program opens an 8 color, HIRES (640*200) screen and a full
- * sized window to show the use of the "init_palette()", "palette()" and
- * "get_fname()" routines.
- *
- * It will let you modify/load/save color palettes, and is exited by
- * selecting "OKAY!" or "CANCEL!" on the color palette.
- *
- * See the file: palette.c for source of these routines and also for the
- * usage of: get_fname() (also included in this arc file as: getfile.c)
- *
- *---------------------------------------------------------------------------
- * To use the palette routines in your program, you need only declare two
- * external functions...
- *
- * extern void init_palette();
- * extern void palette();
- *
- * ...after opening your screen and window, (and a window->UserPort) you call
- * init_palette() with a pointer to your window and screen...
- *
- * init_palette(MyWindow,MyScreen);
- *
- * ...which sets up certain variables needed and then sets the colors to the
- * ones defined in: UBYTE def_colors[] (see: palette.c). Then to open the
- * "Color Palette" window, you call palette() with the same window, screen
- * pointers you used for init_palette()...
- *
- * palette(MyWindow,MyScreen);
- *
- * ...which will the take control of the program until the user is through
- * modifying/loading/saving the colors of your screen. (when he/she selects
- * "OKAY" or "CANCEL")
- *----------------------------------------------------------------------------
- *
- * To use the "File Requester" routine you will need to declare an external
- * function...
- *
- * extern UBYTE *get_fname();
- *
- * ...and set up one or more arrays to hold your "probable_file_name[]" and
- * one or more to hold your "probable_drive/path_name[]"...
- *
- * UBYTE color_file_name[] = "MyFile.Color";
- * UBYTE def_dir[] = "SYS:";
- *
- * ...then to open the "File Requester" (window), you...
- *
- * get_fname(MyWindow,MyScreen,"Title For Window",color_file_name,def_dir);
- *
- * ...you can then find the file name in "color_file_name[]". Or you can call
- * it by...
- *
- * fname = get_fname(MyWindow,MyScreen,"Title","file.color","SYS:").
- *
- * ...using the first method will keep your "color_file_name" and "def_dir"
- * updated for future calls.(See: palette.c for an example.)
- *
- *----------------------------------------------------------------------------
- *
- * These routines now compile using AZTEC 3.4a using 16 bit ints.
- * (makefile for MANX also included)
- *
- * Any bug reports/suggestions/fixes/etc... would be appreciated.
- *
- * I can be reached at: (703) 297-7639
- *
- * via E-MAIL-> GEnie: K.Young
- * CA-AUG: Keith Young
- * Deep Thought: Keith Young
- * COMPUSERVE: 73170,307
- *
- * via Snail-Mail-> Keith Young
- * Rt.2 Box 261
- * Goodview, Va. (yes, really :-)
- * 24095
- * ______________________________________________________
- \********<<<<<<<<<<<<<<<<<<<|---={(~!~)}=---|>>>>>>>>>>>>>>>>>>>>***********/
-
- #include <exec/types.h>
- #include <exec/devices.h>
- #include <intuition/intuition.h>
-
- #include <graphics/gels.h>
- #include <graphics/copper.h>
- #include <graphics/regions.h>
- #include <devices/keymap.h>
-
- extern void init_palette(),palette(); /* Color Palette routines */
-
- #define DPTH 3L /* Raster dimensions */
- #define WDTH 640L
- #define HGHT 200L
-
- #define NL 0L
-
- /* Font Descriptor */
- struct TextAttr MyFont = {
- (UBYTE *)"topaz.font",
- TOPAZ_EIGHTY,
- FS_NORMAL,
- FPF_ROMFONT
- };
-
- /* Used to open a Screen */
- struct NewScreen NewScreen = {
- 0,0,WDTH,HGHT,DPTH, /* Left,Top,Width,Height,Depth */
- 7,5,HIRES, /* DetailPen, BlockPen, ViewModes */
- CUSTOMSCREEN,&MyFont, /* Type, Font */
- (UBYTE *)"Palette/File Requester Tester by--------> Keith Young",/* Title */
- NL,NL }; /* Gadgets, BitMap */
-
- /* Used to open a Window */
- struct NewWindow NewWindow = {
- 0,0,WDTH,HGHT, /* LeftEdge,TopEdge,Width,Height */
- 7,0, /* DetailPen,BlockPen */
- MOUSEBUTTONS | MOUSEMOVE | MENUVERIFY | MENUPICK | GADGETUP |
- GADGETDOWN | CLOSEWINDOW | ACTIVEWINDOW,
- SMART_REFRESH | REPORTMOUSE | ACTIVATE | BACKDROP | BORDERLESS, /*Flags*/
- NL,NL,NL, /* FirstGadget, CheckMark, Title */
- NL, /* MUST SET SCREEN AFTER OPENSCREEN!!! */
- NL, /* BitMap */
- 100,60,32767,32767, /* MinW, MinH, MaxW, MaxH */
- CUSTOMSCREEN }; /* Type */
-
-
- /******* Variables Initialized by open_stuff() **********/
-
- struct IntuitionBase *IntuitionBase = NL;
- struct GfxBase *GfxBase = NL;
- extern UBYTE *OpenLibrary();
- extern struct Screen *OpenScreen();
- extern struct Window *OpenWindow();
- struct Screen *p_S;
- struct Window *p_W;
-
- /************************************************************
- * open_stuff()
- *
- * Opens screen and full-sized window for program.
- *
- * Initializes handles p_S,p_W
- *
- * See also: close_stuff()
- *************************************************************/
-
- open_stuff()
- {
- if ( ! (IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",0L)) ||
- ! (GfxBase =(struct GfxBase *)OpenLibrary("graphics.library",0L)) )
- exit(20);
-
- if ( ! (p_S =(struct Screen *)OpenScreen(&NewScreen)) )
- {
- printf("\tCan't Open Screen!\n Call Your Local Dealer and Buy More Mem!\n");
- exit(21);
- }
-
- NewWindow.Screen = p_S; /* NEED TO SET SCREEN!!! */
-
- if ( ! (p_W =(struct Window *)OpenWindow(&NewWindow)) )
- {
- CloseScreen(p_S);
- printf("This is not good.\n");
- exit(22);
- }
- }
-
- /*************************************************
- * close_stuff()
- *
- * Cleans up what was allocated by open_stuff()
- *************************************************/
-
- void close_stuff()
- {
- CloseWindow(p_W);
- CloseScreen(p_S);
- CloseLibrary(GfxBase);
- CloseLibrary(IntuitionBase);
- }
-
- /*****************************************************************
- * main()
- *
- * open_stuff, initialize_the_palette, call_the_palette_routine,
- * close_stuff and_then_exit.
- ****************************************************************/
-
- void main()
- {
- open_stuff();
- init_palette(p_W,p_S);
- palette(p_W,p_S);
- close_stuff();
- exit(1);
- }
-
- /*** End of Palette/File Requester Tester (test.c) ***/
-