Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GuiButton.h

Go to the documentation of this file.
00001 
00002 //
00003 // $Id: GuiButton.h,v 1.5 2005/07/21 20:26:36 bv Exp $
00004 //
00005 // GuiButton
00006 //
00007 // Package: MIDAD
00008 //
00009 // A button
00010 //
00011 // Contact: bv@bnl.gov
00012 //
00013 // Created on: Tue Nov  6 15:24:26 2001
00014 //
00016 
00017 #ifndef MIDAD_GUIBUTTON_H
00018 #define MIDAD_GUIBUTTON_H
00019 
00020 #include <Midad/Gui/GuiBase.h>
00021 #include <TGButton.h>
00022 #include <TGPicture.h>
00023 
00024 class GuiButtonBase : public GuiBase
00025 {
00026 public:
00027     GuiButtonBase() { SetName("GuiButtonBase"); }
00028     virtual ~GuiButtonBase() {}
00029 
00030     SigC::Signal0<void> pressed, released, clicked;
00031 };
00032 
00033 class GuiPicButton : public TGPictureButton, public GuiButtonBase
00034 {
00035 public:
00036     GuiPicButton(const TGWindow& p, const char* pic_name) 
00037         : TGPictureButton(&p,gClient->GetPicture(pic_name)) 
00038         { SetLayoutHints(0); }
00039     virtual ~GuiPicButton() { }
00040 
00041     // TGPictureButton doesn't return this correctly.
00042     virtual TGDimension GetDefaultSize() const         { 
00043         UInt_t w = (fPic) ? fPic->GetWidth() : fWidth;
00044         UInt_t h = (fPic) ? fPic->GetHeight() : fHeight;
00045         //cerr << "GuiPicButton: " << w << " x " << h << endl;
00046         return TGDimension(w,h);
00047     }
00048 
00049     virtual UInt_t GetDefaultWidth() const { return GetDefaultSize().fWidth;}
00050     virtual UInt_t GetDefaultHeight() const { return GetDefaultSize().fHeight;}
00051 
00052 protected:
00053 
00054     // override Rt.
00055     void Pressed() { this->TGButton::Pressed(); pressed(); }
00056     void Released() { this->TGButton::Released(); released(); }
00057     void Clicked() { this->TGButton::Clicked(); clicked(); }
00058 
00059 };                              // end of class GuiPicButton
00060 
00061 
00062 class GuiTextButton : public TGTextButton, public GuiButtonBase
00063 {
00064 public:
00065 
00066     GuiTextButton(const TGWindow& p, const char* label)
00067         : TGTextButton(&p,label) 
00068         {
00069             // SetLayoutHints(kLHintsExpandX|kLHintsExpandY);
00070             SetLayoutHints(0);
00071         }
00072     virtual ~GuiTextButton() {}
00073 
00074 protected:
00075 
00076     // override Rt.
00077     void Pressed() { this->TGButton::Pressed(); pressed(); }
00078     void Released() { this->TGButton::Released(); released(); }
00079     void Clicked() { this->TGButton::Clicked(); clicked(); }
00080 
00081 };                              // end of class GuiTextButton
00082 
00083 class GuiCheckButton: public TGCheckButton, public GuiButtonBase
00084 {
00085  public:
00086   GuiCheckButton(const TGWindow& p, const char* label)
00087       : TGCheckButton(&p,label) 
00088       {
00089         // SetLayoutHints(kLHintsExpandX|kLHintsExpandY);
00090         SetLayoutHints(0);
00091       }
00092     virtual ~GuiCheckButton() {}
00093 
00094 protected:
00095 
00096     // override Rt.
00097     void Pressed() { this->TGButton::Pressed(); pressed(); }
00098     void Released() { this->TGButton::Released(); released(); }
00099     void Clicked() { this->TGButton::Clicked(); clicked(); }
00100 };
00101 
00102 #endif  // MIDAD_GUIBUTTON_H

Generated on Mon Feb 15 11:06:47 2010 for loon by  doxygen 1.3.9.1