2 // Category: interfaces
5 //========================================================
7 //---------------TG4Editor.cxx---------------------------//
8 //------- A supplementary service class for--------------//
9 //-----------AG4 Geometry Browser------------------------//
11 //=========================================================
13 #include "TG4Editor.h"
14 #include "TG4Globals.h"
17 #include <TGTextEdit.h>
23 TG4Editor::TG4Editor(const TGWindow* main, UInt_t w, UInt_t h) :
24 TGTransientFrame(gClient->GetRoot(), main, w, h)
28 fEdit = new TGTextEdit(this, w, h, kSunkenFrame | kDoubleBorder);
29 fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
32 fOK = new TGTextButton(this, " &OK ");
33 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
40 Resize(GetDefaultSize());
42 // position relative to the parent's window
45 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
46 (((TGFrame *) main)->GetWidth() - fWidth) >> 1,
47 ((TGFrame *) main)->GetHeight() - (fHeight >> 1),
50 SetWMPosition(ax, ay);
53 TG4Editor::TG4Editor(const TG4Editor& ge) :
54 TGTransientFrame( (const TGTransientFrame&) ge)
56 // Dummy copy constructor
57 TG4Globals::Exception(
58 "Attempt to use TG4Editor copy constructor.");
61 TG4Editor& TG4Editor::operator=(const TG4Editor& ge)
63 // check assignement to self
64 if (this == &ge) return *this;
66 TG4Globals::Exception(
67 "Attempt to assign TG4Editor singleton.");
73 TG4Editor::~TG4Editor()
75 // Delete editor accessories
83 void TG4Editor::SetTitle()
85 // Set title in editor window.
87 TGText* txt = GetEditor()->GetText();
88 Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
92 sprintf(title, "Message Display");
94 sprintf(title, "Editor - %s", txt->GetFileName());
100 void TG4Editor::Popup()
105 fClient->WaitFor(this);
108 void TG4Editor::LoadBuffer(const char* buffer)
110 // Load a text buffer in the editor.
112 fEdit->LoadBuffer(buffer);
115 void TG4Editor::CloseWindow()
117 // Called when closed via window manager action.
122 Bool_t TG4Editor::ProcessMessage(Long_t msg, Long_t, Long_t)
124 // Process Help Menu.
127 switch (GET_MSG(msg)) {
129 switch (GET_SUBMSG(msg)) {
131 // Only one button and one action...
139 switch (GET_SUBMSG(msg)) {