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