Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TSessionLogView.cxx
Go to the documentation of this file.
1 // @(#)root/sessionviewer:$Id$
2 // Author: Bertrand Bellenot, Gerri Ganis 15/09/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TSessionLogView.h"
13 #include "TSessionViewer.h"
14 #include "TProof.h"
15 #include "KeySymbols.h"
16 
17 //_____________________________________________________________________________
18 //
19 // TSessionLogView
20 //
21 // Dialog used to display session logs from the session viewer
22 //_____________________________________________________________________________
23 
24 ClassImp(TSessionLogView);
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Create an editor in a dialog.
28 
29 TSessionLogView::TSessionLogView(TSessionViewer *viewer, UInt_t w, UInt_t h) :
30  TGTransientFrame(gClient->GetRoot(), viewer, w, h)
31 {
32  fViewer = viewer;
33  fTextView = new TGTextView(this, w, h, kSunkenFrame | kDoubleBorder);
34  fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
35  AddFrame(fTextView, fL1);
36 
37  fClose = new TGTextButton(this, " &Close ");
38  fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
39  AddFrame(fClose, fL2);
40 
41  SetTitle();
42  fViewer->SetLogWindow(this);
43 
44  MapSubwindows();
45 
46  Resize(GetDefaultSize());
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 
51 TSessionLogView::~TSessionLogView()
52 {
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Set title in editor window.
57 
58 void TSessionLogView::SetTitle()
59 {
60  TString title;
61  title.Form("PROOF Processing Logs: %s", (fViewer->GetActDesc()->fProof ?
62  fViewer->GetActDesc()->fProof->GetMaster() : "<dummy>"));
63  SetWindowName(title);
64  SetIconName(title);
65 }
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Show editor.
69 
70 void TSessionLogView::Popup()
71 {
72  MapWindow();
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Load a text buffer in the editor.
77 
78 void TSessionLogView::AddBuffer(const char *buffer)
79 {
80  TGText txt;
81  txt.LoadBuffer(buffer);
82  fTextView->AddText(&txt);
83  fTextView->ShowBottom();
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Clear log window.
88 
89 void TSessionLogView::ClearLogView()
90 {
91  fTextView->Clear();
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Load a text buffer in the editor.
96 
97 void TSessionLogView::LoadBuffer(const char *buffer)
98 {
99  fTextView->LoadBuffer(buffer);
100  fTextView->ShowBottom();
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Load a file in the editor.
105 
106 void TSessionLogView::LoadFile(const char *file)
107 {
108  fTextView->LoadFile(file);
109  fTextView->ShowBottom();
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// Called when closed via window manager action.
114 
115 void TSessionLogView::CloseWindow()
116 {
117  if (fViewer->GetActDesc()->fProof) {
118  fViewer->GetActDesc()->fProof->Disconnect(
119  "LogMessage(const char*,Bool_t)", fViewer,
120  "LogMessage(const char*,Bool_t)");
121  }
122  fViewer->SetLogWindow(0);
123  delete fTextView;
124  delete fClose;
125  delete fL1;
126  delete fL2;
127  DestroyWindow();
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Process OK button.
132 
133 Bool_t TSessionLogView::ProcessMessage(Long_t msg, Long_t, Long_t)
134 {
135  switch (GET_MSG(msg)) {
136  case kC_COMMAND:
137  switch (GET_SUBMSG(msg)) {
138  case kCM_BUTTON:
139  // Only one button and one action...
140  CloseWindow();
141  break;
142  default:
143  break;
144  }
145  break;
146  default:
147  break;
148  }
149  return kTRUE;
150 }
151