コード例 #1
0
ファイル: app.cpp プロジェクト: Abyss116/luaplus51-all
bool App::OnInit()
{
    bool ok = wxApp::OnInit();

    if (ok)
    {
        wxLocaleHelper::Init(&m_locale, STE_APPNAME, m_cmdLine.m_lang);
        ::wxInitAllImageHandlers();

        // Fill in the application information fields before creating wxConfig.
        SetVendorName(wxT("wxWidgets"));
        SetAppName(APP_NAME_SHORT);
    #if (wxVERSION_NUMBER >= 2900)
        SetAppDisplayName(APP_NAME_DISPLAY);
    #endif

        // Create a document manager
        wxDocManager* docManager = CreateDocManager();

        // create the main frame window
        MainFrame* frame = new MainFrame();
        
        ok = frame->Create(docManager, GetAppDisplayName());
        if (ok)
        {
            frame->Show();
            OpenDocuments(docManager);
        }
        else
        {
            delete frame;
        }
    }
    return ok;
}
コード例 #2
0
int wxGUIDesignerApp::OnRun()
{
    wxApp::SetAppDisplayName("wxGUIDesigner");
    wxSetWorkingDirectory( wxStandardPaths::Get().GetDataDir() );
    delete wxConfigBase::Set( new wxConfig( GetAppDisplayName() ) );

#ifdef __WXMSW__
    wxSystemOptions::SetOption( "msw.remap", 0 );
    wxSystemOptions::SetOption( "msw.staticbox.optimized-paint", 0 );
#endif

    wxYield();

    wxFrame *frame = wxGUIDesigner::Get()->GetMainFrame();

    if( !frame )
    {
        wxLogError(_("Error while loading the main frame.") );
        return 1;
    }

    frame->Show( true );
    SetTopWindow( frame );

    wxGUIDesigner::Get()->NewProject();

    return wxApp::OnRun();
}
コード例 #3
0
ファイル: application.cpp プロジェクト: Mileslee/wxgis
void wxGISApplication::UpdateTitle(const wxString & sPath)
{
    SetTitle(GetAppDisplayName() + wxT(" - [") + sPath + wxT("]"));
}
コード例 #4
0
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    ::wxInitAllImageHandlers();

    // Fill in the application information fields before creating wxConfig.
    SetVendorName("wxWidgets");
    SetAppName("wx_docview_sample");
    SetAppDisplayName("wxWidgets DocView Sample");

    //// Create a document manager
    wxDocManager *docManager = new wxDocManager;

    //// Create a template relating drawing documents to their views
    new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
                      "Drawing Doc", "Drawing View",
                      CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
#if defined( __WXMAC__ )  && wxOSX_USE_CARBON
    wxFileName::MacRegisterDefaultTypeAndCreator("drw" , 'WXMB' , 'WXMA');
#endif

    if ( m_mode == Mode_Single )
    {
        // If we've only got one window, we only get to edit one document at a
        // time. Therefore no text editing, just doodling.
        docManager->SetMaxDocsOpen(1);
    }
    else // multiple documents mode: allow documents of different types
    {
        // Create a template relating text documents to their views
        new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
                          "Text Doc", "Text View",
                          CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
#if defined( __WXMAC__ ) && wxOSX_USE_CARBON
        wxFileName::MacRegisterDefaultTypeAndCreator("txt" , 'TEXT' , 'WXMA');
#endif
        // Create a template relating image documents to their views
        new wxDocTemplate(docManager, "Image", "*.png;*.jpg", "", "png;jpg",
                          "Image Doc", "Image View",
                          CLASSINFO(ImageDocument), CLASSINFO(ImageView));
    }

    // create the main frame window
    wxFrame *frame;
#if wxUSE_MDI_ARCHITECTURE
    if ( m_mode == Mode_MDI )
    {
        frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY,
                                        GetAppDisplayName(),
                                        wxDefaultPosition,
                                        wxSize(500, 400));
    }
    else
#endif // wxUSE_MDI_ARCHITECTURE
    {
        frame = new wxDocParentFrame(docManager, NULL, wxID_ANY,
                                     GetAppDisplayName(),
                                     wxDefaultPosition,
                                     wxSize(500, 400));
    }

    // and its menu bar
    wxMenu *menuFile = new wxMenu;

    menuFile->Append(wxID_NEW);
    menuFile->Append(wxID_OPEN);

    if ( m_mode == Mode_Single )
        AppendDocumentFileCommands(menuFile, true);

    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    // A nice touch: a history of files visited. Use this menu.
    docManager->FileHistoryUseMenu(menuFile);
#if wxUSE_CONFIG
    docManager->FileHistoryLoad(*wxConfig::Get());
#endif // wxUSE_CONFIG


    if ( m_mode == Mode_Single )
    {
        m_canvas = new MyCanvas(NULL, frame);
        m_menuEdit = CreateDrawingEditMenu();
    }

    CreateMenuBarForFrame(frame, menuFile, m_menuEdit);

    frame->SetIcon(wxICON(doc));
    frame->Centre();
    frame->Show();

    if ( m_filesFromCmdLine.empty() )
    {
        docManager->CreateNewDocument();
    }
    else // we have files to open on command line
    {
        for ( size_t i = 0; i != m_filesFromCmdLine.size(); ++i )
            docManager->CreateDocument(m_filesFromCmdLine[i], wxDOC_SILENT);
    }

    return true;
}
コード例 #5
0
ファイル: docview.cpp プロジェクト: czxxjtu/wxPython-1
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    SetAppName("DocView Sample");

    //// Create a document manager
    wxDocManager *docManager = new wxDocManager;

    //// Create a template relating drawing documents to their views
    new wxDocTemplate(docManager, "Drawing", "*.drw", "", "drw",
                      "Drawing Doc", "Drawing View",
                      CLASSINFO(DrawingDocument), CLASSINFO(DrawingView));
#if defined( __WXMAC__ )  && wxOSX_USE_CARBON
    wxFileName::MacRegisterDefaultTypeAndCreator("drw" , 'WXMB' , 'WXMA');
#endif

    if ( m_mode == Mode_Single )
    {
        // If we've only got one window, we only get to edit one document at a
        // time. Therefore no text editing, just doodling.
        docManager->SetMaxDocsOpen(1);
    }
    else // multiple documents mode: allow documents of different types
    {
        // Create a template relating text documents to their views
        new wxDocTemplate(docManager, "Text", "*.txt;*.text", "", "txt;text",
                          "Text Doc", "Text View",
                          CLASSINFO(TextEditDocument), CLASSINFO(TextEditView));
#if defined( __WXMAC__ ) && wxOSX_USE_CARBON
        wxFileName::MacRegisterDefaultTypeAndCreator("txt" , 'TEXT' , 'WXMA');
#endif
    }

    // create the main frame window
    wxFrame *frame;
#if wxUSE_MDI_ARCHITECTURE
    if ( m_mode == Mode_MDI )
    {
        frame = new wxDocMDIParentFrame(docManager, NULL, wxID_ANY,
                                        GetAppDisplayName(),
                                        wxDefaultPosition,
                                        wxSize(500, 400));
    }
    else
#endif // wxUSE_MDI_ARCHITECTURE
    {
        frame = new wxDocParentFrame(docManager, NULL, wxID_ANY,
                                     GetAppDisplayName(),
                                     wxDefaultPosition,
                                     wxSize(500, 400));
    }

    // and its menu bar
    wxMenu *menuFile = new wxMenu;

    menuFile->Append(wxID_NEW);
    menuFile->Append(wxID_OPEN);

    if ( m_mode == Mode_Single )
        AppendDocumentFileCommands(menuFile, true);

    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    // A nice touch: a history of files visited. Use this menu.
    docManager->FileHistoryUseMenu(menuFile);

    if ( m_mode == Mode_Single )
    {
        m_canvas = new MyCanvas(NULL, frame);
        m_menuEdit = CreateDrawingEditMenu();
    }

    CreateMenuBarForFrame(frame, menuFile, m_menuEdit);

    frame->SetIcon(wxICON(doc));
    frame->Centre(wxBOTH);
    frame->Show(true);

    SetTopWindow(frame);
    return true;
}