//------------------------------------------------------------------------------ // gui object class -- // (C) Piero Giubilato 2008, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gui_Object.h" // [Author] "Piero Giubilato, Devis Contarato" // [Version] "1.0" // [Modified by] "Piero Giubilato" // [Last revision] "22 Jan 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Header for the gui_Object class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Overloading check #if !defined gui_Object_H #define gui_Object_H // Standard components #include // Root components #include #include #include #include #include #include // Application components #include "data_Object.h" #include "task_Object.h" #include "task_Clbk.h" // This class provideas a virtual interface for gui objects. class gui_Object: public TGObject { // Cint preprocessor token ClassDef(gui_Object, 2) private: // External references TGMainFrame* frame_Main; // The gui_Object container TGCompositeFrame* frame_Draw; // The gui_Object container TGMenuBar* mnu_Bar; // The application main menu bar // Reference for the callback system // Note: by providing an array of these functors and appropriate // indexing, multiple events handling can be easily implemented. task_Clbk* Clbk; // The callback functor // Unique identifier and common vars UInt_t gui_obj_Id; // The object ID TString gui_obj_id_Text; // The object ID as a string static std::vector gui_obj_Is; // The object's existence list static std::vector gui_obj_Ref; // The object's pointer static bool redraw_all_On; // Global redraw ongoing static bool update_auto_On; // Auto update on/off protected: // Object container TGCompositeFrame* container(TGCompositeFrame* container); // Object size and position UInt_t obj_Left; // Left position UInt_t obj_Top; // Top position UInt_t obj_Width; // Width UInt_t obj_Height; // Height // Colors bool obj_Transparent; // Transparent mode UInt_t obj_foreColor; // Foreground color UInt_t obj_backColor; // Background color // Text TString obj_Text; // Text (Caption, title, ...) TString obj_fontName; // Font name bool obj_fontBold; // Font bold style int obj_fontSize; // Font size style // External label TGLabel* gui_obj_Label; // The gui_Object label // GSO bool obj_Render; // True for render objects public: // Special member functions gui_Object(); virtual ~gui_Object(); // GUI reference functions TGMainFrame* Window() const; TGCompositeFrame* Container() const; TGMenuBar* container_Menu() const; UInt_t container_Color() const; // Self references UInt_t obj_Id() const; const TString obj_id_Text() const; // CallBack system (defined as inline to avoid template inclusion of .cpp) // It is overloaded accordingly to the target function type (static, member) void task_Connect(void (*fnc_Pt)(const int)) { if (Clbk) delete Clbk; Clbk = new task_clbk_ST(fnc_Pt); } template void task_Connect(T* obj_Pt, void (T::*fnc_Pt)(const int)) { if (Clbk) delete Clbk; Clbk = new task_clbk_MB(obj_Pt, fnc_Pt); } // Executes callback (virtualization allows for just one call) void task_Call(const int arg) {if (Clbk) Clbk->call(arg);} // ROOT object interface functions virtual const void Root(UInt_t dummy) const {} // General interface functions static void redraw_All(); static void delete_All(); virtual void ReDraw(); virtual void Update(bool force = false) const; virtual void update_Auto(bool state); // Size/Position interface functions virtual void MoveResize(UInt_t left, UInt_t top, UInt_t width, UInt_t height) {} // Pure virtual virtual void Resize(UInt_t width, UInt_t height); virtual void Move(UInt_t left, UInt_t top); virtual UInt_t Left() const; virtual UInt_t Top() const; virtual UInt_t Width() const; virtual UInt_t Height() const; // Color interface functions virtual void color_Set(UInt_t foreColor, UInt_t backColor) {} // Pure virtual virtual void foreColor(UInt_t color); virtual UInt_t foreColor() const; virtual void backColor(UInt_t color); virtual UInt_t backColor() const; virtual bool Transparent() const; virtual void Transparent(bool transp) {}; virtual bool Render() const; // Text interface functions virtual const TString Text() const; virtual void Text(const char* text) {} virtual bool fontBold() const; virtual void fontBold(bool bold) {} virtual UInt_t fontSize() const; virtual void fontSize(UInt_t size) {} virtual const char* fontName() const; virtual void fontName(const char* name) {} // Label interface function virtual void label_Set(const char* labelText, UInt_t align, UInt_t foreColor = 0xFFFFFF, UInt_t backColor = 0x000000); }; // End of Overloading check #endif