int main(int argc, char **argv)
{
  if ((GTDragBase = OpenLibrary("gtdrag.library",3)) != 0)
  {
    if (GTD_AddApp("dragtest",GTDA_NewStyle,TRUE,TAG_END))
    {
      if ((scr = LockPubScreen(NULL)) != 0)
      {
        vi = GetVisualInfo(scr,TAG_END);
        fontheight = scr->Font->ta_YSize;
        init();

        if ((win = initWindow()) != 0)
        {
          processMsg();
          CloseWindow(win);
        }
        FreeGadgets(glist);

        cleanup();
        FreeVisualInfo(vi);
        UnlockPubScreen(NULL,scr);
      }
      GTD_RemoveApp();
    }
    CloseLibrary(GTDragBase);
  }
  return 0;
}
Beispiel #2
0
void CloseBlockSelectWindow( void )
{
	if ( BlockSelectWnd        ) {
		CloseWindow( BlockSelectWnd );
		BlockSelectWnd = NULL;
	}

	if ( BlockSelectGList      ) {
		FreeGadgets( BlockSelectGList );
		BlockSelectGList = NULL;
	}
}
Beispiel #3
0
/*****************************************
* Quits the program                      *
*****************************************/
void quit_program(int error, char *text)
{
    if (error > 0) {
	printf(VERSION_SHELL);
	printf(" ERROR: %s\n", text);
    }
    if (scr)
	UnlockPubScreen(NULL, scr);
    if (window)
	CloseWindow(window);
    if (VisInfo)
	FreeVisualInfo(VisInfo);
    if (glist)
	FreeGadgets(glist);
}
Beispiel #4
0
ULONG TAPEDECK_RENDER_Gadget(piClass *cl,piObject *o,Msg msg)
{
	UWORD x,y,w,h;
	struct Node_Gadget *ng;
	struct Node_Window *nw;
	struct Gadget *g,*ga;
	BOOL fill=FALSE;

	piGetAttr(o,OBJ_Node,(ULONG *)&ng);
	piGetAttr(ng->ng_Window,OBJ_Node,(ULONG *)&nw);

	x=piCX(o);
	y=piCY(o);
	w=piCW(o);
	h=piCH(o);

	SetAPen(nw->nw_Window->RPort,DrawInfo->dri_Pens[BACKGROUNDPEN]);
	SetDrMd(nw->nw_Window->RPort,JAM1);
	RectFill(nw->nw_Window->RPort,x,y,x+w,y+h);

	g=CreateContext(&g);
	if(ga=(struct Gadget *)piDoMethod(o,OM_CREATE,g))
	{
		AddGList(nw->nw_Window,ga,-1,-1,NULL);
		RefreshGList(g,nw->nw_Window,NULL,-1);
		RemoveGList(nw->nw_Window,ga,-1);
	}
	piDoMethod(o,OM_DELETE);
	g->NextGadget=NULL;
	FreeGadgets(g);

	if(ng->ng_Selected && GUI.gui_Mode==MODE_GADGET)
	{
		SetAPen(nw->nw_Window->RPort,1);
		SetDrMd(nw->nw_Window->RPort,COMPLEMENT);
		if(CurrentGadget==o) fill=TRUE;
		DrawRect(nw->nw_Window->RPort,x,y,fill);
		DrawRect(nw->nw_Window->RPort,x+w-5,y,fill);
		DrawRect(nw->nw_Window->RPort,x+w-5,y+h-5,fill);
		DrawRect(nw->nw_Window->RPort,x,y+h-5,fill);
		DrawRect(nw->nw_Window->RPort,x+(w/2)-2,y,fill);
		DrawRect(nw->nw_Window->RPort,x+(w/2)-2,y+h-5,fill);
		DrawRect(nw->nw_Window->RPort,x,y+(h/2)-2,fill);
		DrawRect(nw->nw_Window->RPort,x+w-5,y+(h/2)-2,fill);
	}
	return TRUE;
}
void CloseBlankerWindow( void )
{
	if ( BlankerWnd        ) {
		CloseWindow( BlankerWnd );
		BlankerWnd = NULL;
	}

	if ( BlankerGList      ) {
		FreeGadgets( BlankerGList );
		BlankerGList = NULL;
	}

	if ( BlankerFont ) {
		CloseFont( BlankerFont );
		BlankerFont = NULL;
	}
}
Beispiel #6
0
static BOOL LayOutReq (struct AHIAudioModeRequesterExt *req, struct TextAttr *TextAttr)
{
  struct Gadget *gad;
  struct NewGadget ng;

  struct TextAttr *gadtextattr;
  struct TextFont *font;
  LONG   fontwidth,buttonheight,buttonwidth,pixels;
  struct IntuiText intuitext = {1,0,JAM1,0,0,NULL,NULL,NULL};
  LONG  sliderlevels,sliderlevel;
  LONG  selected;

  selected=GetSelected(req);
  GetSliderAttrs(req,&sliderlevels,&sliderlevel);

// Calculate gadget area
  req->gx=req->Window->BorderLeft+4;
  req->gy=req->Window->BorderTop+2;
  req->gw=req->Window->Width-req->gx-(req->Window->BorderRight+4);
  req->gh=req->Window->Height-req->gy-(req->Window->BorderBottom+2);

  if(req->Gadgets)
  {
    RemoveGList(req->Window,req->Gadgets,-1);
    FreeGadgets(req->Gadgets);
    SetAPen(req->Window->RPort,0);
    SetDrMd(req->Window->RPort,JAM1);
    EraseRect(req->Window->RPort, req->Window->BorderLeft, req->Window->BorderTop,
        req->Window->Width-req->Window->BorderRight-1,req->Window->Height-req->Window->BorderBottom-1);
    RefreshWindowFrame(req->Window);
  }
  req->Gadgets=NULL;
  if((gad=CreateContext(&req->Gadgets)))
  {
    if(TextAttr)
      gadtextattr=TextAttr;
    else
      gadtextattr=req->Window->WScreen->Font;

    if((font=OpenFont(gadtextattr)))
    {
      fontwidth=font->tf_XSize;
      CloseFont(font);
    }
    else
      return FALSE;

    buttonheight=gadtextattr->ta_YSize+6;
    intuitext.ITextFont=gadtextattr;
    intuitext.IText=req->PositiveText;
    buttonwidth=IntuiTextLength(&intuitext);
    intuitext.IText=req->NegativeText;
    pixels=IntuiTextLength(&intuitext);
    buttonwidth=max(pixels,buttonwidth);
    buttonwidth+=4+fontwidth;

// Create gadgets and check if they fit
    // Do the two buttons fit?
    if(2*buttonwidth > req->gw)
      return FALSE;
    ng.ng_TextAttr=gadtextattr;
    ng.ng_VisualInfo=req->vi;
    ng.ng_UserData=req;
// OK button
    ng.ng_LeftEdge=req->gx;
    ng.ng_TopEdge=req->gy+req->gh-buttonheight;
    ng.ng_Width=buttonwidth;
    ng.ng_Height=buttonheight;
    ng.ng_GadgetText=req->PositiveText;
    ng.ng_GadgetID=OKBUTTON;
    ng.ng_Flags=PLACETEXT_IN;
    gad=CreateGadget(BUTTON_KIND,gad,&ng,TAG_END);
// Cancel button
    ng.ng_LeftEdge=req->gx+req->gw-ng.ng_Width;
    ng.ng_GadgetText=req->NegativeText;
    ng.ng_GadgetID=CANCELBUTTON;
    gad=CreateGadget(BUTTON_KIND,gad,&ng,TAG_END);
// Frequency
    if(req->Flags & freqgad)
    {
      intuitext.IText = GetString(msgReqFrequency, req->Catalog);
      pixels=IntuiTextLength(&intuitext)+INTERWIDTH;
      if(pixels+MINSLIDERWIDTH+INTERWIDTH+FREQLEN2*fontwidth > req->gw)
        return FALSE;
      ng.ng_Width=req->gw-pixels-INTERWIDTH-FREQLEN2*fontwidth;
      ng.ng_LeftEdge=req->gx+pixels;
      ng.ng_TopEdge-=2+buttonheight;
      ng.ng_GadgetText = GetString(msgReqFrequency, req->Catalog);
      ng.ng_GadgetID=FREQSLIDER;
      ng.ng_Flags=PLACETEXT_LEFT;
      gad=CreateGadget(SLIDER_KIND,gad,&ng,
          GTSL_Min,0,
          GTSL_Max,sliderlevels-1,
          GTSL_Level,sliderlevel,
          GTSL_LevelFormat, (ULONG) FREQTEXT2,
          GTSL_MaxLevelLen,FREQLEN2,
          GTSL_LevelPlace,PLACETEXT_RIGHT,
          GTSL_DispFunc, (ULONG) m68k_IndexToFrequency,
          GA_RelVerify,TRUE,
          GA_Disabled,!sliderlevels || (req->tempAudioID == AHI_DEFAULT_ID),
          TAG_DONE);
      req->slidergadget=gad;   // Save for HadleReq()...
    }
// ListView
    if((ng.ng_Height=ng.ng_TopEdge-2-req->gy) < buttonheight)
      return FALSE;
    ng.ng_LeftEdge=req->gx;
    ng.ng_TopEdge=req->gy;
    ng.ng_Width=req->gw;
    ng.ng_GadgetText=NULL,
    ng.ng_GadgetID=LISTVIEW;
    ng.ng_Flags=PLACETEXT_ABOVE;
    gad=CreateGadget(LISTVIEW_KIND,gad,&ng,
        GTLV_ScrollWidth,(fontwidth>8 ? fontwidth*2 : 18),
        GTLV_Labels, (ULONG) req->list,
        GTLV_ShowSelected,NULL,
        ((selected == ~0) || (GadToolsBase->lib_Version >= 39) ? TAG_IGNORE : GTLV_Top),selected,
        (selected == ~0 ? TAG_IGNORE : GTLV_MakeVisible),selected,
        GTLV_Selected,selected,
        TAG_DONE);
    req->listviewgadget=gad;   // Save for HadleReq()...

    if(!gad)
      return FALSE;
  }
  else
    return FALSE;

  AddGList(req->Window,req->Gadgets,~0,-1,NULL);
  RefreshGList(req->Gadgets,req->Window,NULL,-1);
  GT_RefreshWindow(req->Window,NULL);

  return TRUE;
}
Beispiel #7
0
BOOL
get_string(UBYTE * buff, LONG max_len)
{
    struct Gadget *g, *sg;
    struct NewGadget ng;
    struct Gadget *gl;
    struct Window *win;
    struct IntuiMessage *msg;
    struct StringInfo *strinfo;
    UWORD koodi, msgID;
    ULONG classi;
    APTR address;
    UWORD offy;
    BOOL quit, ok;

    g = CreateContext(&gl);
    if (!g)
	return FALSE;

    offy = scr->WBorTop + scr->RastPort.TxHeight + 1;

    ng.ng_TextAttr = &topaz8;
    ng.ng_VisualInfo = VisInfo;
    ng.ng_Flags = PLACETEXT_IN;
    ng.ng_LeftEdge = 14;
    ng.ng_TopEdge = offy + 34;
    ng.ng_Width = 90;
    ng.ng_Height = 15;
    ng.ng_GadgetText = (UBYTE *) "OK";
    ng.ng_GadgetID = GAD_OK;
    g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE);

    ng.ng_LeftEdge = 246;
    ng.ng_TopEdge = offy + 34;
    ng.ng_GadgetText = (UBYTE *) "Cancel";
    ng.ng_GadgetID = GAD_CANCEL;
    g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE);

    ng.ng_LeftEdge = 14;
    ng.ng_TopEdge = offy + 10;
    ng.ng_Width = 322;
    ng.ng_Height = 15;
    ng.ng_GadgetText = NULL;
    ng.ng_GadgetID = GAD_STRING;
    sg = CreateGadget(STRING_KIND, g, &ng,
		      GTST_String, buff,
		      GTST_MaxChars, max_len,
		      TAG_DONE);
    strinfo = (struct StringInfo *) sg->SpecialInfo;
    ok = FALSE;

    newwindow.Title = "Amiga Disk File";
    newwindow.Width = 350;
    newwindow.Height = 65;
    newwindow.FirstGadget = gl;
    newwindow.Screen = scr;

    newwindow.LeftEdge = scr->MouseX - (newwindow.Width / 2);
    if (newwindow.LeftEdge + newwindow.Width > scr->Width)
	newwindow.LeftEdge = scr->Width - newwindow.Width;

    newwindow.TopEdge = scr->MouseY - (newwindow.Height / 2);
    if (newwindow.TopEdge + newwindow.Height > scr->Height)
	newwindow.TopEdge = scr->Height - newwindow.Height;

    win = OpenWindow(&newwindow);
    if (win) {
	ActivateGadget(sg, win, NULL);
	quit = FALSE;
	while (!quit) {
	    WaitPort(win->UserPort);
	    while (msg = (struct IntuiMessage *) GT_GetIMsg(win->UserPort)) {
		classi = msg->Class;
		koodi = msg->Code;
		address = msg->IAddress;
		if (classi == IDCMP_GADGETUP)
		    msgID = ((struct Gadget *) msg->IAddress)->GadgetID;
		else
		    msgID = msg->Code;

		GT_ReplyIMsg((struct IntuiMessage *) msg);
		switch (classi) {
		case IDCMP_CLOSEWINDOW:
		    quit = TRUE;
		    break;
		case IDCMP_GADGETUP:
		    switch (msgID) {
		    case GAD_CANCEL:
			quit = TRUE;
			break;
		    case GAD_OK:
		    case GAD_STRING:
			strcpy(buff, strinfo->Buffer);
			quit = ok = TRUE;
			break;
		    }
		    break;
		default:
		    break;
		}
	    }
	}
	CloseWindow(win);
    }
    FreeGadgets(gl);

    return ok;
}
static void freeTilesetRequesterGadgets(WindowGadgets *gadgets) {
  FreeGadgets(gadgets->glist);
  free(gadgets->data);
  free(gadgets);
}