ROOT logo
// @(#)root/gui:$Id: TGWidget.h 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   05/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_TGWidget
#define ROOT_TGWidget


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGWidget                                                             //
//                                                                      //
// The widget base class. It is light weight (all inline service        //
// methods) and is typically used as mixin class (via multiple          //
// inheritance), see for example TGButton.                              //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_GuiTypes
#include "GuiTypes.h"
#endif
#ifndef ROOT_TGString
#include "TGString.h"
#endif
#ifndef ROOT_WidgetMessageTypes
#include "WidgetMessageTypes.h"
#endif


//--- Text justification modes

enum ETextJustification {
   kTextLeft    = BIT(0),
   kTextRight   = BIT(1),
   kTextCenterX = BIT(2),
   kTextTop     = BIT(3),
   kTextBottom  = BIT(4),
   kTextCenterY = BIT(5)
};


//--- Widget status

enum EWidgetStatus {
   kWidgetWantFocus = BIT(0),
   kWidgetHasFocus  = BIT(1),
   kWidgetIsEnabled = BIT(2)
};


class TGWindow;


class TGWidget {

protected:
   Int_t            fWidgetId;     // the widget id (used for event processing)
   Int_t            fWidgetFlags;  // widget status flags (OR of EWidgetStatus)
   const TGWindow  *fMsgWindow;    // window which handles widget events
   TString          fCommand;      // command to be executed

   TGWidget(const TGWidget& tgw):
     fWidgetId(tgw.fWidgetId), fWidgetFlags(tgw.fWidgetFlags), 
     fMsgWindow(tgw.fMsgWindow), fCommand(tgw.fCommand) { }
   TGWidget& operator=(const TGWidget& tgw) {
     if(this!=&tgw) {
       fWidgetId=tgw.fWidgetId; fWidgetFlags=tgw.fWidgetFlags;
       fMsgWindow=tgw.fMsgWindow; fCommand=tgw.fCommand; } return *this; }
   Int_t SetFlags(Int_t flags) { return fWidgetFlags |= flags; }
   Int_t ClearFlags(Int_t flags) { return fWidgetFlags &= ~flags; }

public:
   TGWidget(): 
     fWidgetId(-1), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
   TGWidget(Int_t id):
     fWidgetId(id), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
   virtual ~TGWidget() { }

   Int_t         WidgetId() const { return fWidgetId; }
   Bool_t        IsEnabled() const { return (Bool_t)((fWidgetFlags & kWidgetIsEnabled) != 0); }
   Bool_t        HasFocus() const { return (Bool_t)((fWidgetFlags & kWidgetHasFocus) != 0); }
   Bool_t        WantFocus() const { return (Bool_t)((fWidgetFlags & kWidgetWantFocus) != 0); }
   virtual void  Associate(const TGWindow *w) { fMsgWindow = w; }
   virtual void  SetCommand(const char *command) { fCommand = command; }
   const char   *GetCommand() const { return fCommand.Data(); }

   ClassDef(TGWidget,0)  // Widget base class
};

#endif
 TGWidget.h:1
 TGWidget.h:2
 TGWidget.h:3
 TGWidget.h:4
 TGWidget.h:5
 TGWidget.h:6
 TGWidget.h:7
 TGWidget.h:8
 TGWidget.h:9
 TGWidget.h:10
 TGWidget.h:11
 TGWidget.h:12
 TGWidget.h:13
 TGWidget.h:14
 TGWidget.h:15
 TGWidget.h:16
 TGWidget.h:17
 TGWidget.h:18
 TGWidget.h:19
 TGWidget.h:20
 TGWidget.h:21
 TGWidget.h:22
 TGWidget.h:23
 TGWidget.h:24
 TGWidget.h:25
 TGWidget.h:26
 TGWidget.h:27
 TGWidget.h:28
 TGWidget.h:29
 TGWidget.h:30
 TGWidget.h:31
 TGWidget.h:32
 TGWidget.h:33
 TGWidget.h:34
 TGWidget.h:35
 TGWidget.h:36
 TGWidget.h:37
 TGWidget.h:38
 TGWidget.h:39
 TGWidget.h:40
 TGWidget.h:41
 TGWidget.h:42
 TGWidget.h:43
 TGWidget.h:44
 TGWidget.h:45
 TGWidget.h:46
 TGWidget.h:47
 TGWidget.h:48
 TGWidget.h:49
 TGWidget.h:50
 TGWidget.h:51
 TGWidget.h:52
 TGWidget.h:53
 TGWidget.h:54
 TGWidget.h:55
 TGWidget.h:56
 TGWidget.h:57
 TGWidget.h:58
 TGWidget.h:59
 TGWidget.h:60
 TGWidget.h:61
 TGWidget.h:62
 TGWidget.h:63
 TGWidget.h:64
 TGWidget.h:65
 TGWidget.h:66
 TGWidget.h:67
 TGWidget.h:68
 TGWidget.h:69
 TGWidget.h:70
 TGWidget.h:71
 TGWidget.h:72
 TGWidget.h:73
 TGWidget.h:74
 TGWidget.h:75
 TGWidget.h:76
 TGWidget.h:77
 TGWidget.h:78
 TGWidget.h:79
 TGWidget.h:80
 TGWidget.h:81
 TGWidget.h:82
 TGWidget.h:83
 TGWidget.h:84
 TGWidget.h:85
 TGWidget.h:86
 TGWidget.h:87
 TGWidget.h:88
 TGWidget.h:89
 TGWidget.h:90
 TGWidget.h:91
 TGWidget.h:92
 TGWidget.h:93
 TGWidget.h:94
 TGWidget.h:95
 TGWidget.h:96
 TGWidget.h:97