Adding Editor

Hello,

I’m trying to add the pad editor that is on the left side of TBrowser into my custom GUI. I have the basic framework set up in the following macro, and I’m not sure how to start. I’ve looked through the TRootCanvas.cxx and noticed that the editor is connected to the pad so I started poking around the TVirtualPad classes. I tried getting the editor and embedding it in the left panel, but it didn’t work. I’m not even sure if that’s possible. Any direction is greatly appreciated.

Also, there are two lines commented out in the macro because they are making the macro crash but I have no idea why. I’m guessing it’s a really silly mistake I’ve done, but I’m unable to find it. Any tips on that would be appreciated too.

//TGVerticalFrame *editor = new TGVerticalFrame(frame1, 100, 400)); //frame1->AddFrame(editor, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

Thank you!
test_editor_canvas.c (2.21 KB)

Hi,

Well, first of all, try to remove the extra parenthesis in your TGVerticalFrame constructor:

TGVerticalFrame *editor = new TGVerticalFrame(frame1, 100, 400); frame1->AddFrame(editor, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); :wink:
Then, you cannot embed the editor in another frame. You would have to modify TRootCanvas for this, just look how this is done for the browser in TRootCanvas::ShowEditor(Bool_t show), in TRootCanvas.cxx, around line 1467)

Cheers, Bertrand.

:smiley: Aha! Thanks.

For the editor then, I just need to use modified code from the TRootCanvas function, and I do not need to inherit from TRootCanvas, is that right?
If that is true, then I’m guessing that I can use the second half of the function (shown below) since the first half has the condition that the main frame be inherited from TRootCanvas. At least, that is my understanding.

Sorry for any confusion. Please let me know if anything doesn’t make sense.

else { if (show) { if (!fEditor) CreateEditor(); TVirtualPadEditor* gged = TVirtualPadEditor::GetPadEditor(kFALSE); if(gged && gged->GetCanvas() == fCanvas){ gged->Hide(); } if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) { ShowFrame(fHorizontal1); h = h + s; } fMainFrame->ShowFrame(fEditorFrame); fEditor->Show(); fViewMenu->CheckEntry(kViewEditor); w = w + e; } else { if (!fViewMenu->IsEntryChecked(kViewToolbar) || fToolDock->IsUndocked()) { HideFrame(fHorizontal1); h = h - s; } if (fEditor) fEditor->Hide(); fMainFrame->HideFrame(fEditorFrame); fViewMenu->UnCheckEntry(kViewEditor); w = w - e; } Resize(w, h); }

Well,

Well, you can still try to make your own class inheriting from TRootCanvas, but I’m wondering if all this is really needed, since you can still pop-up the editor via the TCanvas context menu…
And yes, the code you posted is the one responsible to display the editor in the main frame.

Cheers, Bertrand.

I had just wanted to clarify about inheritance because I was not planning on inheriting from TRootCanvas. And sorry, I’m not sure what you mean by the TCanvas context menu. Do you mean the View menu? I tried popping that up in the macro I posted and nothing showed up so I’m not sure what I did wrong there.

Thank you!

Hi,

No I mean the context menu you obtain by clicking in the canvas with the right button…

Cheers, Bertrand.

Oh, thank you. Yes. I did notice that. I was just hoping to add the editor panel since having it visually on the side might be more convenient. Thanks again! :slight_smile: