Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
26 ClassImp(TRootHelpDialog);
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 /// Create a help text dialog.
30 
31 TRootHelpDialog::TRootHelpDialog(const TGWindow *main,
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 
57 TRootHelpDialog::~TRootHelpDialog()
58 {
59  delete fView;
60  delete fOK;
61  delete fL1;
62  delete fL2;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Show help dialog.
67 
68 void TRootHelpDialog::Popup()
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 
94 void TRootHelpDialog::CloseWindow()
95 {
96  DeleteWindow();
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Process OK button.
101 
102 Bool_t TRootHelpDialog::ProcessMessage(Long_t msg, Long_t, Long_t)
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