#ifndef ROOT_TGWidget
#define ROOT_TGWidget

//+SEQ,CopyRight,T=NOINCLUDE.

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// 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
//*KEEP,GuiTypes.
#include "GuiTypes.h"
//*KEND.
#endif
#ifndef ROOT_TGString
//*KEEP,TGString.
#include "TGString.h"
//*KEND.
#endif
#ifndef ROOT_WidgetMessageTypes
//*KEEP,WidgetMessageTypes,T=C++.
#include "WidgetMessageTypes.h"
//*KEND.
#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

   Int_t SetFlags(Int_t flags) { return fWidgetFlags |= flags; }
   Int_t ClearFlags(Int_t flags) { return fWidgetFlags &= ~flags; }

public:
   TGWidget() { }
   TGWidget(Int_t id) { fWidgetId = id; }
   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); }
   void        Associate(const TGWindow *w) { fMsgWindow = w; }
   void        SetCommand(const char *command) { fCommand = command; }
   const char *GetCommand() const { return fCommand.Data(); }

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

#endif