]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4Editor.cxx
Place station 3 inside Dipole.
[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(),
46 ((TGFrame *) main)->GetWidth() - (fWidth >> 1),
47 (((TGFrame *) main)->GetHeight() - fHeight) >> 1,
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()
84{
85 // Set title in editor window.
86
87 TGText* txt = GetEditor()->GetText();
88 Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
89
90 char title[256];
66a8b12d 91 if (untitled)
b8c9c0a3 92 sprintf(title, "Status Report");
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();
105}
106
66a8b12d 107void TG4Editor::LoadBuffer(const char* buffer)
b8c9c0a3 108{
109 // Load a text buffer in the editor.
110
111 fEdit->LoadBuffer(buffer);
112}
113
b8c9c0a3 114void TG4Editor::CloseWindow()
115{
116 // Called when closed via window manager action.
117
118 delete this;
119}
120
121Bool_t TG4Editor::ProcessMessage(Long_t msg, Long_t, Long_t)
122{
123 // Process Help Menu.
124
125
126 switch (GET_MSG(msg)) {
127 case kC_COMMAND:
128 switch (GET_SUBMSG(msg)) {
129 case kCM_BUTTON:
130 // Only one button and one action...
131 delete this;
132 break;
133 default:
134 break;
135 }
136 break;
137 case kC_TEXTVIEW:
138 switch (GET_SUBMSG(msg)) {
139 case kTXT_CLOSE:
140 // close window
141 delete this;
142 break;
143 case kTXT_OPEN:
144 SetTitle();
145 break;
146 case kTXT_SAVE:
147 SetTitle();
148 break;
149 default:
150 break;
151 }
152 default:
153 break;
154 }
155
156 return kTRUE;
157}
158