Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TTreeInput.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: David Gonzalez Maline 21/10/2008
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 TTreeInput
14 \ingroup fitpanel
15
16Tree Input Dialog Widget
17
18An dialog box that asks the user for the variables and cuts
19of the selected tree in the fitpanel.
20
21*/
22
23
24#include "TTreeInput.h"
25#include "TGButton.h"
26#include "TGLabel.h"
27#include "TGTextEntry.h"
28#include "strlcpy.h"
29
33
34
35////////////////////////////////////////////////////////////////////////////////
36/// Create simple input dialog.
37
39 char *strvars, char *strcuts):
41 fStrvars(strvars),
42 fStrcuts(strcuts)
43{
44 if (!p && !main) {
45 MakeZombie();
46 return;
47 }
49
50 TGLabel *label = new TGLabel(this, "Selected Variables: ");
51 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
52
53 TGTextBuffer *tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
54 fTEVars = new TGTextEntry(this, tbuf, kTI_TEVARS);
57
58 label = new TGLabel(this, "Selected Cuts: ");
59 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
60
61 tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
62 fTECuts = new TGTextEntry(this, tbuf, kTI_TECUTS);
65
66 // create frame and layout hints for Ok and Cancel buttons
68 hf->SetCleanup(kDeepCleanup);
69
70 // create OK and Cancel buttons in their own frame (hf)
71 UInt_t width = 0, height = 0;
72
73 fOk = new TGTextButton(hf, "&Ok", 1);
74 fOk->Associate(this);
75 hf->AddFrame(fOk, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 5, 0, 0));
76 width = std::max(width, fOk->GetDefaultWidth());
77
78 fCancel = new TGTextButton(hf, "&Cancel", 2);
79 fCancel->Associate(this);
80 hf->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 5, 0, 0));
82 width = std::max(width, fCancel->GetDefaultWidth());
83
84 // place button frame (hf) at the bottom
86
87 // keep buttons centered and with the same width
88 hf->Resize((width + 20) * 2, height);
89
90 // set dialog title
91 SetWindowName("Get Input");
92
93 // map all widgets and calculate size of dialog
95
98
100
101 // position relative to the parent's window
103
104 // make the message box non-resizable
107
113
114 // popup dialog and wait till user replies
115 MapWindow();
116 fTEVars->SetFocus();
117
118 gClient->WaitFor(this);
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Cleanup dialog.
123
128
129////////////////////////////////////////////////////////////////////////////////
130/// Handle button and text enter events
131
133{
134 switch (GET_MSG(msg)) {
135 case kC_COMMAND:
136 switch (GET_SUBMSG(msg)) {
137 case kCM_BUTTON:
138 switch (parm1) {
139 case 1:
140 // here copy the string from text buffer to return variable
141 // see TFitEditor.cxx for the maximum length:
142 // char variables[256] = {0}; char cuts[256] = {0};
145 delete this;
146 break;
147 case 2:
148 fStrvars[0] = 0;
149 fStrcuts[0] = 0;
150 delete this;
151 break;
152 }
153 default:
154 break;
155 }
156 break;
157
158 case kC_TEXTENTRY:
159 switch (GET_SUBMSG(msg)) {
160 case kTE_ENTER:
161 // here copy the string from text buffer to return variable
162 // see TFitEditor.cxx for the maximum length:
163 // char variables[256] = {0}; char cuts[256] = {0};
166 delete this;
167 break;
168 case kTE_TAB:
169 if ( parm1 == kTI_TEVARS )
170 fTECuts->SetFocus();
171 else if ( parm1 == kTI_TECUTS )
172 fTEVars->SetFocus();
173 break;
174 default:
175 break;
176 }
177 break;
178
179 default:
180 break;
181 }
182 return kTRUE;
183}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
int main()
Definition Prototype.cxx:12
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gClient
Definition TGClient.h:157
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
ETreeInput
@ kTI_TECUTS
@ kTI_TEVARS
Int_t GET_MSG(Long_t val)
@ kTE_ENTER
@ kC_COMMAND
@ kCM_BUTTON
@ kTE_TAB
@ kC_TEXTENTRY
Int_t GET_SUBMSG(Long_t val)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:314
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:316
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1064
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
void MapWindow() override
map window
Definition TGFrame.h:206
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1885
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1780
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
const char * GetString() const
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetFocus()
Set focus to this text entry.
TGTextBuffer * GetBuffer() const
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:500
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1949
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
void MakeZombie()
Definition TObject.h:53
TGTextButton * fOk
ok button
Definition TTreeInput.h:27
char * fStrcuts
address to store cuts string
Definition TTreeInput.h:30
char * fStrvars
address to store variables string
Definition TTreeInput.h:29
TTreeInput(const TTreeInput &)
TGTextEntry * fTECuts
text entry widget for cuts
Definition TTreeInput.h:26
~TTreeInput() override
Cleanup dialog.
TGTextEntry * fTEVars
text entry widget for variables
Definition TTreeInput.h:25
TGTextButton * fCancel
cancel button
Definition TTreeInput.h:28
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t) override
Handle button and text enter events.