30 ClassImp(TStylePreview);
38 TStylePreview::TStylePreview(
const TGWindow *p, TStyle *style,
39 TVirtualPad *currentPad)
40 : TGTransientFrame(0, p)
45 SetWindowName(
"Style Manager's Preview");
46 SetCleanup(kNoCleanup);
50 fTrashListLayout =
new TList();
53 TGLayoutHints *layoutXY =
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
54 fTrashListLayout->Add(layoutXY);
57 fEcan =
new TRootEmbeddedCanvas(
"TSMPreviewCanvas",
this, 10, 10);
58 AddFrame(fEcan, layoutXY);
61 Update(style, currentPad);
67 fEcan->GetCanvas()->SetEditable(kFALSE);
68 fEcan->GetCanvas()->SetBit(kNoContextMenu);
74 TStylePreview::~TStylePreview()
82 obj1 = fTrashListLayout->First();
84 obj2 = fTrashListLayout->After(obj1);
85 fTrashListLayout->Remove(obj1);
89 delete fTrashListLayout;
96 void TStylePreview::Update(TStyle *style, TVirtualPad *pad)
100 delete fEcan->GetCanvas();
101 fEcan->AdoptCanvas(
new TCanvas(
"TSMPreviewCanvas", 10, 10,
102 fEcan->GetCanvasWindowId()));
103 c = fEcan->GetCanvas();
104 gROOT->SetSelectedPad(c);
105 if (pad->GetCanvas())
106 pad->GetCanvas()->DrawClonePad();
107 gROOT->SetSelectedPad(pad);
112 c = fEcan->GetCanvas();
113 TStyle *tmpStyle = gStyle;
115 c->UseCurrentStyle();
124 void TStylePreview::MapTheWindow()
127 TCanvas *c = fPad->GetCanvas();
129 UInt_t w = c->GetWw() + 4;
130 UInt_t h = c->GetWh() + 4;
131 UInt_t x = (UInt_t) c->GetWindowTopX() + 60;
132 UInt_t y = (UInt_t) c->GetWindowTopY() + 100;
134 MoveResize(x, y, w, h);
143 TCanvas *TStylePreview::GetMainCanvas()
145 return fEcan->GetCanvas();