]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4Editor.cxx
Changes by Massimo Masera to allow Recpoints and Clusters to be written
[u/mrichter/AliRoot.git] / TGeant4 / TG4Editor.cxx
CommitLineData
b8c9c0a3 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
66a8b12d 5//========================================================
b8c9c0a3 6//
66a8b12d 7//---------------TG4Editor.cxx---------------------------//
8//------- A supplementary service class for--------------//
9//-----------AG4 Geometry Browser------------------------//
b8c9c0a3 10//
66a8b12d 11//=========================================================
b8c9c0a3 12
13#include "TG4Editor.h"
66a8b12d 14#include "TG4Globals.h"
b8c9c0a3 15
16#include <TGButton.h>
17#include <TGTextEdit.h>
18#include <TGText.h>
19
20
21ClassImp(TG4Editor)
22
23TG4Editor::TG4Editor(const TGWindow* main, UInt_t w, UInt_t h) :
24 TGTransientFrame(gClient->GetRoot(), main, w, h)
25{
26 // Create an editor
27
28 fEdit = new TGTextEdit(this, w, h, kSunkenFrame | kDoubleBorder);
29 fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
30 AddFrame(fEdit, fL1);
31
32 fOK = new TGTextButton(this, " &OK ");
33 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
34 AddFrame(fOK, fL2);
35
36 SetTitle();
37
38 MapSubwindows();
39
40 Resize(GetDefaultSize());
41
42 // position relative to the parent's window
43 Window_t wdum;
44 int ax, ay;
45 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
39dd4871 46 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
47 ((TGFrame *) main)->GetHeight() - (fHeight >> 1),
b8c9c0a3 48 ax, ay, wdum);
49 Move(ax, ay);
50 SetWMPosition(ax, ay);
51}
52
66a8b12d 53TG4Editor::TG4Editor(const TG4Editor& ge) :
54 TGTransientFrame( (const TGTransientFrame&) ge)
55{
56// Dummy copy constructor
57 TG4Globals::Exception(
58 "Attempt to use TG4Editor copy constructor.");
59}
60
61TG4Editor& TG4Editor::operator=(const TG4Editor& ge)
62{
63 // check assignement to self
64 if (this == &ge) return *this;
65
66 TG4Globals::Exception(
67 "Attempt to assign TG4Editor singleton.");
68
69 return *this;
70}
71
72
b8c9c0a3 73TG4Editor::~TG4Editor()
74{
75 // Delete editor accessories
76
77 delete fEdit;
78 delete fOK;
79 delete fL1;
80 delete fL2;
81}
82
83void TG4Editor::SetTitle()
39dd4871 84{
85// Set title in editor window.
b8c9c0a3 86
87 TGText* txt = GetEditor()->GetText();
88 Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
89
90 char title[256];
66a8b12d 91 if (untitled)
39dd4871 92 sprintf(title, "Message Display");
66a8b12d 93 else
94 sprintf(title, "Editor - %s", txt->GetFileName());
b8c9c0a3 95
96 SetWindowName(title);
97 SetIconName(title);
98}
99
100void TG4Editor::Popup()
101{
102 // Show editor.
103
104 MapWindow();
39dd4871 105 fClient->WaitFor(this);
b8c9c0a3 106}
107
66a8b12d 108void TG4Editor::LoadBuffer(const char* buffer)
b8c9c0a3 109{
110 // Load a text buffer in the editor.
111
112 fEdit->LoadBuffer(buffer);
113}
114
b8c9c0a3 115void TG4Editor::CloseWindow()
116{
117 // Called when closed via window manager action.
118
119 delete this;
120}
121
122Bool_t TG4Editor::ProcessMessage(Long_t msg, Long_t, Long_t)
123{
124 // Process Help Menu.
125
126
127 switch (GET_MSG(msg)) {
128 case kC_COMMAND:
129 switch (GET_SUBMSG(msg)) {
130 case kCM_BUTTON:
131 // Only one button and one action...
132 delete this;
133 break;
134 default:
135 break;
136 }
137 break;
138 case kC_TEXTVIEW:
139 switch (GET_SUBMSG(msg)) {
140 case kTXT_CLOSE:
141 // close window
142 delete this;
143 break;
144 case kTXT_OPEN:
145 SetTitle();
146 break;
147 case kTXT_SAVE:
148 SetTitle();
149 break;
150 default:
151 break;
152 }
153 default:
154 break;
155 }
156
157 return kTRUE;
158}
159