home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d9xx
/
d913
/
stickit.lha
/
StickIt
/
Source
/
Source.lha
/
stickit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
12KB
|
444 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Andy Dean
*/
#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 "stickit.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = "Workbench";
APTR VisualInfo = NULL;
struct Window *editWnd = NULL;
struct Window *aboutWnd = NULL;
struct Window *dummynoteWnd = NULL;
struct Gadget *editGList = NULL;
struct Menu *editMenus = NULL;
struct IntuiMessage editMsg;
struct IntuiMessage aboutMsg;
struct IntuiMessage dummynoteMsg;
struct Gadget *editGadgets[10];
UWORD editLeft = 97;
UWORD editTop = 84;
UWORD editWidth = 444;
UWORD editHeight = 56;
UWORD aboutLeft = 268;
UWORD aboutTop = 96;
UWORD aboutWidth = 92;
UWORD aboutHeight = 37;
UWORD dummynoteLeft = 189;
UWORD dummynoteTop = 53;
UWORD dummynoteWidth = 208;
UWORD dummynoteHeight = 146;
UBYTE *editWdt = (UBYTE *)"Edit notes";
UBYTE *aboutWdt = NULL;
UBYTE *dummynoteWdt = NULL;
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct NewMenu editNewMenu[] = {
NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Open", (STRPTR)"O", 0, 0L, (APTR)editopen,
NM_ITEM, (STRPTR)"Save", (STRPTR)"S", 0, 0L, (APTR)editsave,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"About", (STRPTR)"A", 0, 0L, (APTR)editabout,
NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, (APTR)editquit,
NM_TITLE, (STRPTR)"Edit", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Cut", (STRPTR)"X", 0, 0L, (APTR)editcut,
NM_ITEM, (STRPTR)"Copy", (STRPTR)"C", 0, 0L, (APTR)editcopy,
NM_ITEM, (STRPTR)"Paste", (STRPTR)"V", 0, 0L, (APTR)editpaste,
NM_ITEM, (STRPTR)"Delete", (STRPTR)"B", 0, 0L, (APTR)editdelete,
NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
NM_ITEM, (STRPTR)"Show notes...", (STRPTR)"N", 0, 0L, (APTR)editshownotes,
NM_END, NULL, NULL, 0, 0L, NULL };
UWORD editGTypes[] = {
STRING_KIND,
STRING_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND,
CHECKBOX_KIND,
NUMBER_KIND,
BUTTON_KIND
};
struct NewGadget editNGad[] = {
55, 4, 237, 13, (UBYTE *)"_Title", NULL, GD_title, PLACETEXT_LEFT, NULL, (APTR)titleClicked,
55, 21, 378, 13, (UBYTE *)"_Note", NULL, GD_note, PLACETEXT_LEFT, NULL, (APTR)noteClicked,
92, 38, 49, 13, (UBYTE *)"_Front", NULL, GD_tostart, PLACETEXT_IN, NULL, (APTR)tostartClicked,
145, 38, 49, 13, (UBYTE *)"_<", NULL, GD_prev, PLACETEXT_IN, NULL, (APTR)prevClicked,
198, 38, 49, 13, (UBYTE *)"_>", NULL, GD_next, PLACETEXT_IN, NULL, (APTR)nextClicked,
251, 38, 49, 13, (UBYTE *)"_Back", NULL, GD_toend, PLACETEXT_IN, NULL, (APTR)toendClicked,
304, 38, 49, 13, (UBYTE *)"_Add", NULL, GD_add, PLACETEXT_IN, NULL, (APTR)addClicked,
55, 39, 26, 11, (UBYTE *)"_Show", NULL, GD_show, PLACETEXT_LEFT, NULL, (APTR)showClicked,
381, 4, 52, 13, (UBYTE *)"No. notes", NULL, GD_notetotal, PLACETEXT_LEFT, NULL, NULL,
357, 38, 76, 13, (UBYTE *)"Notes...", NULL, GD_notes, PLACETEXT_IN, NULL, (APTR)notesClicked
};
ULONG editGTags[] = {
(GTST_MaxChars), 29, (GT_Underscore), '_', (TAG_DONE),
(GTST_MaxChars), 255, (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GTNM_Border), TRUE, (TAG_DONE),
(TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
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;
}
}
int HandleeditIDCMP( void )
{
struct IntuiMessage *m;
struct MenuItem *n;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( editWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&editMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( editMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( editWnd );
GT_EndRefresh( editWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = editCloseWindow();
break;
case IDCMP_VANILLAKEY:
running = editVanillaKey();
break;
case IDCMP_CHANGEWINDOW:
running = editChangeWindow();
break;
case IDCMP_GADGETUP:
case IDCMP_GADGETDOWN:
func = ( void * )(( struct Gadget * )editMsg.IAddress )->UserData;
running = func();
break;
case IDCMP_MENUPICK:
while( editMsg.Code != MENUNULL ) {
n = ItemAddress( editMenus, editMsg.Code );
func = (void *)(GTMENUITEM_USERDATA( n ));
running = func();
editMsg.Code = n->NextSelect;
}
break;
}
}
return( running );
}
int OpeneditWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = editLeft, wtop = editTop, ww, wh;
ComputeFont( editWidth, editHeight );
ww = ComputeX( editWidth );
wh = ComputeY( editHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &editGList )))
return( 1L );
for( lc = 0, tc = 0; lc < edit_CNT; lc++ ) {
CopyMem((char * )&editNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
editGadgets[ lc ] = g = CreateGadgetA((ULONG)editGTypes[ lc ], g, &ng, ( struct TagItem * )&editGTags[ tc ] );
while( editGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( editMenus = CreateMenus( editNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( editMenus, VisualInfo, TAG_DONE );
if ( ! ( editWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|NUMBERIDCMP|IDCMP_GADGETDOWN|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_CHANGEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_SIMPLE_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, editGList,
WA_Title, editWdt,
WA_ScreenTitle, "StickIt V1.02 2nd August '93 ©1993 Andy Dean",
WA_AutoAdjust, TRUE,
TAG_DONE )))
return( 4L );
SetMenuStrip( editWnd, editMenus );
GT_RefreshWindow( editWnd, NULL );
return( 0L );
}
void CloseeditWindow( void )
{
if ( editMenus ) {
ClearMenuStrip( editWnd );
FreeMenus( editMenus );
editMenus = NULL; }
if ( editWnd ) {
CloseWindow( editWnd );
editWnd = NULL;
}
if ( editGList ) {
FreeGadgets( editGList );
editGList = NULL;
}
}
int HandleaboutIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( aboutWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&aboutMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( aboutMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( aboutWnd );
GT_EndRefresh( aboutWnd, TRUE );
break;
case IDCMP_MOUSEBUTTONS:
running = aboutMouseButtons();
break;
break;
}
}
return( running );
}
int OpenaboutWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = aboutLeft, wtop = aboutTop, ww, wh;
ComputeFont( aboutWidth, aboutHeight );
ww = ComputeX( aboutWidth );
wh = ComputeY( aboutHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( aboutWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, IDCMP_MOUSEBUTTONS|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_SMART_REFRESH,
WA_Title, aboutWdt,
WA_ScreenTitle, "StickIt V1.02 2nd August '93 ©1993 Andy Dean",
TAG_DONE )))
return( 4L );
GT_RefreshWindow( aboutWnd, NULL );
return( 0L );
}
void CloseaboutWindow( void )
{
if ( aboutWnd ) {
CloseWindow( aboutWnd );
aboutWnd = NULL;
}
}
int HandledummynoteIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
while( m = GT_GetIMsg( dummynoteWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&dummynoteMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( dummynoteMsg.Class ) {
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( dummynoteWnd );
GT_EndRefresh( dummynoteWnd, TRUE );
break;
case IDCMP_CHANGEWINDOW:
running = dummynoteChangeWindow();
break;
case IDCMP_MOUSEBUTTONS:
running = dummynoteMouseButtons();
break;
break;
}
}
return( running );
}
int OpendummynoteWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = dummynoteLeft, wtop = dummynoteTop, ww, wh;
ComputeFont( dummynoteWidth, dummynoteHeight );
ww = ComputeX( dummynoteWidth );
wh = ComputeY( dummynoteHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( dummynoteWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, IDCMP_MOUSEBUTTONS|IDCMP_CHANGEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH|WFLG_SIMPLE_REFRESH|WFLG_RMBTRAP,
WA_Title, dummynoteWdt,
WA_ScreenTitle, "StickIt V0.00 ©1993 Andy Dean",
TAG_DONE )))
return( 4L );
GT_RefreshWindow( dummynoteWnd, NULL );
return( 0L );
}
void ClosedummynoteWindow( void )
{
if ( dummynoteWnd ) {
CloseWindow( dummynoteWnd );
dummynoteWnd = NULL;
}
}