void EditExt::OnPropertiesUpdate()
{
	// Parse string in r,g,b format and save in colorref
	CString r;
	CString g;
	CString b;

	ExtractSubstring(r, rgbStr, ',', 0);
	ExtractSubstring(g, rgbStr, ',', 1);
	ExtractSubstring(b, rgbStr, ',', 2);
	
	int red = atoi(r);
	int green = atoi(g);
	int blue = atoi(b);

	filter = D3D_ARGB(opacity, red, green, blue);
}
Example #2
0
char *DDFFieldDefn::ExpandFormat( const char * pszSrc )

{
    size_t      nDestMax = 32;
    char       *pszDest = (char *) CPLMalloc(nDestMax+1);
    size_t      iSrc, iDst;
    int         nRepeat = 0;

    iSrc = 0;
    iDst = 0;
    pszDest[0] = '\0';

    while( pszSrc[iSrc] != '\0' )
    {
        /* This is presumably an extra level of brackets around some
           binary stuff related to rescanning which we don't care to do
           (see 6.4.3.3 of the standard.  We just strip off the extra
           layer of brackets */
        if( (iSrc == 0 || pszSrc[iSrc-1] == ',') && pszSrc[iSrc] == '(' )
        {
            char       *pszContents = ExtractSubstring( pszSrc+iSrc );
            char       *pszExpandedContents = ExpandFormat( pszContents );

            if( strlen(pszExpandedContents) + strlen(pszDest) + 1 > nDestMax )
            {
                nDestMax = 2 * (strlen(pszExpandedContents) + strlen(pszDest));
                pszDest = (char *) CPLRealloc(pszDest,nDestMax+1);
            }

            strcat( pszDest, pszExpandedContents );
            iDst = strlen(pszDest);

            iSrc = iSrc + strlen(pszContents) + 2;

            CPLFree( pszContents );
            CPLFree( pszExpandedContents );
        }

        /* this is a repeated subclause */
        else if( (iSrc == 0 || pszSrc[iSrc-1] == ',')
                 && isdigit(pszSrc[iSrc]) )
        {
            const char *pszNext;
            nRepeat = atoi(pszSrc+iSrc);

            // skip over repeat count.
            for( pszNext = pszSrc+iSrc; isdigit(*pszNext); pszNext++ )
                iSrc++;

            char       *pszContents = ExtractSubstring( pszNext );
            char       *pszExpandedContents = ExpandFormat( pszContents );

            for( int i = 0; i < nRepeat; i++ )
            {
                if( strlen(pszExpandedContents) + strlen(pszDest) + 1 + 1 > nDestMax )
                {
                    nDestMax =
                        2 * (strlen(pszExpandedContents) + strlen(pszDest) + 1);
                    pszDest = (char *) CPLRealloc(pszDest,nDestMax+1);
                }

                strcat( pszDest, pszExpandedContents );
                if( i < nRepeat-1 )
                    strcat( pszDest, "," );
            }

            iDst = strlen(pszDest);

            if( pszNext[0] == '(' )
                iSrc = iSrc + strlen(pszContents) + 2;
            else
                iSrc = iSrc + strlen(pszContents);

            CPLFree( pszContents );
            CPLFree( pszExpandedContents );
        }
        else
        {
            if( iDst+1 >= nDestMax )
            {
                nDestMax = 2 * iDst;
                pszDest = (char *) CPLRealloc(pszDest,nDestMax);
            }

            pszDest[iDst++] = pszSrc[iSrc++];
            pszDest[iDst] = '\0';
        }
    }

    return pszDest;
}