コード例 #1
0
VOID CM__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
{
    struct colormap_data *data;
    ULONG   	    	idx;
    
    EnterFunc(bug("ColorMap::Get()\n"));
    data = OOP_INST_DATA(cl, o);
    
    if (IS_COLORMAP_ATTR(msg->attrID, idx))
    {
    	switch (idx)
	{
	    case aoHidd_ColorMap_NumEntries:
	    	*msg->storage = data->clut.entries;
		break;
	    
	    default:
	    	D(bug("!!! Unknow colormap attr in ColorMap::Get()\n"));
		OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
		break;
	}
    }
    else
    {
	OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
    }
    
    ReturnVoid("ColorMap::Get");
}
コード例 #2
0
ファイル: gfx_colormapclass.c プロジェクト: michalsc/AROS
OOP_Object *CM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
{
    struct Library *UtilityBase = CSD(cl)->cs_UtilityBase;
    struct Library *OOPBase = CSD(cl)->cs_OOPBase;
    struct colormap_data    *data;
    ULONG   	    	    numentries;
    struct TagItem  	    *tag, *tstate;
    BOOL    	    	    ok = FALSE;
    
    EnterFunc(bug("ColorMap::New()\n"));
    numentries = 256;
    
    for (tstate = msg->attrList; (tag = NextTagItem(&tstate)); )
    {
    	ULONG idx;
	
    	if (IS_COLORMAP_ATTR(tag->ti_Tag, idx))
	{
	    switch (idx)
	    {
	    	case aoHidd_ColorMap_NumEntries:
		    numentries = tag->ti_Data;
		    if (numentries > 256 || numentries < 0)
		    {
		     	D(bug("!!! ILLEGAL value for NumEntries in ColorMap::New()\n"));
		    }
		    break;
		   
	    } /* switch */
	
	}
    }
    
    /* Create the object */
    
    o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
    if (NULL == o)
    	return NULL;
	
    data = OOP_INST_DATA(cl, o);
    
    data->clut.entries = numentries;
    
    data->clut.colors = AllocMem(sizeof (HIDDT_Color) * data->clut.entries, MEMF_CLEAR);
    if (NULL != data->clut.colors)
    {
	ok = TRUE;
    }
    
    if (!ok)
    {
    	ULONG dispose_mid;
	
	dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
	OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid);
	o = NULL;
    }
    
    ReturnPtr("ColorMap::New", OOP_Object *, o);
}