00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLabel
00013 #define ROOT_TGLabel
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_TGFrame
00025 #include "TGFrame.h"
00026 #endif
00027 #ifndef ROOT_TGDimension
00028 #include "TGDimension.h"
00029 #endif
00030 #ifndef ROOT_TGString
00031 #include "TGString.h"
00032 #endif
00033
00034 class TColor;
00035 class TGTextLayout;
00036 class TGFont;
00037
00038 class TGLabel : public TGFrame {
00039
00040 protected:
00041 TGString *fText;
00042 UInt_t fTWidth;
00043 UInt_t fTHeight;
00044 Int_t fMLeft;
00045 Int_t fMRight;
00046 Int_t fMTop;
00047 Int_t fMBottom;
00048 Int_t fTMode;
00049 Int_t f3DStyle;
00050 Int_t fWrapLength;
00051 Int_t fTFlags;
00052 Bool_t fTextChanged;
00053 GContext_t fNormGC;
00054 TGFont *fFont;
00055 TGTextLayout *fTLayout;
00056 Bool_t fHasOwnFont;
00057 Bool_t fDisabled;
00058
00059 virtual void DoRedraw();
00060 virtual void DrawText(GContext_t gc, Int_t x, Int_t y);
00061
00062 static const TGFont *fgDefaultFont;
00063 static const TGGC *fgDefaultGC;
00064
00065 private:
00066 TGLabel(const TGLabel&);
00067 TGLabel& operator=(const TGLabel&);
00068
00069 public:
00070 static FontStruct_t GetDefaultFontStruct();
00071 static const TGGC &GetDefaultGC();
00072
00073 TGLabel(const TGWindow *p, TGString *text,
00074 GContext_t norm = GetDefaultGC()(),
00075 FontStruct_t font = GetDefaultFontStruct(),
00076 UInt_t options = kChildFrame,
00077 Pixel_t back = GetDefaultFrameBackground());
00078 TGLabel(const TGWindow *p = 0, const char *text = 0,
00079 GContext_t norm = GetDefaultGC()(),
00080 FontStruct_t font = GetDefaultFontStruct(),
00081 UInt_t options = kChildFrame,
00082 Pixel_t back = GetDefaultFrameBackground());
00083
00084 virtual ~TGLabel();
00085
00086 virtual TGDimension GetDefaultSize() const;
00087
00088 const TGString *GetText() const { return fText; }
00089 virtual const char *GetTitle() const { return fText->Data(); }
00090 virtual void SetText(TGString *newText);
00091 void SetText(const char *newText) { SetText(new TGString(newText)); }
00092 virtual void ChangeText(const char *newText) { SetText(newText); }
00093 virtual void SetTitle(const char *label) { SetText(label); }
00094 void SetText(Int_t number) { SetText(new TGString(number)); }
00095 void SetTextJustify(Int_t tmode);
00096 Int_t GetTextJustify() const { return fTMode; }
00097 virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
00098 virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
00099 virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
00100 virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
00101 virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
00102 virtual void SetForegroundColor(Pixel_t fore) { SetTextColor(fore); }
00103 virtual void Disable(Bool_t on = kTRUE)
00104 { fDisabled = on; fClient->NeedRedraw(this); }
00105 virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
00106 Bool_t IsDisabled() const { return fDisabled; }
00107 Bool_t HasOwnFont() const;
00108
00109 void SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
00110 Int_t GetWrapLength() const { return fWrapLength; }
00111
00112 void Set3DStyle(Int_t style) { f3DStyle = style; fClient->NeedRedraw(this); }
00113 Int_t Get3DStyle() const { return f3DStyle; }
00114
00115 void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
00116 { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
00117 Int_t GetLeftMargin() const { return fMLeft; }
00118 Int_t GetRightMargin() const { return fMRight; }
00119 Int_t GetTopMargin() const { return fMTop; }
00120 Int_t GetBottomMargin() const { return fMBottom; }
00121
00122 GContext_t GetNormGC() const { return fNormGC; }
00123 FontStruct_t GetFontStruct() const { return fFont->GetFontStruct(); }
00124 TGFont *GetFont() const { return fFont; }
00125
00126 virtual void Layout();
00127 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00128
00129 ClassDef(TGLabel,0)
00130 };
00131
00132 #endif