Пример #1
0
void GuiImages::AssignSpriteToImage(GuiSprite *spr, const char *name, GuiRect rect)
{
    GuiImage *img;
    IMGPOS *p = FindImage(name, &img);
    if( p != NULL ) {
        IMGPOS imgpos = *p;
        if( rect.x > 0 ) {
            imgpos.posx += rect.x;
            imgpos.width -= rect.x;
        }
        if( rect.y > 0 ) {
            imgpos.posy += rect.y;
            imgpos.height -= rect.y;
        }
        if( rect.width > 0 && rect.width < imgpos.width ) {
            imgpos.width = rect.width;
        }
        if( rect.height > 0 && rect.height < imgpos.height ) {
            imgpos.height = rect.height;
        }
        rect.x = imgpos.posx;
        rect.y = imgpos.posy;
        rect.width = imgpos.width;
        rect.height = imgpos.height;
        spr->SetImage(img, rect);
    }
}
Пример #2
0
static void FetchTexture( StoreInfo *info, LWO2_surf *lwo2, LWTextureID texID, LWID chan )
{
	OBJ2            *obj   = info->obj;
	LWSurfaceFuncs  *surff = info->surff;
	LWTextureFuncs	*txtrf = info->txtrf;
	LWTLayerID		 layr;
	LWImageID		 imgID;
	MEMSaveState    *save;
	LWO2_surf_blok  *blok;
	LWO2_blok_head  *head;
	char             buff[4096];
	int              nbytes;
    ID4              id;
    U4               type;
	U2               size;
	ChunkBuff        ch;

	save   = MEM_openSave( buff, sizeof(buff), LWIO_BINARY );
	(*txtrf->save)( texID, (LWSaveState *) save );
	nbytes = MEM_sizeSave( save );
	MEM_closeSave( save );

	chunk_buff_init( &ch, buff, nbytes );
	pull_id4( id, &ch );
	pull_u2 ( &size, 1, &ch );

	layr = (*txtrf->firstLayer)( texID );

    while ((int) ch.bytesread < nbytes) 
    {
		pull_id4( id, &ch );
		pull_u2 ( &size, 1, &ch );
		type = MAKE_ID(id[0],id[1],id[2],id[3]);

		if (type == ID_BLOK) 
		{
			type = (*txtrf->layerType)( layr );
			blok = LWO2_unpackBlok( obj, size, ch.buff, lwo2 );
			head = blok->head;
			if (head && head->chan) {
				head->chan->texture_type = chan;
			}
			if (blok->imag) {
				(*txtrf->getParam)( layr, TXTAG_IMAGE, &imgID );
				blok->imag->texture_image = FindImage( info, imgID );
			}
			layr = (*txtrf->nextLayer)( texID, layr );
		}

		seek_buff( size, &ch );
	}

	if (0) {
		FILE  *fp = fopen("C:\\txtr.txt", "wb");
//		fwrite(buff, size, 1, fp);
		LWO2_dumpSurf( obj, lwo2, fp );
		fclose(fp);
	}
}
Пример #3
0
void GuiImages::GetImage(const char *name, GuiImage **image, GuiRect *rect)
{
    IMGPOS *p = FindImage(name, image);
    if( p != NULL ) {
        rect->x = p->posx;
        rect->y = p->posy;
        rect->width = p->width;
        rect->height = p->height;
    }
}
Пример #4
0
CTIImageList::~CTIImageList()
{
	CTIImageHeader * Previos;
	CTIImageHeader * LastImage;

	while ( (LastImage = FindImage("", &Previos)) != Begin() )
	{
		Previos->SetNext(LastImage->GetNext());
		delete LastImage;
	}
}
Пример #5
0
Bool32 CTIImageList::EnableMask(const char *pName, char* pType, Bool32 mEnabled)
{
	CTIImageHeader * Image = FindImage(pName);

	if (Image == NULL)
	{
		SetReturnCode_cimage(IDS_CIMAGE_NO_IMAGE_FOUND);
		return FALSE;
	}

	return Image->EnableMask(pType, mEnabled);
}
Пример #6
0
ALERROR CImageLibrary::AddImage (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	AddImage
//
//	Add an image to the library

	{
	ALERROR error;

	//	Create the image desc

	CObjectImage *pNewImage;
	if (error = CObjectImage::CreateFromXML(Ctx, pDesc, &pNewImage))
		return error;

	//	If we defer loading, at least make sure that the images exist

	if (pDesc->GetAttributeBool(LOAD_ON_USE_ATTRIB))
		{
		if (error = pNewImage->Exists(Ctx))
			{
			delete pNewImage;
			return error;
			}
		}

	//	Otherwise, load and lock the image

	else
		{
		if (error = pNewImage->Lock(Ctx))
			{
			delete pNewImage;
			return error;
			}
		}

	//	Add to the library

	if (error = m_Library.AddEntry(pNewImage->GetUNID(), (CObject *)pNewImage))
		{
		if (FindImage(pNewImage->GetUNID()))
			Ctx.sError = strPatternSubst(CONSTLIT("Duplicate UNID: %x"), pNewImage->GetUNID());
		else
			Ctx.sError = strPatternSubst(CONSTLIT("Unable to add image to library: %x"), pNewImage->GetUNID());
		delete pNewImage;
		return error;
		}

	return NOERROR;
	}
Пример #7
0
Bool32 CTIImageList::AddImage(const char *lpName, Handle hDIB, uint32_t wFlag)
{
	CTIImageHeader * NewImage = NULL;
	CTIImageHeader * LastImage = NULL;

/* commented by Andrey
    if ( FindImage(lpName, &LastImage) )
	{
		SetReturnCode_cimage(IDS_CIMAGE_IMAGE_NAME_REPEATED);
		return FALSE;
	}
*/
    while (FindImage(lpName, &LastImage))
    {
        LastImage = NULL;
        DeleteImage(lpName);
    }

	if ( lpName == NULL && lpName[0] == 0x0 )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_NAME);
		return FALSE;
	}

	if ( hDIB == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_INFO);
		return FALSE;
	}

	if ( LastImage == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGES_CONTAINER);
		return FALSE;
	}

	NewImage = new CTIImageHeader(lpName, hDIB, wFlag);


	if ( NewImage == NULL )
	{
		SetReturnCode_cimage(IDS_CIMAGE_INVALID_IMAGE_INFO);
		return FALSE;
	}

	NewImage->SetNext(LastImage->GetNext());
	LastImage->SetNext(NewImage);

	return TRUE;
}
Пример #8
0
Bool32 CTIImageList::GetImage(const char *lpName, Handle* phDIB)
{
	CTIImageHeader * Image = FindImage(lpName);

	if (Image == NULL)
	{
		SetReturnCode_cimage(IDS_CIMAGE_NO_IMAGE_FOUND);
		return FALSE;
	}

	*phDIB = Image->GetImageHandle();

	return TRUE;
}
Пример #9
0
Bool32 CTIImageList::GetImageReadMask(const char *lpName, PPCTIMask ppMask, PBool32 pEnMask)
{
	CTIImageHeader * Image = FindImage(lpName);

	if (Image == NULL)
	{
		SetReturnCode_cimage(IDS_CIMAGE_NO_IMAGE_FOUND);
		return FALSE;
	}

	*ppMask = Image->GetReadMask();
	*pEnMask = Image->IsMaskEnabled("r");
	return TRUE;
}
Пример #10
0
Bool32 CTIImageList::DeleteImage(const char *lpName)
{
	CTIImageHeader * Previos = NULL;
	CTIImageHeader * ToDelete = FindImage(lpName, &Previos );

	if ( ToDelete != NULL  )
	{
		Previos->SetNext(ToDelete->GetNext());
		delete ToDelete;
		return TRUE;
	}

	return FALSE;
}
Пример #11
0
Bool32 CTIImageList::SetImageReadMask(const char *lpName,PCTIMask pAMask)
{
	Bool32 bRet;
	CTIImageHeader * Image = FindImage(lpName);

	if (Image == NULL)
	{
		SetReturnCode_cimage(IDS_CIMAGE_NO_IMAGE_FOUND);
		return FALSE;
	}

	bRet = Image->SetReadMask(pAMask);

	return TRUE;
}
Пример #12
0
	iResourceBase* cImageManager::CreateInFrame(const tString& asName, int alFrameHandle)
	{
		cResourceImage *pImage = NULL;
		tString sPath;

		BeginLoad(asName);

		pImage = FindImage(asName, sPath);
		if(!pImage)
		{
			if(sPath != "")
			{
				iBitmap2D *pBmp;
				pBmp = mpLowLevelResources->LoadBitmap2D(sPath);
				if(pBmp==NULL){
					Error("Imagemanager Couldn't load bitmap '%s'\n", sPath.c_str());
					EndLoad();
					return NULL;
				}
				
				pImage = AddToFrame(pBmp, alFrameHandle);

				hplDelete(pBmp);

				if(pImage==NULL){
					Error("Imagemanager couldn't create image '%s'\n", asName.c_str());
				}
				
				if(pImage) AddResource(pImage);
 			}
		}
		else
		{
			//Log("Found '%s' in stock!\n",asName.c_str());
		}

		if(pImage)pImage->IncUserCount();
		else Error("Couldn't load image '%s'\n",asName.c_str());

		//Log("Loaded image %s, it has %d users!\n", pImage->GetName().c_str(),pImage->GetUserCount());
		//Log(" frame has %d pics\n", pImage->GetFrameTexture()->GetPicCount());

		EndLoad();
        return pImage;
	}
Пример #13
0
static RImage * get_texture_image(WScreen *scr, const char *pixmap_file)
{
	char *file;
	RImage *image;

	file = FindImage(wPreferences.pixmap_path, pixmap_file);
	if (!file) {
		wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file);
		return NULL;
	}
	image = RLoadImage(scr->rcontext, file, 0);
	if (!image) {
		wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode));
		wfree(file);
		return NULL;
	}
	wfree(file);

	return image;
}
Пример #14
0
static void updateSettingsPanelIcon(AppSettingsPanel * panel)
{
	char *file;

	file = WMGetTextFieldText(panel->iconField);
	if (!file)
		WMSetLabelImage(panel->iconLabel, NULL);
	else {
		char *path;

		path = FindImage(wPreferences.icon_path, file);
		if (!path) {
			wwarning(_("could not find icon %s, used in a docked application"), file);
			wfree(file);
			WMSetLabelImage(panel->iconLabel, NULL);
			return;
		} else {
			WMPixmap *pixmap;
			RColor color;

			color.red = 0xae;
			color.green = 0xaa;
			color.blue = 0xae;
			color.alpha = 0;
			pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color);
			if (!pixmap) {
				WMSetLabelImage(panel->iconLabel, NULL);
			} else {
				WMSetLabelImage(panel->iconLabel, pixmap);
				WMReleasePixmap(pixmap);
			}
		}
		wfree(file);
		wfree(path);
	}
}
Пример #15
0
static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, const char *wm_instance, const char *wm_class, int flags)
{
	WMPixmap *pixmap = (WMPixmap *) NULL;
	char *file = NULL, *path = NULL;

	if ((flags & USE_TEXT_FIELD) != 0) {
		file = WMGetTextFieldText(panel->fileText);
		if (file && file[0] == 0) {
			wfree(file);
			file = NULL;
		}
	} else if (flags & REVERT_TO_DEFAULT) {
		const char *db_icon;

		/* Get the application icon, default NOT included */
		db_icon = wDefaultGetIconFile(wm_instance, wm_class, False);
		if (db_icon != NULL) {
			file = wstrdup(db_icon);
			flags |= UPDATE_TEXT_FIELD;
		}
	}

	if ((flags & UPDATE_TEXT_FIELD) != 0)
		WMSetTextFieldText(panel->fileText, file);

	if (file) {
		path = FindImage(wPreferences.icon_path, file);

		if (!path) {
			char *buf;
			int len = strlen(file) + 80;

			buf = wmalloc(len);
			snprintf(buf, len, _("Could not find icon \"%s\" specified for this window"), file);
			wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, _("OK"), NULL, NULL);
			wfree(buf);
			wfree(file);
			return -1;
		}

		pixmap = WMCreatePixmapFromFile(scrPtr, path);
		wfree(path);

		if (!pixmap) {
			char *buf;
			int len = strlen(file) + 80;

			buf = wmalloc(len);
			snprintf(buf, len, _("Could not open specified icon \"%s\":%s"),
				 file, RMessageForError(RErrorCode));
			wMessageDialog(panel->frame->screen_ptr, _("Error"), buf, _("OK"), NULL, NULL);
			wfree(buf);
			wfree(file);
			return -1;
		}
		wfree(file);
	}

	WMSetLabelImage(panel->iconLbl, pixmap);
	if (pixmap)
		WMReleasePixmap(pixmap);

	return 0;
}
Пример #16
0
WAppIcon*
wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
                      char *wm_class, int tile)
{
    WAppIcon *dicon;
    char *path;

    dicon = wmalloc(sizeof(WAppIcon));
    wretain(dicon);
    memset(dicon, 0, sizeof(WAppIcon));
    dicon->yindex = -1;
    dicon->xindex = -1;

    dicon->prev = NULL;
    dicon->next = scr->app_icon_list;
    if (scr->app_icon_list) {
        scr->app_icon_list->prev = dicon;
    }
    scr->app_icon_list = dicon;

    if (command) {
        dicon->command = wstrdup(command);
    }
    if (wm_class)
        dicon->wm_class = wstrdup(wm_class);
    if (wm_instance)
        dicon->wm_instance = wstrdup(wm_instance);

    path = wDefaultGetIconFile(scr, wm_instance, wm_class, True);
    if (!path && command) {
        wApplicationExtractDirPackIcon(scr, command, wm_instance, wm_class);

        path = wDefaultGetIconFile(scr, wm_instance, wm_class, False);
    }

    if (path)
        path = FindImage(wPreferences.icon_path, path);

    dicon->icon = wIconCreateWithIconFile(scr, path, tile);
    if (path)
        wfree(path);
#ifdef XDND
    wXDNDMakeAwareness(dicon->icon->core->window);
#endif

#ifdef DEMATERIALIZE_ICON
    {
        XSetWindowAttributes attribs;
        attribs.save_under = True;
        XChangeWindowAttributes(dpy, dicon->icon->core->window,
                                CWSaveUnder, &attribs);
    }
#endif

    /* will be overriden by dock */
    dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
    dicon->icon->core->descriptor.handle_expose = iconExpose;
    dicon->icon->core->descriptor.parent_type = WCLASS_APPICON;
    dicon->icon->core->descriptor.parent = dicon;
    AddToStackList(dicon->icon->core);

    return dicon;
}
Пример #17
0
VOID 
REINITIALIZE_ADAPTER( 
	PVOID 
	)

/*++

Routine Description

	This routine re-initializes display driver
	 to obtains its DrvCoptBits pointer.
	This routine executed as a separate thread in the context of CSRSS.EXE

Arguments

	PVOID

		Thread context, always NULL

Return Value

	None, thread terminates by call PsTerminateSystemThread

Environment

	Separate thread of CSRSS process

--*/

{
	//
	// This routine runs in the context of csrss.exe
	//
	
	KdPrint(("REINITIALIZE_ADAPTER enter\n"));

	HANDLE hDrv = EngLoadImage (L"vid_copy.dll");
	KdPrint(("vid_copy is %X\n", hDrv));
	if (hDrv)
	{
		BOOLEAN (NTAPI *pOriginalDrvEnableDriver)(
			ULONG iEngineVersion,
			ULONG cj,
			PDRVENABLEDATA pded
			);

		*(PVOID*)&pOriginalDrvEnableDriver = EngFindImageProcAddress (hDrv, "DrvEnableDriver");

		KdPrint(("pOriginalDrvEnableDriver = %X\n", pOriginalDrvEnableDriver));

		if (pOriginalDrvEnableDriver)
		{
			BOOLEAN Ret;
			DRVENABLEDATA DrvEnableData = {0};
		
			Ret = pOriginalDrvEnableDriver (DDI_DRIVER_VERSION_NT5_01_SP1,
				sizeof(DrvEnableData),
				&DrvEnableData);

			KdPrint(("pOriginalDrvEnableDriver returned %X\n", Ret));

			if (Ret)
			{
				for (ULONG i = 0; i<DrvEnableData.c; i++)
				{
					if (DrvEnableData.pdrvfn[i].iFunc == INDEX_DrvCopyBits)
					{
						KdPrint(("Found DrvCopyBits: %X\n", DrvEnableData.pdrvfn[i].pfn));

						HANDLE hKey;
						wchar_t value[512];

						hKey = RegOpenKey (L"\\Registry\\Machine\\Software\\NGdbg", KEY_QUERY_VALUE);
						if (hKey)
						{
							ULONG Len = sizeof(value);

							if (RegQueryValue (hKey, L"DisplayDriver", REG_SZ, value, &Len))
							{
								KdPrint(("Display driver: %S\n", value));

								wcscat (value, L".dll");

								PVOID OrigBase = FindImage (value);
								PVOID VidBase = FindImage (L"vid_copy.dll");

								if (OrigBase && VidBase)
								{
									ULONG Offset = (ULONG)DrvEnableData.pdrvfn[i].pfn - (ULONG)VidBase;

									KdPrint(("Offset %X\n", Offset));

									pDrvCopyBits = (PUCHAR)OrigBase + Offset;

									KdPrint(("DrvCopyBits %X\n", pDrvCopyBits));
								}
								else
								{
									KdPrint(("FindImage failed: OrigBase %X, VidBase %X\n", OrigBase, VidBase));
								}
							}
							else
							{
								KdPrint(("RegQueryValue failed\n"));
							}

							ZwClose (hKey);
						}
						else
						{
							KdPrint(("RegOpenKey failed\n"));
						}
					}
				}
			}
		}

		EngUnloadImage (hDrv);
	}

	KdPrint(("REINITIALIZE_ADAPTER exit\n"));

	PsTerminateSystemThread (0);
}
Пример #18
0
static int FetchSurface( StoreInfo *info, LWSurfaceID surfID, U1 *buff )
{
	OBJ2             *obj      = info->obj;
	LWSurfaceFuncs   *surff    = info->surff;
	LWTextureID       texID;
	LWEnvelopeID      envlID;
	LWChanGroupID     grpID;
	LWImageID		  imageID;
	LWO2_surf         lwo2;
	double           *fval;
	int               ival, size;
	const char       *colorVMap;

	memset( &lwo2, 0x00, sizeof(LWO2_surf) );
											/*  COLR  */
	if ((fval = (*surff->getFlt)( surfID, SURF_COLR )) != NULL) {
		lwo2.colr = (LWO2_surf_colr *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_colr) );
		lwo2.colr->color[0] = (F4) fval[0];
		lwo2.colr->color[1] = (F4) fval[1];
		lwo2.colr->color[2] = (F4) fval[2];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_COLR )) != NULL) {
		if (lwo2.colr == NULL) {
			lwo2.colr = (LWO2_surf_colr *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_colr) );
		}
		lwo2.colr->envelope = FetchEnvelope( info, envlID );
		grpID  = (*surff->chanGrp)( surfID );
		FetchChannel( info, grpID, ENVL_COLR_GREEN );
		FetchChannel( info, grpID, ENVL_COLR_BLUE );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_COLR )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_COLR );
	}

											/*  LUMI  */
	if ((fval = (*surff->getFlt)( surfID, SURF_LUMI )) != NULL) {
		lwo2.lumi = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.lumi->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_LUMI )) != NULL) {
		if (lwo2.lumi == NULL) {
			lwo2.lumi = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.lumi->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_LUMI )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_LUMI );
	}

											/*  DIFF  */
	if ((fval = (*surff->getFlt)( surfID, SURF_DIFF )) != NULL) {
		lwo2.diff = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.diff->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_DIFF )) != NULL) {
		if (lwo2.diff == NULL) {
			lwo2.diff = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.diff->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_DIFF )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_DIFF );
	}

											/*  SPEC  */
	if ((fval = (*surff->getFlt)( surfID, SURF_SPEC )) != NULL) {
		lwo2.spec = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.spec->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_SPEC )) != NULL) {
		if (lwo2.spec == NULL) {
			lwo2.spec = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.spec->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_SPEC )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_SPEC );
	}

											/*  GLOS  */
	if ((fval = (*surff->getFlt)( surfID, SURF_GLOS )) != NULL) {
		lwo2.glos = (LWO2_surf_glos *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_glos) );
		lwo2.glos->glossiness = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_GLOS )) != NULL) {
		if (lwo2.glos == NULL) {
			lwo2.glos = (LWO2_surf_glos *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_glos) );
		}
		lwo2.glos->envelope = FetchEnvelope( info, envlID );
	}

											/*  REFL  */
	if ((fval = (*surff->getFlt)( surfID, SURF_REFL )) != NULL) {
		lwo2.refl = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.refl->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_REFL )) != NULL) {
		if (lwo2.refl == NULL) {
			lwo2.refl = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.refl->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_REFL )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_REFL );
	}

											/*  TRAN  */
	if ((fval = (*surff->getFlt)( surfID, SURF_TRAN )) != NULL) {
		lwo2.tran = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.tran->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_TRAN )) != NULL) {
		if (lwo2.tran == NULL) {
			lwo2.tran = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.tran->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_TRAN )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_TRAN );
	}

											/*  RIND  */
	if ((fval = (*surff->getFlt)( surfID, SURF_RIND )) != NULL) {
		lwo2.rind = (LWO2_surf_rind *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_rind) );
		lwo2.rind->refractive_index = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_RIND )) != NULL) {
		if (lwo2.rind == NULL) {
			lwo2.rind = (LWO2_surf_rind *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_rind) );
		}
		lwo2.rind->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_RIND )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_RIND );
	}

											/*  TRNL  */
	if ((fval = (*surff->getFlt)( surfID, SURF_TRNL )) != NULL) {
		lwo2.trnl = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		lwo2.trnl->intensity = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_TRNL )) != NULL) {
		if (lwo2.trnl == NULL) {
			lwo2.trnl = (LWO2_surf_base *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_base) );
		}
		lwo2.trnl->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_TRNL )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_TRNL );
	}

											/*  BUMP  */
	if ((fval = (*surff->getFlt)( surfID, SURF_BUMP )) != NULL) {
		lwo2.bump = (LWO2_surf_bump *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_bump) );
		lwo2.bump->strenght = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_BUMP )) != NULL) {
		if (lwo2.bump == NULL) {
			lwo2.bump = (LWO2_surf_bump *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_bump) );
		}
		lwo2.bump->envelope = FetchEnvelope( info, envlID );
	}
	if ((texID = (*surff->getTex)( surfID, SURF_BUMP )) != NULL) {
		FetchTexture( info, &lwo2, texID, ID_BUMP );
	}

											/*  GVAL  */
	if ((fval = (*surff->getFlt)( surfID, SURF_GVAL )) != NULL) {
		lwo2.gval = (LWO2_surf_gval *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_gval) );
		lwo2.gval->value = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_GVAL )) != NULL) {
		if (lwo2.gval == NULL) {
			lwo2.gval = (LWO2_surf_gval *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_gval) );
		}
		lwo2.gval->envelope = FetchEnvelope( info, envlID );
	}

											/*  LSIZ  */
	if ((fval = (*surff->getFlt)( surfID, SURF_LSIZ )) != NULL) {
		lwo2.lsiz = (LWO2_surf_lsiz *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_lsiz) );
		lwo2.lsiz->size = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_LSIZ )) != NULL) {
		if (lwo2.lsiz == NULL) {
			lwo2.lsiz = (LWO2_surf_lsiz *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_lsiz) );
		}
		lwo2.lsiz->envelope = FetchEnvelope( info, envlID );
	}

											/*  CLRH  */
	if ((fval = (*surff->getFlt)( surfID, SURF_CLRH )) != NULL) {
		lwo2.clrh = (LWO2_surf_clrh *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_clrh) );
		lwo2.clrh->color_highlights = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_CLRH )) != NULL) {
		if (lwo2.clrh == NULL) {
			lwo2.clrh = (LWO2_surf_clrh *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_clrh) );
		}
		lwo2.clrh->envelope = FetchEnvelope( info, envlID );
	}

											/*  CLRF  */
	if ((fval = (*surff->getFlt)( surfID, SURF_CLRF )) != NULL) {
		lwo2.clrf = (LWO2_surf_clrf *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_clrf) );
		lwo2.clrf->color_filter = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_CLRF )) != NULL) {
		if (lwo2.clrf == NULL) {
			lwo2.clrf = (LWO2_surf_clrf *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_clrf) );
		}
		lwo2.clrf->envelope = FetchEnvelope( info, envlID );
	}

											/*  ADTR  */
	if ((fval = (*surff->getFlt)( surfID, SURF_ADTR )) != NULL) {
		lwo2.adtr = (LWO2_surf_adtr *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_adtr) );
		lwo2.adtr->additive = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_ADTR )) != NULL) {
		if (lwo2.adtr == NULL) {
			lwo2.adtr = (LWO2_surf_adtr *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_adtr) );
		}
		lwo2.adtr->envelope = FetchEnvelope( info, envlID );
	}

											/*  SHRP  */
	if ((fval = (*surff->getFlt)( surfID, SURF_SHRP )) != NULL) {
		lwo2.shrp = (LWO2_surf_shrp *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_shrp) );
		lwo2.shrp->sharpness = (F4) fval[0];
	}
	if ((envlID = (*surff->getEnv)( surfID, SURF_SHRP )) != NULL) {
		if (lwo2.shrp == NULL) {
			lwo2.shrp = (LWO2_surf_shrp *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_shrp) );
		}
		lwo2.shrp->envelope = FetchEnvelope( info, envlID );
	}

											/*  SMAN  */
	if ((fval = (*surff->getFlt)( surfID, SURF_SMAN )) != NULL) {
		lwo2.sman = (LWO2_surf_sman *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_sman) );
		lwo2.sman->max_smoothing_angle = (F4) fval[0];
	}

											/*  RSAN  */
	if ((fval = (*surff->getFlt)( surfID, SURF_RSAN )) != NULL) {
		lwo2.rsan = (LWO2_surf_rsan *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_rsan) );
		lwo2.rsan->seam_angle = (F4) fval[0];
	}

											/*  AVAL  */
	if ((fval = (*surff->getFlt)( surfID, SURF_AVAL )) != NULL) {
		lwo2.aval = (LWO2_surf_aval *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_aval) );
		lwo2.aval->value = (F4) fval[0];
	}

											/*  ALPH  */
	if ((fval = (*surff->getFlt)( surfID, SURF_ALPH )) != NULL) {
		lwo2.alph = (LWO2_surf_alph *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_alph) );
		lwo2.alph->value = (F4) fval[0];
	}

											/*  RFOP  */
	ival = (*surff->getInt)( surfID, SURF_RFOP );
	lwo2.rfop = (LWO2_surf_rfop *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_rfop) );
	lwo2.rfop->options = (U2) ival;

											/*  TROP  */
	ival = (*surff->getInt)( surfID, SURF_TROP );
	lwo2.trop = (LWO2_surf_trop *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_trop) );
	lwo2.trop->options = (U2) ival;

											/*  SIDE  */
	ival = (*surff->getInt)( surfID, SURF_SIDE );
	lwo2.side = (LWO2_surf_side *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_side) );
	lwo2.side->sideness = (U2) ival;

											/*  LINE  */
	ival = (*surff->getInt)( surfID, SURF_LINE );
	lwo2.line = (LWO2_surf_line *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_line) );
	lwo2.line->flags = (U2) ival;

											/*  RIMG  */
	if ((imageID = (*surff->getImg)( surfID, SURF_RIMG )) != NULL) {
		lwo2.rimg = (LWO2_surf_rimg *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_rimg) );
		lwo2.rimg->image = FindImage( info, imageID );
	}

											/*  TIMG  */
	if ((imageID = (*surff->getImg)( surfID, SURF_TIMG )) != NULL) {
		lwo2.timg = (LWO2_surf_timg *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_timg) );
		lwo2.timg->image = FindImage( info, imageID );
	}

											/*  VMAP  */
	if ((colorVMap = (*surff->getColorVMap)( surfID )) != NULL) {
		lwo2.vcol = (LWO2_surf_vcol *) MEM_ALLOC( obj->mem, sizeof(LWO2_surf_vcol) );
		strcpy( lwo2.vcol->name, colorVMap );
		lwo2.vcol->type  = FetchColorType( info, colorVMap );
		lwo2.vcol->value = 1.0f;
		if ((fval = (*surff->getFlt)( surfID, SURF_VCOL )) != NULL) {
			lwo2.vcol->value = (F4) fval[0];
		}
	}

	size = LWO2_packSurf( obj, buff, &lwo2 );
	LWO2_freeSurf( obj, &lwo2 );

	return size;
}
Пример #19
0
BOOL TableClass::Layout (struct LayoutMessage &lmsg)
{
  if(Flags & FLG_AllElementsPresent)
  {
    FindImage(lmsg);
    if(!(Flags & FLG_AllocatedColours))
      AllocateColours(lmsg.Share->Scr->ViewPort.ColorMap);

    if(lmsg.Y != lmsg.MinY || !lmsg.IsAtNewline())
      lmsg.AddYSpace(4);

    lmsg.EnsureNewline();

    Top = lmsg.Y;
    Left = lmsg.X;
    lmsg.TopChange = min(Top, lmsg.TopChange);

    if(!(Flags & FLG_KnowsMinMax))
    {
      struct MinMaxMessage mmsg(lmsg.Share->Fonts, &lmsg);
      mmsg.Reset();
      MinMax(mmsg);
    }

    ULONG scr_width = lmsg.ScrWidth() - (Columns+1)*Spacing - 2*BorderSize;
    if(GivenWidth)
    {
      if(GivenWidth->Type == Size_Percent)
         Width = max(Min, ((lmsg.ScrWidth() * GivenWidth->Size) / 100) - (Columns+1)*Spacing - 2*BorderSize);
      else
            Width = max(GivenWidth->Size-(Columns+1)*Spacing-2*BorderSize, Min);
    }
    else
         Width = (Min <= scr_width) ? min(scr_width, Max) : Min;

    /* Set all cells to their min or max width */
    LONG scale = Width, table_delta = 0, relative = 0;
    for(ULONG i = 0; i < Columns; i++)
    {
      if(!Widths[i].Percent)
      {
        LONG cellwidth = Width >= Max ? Widths[i].Max : Widths[i].Min;
        table_delta += Widths[i].Max - Widths[i].Min;
        scale -= cellwidth;
        relative += Widths[i].Relative;
        Widths[i].Width = cellwidth;
      }
    }

    /* Set all cells with a width given in percent */
    for(ULONG i = 0; i < Columns; i++)
    {
      if(Widths[i].Percent)
      {
        ULONG cellwidth = max(Widths[i].Min, min((ULONG)scale, (Width * Widths[i].Percent) / 100));
        Widths[i].Width = cellwidth;
        scale -= cellwidth;
      }
    }

    if(scale > 0)
    {
      if(relative)
      {
        Spread(scale, relative, RelativeScale);
      }
      else if(table_delta)
      {
        Spread(scale, table_delta, NormalScale);
      }
      else
      {
        LONG width = Max;
        for(UWORD i = 0; i < Columns; i++)
        {
          if(Widths[i].Fixed)
            width -= Widths[i].Max;
        }

        if(width)
            Spread(scale, width, LeftOverScale);
        else  Width -= scale;
      }
    }
    else
    {
      Width -= scale;
    }

    struct CellWidth *oldwidths = lmsg.Widths;
    ULONG oldspace = lmsg.Spacing, oldpad = lmsg.Padding;
    struct TextFont *oldfont = lmsg.Font;

    ULONG oldcols = lmsg.Columns, oldimageleftindent = lmsg.ImageLeftIndent, oldimagerightindent = lmsg.ImageRightIndent;
    lmsg.ImageLeftIndent = lmsg.ImageRightIndent = 0;
    struct FloadingImage *fleft = lmsg.FLeft, *fright = lmsg.FRight;
    lmsg.FLeft = lmsg.FRight = NULL;

    lmsg.Widths = Widths;
    lmsg.Spacing = Spacing;
    lmsg.Padding = Padding + (BorderSize ? 1 : 0);
    lmsg.Columns = Columns;

    ULONG oldminx = lmsg.MinX;
    lmsg.MinX = lmsg.X += BorderSize;

    lmsg.AddYSpace(Spacing+BorderSize);
    Flags &= ~FLG_Virgin;

    ULONG *oldopencounts = lmsg.RowOpenCounts;
    lmsg.RowOpenCounts = (ULONG *)memset(RowOpenCounts, 0, Columns * sizeof(ULONG));

    ULONG *oldheights = lmsg.Heights;
    ULONG pass = lmsg.Pass;
    lmsg.Pass = 0;
    lmsg.Heights = (ULONG *)memset(Heights, 0, Rows*sizeof(ULONG));

    ULONG realrows = 0;
    struct ChildsList *first = FirstChild;
    while(first)
    {
      ((class TRClass *)first->Obj)->TRLayout(lmsg);
      first = first->Next;
      realrows++;
    }

    /* Should some cell set a rowspan that ends outside the table, then we enlarge all height entries */
    while(realrows < Rows)
    {
      Heights[realrows] = max(Heights[realrows], Heights[realrows-1]);
      realrows++;
    }

    Bottom = Rows ? Heights[Rows-1] : lmsg.Y;
    lmsg.Y = Bottom + Spacing;

    lmsg.Pass = 1;
    lmsg.Heights = Heights;

    first = FirstChild;
    while(first)
    {
      ((class TRClass *)first->Obj)->TRLayout(lmsg);
      first = first->Next;
    }

    lmsg.Pass = pass;
    lmsg.Heights = oldheights;

    lmsg.RowOpenCounts = oldopencounts;

    lmsg.MinX = oldminx;
    lmsg.AddYSpace(BorderSize);

    lmsg.Widths = oldwidths;
    lmsg.Columns = oldcols;
    lmsg.Spacing = oldspace;
    lmsg.Padding = oldpad;

    lmsg.FLeft = fleft;
    lmsg.FRight = fright;
    lmsg.ImageLeftIndent = oldimageleftindent;
    lmsg.ImageRightIndent = oldimagerightindent;
    lmsg.X += oldimageleftindent;

    lmsg.Font = oldfont;

    lmsg.Width = max((ULONG)lmsg.Width, lmsg.MinX+Width+((Columns+1)*Spacing)+2*BorderSize+lmsg.MarginWidth+lmsg.ImageRightIndent);

    Bottom = lmsg.Y-1;
    lmsg.AddYSpace(4);

    LONG width = Width+((Columns+1)*Spacing)+2*BorderSize;
    LONG delta = lmsg.ScrWidth() - width;
    UBYTE oldalign = lmsg.Align;
    if(delta > 0)
    {
      LONG offset = 0;

      if(Alignment == Align_Left || Alignment == Align_Right)
      {
        LONG width = Width + (Columns+1)*Spacing + 2*BorderSize;
        struct FloadingImage *img = new (std::nothrow) struct FloadingImage(Top, Left, width, (Bottom-Top)+1, this, lmsg.Parent);
        if (img)
        {
        	LONG left = lmsg.AddImage(img, Alignment == Align_Right);
	        offset = left - Left;
    	}

        lmsg.Y = Top;
        lmsg.Baseline = lmsg.Bottom = 0;
      }
      else if(lmsg.Align == Align_Center || Alignment == Align_Center)
      {
        offset = delta/2;
      }
      else if(lmsg.Align == Align_Right)
      {
        offset = delta;
      }

      if(offset)
        AdjustPosition(offset, 0);
    }

    lmsg.Align = oldalign;

    if(Alignment != Align_Left && Alignment != Align_Right)
      lmsg.CheckFloatingObjects();

    Flags |= FLG_Layouted;
  }
  else
  {
    lmsg.TopChange = min(lmsg.TopChange, MAX_HEIGHT);
  }

   return TRUE;
}
Пример #20
0
float GuiImages::GetHeight(const char *name)
{
    IMGPOS *p = FindImage(name);
    return p? p->height : 0;
}
Пример #21
0
float GuiImages::GetWidth(const char *name)
{
    IMGPOS *p = FindImage(name);
    return p? p->width : 0;
}