Skip to content

Commit 197658c

Browse files
committed
Adjust TCanvas::SetCanvasImp for web case
When web implementation assigned from outside, several internal fields has to be reset -like fCanvasID or fPixmapID. Otheriwse canvas cannot be normally displayed and updated. Extra fields only set when web canvas implementation assigned.
1 parent c11464f commit 197658c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

graf2d/gpad/inc/TCanvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ friend class TInterpreter;
202202
void SetGrayscale(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsGrayscale
203203
void SetWindowPosition(Int_t x, Int_t y);
204204
void SetWindowSize(UInt_t ww, UInt_t wh);
205-
void SetCanvasImp(TCanvasImp *i) { fCanvasImp = i; }
205+
void SetCanvasImp(TCanvasImp *i);
206206
void SetCanvasSize(UInt_t ww, UInt_t wh) override; // *MENU*
207207
void SetHighLightColor(Color_t col) { fHighLightColor = col; }
208208
void SetSelected(TObject *obj) override;

graf2d/gpad/src/TCanvas.cxx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,30 @@ void TCanvas::SetWindowSize(UInt_t ww, UInt_t wh)
21562156
fCanvasImp->SetWindowSize(ww, wh);
21572157
}
21582158

2159+
////////////////////////////////////////////////////////////////////////////////
2160+
/// Set canvas implementation
2161+
/// If web-based implementation provided, some internal fields also initialized
2162+
2163+
void TCanvas::SetCanvasImp(TCanvasImp *imp)
2164+
{
2165+
Bool_t was_web = IsWeb();
2166+
2167+
fCanvasImp = imp;
2168+
2169+
if (!was_web && IsWeb()) {
2170+
fCanvasID = fCanvasImp->InitWindow();
2171+
fPixmapID = 0;
2172+
fMother = this;
2173+
if (!fCw) fCw = 800;
2174+
if (!fCh) fCh = 600;
2175+
} else if (was_web && !imp) {
2176+
fCanvasID = -1;
2177+
fPixmapID = -1;
2178+
fMother = nullptr;
2179+
fCw = fCh = 0;
2180+
}
2181+
}
2182+
21592183
////////////////////////////////////////////////////////////////////////////////
21602184
/// Set the canvas scale in centimeters.
21612185
///

0 commit comments

Comments
 (0)