Remove obsolete comments about TTree::Refresh() not working.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveMacroEditor.cxx
CommitLineData
f6afd0e1 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveMacroEditor.h"
11#include "AliEveMacro.h"
12
13#include "TVirtualPad.h"
14
15// Cleanup these includes:
16#include "TGLabel.h"
17#include "TGNumberEntry.h"
18#include "TGColorSelect.h"
19#include "TGTextEntry.h"
20
21#include "TGComboBox.h"
22
23//______________________________________________________________________________
24// GUI editor for AliEveMacro.
25//
26
27ClassImp(AliEveMacroEditor)
28
29//______________________________________________________________________________
30AliEveMacroEditor::AliEveMacroEditor(const TGWindow *p, Int_t width, Int_t height,
31 UInt_t options, Pixel_t back) :
32 TGedFrame(p, width, height, options | kVerticalFrame, back),
33 fM(0),
34 fSources(0),
7b2d546e 35 fTags(0),
f6afd0e1 36 fMacro(0),
37 fFunc(0),
38 fArgs(0),
39 fActive(0)
40{
41 // Constructor.
42
43 MakeTitle("AliEveMacro");
44
45 TGHorizontalFrame *f = 0;
46 //TGLabel *l = 0;
47 Int_t labelW = 48;
48 {
49 f = MkHFrame();
50 MkLabel(f, "Active: ", labelW);
51
52 fActive = new TGCheckButton(f);
53 f->AddFrame(fActive); // new TGLayoutHints());
54 fActive->Connect("Clicked()", "AliEveMacroEditor", this,
55 "DoActive()");
56
7b2d546e 57 MkLabel(f, "Source: ", 56);
f6afd0e1 58 fSources = new TGComboBox(f);
59 f->AddFrame(fSources); // new TGLayoutHints());
60 fSources->AddEntry("None", AliEveMacro::kNone);
61 fSources->AddEntry("RunLoader", AliEveMacro::kRunLoader);
62 fSources->AddEntry("ESD", AliEveMacro::kESD);
63 fSources->AddEntry("ESDfriend", AliEveMacro::kESDfriend);
29207369 64 fSources->AddEntry("RawReader", AliEveMacro::kRawReader);
f6afd0e1 65 {
66 TGListBox* lb = fSources->GetListBox();
67 lb->Resize(lb->GetWidth(), 5*16);
68 }
7b2d546e 69 fSources->Resize(92, 20);
f6afd0e1 70 fSources->Connect("Selected(Int_t)", "AliEveMacroEditor", this,
71 "DoSources(Int_t)");
7b2d546e 72
73 MkLabel(f, "Tags: ", 40);
74 fTags = new TGTextEntry(f);
75 f->AddFrame(fTags, new TGLayoutHints(kLHintsNormal|kLHintsExpandX));
76 fTags->Connect("TextChanged(const char *)", "AliEveMacroEditor", this,
77 "DoTags()");
f6afd0e1 78 }
79 {
80 f = MkHFrame();
81 MkLabel(f, "Macro: ", labelW);
82 fMacro = new TGTextEntry(f);
7b2d546e 83 f->AddFrame(fMacro, new TGLayoutHints(kLHintsNormal));//|kLHintsExpandX));
f6afd0e1 84 fMacro->Connect("TextChanged(const char *)", "AliEveMacroEditor", this,
85 "DoMacro()");
86
87 MkLabel(f, "Func: ", labelW);
88 fFunc = new TGTextEntry(f);
89 f->AddFrame(fFunc, new TGLayoutHints(kLHintsNormal|kLHintsExpandX));
90 fFunc->Connect("TextChanged(const char *)", "AliEveMacroEditor", this,
91 "DoFunc()");
92 }
93 {
94 f = MkHFrame();
95 MkLabel(f, "Args: ", labelW);
96 fArgs = new TGTextEntry(f);
97 f->AddFrame(fArgs, new TGLayoutHints(kLHintsNormal|kLHintsExpandX));
98 fArgs->Connect("TextChanged(const char *)", "AliEveMacroEditor", this,
99 "DoArgs()");
100 }
101}
102
103/******************************************************************************/
104
105//______________________________________________________________________________
106void AliEveMacroEditor::SetModel(TObject* obj)
107{
108 // Set model object.
109
110 fM = dynamic_cast<AliEveMacro*>(obj);
111
112 fSources->Select (fM->GetSources(), kFALSE);
68ca2fe7 113 fTags ->SetText (fM->GetTags(), kFALSE);
114 fMacro ->SetText (fM->GetMacro(), kFALSE);
115 fFunc ->SetText (fM->GetFunc(), kFALSE);
116 fArgs ->SetText (fM->GetArgs(), kFALSE);
f6afd0e1 117 fActive ->SetState(fM->fActive ? kButtonDown : kButtonUp);
118}
119
120//______________________________________________________________________________
121void AliEveMacroEditor::DoSources(Int_t v)
122{
123 // Slot for Sources.
124
125 fM->SetSources(v);
126 Update();
127}
128
129//______________________________________________________________________________
7b2d546e 130void AliEveMacroEditor::DoTags()
131{
132 // Slot for Tags.
133
134 fM->SetTags(fTags->GetText());
135 Update();
136}
137
138//______________________________________________________________________________
f6afd0e1 139void AliEveMacroEditor::DoMacro()
140{
141 // Slot for Macro.
142
143 fM->SetMacro(fMacro->GetText());
144 Update();
145}
146
147//______________________________________________________________________________
148void AliEveMacroEditor::DoFunc()
149{
150 // Slot for Func.
151
152 fM->SetFunc(fFunc->GetText());
153 Update();
154}
155//______________________________________________________________________________
156void AliEveMacroEditor::DoArgs()
157{
158 // Slot for Args.
159
160 fM->SetArgs(fArgs->GetText());
161 Update();
162}
163
164//______________________________________________________________________________
165void AliEveMacroEditor::DoActive()
166{
167 // Slot for Active.
168
169 fM->SetActive(fActive->IsOn());
170 Update();
171}
172
173/******************************************************************************/
174
175TGHorizontalFrame* AliEveMacroEditor::MkHFrame(TGCompositeFrame* p)
176{
177 // Make standard horizontal frame.
178
179 if (p == 0)
180 p = this;
181 TGHorizontalFrame* f = new TGHorizontalFrame(p);
182 p->AddFrame(f, new TGLayoutHints(kLHintsNormal|kLHintsExpandX));
183 return f;
184}
185
186TGLabel* AliEveMacroEditor::MkLabel(TGCompositeFrame* p, const char* txt, Int_t width,
187 Int_t lo, Int_t ro, Int_t to, Int_t bo)
188{
189 // Make standard label.
190
191 TGLabel *l = new TGLabel(p, txt);
192 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
193 l->SetTextJustify(kTextRight);
194 l->SetWidth(width);
195 l->ChangeOptions(l->GetOptions() | kFixedWidth);
196 return l;
197}