News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Is HEAD missing way to get event SCIwindow ??

Started by Pecan, December 09, 2005, 02:42:45 AM

Previous topic - Next topic

Pecan

I have a question about the proper way to obtain a ptr to the cbStyledTextCtrl window.

In HEAD, when a plugin gets an EVT_EDITOR_CLOSE event, it cannot use GetBuiltinActiveEditor()
because the active editor is NOT the one being closed. Attempting to do so will crash C::B.

How should one get a ptr to SCIwindow from event.GetEditor() ??
class EditorBase has no GetControl() function.
RC2 had a event.GetEditor()->GetControl() call.

In the following hack, ...FindWindowByName("SCIwindow", event.GetEditor()) works, but is it
proper to do so??


// ----------------------------------------------------------------------------
void cbDragScroll::OnEditorClose(CodeBlocksEvent& event)
// ----------------------------------------------------------------------------
{
    if (m_IsAttached)
     {
        // Get rid of our event handler
        //v1.RC2 wxFrame* thisEditor = (wxFrame*)event.GetEditor()->GetControl();

        wxWindow* thisWindow = event.GetEditor();

        //v1.RC3 alpha
        // Cannot use GetBuiltinActiveEditor() because the active Editor is NOT the
        // one being closed!!
        // wxWindow* thisEditor
        //  = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor()->GetControl();

        //find the cbStyledTextCtrl wxScintilla window
        wxWindow*
          thisEditor = thisWindow->FindWindowByName("SCIwindow", thisWindow);

        if ( (thisEditor) && (m_EditorPtrs.Index(thisEditor) != wxNOT_FOUND))



thanks
Pecan

mandrav

event.GetEditor() returns EditorBase* (up to RC2, it used to return cbEditor*).
So, try the following:

cbEditor* ed = 0;
EditorBase* eb = event.GetEditor();
if (eb && eb->IsBuiltinEditor())
    ed = static_cast<cbEditor*>(eb);

if (ed)
{
    // ed->GetControl() should work now
    ...
}
Be patient!
This bug will be fixed soon...

rickg22

BTW, what's the difference between static_cast<type*>(pointer) and (type*)(pointer) ? I never understood it.

takeshimiya

It is the same:

(type*)(pointer)  C way
static_cast<type*>(pointer)  C++ way

The C way works on the C++ way of course, but not the opposite.