コード例 #1
0
wxSize wxSpeedButton::DoGetBestSize(void) {
int         i,n;
int         w,h;
int         bn;
int         bw, bh;
int         gw, gh;
int         lw, lh;

// max size of the bitmaps

    bw = 0;
    bh = 0;
    GetGlyphSize(mGlyphUp, gw, gh);
        if (gw > bw) bw = gw;
        if (gh > bh) bh = gh;
    GetGlyphSize(mGlyphDown, gw, gh);
        if (gw > bw) bw = gw;
        if (gh > bh) bh = gh;
    GetGlyphSize(mGlyphDisabled, gw, gh);
        if (gw > bw) bw = gw;
        if (gh > bh) bh = gh;

    mGlyphSize.Set(bw, bh);

// max size of the t  n = inStyle | wxCLIP_CHILDREN;ext label

    lw = 0;
    lh = 0;
    if (! GetLabel().IsEmpty()) GetTextExtent(GetLabel(), &lw, &lh);

    mLabelSize.Set(lw, lh);

// border size is a magiv number, imperically determined using the
// wxNativeRenderer to draw the button

    bn = 2;

// best size depends upon the alignment

    i = GetWindowStyleFlag();

    if (((i & wxBU_LEFT) != 0) || ((i & wxBU_RIGHT) != 0)) {
        w = bn + mMargin + bw + mMargin + lw + mMargin + bn;
        n = (bh > lh) ? bh : lh;
        h = bn + mMargin + n + mMargin + bn;
    }
    else if (((i & wxBU_TOP) != 0) || ((i & wxBU_BOTTOM) != 0)) {
        n = (bw > lw) ? bw : lw;
        w = bn + mMargin + n + mMargin + bn;
        h = bn + mMargin + bh + mMargin + lh + mMargin + bn;
    }
    else { // assume BU_LEFT
        w = bn + mMargin + bw + mMargin + lw + mMargin + bn;
        n = (bh > lh) ? bh : lh;
        h = bn + mMargin + n + mMargin + bn;
    };

    mBestSize.Set(w, h);

// done

    return mBestSize;
}
コード例 #2
0
ファイル: font_create.cpp プロジェクト: jwginge/ojpa
int wuFontTexBufferCreate( FT_Face font, wJAf_t *wfont, int width, int height, char *pngfile )
{
	int i, j;
	int x1, y1;
	int xSz, ySz;
	int Space;
	int rowhigh;
	int newrow;
	unsigned char *buffer;
	int buf_size = width * height * 4;
	FT_Glyph glyph[256];
	//creating rgba buffer
	buffer = new unsigned char[buf_size];
	
	wfont->mAscender = font->ascender >> 6;
	wfont->mDescender = font->descender >> 6;
	if(wfont->mDescender < 0)
	{
		//wfont->mDescender = -wfont->mDescender;
	}
	wfont->mHeight = wfont->mAscender + wfont->mDescender;
	
	i = 0;
	j = 0;
	while( i < width * height )
	{
		buffer[j] = 255;
		j++;
		buffer[j] = 255;
		j++;
		buffer[j] = 255;
		j++;
		buffer[j] = 0;
		j++;
		i++;
	}
	
	x1 = 0;
	y1 = 0;
	Space = 7;
	rowhigh = 0;
	//now we load glyphs on to the buffer!  yay!
	i = 32;
	while( i < 256 )
	{
		if( i <= 0x7E || i >= 0xA0 )
		{
			GetGlyphSize( font, i, &xSz, &ySz );
			if( (x1 + xSz + Space) > width )
			{
				x1 = 0;
				y1 += rowhigh + Space;
				if( y1 + rowhigh > height )
				{
					can_not_add = (256 - i);
					i = 256;
				}
				rowhigh = 0;
			}
			else
			{
			
				if((x1 < width) && (y1 < height))
				{
					//PutDotOnBuffer( buffer, width, height, x1, y1 );
					PutGlyphOnBuffer( buffer, width, height, font, wfont, i, x1, y1 );
				}
				else
				{
					can_not_add++;
				}
			
				x1 += xSz + Space;
				if( ySz > rowhigh )
				{
					rowhigh = ySz;
				}
				i++;
			}
		}
		else
		{
			i++;
		}
	}
	
	pngWrite( pngfile, width, height, buffer );
	delete buffer;
	return 0;
}