#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 //--- 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) }; //--- Widget messages and submessages // (sub messages must be in the range 1-255) // (these should be on a separate include file) enum EWidgetMessageTypes { kC_COMMAND = 1, kCM_MENU = 1, kCM_MENUSELECT = 2, kCM_BUTTON = 3, kCM_CHECKBUTTON = 4, kCM_RADIOBUTTON = 5, kCM_LISTBOX = 6, kCM_COMBOBOX = 7, kCM_TAB = 8, kC_HSCROLL = 2, kC_VSCROLL = 3, kSB_LINEUP = 1, kSB_LINEDOWN = 2, kSB_PAGEUP = 3, kSB_PAGEDOWN = 4, kSB_SLIDERTRACK = 5, kSB_SLIDERPOS = 6, kC_TEXTENTRY = 4, kTE_TEXTCHANGED = 1, kTE_ENTER = 2, kC_CONTAINER = 5, kCT_ITEMCLICK = 1, kCT_ITEMDBLCLICK = 2, kCT_SELCHANGED = 3, kC_HSLIDER = 6, kC_VSLIDER = 7, kSL_POS = 1, kSL_TRACK = 2, kC_LISTTREE = 8, kC_MSGMAX = 8 }; // Message cracking routines inline Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg) { return (msg << 8) + submsg; } inline Int_t GET_MSG(Long_t val) { return Int_t((val >> 8) & 255); } inline Int_t GET_SUBMSG(Long_t val) { return Int_t(val & 255); } 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