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
32};
33
35
36////////////////////////////////////////////////////////////////////////////////
37/// Create simple input dialog.
38
40 char *strvars, char *strcuts):
42 fStrvars(strvars),
43 fStrcuts(strcuts)
44{
45 if (!p && !main) {
46 MakeZombie();
47 return;
48 }
50
51 TGLabel *label = new TGLabel(this, "Selected Variables: ");
52 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
53
54 TGTextBuffer *tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
55 fTEVars = new TGTextEntry(this, tbuf, kTI_TEVARS);
58
59 label = new TGLabel(this, "Selected Cuts: ");
60 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
61
62 tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
63 fTECuts = new TGTextEntry(this, tbuf, kTI_TECUTS);
66
67 // create frame and layout hints for Ok and Cancel buttons
68 TGHorizontalFrame *hf = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
70
71 // create OK and Cancel buttons in their own frame (hf)
72 UInt_t width = 0, height = 0;
73
74 fOk = new TGTextButton(hf, "&Ok", 1);
75 fOk->Associate(this);
78
79 fCancel = new TGTextButton(hf, "&Cancel", 2);
80 fCancel->Associate(this);
82 height = fCancel->GetDefaultHeight();
84
85 // place button frame (hf) at the bottom
86 AddFrame(hf, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5));
87
88 // keep buttons centered and with the same width
89 hf->Resize((width + 20) * 2, height);
90
91 // set dialog title
92 SetWindowName("Get Input");
93
94 // map all widgets and calculate size of dialog
96
98 height = GetDefaultHeight();
99
100 Resize(width, height);
101
102 // position relative to the parent's window
104
105 // make the message box non-resizable
106 SetWMSize(width, height);
107 SetWMSizeHints(width, height, width, height, 0, 0);
108
114
115 // popup dialog and wait till user replies
116 MapWindow();
117 fTEVars->SetFocus();
118
119 gClient->WaitFor(this);
120}
121
122////////////////////////////////////////////////////////////////////////////////
123/// Cleanup dialog.
124
126{
127 Cleanup();
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Handle button and text enter events
132
134{
135 switch (GET_MSG(msg)) {
136 case kC_COMMAND:
137 switch (GET_SUBMSG(msg)) {
138 case kCM_BUTTON:
139 switch (parm1) {
140 case 1:
141 // here copy the string from text buffer to return variable
142 // see TFitEditor.cxx for the maximum length:
143 // char variables[256] = {0}; char cuts[256] = {0};
144 strlcpy(fStrvars, fTEVars->GetBuffer()->GetString(), 256);
145 strlcpy(fStrcuts, fTECuts->GetBuffer()->GetString(), 256);
146 delete this;
147 break;
148 case 2:
149 fStrvars[0] = 0;
150 fStrcuts[0] = 0;
151 delete this;
152 break;
153 }
154 default:
155 break;
156 }
157 break;
158
159 case kC_TEXTENTRY:
160 switch (GET_SUBMSG(msg)) {
161 case kTE_ENTER:
162 // here copy the string from text buffer to return variable
163 // see TFitEditor.cxx for the maximum length:
164 // char variables[256] = {0}; char cuts[256] = {0};
165 strlcpy(fStrvars, fTEVars->GetBuffer()->GetString(), 256);
166 strlcpy(fStrcuts, fTECuts->GetBuffer()->GetString(), 256);
167 delete this;
168 break;
169 case kTE_TAB:
170 if ( parm1 == kTI_TEVARS )
171 fTECuts->SetFocus();
172 else if ( parm1 == kTI_TECUTS )
173 fTEVars->SetFocus();
174 break;
175 default:
176 break;
177 }
178 break;
179
180 default:
181 break;
182 }
183 return kTRUE;
184}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
int main()
Definition Prototype.cxx:12
long Longptr_t
Definition RtypesCore.h:82
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
#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
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=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:314
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
virtual void MapWindow()
map window
Definition TGFrame.h:204
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:386
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:1891
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition TGFrame.cxx:1866
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition TGFrame.cxx:1904
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1788
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:499
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1955
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
Tree Input Dialog Widget.
Definition TTreeInput.h:22
virtual Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t)
Handle button and text enter events.
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()
Cleanup dialog.
TTreeInput(const TTreeInput &)
TGTextEntry * fTECuts
text entry widget for cuts
Definition TTreeInput.h:26
TGTextEntry * fTEVars
text entry widget for variables
Definition TTreeInput.h:25
TGTextButton * fCancel
cancel button
Definition TTreeInput.h:28
Short_t Max(Short_t a, Short_t b)
Definition TMathBase.h:208