Logo ROOT  
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 /** \class TRootHelpDialog
14  \ingroup guiwidgets
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 
22 #include "TRootHelpDialog.h"
23 #include "TGButton.h"
24 #include "TGTextView.h"
25 
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Create a help text dialog.
31 
33  const char *title, UInt_t w, UInt_t h) :
34  TGTransientFrame(gClient->GetRoot(), main, w, h)
35 {
36  fView = new TGTextView(this, w, h, kSunkenFrame | kDoubleBorder);
37  fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
38  AddFrame(fView, fL1);
39 
40  fOK = new TGTextButton(this, " &OK ");
41  fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
42  AddFrame(fOK, fL2);
43 
44  SetWindowName(title);
45  SetIconName(title);
46 
47  MapSubwindows();
48 
50 
51  // position relative to the parent's window
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Delete help text dialog.
57 
59 {
60  delete fView;
61  delete fOK;
62  delete fL1;
63  delete fL2;
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// Show help dialog.
68 
70 {
71  MapWindow();
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Set help text from helpText buffer in TGTextView.
76 
77 void TRootHelpDialog::SetText(const char *helpText)
78 {
79  fView->LoadBuffer(helpText);
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Add help text from helpText buffer to already existing text in TGTextView.
84 
85 void TRootHelpDialog::AddText(const char *helpText)
86 {
87  TGText tt;
88  tt.LoadBuffer(helpText);
89  fView->AddText(&tt);
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// Called when closed via window manager action.
94 
96 {
97  DeleteWindow();
98 }
99 
100 ////////////////////////////////////////////////////////////////////////////////
101 /// Process OK button.
102 
104 {
105  switch (GET_MSG(msg)) {
106  case kC_COMMAND:
107  switch (GET_SUBMSG(msg)) {
108  case kCM_BUTTON:
109  // Only one button and one action...
110  DeleteWindow();
111  break;
112  default:
113  break;
114  }
115  default:
116  break;
117  }
118 
119  return kTRUE;
120 }
121 
TGCompositeFrame::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:316
TRootHelpDialog::Popup
void Popup()
Show help dialog.
Definition: TRootHelpDialog.cxx:69
TGTransientFrame
Defines transient windows that typically are used for dialogs windows.
Definition: TGFrame.h:498
GET_MSG
Int_t GET_MSG(Long_t val)
Definition: WidgetMessageTypes.h:110
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kLHintsCenterX
@ kLHintsCenterX
Definition: TGLayout.h:25
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
tt
auto * tt
Definition: textangle.C:16
TGMainFrame::SetIconName
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition: TGFrame.cxx:1777
TRootHelpDialog::ProcessMessage
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process OK button.
Definition: TRootHelpDialog.cxx:103
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TRootHelpDialog::TRootHelpDialog
TRootHelpDialog(const TRootHelpDialog &)=delete
TGTextButton
Yield an action as soon as it is clicked.
Definition: TGButton.h:142
TGText
A TGText is a multi line text buffer.
Definition: TGText.h:57
TGMainFrame::SetWindowName
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1764
TRootHelpDialog::SetText
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
Definition: TRootHelpDialog.cxx:77
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
TRootHelpDialog::fOK
TGTextButton * fOK
OK button.
Definition: TRootHelpDialog.h:26
TGFrame::MapWindow
virtual void MapWindow()
map window
Definition: TGFrame.h:204
bool
gClient
#define gClient
Definition: TGClient.h:157
kLHintsBottom
@ kLHintsBottom
Definition: TGLayout.h:29
TGFrame::DeleteWindow
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:276
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
h
#define h(i)
Definition: RSha256.hxx:106
TGCompositeFrame::MapSubwindows
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1164
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
TRootHelpDialog::~TRootHelpDialog
virtual ~TRootHelpDialog()
Delete help text dialog.
Definition: TRootHelpDialog.cxx:58
kCM_BUTTON
@ kCM_BUTTON
Definition: WidgetMessageTypes.h:34
Long_t
long Long_t
Definition: RtypesCore.h:54
TGTextView::LoadBuffer
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
Definition: TGTextView.cxx:471
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
TRootHelpDialog.h
TRootHelpDialog::CloseWindow
void CloseWindow()
Called when closed via window manager action.
Definition: TRootHelpDialog.cxx:95
kLHintsExpandY
@ kLHintsExpandY
Definition: TGLayout.h:31
unsigned int
TGTextView.h
TGTransientFrame::CenterOnParent
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition: TGFrame.cxx:1931
kC_COMMAND
@ kC_COMMAND
Definition: WidgetMessageTypes.h:31
TGTextView
A TGTextView is a text viewer widget.
Definition: TGTextView.h:22
TGButton.h
GET_SUBMSG
Int_t GET_SUBMSG(Long_t val)
Definition: WidgetMessageTypes.h:111
TRootHelpDialog::AddText
void AddText(const char *helpText)
Add help text from helpText buffer to already existing text in TGTextView.
Definition: TRootHelpDialog.cxx:85
TRootHelpDialog::fView
TGTextView * fView
text view
Definition: TRootHelpDialog.h:25
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:30
TRootHelpDialog::fL1
TGLayoutHints * fL1
layout of TGTextView
Definition: TRootHelpDialog.h:27
TRootHelpDialog::fL2
TGLayoutHints * fL2
layout of OK button
Definition: TRootHelpDialog.h:28
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1117
TRootHelpDialog
A TRootHelpDialog is used to display help text (or any text in a dialog window).
Definition: TRootHelpDialog.h:22
main
int main(int argc, char *argv[])
Definition: cef_main.cxx:54
TGTextView::AddText
virtual void AddText(TGText *text)
Add text to the view widget.
Definition: TGTextView.cxx:208