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

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