//------------------------------------------------------------------------------ // gui_Led class -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gui_Led.cpp" // [Author] "Piero Giubilato" // [Version] "1.0" // [Modified by] "Piero Giubilato" // [Last revision] "09 Feb 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Source for the gui_Led class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Standard component // Root Component #include "TSystem.h" // Application component #include "global.h" #include "gui_Led.h" // CINT Preprocessor class import definition ClassImp(gui_Led) //______________________________________________________________________________ gui_Led::gui_Led(UInt_t left, UInt_t top, UInt_t width, UInt_t height, UInt_t foreColor, UInt_t backColor) { // 'label' is the text appearing into the button // 'left', 'top', 'width', 'height' set the position and size of the button // 'behaviour' sets the button behaviour ('km_Button', 'km_Latch'), see // btn_Mode for further info. // Debug dbg_Print("gui_Led::gui_Led:(color)", DBG_LVL_ZERO); // Sets up the button Init("", left, top, width, height, foreColor, backColor); } //______________________________________________________________________________ gui_Led::~gui_Led() { // Default destructor. dbg_Print("gui_Led::~gui_Led:()", DBG_LVL_ZERO); // Removes the root object from the root graphical server Container()->RemoveFrame(button); button->DestroyWindow(); // Deletes the root object delete button; } //______________________________________________________________________________ void gui_Led::Init(const char* label, UInt_t left, UInt_t top, UInt_t width, UInt_t height, UInt_t foreColor, UInt_t backColor) { // Creates a layer over a root button dbg_Print("gui_Led::Init:(default)", DBG_LVL_MAKE); // Initializes the root button button = new gso_Button(Container(), "", width, height, gso_Button::km_Led, foreColor, backColor, container_Color()); // Connects it to the button handler function button->Connect(button, "Clicked()", "gui_Led", this, "btn_Do()"); // Renders the button into the frame and adds it to the window Container()->AddFrame(button, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); button->SetWrapLength(-1); MoveResize(left, top, width, height); // This also update the object // Set the object redrawing properties obj_Transparent = true; obj_Render = true; } //______________________________________________________________________________ bool gui_Led::Status() { // Returns the current status of the Led. return button->Status(); } //______________________________________________________________________________ bool gui_Led::Status(UInt_t value) { // Creates a layer over a root button dbg_Print("gui_Led::Status:(UInt)", DBG_LVL_FLOW); // Sets the current status of the button. button->Status(value); // Returns current value return button_Status; } //______________________________________________________________________________ void gui_Led::btn_Do() { // This function is called whenever the button is pressed, as it has been // linked to the associated root TGTextButton when it was instantiated. dbg_Print("gui_Led::btn_Do: button pressed!", DBG_LVL_FLOW) // Calls the associated handler, if anyone, passing the ID as argument gui_Object::task_Call(gui_Object::obj_Id()); } //______________________________________________________________________________ const gso_Button* gui_Led::Root() const { // Returns the pointer to the embedded root object return button; } //______________________________________________________________________________ void gui_Led::ReDraw() { // Redraw the object to keep it in pair with the general GUI parameters dbg_Print("gui_Led::ReDraw:()", DBG_LVL_FLOW); // What we need here is to change the desk background color, this will in // turn trigger the re-rendering of the whole button button->SetBackgroundColor(container_Color()); } //______________________________________________________________________________ void gui_Led::MoveResize(UInt_t left, UInt_t top, UInt_t width, UInt_t height) { // Copied root method dbg_Print("gui_Led::MoveResize:(default)", DBG_LVL_FLOW); // Moves and resizes the button button->MoveResize(left, top, width, height); // Stores the new datas obj_Left = left; obj_Top = top; obj_Width = width; obj_Height = height; // Paint Update(); } //______________________________________________________________________________ void gui_Led::color_Set(UInt_t foreColor, UInt_t backColor) { // Updates button colors dbg_Print("gui_Led::color_Set:(default)", DBG_LVL_FLOW); // button->SetTextColor(foreColor); button->SetColor(backColor, container_Color()); // Stores the new datas obj_foreColor = foreColor; obj_backColor = backColor; // Refresh the graphical container Update(); }