Logo ROOT   6.08/07
Reference Guide
TRootHelpDialog.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 24/02/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TRootHelpDialog //
15 // //
16 // A TRootHelpDialog is used to display help text (or any text in a //
17 // dialog window). There is on OK button to popdown the dialog. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "TRootHelpDialog.h"
22 #include "TGButton.h"
23 #include "TGTextView.h"
24 
25 
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Create a help text dialog.
30 
32  const char *title, UInt_t w, UInt_t h) :
33  TGTransientFrame(gClient->GetRoot(), main, w, h)
34 {
35  fView = new TGTextView(this, w, h, kSunkenFrame | kDoubleBorder);
36  fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
37  AddFrame(fView, fL1);
38 
39  fOK = new TGTextButton(this, " &OK ");
40  fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
41  AddFrame(fOK, fL2);
42 
43  SetWindowName(title);
44  SetIconName(title);
45 
46  MapSubwindows();
47 
48  Resize(GetDefaultSize());
49 
50  // position relative to the parent's window
51  CenterOnParent();
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Delete help text dialog.
56 
58 {
59  delete fView;
60  delete fOK;
61  delete fL1;
62  delete fL2;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Show help dialog.
67 
69 {
70  MapWindow();
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Set help text from helpText buffer in TGTextView.
75 
76 void TRootHelpDialog::SetText(const char *helpText)
77 {
78  fView->LoadBuffer(helpText);
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Add help text from helpText buffer to already existing text in TGTextView.
83 
84 void TRootHelpDialog::AddText(const char *helpText)
85 {
86  TGText tt;
87  tt.LoadBuffer(helpText);
88  fView->AddText(&tt);
89 }
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// Called when closed via window manager action.
93 
95 {
96  DeleteWindow();
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Process OK button.
101 
103 {
104  switch (GET_MSG(msg)) {
105  case kC_COMMAND:
106  switch (GET_SUBMSG(msg)) {
107  case kCM_BUTTON:
108  // Only one button and one action...
109  DeleteWindow();
110  break;
111  default:
112  break;
113  }
114  default:
115  break;
116  }
117 
118  return kTRUE;
119 }
120 
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
Definition: TGTextView.cxx:469
Definition: TGText.h:71
TH1 * h
Definition: legend2.C:5
#define gClient
Definition: TGClient.h:174
bool Bool_t
Definition: RtypesCore.h:59
TGTextButton * fOK
TGTextView * fView
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Definition: TGText.cxx:512
virtual ~TRootHelpDialog()
Delete help text dialog.
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
TText * tt
Definition: textangle.C:16
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process OK button.
void Popup()
Show help dialog.
Int_t GET_SUBMSG(Long_t val)
unsigned int UInt_t
Definition: RtypesCore.h:42
void AddText(const char *helpText)
Add help text from helpText buffer to already existing text in TGTextView.
virtual void AddText(TGText *text)
Add text to the view widget.
Definition: TGTextView.cxx:206
TGLayoutHints * fL2
Int_t GET_MSG(Long_t val)
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void MapWindow()
Definition: TGFrame.h:267
TGLayoutHints * fL1
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
int main(int argc, char **argv)
void CloseWindow()
Called when closed via window manager action.