How to open a document with wxWidgets in CELayoutEditor

Use this forum for:
- Discussion regarding unofficial CEGUI related tools, scripts and utilities.
- User to user help for the obsoleted CELayoutEditor and CEImagesetEditor tools.

Moderators: CEGUI MVP, CEGUI Team

ppl
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Tue May 15, 2007 16:37
Location: Canada

How to open a document with wxWidgets in CELayoutEditor

Postby ppl » Mon Jun 04, 2007 12:05

In the EditorFrame class, how can I open a layout file using m_document, which is of type EditorDocument which derives from wxDocument, with an absolute pathname?

I'm unsure of what is happening with the wxID_OPEN event.

What I'm trying to do is to reload the current document. So, something along these lines:

Code: Select all

void EditorFrame::OnEditReload(wxCommandEvent& WXUNUSED(event))
{
   const wxString filename = m_document->GetFilename();

   m_document->Close();
   m_document->OnOpenDocument(filename); // This line is crashing
}


Thanks,
ppl

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon Jun 04, 2007 21:14

Hi,

how far can you trace into this crash? I have never tried this, but maybe the Close method does more then you want. You might trick the system by calling 'm_document->Modify(false)' and then call Open(). The modify call 'undirties' the document, so that wxWidgets won't prompt for saving.

Or... -i just came up with this- look at CELayoutEditor.cpp where you can see how a new document can be created through the Document Manager. This part:

Code: Select all

// When a current layout was set, load it
wxString layout = COptions::GetInstancePtr()->GetCurrentLayout();
if (layout != wxT("")){
  docManager->CreateDocument(layout, wxDOC_SILENT);
}


Good luck!

ppl
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Tue May 15, 2007 16:37
Location: Canada

Postby ppl » Tue Jun 05, 2007 14:42

I actually want CELayoutEditor to ask the user if he wants to save if he has pending modifications.

What I have is

Code: Select all

void EditorFrame::OnEditReload(wxCommandEvent& WXUNUSED(event))
{
   const wxString filename = m_document->GetFilename();

   m_document->OnCloseDocument();
   m_document->OnOpenDocument(filename);
}


which gets called when you press a button I added to the tool bar.

However it crash within the SetActiveLayout() call, something to do with the background

Code: Select all

bool EditorDocument::OnOpenDocument(const wxString& filename)
{
    if ( filename.empty() || !wxDocument::OnOpenDocument( filename ) )
        return false;

    // Cleanup any current windows to avoid name clashes
    WindowManager::getSingletonPtr()->destroyAllWindows ();

    try
    {
        // Use the full path, because layouts can be loaded from everywhere.
        CEGUI::Window* root = WindowManager::getSingleton().loadWindowLayout(StringHelper::ToCEGUIString(filename));
        SetActiveLayout (root);

        .
        .
        .

    }

    .
    .
    .

}


I simply want to do exactly the same as when you do File>Open> in the menu. However, I want to specify the document location instead of prompting the user. The document location will be m_document->GetFilename()


Return to “Unofficial CEGUI-Related Tools”

Who is online

Users browsing this forum: No registered users and 1 guest