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