//------------------------------------------------------------------------------ // gui tools classes -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gui_Canvas.cpp" // [Author] "Piero Giubilato" // [Version] "0.7" // [Modified by] "Piero Giubilato" // [Last revision] "28 Jan 2008" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Source for the gui_Canvas class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Standard component // Root Component #include #include #include // Application component #include "global.h" #include "gui_Main.h" #include "gui_Canvas.h" // CINT Preprocessor class import definition ClassImp(gui_Canvas) //______________________________________________________________________________ gui_Canvas::gui_Canvas(UInt_t left, UInt_t top, UInt_t width, UInt_t height) { // Default constructor. gui_Canvas provides an interface layer that that // integrates a root TRootEmbeddedCanvas. // 'left', 'top', 'width', 'height' set the position and size of the button dbg_Print("gui_Canvas::gui_Canvas:(default)", DBG_LVL_ZERO); // Sets up the canvas Init(left, top, width, height); } //______________________________________________________________________________ gui_Canvas::~gui_Canvas() { // Default destructor. dbg_Print("gui_Canvas::gui_Canvas:()", DBG_LVL_ZERO); // Removes the root object from the root graphical server Container()->RemoveFrame(canvas); canvas->DestroyWindow(); // Deletes the root object delete canvas; } //______________________________________________________________________________ void gui_Canvas::Init(UInt_t left, UInt_t top, UInt_t width, UInt_t height) { // Creates a layer over a root canvas dbg_Print("gui_Canvas::Init:(default)", DBG_LVL_MAKE); // Initializes the root canvas canvas = new TRootEmbeddedCanvas(obj_id_Text().Data(), Container(), width, height); // Renders the button into the frame and adds it to the window Container()->AddFrame(canvas, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); MoveResize(left, top, width, height); } //______________________________________________________________________________ const TRootEmbeddedCanvas* gui_Canvas::Root() const { // Returns the pointer to the embedded root object return canvas; } //______________________________________________________________________________ void gui_Canvas::Update() const { // Updates the canvas and the subcanvas canvas->GetCanvas()->Draw(); canvas->GetCanvas()->Modified(); canvas->GetCanvas()->Update(); // Returns the pointer to the embedded root object gui_Object::Update(); } //______________________________________________________________________________ void gui_Canvas::MoveResize(UInt_t left, UInt_t top, UInt_t width, UInt_t height) { // Moves and resizes the button canvas->MoveResize(left, top, width, height); // Stores the new datas obj_Left = left; obj_Top = top; obj_Width = width; obj_Height = height; // Refresh the graphical container Update(); } //______________________________________________________________________________ void gui_Canvas::color_Set(UInt_t foreColor, UInt_t backColor) { // Sets the color for the canvas. As the root canvas uses the root palette // to reference colors, it will create the color if not already available. canvas->GetCanvas()->SetFillColor(TColor::GetColor(backColor)); canvas->GetCanvas()->SetLineColor(TColor::GetColor(foreColor)); // Sets the color obj_foreColor = foreColor; obj_backColor = backColor; // Refresh the graphical container Update(); }