Ejemplo n.º 1
0
void DefaultDecorator::Render( const Rect & cUpdateRect )
{
	if( m_nFlags & WND_NO_BORDER )
	{
		return;
	}

	Color32_s sFillColor = m_bHasFocus ? get_default_color( COL_SEL_WND_BORDER ) : get_default_color( COL_NORMAL_WND_BORDER );

	Layer *pcView = GetLayer();

	Rect cOBounds = pcView->GetBounds();
	Rect cIBounds = cOBounds;

	cIBounds.left += m_vLeftBorder - 1;
	cIBounds.right -= m_vRightBorder - 1;
	cIBounds.top += m_vTopBorder - 1;
	cIBounds.bottom -= m_vBottomBorder - 1;

	pcView->DrawFrame( cOBounds, FRAME_RAISED | FRAME_THIN | FRAME_TRANSPARENT );
	pcView->DrawFrame( cIBounds, FRAME_RECESSED | FRAME_THIN | FRAME_TRANSPARENT );

	// Bottom
	pcView->FillRect( Rect( cOBounds.left + 1, cIBounds.bottom + 1, cOBounds.right - 1, cOBounds.bottom - 1 ), sFillColor );
	// Left
	pcView->FillRect( Rect( cOBounds.left + 1, cOBounds.top + m_vTopBorder, cIBounds.left - 1, cIBounds.bottom ), sFillColor );
	// Right
	pcView->FillRect( Rect( cIBounds.right + 1, cOBounds.top + m_vTopBorder, cOBounds.right - 1, cIBounds.bottom ), sFillColor );

	if( ( m_nFlags & WND_NO_TITLE ) == 0 )
	{
		DrawButton( HIT_DRAG, sFillColor );
	}
	else
	{
		pcView->FillRect( Rect( cOBounds.left + 1, cOBounds.top - 1, cOBounds.right - 1, cIBounds.top + 1 ), sFillColor );
	}

	DrawButton( HIT_ZOOM, sFillColor );
	DrawButton( HIT_MINIMIZE, sFillColor );
	DrawButton( HIT_DEPTH, sFillColor );
	DrawButton( HIT_CLOSE, sFillColor );
}
Ejemplo n.º 2
0
void DefaultDecorator::DrawButton( uint32 nButton, const Color32_s & sFillColor )
{
	Layer *pcView = GetLayer();

	nButton = CheckIndex( nButton );
	Rect cFrame = m_cObjectFrame[nButton];
	bool bState = m_bObjectState[nButton];
	font_height fh;

	fh = pcView->GetFontHeight();
	Rect r;
	Point cScale( cFrame.Size() );

	if( cFrame.Width() < 1 )
		return;

	pcView->FillRect( cFrame, sFillColor );
	pcView->DrawFrame( cFrame, FRAME_TRANSPARENT | ( bState ? FRAME_RECESSED : FRAME_RAISED ) );

	switch ( nButton )
	{
	case WindowDecorator::HIT_DRAG:
		pcView->SetFgColor( 255, 255, 255, 0 );
		pcView->SetBgColor( sFillColor );
		pcView->MovePenTo( cFrame.left + 5, ( cFrame.Height() + 1.0f ) / 2 - ( fh.ascender + fh.descender ) / 2 + fh.ascender );
		pcView->DrawString( m_cTitle.c_str(), -1 );
		break;
	case WindowDecorator::HIT_CLOSE:
		SetRect( 0.33, 0.33, 0.67, 0.67 );
		pcView->DrawFrame( r, FRAME_TRANSPARENT | ( bState ? FRAME_RAISED : FRAME_RECESSED ) );
		break;
	case WindowDecorator::HIT_MINIMIZE:
		SetRect( 0.2, 0.2, 0.8, 0.8 );
		pcView->DrawFrame( r, FRAME_TRANSPARENT | ( bState ? FRAME_RAISED : FRAME_RECESSED ) );
		SetRect( 0.2, 0.6, 0.4, 0.8 );
		r.left++;
		r.right += 2;
		r.top--;
		r.bottom -= 2;
		pcView->DrawFrame( r, FRAME_TRANSPARENT | ( bState ? FRAME_RECESSED : FRAME_RAISED ) );
		break;
	case WindowDecorator::HIT_DEPTH:
		if( bState )
		{
			SetRect( 0.2, 0.2, 0.6, 0.6 );
			pcView->DrawFrame( r, FRAME_TRANSPARENT | ( FRAME_RAISED ) );
			SetRect( 0.4, 0.4, 0.8, 0.8 );
			pcView->FillRect( r, sFillColor );
			pcView->DrawFrame( r, FRAME_TRANSPARENT | ( FRAME_RAISED ) );
		}
		else
		{
			SetRect( 0.4, 0.4, 0.8, 0.8 );
			pcView->DrawFrame( r, FRAME_TRANSPARENT | ( FRAME_RECESSED ) );
			SetRect( 0.2, 0.2, 0.6, 0.6 );
			pcView->FillRect( r, sFillColor );
			pcView->DrawFrame( r, FRAME_TRANSPARENT | ( FRAME_RECESSED ) );
		}
		break;
	case WindowDecorator::HIT_ZOOM:
		SetRect( 0.2, 0.2, 0.8, 0.8 );
		pcView->DrawFrame( r, FRAME_TRANSPARENT | ( bState ? FRAME_RAISED : FRAME_RECESSED ) );
		SetRect( 0.2, 0.2, 0.6, 0.6 );
		r.left += 2;
		r.top += 2;
		pcView->DrawFrame( r, FRAME_TRANSPARENT | ( bState ? FRAME_RECESSED : FRAME_RAISED ) );
		break;
	}
}