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


/** 
*    \file Parent Implementation 
* 
*    Implementation of Parent functions. 
*/ 
 
#include "parent.h" 
 
// \todo Move these strings to a Locale/Language class which will 
// initialize them and all of the other strings 
wxString ver = "v0.080a";                                    ///< Current Version 
wxString pName = "Turbo Pad";                                ///< Program Name 
wxString website = "http://turbopad.sourceforge.net";        ///< Website location 
wxString projectPage = "http://sourceforge.net/projects/turbopad"; ///< SF.net project page 
 
Parent::Parent(wxWindow* parent, wxWindowID id, const wxString& title, 
               const wxPoint& pos, const wxSize& size, long style) 
      : wxMDIParentFrame(parent, id, title, pos, size, style, "Turbo Pad") 
{ 
    SetIcon(wxICON(A)); 
 
    fData = new wxFindReplaceData(wxFR_DOWN); 
    rData = new wxFindReplaceData(wxFR_DOWN); 
 
    pData = new wxPrintData; 
    psData = new wxPageSetupDialogData; 
 
    proj = new Project; 
    syn = new Syntax; 
    status = new Status; 
    opt = new Options; 
     
    opt->Load(); 
 
    InitMenus();         // Initialize the menus 
    InitToolbar();       // Initialize Toolbar 
 
    UpdateMenus(); 
    EnableMenus(false);  // Disable All Menus because no windows are open 
 
    wxAcceleratorEntry accEntry[1]; 
    accEntry[0].Set(wxACCEL_CTRL, (int) WXK_SPACE, Par_InsTempl); 
    wxAcceleratorTable accTable(1, accEntry); 
    SetAcceleratorTable(accTable); 
} 
 
Parent::~Parent() 
{ 
    // Clean up a couple pointers 
    delete fData; 
    delete rData; 
    delete fDialog; 
    delete rDialog; 
 
    delete pData; 
    delete psData; 
 
    delete proj; 
    delete syn; 
    delete status; 
    delete opt; 
 
    hlt->Destroy(); 
    toolBar->Destroy(); 
    menuBar->Destroy();      // menuBar->Destroy should also destroy all submenus. 
} 
 
void Parent::About(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxMessageBox(pName + " " + ver + "\nBy Matt Watkins \n\n" 
                 "An all purpose text, code and script editor. \n" 
                 "Written in C++, using wxWindows and the\n" 
                 "Scintilla rich edit control.", 
                 "About", wxOK | wxICON_INFORMATION, this); 
} 
 
void Parent::AddToProj(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (!proj->Ready()) 
    { 
        wxMessageBox("No project file is currently open. \n" 
                     "Please open a project or create a new one.", 
                     "No Project Open", wxOK | wxICON_INFORMATION, this); 
        return; 
    } 
 
    wxFileDialog *addToProjDialog = new wxFileDialog 
                                    (this, "Add file(s) to the project", "", "", Types, 
                                    wxOPEN | wxMULTIPLE | wxHIDE_READONLY | wxCHANGE_DIR); 
 
    if (addToProjDialog->ShowModal() == wxID_OK) 
    { 
        wxArrayString fileNames; 
        addToProjDialog->GetPaths(fileNames); 
        fileNames.Sort(); 
 
        status->SetStatus(OpeningWindows); 
 
        for (unsigned int i = 0; i < fileNames.GetCount(); i++) 
        { 
            OpenFile(fileNames[i]); 
            proj->AddFile(fileNames[i], false); 
            proj->AddFrame(cWin); 
 
            // If this is the last file set the correct highlighter 
            if (i == fileNames.GetCount() - 1) SetHil(HilFromName(fileNames[i]), true); 
        } 
 
        status->SetIdle(); 
        proj->UpdateFileCount(); 
    } 
 
    delete addToProjDialog; 
} 
 
#ifdef __WXMSW__ 
void Parent::AlwaysOnTop(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (GetWindowStyle() & wxSTAY_ON_TOP) 
    { 
        SetWindowStyle(GetWindowStyle() - wxSTAY_ON_TOP); 
        optionsMenu->Check(Par_AlwaysTop, false); 
    } 
 
    else 
    { 
        SetWindowStyle(GetWindowStyle() | wxSTAY_ON_TOP); 
        optionsMenu->Check(Par_AlwaysTop, true); 
    } 
} 
#endif 
 
 
void Parent::Build(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (proj->IsOpen()) 
        wxExecute(proj->GetBuildCommand()); 
    else 
        Exec(cWin->GetFilename(), 2); 
} 
 
void Parent::CloseAll(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (cFrames.GetCount() > 0) 
    { 
        if (status->IsIdle()) 
            status->SetStatus(ClosingWindows); 
 
        if (proj->IsOpen()) 
            Command(Par_CloseProj); 
 
        for (unsigned int i = 0; i < cFrames.GetCount(); i++) 
        { 
            if (cFrames[i]->GetTitle().Contains("*")) 
            { 
                cFrames[i]->wxMDIChildFrame::Activate(); 
                cFrames[i]->Close(); 
            } 
 
            if (status->GetStatus() == ClosingWindows && status->NeedVeto()) 
            { 
                status->SetIdle();       // Windows will be stopped closing 
                status->SetVeto(false);  // Veto is being carried out, don't need this anymore 
                return; 
            } 
 
            if (status->GetStatus() == ClosingProgram && status->NeedVeto()) 
                return;   // Just return and let the program closing handler reset the vars 
        } 
 
        for (unsigned int i = 0; i < cFrames.GetCount(); i++) 
            if (cFrames[i] != NULL) cFrames[i]->Destroy(); 
 
        if (hlt->GetStringSelection() != "Text") 
            SetHil("Text"); 
 
        status->SetIdle(); 
    } 
} 
 
void Parent::CloseChild(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (cFrames.GetCount() > 0) 
        cWin->Close(); 
} 
 
void Parent::CloseProj(wxCommandEvent &WXUNUSED(event)) 
{ 
    for (unsigned int i = 0; i < proj->GetFrames().GetCount(); i++) 
    { 
        if (cFrames.Index(static_cast  (proj->GetFrame(i))) != wxNOT_FOUND) 
        { 
            if (proj->GetFrame(i)->GetTitle().Contains("*")) 
                proj->GetFrame(i)->Close(); 
            else 
                proj->GetFrame(i)->Destroy(); 
        } 
    } 
 
    proj->Close(); 
    UpdateMenus(); 
} 
 
void Parent::Comment(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (syn->HasStreamComment()) 
        cWin->text->StreamCommentSelection(syn->GetCommentStart(), syn->GetCommentEnd()); 
 
    else if (syn->HasBlockComment()) 
        cWin->text->BlockCommentSelection(syn->GetBlockComment()); 
} 
 
void Parent::Compile(wxCommandEvent &WXUNUSED(event)) 
{ 
    Exec(cWin->GetFilename(), 1); 
} 
 
void Parent::ConvertCRLF(wxCommandEvent &event) 
{ 
    cWin->text->SetEOL(CRLF); 
    lineEndingMenu->Check(Par_ConvertCRLF, true); 
} 
 
void Parent::ConvertLF(wxCommandEvent &event) 
{ 
    cWin->text->SetEOL(LF); 
    lineEndingMenu->Check(Par_ConvertLF, true); 
} 
 
void Parent::ConvertCR(wxCommandEvent &event) 
{ 
    cWin->text->SetEOL(CR); 
    lineEndingMenu->Check(Par_ConvertCR, true); 
} 
 
void Parent::Copy(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->Copy(); 
} 
 
inline CPtr Parent::CreateChild(const wxString &title = "") 
{ 
    // The freezing/thawing/refreshing code would be unecessary 
    // if not for cosmetic issues 
 
    menuBar->Freeze(); 
    GetClientWindow()->Freeze(); 
 
    CPtr subFrame = new Child(this, -1, title, wxDefaultPosition, wxDefaultSize, 
                               wxDEFAULT_FRAME_STYLE | wxMAXIMIZE | wxCLIP_CHILDREN); 
     
    if (subFrame->text->GetUseTabs() != opt->GetUseTabs()) 
        subFrame->text->SetUseTabs(opt->GetUseTabs()); 
         
    if (subFrame->text->GetTabWidth() != opt->GetTabSize()) 
        subFrame->text->SetTabWidth(opt->GetTabSize()); 
 
    GetClientWindow()->Thaw(); 
    menuBar->Thaw(); 
    Refresh(); 
 
    menuBar->Refresh(); 
 
    subFrame->Refresh(); 
    subFrame->text->Refresh(); 
 
    return subFrame; 
} 
 
void Parent::Cut(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->Cut(); 
} 
 
void Parent::EnableMenus(bool enable = true) 
{ 
    if (!enable) 
    { 
        fileMenu->Enable(Par_Save, false); 
        fileMenu->Enable(Par_SaveAs, false); 
        fileMenu->Enable(Par_SaveAll, false); 
        fileMenu->Enable(Par_Print, false); 
        //fileMenu->Enable(Par_PrintPre, false); 
        //fileMenu->Enable(Par_Export, false); 
        editMenu->Enable(Par_Undo, false); 
        editMenu->Enable(Par_Redo, false); 
        editMenu->Enable(Par_Cut, false); 
        editMenu->Enable(Par_Copy, false); 
        editMenu->Enable(Par_Paste, false); 
        editMenu->Enable(Par_SelAll, false); 
        searchMenu->Enable(Par_Find, false); 
        searchMenu->Enable(Par_Replace, false); 
        searchMenu->Enable(Par_FindNex, false); 
        searchMenu->Enable(Par_FindPre, false); 
        searchMenu->Enable(Par_GoToLine, false); 
        searchMenu->Enable(Par_ToggleBookMark, false); 
        searchMenu->Enable(Par_NextBookMark, false); 
        searchMenu->Enable(Par_PrevBookMark, false); 
        searchMenu->Enable(Par_RemoveAllBookMarks, false); 
        formatMenu->Enable(Par_Indent, false); 
        formatMenu->Enable(Par_Unindent, false); 
        formatMenu->Enable(Par_Upper, false); 
        formatMenu->Enable(Par_Lower, false); 
        formatMenu->Enable(Par_SortText, false); 
        formatMenu->Enable(Par_Comment, false); 
        formatMenu->Enable(Par_Insert, false); 
        viewMenu->Enable(Par_Refresh, false); 
        viewMenu->Enable(Par_MatchBrace, false); 
        viewMenu->Enable(Par_ReadOnly, false); 
        toolsMenu->Enable(Par_Compile, false); 
        toolsMenu->Enable(Par_Build, false); 
        toolsMenu->Enable(Par_Run, false); 
        toolsMenu->Enable(Par_LineEndings, false); 
        optionsMenu->Enable(Par_EnvOptions, false); 
        optionsMenu->Enable(Par_CodeTemps, false); 
        //optionsMenu->Enable(Par_UseTabs, false); 
        optionsMenu->Enable(Par_WordWrap, false); 
        helpMenu->Enable(Par_CustomHelp, false); 
        helpMenu->Enable(Par_Update, false); 
 
        toolBar->EnableTool(Par_Save, false); 
        toolBar->EnableTool(Par_SaveAll, false); 
        toolBar->EnableTool(Par_Close, false); 
        toolBar->EnableTool(Par_Print, false); 
        toolBar->EnableTool(Par_PrintPre, false); 
        toolBar->EnableTool(Par_Cut, false); 
        toolBar->EnableTool(Par_Copy, false); 
        toolBar->EnableTool(Par_Paste, false); 
        toolBar->EnableTool(Par_Undo, false); 
        toolBar->EnableTool(Par_Redo, false); 
        toolBar->EnableTool(Par_Find, false); 
        toolBar->EnableTool(Par_FindNex, false); 
        toolBar->EnableTool(Par_Replace, false); 
        hlt->Enable(false); 
    } 
 
    else if (enable) 
    { 
        fileMenu->Enable(Par_Save, true); 
        fileMenu->Enable(Par_SaveAs, true); 
        fileMenu->Enable(Par_SaveAll, true); 
        fileMenu->Enable(Par_Print, true); 
        //fileMenu->Enable(Par_PrintPre, true); 
        //fileMenu->Enable(Par_Export, true); 
        editMenu->Enable(Par_Undo, true); 
        editMenu->Enable(Par_Redo, true); 
        editMenu->Enable(Par_Cut, true); 
        editMenu->Enable(Par_Copy, true); 
        editMenu->Enable(Par_Paste, true); 
        editMenu->Enable(Par_SelAll, true); 
        searchMenu->Enable(Par_Find, true); 
        searchMenu->Enable(Par_Replace, true); 
        searchMenu->Enable(Par_FindNex, true); 
        searchMenu->Enable(Par_FindPre, true); 
        searchMenu->Enable(Par_GoToLine, true); 
        searchMenu->Enable(Par_ToggleBookMark, true); 
        searchMenu->Enable(Par_NextBookMark, true); 
        searchMenu->Enable(Par_PrevBookMark, true); 
        searchMenu->Enable(Par_RemoveAllBookMarks, true); 
        formatMenu->Enable(Par_Indent, true); 
        formatMenu->Enable(Par_Unindent, true); 
        formatMenu->Enable(Par_Upper, true); 
        formatMenu->Enable(Par_Lower, true); 
        formatMenu->Enable(Par_SortText, true); 
        //formatMenu->Enable(Par_Comment, true); 
        formatMenu->Enable(Par_Insert, true); 
        viewMenu->Enable (Par_Refresh, true); 
        viewMenu->Enable(Par_MatchBrace, true); 
        viewMenu->Enable(Par_ReadOnly, true); 
        toolsMenu->Enable(Par_Compile, true); 
        toolsMenu->Enable(Par_Build, true); 
        toolsMenu->Enable(Par_Run, true); 
        toolsMenu->Enable(Par_LineEndings, true); 
        //optionsMenu->Enable(Par_EnvOptions, true); 
        //optionsMenu->Enable(Par_CodeTemps, true); 
        //optionsMenu->Enable(Par_UseTabs, true); 
        optionsMenu->Enable(Par_WordWrap, true); 
        //helpMenu->Enable(Par_Update, true); 
 
        toolBar->EnableTool(Par_Save, true); 
        toolBar->EnableTool(Par_SaveAll, true); 
        toolBar->EnableTool(Par_Close, true); 
        toolBar->EnableTool(Par_Print, true); 
        //toolBar->EnableTool(Par_PrintPre, true); 
        toolBar->EnableTool(Par_Cut, true); 
        toolBar->EnableTool(Par_Copy, true); 
        toolBar->EnableTool(Par_Paste, true); 
        toolBar->EnableTool(Par_Undo, true); 
        toolBar->EnableTool(Par_Redo, true); 
        toolBar->EnableTool(Par_Find, true); 
        toolBar->EnableTool(Par_FindNex, true); 
        toolBar->EnableTool(Par_Replace, true); 
        hlt->Enable(true); 
    } 
} 
 
bool Parent::Exec(const wxString &fileName, int execNum) 
{ 
    wxString fileExt; 
    wxSplitPath(fileName, NULL, NULL, &fileExt); 
 
    #ifdef __WXMSW__ 
    const wxString execPath = opt->GetPath() + "\\Misc\\Exec.cfg"; 
    #else 
    const wxString execPath = opt->GetPath() + "/Misc/Exec.cfg"; 
    #endif 
 
    if (cWin->GetTitle() == "Untitled" || cWin->GetTitle() == "Untitled*") 
    { 
        wxMessageBox("Please save the file before attempting to\n" 
                     "execute it.", "File not saved.", wxOK | wxICON_INFORMATION, this); 
        return false; 
    } 
 
    if (!wxFileExists(execPath)) 
    { 
        ShowError("Exec.cfg does not exist.", "Exec.cfg not found"); 
        return false; 
    } 
 
    Execute exec(fileName); 
 
    if (!exec.ReadCommand(execPath, fileExt, execNum)) 
    { 
        ShowError("An error occured while reading Exec.cfg", "Error Reading Exec.cfg"); 
        return false; 
    } 
 
    if (!exec.Exec()) 
    { 
        ShowError("An error occured while attempting to execute the file", "Execution Error"); 
        return false; 
    } 
 
    return true; 
} 
 
void Parent::Exit(wxCommandEvent &WXUNUSED(event)) 
{ 
    Close(true); 
} 
 
void Parent::Find(wxCommandEvent &WXUNUSED(event)) 
{ 
    searchMenu->Enable(Par_Find, false); 
    searchMenu->Enable(Par_Replace, false); 
 
    if (cWin->text->HasSelection()) 
        fData->SetFindString(cWin->text->GetSelectedText()); 
 
    else 
        fData->SetFindString(cWin->text->GetTextUnderCursor()); 
 
    fDialog = new wxFindReplaceDialog(this, fData, "Find Text", 0); 
    fDialog->Show(); 
} 
 
void Parent::FindAgain(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->FindNext(); 
} 
 
void Parent::FindButton(wxFindDialogEvent &event) 
{ 
    int flags = 0; 
 
    if (event.GetFlags() & wxFR_WHOLEWORD) 
        flags += wxSTC_FIND_WHOLEWORD; 
 
    if (event.GetFlags() & wxFR_MATCHCASE) 
        flags += wxSTC_FIND_MATCHCASE; 
 
    if (event.GetFlags() & wxFR_DOWN)  // Search Down 
        cWin->text->FindNextOccurence(event.GetFindString(), flags); 
 
    else  // Search Up 
        cWin->text->FindPreviousOccurence(event.GetFindString(), flags); 
} 
 
void Parent::FindClose(wxFindDialogEvent &event) 
{ 
    if (event.GetDialog() == fDialog) 
    { 
        //fData->SetFlags(event.GetFlags()); 
        delete fDialog; 
        fDialog = NULL; 
    } 
 
    else if (event.GetDialog() == rDialog) 
    { 
        //rData->SetFlags(event.GetFlags()); 
        delete rDialog; 
        rDialog = NULL; 
    } 
 
    searchMenu->Enable(Par_Find, true); 
    searchMenu->Enable(Par_Replace, true); 
} 
 
void Parent::FindNext(wxFindDialogEvent &event) 
{ 
    int flags = 0; 
 
    if (event.GetFlags() & wxFR_WHOLEWORD) 
        flags += wxSTC_FIND_WHOLEWORD; 
 
    if (event.GetFlags() & wxFR_MATCHCASE) 
        flags += wxSTC_FIND_MATCHCASE; 
 
    if (event.GetFlags() & wxFR_DOWN)  // Search Down 
        cWin->text->FindNextOccurence(event.GetFindString(), flags); 
 
    else  // Search Up 
        cWin->text->FindPreviousOccurence(event.GetFindString(), flags); 
} 
 
void Parent::FindPrevious(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->FindPrevious(); 
} 
 
int Parent::GetHighlighterIndex() 
{ 
    wxString hil = cWin->GetHil(); 
 
    if (hil == "C++") return 1; 
    else if (hil == "Config") return 2; 
    else if (hil == "Dos Batch") return 3; 
    else if (hil == "Fortran") return 4; 
    else if (hil == "HTML") return 5; 
    else if (hil == "Java") return 6; 
    else if (hil == "Javascript") return 7; 
    else if (hil == "Makefile") return 8; 
    else if (hil == "Pascal") return 9; 
    else if (hil == "Perl") return 10; 
    else if (hil == "PHP") return 11; 
    else if (hil == "Python") return 12; 
    else if (hil == "Ruby") return 13; 
    else if (hil == "SQL") return 14; 
    else if (hil == "Tcl/Tk") return 15; 
    else if (hil == "Text") return 0; 
    else if (hil == "Visual Basic") return 17; 
    else if (hil == "Windows Resource") return 18; 
    else if (hil == "x86 Assembler") return 19; 
    else if (hil == "XML") return 20; 
    else return 0; 
} 
 
void Parent::GoToLine(wxCommandEvent &WXUNUSED(event)) 
{ 
    long lineNum = wxGetNumberFromUser("", "Go To Line Number:", 
                                       "Go To Line", cWin->text->GetY() + 1, 1, 
                                       cWin->text->GetLineCount(), 
                                       this, wxDefaultPosition); 
 
    if (lineNum != -1) 
    { 
        lineNum--; 
        cWin->text->GotoLine(lineNum); 
    } 
} 
 
void Parent::Help(wxCommandEvent &WXUNUSED(event)) 
{ 
    #ifdef __WXMSW__ 
    if (!wxFileExists(opt->GetPath() + "\\Documentation\\Help.chm")) 
    { 
        ShowError("Unable to find the help file.", "Help file not found"); 
        return; 
    } 
 
    wxExecute("C:\\WINDOWS\\hh.exe " + opt->GetPath() + "\\Documentation\\Help.chm", false, NULL); 
    #endif 
    /*wxHtmlHelpController help(wxHF_FLAT_TOOLBAR | wxHF_CONTENTS | 
    wxHF_INDEX | wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT); 
    help.Initialize("Help.htb"); 
    help.DisplayContents();*/ 
} 
 
wxString Parent::HilFromName(wxString fileName) 
{ 
    wxString ext; 
    wxSplitPath(fileName, NULL, NULL, &ext); 
    ext.MakeLower(); 
 
    if (ext.Last() == '*') 
        ext.RemoveLast(); 
 
    else if (ext == "bas" || ext == "vbs" || ext == "frm" || ext == "cls") 
        return "Visual Basic"; 
 
    else if (ext == "cpp" || ext == "cc" || ext == "cp" || ext == "c" || ext == "cxx" || ext == "hpp" || ext == "h") 
        return "C++"; 
 
    else if (ext == "bat") 
        return "Dos Batch"; 
 
    else if (ext == "for") 
        return "Fortran"; 
 
    else if (ext == "html" || ext == "htm" || ext == "asp" || ext == "shtml") 
        return "HTML"; 
 
    else if (ext == "ini" || ext == "cfg") 
        return "Text"; 
 
    else if (ext == "java" || ext == "jav") 
        return "Java"; 
 
    else if (ext == "js") 
        return "Javascript"; 
 
    else if (ext == "pas" || ext == "dpr" || ext == "dpk" || ext == "inc" || ext == "pp") 
        return "Pascal"; 
 
    else if (ext == "pl" || ext == "pm" || ext == "cgi") 
        return "Perl"; 
 
    else if (ext == "php" || ext == "php3" || ext == "phtml") 
        return "PHP"; 
 
    else if (ext == "py") 
        return "Python"; 
         
    else if (ext == "rb" || ext == "rbw") 
        return "Ruby"; 
 
    else if (ext == "sql") 
        return "SQL"; 
 
    else if (ext == "tcl") 
        return "Tcl/Tk"; 
 
    else if (ext == "txt" || ext == "log") 
        return "Text"; 
 
    else if (ext == "rc") 
        return "Text"; 
 
    else if (ext == "asm") 
        return "x86 Assembler"; 
 
    else if (ext == "xml" || ext == "xsd" || ext == "xsl" || ext == "xslt") 
        return "XML"; 
 
    else 
        return "Text"; 
} 
 
void Parent::Indent(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->CmdKeyExecute(wxSTC_CMD_TAB); 
} 
 
inline void Parent::InitMenus() 
{ 
    // Export Menu 
    exportMenu = new wxMenu; 
    exportMenu->Append(Par_ExpHTML, "To HTML"); 
    exportMenu->Append(Par_ExpRTF, "To RTF"); 
     
    // Line Endings Menu 
    lineEndingMenu = new wxMenu; 
    lineEndingMenu->AppendRadioItem(Par_ConvertCRLF, "Windows (CRLF)"); 
    lineEndingMenu->AppendRadioItem(Par_ConvertLF, "Unix (LF)"); 
    lineEndingMenu->AppendRadioItem(Par_ConvertCR, "Macintosh (CR)"); 
 
    // Insert Menu 
    insertMenu = new wxMenu; 
    insertMenu->Append(Par_InsDT, "&Date/Time\tCtrl+Ins"); 
 
    // File Menu 
    fileMenu = new wxMenu; 
    fileMenu->Append(Par_NewFile, "&New\tCtrl+N"); 
    fileMenu->Append(Par_Open, "&Open...\tCtrl+O"); 
    fileMenu->Append(Par_Save, "&Save\tCtrl+S"); 
    fileMenu->Append(Par_SaveAs, "Save &As...\tShift+Ctrl+S"); 
    fileMenu->Append(Par_SaveAll, "Save All Files"); 
    fileMenu->AppendSeparator(); 
    fileMenu->Append(Par_Print, "&Print...\tCtrl+P"); 
    //fileMenu->Append(Par_PrintPre, "P&rint Preview..."); 
    fileMenu->Append(Par_Ps, "Pa&ge Setup..."); 
    //fileMenu->AppendSeparator(); 
    //fileMenu->Append(Par_Export, "Export", exportMenu); 
    fileMenu->AppendSeparator(); 
    fileMenu->Append(Par_Exit, "E&xit\tAlt+X"); 
 
    // Edit Menu 
    editMenu = new wxMenu; 
    editMenu->Append(Par_Undo, "&Undo\tCtrl+Z"); 
    editMenu->Append(Par_Redo, "&Redo\tShift+Ctrl+Z"); 
    editMenu->AppendSeparator(); 
 
    editMenu->Append(Par_Cut, "Cu&t\tCtrl+X"); 
    editMenu->Append(Par_Copy, "&Copy\tCtrl+C"); 
    editMenu->Append(Par_Paste, "&Paste\tCtrl+V"); 
    editMenu->Append(Par_SelAll, "Select &All\tCtrl+A"); 
 
    // Search Menu 
    searchMenu = new wxMenu; 
    searchMenu->Append(Par_Find, "&Find...\tCtrl+F"); 
    searchMenu->Append(Par_Replace, "Replace...\tCtrl+R"); 
    searchMenu->Append(Par_FindNex, "Find &Next\tF3"); 
    searchMenu->Append(Par_FindPre, "Find Pr&evious\tShift+F3"); 
    searchMenu->AppendSeparator(); 
    searchMenu->Append(Par_GoToLine, "Go To Line...\tCtrl+G"); 
    searchMenu->AppendSeparator(); 
    searchMenu->Append(Par_NextBookMark, "Next Bookmark\tF2"); 
    searchMenu->Append(Par_PrevBookMark, "Previous Bookmark\tShift+F2"); 
    searchMenu->Append(Par_ToggleBookMark, "Toggle Bookmark\tCtrl+F2"); 
    searchMenu->Append(Par_RemoveAllBookMarks, "Remove All Bookmarks"); 
 
    // Format Menu 
    formatMenu = new wxMenu; 
    formatMenu->Append(Par_Indent, "&Indent Block\tShift+Ctrl+I"); 
    formatMenu->Append(Par_Unindent, "&Unindent Block\tShift+Ctrl+U"); 
    formatMenu->AppendSeparator(); 
    formatMenu->Append(Par_Upper, "To U&pper Case\tCtrl+F5"); 
    formatMenu->Append(Par_Lower, "To &Lower Case\tAlt+F5"); 
    formatMenu->AppendSeparator(); 
    formatMenu->Append(Par_SortText, "&Sort Text\tCtrl+F4"); 
    formatMenu->AppendSeparator(); 
    formatMenu->Append(Par_Comment, "&Comment Code\tShift+Ctrl+C"); 
    formatMenu->Append(Par_Insert, "Insert", insertMenu); 
 
    // View Menu 
    viewMenu = new wxMenu; 
    viewMenu->Append(Par_MatchBrace, "Show Matching Brace\tCtrl+M"); 
    viewMenu->AppendSeparator(); 
    viewMenu->AppendCheckItem(Par_ReadOnly, "Read Only"); 
 
    // Project Menu 
    projectMenu = new wxMenu; 
    projectMenu->Append(Par_NewProj, "&New Project..."); 
    projectMenu->Append(Par_OpenProj, "&Open Project..."); 
    projectMenu->Append(Par_CloseProj, "&Close Project"); 
    projectMenu->AppendSeparator(); 
    projectMenu->Append(Par_AddProj, "&Add Files To Project..."); 
    projectMenu->AppendSeparator(); 
    projectMenu->Append(Par_ProjOption, "&Project Options..."); 
    projectMenu->Append(Par_ToDo, "&To Do List...\tCtrl+T"); 
 
    // Tools Menu 
    toolsMenu = new wxMenu; 
    toolsMenu->Append(Par_Compile, "&Compile\tCtrl+F9"); 
    toolsMenu->Append(Par_Build, "&Build\tF9"); 
    toolsMenu->Append(Par_Run, "&Run\tShift+F9"); 
    toolsMenu->AppendSeparator(); 
    toolsMenu->Append(Par_LineEndings, "Line Endings", lineEndingMenu); 
 
    // Options Menu 
    optionsMenu = new wxMenu; 
    optionsMenu->Append(Par_EnvOptions, "&Environment Options..."); 
    optionsMenu->Append(Par_CodeTemps, "&Code Templates..."); 
    optionsMenu->AppendSeparator(); 
    optionsMenu->AppendCheckItem(Par_UseTabs, "Use &Tabs"); 
    optionsMenu->AppendSeparator(); 
    optionsMenu->AppendCheckItem(Par_WordWrap, "&Word Wrap"); 
    #ifdef __WXMSW__ 
    optionsMenu->AppendCheckItem(Par_AlwaysTop, "&Always On Top"); 
    #endif 
 
    // Help Menu 
    helpMenu = new wxMenu; 
    helpMenu->Append(Par_CustomHelp, "&Help...\tF1"); 
    helpMenu->AppendSeparator(); 
    helpMenu->Append(Par_Help, pName + " He&lp..."); 
    helpMenu->Append(Par_Update, "Check For &Updates..."); 
    helpMenu->AppendSeparator(); 
    helpMenu->Append(Par_About, "&About..."); 
 
    // Window Menu 
    wxMenuItem *closeAll = new wxMenuItem(GetWindowMenu(), Par_CloseAll, "Close All Windows"); 
    wxMenuItem *sep = new wxMenuItem(GetWindowMenu()); 
 
    GetWindowMenu()->Insert(0, closeAll); 
    GetWindowMenu()->Insert(1, sep); 
 
    delete closeAll; 
    delete sep; 
 
    // Append menus to menubar 
    menuBar = new wxMenuBar(); 
    menuBar->Append(fileMenu, "&File"); 
    menuBar->Append(editMenu, "&Edit"); 
    menuBar->Append(searchMenu, "&Search"); 
    menuBar->Append(formatMenu, "For&mat"); 
    menuBar->Append(viewMenu, "&View"); 
    menuBar->Append(projectMenu, "&Project"); 
    menuBar->Append(toolsMenu, "&Tools"); 
    menuBar->Append(optionsMenu, "&Options"); 
    menuBar->Append(helpMenu, "&Help"); 
 
    SetMenuBar(menuBar); 
} 
 
inline void Parent::InitToolbar() 
{ 
    toolBar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, 
                            wxTB_FLAT | wxTB_HORIZONTAL); 
 
    SetToolBar(toolBar); 
 
    wxBitmap *toolBarIcons[15]; 
 
    toolBarIcons[0] = new wxBitmap("new"); 
    toolBarIcons[1] = new wxBitmap("open"); 
    toolBarIcons[2] = new wxBitmap("save"); 
    toolBarIcons[3] = new wxBitmap("saveall"); 
    toolBarIcons[4] = new wxBitmap("close"); 
 
    toolBarIcons[5] = new wxBitmap("print"); 
    toolBarIcons[6] = new wxBitmap("printpreview"); 
 
    toolBarIcons[7] = new wxBitmap("cut"); 
    toolBarIcons[8] = new wxBitmap("copy"); 
    toolBarIcons[9] = new wxBitmap("paste"); 
    toolBarIcons[10] = new wxBitmap("undo"); 
    toolBarIcons[11] = new wxBitmap("redo"); 
 
    toolBarIcons[12] = new wxBitmap("find"); 
    toolBarIcons[13] = new wxBitmap("findnext"); 
    toolBarIcons[14] = new wxBitmap("replace"); 
 
    int toolWidth = 24; 
    int currentX = 5; 
 
    toolBar->AddSeparator(); 
    toolBar->AddTool(Par_NewFile, *(toolBarIcons[0]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "New file"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Open, *(toolBarIcons[1]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Open file"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Save, *(toolBarIcons[2]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Save file"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_SaveAll, *(toolBarIcons[3]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Save All files"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Close, *(toolBarIcons[4]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Close file"); 
    currentX += toolWidth + 5; 
    toolBar->AddSeparator(); 
 
    toolBar->AddTool(Par_Print, *(toolBarIcons[5]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Print"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_PrintPre, *(toolBarIcons[6]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Print Preview"); 
    currentX += toolWidth + 5; 
    toolBar->AddSeparator(); 
 
    toolBar->AddTool(Par_Cut, *(toolBarIcons[7]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Cut"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Copy, *(toolBarIcons[8]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Copy"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Paste, *(toolBarIcons[9]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Paste"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Undo, *(toolBarIcons[10]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Undo"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Redo, *(toolBarIcons[11]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Redo"); 
    currentX += toolWidth + 5; 
    toolBar->AddSeparator(); 
 
    toolBar->AddTool(Par_Find, *(toolBarIcons[12]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Find"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_FindNex, *(toolBarIcons[13]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Find Next"); 
    currentX += toolWidth + 5; 
    toolBar->AddTool(Par_Replace, *(toolBarIcons[14]), wxNullBitmap, false, currentX, -1, (wxObject *) NULL, "Replace"); 
    currentX += toolWidth + 5; 
    toolBar->AddSeparator(); 
 
    for (int i = 0; i < 15; i++) 
        delete toolBarIcons[i]; 
 
    hlt = new wxChoice(toolBar, Par_Lang); 
    hlt->Append("C++"); 
    hlt->Append("Dos Batch"); 
    hlt->Append("Fortran"); 
    hlt->Append("HTML"); 
    hlt->Append("Java"); 
    hlt->Append("Javascript"); 
    hlt->Append("Pascal"); 
    hlt->Append("Perl"); 
    hlt->Append("PHP"); 
    hlt->Append("Python"); 
    hlt->Append("Ruby"); 
    hlt->Append("SQL"); 
    hlt->Append("Tcl/Tk"); 
    hlt->Append("Text"); 
    hlt->Append("Visual Basic"); 
    hlt->Append("x86 Assembler"); 
    hlt->Append("XML"); 
    hlt->SetStringSelection("Text"); 
 
    toolBar->AddControl(hlt); 
     
    toolBar->Realize(); 
} 
 
void Parent::InsDT(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxDateTime dt; 
    dt = wxDateTime::Now(); 
 
    wxString time = dt.Format("%x %I:%M:%S %p"); 
    cWin->text->AddText(time); 
} 
 
void Parent::InsTemplate(wxCommandEvent &WXUNUSED(event)) 
{ 
    CodeTemplate ct; 
    int start, end; 
    wxString cText; 
    wxString tp; 
 
    cWin->text->BeginUndoAction(); 
    cText = cWin->text->GetTextUnderCursor(start, end); 
 
    const wxString tpFile = opt->GetPath() + "\\Templates\\" + hlt->GetStringSelection() + ".tpl"; 
 
    if (wxFileExists(tpFile) && ((tp = ct.GetTemplate(tpFile, cText)) != "")) 
    { 
        ct.AlignTemplate(tp, cWin->text->GetLineIndentation(cWin->text->GetCurrentLine())); 
        int pos = ct.FindInsertionPoint(tp); 
        cWin->text->ReplaceText(start, end, tp); 
        if (pos != -1) cWin->text->GotoPos(cWin->text->GetCurrentPos()+pos); 
    } 
    cWin->text->EndUndoAction(); 
} 
 
void Parent::LoadHil(const wxString &hil) 
{ 
    if (GetHil() == "Text") 
        formatMenu->Enable(Par_Comment, false); 
 
    else 
        formatMenu->Enable(Par_Comment, true); 
 
    // Constant Colors 
    const wxColour lightBlue(49, 106, 197); 
    const wxColour green(0, 128, 0); 
    const wxColour blue(0, 0, 255); 
    const wxColour purple(128, 0, 128); 
    const wxColour red(255, 0, 0); 
    const wxColour black(0, 0, 0); 
    const wxColour darkBlue(0, 0, 128); 
    const wxColour teal(0, 128, 128); 
    const wxColour orange(128, 128, 0); 
 
    cWin->text->StyleClearAll(); 
    cWin->text->StyleSetBold(wxSTC_STYLE_BRACELIGHT, true); 
    cWin->text->StyleSetBold(wxSTC_STYLE_BRACEBAD, true); 
    cWin->text->StyleSetForeground(wxSTC_STYLE_DEFAULT, black); 
    cWin->text->StyleSetForeground(wxSTC_STYLE_LINENUMBER, black); 
    cWin->text->StyleSetForeground(wxSTC_STYLE_BRACELIGHT, blue); 
    cWin->text->StyleSetForeground(wxSTC_STYLE_BRACEBAD, red); 
 
    if (hil == "C++") 
    { 
        syn->Initialize(CPP); 
        cWin->text->SetLexer(wxSTC_LEX_CPP); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
        cWin->text->SetKeyWords(2, syn->GetKeyWords(2)); 
 
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Dos Batch") 
    { 
        syn->Initialize(DosBatch); 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        //cWin->text->SetLexer(wxSTC_LEX_BATCH); 
        cWin->text->SetLexer(wxSTC_LEX_NULL); 
 
        cWin->text->StyleSetBold(wxSTC_BAT_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_BAT_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_BAT_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_BAT_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_BAT_LABEL, black); 
        cWin->text->StyleSetForeground(wxSTC_BAT_HIDE, black); 
        cWin->text->StyleSetForeground(wxSTC_BAT_COMMAND, black); 
        cWin->text->StyleSetForeground(wxSTC_BAT_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_BAT_OPERATOR, black); 
    } 
 
    if (hil == "Fortran") 
    { 
        syn->Initialize(Fortran); 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->SetLexer(wxSTC_LEX_FORTRAN); 
 
        cWin->text->StyleSetBold(wxSTC_F_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_F_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_F_WORD3, true); 
        cWin->text->StyleSetForeground(wxSTC_F_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_F_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_F_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_F_STRING1, red); 
        cWin->text->StyleSetForeground(wxSTC_F_STRING2, red); 
        cWin->text->StyleSetForeground(wxSTC_F_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_F_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_F_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_F_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_F_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_F_WORD3, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_F_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_F_OPERATOR2, black); 
        cWin->text->StyleSetForeground(wxSTC_F_LABEL, black); 
        cWin->text->StyleSetForeground(wxSTC_F_CONTINUATION, black); 
    } 
 
    if (hil == "HTML")  ///< \todo Fix PHP highlighting 
    { 
        syn->Initialize(HTML); 
        cWin->text->SetLexer(wxSTC_LEX_HTML); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
        cWin->text->SetKeyWords(4, syn->GetKeyWords(4)); 
 
        cWin->text->StyleSetBold(wxSTC_H_TAG, true); 
        cWin->text->StyleSetBold(wxSTC_H_ATTRIBUTE, true); 
        cWin->text->StyleSetForeground(wxSTC_H_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_H_TAG, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_TAGUNKNOWN, black); 
        cWin->text->StyleSetForeground(wxSTC_H_ATTRIBUTE, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_ATTRIBUTEUNKNOWN, black); 
        cWin->text->StyleSetForeground(wxSTC_H_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_H_DOUBLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_H_SINGLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_H_OTHER, black); 
        cWin->text->StyleSetForeground(wxSTC_H_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_ENTITY, purple); 
 
        cWin->text->StyleSetBold(wxSTC_HPHP_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_HSTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_SIMPLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_VARIABLE, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_HSTRING_VARIABLE, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_OPERATOR, black); 
    } 
 
    if (hil == "Java") 
    { 
        syn->Initialize(Java); 
        cWin->text->SetLexer(wxSTC_LEX_CPP); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Javascript") 
    { 
        syn->Initialize(Javascript); 
        cWin->text->SetLexer(wxSTC_LEX_CPP); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Pascal") 
    { 
        syn->Initialize(Pascal); 
        cWin->text->SetLexer(wxSTC_LEX_PASCAL); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, red); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Perl") 
    { 
        syn->Initialize(Perl); 
        cWin->text->SetLexer(wxSTC_LEX_PERL); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_PL_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_PL_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_ERROR, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_PL_POD, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_PL_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_PL_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_PL_PUNCTUATION, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_PL_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_SCALAR, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_ARRAY, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_HASH, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_SYMBOLTABLE, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_PL_REGSUBST, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_LONGQUOTE, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_BACKTICKS, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_DATASECTION, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_HERE_DELIM, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_HERE_Q, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_HERE_QQ, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_HERE_QX, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING_Q, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING_QQ, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING_QX, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING_QR, black); 
        cWin->text->StyleSetForeground(wxSTC_PL_STRING_QW, black); 
    } 
 
    if (hil == "PHP") 
    { 
        syn->Initialize(PHP); 
        //cWin->text->SetLexer(wxSTC_LEX_PHP);    // PHP highlighting doesn't work correctly 
        cWin->text->SetLexer(wxSTC_LEX_NULL); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_HPHP_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_HSTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_SIMPLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_VARIABLE, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_HSTRING_VARIABLE, black); 
        cWin->text->StyleSetForeground(wxSTC_HPHP_OPERATOR, black); 
    } 
 
    if (hil == "Python") 
    { 
        syn->Initialize(Python); 
        cWin->text->SetLexer(wxSTC_LEX_PYTHON); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_P_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_P_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_P_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_P_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_P_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_TRIPLE, black); 
        cWin->text->StyleSetForeground(wxSTC_P_TRIPLEDOUBLE, black); 
        cWin->text->StyleSetForeground(wxSTC_P_CLASSNAME, black); 
        cWin->text->StyleSetForeground(wxSTC_P_DEFNAME, purple); 
        cWin->text->StyleSetForeground(wxSTC_P_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_P_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_P_COMMENTBLOCK, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_STRINGEOL, black); 
    } 
 
    if (hil == "Ruby") 
    { 
        syn->Initialize(Ruby); 
        cWin->text->SetLexer(wxSTC_LEX_RUBY); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
         
        cWin->text->StyleSetBold(wxSTC_P_WORD, true); 
        cWin->text->StyleSetForeground(wxSTC_P_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_P_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_P_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_P_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_TRIPLE, black); 
        cWin->text->StyleSetForeground(wxSTC_P_TRIPLEDOUBLE, black); 
        cWin->text->StyleSetForeground(wxSTC_P_CLASSNAME, black); 
        cWin->text->StyleSetForeground(wxSTC_P_DEFNAME, purple); 
        cWin->text->StyleSetForeground(wxSTC_P_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_P_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_P_COMMENTBLOCK, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_P_STRINGEOL, black); 
    } 
 
    if (hil == "SQL") 
    { 
        syn->Initialize(SQL); 
        cWin->text->SetLexer(wxSTC_LEX_SQL); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Tcl/Tk") 
    { 
        syn->Initialize(TclTk); 
         
        cWin->text->SetLexer(wxSTC_LEX_TCL); 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
         
        cWin->text->StyleSetBold(wxSTC_C_WORD, true); 
        cWin->text->StyleSetBold(wxSTC_C_WORD2, true); 
        cWin->text->StyleSetBold(wxSTC_C_COMMENTDOCKEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_C_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINE, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_C_CHARACTER, purple); 
        cWin->text->StyleSetForeground(wxSTC_C_UUID, teal); 
        cWin->text->StyleSetForeground(wxSTC_C_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_C_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_C_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_C_STRINGEOL, red); 
        cWin->text->StyleSetForeground(wxSTC_C_VERBATIM, black); 
        cWin->text->StyleSetForeground(wxSTC_C_REGEX, orange); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTLINEDOC, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_WORD2, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORD, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_C_COMMENTDOCKEYWORDERROR, black); 
    } 
 
    if (hil == "Text") 
    { 
        syn->Initialize(Text); 
        cWin->text->SetLexer(wxSTC_LEX_NULL); 
    } 
 
    if (hil == "Visual Basic") 
    { 
        syn->Initialize(VisualBasic); 
        cWin->text->SetLexer(wxSTC_LEX_VB); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_B_KEYWORD, true); 
        cWin->text->StyleSetForeground(wxSTC_B_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_B_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_B_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_B_KEYWORD, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_B_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_B_PREPROCESSOR, green); 
        cWin->text->StyleSetForeground(wxSTC_B_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_B_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_B_DATE, black); 
    } 
 
    if (hil == "x86 Assembler") 
    { 
        syn->Initialize(x86); 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->SetLexer(wxSTC_LEX_ASM); 
 
        cWin->text->StyleSetBold(wxSTC_ASM_CPUINSTRUCTION, true); 
        cWin->text->StyleSetBold(wxSTC_ASM_MATHINSTRUCTION, true); 
        cWin->text->StyleSetForeground(wxSTC_ASM_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_ASM_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_ASM_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_ASM_STRING, red); 
        cWin->text->StyleSetForeground(wxSTC_ASM_OPERATOR, black); 
        cWin->text->StyleSetForeground(wxSTC_ASM_IDENTIFIER, black); 
        cWin->text->StyleSetForeground(wxSTC_ASM_CPUINSTRUCTION, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_ASM_MATHINSTRUCTION, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_ASM_REGISTER, black); 
        cWin->text->StyleSetForeground(wxSTC_ASM_DIRECTIVE, black); 
        cWin->text->StyleSetForeground(wxSTC_ASM_DIRECTIVEOPERAND, black); 
    } 
 
    if (hil == "XML") 
    { 
        syn->Initialize(XML); 
        cWin->text->SetLexer(wxSTC_LEX_XML); 
 
        cWin->text->SetKeyWords(0, syn->GetKeyWords()); 
 
        cWin->text->StyleSetBold(wxSTC_H_TAG, true); 
        cWin->text->StyleSetBold(wxSTC_H_ATTRIBUTE, true); 
        cWin->text->StyleSetForeground(wxSTC_H_DEFAULT, black); 
        cWin->text->StyleSetForeground(wxSTC_H_TAG, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_TAGUNKNOWN, black); 
        cWin->text->StyleSetForeground(wxSTC_H_ATTRIBUTE, darkBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_ATTRIBUTEUNKNOWN, black); 
        cWin->text->StyleSetForeground(wxSTC_H_NUMBER, teal); 
        cWin->text->StyleSetForeground(wxSTC_H_DOUBLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_H_SINGLESTRING, red); 
        cWin->text->StyleSetForeground(wxSTC_H_OTHER, black); 
        cWin->text->StyleSetForeground(wxSTC_H_COMMENT, lightBlue); 
        cWin->text->StyleSetForeground(wxSTC_H_ENTITY, purple); 
 
        cWin->text->StyleSetForeground(wxSTC_H_TAGEND, black); 
        cWin->text->StyleSetForeground(wxSTC_H_XMLSTART, black); 
        cWin->text->StyleSetForeground(wxSTC_H_XMLEND, black); 
    } 
 
    cWin->text->Colourise(0, cWin->text->GetLength()-1); 
} 
 
void Parent::Lower(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->MakeLower(); 
} 
 
void Parent::MatchBrace(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->ShowMatchingBrace(cWin->text->GetCurrentPos()); 
} 
 
inline void Parent::NewFile(wxCommandEvent &WXUNUSED(event)) 
{ 
    CreateChild("Untitled"); 
} 
 
void Parent::NewProj(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxFileDialog *newProjDialog = new wxFileDialog 
                                  (this, "Create a new project", "", "", PrjTypes, 
                                   wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR); 
 
    if (newProjDialog->ShowModal() == wxID_OK) 
    { 
        proj->Create(wxFileNameFromPath(newProjDialog->GetPath()), newProjDialog->GetPath()); 
        proj->Load(newProjDialog->GetPath()); 
        UpdateMenus(); 
    } 
 
    delete newProjDialog; 
} 
 
void Parent::NextBookMark(wxCommandEvent &event) 
{ 
    cWin->text->ShowNextBookMark(cWin->text->GetCurrentLine()); 
} 
 
void Parent::OnHighlighterChange(wxCommandEvent &event) 
{ 
    LoadHil(event.GetString()); 
    cWin->SetHil(event.GetString()); 
    cWin->text->SetFocus(); 
} 
 
void Parent::OnWindowClose(wxCloseEvent& event) 
{ 
    status->SetStatus(ClosingProgram); 
    Command(Par_CloseAll); 
 
    if (event.CanVeto() && status->NeedVeto()) // Close needs to be vetoed 
    { 
        status->SetIdle(); 
        status->SetVeto(false); 
        event.Veto(); 
        return; 
    } 
 
    opt->Write(); 
    event.Skip(); 
} 
 
void Parent::Open(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxFileDialog *openDialog = new wxFileDialog 
                               (this, "Open a file", "", "", Types, 
                               wxOPEN | wxMULTIPLE | wxHIDE_READONLY | wxCHANGE_DIR); 
 
    if (openDialog->ShowModal() == wxID_OK) 
    { 
        wxArrayString fileNames; 
        openDialog->GetPaths(fileNames); 
 
        OpenFiles(fileNames); 
    } 
 
    delete openDialog; 
} 
 
inline void Parent::OpenFile(const wxString &fileName) 
{ 
    CreateChild(wxFileNameFromPath(fileName)); 
    cWin->text->LoadFile(fileName); 
    cWin->SetFilename(fileName); 
    cWin->SetHil(HilFromName(fileName)); 
    cWin->UpdateModTime(); 
} 
 
inline void Parent::OpenFiles(const wxArrayString &files) 
{ 
    status->SetStatus(OpeningWindows); 
    for (unsigned int i = 0; i < files.GetCount(); i++) 
    { 
        OpenFile(files[i]); 
        if (i == files.GetCount() - 1) SetHil(HilFromName(files[i])); 
    } 
    status->SetIdle(); 
} 
 
void Parent::OpenProject(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxFileDialog *openProjDialog = new wxFileDialog 
                                   (this, "Open a project", "", "", PrjTypes, 
                                   wxOPEN | wxHIDE_READONLY | wxCHANGE_DIR); 
 
    if (openProjDialog->ShowModal() == wxID_OK) 
    { 
        Command(Par_CloseProj); 
        proj->Load(openProjDialog->GetPath()); 
 
        status->SetStatus(OpeningWindows); 
        for (int i = 0; i < proj->GetNumFiles(); i++) 
        { 
            OpenFile(proj->GetFile(i)); 
 
            proj->AddFrame(cWin); 
            cWin->SetHil(HilFromName(proj->GetFile(i))); 
 
            // If this is the last file set the correct highlighter 
            if (i == proj->GetNumFiles() - 1) SetHil(HilFromName(proj->GetFile(i))); 
        } 
        status->SetIdle(); 
        UpdateMenus(); 
    } 
 
    delete openProjDialog; 
} 
 
void Parent::PageSetup(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxPageSetupDialog *pageSetup = new wxPageSetupDialog(this, psData); 
    pageSetup->ShowModal(); 
 
    *pData = pageSetup->GetPageSetupData().GetPrintData(); 
    *psData = pageSetup->GetPageSetupData(); 
 
    delete pageSetup; 
} 
 
void Parent::Paste(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->Paste(); 
} 
 
void Parent::PreviousBookMark(wxCommandEvent &event) 
{ 
    cWin->text->ShowPreviousBookMark(cWin->text->GetCurrentLine()); 
} 
 
void Parent::Print(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxPrintDialogData pDialogData(*pData); 
    pDialogData.EnablePrintToFile(true); 
 
    wxPrinter printer(&pDialogData); 
    Printout printout(cWin->GetFilename(), cWin); 
    printer.Print(this, &printout, true); 
} 
 
void Parent::PrintPreview(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxPrintDialogData pDialogData(*pData); 
    Printout printout(cWin->GetFilename(), cWin); 
    Printout printoutForPrinting(cWin->GetFilename(), cWin); 
 
    wxPrintPreview printPreview(&printout, &printoutForPrinting, &pDialogData); 
 
    if (!printPreview.Ok()) 
    { 
        ShowError("An error occured while attempting to preview the document.", 
        "Print Preview Error"); 
        return; 
    } 
 
    wxPreviewFrame previewFrame(&printPreview, this, "Print Preview"); 
    previewFrame.Initialize(); 
    previewFrame.Show(); 
} 
 
void Parent::ReadOnly(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (!cWin->text->GetReadOnly()) 
    { 
        cWin->text->SetReadOnly(true); 
        viewMenu->Check(Par_ReadOnly, true); 
        return; 
    } 
 
    else if (cWin->text->GetReadOnly()) 
    { 
        cWin->text->SetReadOnly(false); 
        viewMenu->Check(Par_ReadOnly, false); 
        return; 
    } 
} 
 
void Parent::Redo(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->Redo(); 
} 
 
void Parent::RemoveBookMarks(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->RemoveAllBookMarks(); 
} 
 
void Parent::Replace(wxCommandEvent &WXUNUSED(event)) 
{ 
    searchMenu->Enable(Par_Find, false); 
    searchMenu->Enable(Par_Replace, false); 
 
    if (cWin->text->HasSelection()) 
        rData->SetFindString(cWin->text->GetSelectedText()); 
 
    else 
        rData->SetFindString(cWin->text->GetTextUnderCursor()); 
 
    rDialog = new wxFindReplaceDialog(this, rData, 
                                      "Replace Text", wxFR_REPLACEDIALOG); 
    rDialog->Show(); 
} 
 
void Parent::ReplaceAll(wxFindDialogEvent &event) 
{ 
    int flags = 0; 
 
    if (event.GetFlags() & wxFR_WHOLEWORD) 
        flags += wxSTC_FIND_WHOLEWORD; 
 
    if (event.GetFlags() & wxFR_MATCHCASE) 
        flags += wxSTC_FIND_MATCHCASE; 
 
    cWin->text->ReplaceAll(event.GetFindString(), event.GetReplaceString(), flags); 
} 
 
void Parent::ReplaceSel(wxFindDialogEvent &event) 
{ 
    int flags = 0; 
 
    if (event.GetFlags() & wxFR_WHOLEWORD) 
        flags += wxSTC_FIND_WHOLEWORD; 
 
    if (event.GetFlags() & wxFR_MATCHCASE) 
        flags += wxSTC_FIND_MATCHCASE; 
 
    cWin->text->Replace(event.GetFindString(), event.GetReplaceString(), flags); 
} 
 
void Parent::Run(wxCommandEvent &WXUNUSED(event)) 
{ 
    Exec(cWin->GetFilename(), 3); 
} 
 
void Parent::Save(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (cWin->GetTitle() != "Untitled" && cWin->GetTitle() != "Untitled*") 
    { 
        cWin->text->SaveFile(cWin->GetFilename()); 
        cWin->SetTitle(wxFileNameFromPath(cWin->GetFilename())); 
        UpdateMenus(); 
        cWin->UpdateModTime(); 
    } 
 
    else 
        Command(Par_SaveAs); 
} 
 
void Parent::SaveAll(wxCommandEvent &WXUNUSED(event)) 
{ 
    for (unsigned int i = 0; i < cFrames.GetCount(); i++) 
    { 
        if (cFrames[i]->GetFilename() != "Untitled") 
        { 
            cFrames[i]->text->SaveFile(cFrames[i]->GetFilename()); 
            cFrames[i]->SetTitle(wxFileNameFromPath(cFrames[i]->GetFilename())); 
            cFrames[i]->UpdateModTime(); 
            continue; 
        } 
 
        else if (cFrames[i]->GetFilename() == "Untitled") 
        { 
            cFrames[i]->wxMDIChildFrame::Activate(); 
            Command(Par_SaveAs); 
        } 
    } 
 
    UpdateMenus(); 
} 
 
void Parent::SaveAs(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxFileDialog *saveAsDialog = new wxFileDialog 
                                 (this, "Save file as", "", "", Types, 
                                 wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR); 
 
    saveAsDialog->SetFilterIndex(GetHighlighterIndex()); 
 
    if (saveAsDialog->ShowModal() == wxID_OK) 
    { 
        cWin->text->SaveFile(saveAsDialog->GetPath()); 
        cWin->SetFilename(saveAsDialog->GetPath()); 
        cWin->SetTitle(saveAsDialog->GetFilename()); 
        cWin->UpdateModTime(); 
    } 
 
    delete saveAsDialog; 
    UpdateMenus(); 
} 
 
void Parent::SelAll(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->SelectAll(); 
} 
 
void Parent::SetHil(const wxString &hil, bool load = true) 
{ 
    hlt->SetStringSelection(hil); 
    if (load) LoadHil(hil); 
} 
 
void Parent::ShowError(const wxString &error = "", const wxString &title = "") 
{ 
    wxMessageBox(error, title, wxOK | wxICON_ERROR, this); 
} 
 
void Parent::SortText(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->SortSelection(); 
} 
 
void Parent::ToggleBookMark(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->ToggleBookMark(cWin->text->GetCurrentLine()); 
} 
 
void Parent::Undo(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->Undo(); 
} 
 
void Parent::Unindent(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->CmdKeyExecute(wxSTC_CMD_BACKTAB); 
} 
 
void Parent::Update(wxCommandEvent &WXUNUSED(event)) 
{ 
    wxURL verFile(website + "/ver.txt"); 
    wxInputStream *input; 
    wxOutputStream outStream; 
    wxString verString; 
 
    if (verFile.GetError() != wxURL_NOERR) 
    { 
        ShowError("An error occured while checking for updates.", "Update error"); 
        return; 
    } 
 
    input = verFile.GetInputStream(); 
 
    if (!input) 
    { 
        ShowError("An error occured while processing input.", "Update error"); 
        return; 
    } 
 
    input->Read(outStream); 
    wxDataOutputStream dataOutput(outStream); 
    dataOutput.WriteString(verString); 
    //ShowError("|||" + verString + "|||"); // Uncomment for debugging 
    delete input; 
 
    int newVersion = verString.CmpNoCase(ver); 
 
    if (newVersion < 0)   // Current version is newer than the one on the website 
        wxMessageBox("You have the most recent version.\n" 
                     "(Please e-mail Matt and tell\n him to update his\n" 
                     "website with the new version information)", 
                     "No newer version available", wxOK | wxICON_INFORMATION, this); 
 
    if (newVersion == 0)  // Current version is the most recent 
        wxMessageBox("You have the most recent version.", 
                     "No newer version available", wxOK | wxICON_INFORMATION, this); 
 
    if (newVersion > 0)   // Current version is older than the one on the website 
    { 
        int download = wxMessageBox("A new version is available.\n" 
                                    "Do you wish to download the new version?", 
                                    "New version available", wxYES_NO | wxICON_INFORMATION, this); 
 
        if (download == wxYES) 
            #ifdef __WXMSW__ 
            wxExecute("explorer " + website); 
            #else 
            wxExecute("mozilla " + website); 
            #endif 
    } 
} 
 
inline void Parent::UpdateMenus() 
{ 
    if (cFrames.GetCount() > 0) 
    { 
        if (cWin->text->GetModify() || cWin->GetTitle().Contains("*")) 
        { 
            fileMenu->Enable(Par_Save, true); 
            toolBar->EnableTool(Par_Save, true); 
        } 
 
        else 
        { 
            fileMenu->Enable(Par_Save, false); 
            toolBar->EnableTool(Par_Save, false); 
        } 
         
        if (cWin->text->GetEOLMode() == CRLF) 
            lineEndingMenu->Check(Par_ConvertCRLF, true); 
         
        else if (cWin->text->GetEOLMode() == CR) 
            lineEndingMenu->Check(Par_ConvertCR, true); 
             
        else if (cWin->text->GetEOLMode() == LF) 
            lineEndingMenu->Check(Par_ConvertLF, true); 
 
        if (cWin->text->CanUndo()) 
        { 
            editMenu->Enable(Par_Undo, true); 
            toolBar->EnableTool(Par_Undo, true); 
        } 
 
        else 
        { 
            editMenu->Enable(Par_Undo, false); 
            toolBar->EnableTool(Par_Undo, false); 
        } 
 
        if (cWin->text->CanRedo()) 
        { 
            editMenu->Enable(Par_Redo, true); 
            toolBar->EnableTool(Par_Redo, true); 
        } 
 
        else 
        { 
            editMenu->Enable(Par_Redo, false); 
            toolBar->EnableTool(Par_Redo, false); 
        } 
 
        if (cWin->text->HasSelection()) 
        { 
            editMenu->Enable(Par_Cut, true); 
            editMenu->Enable(Par_Copy, true); 
            formatMenu->Enable(Par_Indent, true); 
            formatMenu->Enable(Par_Unindent, true); 
 
            toolBar->EnableTool(Par_Cut, true); 
            toolBar->EnableTool(Par_Copy, true); 
        } 
 
        else 
        { 
            editMenu->Enable(Par_Cut, false); 
            editMenu->Enable(Par_Copy, false); 
            formatMenu->Enable(Par_Indent, false); 
            formatMenu->Enable(Par_Unindent, false); 
 
            toolBar->EnableTool(Par_Cut, false); 
            toolBar->EnableTool(Par_Copy, false); 
        } 
 
        if (cWin->text->CanPaste()) 
        { 
            editMenu->Enable(Par_Paste, true); 
            toolBar->EnableTool(Par_Paste, true); 
        } 
 
        else 
        { 
            editMenu->Enable(Par_Paste, false); 
            toolBar->EnableTool(Par_Paste, false); 
        } 
 
        if (cWin->text->HasText()) 
            editMenu->Enable(Par_SelAll, true); 
 
        else 
            editMenu->Enable(Par_SelAll, false); 
 
        if (!cWin->text->GetReadOnly()) 
            viewMenu->Check(Par_ReadOnly, false); 
 
        else 
            viewMenu->Check(Par_ReadOnly, true); 
 
        if (!cWin->text->GetWrapMode()) 
            optionsMenu->Check(Par_WordWrap, false); 
 
        else 
            optionsMenu->Check(Par_WordWrap, true); 
    } 
                 
    if (opt->GetUseTabs()) 
        optionsMenu->Check(Par_UseTabs, true); 
     
    else     
        optionsMenu->Check(Par_UseTabs, false); 
 
    if (proj->IsOpen()) 
    { 
        projectMenu->Enable(Par_CloseProj, true); 
        projectMenu->Enable(Par_AddProj, true); 
        //projectMenu->Enable(Par_ProjOption, true);   // Uncomment when these features are implemented 
        //projectMenu->Enable(Par_ToDo, true); 
    } 
 
    else 
    { 
        projectMenu->Enable(Par_CloseProj, false); 
        projectMenu->Enable(Par_AddProj, false); 
        projectMenu->Enable(Par_ProjOption, false); 
        projectMenu->Enable(Par_ToDo, false); 
    } 
} 
 
void Parent::Upper(wxCommandEvent &WXUNUSED(event)) 
{ 
    cWin->text->MakeUpper(); 
} 
 
void Parent::UseTabs(wxCommandEvent &WXUNUSED(event)) 
{ 
    bool useTabs; 
     
    if (opt->GetUseTabs()) 
    { 
        optionsMenu->Check(Par_UseTabs, false); 
        useTabs = false; 
    } 
         
    else 
    { 
        optionsMenu->Check(Par_UseTabs, true); 
        useTabs = true; 
    } 
         
    opt->SetUseTabs(useTabs); 
         
    for (unsigned int i = 0; i < cFrames.GetCount(); i++) 
        if (cFrames[i]->text->GetUseTabs() != useTabs) 
            cFrames[i]->text->SetUseTabs(useTabs); 
} 
 
void Parent::WordWrap(wxCommandEvent &WXUNUSED(event)) 
{ 
    if (cWin->text->GetWrapMode() == wxSTC_WRAP_NONE) 
    { 
        cWin->text->SetWrapMode(wxSTC_WRAP_WORD); 
        optionsMenu->Check(Par_WordWrap, true); 
    } 
 
    else 
    { 
        cWin->text->SetWrapMode(wxSTC_WRAP_NONE); 
        optionsMenu->Check(Par_WordWrap, false); 
    } 
} 
 
BEGIN_EVENT_TABLE(Parent, wxMDIParentFrame) 
    EVT_CHOICE(Par_Lang, Parent::OnHighlighterChange) 
    EVT_CLOSE(Parent::OnWindowClose) 
    EVT_FIND(-1, Parent::FindButton) 
    EVT_FIND_CLOSE(-1, Parent::FindClose) 
    EVT_FIND_NEXT(-1, Parent::FindNext) 
    EVT_FIND_REPLACE(-1, Parent::ReplaceSel) 
    EVT_FIND_REPLACE_ALL(-1, Parent::ReplaceAll) 
    EVT_MENU(Par_About, Parent::About) 
    EVT_MENU(Par_AddProj, Parent::AddToProj) 
    #ifdef __WXMSW__ 
    EVT_MENU(Par_AlwaysTop, Parent::AlwaysOnTop) 
    #endif 
    EVT_MENU(Par_Build, Parent::Build) 
    EVT_MENU(Par_Close, Parent::CloseChild) 
    EVT_MENU(Par_CloseAll, Parent::CloseAll) 
    EVT_MENU(Par_CloseProj, Parent::CloseProj) 
    EVT_MENU(Par_Comment, Parent::Comment) 
    EVT_MENU(Par_Compile, Parent::Compile) 
    EVT_MENU(Par_ConvertCR, Parent::ConvertCR) 
    EVT_MENU(Par_ConvertCRLF, Parent::ConvertCRLF) 
    EVT_MENU(Par_ConvertLF, Parent::ConvertLF) 
    EVT_MENU(Par_Copy, Parent::Copy) 
    EVT_MENU(Par_Cut, Parent::Cut) 
    EVT_MENU(Par_Exit, Parent::Exit) 
    EVT_MENU(Par_Find, Parent::Find) 
    EVT_MENU(Par_FindNex, Parent::FindAgain) 
    EVT_MENU(Par_FindPre, Parent::FindPrevious) 
    EVT_MENU(Par_GoToLine, Parent::GoToLine) 
    EVT_MENU(Par_Help, Parent::Help) 
    EVT_MENU(Par_Indent, Parent::Indent) 
    EVT_MENU(Par_InsDT, Parent::InsDT) 
    EVT_MENU(Par_InsTempl, Parent::InsTemplate) 
    EVT_MENU(Par_Lower, Parent::Lower) 
    EVT_MENU(Par_MatchBrace, Parent::MatchBrace) 
    EVT_MENU(Par_NewFile, Parent::NewFile) 
    EVT_MENU(Par_NewProj, Parent::NewProj) 
    EVT_MENU(Par_NextBookMark, Parent::NextBookMark) 
    EVT_MENU(Par_Open, Parent::Open) 
    EVT_MENU(Par_OpenProj, Parent::OpenProject) 
    EVT_MENU(Par_Paste, Parent::Paste) 
    EVT_MENU(Par_PrevBookMark, Parent::PreviousBookMark) 
    EVT_MENU(Par_Print, Parent::Print) 
    EVT_MENU(Par_PrintPre, Parent::PrintPreview) 
    EVT_MENU(Par_Ps, Parent::PageSetup) 
    EVT_MENU(Par_ReadOnly, Parent::ReadOnly) 
    EVT_MENU(Par_Redo, Parent::Redo) 
    EVT_MENU(Par_RemoveAllBookMarks, Parent::RemoveBookMarks) 
    EVT_MENU(Par_Replace, Parent::Replace) 
    EVT_MENU(Par_Run, Parent::Run) 
    EVT_MENU(Par_Save, Parent::Save) 
    EVT_MENU(Par_SaveAll, Parent::SaveAll) 
    EVT_MENU(Par_SaveAs, Parent::SaveAs) 
    EVT_MENU(Par_SelAll, Parent::SelAll) 
    EVT_MENU(Par_SortText, Parent::SortText) 
    EVT_MENU(Par_ToggleBookMark, Parent::ToggleBookMark) 
    EVT_MENU(Par_Undo, Parent::Undo) 
    EVT_MENU(Par_Unindent, Parent::Unindent) 
    EVT_MENU(Par_Update, Parent::Update) 
    EVT_MENU(Par_Upper, Parent::Upper) 
    EVT_MENU(Par_UseTabs, Parent::UseTabs) 
    EVT_MENU(Par_WordWrap, Parent::WordWrap) 
END_EVENT_TABLE()