#include "TStylePreview.h"
#include "TStyleManager.h"
#include <TCanvas.h>
#include <TRootEmbeddedCanvas.h>
#include <TStyle.h>
#include <TROOT.h>
ClassImp(TStylePreview)
TStylePreview::TStylePreview(const TGWindow *p, TStyle *style,
TVirtualPad *currentPad)
: TGTransientFrame(0, p)
{
fPad = 0;
SetWindowName("Style Manager's Preview");
SetCleanup(kNoCleanup);
DontCallClose();
fTrashListLayout = new TList();
TGLayoutHints *layoutXY = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
fTrashListLayout->Add(layoutXY);
fEcan = new TRootEmbeddedCanvas("TSMPreviewCanvas", this, 10, 10);
AddFrame(fEcan, layoutXY);
Update(style, currentPad);
MapTheWindow();
fEcan->GetCanvas()->SetEditable(kFALSE);
fEcan->GetCanvas()->SetBit(kNoContextMenu);
}
TStylePreview::~TStylePreview()
{
delete fEcan;
TObject *obj1;
TObject *obj2;
obj1 = fTrashListLayout->First();
while (obj1) {
obj2 = fTrashListLayout->After(obj1);
fTrashListLayout->Remove(obj1);
delete obj1;
obj1 = obj2;
}
delete fTrashListLayout;
}
void TStylePreview::Update(TStyle *style, TVirtualPad *pad)
{
TCanvas *c;
if (pad != fPad) {
delete fEcan->GetCanvas();
fEcan->AdoptCanvas(new TCanvas("TSMPreviewCanvas", 10, 10,
fEcan->GetCanvasWindowId()));
c = fEcan->GetCanvas();
gROOT->SetSelectedPad(c);
pad->GetCanvas()->DrawClonePad();
gROOT->SetSelectedPad(pad);
fPad = pad;
}
c = fEcan->GetCanvas();
TStyle *tmpStyle = gStyle;
gStyle = style;
c->UseCurrentStyle();
gStyle = tmpStyle;
c->Modified();
c->Update();
}
void TStylePreview::MapTheWindow()
{
MapSubwindows();
TCanvas *c = fPad->GetCanvas();
UInt_t w = c->GetWw() + 4;
UInt_t h = c->GetWh() + 4;
UInt_t x = (UInt_t) c->GetWindowTopX() + 60;
UInt_t y = (UInt_t) c->GetWindowTopY() + 100;
MoveResize(x, y, w, h);
SetWMPosition(x, y);
MapWindow();
}
TCanvas *TStylePreview::GetMainCanvas()
{
return fEcan->GetCanvas();
}
Last change: Wed Jun 25 08:53:49 2008
Last generated: 2008-06-25 08:53
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.