TGWidget.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGWidget.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   05/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_TGWidget
00013 #define ROOT_TGWidget
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGWidget                                                             //
00019 //                                                                      //
00020 // The widget base class. It is light weight (all inline service        //
00021 // methods) and is typically used as mixin class (via multiple          //
00022 // inheritance), see for example TGButton.                              //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_GuiTypes
00027 #include "GuiTypes.h"
00028 #endif
00029 #ifndef ROOT_TGString
00030 #include "TGString.h"
00031 #endif
00032 #ifndef ROOT_WidgetMessageTypes
00033 #include "WidgetMessageTypes.h"
00034 #endif
00035 
00036 
00037 //--- Text justification modes
00038 
00039 enum ETextJustification {
00040    kTextLeft    = BIT(0),
00041    kTextRight   = BIT(1),
00042    kTextCenterX = BIT(2),
00043    kTextTop     = BIT(3),
00044    kTextBottom  = BIT(4),
00045    kTextCenterY = BIT(5)
00046 };
00047 
00048 
00049 //--- Widget status
00050 
00051 enum EWidgetStatus {
00052    kWidgetWantFocus = BIT(0),
00053    kWidgetHasFocus  = BIT(1),
00054    kWidgetIsEnabled = BIT(2)
00055 };
00056 
00057 
00058 class TGWindow;
00059 
00060 
00061 class TGWidget {
00062 
00063 protected:
00064    Int_t            fWidgetId;     // the widget id (used for event processing)
00065    Int_t            fWidgetFlags;  // widget status flags (OR of EWidgetStatus)
00066    const TGWindow  *fMsgWindow;    // window which handles widget events
00067    TString          fCommand;      // command to be executed
00068 
00069    TGWidget(const TGWidget& tgw):
00070      fWidgetId(tgw.fWidgetId), fWidgetFlags(tgw.fWidgetFlags), 
00071      fMsgWindow(tgw.fMsgWindow), fCommand(tgw.fCommand) { }
00072    TGWidget& operator=(const TGWidget& tgw) {
00073      if(this!=&tgw) {
00074        fWidgetId=tgw.fWidgetId; fWidgetFlags=tgw.fWidgetFlags;
00075        fMsgWindow=tgw.fMsgWindow; fCommand=tgw.fCommand; } return *this; }
00076    Int_t SetFlags(Int_t flags) { return fWidgetFlags |= flags; }
00077    Int_t ClearFlags(Int_t flags) { return fWidgetFlags &= ~flags; }
00078 
00079 public:
00080    TGWidget(): 
00081      fWidgetId(-1), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
00082    TGWidget(Int_t id):
00083      fWidgetId(id), fWidgetFlags(0), fMsgWindow(0), fCommand() { }
00084    virtual ~TGWidget() { }
00085 
00086    Int_t         WidgetId() const { return fWidgetId; }
00087    Bool_t        IsEnabled() const { return (Bool_t)((fWidgetFlags & kWidgetIsEnabled) != 0); }
00088    Bool_t        HasFocus() const { return (Bool_t)((fWidgetFlags & kWidgetHasFocus) != 0); }
00089    Bool_t        WantFocus() const { return (Bool_t)((fWidgetFlags & kWidgetWantFocus) != 0); }
00090    virtual void  Associate(const TGWindow *w) { fMsgWindow = w; }
00091    virtual void  SetCommand(const char *command) { fCommand = command; }
00092    const char   *GetCommand() const { return fCommand.Data(); }
00093 
00094    ClassDef(TGWidget,0)  // Widget base class
00095 };
00096 
00097 #endif

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