示例#1
0
/*
 * Varargs stub for NewObjectA().
 */
Object *
NewObject (struct IClass *classPtr, ClassID classID, ULONG tag1, ...)
{
    APTR    object;

    object = NewObjectA (classPtr, classID, (struct TagItem *)&tag1);
    return object;
} /* NewObject */
示例#2
0
Object *AROSCycle__OM_NEW(Class *cl, Class *rootcl, struct opSet *msg)
{
    struct CycleData 	*data;
    struct TextAttr 	*tattr;
    struct TagItem  	imgtags[] = {
        { IA_Width	, 0 		},
        { IA_Height	, 0 		},
        { IA_EdgesOnly	, FALSE		},
	{ IA_FrameType	, FRAME_BUTTON	},
        { TAG_DONE	, 0UL 		}
    };
    STRPTR  	    	*labels;
    Object  	    	*o;

    o = (Object *)DoSuperMethodA(cl, (Object *)rootcl, (Msg)msg);
    if (!o)
        return NULL;

    data = INST_DATA(cl, o);
    data->active = GetTagData(AROSCYCLE_Active, 0, msg->ops_AttrList);
    data->labels = (STRPTR *)GetTagData(AROSCYCLE_Labels, (IPTR) NULL, msg->ops_AttrList);
    data->numlabels = 0;

    labels = data->labels;
    if (labels)
    {
        while (labels[0])
        {
            data->numlabels++;
            labels++;
        }
    }

    tattr = (struct TextAttr *)GetTagData(GA_TextAttr, (IPTR) NULL, msg->ops_AttrList);
    if (tattr) data->font = OpenFont(tattr);
    
    imgtags[0].ti_Data = (IPTR)EG(o)->Width;
    imgtags[1].ti_Data = (IPTR)EG(o)->Height;

    EG(o)->GadgetRender = NewObjectA(NULL, FRAMEICLASS, imgtags);
    if (!EG(o)->GadgetRender)
    {
        IPTR methodid = OM_DISPOSE;
        CoerceMethodA(cl, o, (Msg)&methodid);
        return NULL;
    }

    return o;
}
示例#3
0
ULONG NATDECLFUNC_5(GUI_Open, d0, ULONG, cpu, a0, UBYTE *, ProgramName, a1, struct WBArg *, IconName, a2, CONST_STRPTR, vstring, a6, struct DnetcLibrary *, LibBase)
{
	DECLARG_5(d0, ULONG, cpu, a0, UBYTE *, ProgramName, a1, struct WBArg *, IconName, a2, CONST_STRPTR, vstring, a6, struct DnetcLibrary *, LibBase)

	ULONG	sigmask;

	(void)ProgramName;
	(void)cpu;

	if (!LibBase->dobj)
	{
		if (IconName)
		{
			BPTR olddir;

			olddir = CurrentDir(IconName->wa_Lock);
			LibBase->dobj	= GetDiskObject(IconName->wa_Name);
			CurrentDir(olddir);
		}
	}

	sigmask	= 0;

	ObtainSemaphore(&LibBase->SemaphoreGUI);

	if (!LibBase->App)
	{
		Object	*app;

		strcpy(LibBase->Version, vstring);

		app	= NewObjectA(LibBase->AppMCC->mcc_Class, NULL, NULL);

		if (app)
		{
			LibBase->App			= app;
			LibBase->OwnerTask	= FindTask(NULL);

			DoMethod(app, MUIM_MyApplication_OpenMainWindow);

			sigmask	= 0xffff0000;
		}
	}

	ReleaseSemaphore(&LibBase->SemaphoreGUI);

	return sigmask;
}
示例#4
0
IPTR GTSlider__OM_NEW(Class * cl, Object * o, struct opSet *msg)
{
    struct DrawInfo	*dri;
    
    struct TagItem 	fitags[] =
    {
	{IA_Width	, 0UL		},
	{IA_Height	, 0UL		},
	{IA_Resolution	, 0UL		},
	{IA_FrameType	, FRAME_BUTTON	},
	{IA_EdgesOnly	, TRUE		},
	{TAG_DONE			}
    };
    
    EnterFunc(bug("Slider::New()\n"));
    
    o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
    if (o)
    {
    	struct SliderData *data = INST_DATA(cl, o);
  
	dri = (struct DrawInfo *)GetTagData(GA_DrawInfo, (IPTR) NULL, msg->ops_AttrList);
	
	fitags[0].ti_Data = GetTagData(GA_Width, 0, msg->ops_AttrList) + BORDERPROPSPACINGX * 2;
	fitags[1].ti_Data = GetTagData(GA_Height, 0, msg->ops_AttrList) + BORDERPROPSPACINGY * 2;
	fitags[2].ti_Data = (dri->dri_Resolution.X << 16) + dri->dri_Resolution.Y;

	data->frame = NewObjectA(NULL, FRAMEICLASS, fitags);
	if (data->frame)
	{
	    data->freedom=GetTagData(PGA_Freedom,FREEHORIZ,msg->ops_AttrList);

	    data->min   = 0;
	    data->max   = 15;
	    data->level = data->freedom==FREEHORIZ?data->min:data->max;

	    GTSlider__OM_SET(cl, o, msg);
	    
	    data->labelplace = GetTagData(GA_LabelPlace, GV_LabelPlace_Left, msg->ops_AttrList);
	} else {
	    CoerceMethod(cl, o, OM_DISPOSE);
	    o = NULL;
	}
    }
    ReturnPtr("Slider::New", IPTR, (IPTR)o);
    
}
示例#5
0
IPTR GTCheckBox__OM_NEW(Class *cl, Object *supercl, struct opSet *msg)
{
    struct CheckBoxData *data;
    struct TagItem  	tags[] =
    {
	{IA_Width   	, 0UL	    },
	{IA_Height  	, 0UL	    },
	{SYSIA_DrawInfo , 0UL	    },
	{SYSIA_Which	, CHECKIMAGE},
	{TAG_DONE   	    	    }
    };
    struct Gadget   	*g;

    g = (struct Gadget *)DoSuperMethodA(cl, supercl, (Msg)msg);
    if (!g)
	return (IPTR)0;

    g->Activation |= GACT_RELVERIFY;

    data = INST_DATA(cl, g);
    data->dri = NULL;
    data->flags = 0;
    GTCheckBox__OM_SET(cl, g, msg);

    if (!g->GadgetRender)
    {
        tags[0].ti_Data = g->Width;
        tags[1].ti_Data = g->Height;
        tags[2].ti_Data = (IPTR) data->dri;
        g->GadgetRender = (struct Image *) NewObjectA(NULL, SYSICLASS,
                                                           tags);
        data->flags |= CF_CustomImage;
    }
    
    if ((!data->dri) || (!g->GadgetRender)) 
    {
	CoerceMethod(cl, (Object *)g, OM_DISPOSE);
	g = NULL;
    }

    return (IPTR)g;
}
示例#6
0
IPTR AslProp__OM_NEW(Class * cl, Object * o, struct opSet * msg)
{
    struct AslPropData *data;
    struct TagItem fitags[] =
    {
        {IA_FrameType, FRAME_BUTTON},
        {IA_EdgesOnly, TRUE 	   },
        {TAG_DONE, 0UL}
    };

    struct ExtGadget *eg = (struct ExtGadget *)DoSuperMethodA(cl, o, (Msg)msg);
    if (eg)
    {
        data = INST_DATA(cl, eg);

        eg->BoundsLeftEdge = eg->LeftEdge;
        eg->BoundsTopEdge  = eg->TopEdge;
        eg->BoundsWidth    = eg->Width;
        eg->BoundsHeight   = eg->Height;
        eg->MoreFlags |= GMORE_BOUNDS;

        eg->LeftEdge += BORDERPROPSPACINGX;
        eg->TopEdge  += BORDERPROPSPACINGY;
        eg->Width    -= BORDERPROPSPACINGX * 2;
        eg->Height   -= BORDERPROPSPACINGY * 2;

        data->deltafactor = 1;
        data->frame = NewObjectA(NULL, FRAMEICLASS, fitags);
        if (!data->frame)
        {
            CoerceMethod(cl, (Object *)eg, OM_DISPOSE);
            eg = NULL;
        }
    }

    return (IPTR)eg;
}
示例#7
0
BOOL makescrollergadget(struct ScrollerGadget *scrollergad, struct LayoutData *ld,
			struct TagItem *tags, struct AslBase_intern *AslBase)
{
    struct TagItem extraproptags[] =
    {
    	{PGA_NotifyBehaviour, PG_BEHAVIOUR_NICE},
	{PGA_RenderBehaviour, PG_BEHAVIOUR_NICE},
	{TAG_MORE   	    , 0     	       }
    };
    
    struct TagItem *ti, *h_ti, *w_ti;
    WORD x, y, w, h, aw, ah;
    UWORD flags = 0;
    BOOL freehoriz = (GetTagData(PGA_Freedom, FREEVERT, tags) == FREEHORIZ);
    BOOL result = FALSE;
    
    if ((ti = FindTagItem(GA_Left, tags)))
    {
        x = ti->ti_Data;
    } else if ((ti = FindTagItem(GA_RelRight, tags)))
    {
        x = ti->ti_Data; flags |= GFLG_RELRIGHT;
    }
    
    if ((ti = FindTagItem(GA_Top, tags)))
    {
        y = ti->ti_Data;
    } else if ((ti = FindTagItem(GA_RelBottom, tags)))
    {
        y = ti->ti_Data; flags |= GFLG_RELBOTTOM;
    }
    
    if ((w_ti = FindTagItem(GA_Width, tags)))
    {
        w = w_ti->ti_Data;
    } else if ((w_ti = FindTagItem(GA_RelWidth, tags)))
    {
        w = w_ti->ti_Data; flags |= GFLG_RELWIDTH;
    }
    
    if ((h_ti = FindTagItem(GA_Height, tags)))
    {
        h = h_ti->ti_Data;
    } else if ((h_ti = FindTagItem(GA_RelHeight, tags)))
    {
        h = h_ti->ti_Data; flags |= GFLG_RELHEIGHT;
    }
    
    if (freehoriz)
    {
        aw = h; ah = h;
	w -= aw * 2;
	if (w_ti) w_ti->ti_Data = w;
    } else {
        aw = w; ah = w;
	h -= ah * 2;
	if (h_ti) h_ti->ti_Data = h; 
    }
    
    extraproptags[2].ti_Data = (IPTR)tags;
    if ((scrollergad->prop = NewObjectA(AslBase->aslpropclass, NULL, extraproptags)))
    {
        struct TagItem arrow_tags[] =
	{
	    {GA_Left		, freehoriz ? x + w - 1 : x	},
	    {GA_Top		, freehoriz ? y : y + h - 1	},
	    {GA_Width		, aw				},
	    {GA_Height		, ah				},
	    {GA_RelVerify	, TRUE				},
	    {GA_Immediate	, TRUE				},
	    {GA_Previous	, (IPTR)scrollergad->prop	},
	    {GA_ID		, ID_ARROWDEC			},
	    {TAG_DONE						}	    
	};
	
	if (flags & GFLG_RELRIGHT) arrow_tags[0].ti_Tag = GA_RelRight;
	if (flags & GFLG_RELWIDTH)
	{
	    arrow_tags[0].ti_Tag = GA_RelRight;
	    if (freehoriz) arrow_tags[0].ti_Data += 2;
	}
	
	if (flags & GFLG_RELBOTTOM) arrow_tags[1].ti_Tag = GA_RelBottom;
	if (flags & GFLG_RELHEIGHT)	
	{
	    arrow_tags[1].ti_Tag = GA_RelBottom;
	    if (!freehoriz) arrow_tags[1].ti_Data += 2;
	}
	
	if ((scrollergad->arrow1 = NewObjectA(AslBase->aslarrowclass, NULL, arrow_tags)))
	{
	    if (freehoriz)
	    {		
	        arrow_tags[0].ti_Data += aw;
	    } else {
	        arrow_tags[1].ti_Data += ah;
	    }
	    arrow_tags[6].ti_Data = (IPTR)scrollergad->arrow1;
	    arrow_tags[7].ti_Data = ID_ARROWINC;
	    
	    if ((scrollergad->arrow2 = NewObjectA(AslBase->aslarrowclass, NULL, arrow_tags)))
	    {
	        struct TagItem image_tags[] =
		{
		    {SYSIA_Which	, freehoriz ? LEFTIMAGE : UPIMAGE	},
		    {SYSIA_DrawInfo	, (IPTR)ld->ld_Dri			},
		    {SYSIA_Style	, SYSISTYLE_GADTOOLS			},
		    {IA_Width		, aw					},
		    {IA_Height		, ah					},
		    {TAG_DONE							}		
		};
	        struct Image *im;
	    	
		if ((im = NewObjectA(NULL, SYSICLASS, image_tags)))
		{
		    SetAttrs(scrollergad->arrow1, GA_Image, (IPTR)im,
		    				  TAG_DONE);
						  
		    image_tags[0].ti_Data = (freehoriz ? RIGHTIMAGE : DOWNIMAGE);
		    
		    if ((im = NewObjectA(NULL, SYSICLASS, image_tags)))
		    {
		    #if USE_SAFE_NOTIFYING
		    	struct TagItem ic_tags [] =
			{
			    {ICA_MAP , (IPTR) prop_to_lv },
			    {TAG_DONE	    	    	 }
			};
			
			if ((scrollergad->prop_ic = NewObjectA(NULL, ICCLASS, ic_tags)))
			{
			    ic_tags[0].ti_Data = (IPTR)lv_to_prop;
			    
			    if ((scrollergad->listview_ic = NewObjectA(NULL, ICCLASS, ic_tags)))			    
			    {
		    #endif			    	 
		        	struct TagItem set_tags [] =
				{
				    {ICA_TARGET	, (IPTR) scrollergad->prop	},
				    {ICA_MAP    , (IPTR) arrowdec_to_prop	},
				    {TAG_DONE					}
				};

		        	SetAttrs(scrollergad->arrow2, GA_Image, (IPTR)im,
							      TAG_DONE);

				SetAttrsA(scrollergad->arrow1, set_tags);
				set_tags[1].ti_Data = (IPTR)arrowinc_to_prop;
				SetAttrsA(scrollergad->arrow2, set_tags);

				result = TRUE;
				
		    #if USE_SAFE_NOTIFYING
		    
			    } /* if ((scrollergad->listview_ic = NewObjectA(NULL, ICCLASS, ic_tags))) */
			    
			} /* if ((scrollergad->prop_ic = NewObjectA(NULL, ICCLASS, ic_tags))) */
			
		    #endif
			
		    } /* if ((im = NewObjectA(NULL, SYSICLASS, image_tags))) */
		    
		} /* if ((im = NewObject(NULL, SYSICLASS, image_tags))) */
		
	    } /* if ((scrollergad->arrow2 = NewObjectA(NULL, BUTTONGCLASS, arrow_tags))) */
	    
	} /* if (scrollergad->arrow1 = NewObjectA(NULL, BUTTONGCLASS, arrow_tags)) */
	
    } /* if ((scrollergad->prop = NewObjectA(AslBase->aslpropclass, NULL, tags))) */
    
    if (!result) killscrollergadget(scrollergad, AslBase);
    
    return result;
}
示例#8
0
struct MenuItem * makemenuitem(struct NewMenu * newmenu,
                               BOOL is_image,
                               struct TagItem * taglist,
                               struct GadToolsBase_intern * GadToolsBase)
{
    struct MenuItem	* menuitem = NULL;
    ULONG		allocsize;
    ULONG		* p;

    /* Note: 2 IntuiTexts must be alloced, because CreateMenusA can depend on it
             if a subitem mark (">>") must be added */

    if (newmenu->nm_Label == NM_BARLABEL) is_image = TRUE;

    allocsize = sizeof(ULONG) + sizeof(struct MenuItem) + sizeof(APTR);
    if (!is_image) allocsize += sizeof(struct IntuiText) * 2; /* for text + (commandstring OR ">>") */

    p = (ULONG *)AllocMem(allocsize, MEMF_CLEAR);

    if (NULL != p)
    {
	*p = allocsize;
	menuitem = (struct MenuItem *)(p + 1);

	DEBUG_ALLOCMENUS(bug("makemenuitem: MenuItem %p\n",menuitem));
	menuitem->Flags = (newmenu->nm_Flags & (NM_ITEMDISABLED | CHECKIT | MENUTOGGLE | CHECKED)) ^
    			  ITEMENABLED;

	menuitem->Flags |= HIGHCOMP;

	if (newmenu->nm_CommKey)
	{
            if (!(newmenu->nm_Flags & NM_COMMANDSTRING))
	    {
		menuitem->Flags |= COMMSEQ;
		menuitem->Command = newmenu->nm_CommKey[0];
	    }
	}

	menuitem->MutualExclude = newmenu->nm_MutualExclude;
	GTMENUITEM_USERDATA(menuitem) = newmenu->nm_UserData;

	if (FALSE == is_image)
	{
	    /*
	    ** Text
	    */
	    struct IntuiText * it = (struct IntuiText *)(((UBYTE *)menuitem) +
      							 sizeof(struct MenuItem) +
							 sizeof(APTR));

	    DEBUG_ALLOCMENUS(bug("makemenuitem: Text MenuItem\n"));
	    menuitem->ItemFill = (APTR)it;

	    it->FrontPen = GetTagData(GTMN_FrontPen, 0, taglist);
	    it->DrawMode = JAM1;

	    it->IText    = newmenu->nm_Label;
	    DEBUG_ALLOCMENUS(bug("makemenuitem: FillName <%s>\n",it->IText));

	    menuitem->Flags |= ITEMTEXT;

	    if (newmenu->nm_CommKey && (newmenu->nm_Flags & NM_COMMANDSTRING))
	    {
        	struct IntuiText *it2 = it + 1;

		*it2 = *it;
		it2->IText = newmenu->nm_CommKey;
		it->NextText = it2;
	    }

	} /* if (FALSE == is_image) */
	else
	{
	    DEBUG_ALLOCMENUS(bug("makemenuitem: Image MenuItem\n"));
	    menuitem->Flags &= ~ITEMTEXT;

	    if (newmenu->nm_Label != NM_BARLABEL)
	    {
		/*
		** An image.
		*/
		menuitem->ItemFill = (APTR)newmenu->nm_Label;
		DEBUG_ALLOCMENUS(bug("makemenuitem: FillImage 0x%lx\n",menuitem->ItemFill));
	    }
	    else
	    {
        	/*
		** A barlabel image.
		*/

		struct TagItem barlabel_tags[] =
		{
		    {IA_Left	, ITEXT_EXTRA_LEFT	},
		    {IA_Top	, 3			},
		    {IA_Width	, 20			},
		    {IA_Height	, 2			},
		    {TAG_DONE				}
		};

		menuitem->Flags &= ~ITEMENABLED;

		menuitem->ItemFill = NewObjectA(NULL, MENUBARLABELCLASS, barlabel_tags);

		DEBUG_ALLOCMENUS(bug("makemenuitem: BarImage 0x%lx\n",menuitem->ItemFill));

		if (!menuitem->ItemFill)
		{
		    DEBUG_ALLOCMENUS(bug("makemenuitem: barimage failed\n"));
		    FreeVec(menuitem);
		    menuitem = NULL;
		}
	    }

	} /* is_image */

    } /* if (NULL != menuitem) */

    return menuitem;
}
示例#9
0
STATIC BOOL FOGadInit(struct LayoutData *ld, struct AslBase_intern *AslBase)
{    
    struct FOUserData 	*udata = ld->ld_UserData;
    struct IntFontReq 	*iforeq = (struct IntFontReq *)ld->ld_IntReq;
    STRPTR 		str[6];
#if USE_SHARED_COOLIMAGES
    struct ButtonInfo 	bi[NUMBUTS] =
    {
        { ID_BUTOK	, GetIR(iforeq)->ir_PositiveText , MSG_FONTREQ_POSITIVE_GAD, COOL_USEIMAGE_ID    , &udata->OKBut	  },
	{ ID_BUTCANCEL  , GetIR(iforeq)->ir_NegativeText , MSG_FONTREQ_NEGATIVE_GAD, COOL_CANCELIMAGE_ID , &udata->CancelBut  }
    };
#else
    struct ButtonInfo 	bi[NUMBUTS] =
    {
        { ID_BUTOK	, GetIR(iforeq)->ir_PositiveText , MSG_FONTREQ_POSITIVE_GAD, &cool_useimage    , &udata->OKBut	  },
	{ ID_BUTCANCEL  , GetIR(iforeq)->ir_NegativeText , MSG_FONTREQ_NEGATIVE_GAD, &cool_cancelimage , &udata->CancelBut  }
    };
#endif
    Object 		*gad;
    LONG		error;
    WORD 		gadrows, x, y, w, h, i, y2;
    WORD		sizelvwidth, labelwidth = 0, maxgadcolwidth = 0;
    
    NEWLIST(&udata->NameListviewList);

    udata->SizeListviewRenderHook.h_Entry      = (APTR)AROS_ASMSYMNAME(SizeListviewRenderFunc);
    udata->SizeListviewRenderHook.h_SubEntry   = NULL;
    udata->SizeListviewRenderHook.h_Data       = AslBase;

    udata->StringEditHook.h_Entry    = (APTR)AROS_ASMSYMNAME(StringEditFunc);
    udata->StringEditHook.h_SubEntry = NULL;
    udata->StringEditHook.h_Data     = AslBase;

    FOGetFonts(ld, AslBase);
    
    error = ERROR_NO_FREE_STORE;
    
    /* calc. min. size */

    w = 0;
    for(i = 0; i < NUMBUTS; i++)
    {
    	if(!bi[i].text) bi[i].text = GetString(bi[i].deftextid, GetIR(iforeq)->ir_Catalog, AslBase);

        x = TextLength(&ld->ld_DummyRP, bi[i].text, strlen(bi[i].text));

#if FOREQ_COOL_BUTTONS
#if USE_SHARED_COOLIMAGES
    	if (CoolImagesBase)
	{
	    bi[i].coolimage = (const struct CoolImage *)COOL_ObtainImageA(bi[i].coolid, NULL);
	}
	
	if (CoolImagesBase)
#endif
	if (ld->ld_TrueColor)
	{
	    x += IMAGEBUTTONEXTRAWIDTH + bi[i].coolimage->width;
	}
#endif

	if (x > w) w = x;	
    }
    
    udata->ButWidth = w + BUTTONEXTRAWIDTH;

    ld->ld_ButWidth = udata->ButWidth;
    ld->ld_NumButtons = 4;
    
#if FOREQ_COOL_BUTTONS

#if USE_SHARED_COOLIMAGES
    if (CoolImagesBase)
    {
#endif
	y  = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
	if (ld->ld_TrueColor)
	{
            y2 = IMAGEBUTTONEXTRAHEIGHT + DEF_COOLIMAGEHEIGHT;
	} else {
            y2 = 0;
	}
	udata->ButHeight = (y > y2) ? y : y2;
#if USE_SHARED_COOLIMAGES
    }
    else
    {
    	udata->ButHeight = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
    }
#endif

#else
    udata->ButHeight = BUTTONEXTRAHEIGHT + ld->ld_Font->tf_YSize;
#endif
    
    gadrows = 2; /* button row + string gadgets under listviews */
    if (iforeq->ifo_Flags & FOF_DODRAWMODE) gadrows++;
    if (iforeq->ifo_Flags & FOF_DOSTYLE) gadrows++;
    if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) gadrows++;
    
    ld->ld_MinWidth =  OUTERSPACINGX * 2 +
		       GADGETSPACINGX * 1 +
		       udata->ButWidth * NUMBUTS;

    ld->ld_MinHeight = OUTERSPACINGY * 2 +
		       (GADGETSPACINGY + udata->ButHeight) * gadrows +
		       BORDERLVSPACINGY * 2 +
		       (ld->ld_Font->tf_YSize + BORDERLVITEMSPACINGY * 2) * FOREQ_MIN_VISIBLELINES +
		       FONTPREVIEWHEIGHT + GADGETSPACINGY -
		       GADGETSPACINGY; /* because the string gadgets are attached to listview gadgets */

    /* make listview gadgets */
    
    sizelvwidth = PROPSIZE +
    	    	  FOREQ_VISIBILE_SIZE_CHARS * ld->ld_Font->tf_XSize +
		  BORDERLVSPACINGX * 2 +
		  BORDERLVITEMSPACINGX * 2;
    
    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = ld->ld_WBorTop + OUTERSPACINGY;
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2 - PROPSIZE - GADGETSPACINGX - sizelvwidth;
    h = -ld->ld_WBorBottom - ld->ld_WBorTop - OUTERSPACINGY * 2 -
    	udata->ButHeight * gadrows -
	GADGETSPACINGY * gadrows -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) +
	GADGETSPACINGY; /* because the string gadgets are attached to listview gadgets */
    
    {
        struct TagItem lv_tags[] = 
	{
	    {GA_Left		, x						},
	    {GA_Top		, y						},
	    {GA_RelWidth	, w						},
	    {GA_RelHeight	, h						},
	    {GA_UserData	, (IPTR)ld					},
	    {GA_ID		, ID_NAMELISTVIEW				},
	    {GA_RelVerify	, TRUE						},
	    {ASLLV_Labels	, (IPTR)&udata->NameListviewList		},
	    {TAG_IGNORE    	, 0 	    	    	    	    	    	},
	    {TAG_IGNORE     	, (IPTR)&udata->SizeListviewRenderHook	    	},
	    {ASLLV_Font     	, (IPTR)ld->ld_Font 	    	    	    	},
	    {TAG_DONE								}
	};
	
	udata->NameListview = gad = NewObjectA(AslBase->asllistviewclass, NULL, lv_tags);
	if (!gad) goto failure;

    	lv_tags[0].ti_Tag  = GA_RelRight;
	lv_tags[0].ti_Data = -ld->ld_WBorRight - OUTERSPACINGX - sizelvwidth + 1;
	lv_tags[2].ti_Tag  = GA_Width;
	lv_tags[2].ti_Data = sizelvwidth - PROPSIZE;
	lv_tags[5].ti_Data = ID_SIZELISTVIEW;
	lv_tags[7].ti_Data = 0;
	lv_tags[8].ti_Tag  = GA_Previous;
	lv_tags[8].ti_Data = (IPTR)gad;
	lv_tags[9].ti_Tag  = ASLLV_CallBack;
	
	udata->SizeListview = gad = NewObjectA(AslBase->asllistviewclass, NULL, lv_tags);
	if (!gad) goto failure;
	
    }
    
    /* make scroller gadgets for listviews */
    		       
    x = -ld->ld_WBorRight - OUTERSPACINGX - PROPSIZE - sizelvwidth - GADGETSPACINGX + 1;
    y = ld->ld_WBorTop + OUTERSPACINGY;
    w = PROPSIZE;
    h = -ld->ld_WBorBottom - ld->ld_WBorTop - OUTERSPACINGY * 2 -
    	udata->ButHeight * gadrows -
	GADGETSPACINGY * gadrows -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) +
	GADGETSPACINGY;
    {
	struct TagItem scroller_tags[] =
	{
    	    {GA_RelRight	, x		    },
	    {GA_Top		, y		    },
	    {GA_Width		, w		    },
	    {GA_RelHeight	, h		    },
	    {GA_ID		, ID_NAMELISTVIEW   },
	    {PGA_NewLook	, TRUE		    },
	    {PGA_Borderless 	, TRUE		    },
	    {PGA_Freedom	, FREEVERT	    },
	    {PGA_Top		, 0		    },
	    {PGA_Total		, 20		    },
	    {PGA_Visible	, 1		    },
	    {GA_Previous	, (IPTR)gad	    },
	    {TAG_DONE				    }
	};

	if (!makescrollergadget(&udata->NameScrollGad, ld, scroller_tags, AslBase)) goto failure;
	gad = udata->NameScrollGad.arrow2;

    	scroller_tags[0].ti_Data  = x + sizelvwidth + GADGETSPACINGX;
	scroller_tags[1].ti_Data  = y;
	scroller_tags[2].ti_Data  = w;
	scroller_tags[3].ti_Data  = h;
	scroller_tags[4].ti_Data  = ID_SIZELISTVIEW;
	scroller_tags[11].ti_Data = (IPTR)gad;
	
	if (!makescrollergadget(&udata->SizeScrollGad, ld, scroller_tags, AslBase)) goto failure;
	gad = udata->SizeScrollGad.arrow2;
	
    }

    connectscrollerandlistview(&udata->NameScrollGad, udata->NameListview, AslBase);
    connectscrollerandlistview(&udata->SizeScrollGad, udata->SizeListview, AslBase);

    /* make preview gadget */

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	GADGETSPACINGY - FONTPREVIEWHEIGHT;
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2;

    {
    	struct TagItem preview_tags[] =
	{
	    {GA_Left	    	, x 	    	    	    	    },
	    {GA_RelBottom   	, y 	    	    	    	    },
	    {GA_RelWidth    	, w 	    	    	    	    },
	    {GA_Height	    	, FONTPREVIEWHEIGHT  	    	    },
	    {GA_Previous    	, (IPTR)gad 	    	    	    },
	    {GA_ID  	    	, ID_PREVIEW     	    	    },
	    {ASLFP_SampleText	, (IPTR)iforeq->ifo_SampleText	    },
	    {ASLFP_APen     	, iforeq->ifo_FrontPen	    	    },
	    {ASLFP_BPen     	, iforeq->ifo_BackPen	    	    },
	    {TAG_DONE	    	    	    	    	    	    }
	};

	udata->Preview = gad = NewObjectA(AslBase->aslfontpreviewclass, NULL, preview_tags);
	if (!gad) goto failure;
    }
    
    /* make string gadgets */

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	(udata->ButHeight + GADGETSPACINGY) * (gadrows - 1) -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;
		
    w = -ld->ld_WBorRight - ld->ld_WBorLeft - OUTERSPACINGX * 2 - GADGETSPACINGX - sizelvwidth;
    
    {
    	struct TagItem string_tags[] =
	{
	    {GA_Left	    	, x 	    	    	    	    },
	    {GA_RelBottom   	, y 	    	    	    	    },
	    {GA_RelWidth    	, w 	    	    	    	    },
	    {GA_Height	    	, udata->ButHeight  	    	    },
	    {GA_Previous    	, (IPTR)gad 	    	    	    },
	    {STRINGA_TextVal	, (IPTR)""     	    	    	    },
	    {STRINGA_MaxChars	, MAXFONTNAME 	    	    	    },
	    {STRINGA_EditHook	, (IPTR)&udata->StringEditHook	    },
	    {GA_ID  	    	, ID_NAMESTRING     	    	    },
	    {GA_RelVerify   	, TRUE	    	    	    	    },
	    {GA_UserData    	, (IPTR)ld  	    	    	    },
	    {GA_TabCycle    	, TRUE	    	    	    	    },
	    {STRINGA_Font   	, (IPTR)ld->ld_Font 	    	    },
	    {TAG_DONE	    	    	    	    	    	    }
	};

	udata->NameString = gad = NewObjectA(AslBase->aslstringclass, NULL, string_tags);
	if (!gad) goto failure;
	
   	string_tags[0].ti_Tag  = GA_RelRight;
	string_tags[0].ti_Data = -ld->ld_WBorRight - OUTERSPACINGX - sizelvwidth + 1;
	string_tags[2].ti_Tag  = GA_Width;
	string_tags[2].ti_Data = sizelvwidth;
	string_tags[4].ti_Data = (IPTR)gad;
	string_tags[5].ti_Tag  = STRINGA_LongVal;
	string_tags[5].ti_Data = iforeq->ifo_TextAttr.ta_YSize;
	string_tags[6].ti_Data = 6;
	string_tags[8].ti_Data = ID_SIZESTRING;

	udata->SizeString = gad = NewObjectA(AslBase->aslstringclass, NULL, string_tags);
	if (!gad) goto failure;
	
    }
    
    /* make button row */
    
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight + 1;
    
    {
        struct TagItem button_tags[] =
	{
	    {GA_Text		, 0			},
	    {GA_Previous	, 0			},
	    {GA_ID		, 0			},
#if FOREQ_COOL_BUTTONS
	    {ASLBT_CoolImage	, 0			},
#else
	    {TAG_IGNORE		, 0			},
#endif	    
	    {GA_UserData	, (IPTR)ld		},
	    {GA_Left		, 0			},
	    {GA_RelBottom	, y			},
	    {GA_Width		, udata->ButWidth	},
	    {GA_Height		, udata->ButHeight	},
	    {GA_RelVerify	, TRUE			},
	    {GA_Image		, 0			}, /* means we want a frame */
	    {TAG_DONE					}
	};

	for(i = 0; i < NUMBUTS; i++)
	{
	    button_tags[0].ti_Data = (IPTR)bi[i].text;
	    button_tags[1].ti_Data = (IPTR)gad;
	    button_tags[2].ti_Data = bi[i].gadid;
	#if USE_SHARED_COOLIMAGES
	    if (CoolImagesBase == NULL) button_tags[3].ti_Tag = TAG_IGNORE;
	#endif
	    button_tags[3].ti_Data = (IPTR)bi[i].coolimage;

	    *(bi[i].objvar) = gad = NewObjectA(AslBase->aslbuttonclass, NULL, button_tags);
	    if (!gad) goto failure;
	}
	 	 
    }	 
    
    /* make labels */
        
    i = 0;

    x = ld->ld_WBorLeft + OUTERSPACINGX;
    y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	(udata->ButHeight + GADGETSPACINGY) * (gadrows - 2) -
	(FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;

    if (iforeq->ifo_Flags & (FOF_DODRAWMODE | FOF_DOSTYLE | FOF_DOFRONTPEN | FOF_DOBACKPEN))
    {
        #define FSET(x) ((iforeq->ifo_Flags & x) ? TRUE : FALSE)
	
        struct LabelInfo
	{
	    BOOL doit;
	    char *text;
	    Object **objvar;
	} li [] =
	{
	    {FSET(FOF_DOSTYLE)	    , (STRPTR)MSG_FONTREQ_STYLE_LABEL 	, &udata->StyleLabel     },
	    {FALSE  	    	    , (STRPTR)MSG_FONTREQ_COLOR_LABEL_FG, &udata->ColorLabel	 },
	    {FSET(FOF_DODRAWMODE)   , (STRPTR)MSG_FONTREQ_MODE_LABEL  	, &udata->DrawModeLabel  }
	}; 

        #undef FSET
	
        struct TagItem label_tags[] =
	{
	    {GA_Left		, 0			},
	    {GA_RelBottom	, y			},
	    {GA_Width		, 0			},
	    {GA_Height		, udata->ButHeight	},
	    {GA_Text		, 0			},
	    {GA_Previous	, (IPTR)gad		},
	    {GA_UserData	, (IPTR)ld		},
	    {GA_Disabled	, TRUE			},
	    {TAG_DONE					}
	};
    	WORD i2;
	
	if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	{
	    li[1].doit = TRUE;
	    
	    switch(iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	    {
	    	case FOF_DOFRONTPEN:
		    break;
		    
		case FOF_DOBACKPEN:
		    li[1].text = (STRPTR)MSG_FONTREQ_COLOR_LABEL_BG;
		    break;
		    
		case FOF_DOFRONTPEN | FOF_DOBACKPEN:
		    li[1].text = (STRPTR)MSG_FONTREQ_COLOR_LABEL_FGBG;
		    break;
	    }
	    
	} /* if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) */
    	for(i = 0, i2 = 0; i < 3; i++)
	{
	    if (li[i].doit)
	    {
	    	if ((i == 2) && (iforeq->ifo_ModeList))
		{
		    li[i].text = iforeq->ifo_ModeList[0];
		}
		else
		{
	    	    li[i].text = GetString((LONG)li[i].text, GetIR(iforeq)->ir_Catalog, AslBase);
		}
		str[i2++] = li[i].text;
	    }
	}
		
	w = labelwidth = BiggestTextLength(str, i2, &(ld->ld_DummyRP), AslBase);
            
	for(i = 0; i < 3;i++)
	{
	    if (!li[i].doit) continue;
	    
	    label_tags[2].ti_Data = TextLength(&ld->ld_DummyRP, li[i].text, strlen(li[i].text));
	    label_tags[0].ti_Data = x + w - label_tags[2].ti_Data;
	    label_tags[4].ti_Data = (IPTR)li[i].text;
	    label_tags[5].ti_Data = (IPTR)gad;
	    
	    *(li[i].objvar) = gad = NewObjectA(AslBase->aslbuttonclass, NULL, label_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    label_tags[1].ti_Data = y;
	}	

    	y = -ld->ld_WBorBottom - OUTERSPACINGY - udata->ButHeight - 
    	    (udata->ButHeight + GADGETSPACINGY) * (gadrows - 2) -
	    (FONTPREVIEWHEIGHT + GADGETSPACINGY) + 1;
	    
	x = ld->ld_WBorLeft + OUTERSPACINGX + w + LABELSPACINGX;

    	/* Make Style gadget */
	
	if (iforeq->ifo_Flags & FOF_DOSTYLE)
	{
	    STRPTR stylestrings[3];
	    
	    struct TagItem style_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, 0				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_STYLE			  },
		{ASLFS_LabelArray    	, (IPTR)stylestrings	    	  },
		{ASLFS_Style		, iforeq->ifo_TextAttr.ta_Style	  },
		{TAG_DONE						  }
	    };

    	    stylestrings[0] = GetString(MSG_FONTREQ_STYLE_BOLD, GetIR(iforeq)->ir_Catalog, AslBase);
    	    stylestrings[1] = GetString(MSG_FONTREQ_STYLE_ITALIC, GetIR(iforeq)->ir_Catalog, AslBase);
    	    stylestrings[2] = GetString(MSG_FONTREQ_STYLE_UNDERLINED, GetIR(iforeq)->ir_Catalog, AslBase);
	    
	    w = BiggestTextLength(stylestrings, 3, &(ld->ld_DummyRP), AslBase);
	    w *= 2;
	    w *= 3;
	    
	    style_tags[3].ti_Data = w;
	    
	    if (w > maxgadcolwidth) maxgadcolwidth = w;
	    
	    udata->StyleGadget = gad = NewObjectA(AslBase->aslfontstyleclass, NULL, style_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    
	}
	
	w = udata->ButHeight * 12 / 10 + 19; /* CYCLEIMAGEWIDTH = 19 */
	
	/* Make FrontPen gadget */
	
	if (iforeq->ifo_Flags & FOF_DOFRONTPEN)
	{
	    struct TagItem cp_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_FRONTPEN			  },
		{ASLCP_Color	    	, iforeq->ifo_FrontPen	    	  },
		{ASLCP_ColorTable   	, (IPTR)iforeq->ifo_FrontPens     },
		{ASLCP_NumColors    	, iforeq->ifo_MaxFrontPen   	  },
		{TAG_DONE						  }
		
	    };
	    
	    udata->FGColorGadget = gad = NewObjectA(AslBase->aslcolorpickerclass, NULL, cp_tags);
	    if (!gad) goto failure;
	    
	    x += w + GADGETSPACINGX;
	}

    	/* Make BackPen gadget */
	
	if (iforeq->ifo_Flags & FOF_DOBACKPEN)
	{
	    struct TagItem cp_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_Width		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_BACKPEN			  },
		{ASLCP_Color	    	, iforeq->ifo_BackPen	    	  },
		{ASLCP_ColorTable   	, (IPTR)iforeq->ifo_BackPens      },
		{ASLCP_NumColors    	, iforeq->ifo_MaxBackPen   	  },
		{TAG_DONE						  }
		
	    };
	    
	    udata->BGColorGadget = gad = NewObjectA(AslBase->aslcolorpickerclass, NULL, cp_tags);
	    if (!gad) goto failure;
	    
	}

    	if (iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	{
	    if ((iforeq->ifo_Flags & (FOF_DOFRONTPEN | FOF_DOBACKPEN)) == (FOF_DOFRONTPEN | FOF_DOBACKPEN))
	    {
	    	w += GADGETSPACINGX + w;
	    }
	    
	    if (w > maxgadcolwidth) maxgadcolwidth = w;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	}
	
	
    	/* Make DrawMode gadget */

	x = ld->ld_WBorLeft + OUTERSPACINGX + labelwidth + LABELSPACINGX;

	w = -ld->ld_WBorLeft - ld->ld_WBorRight - OUTERSPACINGX * 2 -
            labelwidth - LABELSPACINGX;

	
	if (iforeq->ifo_Flags & FOF_DODRAWMODE)
	{
	    struct TagItem cycle_tags[] =
	    {
	        {GA_Previous		, (IPTR)gad			  },
		{GA_Left		, x				  },
		{GA_RelBottom		, y				  },
		{GA_RelWidth		, w				  },
		{GA_Height		, udata->ButHeight		  },
		{GA_RelVerify		, TRUE				  },
		{GA_UserData		, (IPTR)ld			  },
		{GA_ID			, ID_DRAWMODE			  },
		{ASLCY_Labels		, 0 	    	    	    	  },
		{ASLCY_Active		, iforeq->ifo_DrawMode	    	  },
		{ASLCY_Font 	    	, (IPTR)ld->ld_Font 	    	  },
		{TAG_DONE						  }
		
	    };
	    static LONG labelids[] =
	    {
		MSG_FONTREQ_MODE_TEXT,
		MSG_FONTREQ_MODE_TEXTANDFIELD,
		MSG_FONTREQ_MODE_COMPLEMENT,
	    };
	    STRPTR *labels;
	    
	    
	    if (iforeq->ifo_ModeList)
	    {
	    	labels = &iforeq->ifo_ModeList[1];
	    }
	    else
	    {
    	    	labels = (STRPTR *)&iforeq->ifo_DrawModeJAM1Text;
	    	
    		for(i = 0; i < 3; i++)
		{
	    	    labels[i] = GetString(labelids[i], GetIR(iforeq)->ir_Catalog, AslBase);
		}
	    }
	    
	    cycle_tags[8].ti_Data = (IPTR)labels;
	    
	    i = CYCLEEXTRAWIDTH +  BiggestTextLength(labels,
	    					     0x7FFF,
						     &(ld->ld_DummyRP),
						     AslBase);						     
	    if (i > maxgadcolwidth) maxgadcolwidth = i;
	    
	    udata->DrawModeGadget = gad = NewObjectA(AslBase->aslcycleclass, NULL, cycle_tags);
	    if (!gad) goto failure;
	    
	    y += udata->ButHeight + GADGETSPACINGY;
	    
	} /* if (iforeq->ifo_Flags & FOF_DODRAWMODE) */
		
    } /* if (iforeq->ifo_Flags & (FOF_DODRAWMODE | FOF_DOSTYLE | FOF_DOFRONTPEN | FOF_DOBACKPEN)) */

#if AVOID_FLICKER
    {
    	struct TagItem eraser_tags[] =
	{
	    {GA_Previous, (IPTR)gad},
	    {TAG_DONE}
	};
	
	udata->EraserGadget = gad = NewObjectA(AslBase->asleraserclass, NULL, eraser_tags);
	/* Doesn't matter if this failed */
    }
#endif
    
    w = OUTERSPACINGX + labelwidth + LABELSPACINGX + maxgadcolwidth + OUTERSPACINGX;
    if (w > ld->ld_MinWidth) ld->ld_MinWidth = w;
    
    ld->ld_GList = (struct Gadget *)udata->NameListview;							 
    
    /* Menus */
    {
        struct NewMenu nm[] =
	{
	    {NM_TITLE, (STRPTR)MSG_FONTREQ_MEN_CONTROL							},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_LASTFONT , 0, 0, 0, (APTR)FOMEN_LASTFONT		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_NEXTFONT , 0, 0, 0, (APTR)FOMEN_NEXTFONT 	},
	     {NM_ITEM, NM_BARLABEL									},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_RESTORE	, 0, 0, 0, (APTR)FOMEN_RESTORE 		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_RESCAN	, 0, 0, 0, (APTR)FOMEN_RESCAN		},
	     {NM_ITEM, NM_BARLABEL									},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_OK   	, 0, 0, 0, (APTR)FOMEN_OK		},
	     {NM_ITEM, (STRPTR)MSG_FONTREQ_MEN_CONTROL_CANCEL	, 0, 0, 0, (APTR)FOMEN_CANCEL		},
	    {NM_END																}
	};

	struct TagItem menu_tags[] =
	{
	    {GTMN_NewLookMenus  , TRUE  	    	    	    },
	    {GTMN_TextAttr	, (IPTR)GetIR(iforeq)->ir_TextAttr  },
	    {TAG_DONE   	    	    	    	    	    }
	};
	
	if (menu_tags[1].ti_Data == 0) menu_tags[1].ti_Tag = TAG_IGNORE;

	LocalizeMenus(nm, GetIR(iforeq)->ir_Catalog, AslBase);

	/* Don't fail, if menus cannot be created/layouted, because a requester
	   without menus is still better than no requester at all */
	   
	if ((ld->ld_Menu = CreateMenusA(nm, NULL)))
	{
	    if (!LayoutMenusA(ld->ld_Menu, ld->ld_VisualInfo, menu_tags))
	    {
	        FreeMenus(ld->ld_Menu);ld->ld_Menu = NULL;
	    }
	}
    }
    
    FORestore(ld, iforeq->ifo_TextAttr.ta_Name, iforeq->ifo_TextAttr.ta_YSize,  AslBase);
    
    SetIoErr(0);
    ReturnBool ("FOGadInit", TRUE);
    
failure:
    SetIoErr(error);
    
    D(bug("failure\n"));

    FOGadCleanup(ld, ASLB(AslBase));

    ReturnBool ("FOGadInit", FALSE);

}
示例#10
0
文件: vastubs.c 项目: amiga-mui/nlist
APTR NewObject( struct IClass *classPtr, CONST_STRPTR classID, Tag tag1, ... )
{ return NewObjectA(classPtr, classID, (struct TagItem *)&tag1); }
示例#11
0
struct ButtonGadget *createButton
(
    ULONG left, ULONG top, ULONG width, ULONG height,
    struct Gadget *prev,
    STRPTR name,
    UWORD id,
    struct BootMenuBase *BootMenuBase
)
{
    struct TagItem tags[] =
    {
        {GA_Left,           (IPTR)left}, /* 0 */
        {GA_Top,             (IPTR)top}, /* 1 */
        {GA_Height,       (IPTR)height}, /* 2 */
        {GA_Width,         (IPTR)width}, /* 3 */
        {GA_Border,         0}, /* 4 */
        {GA_SelectRender,   0}, /* 5 */
        {GA_Previous, (IPTR)prev}, /* 6 */
        {GA_Text,     (IPTR)name}, /* 7 */
        {GA_ID,         (IPTR)id}, /* 8 */
        {GA_Immediate,      TRUE},
        {GA_RelVerify,      TRUE},
        {TAG_DONE,           0UL}
    };
    struct ButtonGadget *button;

    D(bug("[BootMenu] createButton()\n"));

    if ((button = AllocMem(sizeof(struct ButtonGadget), MEMF_PUBLIC | MEMF_CLEAR)) != NULL)
    {
        if (!(prev)) tags[6].ti_Tag = TAG_IGNORE;

        tags[4].ti_Data = (IPTR)&button->uborder2;
        tags[5].ti_Data = (IPTR)&button->sborder2;
        button->XY1[1] = height;
        button->XY1[4] = width;
        button->XY2[0] = width;
        button->XY2[2] = width;
        button->XY2[3] = height;
        button->XY2[5] = height;
        button->uborder1.FrontPen = 1;
        button->uborder1.DrawMode = JAM1;
        button->uborder1.Count = 3;
        button->uborder1.XY = button->XY2;
        button->uborder2.FrontPen = 2;
        button->uborder2.DrawMode = JAM1;
        button->uborder2.Count = 3;
        button->uborder2.XY = button->XY1;
        button->uborder2.NextBorder = &button->uborder1;
        button->sborder1.FrontPen = 2;
        button->sborder1.DrawMode = JAM1;
        button->sborder1.Count = 3;
        button->sborder1.XY = button->XY2;
        button->sborder2.FrontPen = 1;
        button->sborder2.DrawMode = JAM1;
        button->sborder2.Count = 3;
        button->sborder2.XY = button->XY1;
        button->sborder2.NextBorder = &button->sborder1;
        if ((button->gadget = NewObjectA(NULL, FRBUTTONCLASS, tags)) != NULL)
        {
            if (prev != NULL)
            {
                prev->NextGadget = button->gadget;
            }
            return button;
        }
        FreeMem(button, sizeof(struct ButtonGadget));
    }
    return NULL;
}
示例#12
0
IPTR GTText__OM_NEW(Class * cl, Object * o, struct opSet *msg)
{

    EnterFunc(bug("Text::New()\n"));
    o = (Object *) DoSuperMethodA(cl, o, (Msg)msg);
    if (o)
    {
    	struct TextData *data = INST_DATA(cl, o);
    	struct TextAttr *tattr, def_tattr;
   	
   	/* Set some defaults */
    	data->format	= "%ld";
    	data->flags 	= 0;
    	data->frontpen	= TEXTPEN;
    	data->backpen  	= BACKGROUNDPEN;
    	data->toprint 	= (IPTR) NULL;
    	data->font 	= NULL;
    	data->maxnumberlength = 0; /* This means "no limit" */
    	data->dispfunc = (APTR)GetTagData(GTA_Text_DispFunc, (IPTR) NULL, msg->ops_AttrList);
    	data->labelplace = GetTagData(GA_LabelPlace, GV_LabelPlace_Left, msg->ops_AttrList);
	
    	/* Open font to use for gadget */
    	
    	/* We will *ALWAYS* have a valid DrawInfo struct */
    	data->dri = (struct DrawInfo *)GetTagData(GA_DrawInfo, (IPTR) NULL, msg->ops_AttrList);

    	def_tattr.ta_Name  = data->dri->dri_Font->tf_Message.mn_Node.ln_Name;
    	def_tattr.ta_YSize = data->dri->dri_Font->tf_YSize;
    	def_tattr.ta_Style = 0;
    	def_tattr.ta_Flags = 0;

    	tattr = (struct TextAttr *)GetTagData(GA_TextAttr, (IPTR)&def_tattr, msg->ops_AttrList);

    	data->font = OpenFont(tattr);
    	if (!data->font)
    	   goto error;
    	
    	
    	if (GetTagData(GTTX_CopyText, (IPTR)FALSE, msg->ops_AttrList))
    	{
    	    STRPTR text;
    	    
    	    D(bug("Got GTTX_CopyText\n"));
    	    text = (STRPTR)GetTagData(GTTX_Text, (IPTR)"Text MUST be passed with OM_NEW", msg->ops_AttrList);
    	    if (text)
	    {		
		D(bug("Text: %s\n", text));
		/* Allocate copy buffer for the text */
		data->toprint = (IPTR)AllocVec(strlen(text) + 1, MEMF_ANY);
		if (data->toprint)
		{
		    data->flags |= TEXTF_COPYTEXT;
		    D(bug("Copying text\n"));
		    strcpy((STRPTR)data->toprint, text);
		}
		else
		{
		    goto error;
		}
	    } else {
		/* If text==NULL we have nothing to copy */
		data->toprint = 0;
	    }
    	} else {
	    STRPTR text;
	    
	    if ((text = (STRPTR)GetTagData(GTTX_Text, (IPTR) NULL, msg->ops_AttrList)))
	    {
	        data->toprint = (IPTR)text;
	    }
	}

    	D(bug("calling text_set\n"));
    	text_set(cl, o, msg);
	
	if (data->flags & TEXTF_BORDER)
	{
	    struct TagItem frame_tags[] =
	    {
		{IA_Width	, GetTagData(GA_Width, 0, msg->ops_AttrList)				},
		{IA_Height	, GetTagData(GA_Height, 0, msg->ops_AttrList)				},
		{IA_Resolution	, (data->dri->dri_Resolution.X << 16) + data->dri->dri_Resolution.Y	},
		{IA_FrameType	, FRAME_BUTTON								},
		{IA_Recessed	, TRUE									},
		{TAG_DONE	, 0UL									}
	    };

	    data->frame = NewObjectA(NULL, FRAMEICLASS, frame_tags);
	}
	
    }
    ReturnPtr ("Text::New", IPTR, (IPTR)o);
    
error:
    CoerceMethod(cl, o, OM_DISPOSE);
    ReturnPtr ("Text::New", IPTR, (IPTR) NULL);
}