//------------------------------------------------------------------------------ // gso_Button class -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "gso_Button.h" // [Author] "Piero Giubilato" // [Version] "1.1" // [Modified by] "Piero Giubilato" // [Last revision] "12 Mar 2009" // [Language] "C++" // [Compiler] "Visual C++ 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Header for the gso_Button class" // [Key documentation] // "Visual C++ Reference Help" // "Root reference guide" // {Trace} //______________________________________________________________________________ // Overloading check #if !defined gso_Button_H #define gso_Button_H // Root components #include #include //#include #include #include // Application components #include "gso_Frame.h" // Palette object class gso_Button: public gso_Frame { private: // Button root components //TGHotString* btn_Label; // The text label on the button TGHotString* btn_Label; // The text label on the button TGTextLayout* label_Layout; // The text layout static const TGFont* font_Default; // The deafult font handle FontStruct_t font_Struct; // The font description GContext_t norm_gc_Hnd; // The graphic contect used to write text into the frame Pixmap_t frame_PxMap[5]; // The different status pixmaps // Status UInt_t btn_Mode; // Standard/Toggle/Led bool btn_Down; // Button down bool btn_Inside; // Inside the button // Colors UInt_t btn_textColor; // Text color UInt_t btn_foreColor; // Fore color UInt_t btn_backColor; // Back color // Button appearance parameters Float_t btn_Radius; // Bevel radius Float_t btn_Flatness; // Elevation factor Float_t btn_Depressed; // Pressed factor UInt_t btn_Overlap; // Overlap with the ventual bevel // LED appearance parameters Float_t led_Flatness; // Elevation factor // Label properties TString label_Text; UInt_t label_Width; UInt_t label_Height; UInt_t label_WrapLength; // Drawing void Init(); // Common initialization sub void Draw(); // Creates the button pxMaps void draw_Push(UChar_t** chr_Map); // Button shaping void draw_Latch(UChar_t** chr_Map); // Latch shaping void draw_Led(UChar_t** chr_Map); // Led shaping void Layout(); // Layout the text label protected: void DoRedraw(); // Put the palette image on screen public: // Modes enum km {km_Button, km_Latch, km_Led}; enum ks {ks_Up, ks_Down}; // Default methods gso_Button(const TGWindow* window, const char* text = 0, UInt_t width = 1, UInt_t height = 1, UInt_t mode = 0, UInt_t textColor = 0, UInt_t foreColor = 0x777777, UInt_t backColor = 0, Float_t bvlRadius = 12, Float_t bvlFlatness = 0.8); ~gso_Button(); // Events void Event(Event_t* evn); // gso_Frame overloaded void MoveResize(Int_t left, Int_t top, UInt_t width, UInt_t height); void Resize(UInt_t width, UInt_t height); void Resize(TGDimension size) {Resize(size.fWidth, size.fHeight);}; void SetColor(Pixel_t color); void SetColor(Pixel_t fore, Pixel_t back); void SetBackgroundColor(Pixel_t color); // Button mode and status UInt_t Mode() const; void Mode(UInt_t mode); UInt_t Status() const; void Status(UInt_t status); // Label void SetText(const char* text); void SetText(const TString &label); void SetText(TGHotString *label); void SetFont(const char *fontName, Bool_t global); void SetFont(FontStruct_t font, Bool_t global); void SetTextColor(Pixel_t color); void SetWrapLength(Int_t wl) {label_WrapLength = wl; Layout();} Int_t GetWrapLength() const {return label_WrapLength; } // Signals (Mind that here the comment is vital!) virtual void Pressed() {Emit("Pressed()");} // *SIGNAL* virtual void Released() {Emit("Released()");} // *SIGNAL* virtual void Clicked() {Emit("Clicked()");} // *SIGNAL* // Cint preprocessor token ClassDef(gso_Button, 1) }; // End of Overloading check #endif