Warning, file /include/root/TGLabel.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGLabel
0013 #define ROOT_TGLabel
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGDimension.h"
0018 #include "TGString.h"
0019
0020 class TColor;
0021 class TGTextLayout;
0022 class TGFont;
0023
0024 class TGLabel : public TGFrame {
0025
0026 protected:
0027 TGString *fText;
0028 UInt_t fTWidth;
0029 UInt_t fTHeight;
0030 Int_t fMLeft;
0031 Int_t fMRight;
0032 Int_t fMTop;
0033 Int_t fMBottom;
0034 Int_t fTMode;
0035 Int_t f3DStyle;
0036 Int_t fWrapLength;
0037 Int_t fTFlags;
0038 Bool_t fTextChanged;
0039 GContext_t fNormGC;
0040 TGFont *fFont;
0041 TGTextLayout *fTLayout;
0042 Bool_t fHasOwnFont;
0043 Bool_t fDisabled;
0044
0045 void DoRedraw() override;
0046 virtual void DrawText(GContext_t gc, Int_t x, Int_t y);
0047
0048 static const TGFont *fgDefaultFont;
0049 static const TGGC *fgDefaultGC;
0050
0051 private:
0052 TGLabel(const TGLabel&) = delete;
0053 TGLabel& operator=(const TGLabel&) = delete;
0054
0055 public:
0056 static FontStruct_t GetDefaultFontStruct();
0057 static const TGGC &GetDefaultGC();
0058
0059 TGLabel(const TGWindow *p, TGString *text,
0060 GContext_t norm = GetDefaultGC()(),
0061 FontStruct_t font = GetDefaultFontStruct(),
0062 UInt_t options = kChildFrame,
0063 Pixel_t back = GetDefaultFrameBackground());
0064 TGLabel(const TGWindow *p = nullptr, const char *text = nullptr,
0065 GContext_t norm = GetDefaultGC()(),
0066 FontStruct_t font = GetDefaultFontStruct(),
0067 UInt_t options = kChildFrame,
0068 Pixel_t back = GetDefaultFrameBackground());
0069
0070 ~TGLabel() override;
0071
0072 TGDimension GetDefaultSize() const override;
0073
0074 const TGString *GetText() const { return fText; }
0075 const char *GetTitle() const override { return fText->Data(); }
0076 virtual void SetText(TGString *newText);
0077 void SetText(const char *newText) { SetText(new TGString(newText)); }
0078 virtual void ChangeText(const char *newText) { SetText(newText); }
0079 virtual void SetTitle(const char *label) { SetText(label); }
0080 void SetText(Int_t number) { SetText(new TGString(number)); }
0081 void SetTextJustify(Int_t tmode);
0082 Int_t GetTextJustify() const { return fTMode; }
0083 virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
0084 virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
0085 virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
0086 virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
0087 virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
0088 void SetForegroundColor(Pixel_t fore) override { SetTextColor(fore); }
0089 virtual void Disable(Bool_t on = kTRUE)
0090 { fDisabled = on; fClient->NeedRedraw(this); }
0091 virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
0092 Bool_t IsDisabled() const { return fDisabled; }
0093 Bool_t HasOwnFont() const;
0094
0095 void SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
0096 Int_t GetWrapLength() const { return fWrapLength; }
0097
0098 void Set3DStyle(Int_t style) { f3DStyle = style; fClient->NeedRedraw(this); }
0099 Int_t Get3DStyle() const { return f3DStyle; }
0100
0101 void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
0102 { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
0103 Int_t GetLeftMargin() const { return fMLeft; }
0104 Int_t GetRightMargin() const { return fMRight; }
0105 Int_t GetTopMargin() const { return fMTop; }
0106 Int_t GetBottomMargin() const { return fMBottom; }
0107
0108 GContext_t GetNormGC() const { return fNormGC; }
0109 FontStruct_t GetFontStruct() const { return fFont->GetFontStruct(); }
0110 TGFont *GetFont() const { return fFont; }
0111
0112 void Layout() override;
0113 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0114
0115 ClassDefOverride(TGLabel,0)
0116 };
0117
0118 #endif