Exemplo n.º 1
0
void GUITextBox::Draw()
{
	if(IsVisible())
	{
		COLOR4 color = GetColor();
		Box(GetX(), GetY(), GetWidth(), GetHeight(),
			color.r, color.g, color.b, color.a);

		if(GetCaption() && GetCaptionFont())
		{
			COLOR4 c_color = GetCaptionColor();
			glColor4ub(c_color.r, c_color.g, c_color.b, c_color.a);
			PrintText(GetCaption(), GetCaptionFont(),
				GetX() + GetCaptionX(), GetY() + GetCaptionY());
		}

		if(GetTextFont())
		{
			COLOR4 t_color = GetTextColor();
			glColor4ub(t_color.r, t_color.g, t_color.b, t_color.a);
			PrintText(GetText(), GetTextFont(),
				GetX() + GetTextX(), GetY() + GetTextY());
		}
	}
}
Exemplo n.º 2
0
sint32 aui_Control::DesiredWidth(ldl_datablock *theBlock,
								 sint32 layerIndex) const
{

	sint32 layerWidth = Width();






	char widthLayerString[k_MAX_NAME_LEN];
	sprintf(widthLayerString, "%s%d", k_AUI_LDL_HABSSIZE, layerIndex);

	if(theBlock->GetAttributeType(widthLayerString) == ATTRIBUTE_TYPE_INT) {

		layerWidth = theBlock->GetInt(widthLayerString);
	}


	if(!layerWidth && GetText() && GetTextFont()) {
		layerWidth = GetTextFont()->GetStringWidth(GetText()) + 24;
	}

	return(layerWidth);
}
Exemplo n.º 3
0
AUI_ERRCODE TextBox::InitCommon( BOOL fromLDL )
{
	m_numItems = 0,
	m_curItem = 0;
	m_curColor = k_AUI_UI_NOCOLOR;
	m_curBold = FALSE;
	m_curItalic = FALSE;

	sint32 i;
	aui_Static **itemPtr = m_items;


	TextReloadFont();

	for (i=0; i<k_AUI_TEXTBOX_MAXITEMS; i++) {
		(*itemPtr) = NULL;
		itemPtr++;
	}

	aui_BitmapFont	*font = GetTextFont();

	if (!font) {
		aui_TextBase::SetTextFont(k_AUI_TEXTBASE_DEFAULT_FONTNAME);
		aui_TextBase::TextReloadFont();
		font = GetTextFont();
	}

	MBCHAR *fontName = font->GetTTFFile();

	itemPtr = m_items;
	for (i = k_AUI_TEXTBOX_MAXITEMS; i; i--, itemPtr++ )
	{
		AUI_ERRCODE		errcode;

		*itemPtr = new c3_Static(
			&errcode,
			aui_UniqueId(),
			10, 0, m_width-20, 14,
			NULL, NULL, k_AUI_TEXTBOX_MAXTEXT, 0 ,0 );

		(*itemPtr)->SetTextFont( fontName);
		(*itemPtr)->SetTextFontSize(9);
		(*itemPtr)->TextFlags() = k_AUI_BITMAPFONT_DRAWFLAG_JUSTLEFT;
		(*itemPtr)->SetTextColor(GetTextColor());
		if (GetTextShadow()) (*itemPtr)->SetTextShadow(TRUE);
		(*itemPtr)->SetTextShadowColor(GetTextShadowColor());
	}

	return AUI_ERRCODE_OK;
}
Exemplo n.º 4
0
void CXTPPopupItem::CalculateHeight()
{
    if (m_pRichRender)
    {
        return;
    }

    if (m_pUIElement)
    {
        XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL);

        CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    CXTPImageManagerIcon* pIcon = GetImage();

    if (pIcon)
    {
        m_rcItem.bottom = m_rcItem.top + pIcon->GetHeight();
        return;
    }

    CWindowDC dc(NULL);
    CRect rcText(0, 0, m_rcItem.Width(), 0);

    CFont fntUnderline;
    CFont* pFont = GetTextFont();

    if (IsHyperLink() && IsUnderline() || IsBold())
    {
        LOGFONT lpLogFont;
        pFont->GetLogFont(&lpLogFont);
        lpLogFont.lfUnderline = (IsHyperLink() && IsUnderline());
        lpLogFont.lfWeight = IsBold() ? FW_BOLD : FW_NORMAL;

        VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont));
        pFont = &fntUnderline;
    }

    CXTPFontDC font(&dc, pFont);

    dc.DrawText(m_strCaption, rcText, m_nAlign | DT_CALCRECT);

    m_rcItem.bottom = m_rcItem.top + rcText.Height();
}
Exemplo n.º 5
0
wxSize wxFlatButton::GetBestSize()
{
    wxBitmap bmp(1, 1);
    wxMemoryDC memDc(bmp);
    wxGCDC gdc;
    wxGraphicsRenderer* const renderer = wxGraphicsRenderer::GetDefaultRenderer();
    wxGraphicsContext* context = renderer->CreateContext(memDc);
    gdc.SetGraphicsContext(context);

    int buttonWidth(0);
    int buttonHeight(0);

    gdc.SetFont(GetTextFont());

    // Get the button width
    // [spacer | text + spacer | image + spacer ]
    buttonWidth += X_SPACER;
    if(!m_text.IsEmpty()) {
        buttonWidth += gdc.GetTextExtent(m_text).x;
        buttonWidth += X_SPACER;
    }

    if(m_bmp.IsOk()) {
        buttonWidth += m_bmp.GetWidth();
        buttonWidth += X_SPACER;
    }

    wxSize textExtent = gdc.GetTextExtent(m_text);
    int bmpHeight = m_bmp.IsOk() ? m_bmp.GetHeight() : 0;

    buttonHeight = std::max(textExtent.GetHeight(), bmpHeight);
    buttonHeight += 2 * Y_SPACER;
    return wxSize(buttonWidth + 2 * X_SPACER, buttonHeight);
}
Exemplo n.º 6
0
bool CHexEdit::SetFontFaceName( const CString& sFaceName )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    strcpy( lgfnt.lfFaceName, sFaceName );
    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 7
0
bool CHexEdit::SetFontHeight( int nHeight )
{
    LOGFONT lgfnt;
    GetTextFont( &lgfnt );
    lgfnt.lfHeight  = -MulDiv(nHeight, GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY), 72);
    lgfnt.lfWidth   = 0;
    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 8
0
bool CHexEdit::SetFontItalic( bool bItalic )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    lgfnt.lfItalic  = bItalic ? TRUE : FALSE;

    SetTextFont( lgfnt );
    return true;
}
Exemplo n.º 9
0
bool CHexEdit::SetFontBold( bool bBold )
{
    LOGFONT lgfnt;

    GetTextFont( &lgfnt );
    lgfnt.lfWeight  = bBold?FW_BOLD:FW_DONTCARE;

    SetTextFont( lgfnt );

    return true;
}
Exemplo n.º 10
0
void CXTPPopupItem::Draw(CDC* pDC)
{
    if (m_pUIElement)
    {
        XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), m_clrText == (COLORREF)-1 ? m_pControl->GetPaintManager()->m_clrText : m_clrText);

        XTPMarkupRenderElement(m_pUIElement, pDC->GetSafeHdc(), m_rcItem);
    }
    else
    {
        ASSERT(m_pControl);
        if (m_pControl)
            m_pControl->GetPaintManager()->DrawItem(pDC, this);
    }
}
Exemplo n.º 11
0
	virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override
	{
		SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);

		if ( WidthLastFrame != AllottedGeometry.Size.X )
		{
			WidthLastFrame = AllottedGeometry.Size.X;

			// The width changed, update the font
			if ( LabelTextBlock.IsValid() )
			{
				LabelTextBlock->SetFont( GetTextFont() );
			}

			if ( HintTextBlock.IsValid() )
			{
				HintTextBlock->SetFont( GetHintTextFont() );
			}
		}
	}
Exemplo n.º 12
0
	virtual void Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime ) override
	{
		if ( WidthLastFrame != AllottedGeometry.Size.X )
		{
			WidthLastFrame = AllottedGeometry.Size.X;

			// The width changed, update the font
			if ( GenericLabelTextBlock.IsValid() )
			{
				GenericLabelTextBlock->SetFont( GetTextFont() );
				GenericLabelTextBlock->SetWrapTextAt( GetTextWrapWidth() );
			}

			if ( HintTextBlock.IsValid() )
			{
				HintTextBlock->SetFont( GetHintTextFont() );
				HintTextBlock->SetWrapTextAt( GetTextWrapWidth() );
			}
		}
	}
Exemplo n.º 13
0
void CXTPPopupItem::FitToContent()
{
    if (m_pRichRender)
    {
        CWindowDC dc(NULL);
        CSize sz = m_pRichRender->GetTextExtent(&dc, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    if (m_pUIElement)
    {
        XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL);

        CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    CalculateWidth();
    CalculateHeight();
}
Exemplo n.º 14
0
	/** Constructs this widget with InArgs */
	void Construct( const FArguments& InArgs )
	{
		Style = InArgs._Style;
		HighlightedText = InArgs._HighlightedText;
		Label = InArgs._Label;
		HintColorAndOpacity = InArgs._HintColorAndOpacity;
		AllowHintText = InArgs._AllowHintText;
		ShowClassBackground = InArgs._ShowClassBackground;

		AssetThumbnail = InArgs._AssetThumbnail;
		bHasRenderedThumbnail = false;
		WidthLastFrame = 0;
		GenericThumbnailBorderPadding = 2.f;

		AssetThumbnail->OnAssetDataChanged().AddSP(this, &SAssetThumbnail::OnAssetDataChanged);

		const FAssetData& AssetData = AssetThumbnail->GetAssetData();

		UClass* Class = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetClass.ToString());
		FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
		TWeakPtr<IAssetTypeActions> AssetTypeActions;
		if ( Class != NULL )
		{
			AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass(Class);
		}

		AssetColor = FLinearColor::White;
		if ( AssetTypeActions.IsValid() )
		{
			AssetColor = AssetTypeActions.Pin()->GetTypeColor();
		}

		TSharedRef<SOverlay> OverlayWidget = SNew(SOverlay);

		FName Substyle;
		if ( Class == UClass::StaticClass() )
		{
			Substyle = FName(".ClassBackground");
			ClassAssetClass = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetName.ToString());
		}
		else if(AssetTypeActions.IsValid())
		{
			Substyle = FName(".AssetBackground");
		}
		const FName BackgroundBrushName( *(Style.ToString() + Substyle.ToString()) );

		ClassThumbnailBrushOverride = InArgs._ClassThumbnailBrushOverride;

		OverlayWidget->AddSlot()
		[
			SNew(SBorder)
			.BorderImage( this, &SAssetThumbnail::GetBackgroundBrush )
			.BorderBackgroundColor( this, &SAssetThumbnail::GetAssetColor )
			.Padding( GenericThumbnailBorderPadding )
			.VAlign(VAlign_Center)
			.HAlign(HAlign_Center)
			.Visibility(this, &SAssetThumbnail::GetClassThumbnailVisibility)
			[
				SNew( SImage )
				.Image( this, &SAssetThumbnail::GetClassThumbnailBrush )
			]
		];

		// The generic representation of the thumbnail, for use before the rendered version, if it exists
		OverlayWidget->AddSlot()
		[
			SNew(SBorder)
			.BorderImage( this, &SAssetThumbnail::GetBackgroundBrush )
			.BorderBackgroundColor( this, &SAssetThumbnail::GetAssetColor )
			.Padding( GenericThumbnailBorderPadding )
			.VAlign(VAlign_Center) .HAlign(HAlign_Center)
			.Visibility(this, &SAssetThumbnail::GetGenericThumbnailVisibility)
			[
				SAssignNew(LabelTextBlock, STextBlock)
				.Text( GetLabelText() )
				.Font( GetTextFont() )
				.ColorAndOpacity( FEditorStyle::GetColor(Style, ".ColorAndOpacity") )
				.ShadowOffset( FEditorStyle::GetVector(Style, ".ShadowOffset") )
				.ShadowColorAndOpacity( FEditorStyle::GetColor(Style, ".ShadowColorAndOpacity") )
				.WrapTextAt(this, &SAssetThumbnail::GetTextWrapWidth)
				.HighlightText( HighlightedText )
			]
		];

		if ( InArgs._ThumbnailPool.IsValid() && !InArgs._ForceGenericThumbnail && Class != UClass::StaticClass() )
		{
			ViewportFadeAnimation = FCurveSequence();
			ViewportFadeCurve = ViewportFadeAnimation.AddCurve(0.f, 0.25f, ECurveEaseFunction::QuadOut);

			TSharedPtr<SViewport> Viewport = 
				SNew( SViewport )
				.EnableGammaCorrection(false);

			Viewport->SetViewportInterface( AssetThumbnail.ToSharedRef() );
			AssetThumbnail->GetViewportRenderTargetTexture(); // Access the render texture to push it on the stack if it isnt already rendered

			InArgs._ThumbnailPool->OnThumbnailRendered().AddSP(this, &SAssetThumbnail::OnThumbnailRendered);
			InArgs._ThumbnailPool->OnThumbnailRenderFailed().AddSP(this, &SAssetThumbnail::OnThumbnailRenderFailed);

			if ( ShouldRender() && (!InArgs._AllowFadeIn || InArgs._ThumbnailPool->IsRendered(AssetThumbnail)) )
			{
				bHasRenderedThumbnail = true;
				ViewportFadeAnimation.JumpToEnd();
			}

			// The viewport for the rendered thumbnail, if it exists
			OverlayWidget->AddSlot()
			[
				SNew(SBorder)
				.Padding(0)
				.BorderImage(FEditorStyle::GetBrush("NoBrush"))
				.ColorAndOpacity(this, &SAssetThumbnail::GetViewportColorAndOpacity)
				.Visibility(this, &SAssetThumbnail::GetViewportVisibility)
				[
					Viewport.ToSharedRef()
				]
			];
		}

		OverlayWidget->AddSlot()
		.HAlign( HAlign_Center )
		.VAlign( VAlign_Top )
		.Padding(FMargin(2,2,2,2))
		[
			SNew(SBorder)
			.BorderImage( FEditorStyle::GetBrush( Style, ".HintBackground" ) )
			.BorderBackgroundColor( this, &SAssetThumbnail::GetHintBackgroundColor) //Adjust the opacity of the border itself
			.ColorAndOpacity( HintColorAndOpacity ) //adjusts the opacity of the contents of the border
			.Visibility( this, &SAssetThumbnail::GetHintTextVisibility )
			.Padding(0)
			[
				SAssignNew( HintTextBlock, STextBlock )
				.Text( GetLabelText() )
				.Font( GetHintTextFont() )
				.ColorAndOpacity( FEditorStyle::GetColor( Style, ".HintColorAndOpacity" ) )
				.ShadowOffset( FEditorStyle::GetVector( Style, ".HintShadowOffset" ) )
				.ShadowColorAndOpacity( FEditorStyle::GetColor( Style, ".HintShadowColorAndOpacity" ) )
				.WrapTextAt(this, &SAssetThumbnail::GetTextWrapWidth)
				.HighlightText( HighlightedText )
			]
		];

		// The asset color strip, only visible when the rendered viewport is
		OverlayWidget->AddSlot()
		.HAlign(HAlign_Fill)
		.VAlign(VAlign_Bottom)
		[
			SNew(SBorder)
			.BorderImage(FEditorStyle::GetBrush("WhiteBrush"))
			.BorderBackgroundColor(AssetColor)
			.Visibility(this, &SAssetThumbnail::GetViewportVisibility)
			.Padding(this, &SAssetThumbnail::GetAssetColorStripPadding)
		];

		ChildSlot
		[
			OverlayWidget
		];
	}
Exemplo n.º 15
0
LPFONTDISP CXTPPopupItem::OleGetFont()
{
    return AxCreateOleFont(GetTextFont(), this, (LPFNFONTCHANGED)&CXTPPopupItem::OleSetFont);
}
Exemplo n.º 16
0
void GetLLString (LongPoint *LPointPtr, long UnitCode, char *LatStr, char *LongStr)
{
	long		NegLatFlag, NegLongFlag;
	double		ExLatDeg, ExLongDeg, ExLatMin, ExLongMin, ExLatSec, ExLongSec;
	long		LatDeg, LongDeg, LatMin, LongMin, LatSec, LongSec;
	LongPoint	LLPoint;
	
	LLPoint = *LPointPtr;

	/* check for negative signs and set flags, then manually convert to
		absolute value (lib fuction was having problems) */
	if (LLPoint.v < 0)
	{
		NegLatFlag = -1;
		LLPoint.v = -LLPoint.v;
	}
	else if (LLPoint.v > 0)
		NegLatFlag = 1;
	else
		NegLatFlag = 0;

	if (LLPoint.h < 0)
	{
		NegLongFlag = -1;
		LLPoint.h = -LLPoint.h;
	}
	else if (LLPoint.h > 0)
		NegLongFlag = 1;
	else
		NegLongFlag = 0;

	/* convert matrix point to decimal degrees */
	ExLatDeg  = LLPoint.v / 1000000.0;
	ExLongDeg = LLPoint.h / 1000000.0;

	/* extract the degrees portion of decimal degrees */
	LatDeg  = ExLatDeg;
	LongDeg = ExLongDeg;

	/* now get decimal minutes by subtracting the int-degrees from decimal degrees */
	ExLatMin  = ExLatDeg  - (long) ExLatDeg;
	ExLongMin = ExLongDeg - (long) ExLongDeg;

	/* convert decimal degrees into decimal minutes */
	ExLatMin  *= 59.9999999;
	ExLongMin *= 59.9999999;

	LatMin  = ExLatMin;
	LongMin = ExLongMin;

	{
		/* now get the decimal secons using minutes */
		ExLatSec  = ExLatMin  - (long) ExLatMin;
		ExLongSec = ExLongMin - (long) ExLongMin;
		ExLatSec  *= 100.0;		/* each second is one/hundredth of a degree for better res */
		ExLongSec *= 100.0;		/* each second is one/hundredth of a degree for better res */
		
		/* convert to integer seconds */
		LatSec  = ExLatSec;
		LongSec = ExLongSec;
	}

//	Debug ("LatDeg = %2.2d, LatMin = %2.2d, LatSec = %2.2d\nExLatMin = %f\n", LatDeg, LatMin, LatSec, ExLatMin);

	if (UnitCode == kDMUnitCode)					/* degrees and decimal minutes requested */
	{
		char	latFormat [64], longFormat [64];
		
		char degChar = GetDegreeChar(GetTextFont()); //JLM
 
		strcpy (latFormat,  "%2.2d%c ");//JLM
		strcpy (longFormat, "%2.2d%c ");
		
		{
			if ((long) (ExLatMin * 3600) != 0)
			{
				if (LatSec == 99 || LatSec == 0)
					strcat (latFormat, "%2.0f' ");
				else
					strcat (latFormat, "%5.2f' ");
			}
			
			if ((long) (ExLongMin * 3600) != 0)
			{
				if (LongSec == 99 || LongSec == 0)
					strcat (longFormat, "%2.0f' ");
				else
					strcat (longFormat, "%5.2f' ");
			}
		}
		
		{		
			if (NegLatFlag < 0)
				strcat (latFormat, "S ");
			else if (NegLatFlag > 0)
				strcat (latFormat, "N ");
			else
				strcat (latFormat, "  ");
			
			if (NegLongFlag < 0)
				strcat (longFormat, "W ");
			else if (NegLongFlag > 0)
				strcat (longFormat, "E ");
			else
				strcat (longFormat, "  ");
		}
		
		sprintf (LatStr,  latFormat,  LatDeg,  degChar, ExLatMin); //JLM
		sprintf (LongStr, longFormat, LongDeg, degChar, ExLongMin);
	}
	else if (UnitCode == kDecDegUnitCode)		/* decimal degrees requested */
	{
		/* we need decimal degrees */
		ExLatDeg = LLPoint.v / 1000000.0;
		ExLongDeg = LLPoint.h / 1000000.0;

		if (NegLatFlag < 0)
			sprintf (LatStr,  "%05.3f' S ", ExLatDeg);
		else if (NegLatFlag > 0)
			sprintf (LatStr,  "%05.3f' N ", ExLatDeg);
		else
			sprintf (LatStr,  "%05.3f'   ", ExLatDeg);
		
		if (NegLongFlag < 0)
			sprintf (LongStr, "%05.3f' W ", ExLongDeg);
		else if (NegLongFlag > 0)
			sprintf (LongStr, "%05.3f' E ", ExLongDeg);
		else
			sprintf (LongStr, "%05.3f'   ", ExLongDeg);
	}
	else if (UnitCode == kDMSUnitCode)					/* degrees, minutes and seconds requested */
	{
	}

	return;
}
Exemplo n.º 17
0
void wxFlatButton::OnPaint(wxPaintEvent& event)
{
    wxUnusedVar(event);
    wxAutoBufferedPaintDC paintDC(this);
    wxGCDC gdc;
    GetGCDC(paintDC, gdc);

    wxRect clientRect = GetClientRect();
    // Draw the background
    gdc.SetPen(GetBarBgColour(m_theme));
    gdc.SetBrush(GetBarBgColour(m_theme));
    gdc.DrawRectangle(clientRect);

    switch(m_state) {
    case kStateHover: {
        if(!IsChecked()) {
            // Hover
            gdc.SetBrush(GetBgHoverColour());
            gdc.SetPen(m_penHoverOuterColour);
            gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);

            clientRect.Deflate(1);
            gdc.SetBrush(*wxTRANSPARENT_BRUSH);
            gdc.SetPen(m_penHoverColourInner);
            gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);

            // gdc.SetPen(m_penHoverColourInner);
            // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft());
            // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight());
            //
            // gdc.SetPen(m_penHoverOuterColour);
            // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight());
            // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft());
        }
        break;
    }
    case kStateNormal: {
        // do nothing
        gdc.SetBrush(GetBgColour());
        gdc.SetPen(GetPenNormalColour());
        gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);
        break;
    }
    case kStatePressed: {
        // Pressed
        gdc.SetBrush(GetBgPressedColour());
        gdc.SetPen(GetPenPressedColour());
        gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);

        // gdc.SetBrush(GetBgPressedColour());
        // gdc.DrawRectangle(clientRect);
        //
        // gdc.SetPen(m_penHoverOuterColour);
        // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft());
        // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight());
        //
        // gdc.SetPen(m_penHoverColourInner);
        // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight());
        // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft());
        break;
    }
    }

    // Draw text
    gdc.SetFont(GetTextFont());
    if(!IsEnabled()) {
        gdc.SetTextForeground(GetTextColourDisabled());
        gdc.DrawLabel(
            m_text, m_bmpDisabled, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex);
    } else {
        gdc.SetTextForeground(GetTextColour());
        gdc.DrawLabel(m_text, m_bmp, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex);
    }
}
Exemplo n.º 18
0
void wxFlatButton::OnPaint(wxPaintEvent& event)
{
    wxUnusedVar(event);
    wxAutoBufferedPaintDC paintDC(this);
    PrepareDC(paintDC);

    wxGCDC gdc;
    GetGCDC(paintDC, gdc);

    wxRect clientRect = GetClientRect();
    // Draw the background
    gdc.SetPen(GetBarBgColour(m_theme));
    gdc.SetBrush(GetBarBgColour(m_theme));
    gdc.DrawRectangle(clientRect);

    switch(m_state) {
    case kStateHover: {
        // do nothing
        gdc.SetBrush(GetBgColour());
        gdc.SetPen(GetPenNormalColour());
        gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);
        break;
    }
    case kStateNormal: {
        break;
    }
    case kStatePressed: {
        // Pressed
        gdc.SetBrush(GetBgPressedColour());
        gdc.SetPen(GetPenPressedColour());
        gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS);
        break;
    }
    }

    // Draw text
    gdc.SetFont(GetTextFont());
    wxColour textColour = IsEnabled() ? GetTextColour() : GetTextColourDisabled();
    wxBitmap bmp = IsEnabled() ? m_bmp : m_bmpDisabled;

    wxCoord textY;
    wxCoord bmpY;

    wxCoord totalLen = 0;
    const int spacer = 2;
    if(bmp.IsOk()) {
        // we got a bitmap
        totalLen += bmp.GetScaledWidth();
    }

    wxSize textSize;
    if(!m_text.IsEmpty()) {
        textSize = gdc.GetTextExtent(m_text);
        totalLen += spacer;
        totalLen += textSize.x;
    }

    wxCoord offset = (clientRect.GetWidth() - totalLen) / 2;
    bmpY = (clientRect.GetHeight() - bmp.GetScaledHeight()) / 2;
    textY = (clientRect.GetHeight() - textSize.y) / 2;
    if(bmp.IsOk()) {
        gdc.DrawBitmap(bmp, offset, bmpY);
        offset += bmp.GetScaledWidth();
        offset += spacer;
    }

    if(!m_text.IsEmpty()) {
        gdc.DrawText(m_text, offset, textY);
        offset += textSize.x;
        offset += spacer;
    }
}
Exemplo n.º 19
0
	/** Constructs this widget with InArgs */
	void Construct( const FArguments& InArgs )
	{
		Style = InArgs._Style;
		HighlightedText = InArgs._HighlightedText;
		Label = InArgs._Label;
		HintColorAndOpacity = InArgs._HintColorAndOpacity;
		bAllowHintText = InArgs._AllowHintText;

		AssetThumbnail = InArgs._AssetThumbnail;
		bHasRenderedThumbnail = false;
		WidthLastFrame = 0;
		GenericThumbnailBorderPadding = 2.f;

		AssetThumbnail->OnAssetDataChanged().AddSP(this, &SAssetThumbnail::OnAssetDataChanged);

		const FAssetData& AssetData = AssetThumbnail->GetAssetData();

		UClass* Class = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetClass.ToString());
		FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
		TSharedPtr<IAssetTypeActions> AssetTypeActions;
		if ( Class != NULL )
		{
			AssetTypeActions = AssetToolsModule.Get().GetAssetTypeActionsForClass(Class).Pin();
		}

		AssetColor = FLinearColor::White;
		if( InArgs._AssetTypeColorOverride.IsSet() )
		{
			AssetColor = InArgs._AssetTypeColorOverride.GetValue();
		}
		else if ( AssetTypeActions.IsValid() )
		{
			AssetColor = AssetTypeActions->GetTypeColor();
		}

		TSharedRef<SOverlay> OverlayWidget = SNew(SOverlay);

		UpdateThumbnailClass(AssetData.AssetName, Class);

		ClassThumbnailBrushOverride = InArgs._ClassThumbnailBrushOverride;

		// The generic representation of the thumbnail, for use before the rendered version, if it exists
		OverlayWidget->AddSlot()
		[
			SNew(SBorder)
			.BorderImage(GetAssetBackgroundBrush())
			.BorderBackgroundColor(AssetColor.CopyWithNewOpacity(0.3f))
			.Padding(GenericThumbnailBorderPadding)
			.VAlign(VAlign_Center)
			.HAlign(HAlign_Center)
			.Visibility(this, &SAssetThumbnail::GetGenericThumbnailVisibility)
			[
				SNew(SOverlay)

				+SOverlay::Slot()
				[
					SAssignNew(GenericLabelTextBlock, STextBlock)
					.Text(GetLabelText())
					.Font(GetTextFont())
					.Justification(ETextJustify::Center)
					.ColorAndOpacity(FEditorStyle::GetColor(Style, ".ColorAndOpacity"))
					.ShadowOffset(FEditorStyle::GetVector(Style, ".ShadowOffset"))
					.ShadowColorAndOpacity( FEditorStyle::GetColor(Style, ".ShadowColorAndOpacity"))
					.HighlightText(HighlightedText)
				]

				+SOverlay::Slot()
				[
					SAssignNew(GenericThumbnailImage, SImage)
					.Image(this, &SAssetThumbnail::GetClassThumbnailBrush)
				]
			]
		];

		if ( InArgs._ThumbnailPool.IsValid() && !InArgs._ForceGenericThumbnail )
		{
			ViewportFadeAnimation = FCurveSequence();
			ViewportFadeCurve = ViewportFadeAnimation.AddCurve(0.f, 0.25f, ECurveEaseFunction::QuadOut);

			TSharedPtr<SViewport> Viewport = 
				SNew( SViewport )
				.EnableGammaCorrection(false);

			Viewport->SetViewportInterface( AssetThumbnail.ToSharedRef() );
			AssetThumbnail->GetViewportRenderTargetTexture(); // Access the render texture to push it on the stack if it isnt already rendered

			InArgs._ThumbnailPool->OnThumbnailRendered().AddSP(this, &SAssetThumbnail::OnThumbnailRendered);
			InArgs._ThumbnailPool->OnThumbnailRenderFailed().AddSP(this, &SAssetThumbnail::OnThumbnailRenderFailed);

			if ( ShouldRender() && (!InArgs._AllowFadeIn || InArgs._ThumbnailPool->IsRendered(AssetThumbnail)) )
			{
				bHasRenderedThumbnail = true;
				ViewportFadeAnimation.JumpToEnd();
			}

			// The viewport for the rendered thumbnail, if it exists
			OverlayWidget->AddSlot()
			[
				SAssignNew(RenderedThumbnailWidget, SBorder)
				.Padding(0)
				.BorderImage(FEditorStyle::GetBrush("NoBrush"))
				.ColorAndOpacity(this, &SAssetThumbnail::GetViewportColorAndOpacity)
				[
					Viewport.ToSharedRef()
				]
			];
		}

		if( ThumbnailClass.Get() && bIsClassType )
		{
			OverlayWidget->AddSlot()
			.VAlign(VAlign_Bottom)
			.HAlign(HAlign_Right)
			.Padding(TAttribute<FMargin>(this, &SAssetThumbnail::GetClassIconPadding))
			[
				SAssignNew(ClassIconWidget, SBorder)
				.BorderImage(FEditorStyle::GetNoBrush())
				[
					SNew(SImage)
					.Image(this, &SAssetThumbnail::GetClassIconBrush)
				]
			];
		}

		if( bAllowHintText )
		{
			OverlayWidget->AddSlot()
				.HAlign(HAlign_Center)
				.VAlign(VAlign_Top)
				.Padding(FMargin(2, 2, 2, 2))
				[
					SNew(SBorder)
					.BorderImage(FEditorStyle::GetBrush(Style, ".HintBackground"))
					.BorderBackgroundColor(this, &SAssetThumbnail::GetHintBackgroundColor) //Adjust the opacity of the border itself
					.ColorAndOpacity(HintColorAndOpacity) //adjusts the opacity of the contents of the border
					.Visibility(this, &SAssetThumbnail::GetHintTextVisibility)
					.Padding(0)
					[
						SAssignNew(HintTextBlock, STextBlock)
						.Text(GetLabelText())
						.Font(GetHintTextFont())
						.ColorAndOpacity(FEditorStyle::GetColor(Style, ".HintColorAndOpacity"))
						.ShadowOffset(FEditorStyle::GetVector(Style, ".HintShadowOffset"))
						.ShadowColorAndOpacity(FEditorStyle::GetColor(Style, ".HintShadowColorAndOpacity"))
						.HighlightText(HighlightedText)
					]
				];
		}

		// The asset color strip
		OverlayWidget->AddSlot()
		.HAlign(HAlign_Fill)
		.VAlign(VAlign_Bottom)
		[
			SAssignNew(AssetColorStripWidget, SBorder)
			.BorderImage(FEditorStyle::GetBrush("WhiteBrush"))
			.BorderBackgroundColor(AssetColor)
			.Padding(this, &SAssetThumbnail::GetAssetColorStripPadding)
		];

		if( InArgs._AllowAssetSpecificThumbnailOverlay && AssetTypeActions.IsValid() )
		{
			// Does the asset provide an additional thumbnail overlay?
			TSharedPtr<SWidget> AssetSpecificThumbnailOverlay = AssetTypeActions->GetThumbnailOverlay(AssetData);
			if( AssetSpecificThumbnailOverlay.IsValid() )
			{
				OverlayWidget->AddSlot()
				[
					AssetSpecificThumbnailOverlay.ToSharedRef()
				];
			}
		}

		ChildSlot
		[
			OverlayWidget
		];

		UpdateThumbnailVisibilities();

	}