// @(#)root/gui:$Id$
// Author: Fons Rademakers   06/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLabel
#define ROOT_TGLabel


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGLabel                                                              //
//                                                                      //
// This class handles GUI labels.                                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGDimension
#include "TGDimension.h"
#endif
#ifndef ROOT_TGString
#include "TGString.h"
#endif

class TColor;
class TGTextLayout;
class TGFont;

class TGLabel : public TGFrame {

protected:
   TGString      *fText;         // label text
   UInt_t         fTWidth;       // text width
   UInt_t         fTHeight;      // text height
   Int_t          fMLeft;        // margin left
   Int_t          fMRight;       // margin right
   Int_t          fMTop;         // margin top
   Int_t          fMBottom;      // margin bottom
   Int_t          fTMode;        // text alignment
   Int_t          f3DStyle;      // 3D style (0 - normal, kRaisedFrame - raised, kSunkenFrame - sunken)
   Int_t          fWrapLength;   // wrap length
   Int_t          fTFlags;       // text flags (see TGFont.h  ETextLayoutFlags)
   Bool_t         fTextChanged;  // has text changed
   GContext_t     fNormGC;       // graphics context used for drawing label
   TGFont        *fFont;         // font to draw label
   TGTextLayout  *fTLayout;      // text layout
   Bool_t         fHasOwnFont;   // kTRUE - font defined locally,  kFALSE - globally
   Bool_t         fDisabled;     // if kTRUE label looks disabled (shaded text)

   virtual void DoRedraw();
   virtual void DrawText(GContext_t gc, Int_t x, Int_t y);

   static const TGFont  *fgDefaultFont;
   static const TGGC    *fgDefaultGC;

private:
   TGLabel(const TGLabel&);             // not implemented
   TGLabel& operator=(const TGLabel&);  // not implemented

public:
   static FontStruct_t  GetDefaultFontStruct();
   static const TGGC   &GetDefaultGC();

   TGLabel(const TGWindow *p, TGString *text,
           GContext_t norm = GetDefaultGC()(),
           FontStruct_t font = GetDefaultFontStruct(),
           UInt_t options = kChildFrame,
           Pixel_t back = GetDefaultFrameBackground());
   TGLabel(const TGWindow *p = 0, const char *text = 0,
           GContext_t norm = GetDefaultGC()(),
           FontStruct_t font = GetDefaultFontStruct(),
           UInt_t options = kChildFrame,
           Pixel_t back = GetDefaultFrameBackground());

   virtual ~TGLabel();

   virtual TGDimension GetDefaultSize() const;

   const TGString *GetText() const { return fText; }
   virtual const char *GetTitle() const { return fText->Data(); }
   virtual void SetText(TGString *newText);
   void SetText(const char *newText) { SetText(new TGString(newText)); }
   virtual void ChangeText(const char *newText) { SetText(newText); } //*MENU*icon=bld_rename.png*
   virtual void SetTitle(const char *label) { SetText(label); }
   void  SetText(Int_t number) { SetText(new TGString(number)); }
   void  SetTextJustify(Int_t tmode);
   Int_t GetTextJustify() const { return fTMode; }
   virtual void SetTextFont(TGFont *font, Bool_t global = kFALSE);
   virtual void SetTextFont(FontStruct_t font, Bool_t global = kFALSE);
   virtual void SetTextFont(const char *fontName, Bool_t global = kFALSE);
   virtual void SetTextColor(Pixel_t color, Bool_t global = kFALSE);
   virtual void SetTextColor(TColor *color, Bool_t global = kFALSE);
   virtual void SetForegroundColor(Pixel_t fore) { SetTextColor(fore); }
   virtual void Disable(Bool_t on = kTRUE)
               { fDisabled = on; fClient->NeedRedraw(this); } //*TOGGLE* *GETTER=IsDisabled
   virtual void Enable() { fDisabled = kFALSE; fClient->NeedRedraw(this); }
   Bool_t IsDisabled() const { return fDisabled; }
   Bool_t HasOwnFont() const;

   void  SetWrapLength(Int_t wl) { fWrapLength = wl; Layout(); }
   Int_t GetWrapLength() const { return fWrapLength; }

   void  Set3DStyle(Int_t style) { f3DStyle = style; fClient->NeedRedraw(this); }
   Int_t Get3DStyle() const { return f3DStyle; }

   void SetMargins(Int_t left=0, Int_t right=0, Int_t top=0, Int_t bottom=0)
      { fMLeft = left; fMRight = right; fMTop = top; fMBottom = bottom; }
   Int_t GetLeftMargin() const { return fMLeft; }
   Int_t GetRightMargin() const { return fMRight; }
   Int_t GetTopMargin() const { return fMTop; }
   Int_t GetBottomMargin() const { return fMBottom; }

   GContext_t GetNormGC() const { return fNormGC; }
   FontStruct_t GetFontStruct() const { return fFont->GetFontStruct(); }
   TGFont      *GetFont() const  { return fFont; }

   virtual void Layout();
   virtual void SavePrimitive(std::ostream &out, Option_t *option = "");

   ClassDef(TGLabel,0)  // A label GUI element
};

#endif
 TGLabel.h:1
 TGLabel.h:2
 TGLabel.h:3
 TGLabel.h:4
 TGLabel.h:5
 TGLabel.h:6
 TGLabel.h:7
 TGLabel.h:8
 TGLabel.h:9
 TGLabel.h:10
 TGLabel.h:11
 TGLabel.h:12
 TGLabel.h:13
 TGLabel.h:14
 TGLabel.h:15
 TGLabel.h:16
 TGLabel.h:17
 TGLabel.h:18
 TGLabel.h:19
 TGLabel.h:20
 TGLabel.h:21
 TGLabel.h:22
 TGLabel.h:23
 TGLabel.h:24
 TGLabel.h:25
 TGLabel.h:26
 TGLabel.h:27
 TGLabel.h:28
 TGLabel.h:29
 TGLabel.h:30
 TGLabel.h:31
 TGLabel.h:32
 TGLabel.h:33
 TGLabel.h:34
 TGLabel.h:35
 TGLabel.h:36
 TGLabel.h:37
 TGLabel.h:38
 TGLabel.h:39
 TGLabel.h:40
 TGLabel.h:41
 TGLabel.h:42
 TGLabel.h:43
 TGLabel.h:44
 TGLabel.h:45
 TGLabel.h:46
 TGLabel.h:47
 TGLabel.h:48
 TGLabel.h:49
 TGLabel.h:50
 TGLabel.h:51
 TGLabel.h:52
 TGLabel.h:53
 TGLabel.h:54
 TGLabel.h:55
 TGLabel.h:56
 TGLabel.h:57
 TGLabel.h:58
 TGLabel.h:59
 TGLabel.h:60
 TGLabel.h:61
 TGLabel.h:62
 TGLabel.h:63
 TGLabel.h:64
 TGLabel.h:65
 TGLabel.h:66
 TGLabel.h:67
 TGLabel.h:68
 TGLabel.h:69
 TGLabel.h:70
 TGLabel.h:71
 TGLabel.h:72
 TGLabel.h:73
 TGLabel.h:74
 TGLabel.h:75
 TGLabel.h:76
 TGLabel.h:77
 TGLabel.h:78
 TGLabel.h:79
 TGLabel.h:80
 TGLabel.h:81
 TGLabel.h:82
 TGLabel.h:83
 TGLabel.h:84
 TGLabel.h:85
 TGLabel.h:86
 TGLabel.h:87
 TGLabel.h:88
 TGLabel.h:89
 TGLabel.h:90
 TGLabel.h:91
 TGLabel.h:92
 TGLabel.h:93
 TGLabel.h:94
 TGLabel.h:95
 TGLabel.h:96
 TGLabel.h:97
 TGLabel.h:98
 TGLabel.h:99
 TGLabel.h:100
 TGLabel.h:101
 TGLabel.h:102
 TGLabel.h:103
 TGLabel.h:104
 TGLabel.h:105
 TGLabel.h:106
 TGLabel.h:107
 TGLabel.h:108
 TGLabel.h:109
 TGLabel.h:110
 TGLabel.h:111
 TGLabel.h:112
 TGLabel.h:113
 TGLabel.h:114
 TGLabel.h:115
 TGLabel.h:116
 TGLabel.h:117
 TGLabel.h:118
 TGLabel.h:119
 TGLabel.h:120
 TGLabel.h:121
 TGLabel.h:122
 TGLabel.h:123
 TGLabel.h:124
 TGLabel.h:125
 TGLabel.h:126
 TGLabel.h:127
 TGLabel.h:128
 TGLabel.h:129
 TGLabel.h:130
 TGLabel.h:131
 TGLabel.h:132