source: trunk/MagicSoft/Cosy/gui/MGEmbeddedCanvas.cc@ 8826

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