home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 8
/
amigaformatcd08.iso
/
screenplay
/
shareware
/
pnp098
/
modules
/
testmod0.e
< prev
next >
Wrap
Text File
|
1996-09-18
|
5KB
|
168 lines
/* E Source generated by SRCGEN v0.1 */
/* Simple example of a PNP-module by A.Koch */
OPT OSVERSION=37
MODULE 'gadtools','libraries/gadtools','intuition/intuition',
'intuition/screens', 'intuition/gadgetclass', 'graphics/text'
ENUM NONE,NOCONTEXT,NOGADGET,NOSCREEN,NOVISUAL,OPENGT,NOWINDOW,NOMENUS
DEF testmodwnd:PTR TO window,
testmodglist,
infos:PTR TO gadget,
scr:PTR TO screen,
visual=NIL,
offx,offy,tattr:PTR TO textattr,
insclicked,dataptr,closed,strgad:PTR TO gadget
PROC setupscreen()
IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN RETURN OPENGT
IF (scr:=LockPubScreen('PNP'))=NIL THEN RETURN NOSCREEN
IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN NOVISUAL
offy:=scr.wbortop+Int(scr.rastport+58)-10
ENDPROC
PROC closedownscreen()
IF visual THEN FreeVisualInfo(visual)
IF scr THEN UnlockPubScreen(NIL,scr)
IF gadtoolsbase THEN CloseLibrary(gadtoolsbase)
ENDPROC
PROC opentestmodwindow()
DEF g:PTR TO gadget
IF (g:=CreateContext({testmodglist}))=NIL THEN RETURN NOCONTEXT
IF (g:=CreateGadgetA(STRING_KIND,g,
[offx+75,offy+26,284,20,'Text',tattr,0,1,visual,0]:newgadget,
[GTST_MAXCHARS,256,
NIL]))=NIL THEN RETURN NOGADGET
strgad:=g
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+38,offy+65,105,17,'Insert',tattr,1,16,visual,0]:newgadget,
[NIL]))=NIL THEN RETURN NOGADGET
IF (g:=CreateGadgetA(BUTTON_KIND,g,
[offx+255,offy+65,105,17,'Close',tattr,2,16,visual,0]:newgadget,
[NIL]))=NIL THEN RETURN NOGADGET
IF (testmodwnd:=OpenWindowTagList(NIL,
[WA_LEFT,98,
WA_TOP,132,
WA_WIDTH,offx+382,
WA_HEIGHT,offy+99,
WA_IDCMP,$24C077E,
WA_FLAGS,$100E,
WA_TITLE,'TestMod',
WA_PUBSCREEN,scr,
WA_MINWIDTH,67,
WA_MINHEIGHT,21,
WA_MAXWIDTH,$280,
WA_MAXHEIGHT,480,
WA_AUTOADJUST,1,
WA_AUTOADJUST,1,
WA_GADGETS,testmodglist,
NIL]))=NIL THEN RETURN NOWINDOW
Gt_RefreshWindow(testmodwnd,NIL)
ENDPROC
PROC closetestmodwindow()
IF testmodwnd THEN CloseWindow(testmodwnd)
IF testmodglist THEN FreeGadgets(testmodglist)
ENDPROC
PROC wait4message(win:PTR TO window)
DEF mes:PTR TO intuimessage,type,g:LONG,txt[255]:STRING
REPEAT
type:=0
IF mes:=Gt_GetIMsg(win.userport)
type:=mes.class
IF type=IDCMP_MENUPICK
infos:=mes.code
type:=0
ELSEIF (type=IDCMP_GADGETDOWN) OR (type=IDCMP_GADGETUP)
infos:=mes.iaddress
g:=infos.gadgetid
stdrast:=testmodwnd.rport
SELECT g
CASE 0 /* Stringgadget */
type:=0
CASE 1 /* Insert */
type:=0
txt:=gt_GetString(strgad)
StrCopy(^dataptr,txt,ALL) /* The content of dataptr can be used by PNP */
^insclicked:=1 /* Tell PNP that the insertgadget has been */
/* clicked. PNP will insert the content of */
/* in the texteditor now. */
CASE 2 /* Close */
type:=1
ENDSELECT
ELSEIF type=IDCMP_REFRESHWINDOW
Gt_BeginRefresh(win)
Gt_EndRefresh(win,TRUE)
type:=0
ELSEIF type<>IDCMP_CLOSEWINDOW /* remove these if you like */
type:=0
ENDIF
Gt_ReplyIMsg(mes)
ELSE
WaitPort(win.userport)
ENDIF
UNTIL type
ENDPROC type
PROC reporterr(er)
DEF erlist:PTR TO LONG
IF er
erlist:=['get context','create gadget','lock scr','get visual infos',
'open "gadtools.library" v37+','open window','create menus']
EasyRequestArgs(0,[20,0,0,'Could not \s!','ok'],0,[erlist[er-1]])
ENDIF
ENDPROC er
PROC getargs()
DEF myargs:PTR TO LONG,rdargs,buf[255]:STRING
myargs:=[0,0,0,0,0,0]
IF rdargs:=ReadArgs('SCREEN/A, WINDOW/A, A/A, B/A, C/A, D/A',myargs,NIL)
/* Args 0,1,2 are not used yet */
StringF(buf,'\s',myargs[1])
tattr:=Val(buf,NIL)
StringF(buf,'\s',myargs[3])
insclicked:=Val(buf,NIL)
StringF(buf,'\s',myargs[4])
dataptr:=Val(buf,NIL)
StringF(buf,'\s',myargs[5])
closed:=Val(buf,NIL)
FreeArgs(rdargs)
ENDIF
ENDPROC
PROC main()
getargs()
IF reporterr(setupscreen())=0
reporterr(opentestmodwindow())
wait4message(testmodwnd)
closetestmodwindow()
^closed:=1 /* Tell PNP that this Module has been closed now */
IF CtrlC() THEN BRA x
ENDIF
x: closedownscreen()
ENDPROC
PROC gt_GetString( gad:PTR TO gadget )
DEF si:PTR TO stringinfo
si := gad.specialinfo
ENDPROC si.buffer