Logo ROOT   6.14/05
Reference Guide
TGWidget.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 05/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGWidget
13 #define ROOT_TGWidget
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGWidget //
19 // //
20 // The widget base class. It is light weight (all inline service //
21 // methods) and is typically used as mixin class (via multiple //
22 // inheritance), see for example TGButton. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "GuiTypes.h"
27 #include "TGString.h"
28 #include "WidgetMessageTypes.h"
29 
30 
31 //--- Text justification modes
32 
34  kTextLeft = BIT(0),
37  kTextTop = BIT(3),
40 };
41 
42 
43 //--- Widget status
44 
49 };
50 
51 
52 class TGWindow;
53 
54 
55 class TGWidget {
56 
57 protected:
58  Int_t fWidgetId; // the widget id (used for event processing)
59  Int_t fWidgetFlags; // widget status flags (OR of EWidgetStatus)
60  const TGWindow *fMsgWindow; // window which handles widget events
61  TString fCommand; // command to be executed
62 
63  TGWidget(const TGWidget& tgw):
64  fWidgetId(tgw.fWidgetId), fWidgetFlags(tgw.fWidgetFlags),
65  fMsgWindow(tgw.fMsgWindow), fCommand(tgw.fCommand) { }
66  TGWidget& operator=(const TGWidget& tgw) {
67  if(this!=&tgw) {
68  fWidgetId=tgw.fWidgetId; fWidgetFlags=tgw.fWidgetFlags;
69  fMsgWindow=tgw.fMsgWindow; fCommand=tgw.fCommand; } return *this; }
70  Int_t SetFlags(Int_t flags) { return fWidgetFlags |= flags; }
71  Int_t ClearFlags(Int_t flags) { return fWidgetFlags &= ~flags; }
72 
73 public:
75  fWidgetId(-1), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
77  fWidgetId(id), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
78  virtual ~TGWidget() { }
79 
80  Int_t WidgetId() const { return fWidgetId; }
81  Bool_t IsEnabled() const { return (Bool_t)((fWidgetFlags & kWidgetIsEnabled) != 0); }
82  Bool_t HasFocus() const { return (Bool_t)((fWidgetFlags & kWidgetHasFocus) != 0); }
83  Bool_t WantFocus() const { return (Bool_t)((fWidgetFlags & kWidgetWantFocus) != 0); }
84  virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
85  virtual void SetCommand(const char *command) { fCommand = command; }
86  const char *GetCommand() const { return fCommand.Data(); }
87 
88  ClassDef(TGWidget,0) // Widget base class
89 };
90 
91 #endif
TGWidget(Int_t id)
Definition: TGWidget.h:76
TGWidget(const TGWidget &tgw)
Definition: TGWidget.h:63
#define BIT(n)
Definition: Rtypes.h:78
Int_t WidgetId() const
Definition: TGWidget.h:80
TGWidget & operator=(const TGWidget &tgw)
Definition: TGWidget.h:66
Int_t SetFlags(Int_t flags)
Definition: TGWidget.h:70
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ETextJustification
Definition: TGWidget.h:33
Int_t fWidgetId
Definition: TGWidget.h:58
const char * GetCommand() const
Definition: TGWidget.h:86
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void SetCommand(const char *command)
Definition: TGWidget.h:85
virtual ~TGWidget()
Definition: TGWidget.h:78
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
TString fCommand
Definition: TGWidget.h:61
Int_t ClearFlags(Int_t flags)
Definition: TGWidget.h:71
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t HasFocus() const
Definition: TGWidget.h:82
Bool_t IsEnabled() const
Definition: TGWidget.h:81
EWidgetStatus
Definition: TGWidget.h:45
Int_t fWidgetFlags
Definition: TGWidget.h:59
TGWidget()
Definition: TGWidget.h:74
const char * Data() const
Definition: TString.h:364
Bool_t WantFocus() const
Definition: TGWidget.h:83