Guest User

RichTextBox.h

a guest
Jan 20th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.22 KB | None | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "Runtime/UMG/Public/UMG.h"
  6. #include "Runtime/UMG/Public/UMGStyle.h"
  7. #include "Runtime/UMG/Public/Components/RichTextBlockDecorator.h"
  8. #include "Components/Widget.h"
  9. #include "RichTextBox.generated.h"
  10.  
  11. /* Replace the project API with yours! */
  12. UCLASS()
  13. class MYPROJECT_API URichTextBox : public UWidget
  14. {
  15.     GENERATED_BODY()
  16.    
  17. public:
  18.     URichTextBox(const FObjectInitializer& ObjectInitializer);
  19.  
  20.     // UWidget interface
  21.     virtual void SynchronizeProperties() override;
  22.     // End of UWidget interface
  23.  
  24.     // UVisual interface
  25.     virtual void ReleaseSlateResources(bool bReleaseChildren) override;
  26.     // End of UVisual interface
  27.  
  28.     // Sets the text of this Rich Text
  29.     UFUNCTION(BlueprintCallable, Category = "Rich Text")
  30.         void SetText(FText InText);
  31.  
  32.     UFUNCTION(BlueprintPure, Category = "Rich Text")
  33.         FText GetText();
  34.  
  35. #if WITH_EDITOR
  36.     // UWidget interface
  37.     //virtual const FSlateBrush* GetEditorIcon() override;
  38.     virtual const FText GetPaletteCategory() override;
  39.     // End UWidget interface
  40. #endif
  41.  
  42. protected:
  43.     /** The text to display */
  44.     UPROPERTY(EditAnywhere, Category = Content, meta = (MultiLine = "true"))
  45.         FText Text;
  46.  
  47.     /** A bindable delegate to allow logic to drive the text of the widget */
  48.     UPROPERTY()
  49.         FGetText TextDelegate;
  50.  
  51.     /** The default color for the text. */
  52.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance)
  53.         FLinearColor ColorAndOpacity;
  54.  
  55.     /** The default font for the text. */
  56.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance)
  57.         FSlateFontInfo Font;
  58.  
  59.     /** The direction the shadow is cast */
  60.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance)
  61.         FVector2D ShadowOffset;
  62.  
  63.     /** The color of the shadow */
  64.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance, meta = (DisplayName = "Shadow Color"))
  65.         FLinearColor ShadowColorAndOpacity;
  66.  
  67.  
  68.     /** How the text should be aligned with the margin. */
  69.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance)
  70.         TEnumAsByte<ETextJustify::Type> Justification;
  71.  
  72.     /** True if we're wrapping text automatically based on the computed horizontal space for this widget */
  73.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance)
  74.         bool AutoWrapText;
  75.  
  76.     /** Whether text wraps onto a new line when it's length exceeds this width; if this value is zero or negative, no wrapping occurs. */
  77.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance, AdvancedDisplay)
  78.         float WrapTextAt;
  79.  
  80.     /** The amount of blank space left around the edges of text area. */
  81.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance, AdvancedDisplay)
  82.         FMargin Margin;
  83.  
  84.     /** The amount to scale each lines height by. */
  85.     UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Appearance, AdvancedDisplay)
  86.         float LineHeightPercentage;
  87.  
  88.     UPROPERTY(EditAnywhere, Instanced, Category = Decorators)
  89.         TArray<class URichTextBlockDecorator*> Decorators;
  90.  
  91. protected:
  92.     FTextBlockStyle DefaultStyle;
  93.  
  94.     /** Native Slate Widget */
  95.     TSharedPtr<SRichTextBlock> MyRichTextBlock;
  96.  
  97.     // UWidget interface
  98.     virtual TSharedRef<SWidget> RebuildWidget() override;
  99.     // End of UWidget interface
  100.  
  101. };
Add Comment
Please, Sign In to add comment