Esempio n. 1
0
void InitializeOneFont (HFONT * theFont, 
                               const TCHAR FontRegKey[] , 
                               LOGFONT autoLogFont, 
                               LOGFONT * LogFontUsed)
{
  LOGFONT logfont;
  if (GetObjectType(*theFont) == OBJ_FONT) {
    DeleteObject(*theFont); // RLD the EditFont screens use the Delete
  }

  memset ((char *)&logfont, 0, sizeof (LOGFONT));

  if (UseCustomFonts) {
    propGetFontSettings((TCHAR * )FontRegKey, &logfont);
    if (!IsNullLogFont(logfont)) {
      *theFont = CreateFontIndirect (&logfont);
      if (GetObjectType(*theFont) == OBJ_FONT) {
        if (LogFontUsed != NULL) *LogFontUsed = logfont; // RLD save for custom font GUI
      }
    }
  }

  if (GetObjectType(*theFont) != OBJ_FONT) {
    if (!IsNullLogFont(autoLogFont)) {
      ApplyClearType(&autoLogFont);
      ApplyFontSize(&autoLogFont);
      *theFont = CreateFontIndirect (&autoLogFont);
      if (GetObjectType(*theFont) == OBJ_FONT) {
        if (LogFontUsed != NULL) *LogFontUsed = autoLogFont; // RLD save for custom font GUI
      }
    }
  }
}
Esempio n. 2
0
File: gdiobj.c Progetto: iXit/wine
static void test_thread_objects(void)
{
    LOGPEN lp;
    DWORD tid, type;
    HANDLE hthread;
    struct hgdiobj_event hgdiobj_event;
    INT ret;
    DWORD status;
    BOOL bRet;

    hgdiobj_event.stop_event = CreateEventA(NULL, 0, 0, NULL);
    ok(hgdiobj_event.stop_event != NULL, "CreateEvent error %u\n", GetLastError());
    hgdiobj_event.ready_event = CreateEventA(NULL, 0, 0, NULL);
    ok(hgdiobj_event.ready_event != NULL, "CreateEvent error %u\n", GetLastError());

    hthread = CreateThread(NULL, 0, thread_proc, &hgdiobj_event, 0, &tid);
    ok(hthread != NULL, "CreateThread error %u\n", GetLastError());

    status = WaitForSingleObject(hgdiobj_event.ready_event, INFINITE);
    ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());

    ret = GetObjectA(hgdiobj_event.hgdiobj1, sizeof(lp), &lp);
    ok(ret == sizeof(lp), "GetObject error %u\n", GetLastError());
    ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
    ok(lp.lopnWidth.x == 17, "wrong pen width.y %d\n", lp.lopnWidth.x);
    ok(lp.lopnWidth.y == 0, "wrong pen width.y %d\n", lp.lopnWidth.y);
    ok(lp.lopnColor == RGB(1, 2, 3), "wrong pen width.y %08x\n", lp.lopnColor);

    ret = GetDeviceCaps(hgdiobj_event.hdc, TECHNOLOGY);
    ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);

    bRet = DeleteObject(hgdiobj_event.hgdiobj1);
    ok(bRet, "DeleteObject error %u\n", GetLastError());
    bRet = DeleteDC(hgdiobj_event.hdc);
    ok(bRet, "DeleteDC error %u\n", GetLastError());

    type = GetObjectType(hgdiobj_event.hgdiobj2);
    ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);

    SetEvent(hgdiobj_event.stop_event);
    status = WaitForSingleObject(hthread, INFINITE);
    ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());
    CloseHandle(hthread);

    type = GetObjectType(hgdiobj_event.hgdiobj2);
    ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);
    bRet = DeleteObject(hgdiobj_event.hgdiobj2);
    ok(bRet, "DeleteObject error %u\n", GetLastError());

    CloseHandle(hgdiobj_event.stop_event);
    CloseHandle(hgdiobj_event.ready_event);
}
Esempio n. 3
0
int LuaObjectRenderingImpl::SetPieceList(lua_State* L)
{
	CSolidObject* obj = ParseSolidObject(L, __FUNCTION__, 1, GetObjectType());

	if (obj == nullptr)
		return 0;

	const LuaObjectMaterialData* lmd = obj->GetLuaMaterialData();
	LocalModelPiece* lmp = ParseObjectLocalModelPiece(L, obj, 3);

	if (lmp == nullptr)
		return 0;

	const unsigned int lod = luaL_checknumber(L, 2) - 1;

	if (lod >= lmd->GetLODCount())
		return 0;

	// (re)set the default if no fourth argument
	unsigned int dlist = lmp->dispListID;

	if (lua_isnumber(L, 4)) {
		CLuaDisplayLists& displayLists = CLuaHandle::GetActiveDisplayLists(L);
		dlist = displayLists.GetDList(luaL_checknumber(L, 4));
	}

	lmp->lodDispLists[lod] = dlist;
	return 0;
}
Esempio n. 4
0
int LuaObjectRenderingImpl::SetMaterial(lua_State* L)
{
	// args=<objID, lodMatNum, matName, matRef>
	CSolidObject* obj = ParseSolidObject(L, __FUNCTION__, 1, GetObjectType());

	if (obj == nullptr)
		return 0;

	const string matName = luaL_checkstring(L, 3);
	const LuaMatType matType = ParseMaterialType(matName);

	LuaObjectMaterial* objMat = GetObjectMaterial(obj, matName);

	if (objMat == nullptr)
		return 0;

	LuaObjectLODMaterial* lodMat = objMat->GetMaterial(luaL_checknumber(L, 2) - 1);

	if (lodMat == nullptr)
		return 0;

	if (lua_isuserdata(L, 4)) {
		LuaMatRef** matRef = (LuaMatRef**) luaL_checkudata(L, 4, "MatRef");
		if (matRef) {
			lodMat->matref = **matRef;
		}
	} else {
		lodMat->matref = ParseMaterial(L, 4, matType);
	}

	return 0;
}
Esempio n. 5
0
/***********************************************************************
 *           GDISelectPalette    (Not a Windows API)
 */
HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg)
{
    HPALETTE ret = 0;
    DC *dc;

    TRACE("%p %p\n", hdc, hpal );

    hpal = get_full_gdi_handle( hpal );
    if (GetObjectType(hpal) != OBJ_PAL)
    {
      WARN("invalid selected palette %p\n",hpal);
      return 0;
    }
    if ((dc = get_dc_ptr( hdc )))
    {
        PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectPalette );
        ret = dc->hPalette;
        if (physdev->funcs->pSelectPalette( physdev, hpal, FALSE ))
        {
            dc->hPalette = hpal;
            if (!wBkg) hPrimaryPalette = hpal;
        }
        else ret = 0;
        release_dc_ptr( dc );
    }
    return ret;
}
Esempio n. 6
0
int asCModule::GetMethodIDByName(const char *object, const char *name)
{
	if( isBuildWithoutErrors == false )
		return asERROR;

	asCObjectType *ot = GetObjectType(object);
	if( ot == 0 )
		return asINVALID_TYPE;

	// TODO: Improve linear search
	// Find the function id
	int id = -1;
	for( asUINT n = 0; n < ot->methods.GetLength(); n++ )
	{
		if( scriptFunctions[ot->methods[n]]->name == name )
		{
			if( id == -1 )
				id = ot->methods[n];
			else
				return asMULTIPLE_FUNCTIONS;
		}
	}

	if( id == -1 ) return asNO_FUNCTION;

	return moduleID | id;
}
Esempio n. 7
0
// MEMBER      -> [ OBJECT s_dot ] <
//                k_type | k_name | k_attrib | k_version | k_uuid | k_uunm |
//                k_clsid | k_iid | k_value >
//
int P_Member(LubeToken token)
{
    ObjectType object;
    MemberType member;
    PSTATEDESC pDesc;

    if (IsObjectToken(token)) {
        object = GetObjectType(token);
        if (Object_None == object) object = s_pContext->m_curObject;

        if (_PeekToken() != Token_S_dot) {
            ErrorReport(Lube_E_InvalidMember, g_szCurrentToken);
            return Ret_Continue;
        }
        _GetToken(); // skip s_dot
        token = _GetToken();
    }
    else {
        object = s_pContext->m_curObject;
    }

    member = GetMemberType(object, token);
    if (Member_None == member) return Ret_Continue;

    pDesc = s_pContext->CreateBlockette(State_Member);
    if (!pDesc) {
        ErrorReport(Lube_E_OutOfMemory);
        return Ret_AbortOnError;
    }
    pDesc->object = object;
    pDesc->member = member;

    return Ret_Continue;
}
Esempio n. 8
0
/******************************************************************************
 * CreateCompatibleBitmap [GDI32.@]
 *
 * Creates a bitmap compatible with the DC.
 *
 * PARAMS
 *    hdc    [I] Handle to device context
 *    width  [I] Width of bitmap
 *    height [I] Height of bitmap
 *
 * RETURNS
 *    Success: Handle to bitmap
 *    Failure: 0
 */
HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height)
{
    char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
    BITMAPINFO *bi = (BITMAPINFO *)buffer;
    DIBSECTION dib;

    TRACE("(%p,%d,%d)\n", hdc, width, height);

    if (GetObjectType( hdc ) != OBJ_MEMDC)
        return CreateBitmap( width, height,
                             GetDeviceCaps(hdc, PLANES), GetDeviceCaps(hdc, BITSPIXEL), NULL );

    switch (GetObjectW( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(dib), &dib ))
    {
    case sizeof(BITMAP): /* A device-dependent bitmap is selected in the DC */
        return CreateBitmap( width, height, dib.dsBm.bmPlanes, dib.dsBm.bmBitsPixel, NULL );

    case sizeof(DIBSECTION): /* A DIB section is selected in the DC */
        bi->bmiHeader = dib.dsBmih;
        bi->bmiHeader.biWidth  = width;
        bi->bmiHeader.biHeight = height;
        if (dib.dsBmih.biCompression == BI_BITFIELDS)  /* copy the color masks */
            memcpy(bi->bmiColors, dib.dsBitfields, sizeof(dib.dsBitfields));
        else if (dib.dsBmih.biBitCount <= 8)  /* copy the color table */
            GetDIBColorTable(hdc, 0, 256, bi->bmiColors);
        return CreateDIBSection( hdc, bi, DIB_RGB_COLORS, NULL, NULL, 0 );

    default:
        return 0;
    }
}
Esempio n. 9
0
void KillObject (ObjectRecHdl ObjectHdl)
// this subroutine releases the memory occupied by the given object handle
{
	OSType			thisObjectType;
	PolyObjectHdl	thisPolyHdl;
	LongPoint		**thisPointsHdl;
	
	if (ObjectHdl != nil)
	{
		GetObjectType (ObjectHdl, &thisObjectType);
		
		// dispose of any non-standard object data structures first
		switch (thisObjectType)
		{
			case kPolyType:
				thisPolyHdl = (PolyObjectHdl) ObjectHdl;
				thisPointsHdl = (LongPoint**) (**thisPolyHdl).objectDataHdl;
				if (thisPointsHdl != nil)
				{
					DisposeHandle ((Handle) thisPointsHdl);
					(**thisPolyHdl).objectDataHdl = nil;
				}
			break;
		}
		
		DisposeHandle ((Handle) ObjectHdl);		// finally, dispose the object handle
	}
	
	return;
}
Esempio n. 10
0
int32 UI_CheckObjectMask(int32 nMessage, AActor* oTarget)
{
	int32 nDispMask = GetM2DAInt(TABLE_UI_MESSAGES, "ObjectMask", nMessage);

	if (nDispMask != 0)
	{
		int32 bShow = ((nDispMask & 0xffffff) == 0xffffff);

		if (!bShow)
		{
			bShow = ((nDispMask & GetObjectType(oTarget)) == GetObjectType(oTarget));
		}

		return bShow;
	}
	return FALSE_;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *object - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CHintItemObjectBase::IsObjectOfType( C_BaseEntity *object )
{
	if ( !stricmp( GetObjectType(), "Resource Zone" ) )
	{
		return dynamic_cast< C_ResourceZone *>( object ) ? true : false;
	}
	else if ( !stricmp( GetObjectType(), "Resource Pump" ) )
	{
		return dynamic_cast< C_ObjectResourcePump * >( object) ? true : false;
	}
	else if ( !stricmp( GetObjectType(), "BaseObject" ) )
	{
		return dynamic_cast< C_BaseObject * >( object) ? true : false;
	}
	
	return false;
}
Esempio n. 12
0
ContentControl::ContentControl ()
{
	SetContentSetsParent (true);
	SetObjectType (Type::CONTENTCONTROL);

	ManagedTypeInfo type_info (GetObjectType (), "System.Windows.Controls.ContentControl");
	SetDefaultStyleKey (&type_info);
}
Esempio n. 13
0
int LuaObjectRenderingImpl::SetLODDistance(lua_State* L)
{
	// args=<objID, lodLevel, lodLength>
	//
	// length adjusted for 45 degree FOV with a 1024x768 screen; the magic
	// constant is 2.0f * math::tanf((45.0f * 0.5f) * (PI / 180.0f)) / 768.0f)
	return (SetLODLengthCommon(L, ParseSolidObject(L, __FUNCTION__, 1, GetObjectType()), 0.0010786811520132682f));
}
Esempio n. 14
0
BOOL CObjectEntry::StoreObjectDictionarySchema(XML_PARSER* pXmlParser)
{
    CStdString strIndex = "";
    CStdString strSubIndex = "";
    CStdString strParameterName = "";
    CStdString strObjectType = "";
    CStdString strDataType = "";
    CStdString strAccessType = "";
    CStdString strLowLimit = "";
    CStdString strHighLimit = "";
    CStdString strDefaultValue = "";
    CStdString strPDOMapping = "";
    CStdString strObjFlags = "";

    if(pXmlParser)
    {
        //ObjectEntry
        pXmlParser->AddNewLineTab();
        pXmlParser->Add_LastChildNode(_T("ObjectEntry"));
        pXmlParser->IncTabLevel();

        //Prepare Attributes
        GetIndex(strIndex);
        GetSubIndex(strSubIndex);
        GetParameterName(strParameterName);
        GetObjectType(strObjectType);
        GetDataType(strDataType, FALSE);
        GetAccessType(strAccessType);
        GetLowLimit(strLowLimit);
        GetHighLimit(strHighLimit);
        GetDefaultValue(strDefaultValue);
        GetPDOMapping(strPDOMapping);
        GetObjFlags(strObjFlags);

        //ObjectEntry Attributes
        pXmlParser->Set_Attribute(_T("Index"), strIndex);
        pXmlParser->Set_Attribute(_T("SubIndex"), strSubIndex);
        pXmlParser->Set_Attribute(_T("ParameterName"), strParameterName);
        pXmlParser->Set_Attribute(_T("ObjectType"), strObjectType);
        pXmlParser->Set_Attribute(_T("DataType"), strDataType);
        pXmlParser->Set_Attribute(_T("AccessType"), strAccessType);

        if(!strLowLimit.IsEmpty()) pXmlParser->Set_Attribute(_T("LowLimit"), strLowLimit);
        if(!strHighLimit.IsEmpty()) pXmlParser->Set_Attribute(_T("HighLimit"), strHighLimit);
        if(!strDefaultValue.IsEmpty()) pXmlParser->Set_Attribute(_T("DefaultValue"), strDefaultValue);
        if(!strPDOMapping.IsEmpty()) pXmlParser->Set_Attribute(_T("PDOMapping"), strPDOMapping);
        if(!strObjFlags.IsEmpty()) pXmlParser->Set_Attribute(_T("ObjFlags"), strObjFlags);

        //End ObjectEntry
        pXmlParser->DecTabLevel();
        pXmlParser->AddNewLineTab();
        pXmlParser->Go_to_Parent();

        return TRUE;
    }

    return FALSE;
}
Esempio n. 15
0
/***********************************************************************
 *           BITMAP_SelectObject
 */
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
{
    HGDIOBJ ret;
    BITMAPOBJ *bitmap;
    DC *dc;

    if (!(dc = get_dc_ptr( hdc ))) return 0;

    if (GetObjectType( hdc ) != OBJ_MEMDC)
    {
        ret = 0;
        goto done;
    }
    ret = dc->hBitmap;
    if (handle == dc->hBitmap) goto done;  /* nothing to do */

    if (!(bitmap = GDI_GetObjPtr( handle, BITMAP_MAGIC )))
    {
        ret = 0;
        goto done;
    }

    if (bitmap->header.dwCount && (handle != GetStockObject(DEFAULT_BITMAP)))
    {
        WARN( "Bitmap already selected in another DC\n" );
        GDI_ReleaseObj( handle );
        ret = 0;
        goto done;
    }

    if (!bitmap->funcs && !BITMAP_SetOwnerDC( handle, dc ))
    {
        GDI_ReleaseObj( handle );
        ret = 0;
        goto done;
    }

    if (dc->funcs->pSelectBitmap && !dc->funcs->pSelectBitmap( dc->physDev, handle ))
    {
        GDI_ReleaseObj( handle );
        ret = 0;
    }
    else
    {
        dc->hBitmap = handle;
        GDI_inc_ref_count( handle );
        dc->dirty = 0;
        SetRectRgn( dc->hVisRgn, 0, 0, bitmap->bitmap.bmWidth, bitmap->bitmap.bmHeight);
        GDI_ReleaseObj( handle );
        DC_InitDC( dc );
        GDI_dec_ref_count( ret );
    }

 done:
    release_dc_ptr( dc );
    return ret;
}
Esempio n. 16
0
// CImgCtx (Public) -----------------------------------------------------------
void CImgCtx::Tile(
                   HDC hdc,
                   POINT* pptOrg,
                   RECT* prc,
                   SIZE* psizePrint,
                   COLORREF crBack,
                   IMGANIMSTATE* pImgAnimState,
                   DWORD dwFlags)
{
    BOOL fOpaque = !!(GetState() & IMGTRANS_OPAQUE);

    // If the source image is 1x1 just let the normal StretchBlt mechanism
    // fill up the destination.
    if(GetImgInfo()->_xWid==1 && GetImgInfo()->_yHei==1)
    {
        if(crBack != CLR_INVALID)
        {
            PatBltBrush(hdc, prc, PATCOPY, crBack);
        }

        if(pImgAnimState)
        {
            GetImgInfo()->DrawFrame(hdc, pImgAnimState, prc, NULL, NULL, dwFlags);
        }
        else
        {
            GetImgInfo()->DrawImage(hdc, prc, NULL, SRCCOPY, dwFlags);
        }

        goto Cleanup;
    }

    // If the image is opaque and we are writing into an offscreen bitmap
    // which is not clipped, just tile directly into it.
    if(psizePrint==NULL && (fOpaque || crBack!=CLR_INVALID) && GetObjectType(hdc)==OBJ_MEMDC)
    {
        RECT rcBox;
        int iRgn = GetClipBox(hdc, &rcBox);

        if(iRgn==NULLREGION
            || (iRgn==SIMPLEREGION
            && prc->left>=rcBox.left
            && prc->top>=rcBox.top
            && prc->right<=rcBox.right
            && prc->bottom<=rcBox.bottom))
        {
            TileFast(hdc, prc, pptOrg->x, pptOrg->y, fOpaque, crBack, pImgAnimState, dwFlags);
            goto Cleanup;
        }
    }

    // Otherwise just tile the slow way (it may still decide to pretile)
    TileSlow(hdc, prc, pptOrg->x, pptOrg->y, psizePrint, fOpaque, crBack, pImgAnimState, dwFlags);

Cleanup:
    ;
}
Esempio n. 17
0
bool GroundFilterFn(HOBJECT hObj, void *pUserData)
{
    if ( IsMainWorld(hObj) || (OT_WORLDMODEL == GetObjectType(hObj)) )
    {
        return true;
    }

    return false;
}
Esempio n. 18
0
BOOL IsMetaFile(
    HDC hdc)
{
    DWORD dwType = GetObjectType(hdc);
    return (dwType == OBJ_METAFILE ||
            dwType == OBJ_METADC ||
            dwType == OBJ_ENHMETAFILE ||
            dwType == OBJ_ENHMETADC);
}
Esempio n. 19
0
ContentControl::ContentControl ()
{
	SetContentSetsParent (true);
	SetObjectType (Type::CONTENTCONTROL);

	ManagedTypeInfo *type_info = g_new (ManagedTypeInfo, 1);
	type_info->Initialize (GetObjectType (), "System.Windows.Controls.ContentControl");
	SetDefaultStyleKey (type_info);
	ManagedTypeInfo::Free (type_info);
}
Esempio n. 20
0
int asCModule::GetMethodCount(const char *object)
{
	if( isBuildWithoutErrors == false )
		return asERROR;

	asCObjectType *ot = GetObjectType(object);
	if( ot == 0 )
		return asINVALID_TYPE;

	return ot->methods.GetLength();
}
Esempio n. 21
0
/* nulldrv fallback implementation using StretchDIBits */
BOOL CDECL nulldrv_StretchBlt( PHYSDEV dst_dev, INT xDst, INT yDst, INT widthDst, INT heightDst,
                               PHYSDEV src_dev, INT xSrc, INT ySrc, INT widthSrc, INT heightSrc,
                               DWORD rop )
{
    DC *dc = get_nulldrv_dc( dst_dev );
    BITMAP bm;
    BITMAPINFOHEADER info_hdr;
    HBITMAP hbm;
    LPVOID bits;
    INT lines;
    POINT pts[2];

    /* make sure we have a real implementation for StretchDIBits */
    if (GET_DC_PHYSDEV( dc, pStretchDIBits ) == dst_dev) return 0;

    pts[0].x = xSrc;
    pts[0].y = ySrc;
    pts[1].x = xSrc + widthSrc;
    pts[1].y = ySrc + heightSrc;
    LPtoDP( src_dev->hdc, pts, 2 );
    xSrc      = pts[0].x;
    ySrc      = pts[0].y;
    widthSrc  = pts[1].x - pts[0].x;
    heightSrc = pts[1].y - pts[0].y;

    if (GetObjectType( src_dev->hdc ) != OBJ_MEMDC) return FALSE;
    if (!GetObjectW( GetCurrentObject( src_dev->hdc, OBJ_BITMAP ), sizeof(bm), &bm )) return FALSE;

    info_hdr.biSize = sizeof(info_hdr);
    info_hdr.biWidth = bm.bmWidth;
    info_hdr.biHeight = bm.bmHeight;
    info_hdr.biPlanes = 1;
    info_hdr.biBitCount = 32;
    info_hdr.biCompression = BI_RGB;
    info_hdr.biSizeImage = 0;
    info_hdr.biXPelsPerMeter = 0;
    info_hdr.biYPelsPerMeter = 0;
    info_hdr.biClrUsed = 0;
    info_hdr.biClrImportant = 0;

    if (!(bits = HeapAlloc(GetProcessHeap(), 0, bm.bmHeight * bm.bmWidth * 4)))
        return FALSE;

    /* Select out the src bitmap before calling GetDIBits */
    hbm = SelectObject( src_dev->hdc, GetStockObject(DEFAULT_BITMAP) );
    lines = GetDIBits( src_dev->hdc, hbm, 0, bm.bmHeight, bits, (BITMAPINFO*)&info_hdr, DIB_RGB_COLORS );
    SelectObject( src_dev->hdc, hbm );

    if (lines) lines = StretchDIBits( dst_dev->hdc, xDst, yDst, widthDst, heightDst,
                                          xSrc, bm.bmHeight - heightSrc - ySrc, widthSrc, heightSrc,
                                          bits, (BITMAPINFO*)&info_hdr, DIB_RGB_COLORS, rop );
    HeapFree( GetProcessHeap(), 0, bits );
    return (lines == heightSrc);
}
Esempio n. 22
0
	ChildListId RetainedEntities::GetChildListId(ObjectTypeId typeId, const utf8 name[]) const
    {
        auto type = GetObjectType(typeId);
        if (!type) return 0;

        for (auto i=type->_childLists.cbegin(); i!=type->_childLists.cend(); ++i)
            if (!XlCompareStringI(i->c_str(), name)) 
                return (PropertyId)std::distance(type->_childLists.cbegin(), i);
        
        type->_childLists.push_back(name);
        return (PropertyId)(type->_childLists.size()-1);
    }
Esempio n. 23
0
int LuaObjectRenderingImpl::GetLODCount(lua_State* L)
{
	const CSolidObject* obj = ParseSolidObject(L, __FUNCTION__, 1, GetObjectType());

	if (obj == nullptr)
		return 0;

	const LuaObjectMaterialData* lmd = obj->GetLuaMaterialData();

	lua_pushnumber(L, lmd->GetLODCount());
	lua_pushnumber(L, lmd->GetCurrentLOD());
	return 2;
}
Esempio n. 24
0
void ParseStringToken()
{
    int n = 0;
    char *s, buf[c_nStrBufSize];
    LubeToken token;
    ObjectType object;
    MemberType member;

    s = g_szCurrentToken;
    while (*s) {
        if (c_nEmbedPrefix != *s) {
            buf[n++] = *s++;
        }
        else {
            s++; // skip prefix char
            token = *(LubeToken *)s;
            s += sizeof(LubeToken); // skip token

            if (IsObjectToken(token)) {
                if (*s != '.' || *(s + 1) != c_nEmbedPrefix) {
                    ErrorReport(Lube_E_InvalidEmbed);
                    return;
                }
                s += 2;

                object = GetObjectType(token);
                if (Object_None == object) return;

                token = *(LubeToken *)s;
                s += sizeof(LubeToken); // skip token
            }
            else {
                object = s_pContext->m_curObject;
            }

            if (!IsMemberToken(token)) {
                ErrorReport(Lube_E_InvalidEmbed);
                return;
            }
            member = GetMemberType(object, token);
            if (Member_None == member) return;

            buf[n++] = c_nEmbedPrefix;
            buf[n++] = (char)object;
            buf[n++] = (char)member;
        }
    }
    buf[n] = 0;
    strcpy(g_szCurrentToken, buf);
}
Esempio n. 25
0
File: init.c Progetto: Barrell/wine
/**********************************************************************
 *          MFDRV_CloseMetaFile
 */
static DC *MFDRV_CloseMetaFile( HDC hdc )
{
    DC *dc;
    METAFILEDRV_PDEVICE *physDev;

    TRACE("(%p)\n", hdc );

    if (!(dc = get_dc_ptr( hdc ))) return NULL;
    if (GetObjectType( hdc ) != OBJ_METADC)
    {
        release_dc_ptr( dc );
        return NULL;
    }
    if (dc->refcount != 1)
    {
        FIXME( "not deleting busy DC %p refcount %u\n", hdc, dc->refcount );
        release_dc_ptr( dc );
        return NULL;
    }
    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;

    /* Construct the end of metafile record - this is documented
     * in SDK Knowledgebase Q99334.
     */

    if (!MFDRV_MetaParam0(dc->physDev, META_EOF))
    {
        free_dc_ptr( dc );
	return 0;
    }

    if (physDev->mh->mtType == METAFILE_DISK)  /* disk based metafile */
    {
        if (SetFilePointer(physDev->hFile, 0, NULL, FILE_BEGIN) != 0) {
            free_dc_ptr( dc );
            return 0;
        }

	physDev->mh->mtType = METAFILE_MEMORY; /* This is what windows does */
        if (!WriteFile(physDev->hFile, physDev->mh, sizeof(*physDev->mh),
                       NULL, NULL)) {
            free_dc_ptr( dc );
            return 0;
        }
        CloseHandle(physDev->hFile);
	physDev->mh->mtType = METAFILE_DISK;
    }

    return dc;
}
Esempio n. 26
0
int LuaObjectRenderingImpl::SetLODCount(lua_State* L)
{
	// args=<objID, lodCount>
	const unsigned int objType = GetObjectType();
	const unsigned int lodCount = std::min(1024, luaL_checkint(L, 2));

	CSolidObject* obj = ParseSolidObject(L, __FUNCTION__, 1, objType);

	if (obj == nullptr)
		return 0;

	LuaObjectDrawer::SetObjectLOD(obj, LuaObjType(objType), lodCount);
	return 0;
}
Esempio n. 27
0
int asCModule::GetMethodIDByDecl(const char *object, const char *decl)
{
	if( isBuildWithoutErrors == false )
		return asERROR;

	asCObjectType *ot = GetObjectType(object);
	if( ot == 0 )
		return asINVALID_TYPE;

	asCBuilder bld(engine, this);

	asCScriptFunction func;
	int r = bld.ParseFunctionDeclaration(decl, &func);
	if( r < 0 )
		return asINVALID_DECLARATION;

	// TODO: Improve linear search
	// Search script functions for matching interface
	int id = -1;
	for( asUINT n = 0; n < ot->methods.GetLength(); ++n )
	{
		if( func.name == scriptFunctions[ot->methods[n]]->name && 
			func.returnType == scriptFunctions[ot->methods[n]]->returnType &&
			func.parameterTypes.GetLength() == scriptFunctions[ot->methods[n]]->parameterTypes.GetLength() )
		{
			bool match = true;
			for( asUINT p = 0; p < func.parameterTypes.GetLength(); ++p )
			{
				if( func.parameterTypes[p] != scriptFunctions[ot->methods[n]]->parameterTypes[p] )
				{
					match = false;
					break;
				}
			}

			if( match )
			{
				if( id == -1 )
					id = ot->methods[n];
				else
					return asMULTIPLE_FUNCTIONS;
			}
		}
	}

	if( id == -1 ) return asNO_FUNCTION;

	return moduleID | id;
}
    /** Function to set the internal object handle. This function will
    delete any previous GDI object held in this class. This can be used to
    re-use VGDIObject classes that wrap different logical GDI objects. In a
    pure OOP world, this would not be considered good behaviour. But in
    reality, this offers a great deal of functionality to objects that
    expose internal GDI objects that can be manipulated. If we did not
    allow this to occur, the end result would be many dynamically allocated
    objects used to similuate this behaviour. For instance, if class A
    allows customization of a VBrush object, without this ability that
    brush would have to be deleted and reallocated with the new settings.
    This adds an obvious problem when dealing with GDI objects in that it
    makes it more prone to allocation and deallocation errors, and forces
    the use of pointers when references would be preferred.*/
    VBOOL			SetHandle(HGDIOBJ hGDIObject)
    {
        /* Delete and current object wrapped by this class.*/
        Delete();

        /* hGDIObject should be valid.*/
        VBOOL bValidObject =
            (hGDIObject && GetObjectType(hGDIObject) != 0) ? VTRUE : VFALSE;
        VASSERT(bValidObject)

        /* Save handle.*/
        m_hGDIObject = (bValidObject) ? hGDIObject : NULL;

        return (m_hGDIObject) ? VTRUE : VFALSE;
    }
Esempio n. 29
0
int LuaObjectRenderingImpl::SetMaterialLastLOD(lua_State* L)
{
	// args=<objID, matName, lodMatNum>
	CSolidObject* obj = ParseSolidObject(L, __FUNCTION__, 1, GetObjectType());

	if (obj == nullptr)
		return 0;

	LuaObjectMaterial* objMat = GetObjectMaterial(obj, luaL_checkstring(L, 2));

	if (objMat == nullptr)
		return 0;

	objMat->SetLastLOD(luaL_checknumber(L, 3) - 1);
	return 0;
}
Esempio n. 30
0
void SetObjectLPoint (ObjectRecHdl ObjectHdl, LongPoint *objectLPointPtr)
{
	OSType	thisObjectType;
		
	(**ObjectHdl).objectLPoint = *objectLPointPtr;
	GetObjectType (ObjectHdl, &thisObjectType);
	if (thisObjectType == kSymbolType)
	{
		LongRect	thisObjectLRect;
		
		SetLRect (&thisObjectLRect, objectLPointPtr -> h, objectLPointPtr -> v,
									objectLPointPtr -> h, objectLPointPtr -> v);
									
		SetObjectLRect (ObjectHdl, &thisObjectLRect);
	}
	
	return;
}