source: trunk/Cosy/gui/MGEmbeddedCanvas.cc@ 18589

Last change on this file since 18589 was 9515, checked in by tbretz, 15 years ago
*** empty log message ***
File size: 2.8 KB
Line 
1//
2// This File contains the definition of the MGCoordinates-class
3//
4// Author: Thomas Bretz
5// Version: V1.0 (1-8-2000)
6
7#include "MGEmbeddedCanvas.h"
8
9#include <iostream>
10
11#include <math.h>
12
13#include <TList.h>
14#include <TCanvas.h>
15
16#undef DEBUG
17
18ClassImp(MGEmbeddedCanvas);
19
20using namespace std;
21
22MGEmbeddedCanvas::MGEmbeddedCanvas(const char *name, const TGWindow* p,
23 UInt_t width, Double_t range)
24 : TRootEmbeddedCanvas(name, p, width+1, width+1, 0/*kRaisedFrame*/),
25 fModified(kFALSE), fWidth(width), fRange(fabs(range)), fPix(2.*fabs(range)/width)
26{
27#ifdef DEBUG
28 cout << "MGEmbeddedCanvas: Initializing." << endl;
29#endif
30
31 fCanvas = GetCanvas();
32
33#ifdef DEBUG
34 cout << "MGEmbeddedCanvas: fCanvas = 0x" << fCanvas << endl;
35
36 cout << "MGEmbeddedCanvas: SetFillColor." << endl;
37#endif
38 fCanvas->SetFillColor(39); // s. TAttFill
39#ifdef DEBUG
40 cout << "MGEmbeddedCanvas." << endl;
41#endif
42
43 fCanvas->Range(-fRange, -fRange, fRange, fRange);
44
45 fList = new TList;
46 fList->SetOwner();
47
48#ifdef DEBUG
49 cout << "MGEmbeddedCanvas: Initializing done." << endl;
50#endif
51}
52
53MGEmbeddedCanvas::~MGEmbeddedCanvas()
54{
55 delete fList;
56}
57
58void MGEmbeddedCanvas::Resize(TGDimension size)
59{
60 fWidth = size.fWidth;
61 fPix = 2.*fRange/size.fWidth;
62 TRootEmbeddedCanvas::Resize(size);
63}
64
65void MGEmbeddedCanvas::Resize(UInt_t w, UInt_t h)
66{
67 fWidth = w;
68 fPix = 2.*fRange/w;
69 TRootEmbeddedCanvas::Resize(w, h);
70}
71
72void MGEmbeddedCanvas::MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
73{
74 fWidth = w;
75 fPix = 2.*fRange/w;
76 TRootEmbeddedCanvas::MoveResize(x, y, w, h);
77}
78
79// ------------------------------------------------------------------------
80//
81// Map the subwindows, resize to its quadratic size, map the window itself
82// and set it to Non-Editable.
83//
84void MGEmbeddedCanvas::InitCanvas()
85{
86 MapSubwindows();
87
88 Resize(fWidth, fWidth); //GetDefaultSize()); // ???
89 MapWindow();
90
91 fCanvas->SetEditable(kFALSE);
92}
93
94void MGEmbeddedCanvas::UpdateCanvas()
95{
96 if (!fModified)
97 return;
98
99 //
100 // FIXME: Sometimes (if the canvas couldn't be created correctly:
101 // X11 Pixmap error) Update hangs the Gui system.
102 //
103 // Fixed: By using root 3.01/06 and doing the update from within the
104 // mainthread.
105 //
106
107 fCanvas->Modified();
108 fCanvas->Update();
109
110 fModified = kFALSE;
111}
112
113// ------------------------------------------------------------------------
114//
115// Set's the kNoContextMenu bit for all primitives in the embedded canvas
116// and the canvas itself, so that no context menu is displayed.
117//
118void MGEmbeddedCanvas::SetNoContextMenu()
119{
120 TList &list = *fCanvas->GetListOfPrimitives();
121 list.R__FOR_EACH(TObject, SetBit)(kNoContextMenu);
122
123 fCanvas->SetBit(kNoContextMenu);
124}
Note: See TracBrowser for help on using the repository browser.