| 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 |
|
|---|
| 16 | ClassImp(MGEmbeddedCanvas);
|
|---|
| 17 |
|
|---|
| 18 | MGEmbeddedCanvas::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 |
|
|---|
| 49 | MGEmbeddedCanvas::~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 | //
|
|---|
| 59 | void MGEmbeddedCanvas::InitCanvas()
|
|---|
| 60 | {
|
|---|
| 61 | MapSubwindows();
|
|---|
| 62 |
|
|---|
| 63 | Resize(fWidth, fWidth); //GetDefaultSize()); // ???
|
|---|
| 64 | MapWindow();
|
|---|
| 65 |
|
|---|
| 66 | fCanvas->SetEditable(kFALSE);
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | void 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 | //
|
|---|
| 93 | void MGEmbeddedCanvas::SetNoContextMenu()
|
|---|
| 94 | {
|
|---|
| 95 | TList &list = *fCanvas->GetListOfPrimitives();
|
|---|
| 96 | list.ForEach(TObject, SetBit)(kNoContextMenu);
|
|---|
| 97 |
|
|---|
| 98 | fCanvas->SetBit(kNoContextMenu);
|
|---|
| 99 | }
|
|---|