home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
-
- #include <string.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/gadtools.h>
- #include <proto/intuition.h>
- #include <proto/icon.h>
- #include <proto/graphics.h>
- #include <proto/wb.h>
- #include <proto/commodities.h>
- #include <proto/diskfont.h>
- #include <proto/graphics.h>
- #include <proto/utility.h>
-
-
-
- char *GetStringWindow(UWORD x, UWORD y, char *windowtitle, char *buffer, WORD len)
- {
- /* WORD x The current X mouse position */
- /* WORD y The current Y mouse position */
- /* char *windowtitle The title of the window */
- /* char *buffer What to put in the initial string gadget, and the resulting string */
- /* WORD len The # of characters in buffer, including the added NULL */
- /* RETURNS a pointer to buffer */
-
- ULONG signals;
- ULONG winsigflag;
- BOOL LOOP;
- struct IntuiMessage *winmsg;
- struct Window *win;
- struct Screen *scr;
- struct VisualInfo *vi;
- struct Gadget *gad;
- struct Gadget *glist=NULL;
- struct NewGadget ng;
- ULONG winheight,winwidth;
- char *gadgetbuffer;
-
- if (scr=LockPubScreen(NULL))
- {
- if (vi=GetVisualInfo(scr,TAG_END))
- {
- winheight = scr->WBorTop + (2 * scr->Font->ta_YSize) + 1 + scr->WBorBottom + 8;
- winwidth = (2 * TextLength(&scr->RastPort,windowtitle,strlen(windowtitle))) + 40; /* 40 is for the close and depth gadgets */
- if (win = OpenWindowTags(NULL,
- WA_Left, x - (winwidth/2),
- WA_Top, y - (winheight/2),
- WA_Width, winwidth,
- WA_Height, winheight,
- WA_AutoAdjust, TRUE,
- WA_Gadgets, glist,
- WA_IDCMP, IDCMP_REFRESHWINDOW | IDCMP_CLOSEWINDOW | IDCMP_ACTIVEWINDOW | IDCMP_GADGETUP,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE,
- WA_Title, windowtitle,
- WA_PubScreen, scr,
- TAG_END))
- {
- gad = CreateContext(&glist);
-
- ng.ng_LeftEdge = win->BorderLeft+2;
- ng.ng_TopEdge = win->BorderTop+2;
- ng.ng_Width = win->Width-win->BorderRight-2-ng.ng_LeftEdge;
- ng.ng_Height = scr->Font->ta_YSize + 4;
- ng.ng_GadgetText = NULL;
- ng.ng_TextAttr = NULL;//win->WScreen->Font;
- ng.ng_VisualInfo = vi;
- ng.ng_GadgetID = 0;
- ng.ng_Flags = 0;
-
- gad = CreateGadget(STRING_KIND,gad,&ng,
- GTST_String, buffer,
- GTST_MaxChars, len-1,
- TAG_DONE);
-
- if (gad)
- {
- winsigflag = 1L<<win->UserPort->mp_SigBit;
- AddGList(win, glist, (UWORD)~0, -1, NULL);
- RefreshGList(glist,win,NULL,-1);
- GT_RefreshWindow(win,NULL);
-
- LOOP=TRUE;
- while (LOOP)
- {
- signals=Wait(SIGBREAKF_CTRL_C | winsigflag);
-
- if (signals & SIGBREAKF_CTRL_C)
- LOOP=FALSE;
-
- if (signals & winsigflag)
- {
- while (winmsg = (struct IntuiMessage *)GT_GetIMsg((struct MsgPort *)win->UserPort))
- {
- switch(winmsg->Class)
- {
- case IDCMP_GADGETUP:
- LOOP=FALSE;
- break;
- case IDCMP_REFRESHWINDOW:
- BeginRefresh(win);
- EndRefresh(win, TRUE);
- break;
- case IDCMP_CLOSEWINDOW:
- LOOP=FALSE;
- break;
- case IDCMP_ACTIVEWINDOW:
- ActivateGadget(gad,win,NULL);
- break;
- }
- GT_ReplyIMsg(winmsg);
- }
- } /* End of process window events */
- } /* End of while (LOOP) */
-
- GT_GetGadgetAttrs(gad, win, NULL, GTST_String, &gadgetbuffer);
- strcpy(buffer, gadgetbuffer);
-
- RemoveGList(win,glist,-1);
- }
- FreeGadgets(glist);
- CloseWindow(win);
- } /* End of if (OpenWindowTags()) */
- FreeVisualInfo(vi);
- }
- UnlockPubScreen(NULL,scr);
- }
- return(buffer);
- }
-