www.pudn.com > TurboPadSource.tar.gz > app.cpp


/** 
*    \file App Implementation 
* 
*    Implementation of App functions. 
*/ 
 
#include "app.h" 
 
IMPLEMENT_APP(App) 
 
#ifndef __WXMSW__ // \todo Create a Linux.h file to hold Linux specific code like this 
#include "Bitmaps/new.xpm" 
#include "Bitmaps/open.xpm" 
#include "Bitmaps/save.xpm" 
#include "Bitmaps/saveall.xpm" 
#include "Bitmaps/close.xpm" 
 
#include "Bitmaps/print.xpm" 
#include "Bitmaps/printpreview.xpm" 
 
#include "Bitmaps/copy.xpm" 
#include "Bitmaps/cut.xpm" 
#include "Bitmaps/paste.xpm" 
#include "Bitmaps/undo.xpm" 
#include "Bitmaps/redo.xpm" 
 
#include "Bitmaps/find.xpm" 
#include "Bitmaps/findnext.xpm" 
#include "Bitmaps/replace.xpm" 
#endif 
 
bool App::OnInit() 
{ 
    int x, y, h, w; 
    wxClientDisplayRect(&x, &y, &w, &h); 
 
    SetVendorName("Matt Watkins"); 
    SetAppName("Turbo Pad"); 
 
    PPtr frame = new Parent(NULL, -1, "Turbo Pad", wxPoint(x, y), wxSize (w, h), 
                               wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxMAXIMIZE); 
 
    // Freeze and thaw the frame to prevent the user from seeing the menus being grayed out 
    frame->Freeze(); 
    frame->Show(true); 
    frame->Refresh(); 
    frame->Thaw(); 
 
    ParseCommandLine(argc, argv, frame); 
 
    return true; 
} 
 
inline void App::ParseCommandLine(int argc, char** argv, PPtr frame) 
{ 
    wxCmdLineParser cmdLineParser(argc, argv); 
    cmdLineParser.AddOption("p", "project", "Opens a project file.", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); 
    cmdLineParser.AddSwitch("n", "new", "Creates a new file.", wxCMD_LINE_PARAM_OPTIONAL); 
    cmdLineParser.AddOption("f", "files", "Opens file(s).", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE); 
    cmdLineParser.Parse(true); 
 
    if (cmdLineParser.Found("n")) 
        frame->Command(Par_NewFile); 
 
    wxString prjFile; 
    if (cmdLineParser.Found("p", &prjFile)) 
    { 
        frame->GetProject()->Load(prjFile); 
        frame->UpdateMenus(); 
    } 
 
    wxString files; 
    if (cmdLineParser.Found("f", &files)) 
    { 
        if (wxFileExists(files)) 
            frame->OpenFile(files); 
    } 
}