TRootHelpDialog.cxx

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TRootHelpDialog.cxx 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   24/02/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TRootHelpDialog                                                      //
00015 //                                                                      //
00016 // A TRootHelpDialog is used to display help text (or any text in a     //
00017 // dialog window). There is on OK button to popdown the dialog.         //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 
00021 #include "TRootHelpDialog.h"
00022 #include "TGButton.h"
00023 #include "TGTextView.h"
00024 
00025 
00026 ClassImp(TRootHelpDialog)
00027 
00028 //______________________________________________________________________________
00029 TRootHelpDialog::TRootHelpDialog(const TGWindow *main,
00030     const char *title, UInt_t w, UInt_t h) :
00031     TGTransientFrame(gClient->GetRoot(), main, w, h)
00032 {
00033    // Create a help text dialog.
00034 
00035    fView = new TGTextView(this, w, h, kSunkenFrame | kDoubleBorder);
00036    fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
00037    AddFrame(fView, fL1);
00038 
00039    fOK = new TGTextButton(this, "  &OK  ");
00040    fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
00041    AddFrame(fOK, fL2);
00042 
00043    SetWindowName(title);
00044    SetIconName(title);
00045 
00046    MapSubwindows();
00047 
00048    Resize(GetDefaultSize());
00049 
00050    // position relative to the parent's window
00051    CenterOnParent();
00052 }
00053 
00054 //______________________________________________________________________________
00055 TRootHelpDialog::~TRootHelpDialog()
00056 {
00057    // Delete help text dialog.
00058 
00059    delete fView;
00060    delete fOK;
00061    delete fL1;
00062    delete fL2;
00063 }
00064 
00065 //______________________________________________________________________________
00066 void TRootHelpDialog::Popup()
00067 {
00068    // Show help dialog.
00069 
00070    MapWindow();
00071 }
00072 
00073 //______________________________________________________________________________
00074 void TRootHelpDialog::SetText(const char *helpText)
00075 {
00076    // Set help text from helpText buffer in TGTextView.
00077 
00078    fView->LoadBuffer(helpText);
00079 }
00080 
00081 //______________________________________________________________________________
00082 void TRootHelpDialog::AddText(const char *helpText)
00083 {
00084    // Add help text from helpText buffer to already existing text in TGTextView.
00085 
00086    TGText tt;
00087    tt.LoadBuffer(helpText);
00088    fView->AddText(&tt);
00089 }
00090 
00091 //______________________________________________________________________________
00092 void TRootHelpDialog::CloseWindow()
00093 {
00094    // Called when closed via window manager action.
00095 
00096    DeleteWindow();
00097 }
00098 
00099 //______________________________________________________________________________
00100 Bool_t TRootHelpDialog::ProcessMessage(Long_t msg, Long_t, Long_t)
00101 {
00102    // Process OK button.
00103 
00104    switch (GET_MSG(msg)) {
00105       case kC_COMMAND:
00106          switch (GET_SUBMSG(msg)) {
00107             case kCM_BUTTON:
00108                // Only one button and one action...
00109                DeleteWindow();
00110                break;
00111             default:
00112                break;
00113          }
00114       default:
00115          break;
00116    }
00117 
00118    return kTRUE;
00119 }
00120 

Generated on Tue Jul 5 14:22:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1