Пример #1
0
STATIC VOID FOGadCleanup(struct LayoutData *ld, struct AslBase_intern *AslBase)
{
    struct FOUserData 		*udata = (struct FOUserData *)ld->ld_UserData;
    struct FontRequester 	*req = (struct FontRequester *)ld->ld_Req;
    struct IntReq 		*intreq = ld->ld_IntReq;
//  struct IntFontReq 		*iforeq = (struct IntFontReq *)intreq;
    
    EnterFunc(bug("FOGadCleanup(ld=%p)\n", ld));

    if (ld->ld_Window && ld->ld_GList)
    {
        RemoveGList(ld->ld_Window, ld->ld_GList, -1);
    }
    
    killscrollergadget(&udata->NameScrollGad, AslBase);
    killscrollergadget(&udata->SizeScrollGad, AslBase);

    FreeObjects(&FOREQ_FIRST_OBJECT(udata), &FOREQ_LAST_OBJECT(udata), AslBase);
    
    FOFreeFonts(ld, AslBase);
    		
    if (udata->PreviewFont) CloseFont(udata->PreviewFont);
    
    if (ld->ld_Window)
    {
	req->fo_LeftEdge = intreq->ir_LeftEdge = ld->ld_Window->LeftEdge;
	req->fo_TopEdge  = intreq->ir_TopEdge  = ld->ld_Window->TopEdge;
	req->fo_Width    = intreq->ir_Width    = ld->ld_Window->Width;
	req->fo_Height   = intreq->ir_Height   = ld->ld_Window->Height;
    }
        
    ReturnVoid("FOGadCleanup");
}
Пример #2
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;
}
Пример #3
0
static void resizeWindow(FrameworkWindow *window) {
  if(window->gadgets) {
    RemoveGList(window->intuitionWindow, window->gadgets->glist, -1);
    (*window->kind->freeGadgets)(window->gadgets);
    SetRast(window->intuitionWindow->RPort, 0);
    window->gadgets = (*window->kind->buildGadgets)(window->intuitionWindow->Width, window->intuitionWindow->Height, window->data);
    if(!window->gadgets) {
      fprintf(stderr, "resizeWindow: couldn't create gadgets\n");
      goto error;
    }
    AddGList(window->intuitionWindow, window->gadgets->glist, (UWORD)~0, -1, NULL);
    RefreshWindowFrame(window->intuitionWindow);
    RefreshGList(window->gadgets->glist, window->intuitionWindow, NULL, -1);
    GT_RefreshWindow(window->intuitionWindow, NULL);
  }

  return;

error:
  return;
}
Пример #4
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;
}
Пример #5
0
// Add or remove fuel gauge
void lister_set_gauge(Lister *lister,BOOL refresh)
{
	BOOL want,change=0;

	// If lister is closed, problem is moot
	if (!lister->window ||
		(lister->more_flags&LISTERF_TITLEBARRED)) return;

	// See if lister wants a gauge
	want=lister_want_gauge(lister);

	// Does lister have gauge and we don't want it to?
	if (lister->gauge_gadget && !want)
	{
		// Remove the gadget
		RemoveGList(lister->window,lister->gauge_gadget,1);

		// Free gadget
		DisposeObject((Object *)lister->gauge_gadget);
		lister->gauge_gadget=0;

		// Fix border width
		lister->window->BorderLeft=lister->old_border_left;

		// Free pens
		lister_init_colour(lister,ENVCOL_GAUGE,TRUE);

		// Set change flag
		change=1;
	}

	// Or, do we not have it but want it?
	else
	if (!lister->gauge_gadget && want)
	{
		// Initialise pens
		lister_init_colour(lister,ENVCOL_GAUGE,FALSE);

		// Create gauge
		if ((lister->gauge_gadget=(struct Gadget *)
				NewObject(
					0,
					"dopusgaugeclass",
					GA_ID,GAD_GAUGE,
					GA_Left,0,
					GA_Top,lister->window->BorderTop,
					GA_Width,lister->window->BorderRight,
					GA_RelHeight,-lister->window->BorderTop-lister->window->BorderBottom+3,
					GA_LeftBorder,TRUE,
					DGG_FillPen,lister->lst_Colours[ENVCOL_GAUGE].cr_Pen[0],
					DGG_FillPenAlert,lister->lst_Colours[ENVCOL_GAUGE].cr_Pen[1],
					TAG_END)))
		{
			// Fix border width
			lister->window->BorderLeft=lister->window->BorderRight;

			// Add gauge to window after parent button
			AddGList(lister->window,lister->gauge_gadget,-1,1,0);
			RefreshGList(lister->gauge_gadget,lister->window,0,1);

			// Set change flag
			change=1;
		}

		// Failed
		else
		{
			// Free pens
			lister_init_colour(lister,ENVCOL_GAUGE,TRUE);
		}
	}

	// Changed?
	if (change)
	{
		// Fix left border related things
		lister->window->GZZWidth=lister->window->Width-lister->window->BorderLeft-lister->window->BorderRight;
		lister->parent_button.Width=lister->window->BorderLeft;
	}

	// Changed and need to refresh?
	if (change && refresh)
	{
		// Initialise and refresh
		lister_init_display(lister);
		lister_refresh(lister,LREFRESH_FULL|LREFRESH_FULL_ICON);

		// If the path field is added, refresh it
		if (lister->path_field && lister->flags&LISTERF_PATH_FIELD)
		{
			struct gpResize resize;

			// Fill out resize packet
			resize.MethodID=GM_RESIZE;
			resize.gpr_GInfo=0;
			resize.gpr_RPort=0;
			resize.gpr_Size.Left=lister->window->BorderLeft;
			resize.gpr_Size.Top=-(lister->window->BorderBottom+FIELD_FONT->tf_YSize+4);
			resize.gpr_Size.Width=-(lister->window->BorderLeft+lister->window->BorderRight);
			resize.gpr_Size.Height=FIELD_FONT->tf_YSize+4;
			resize.gpr_Redraw=0;
			resize.gpr_Window=lister->window;
			resize.gpr_Requester=0;

			// Tell string gadget to resize
			DoMethodA((Object *)lister->path_field,(Msg)&resize);

			// Erase behind path field
			SetAPen(lister->window->RPort,3);
			RectFill(
				lister->window->RPort,
				lister->window->BorderLeft,
				lister->window->Height+lister->path_field->TopEdge-2,
				lister->window->Width-lister->window->BorderRight-1,
				lister->window->Height+lister->path_field->TopEdge+lister->path_field->Height+1);

			// Refresh path field
			RefreshGList(lister->path_field,lister->window,0,1);
		}

		// Refresh the window frame
		RefreshWindowFrame(lister->window);

		// Do we have the gauge?
		if (lister->gauge_gadget)
		{
			// Refresh title and gauge
			lister_show_name(lister);
		}
	}
}
Пример #6
0
void main(int argc, char *argv[])
{
	struct gtbApplication *appl=NULL;
	struct Window *Wnd;
	struct Gadget *GList=NULL;
	Object *prev;

	unless(appl=gtbNewApplication(TAG_DONE)) Leave("Can't create application");
	unless(Scrn=NewObject(appl->ga_ScrClass,NULL,
		SCRN_LikeWorkbench,TRUE,
		SCRN_PubName,APPPUBNAME,
		SCRN_Private,FALSE,
		SCRN_Title,APPPUBNAME,
		TAG_DONE)) Leave("Can't create screen");
	unless(Cdity=NewObject(appl->ga_CxClass,NULL,
		COMM_Name,APPNAME,
		COMM_Title,APPTITLE,
		COMM_Description,APPDESCRIPTION,
		COMM_Unique,TRUE,
		COMM_Notify,TRUE,
		COMM_ShowHide,TRUE,
		COMM_Handler,(ULONG)CdityHandler,
		COMM_AddHotKeyStr,"control t",COMM_AddHotKeyID,1,
		TAG_DONE)) Leave("Can't create commodity");
	unless(CtrlC=NewObject(appl->ga_MsgClass,NULL,
		MESG_SigBit,SIGBREAKF_CTRL_C,
		MESG_Handler,(ULONG)CtrlCHandler,
		TAG_DONE)) Leave("Can't create message handler");
	unless(ARexx=NewObject(appl->ga_ARexxClass,NULL,
		REXX_Name,APPPUBNAME,
		REXX_Extension,APPEXTENSION,
		REXX_CommandTable,commands,
		REXX_Handler,(ULONG)ARexxHandler,
		TAG_DONE)) Leave("Can't create arexx");
	unless(AmigaGuide=NewObject(appl->ga_AGClass,NULL,
		AGUI_Name,APPGUIDE,
		AGUI_ScreenObject,Scrn,
		AGUI_ARexxObject,ARexx,
		AGUI_Activate,TRUE,
		AGUI_BaseName,APPNAME,
		TAG_DONE)) Leave("Can't create amigaguide");
	unless(MainWnd=NewObject(appl->ga_WndClass,NULL,WIND_CenterX,600,WIND_CenterY,20,WIND_Width,200,WIND_Height,200,
		WIND_DragBar,TRUE,
		WIND_DepthGadget,TRUE,
		WIND_SizeGadget,TRUE,
		WIND_CloseGadget,TRUE,
		WIND_Title,APPTITLE,
		WIND_ScreenObject,Scrn,
		WIND_VertScroll,TRUE,
		WIND_VertTotal,10,
		WIND_HorizScroll,TRUE,
		WIND_HorizTotal,10,
		WIND_HorizVisible,5,
		WIND_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_GADGETUP,
		WIND_Handler,(ULONG)WndHandler,
		WIND_Activate,TRUE,
		WIND_MaxWidth,-1,
		WIND_MaxHeight,-1,
		TAG_DONE)) Leave("Can't create window");
	GetAttr(WIND_Window,MainWnd,(ULONG *)&Wnd);

	unless(prev=(Object *)CreateContext(&GList)) Leave("Can't create context");
	unless(prev=gtbCreateGadget(BUTTON_KIND,NULL,NULL,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble",
		GT_ScreenObj,Scrn,
		GT_Handler,(ULONG)Gad1Handler,
		TAG_DONE)) Leave("Can't create gadget 1");
	unless(prev=gtbCreateGadget(STRING_KIND,NULL,NULL,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop+30,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble2",
		GT_ScreenObj,Scrn,
		TAG_DONE)) Leave("Can't create gadget 2");
	unless(prev=gtbCreateGadget(BOOPSI_KIND,NULL,FRBUTTONCLASS,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop+60,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble3",
		ICA_TARGET,ICTARGET_IDCMP,
		TAG_DONE)) Leave("Can't create gadget 3");

	DoMethod(MainWnd,OM_ADDMEMBER,GList);
	RefreshGList(GList,Wnd,NULL,-1);
	GT_RefreshWindow(Wnd,NULL);

	gtbExecuteRexx(ARexx,argv[1]);

	while(gtbHandleObject(MainWnd,Cdity,CtrlC,ARexx,AmigaGuide,TAG_DONE));

	RemoveGList(Wnd,GList,-1);
	gtbFreeGadgets(GList);
end:
	if(AmigaGuide) DisposeObject(AmigaGuide);
	if(ARexx) DisposeObject(ARexx);
	if(MainWnd) DisposeObject(MainWnd);
	if(CtrlC) DisposeObject(CtrlC);
	if(Cdity) DisposeObject(Cdity);
	if(Scrn) DisposeObject(Scrn);
	if(appl) gtbDisposeApplication(appl);
}