GTitleFrame.cxx

Go to the documentation of this file.
00001 // Author: Bertrand Bellenot   22/08/02
00002 
00003 /*************************************************************************
00004  * Copyright (C) 1995-2002, Bertrand Bellenot.                           *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see the LICENSE file.                         *
00008  *************************************************************************/
00009 
00010 #include <TSystem.h>
00011 #include <TGButton.h>
00012 #include <TGLabel.h>
00013 #include <TGPicture.h>
00014 #include <TGIcon.h>
00015 #include <TGResourcePool.h>
00016 
00017 #include "GTitleFrame.h"
00018 
00019 //______________________________________________________________________________
00020 //
00021 // GTitleFrame
00022 //______________________________________________________________________________
00023 
00024 //______________________________________________________________________________
00025 GTitleFrame::GTitleFrame(const TGWindow *p, const char *mainText, 
00026                          const char *subText, UInt_t w, UInt_t h,
00027                          UInt_t options) : TGCompositeFrame(p, w, h, options)
00028 {
00029    // Create GTitleFrame object, with TGWindow parent 'p', text 'mainText'
00030    // with sub text 'subText'.
00031 
00032    Pixel_t col;
00033    TString fontname("-*-times-bold-r-*-*-24-*-*-*-*-*-*-*");
00034    gClient->GetColorByName("red", col);
00035 
00036    // add pictures
00037    TString theLeftLogoFilename = StrDup(gProgPath);
00038    theLeftLogoFilename.Append("/icons/left.xpm");
00039    fLeftIconPicture = (TGPicture *)gClient->GetPicture(theLeftLogoFilename);
00040    fLeftIcon = new TGIcon(this, fLeftIconPicture,
00041                           fLeftIconPicture->GetWidth(),
00042                           fLeftIconPicture->GetHeight());
00043    fLeftLogoLayout = new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0);
00044    AddFrame(fLeftIcon, fLeftLogoLayout);
00045 
00046    TString theRightLogoFilename = StrDup(gProgPath);
00047    theRightLogoFilename.Append("/anim/anim01.xpm");
00048    fRightIconPicture = (TGPicture *)gClient->GetPicture(theRightLogoFilename);
00049    fRightIcon = new TGIcon(this, fRightIconPicture,
00050                            fRightIconPicture->GetWidth(),
00051                            fRightIconPicture->GetHeight());
00052    fRightLogoLayout = new TGLayoutHints(kLHintsRight, 0, 0, 0, 0);
00053    AddFrame(fRightIcon, fRightLogoLayout);
00054 
00055    // add text
00056    fTextFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 0, 0);
00057    fTextLabelLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 10, 10, 10, 10);
00058    fTextFrame = new TGCompositeFrame(this, 0, 0, kVerticalFrame);
00059    fTextLabel1 = new TGLabel(fTextFrame, mainText);
00060    fTextLabel1->SetTextFont(fontname.Data());
00061    fTextLabel1->SetTextColor(col);
00062 
00063    fTextLabel2 = new TGLabel(fTextFrame, subText);
00064    fTextLabel2->SetTextFont(fontname.Data());
00065    fTextLabel2->SetTextColor(col);
00066    fTextFrame->AddFrame(fTextLabel1, fTextLabelLayout);
00067    fTextFrame->AddFrame(fTextLabel2, fTextLabelLayout);
00068 
00069    AddFrame(fTextFrame, fTextFrameLayout);
00070 }
00071 
00072 //______________________________________________________________________________
00073 void GTitleFrame::ChangeRightLogo(Int_t frame)
00074 {
00075    // Change the right logo ( used for animation ).
00076 
00077    Char_t name[12];
00078    TString theRightLogoFilename = StrDup(gProgPath);
00079    sprintf(name,"%02d.xpm",frame);
00080    theRightLogoFilename.Append("/anim/anim");
00081    theRightLogoFilename.Append(name);
00082    gClient->FreePicture(fRightIconPicture);
00083    fRightIconPicture = (TGPicture *)gClient->GetPicture(theRightLogoFilename);
00084    fRightIcon->SetPicture(fRightIconPicture);
00085 }
00086 
00087 //______________________________________________________________________________
00088 GTitleFrame::~GTitleFrame()
00089 {
00090    // Destroy GTitleFrame object. Delete all created widgets.
00091 
00092    gClient->FreePicture(fLeftIconPicture);
00093    gClient->FreePicture(fRightIconPicture);
00094    delete fTextLabel1;
00095    delete fTextLabel2;
00096    delete fTextFrame;
00097    delete fTextLabelLayout;
00098    delete fTextFrameLayout;
00099    delete fLeftLogoLayout;
00100    delete fRightLogoLayout;
00101 }
00102 

Generated on Tue Jul 5 15:15:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1