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// //
14// Tree Input Widget //
15// //
16// An dialog box that asks the user for the variables and cuts //
17// of the selected tree in the fitpanel. //
18// //
19//////////////////////////////////////////////////////////////////////////
20
21#include "TTreeInput.h"
22#include "TGButton.h"
23#include "TGLabel.h"
24#include "TGTextEntry.h"
25#include "strlcpy.h"
26
29};
30
32
33////////////////////////////////////////////////////////////////////////////////
34/// Create simple input dialog.
35
37 char *strvars, char *strcuts):
39 fStrvars(strvars),
40 fStrcuts(strcuts)
41{
42 if (!p && !main) {
43 MakeZombie();
44 return;
45 }
47
48 TGLabel *label = new TGLabel(this, "Selected Variables: ");
49 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
50
51 TGTextBuffer *tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
52 fTEVars = new TGTextEntry(this, tbuf, kTI_TEVARS);
55
56 label = new TGLabel(this, "Selected Cuts: ");
57 AddFrame(label, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 0));
58
59 tbuf = new TGTextBuffer(256); //will be deleted by TGtextEntry
60 fTECuts = new TGTextEntry(this, tbuf, kTI_TECUTS);
63
64 // create frame and layout hints for Ok and Cancel buttons
65 TGHorizontalFrame *hf = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
67
68 // create OK and Cancel buttons in their own frame (hf)
69 UInt_t width = 0, height = 0;
70
71 fOk = new TGTextButton(hf, "&Ok", 1);
72 fOk->Associate(this);
74 height = fOk->GetDefaultHeight();
76
77 fCancel = new TGTextButton(hf, "&Cancel", 2);
78 fCancel->Associate(this);
80 height = fCancel->GetDefaultHeight();
82
83 // place button frame (hf) at the bottom
84 AddFrame(hf, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5));
85
86 // keep buttons centered and with the same width
87 hf->Resize((width + 20) * 2, height);
88
89 // set dialog title
90 SetWindowName("Get Input");
91
92 // map all widgets and calculate size of dialog
94
96 height = GetDefaultHeight();
97
98 Resize(width, height);
99
100 // position relative to the parent's window
102
103 // make the message box non-resizable
104 SetWMSize(width, height);
105 SetWMSizeHints(width, height, width, height, 0, 0);
106
112
113 // popup dialog and wait till user replies
114 MapWindow();
115 fTEVars->SetFocus();
116
117 gClient->WaitFor(this);
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Cleanup dialog.
122
124{
125 Cleanup();
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Handle button and text enter events
130
132{
133 switch (GET_MSG(msg)) {
134 case kC_COMMAND:
135 switch (GET_SUBMSG(msg)) {
136 case kCM_BUTTON:
137 switch (parm1) {
138 case 1:
139 // here copy the string from text buffer to return variable
140 // see TFitEditor.cxx for the maximum length:
141 // char variables[256] = {0}; char cuts[256] = {0};
142 strlcpy(fStrvars, fTEVars->GetBuffer()->GetString(), 256);
143 strlcpy(fStrcuts, fTECuts->GetBuffer()->GetString(), 256);
144 delete this;
145 break;
146 case 2:
147 fStrvars[0] = 0;
148 fStrcuts[0] = 0;
149 delete this;
150 break;
151 }
152 default:
153 break;
154 }
155 break;
156
157 case kC_TEXTENTRY:
158 switch (GET_SUBMSG(msg)) {
159 case kTE_ENTER:
160 // here copy the string from text buffer to return variable
161 // see TFitEditor.cxx for the maximum length:
162 // char variables[256] = {0}; char cuts[256] = {0};
163 strlcpy(fStrvars, fTEVars->GetBuffer()->GetString(), 256);
164 strlcpy(fStrcuts, fTECuts->GetBuffer()->GetString(), 256);
165 delete this;
166 break;
167 case kTE_TAB:
168 if ( parm1 == kTI_TEVARS )
169 fTECuts->SetFocus();
170 else if ( parm1 == kTI_TECUTS )
171 fTEVars->SetFocus();
172 break;
173 default:
174 break;
175 }
176 break;
177
178 default:
179 break;
180 }
181 return kTRUE;
182}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
long Long_t
Definition RtypesCore.h:54
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
#define gClient
Definition TGClient.h:166
@ kMWMDecorResizeH
Definition TGFrame.h:73
@ kMWMFuncAll
Definition TGFrame.h:57
@ kMWMFuncResize
Definition TGFrame.h:58
@ kMWMDecorMaximize
Definition TGFrame.h:77
@ kMWMDecorMinimize
Definition TGFrame.h:76
@ kMWMDecorMenu
Definition TGFrame.h:75
@ kMWMDecorAll
Definition TGFrame.h:71
@ kMWMFuncMaximize
Definition TGFrame.h:61
@ kMWMInputModeless
Definition TGFrame.h:65
@ kMWMFuncMinimize
Definition TGFrame.h:60
@ kDeepCleanup
Definition TGFrame.h:50
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsCenterY
Definition TGLayout.h:35
@ kLHintsCenterX
Definition TGLayout.h:32
@ kLHintsBottom
Definition TGLayout.h:36
@ kLHintsTop
Definition TGLayout.h:34
@ kLHintsExpandX
Definition TGLayout.h:37
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:1102
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:348
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:952
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1057
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:350
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:214
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:215
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
virtual void MapWindow()
map window
Definition TGFrame.h:228
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition TGFrame.cxx:1852
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition TGFrame.cxx:1827
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:1865
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition TGFrame.cxx:1749
const char * GetString() const
virtual void SetFocus()
Set focus to this text entry.
TGTextBuffer * GetBuffer() const
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition TGFrame.cxx:1916
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
void MakeZombie()
Definition TObject.h:49
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t)
Handle button and text enter events.
TGTextButton * fOk
Definition TTreeInput.h:35
char * fStrcuts
Definition TTreeInput.h:38
char * fStrvars
Definition TTreeInput.h:37
~TTreeInput()
Cleanup dialog.
TTreeInput(const TTreeInput &)
TGTextEntry * fTECuts
Definition TTreeInput.h:34
TGTextEntry * fTEVars
Definition TTreeInput.h:33
TGTextButton * fCancel
Definition TTreeInput.h:36
int main()
Short_t Max(Short_t a, Short_t b)
Definition TMathBase.h:212