home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
util
/
cdity
/
colorsaver
/
src
/
gadgets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-28
|
7KB
|
240 lines
/*
* Source machine generated by GadToolsBox V1.4
* which is (c) Copyright 1991,92 Jaba Development
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <clib/diskfont_protos.h>
#include "gadgets.h"
extern struct Screen *Scr;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *ColorSaverWnd = NULL;
struct Gadget *ColorSaverGList = NULL;
struct TextFont *Font = NULL;
struct Gadget *ColorSaverGadgets[25];
extern UWORD ColorSaverLeft;
extern UWORD ColorSaverTop;
UWORD ColorSaverWidth = 319;
UWORD ColorSaverHeight = 102;
UBYTE *ColorSaverWdt;
UBYTE *CYCLE_GAD0Labels[] = {
(UBYTE *)"-------",
NULL };
UBYTE *RGBHSV_GAD0Labels[] = {
(UBYTE *)"RGB",
(UBYTE *)"HSV",
NULL };
struct TextAttr topaz8 = {
( STRPTR )"topaz.font", 8, 0x00, 0x00 };
UWORD ColorSaverGTypes[] = {
PALETTE_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
CYCLE_KIND,
BUTTON_KIND,
SLIDER_KIND,
SLIDER_KIND,
SLIDER_KIND,
MX_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
TEXT_KIND,
BUTTON_KIND,
TEXT_KIND,
TEXT_KIND,
TEXT_KIND
};
struct NewGadget ColorSaverNGad[] = {
177, 2, 132, 37, NULL, NULL, GD_PALETTE_GAD, 0, NULL, NULL,
156, 40, 49, 13, (UBYTE *)"Copy", NULL, GD_COPY_GAD, PLACETEXT_IN, NULL, NULL,
207, 40, 49, 13, (UBYTE *)"Swap", NULL, GD_SWAP_GAD, PLACETEXT_IN, NULL, NULL,
205, 85, 45, 13, (UBYTE *)"_UnDO", NULL, GD_RESET_GAD, PLACETEXT_IN, NULL, NULL,
2, 40, 46, 13, (UBYTE *)"_Load", NULL, GD_LOAD_GAD, PLACETEXT_IN, NULL, NULL,
50, 40, 46, 13, (UBYTE *)"_Save", NULL, GD_SAVE_GAD, PLACETEXT_IN, NULL, NULL,
2, 85, 57, 13, (UBYTE *)"_Okay", NULL, GD_OKAY_GAD, PLACETEXT_IN, NULL, NULL,
252, 85, 57, 13, (UBYTE *)"_Cancel", NULL, GD_CANCEL_GAD, PLACETEXT_IN, NULL, NULL,
2, 55, 104, 13, (UBYTE *)"Scan Binary", NULL, GD_SCAN_GAD, PLACETEXT_IN, NULL, NULL,
2, 70, 104, 13, (UBYTE *)" ", NULL, GD_CYCLE_GAD, PLACETEXT_LEFT, NULL, NULL,
98, 40, 55, 13, (UBYTE *)"Write", NULL, GD_WRITE_GAD, PLACETEXT_IN, NULL, NULL,
13, 2, 131, 11, NULL, NULL, GD_RED_GAD, 0, NULL, NULL,
13, 15, 131, 11, NULL, NULL, GD_GREEN_GAD, 0, NULL, NULL,
13, 28, 131, 11, NULL, NULL, GD_BLUE_GAD, 0, NULL, NULL,
164, 75, 17, 9, NULL, NULL, GD_RGBHSV_GAD, PLACETEXT_LEFT, NULL, NULL,
61, 85, 45, 13, (UBYTE *)"DO", NULL, GD_DO_GAD, PLACETEXT_IN, NULL, NULL,
156, 55, 41, 13, (UBYTE *)"««·", NULL, GD_SLEFT_GAD, PLACETEXT_IN, NULL, NULL,
268, 55, 41, 13, (UBYTE *)"·»»", NULL, GD_SRIGHT_GAD, PLACETEXT_IN, NULL, NULL,
205, 70, 104, 13, (UBYTE *)"Complement", NULL, GD_COMP_GAD, PLACETEXT_IN, NULL, NULL,
109, 55, 44, 13, (UBYTE *)"©", NULL, GD_EXTRA_GAD, PLACETEXT_IN, NULL, NULL,
200, 55, 64, 13, NULL, NULL, GD_SHIFT_GAD, 0, NULL, NULL,
258, 40, 51, 13, (UBYTE *)"Range", NULL, GD_RANGE_GAD, PLACETEXT_IN, NULL, NULL,
2, 15, 16, 11, NULL, NULL, GD_RGBG_GAD, 0, NULL, NULL,
2, 28, 16, 11, NULL, NULL, GD_RGBB_GAD, 0, NULL, NULL,
2, 2, 16, 11, NULL, NULL, GD_RGBR_GAD, 0, NULL, NULL
};
ULONG ColorSaverGTags[] = {
(GTPA_Depth), 2, (GTPA_IndicatorWidth), 20, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(TAG_DONE),
(GTCY_Labels), (ULONG)&CYCLE_GAD0Labels[ 0 ],(GA_Disabled), TRUE, (TAG_DONE),
(GA_Disabled), TRUE, (TAG_DONE),
(GTSL_MaxLevelLen), 5, (GTSL_LevelFormat), (ULONG)"%03ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GTSL_MaxLevelLen), 5, (GTSL_LevelFormat), (ULONG)"%03ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GTSL_MaxLevelLen), 5, (GTSL_LevelFormat), (ULONG)"%03ld", (GTSL_LevelPlace), (PLACETEXT_RIGHT), (PGA_Freedom), LORIENT_HORIZ, (GA_RelVerify), TRUE, (TAG_DONE),
(GTMX_Labels), (ULONG)&RGBHSV_GAD0Labels[ 0 ], (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GTTX_Text), (ULONG)" Shift", (GTTX_Border), TRUE, (TAG_DONE),
(TAG_DONE),
(GTTX_Text), (ULONG)"G", (TAG_DONE),
(GTTX_Text), (ULONG)"B", (TAG_DONE),
(GTTX_Text), (ULONG)"R", (TAG_DONE)
};
int SetupScreen( void )
{
if ( ! ( Font = OpenDiskFont( &topaz8 )))
return( 5L );
/* if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );*/
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
/* UnlockPubScreen( NULL, Scr ); */
Scr = NULL;
}
if ( Font ) {
CloseFont( Font );
Font = NULL;
}
}
void ColorSaverRender( void )
{
UWORD offx, offy;
offx = ColorSaverWnd->BorderLeft;
offy = ColorSaverWnd->BorderTop;
DrawBevelBox( ColorSaverWnd->RPort, offx + 109, offy + 70, 93, 28, GT_VisualInfo, VisualInfo, TAG_DONE );
}
int OpenColorSaverWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
ColorSaverGTags[1] = Scr->BitMap.Depth;
if ( ! ( g = CreateContext( &ColorSaverGList )))
return( 1L );
for( lc = 0, tc = 0; lc < ColorSaver_CNT; lc++ ) {
CopyMem((char * )&ColorSaverNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = &topaz8;
ng.ng_LeftEdge += offx;
ng.ng_TopEdge += offy;
ColorSaverGadgets[ lc ] = g = CreateGadgetA((ULONG)ColorSaverGTypes[ lc ], g, &ng, ( struct TagItem * )&ColorSaverGTags[ tc ] );
while( ColorSaverGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( ColorSaverWnd = OpenWindowTags( NULL,
WA_Left, ColorSaverLeft,
WA_Top, ColorSaverTop,
WA_Width, ColorSaverWidth,
WA_Height, ColorSaverHeight + offy,
WA_IDCMP, PALETTEIDCMP|BUTTONIDCMP|CYCLEIDCMP|SLIDERIDCMP|MXIDCMP|TEXTIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_CHANGEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH,
WA_Gadgets, ColorSaverGList,
WA_Title, ColorSaverWdt,
WA_ScreenTitle, "ColorSaver © 1993 by Dan Fish",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( ColorSaverWnd, NULL );
ColorSaverRender();
return( 0L );
}
void CloseColorSaverWindow( void )
{
if ( ColorSaverWnd ) {
CloseWindow( ColorSaverWnd );
ColorSaverWnd = NULL;
}
if ( ColorSaverGList ) {
FreeGadgets( ColorSaverGList );
ColorSaverGList = NULL;
}
}