//------------------------------------------------------------------------------ // gso_Panel class -- // (C) Piero Giubilato 2008-1010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gso_Panel.cpp" // [Author] "Piero Giubilato" // [Version] "1.0" // [Modified by] "Piero Giubilato" // [Last revision] "13 Mar 2009" // [Language] "C++" // [Compiler] "Visual C++ 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Source for the gso_Panel class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Standard component #include // Application component #include "global.h" #include "gso_Shaper.h" #include "gso_Panel.h" // CINT Preprocessor class import definition ClassImp(gso_Panel) //______________________________________________________________________________ gso_Panel::gso_Panel(const TGWindow* window, UInt_t width, UInt_t height, UInt_t bvl_Size, Float_t bvl_Thick, UInt_t foreColor, UInt_t backColor): gso_Frame(window, width, height, bvl_Size, bvl_Thick, gso_Frame::ks_Notch, foreColor, backColor) { // Default constructor dbg_Print("gso_Panel::gso_Panel:(default)", DBG_LVL_ZERO); // Appearance pnl_Color = foreColor; bck_Color = backColor; brd_Size = bvl_Size; brd_Thick = bvl_Thick; // Clears the pixmap reference frame_PxMap = 0; Draw(); } //______________________________________________________________________________ gso_Panel::~gso_Panel() { // Default destructor dbg_Print("gso_Panel::~gso_Panel:()", DBG_LVL_ZERO); // Removes the old PixMap if any if (frame_PxMap) gVirtualX->DeletePixmap(frame_PxMap); } //______________________________________________________________________________ void gso_Panel::Draw() { // Draws the 3D panel dbg_Print("gso_Panel::Draw:()", DBG_LVL_FLOW); // SpeedUp pivots UInt_t width = ClrWidth(); UInt_t height = ClrHeight(); // Removes the old PixMap in case if (frame_PxMap) gVirtualX->DeletePixmap(frame_PxMap); // Creates the PixMap reference where to store the palette image. UChar_t* chr_Map = new UChar_t[width * height * 4]; // Necessary pivot maps Float_t* surf_Map[1]; for (int i = 0; i < 1; i++) surf_Map[i] = new Float_t[(width + 1) * (height + 1)]; UChar_t* surf_Mask[1]; for (int i = 0; i < 1; i++) surf_Mask[i] = new UChar_t[width * height]; UChar_t* col_Map[1]; for (int i = 0; i < 1; i++) col_Map[i] = new UChar_t[width * height * 4]; // Creates the button Up/Down maps + mask gso_Shaper::shape_Button(surf_Map[0], surf_Mask[0], width, height, (Float_t)brd_Size, brd_Thick, false); // Derives the border mask as inverse of the surf mask gso_Shaper::mask_Invert(surf_Mask[1], surf_Mask[0], width, height); // Sets the material for the button gso_Material mat(gso_Renderer::k_Material); mat.k_Color = pnl_Color; // Renders the surface UP/Off map gso_Renderer::l_Strenght(gso_Renderer::kl_Default); gso_Shaper::shape_Render(col_Map[0], surf_Map[0], surf_Mask[0], width, height, &mat, bck_Color); // Create a flat equal to the desktop UInt_t px_Color = 0; gso_Shaper::map_Pixel(&px_Color, bck_Color); gso_Shaper::map_Flat(col_Map[1], width, height, px_Color); // Generate the final maps! gso_Shaper::map_Sum(chr_Map, col_Map[0], surf_Mask[0], col_Map[1], surf_Mask[1], width, height, 1); // Kills the pivot maps for (UInt_t i = 0; i < 1; i++) delete surf_Map[i]; for (UInt_t i = 0; i < 1; i++) delete surf_Mask[i]; for (UInt_t i = 0; i < 1; i++) delete col_Map[i]; // Converts the filled char pixmap into a PxMap frame_PxMap = gVirtualX->CreatePixmapFromData((UChar_t*)chr_Map, width, height); delete chr_Map; // Show the panel DoRedraw(); } //______________________________________________________________________________ void gso_Panel::SetColor(Pixel_t fore, Pixel_t back) { // Sets the panel colors dbg_Print("gso_Panel::colors_Set:(UInt, UInt)", DBG_LVL_FLOW); // Shows the new palette Draw(); } //______________________________________________________________________________ void gso_Panel::MoveResize(Int_t left, Int_t top, UInt_t width, UInt_t height) { // Overloaded move and resize function. dbg_Print("gso_Panel::MoveResize:(default)", DBG_LVL_FLOW); // Moves and resizes the palette frame. Tthis will call a DoRedraw in case of need gso_Frame::MoveResize(left, top, width, height); // Resize the palette pxMap Draw(); } //______________________________________________________________________________ void gso_Panel::Resize(UInt_t width, UInt_t height) { // Overloaded move and resize function. dbg_Print("gso_Panel::MoveResize:(default)", DBG_LVL_FLOW); // Moves and resizes the palette frame. Tthis will call a DoRedraw in case of need gso_Frame::Resize(width, height); // Resize the palette pxMap Draw(); } //______________________________________________________________________________ void gso_Panel::DoRedraw() { // Draws the current palette to the palette frame. This function // overloads the TGFrame original one. dbg_Print("gso_Panel::DoRedraw:()", DBG_LVL_FLOW); // Redraws the parent frame gso_Frame::DoRedraw(); // Redraws the palette map if any available if (frame_PxMap) gVirtualX->CopyArea(frame_PxMap, GetId(), GetGC(), 0, 0, ClrWidth(), ClrHeight(), ClrLeft(), ClrTop()); }