TGLabel.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGLabel.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   06/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGLabel
00013 #define ROOT_TGLabel
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGLabel                                                              //
00019 //                                                                      //
00020 // This class handles GUI labels.                                       //
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;         // label text
00042    UInt_t         fTWidth;       // text width
00043    UInt_t         fTHeight;      // text height
00044    Int_t          fMLeft;        // margin left
00045    Int_t          fMRight;       // margin right
00046    Int_t          fMTop;         // margin top
00047    Int_t          fMBottom;      // margin bottom
00048    Int_t          fTMode;        // text alignment
00049    Int_t          f3DStyle;      // 3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
00050    Int_t          fWrapLength;   // wrap length
00051    Int_t          fTFlags;       // text flags (see TGFont.h  ETextLayoutFlags)
00052    Bool_t         fTextChanged;  // has text changed
00053    GContext_t     fNormGC;       // graphics context used for drawing label
00054    TGFont        *fFont;         // font to draw label
00055    TGTextLayout  *fTLayout;      // text layout   
00056    Bool_t         fHasOwnFont;   // kTRUE - font defined locally,  kFALSE - globally
00057    Bool_t         fDisabled;     // if kTRUE label looks disabled (shaded text)
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&);             // not implemented
00067    TGLabel& operator=(const TGLabel&);  // not implemented
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); } //*MENU*icon=bld_rename.png*
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); } //*TOGGLE* *GETTER=IsDisabled
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)  // A label GUI element
00130 };
00131 
00132 #endif

Generated on Tue Jul 5 14:20:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1