~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
3
 * http://www.gnu.org/licenses/gpl-3.0.html
4
4
 *
5
 
 * $Revision: 4909 $
6
 
 * $Id: main.cpp 4909 2008-02-27 13:15:26Z mortenmacfly $
7
 
 * $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/src/main.cpp $
 
5
 * $Revision: 6206 $
 
6
 * $Id: main.cpp 6206 2010-05-01 08:37:51Z jenslody $
 
7
 * $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/src/main.cpp $
8
8
 */
9
9
 
10
10
#include <sdk.h>
58
58
#include "batchbuild.h"
59
59
#include <wx/printdlg.h>
60
60
#include <wx/filename.h>
61
 
#include <wx/wxFlatNotebook/wxFlatNotebook.h>
 
61
#include "cbauibook.h"
62
62
 
63
63
#include "uservarmanager.h"
64
64
#include "infowindow.h"
 
65
#include "notebookstyles.h"
 
66
#include "switcherdlg.h"
65
67
 
66
68
class wxMyFileDropTarget : public wxFileDropTarget
67
69
{
69
71
    wxMyFileDropTarget(MainFrame *frame):m_frame(frame){}
70
72
    virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames)
71
73
    {
72
 
        if(!m_frame) return false;
 
74
        if (!m_frame) return false;
73
75
        return m_frame->OnDropFiles(x,y,filenames);
74
76
    }
75
77
private:
131
133
 
132
134
int idEditUndo = XRCID("idEditUndo");
133
135
int idEditRedo = XRCID("idEditRedo");
 
136
int idEditClearHistory = XRCID("idEditClearHistory");
134
137
int idEditCopy = XRCID("idEditCopy");
135
138
int idEditCut = XRCID("idEditCut");
136
139
int idEditPaste = XRCID("idEditPaste");
207
210
int idViewStatusbar = XRCID("idViewStatusbar");
208
211
int idViewScriptConsole = XRCID("idViewScriptConsole");
209
212
int idViewFocusEditor = XRCID("idViewFocusEditor");
 
213
int idViewSwitchTabs = XRCID("idViewSwitchTabs");
210
214
int idViewFullScreen = XRCID("idViewFullScreen");
211
215
 
212
216
int idSearchFind = XRCID("idSearchFind");
216
220
int idSearchReplace = XRCID("idSearchReplace");
217
221
int idSearchReplaceInFiles = XRCID("idSearchReplaceInFiles");
218
222
int idSearchGotoLine = XRCID("idSearchGotoLine");
 
223
int idSearchGotoNextChanged = XRCID("idSearchGotoNextChanged");
 
224
int idSearchGotoPreviousChanged = XRCID("idSearchGotoPreviousChanged");
219
225
 
220
226
int idSettingsEnvironment = XRCID("idSettingsEnvironment");
221
227
int idSettingsGlobalUserVars = XRCID("idSettingsGlobalUserVars");
262
268
 
263
269
    EVT_UPDATE_UI(idEditUndo, MainFrame::OnEditMenuUpdateUI)
264
270
    EVT_UPDATE_UI(idEditRedo, MainFrame::OnEditMenuUpdateUI)
 
271
    EVT_UPDATE_UI(idEditClearHistory, MainFrame::OnEditMenuUpdateUI)
265
272
    EVT_UPDATE_UI(idEditCopy, MainFrame::OnEditMenuUpdateUI)
266
273
    EVT_UPDATE_UI(idEditCut, MainFrame::OnEditMenuUpdateUI)
267
274
    EVT_UPDATE_UI(idEditPaste, MainFrame::OnEditMenuUpdateUI)
295
302
    EVT_UPDATE_UI(idSearchReplace, MainFrame::OnSearchMenuUpdateUI)
296
303
    EVT_UPDATE_UI(idSearchReplaceInFiles, MainFrame::OnSearchMenuUpdateUI)
297
304
    EVT_UPDATE_UI(idSearchGotoLine, MainFrame::OnSearchMenuUpdateUI)
 
305
    EVT_UPDATE_UI(idSearchGotoNextChanged, MainFrame::OnSearchMenuUpdateUI)
 
306
    EVT_UPDATE_UI(idSearchGotoPreviousChanged, MainFrame::OnSearchMenuUpdateUI)
298
307
 
299
308
    EVT_UPDATE_UI(idViewToolMain, MainFrame::OnViewMenuUpdateUI)
300
309
    EVT_UPDATE_UI(idViewLogManager, MainFrame::OnViewMenuUpdateUI)
345
354
 
346
355
    EVT_MENU(idEditUndo,  MainFrame::OnEditUndo)
347
356
    EVT_MENU(idEditRedo,  MainFrame::OnEditRedo)
 
357
    EVT_MENU(idEditClearHistory,  MainFrame::OnEditClearHistory)
348
358
    EVT_MENU(idEditCopy,  MainFrame::OnEditCopy)
349
359
    EVT_MENU(idEditCut,  MainFrame::OnEditCut)
350
360
    EVT_MENU(idEditPaste,  MainFrame::OnEditPaste)
409
419
    EVT_MENU(idSearchReplace, MainFrame::OnSearchReplace)
410
420
    EVT_MENU(idSearchReplaceInFiles, MainFrame::OnSearchReplace)
411
421
    EVT_MENU(idSearchGotoLine, MainFrame::OnSearchGotoLine)
 
422
    EVT_MENU(idSearchGotoNextChanged, MainFrame::OnSearchGotoNextChanged)
 
423
    EVT_MENU(idSearchGotoPreviousChanged, MainFrame::OnSearchGotoPrevChanged)
412
424
 
413
425
    EVT_MENU(idViewLayoutSave, MainFrame::OnViewLayoutSave)
414
426
    EVT_MENU(idViewLayoutDelete, MainFrame::OnViewLayoutDelete)
418
430
    EVT_MENU(idViewStatusbar, MainFrame::OnToggleStatusBar)
419
431
    EVT_MENU(idViewScriptConsole, MainFrame::OnViewScriptConsole)
420
432
    EVT_MENU(idViewFocusEditor, MainFrame::OnFocusEditor)
 
433
    EVT_MENU(idViewSwitchTabs, MainFrame::OnSwitchTabs)
421
434
    EVT_MENU(idViewFullScreen, MainFrame::OnToggleFullScreen)
422
435
 
423
436
    EVT_MENU(idSettingsEnvironment, MainFrame::OnSettingsEnvironment)
453
466
       m_pEdMan(0L),
454
467
       m_pPrjMan(0L),
455
468
       m_pMsgMan(0L),
456
 
       infoPane(0),
 
469
       m_pInfoPane(0L),
457
470
       m_pToolbar(0L),
458
471
       m_ToolsMenu(0L),
459
472
       m_HelpPluginsMenu(0L),
460
473
       m_StartupDone(false), // one-time flag
461
474
       m_InitiatedShutdown(false),
462
 
       m_AutoHideLogs(false),
463
475
       m_AutoHideLockCounter(0),
464
476
       m_LastLayoutIsTemp(false),
465
477
       m_pScriptConsole(0),
524
536
 
525
537
    ShowHideStartPage();
526
538
 
527
 
    // create script console (if needed)
528
 
    if (Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/show_script_console"), false))
529
 
        ShowHideScriptConsole();
530
 
 
531
539
    RegisterScriptFunctions();
532
540
    RunStartupScripts();
533
541
 
534
 
    m_StartupDone = true;
535
 
    DoUpdateLayout();
 
542
//    m_StartupDone = true;
 
543
//    DoUpdateLayout();
536
544
 
537
545
//    if (Manager::Get()->GetLogManager()->HasErrors())
538
546
//    {
624
632
    wxSize clientsize = GetClientSize();
625
633
 
626
634
    // Create CloseFullScreen Button, and hide it initially
627
 
    m_pCloseFullScreenBtn = new wxButton(this, idCloseFullScreen, _( "Close Fullscreen" ), wxDefaultPosition );
 
635
    m_pCloseFullScreenBtn = new wxButton(this, idCloseFullScreen, _( "Close full screen" ), wxDefaultPosition );
628
636
    m_pCloseFullScreenBtn->Show( false );
629
637
 
630
638
    // project manager
650
658
    m_LayoutManager.AddPane(m_pEdMan->GetNotebook(), wxAuiPaneInfo().Name(wxT("MainPane")).
651
659
                            CentrePane());
652
660
 
 
661
    m_pScriptConsole = new ScriptConsole(this, -1);
 
662
    m_LayoutManager.AddPane(m_pScriptConsole, wxAuiPaneInfo().Name(wxT("ScriptConsole")).
 
663
                            Caption(_("Scripting console")).Float().MinSize(100,100));
 
664
 
653
665
    DoUpdateLayout();
654
666
    DoUpdateLayoutColours();
655
667
    DoUpdateEditorStyle();
661
673
 
662
674
void MainFrame::SetupGUILogging()
663
675
{
664
 
    m_AutoHideLogs = Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_hide"), false);
 
676
    // allow new docked windows to use be 3/4 of the available space, the default (0.3) is sometimes too small, especially for "Logs & others"
 
677
    m_LayoutManager.SetDockSizeConstraint(0.75,0.75);
665
678
 
666
679
    int bottomH = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/main_frame/layout/bottom_block_height"), 150);
667
680
    wxSize clientsize = GetClientSize();
668
681
 
669
682
    LogManager* mgr = Manager::Get()->GetLogManager();
670
683
 
671
 
    if(!Manager::IsBatchBuild())
 
684
    if (!Manager::IsBatchBuild())
672
685
    {
673
 
        infoPane = new InfoPane(this);
674
 
        m_LayoutManager.AddPane(infoPane, wxAuiPaneInfo().
 
686
        m_pInfoPane = new InfoPane(this);
 
687
        m_LayoutManager.AddPane(m_pInfoPane, wxAuiPaneInfo().
675
688
                                  Name(wxT("MessagesPane")).Caption(_("Logs & others")).
676
689
                                  BestSize(wxSize(clientsize.GetWidth(), bottomH)).//MinSize(wxSize(50,50)).
677
690
                                  Bottom());
680
693
 
681
694
        for(size_t i = LogManager::app_log; i < ::max_logs; ++i)
682
695
        {
683
 
            if((log = mgr->Slot(i).GetLogger()->CreateControl(infoPane)))
684
 
                infoPane->AddLogger(mgr->Slot(i).GetLogger(), log, mgr->Slot(i).title, mgr->Slot(i).icon);
 
696
            if ((log = mgr->Slot(i).GetLogger()->CreateControl(m_pInfoPane)))
 
697
                m_pInfoPane->AddLogger(mgr->Slot(i).GetLogger(), log, mgr->Slot(i).title, mgr->Slot(i).icon);
685
698
        }
686
699
    }
687
700
    else
688
701
    {
689
702
        m_pBatchBuildDialog = new BatchLogWindow(this, _("Batch build"));
690
703
        wxSizer* s = new wxBoxSizer(wxVERTICAL);
691
 
        infoPane = new InfoPane(m_pBatchBuildDialog);
692
 
        s->Add(infoPane, 1, wxEXPAND);
 
704
        m_pInfoPane = new InfoPane(m_pBatchBuildDialog);
 
705
        s->Add(m_pInfoPane, 1, wxEXPAND);
693
706
        m_pBatchBuildDialog->SetSizer(s);
694
707
 
695
708
        // setting &g_null_log causes the app to crash on exit for some reason...
698
711
    }
699
712
 
700
713
    mgr->NotifyUpdate();
701
 
    infoPane->SetDropTarget(new wxMyFileDropTarget(this));
 
714
    m_pInfoPane->SetDropTarget(new wxMyFileDropTarget(this));
702
715
}
703
716
 
704
717
 
740
753
                    else if (!se.menu.IsEmpty())
741
754
                        Manager::Get()->GetScriptingManager()->RegisterScriptMenu(se.menu, startup, false);
742
755
                    else
 
756
                    #if wxCHECK_VERSION(2, 9, 0)
 
757
                        Manager::Get()->GetLogManager()->LogWarning(F(_("Startup script/function '%s' not loaded: invalid configuration"), se.script.wx_str()));
 
758
                    #else
743
759
                        Manager::Get()->GetLogManager()->LogWarning(F(_("Startup script/function '%s' not loaded: invalid configuration"), se.script.c_str()));
 
760
                    #endif
744
761
                }
745
762
                else
 
763
                #if wxCHECK_VERSION(2, 9, 0)
 
764
                    Manager::Get()->GetLogManager()->LogWarning(F(_("Startup script '%s' not found"), se.script.wx_str()));
 
765
                #else
746
766
                    Manager::Get()->GetLogManager()->LogWarning(F(_("Startup script '%s' not found"), se.script.c_str()));
 
767
                #endif
747
768
            }
748
769
            catch (SquirrelError& exception)
749
770
            {
825
846
    wxXmlResource *myres = wxXmlResource::Get();
826
847
    myres->Load(resPath + _T("/resources.zip#zip:main_menu.xrc"));
827
848
    mbar = myres->LoadMenuBar(_T("main_menu_bar"));
828
 
    if(!mbar)
829
 
    {
830
 
      mbar = new wxMenuBar(); // Some error happened.
831
 
      SetMenuBar(mbar);
832
 
    }
 
849
    if (!mbar)
 
850
        mbar = new wxMenuBar(); // Some error happened.
 
851
    if (mbar)
 
852
        SetMenuBar(mbar);
833
853
 
834
854
    // Find Menus that we'll change later
835
855
 
836
856
    tmpidx=mbar->FindMenu(_("&Edit"));
837
 
    if(tmpidx!=wxNOT_FOUND)
 
857
    if (tmpidx!=wxNOT_FOUND)
838
858
    {
839
859
        mbar->FindItem(idEditHighlightModeText, &hl);
840
860
        if (hl)
859
879
    }
860
880
 
861
881
    tmpidx=mbar->FindMenu(_("&Tools"));
862
 
    if(tmpidx!=wxNOT_FOUND)
 
882
    if (tmpidx!=wxNOT_FOUND)
863
883
        tools = mbar->GetMenu(tmpidx);
864
884
 
865
885
    tmpidx=mbar->FindMenu(_("P&lugins"));
866
 
    if(tmpidx!=wxNOT_FOUND)
 
886
    if (tmpidx!=wxNOT_FOUND)
867
887
        plugs = mbar->GetMenu(tmpidx);
868
888
 
869
 
    if((tmpitem = mbar->FindItem(idHelpPlugins,NULL)))
 
889
    if ((tmpitem = mbar->FindItem(idHelpPlugins,NULL)))
870
890
        pluginsM = tmpitem->GetSubMenu();
871
891
 
872
892
    m_ToolsMenu = tools ? tools : new wxMenu();
907
927
 
908
928
    Manager::Get()->GetToolsManager()->BuildToolsMenu(m_ToolsMenu);
909
929
 
 
930
    // Ctrl+Tab workaround for non windows platforms:
 
931
    if ((platform::carbon) || (platform::gtk))
 
932
    {
 
933
        // Find the menu item for tab switching:
 
934
        tmpidx = mbar->FindMenu(_("&View"));
 
935
        if (tmpidx != wxNOT_FOUND)
 
936
        {
 
937
            wxMenu* view = mbar->GetMenu(tmpidx);
 
938
            wxMenuItem* switch_item = view->FindItem(idViewSwitchTabs);
 
939
            if (switch_item)
 
940
            {
 
941
                // Change the accelerator for this menu item:
 
942
                wxString accel;
 
943
                if (platform::carbon)
 
944
                    accel = wxT("Alt+Tab");
 
945
                else if (platform::gtk)
 
946
                    accel = wxT("Ctrl+,");
 
947
                switch_item->SetItemLabel(wxString(_("S&witch Tabs")) + wxT("\t") + accel);
 
948
            }
 
949
        }
 
950
    }
 
951
 
910
952
    SetMenuBar(mbar);
911
953
    InitializeRecentFilesHistory();
912
954
 
926
968
 
927
969
    wxString resPath = ConfigManager::GetDataFolder();
928
970
    wxString xrcToolbarName = _T("main_toolbar");
929
 
    if(m_SmallToolBar) // Insert logic here
 
971
    if (m_SmallToolBar) // Insert logic here
930
972
        xrcToolbarName += _T("_16x16");
931
973
    myres->Load(resPath + _T("/resources.zip#zip:*.xrc"));
932
974
    Manager::Get()->GetLogManager()->DebugLog(_T("Loading toolbar..."));
1020
1062
 
1021
1063
    while(!item)
1022
1064
    {
1023
 
        if(!pos || title.CmpNoCase(menu->FindItemByPosition(pos - 1)->GetLabel()) > 0)
 
1065
        #if wxCHECK_VERSION(2, 9, 0)
 
1066
        if (!pos || title.CmpNoCase(menu->FindItemByPosition(pos - 1)->GetItemLabelText()) > 0)
 
1067
        #else
 
1068
        if (!pos || title.CmpNoCase(menu->FindItemByPosition(pos - 1)->GetLabel()) > 0)
 
1069
        #endif
1024
1070
            item = menu->Insert(pos, id, title, wxEmptyString, checkable ? wxITEM_CHECK : wxITEM_NORMAL);
1025
1071
 
1026
1072
        --pos;
1047
1093
 
1048
1094
void MainFrame::AddPluginInSettingsMenu(cbPlugin* plugin)
1049
1095
{
1050
 
//    if(!plugin)
 
1096
//    if (!plugin)
1051
1097
//        return;
1052
1098
//    if (!plugin->GetInfo()->hasConfigure)
1053
1099
//        return;
1111
1157
 
1112
1158
    // load manager and messages selected page
1113
1159
    Manager::Get()->GetProjectManager()->GetNotebook()->SetSelection(Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/main_frame/layout/left_block_selection"), 0));
1114
 
    infoPane->SetSelection(Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/main_frame/layout/bottom_block_selection"), 0));
 
1160
    m_pInfoPane->SetSelection(Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/main_frame/layout/bottom_block_selection"), 0));
1115
1161
 
1116
1162
#ifndef __WXMAC__
1117
1163
    int x = 0;
1141
1187
{
1142
1188
    DoCheckCurrentLayoutForChanges(false);
1143
1189
 
 
1190
    // first delete all previos layouts, otherwise they might remain
 
1191
    // if the new amount of layouts is less than the previous, because only the first layouts will be overwritten
 
1192
    wxArrayString subs = Manager::Get()->GetConfigManager(_T("app"))->EnumerateSubPaths(_T("/main_frame/layout"));
 
1193
    for (size_t i = 0; i < subs.GetCount(); ++i)
 
1194
    {
 
1195
        Manager::Get()->GetConfigManager(_T("app"))->DeleteSubPath(_T("/main_frame/layout/") + subs[i]);
 
1196
    }
 
1197
 
1144
1198
    int count = 0;
1145
1199
    for (LayoutViewsMap::iterator it = m_LayoutViews.begin(); it != m_LayoutViews.end(); ++it)
1146
1200
    {
1154
1208
 
1155
1209
    // save manager and messages selected page
1156
1210
    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/left_block_selection"), Manager::Get()->GetProjectManager()->GetNotebook()->GetSelection());
1157
 
    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/bottom_block_selection"), infoPane->GetSelection());
 
1211
    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/bottom_block_selection"), m_pInfoPane->GetSelection());
1158
1212
 
1159
1213
    // save window size and position
1160
1214
    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/maximized"), IsMaximized());
1172
1226
    if (m_LastLayoutName != name && !DoCheckCurrentLayoutForChanges(true))
1173
1227
        return;
1174
1228
 
1175
 
        m_LastLayoutIsTemp = isTemp;
1176
 
        
 
1229
    m_LastLayoutIsTemp = isTemp;
 
1230
 
1177
1231
    wxString layout = m_LayoutViews[name];
1178
1232
    if (layout.IsEmpty())
1179
1233
    {
1205
1259
    if (viewLayouts && viewLayouts->FindItem(name) == wxNOT_FOUND)
1206
1260
    {
1207
1261
        int id = wxNewId();
1208
 
        viewLayouts->InsertCheckItem(viewLayouts->GetMenuItemCount() - 3, id, name, wxString::Format(_("Switch to %s layout"), name.c_str()));
 
1262
        viewLayouts->InsertCheckItem(viewLayouts->GetMenuItemCount() - 3, id, name, wxString::Format(_("Switch to %s perspective"), name.c_str()));
1209
1263
        Connect( id,  wxEVT_COMMAND_MENU_SELECTED,
1210
1264
            (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction)&MainFrame::OnViewLayout);
1211
1265
        m_PluginIDsMap[id] = name;
1220
1274
bool MainFrame::LayoutDifferent(const wxString& layout1,const wxString& layout2,const wxString& delimiter)
1221
1275
{
1222
1276
    wxStringTokenizer strTok;
 
1277
    unsigned long j;
1223
1278
 
1224
1279
    strTok.SetString(layout1, delimiter);
1225
1280
    wxArrayString arLayout1;
1229
1284
        while(strTokColon.HasMoreTokens())
1230
1285
        {
1231
1286
            wxString theToken = strTokColon.GetNextToken();
1232
 
            if (!theToken.StartsWith(_T("state="))) arLayout1.Add(theToken);
 
1287
            if (theToken.StartsWith(_T("state=")))
 
1288
            {
 
1289
                theToken=theToken.Right(theToken.Len() - wxString(_T("state=")).Len());
 
1290
                theToken.ToULong(&j);
 
1291
                // we filter out the hidden/show state
 
1292
                theToken=wxString::Format(_("state=%d"),j & wxAuiPaneInfo::optionHidden);
 
1293
            }
 
1294
               arLayout1.Add(theToken);
1233
1295
        }
1234
1296
    }
1235
1297
 
1241
1303
        while(strTokColon.HasMoreTokens())
1242
1304
        {
1243
1305
            wxString theToken = strTokColon.GetNextToken();
1244
 
            if (!theToken.StartsWith(_T("state="))) arLayout2.Add(theToken);
 
1306
            if (theToken.StartsWith(_T("state=")))
 
1307
            {
 
1308
                theToken=theToken.Right(theToken.Len() - wxString(_T("state=")).Len());
 
1309
                theToken.ToULong(&j);
 
1310
                // we filter out the hidden/show state
 
1311
                theToken=wxString::Format(_("state=%d"),j & wxAuiPaneInfo::optionHidden);
 
1312
            }
 
1313
               arLayout2.Add(theToken);
1245
1314
        }
1246
1315
    }
1247
1316
 
1258
1327
    if (!m_LastLayoutName.IsEmpty() && LayoutDifferent(lastlayout, m_LastLayoutData))
1259
1328
    {
1260
1329
        AnnoyingDialog dlg(_("Layout changed"),
1261
 
                            wxString::Format(_("The layout '%s' has changed. Do you want to save it?"), m_LastLayoutName.c_str()),
 
1330
                            wxString::Format(_("The perspective '%s' has changed. Do you want to save it?"), m_LastLayoutName.c_str()),
1262
1331
                            wxART_QUESTION,
1263
1332
                            canCancel ? AnnoyingDialog::YES_NO_CANCEL : AnnoyingDialog::YES_NO,
1264
1333
                            wxID_YES);
1302
1371
        {
1303
1372
            if (!items[i]->IsCheckable())
1304
1373
                continue;
 
1374
            #if wxCHECK_VERSION(2, 9, 0)
 
1375
            items[i]->Check(items[i]->GetItemLabel().IsSameAs(name));
 
1376
            #else
1305
1377
            items[i]->Check(items[i]->GetText().IsSameAs(name));
 
1378
            #endif
1306
1379
        }
1307
 
        
 
1380
 
1308
1381
        if (!m_LastLayoutIsTemp)
1309
 
                        Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/default"), name);
 
1382
            Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/main_frame/layout/default"), name);
1310
1383
    }
1311
1384
}
1312
1385
 
1319
1392
    {
1320
1393
        SetToolBar(0);
1321
1394
 
1322
 
#ifdef __WXMSW__
 
1395
#if defined __WXMSW__ && !wxCHECK_VERSION(2, 8, 9)
1323
1396
        // HACK: for all windows versions (including XP *without* using a manifest file),
1324
1397
        //       the best size for a toolbar is not correctly calculated by wxWidgets/wxAUI/whatever.
1325
1398
        //       so we try to help the situation a little. It's not perfect, but it works.
 
1399
        // not needed for versions >= 2.8.9: fixed in upstream, toolbars with standard-controls
 
1400
        // are much too large with it (at least on w2k).
1326
1401
        if (!UsesCommonControls6()) // all windows versions, including XP without a manifest file
1327
1402
        {
1328
1403
            // calculate the total width of all wxWindow* in the toolbar (if any)
1421
1496
 
1422
1497
wxString MainFrame::ShowOpenFileDialog(const wxString& caption, const wxString& filter)
1423
1498
{
1424
 
    wxFileDialog* dlg = new wxFileDialog(this,
1425
 
                            caption,
1426
 
                            wxEmptyString,
1427
 
                            wxEmptyString,
1428
 
                            filter,
1429
 
                            wxOPEN | compatibility::wxHideReadonly);
 
1499
    wxFileDialog dlg(this,
 
1500
                     caption,
 
1501
                     wxEmptyString,
 
1502
                     wxEmptyString,
 
1503
                     filter,
 
1504
                     wxFD_OPEN | compatibility::wxHideReadonly);
1430
1505
    wxString sel;
1431
 
    PlaceWindow(dlg);
1432
 
    if (dlg->ShowModal() == wxID_OK)
1433
 
        sel = dlg->GetPath();
1434
 
    dlg->Destroy();
 
1506
    PlaceWindow(&dlg);
 
1507
    if (dlg.ShowModal() == wxID_OK)
 
1508
        sel = dlg.GetPath();
1435
1509
    return sel;
1436
1510
}
1437
1511
 
1453
1527
                DoCloseCurrentWorkspace())
1454
1528
            {
1455
1529
                wxBusyCursor wait; // loading a worspace can take some time -> showhourglass
 
1530
                ShowHideStartPage(true); // hide startherepage, so we can use full tab-range
1456
1531
                bool ret = Manager::Get()->GetProjectManager()->LoadWorkspace(filename);
1457
 
                if (ret && addToHistory)
 
1532
                if (!ret)
 
1533
                {
 
1534
                    ShowHideStartPage(); // show/hide startherepage, dependant of settings, if loading failed
 
1535
                }
 
1536
                else if (addToHistory)
 
1537
                {
1458
1538
                    AddToRecentProjectsHistory(Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename());
 
1539
                }
1459
1540
                return ret;
1460
1541
            }
1461
1542
            else
 
1543
            {
1462
1544
                return false;
 
1545
            }
1463
1546
            break;
1464
1547
 
1465
1548
        //
1522
1605
        return false;
1523
1606
    }
1524
1607
 
 
1608
    ShowHideStartPage(true); // hide startherepage, so we can use full tab-range
1525
1609
    cbProject* prj = Manager::Get()->GetProjectManager()->LoadProject(filename, true);
1526
1610
    if (prj)
1527
1611
    {
1528
1612
        if (addToHistory)
 
1613
        {
1529
1614
            AddToRecentProjectsHistory(prj->GetFilename());
 
1615
        }
1530
1616
        return true;
1531
1617
    }
 
1618
    ShowHideStartPage(); // show/hide startherepage, dependant of settings, if loading failed
1532
1619
    return false;
1533
1620
}
1534
1621
 
1535
1622
bool MainFrame::DoOpenFile(const wxString& filename, bool addToHistory)
1536
1623
{
1537
 
    if (Manager::Get()->GetEditorManager()->Open(filename))
 
1624
    cbEditor* ed = Manager::Get()->GetEditorManager()->Open(filename);
 
1625
    if (ed)
1538
1626
    {
1539
1627
        if (addToHistory)
1540
 
            AddToRecentFilesHistory(filename);
 
1628
            AddToRecentFilesHistory(ed->GetFilename());
1541
1629
        return true;
1542
1630
    }
1543
1631
    return false;
1592
1680
        SetStatusText(ed->GetEncodingName(), panel++);
1593
1681
        SetStatusText(msg, panel++);
1594
1682
        SetStatusText(ed->GetControl()->GetOvertype() ? _("Overwrite") : _("Insert"), panel++);
 
1683
        #if wxCHECK_VERSION(2, 9, 0)
 
1684
        SetStatusText(ed->GetModified() ? _("Modified") : _T(""), panel++);
 
1685
        #else
1595
1686
        SetStatusText(ed->GetModified() ? _("Modified") : wxEmptyString, panel++);
 
1687
        #endif
1596
1688
        SetStatusText(ed->GetControl()->GetReadOnly() ? _("Read only") : _("Read/Write"), panel++);
1597
1689
        SetStatusText(personality, panel++);
1598
1690
    }
1610
1702
#endif // wxUSE_STATUSBAR
1611
1703
}
1612
1704
 
1613
 
void MainFrame::DoUpdateEditorStyle(wxFlatNotebook* target, const wxString& prefix, long defaultStyle)
 
1705
void MainFrame::DoUpdateEditorStyle(cbAuiNotebook* target, const wxString& prefix, long defaultStyle)
1614
1706
{
1615
1707
    if (!target)
1616
1708
        return;
1617
1709
 
1618
1710
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("app"));
 
1711
    target->SetTabCtrlHeight(-1);
 
1712
 
1619
1713
    long nbstyle = cfg->ReadInt(_T("/environment/tabs_style"), 0);
1620
1714
    switch (nbstyle)
1621
1715
    {
1622
 
        case 1: // gradient
1623
 
            nbstyle = wxFNB_FANCY_TABS;
1624
 
            break;
1625
 
 
1626
 
        case 2: // vc71
1627
 
            nbstyle = wxFNB_VC71;
1628
 
            break;
1629
 
 
1630
 
        case 3: // vc8
1631
 
            nbstyle = wxFNB_VC8;
1632
 
            break;
1633
 
 
1634
 
        default:
1635
 
            nbstyle = 0;
 
1716
        case 1: // simple style
 
1717
            target->SetArtProvider(new wxAuiSimpleTabArt());
 
1718
            break;
 
1719
 
 
1720
        case 2: // VC 7.1 style
 
1721
            target->SetArtProvider(new NbStyleVC71());
 
1722
            break;
 
1723
 
 
1724
        case 3: // Firefox 2 style
 
1725
            target->SetArtProvider(new NbStyleFF2());
 
1726
            break;
 
1727
 
 
1728
        default: // default style
 
1729
            target->SetArtProvider(new wxAuiDefaultTabArt());
1636
1730
            break;
1637
1731
    }
1638
 
    nbstyle |= defaultStyle;
 
1732
 
 
1733
    nbstyle = defaultStyle;
1639
1734
    if (cfg->ReadBool(_T("/environment/") + prefix + _T("_tabs_bottom")))
1640
 
        nbstyle |= wxFNB_BOTTOM;
1641
 
 
1642
 
    if (cfg->ReadBool(_T("/environment/tabs_smart")))
1643
 
        nbstyle |= wxFNB_SMART_TABS;
 
1735
        nbstyle |= wxAUI_NB_BOTTOM;
1644
1736
 
1645
1737
    if (cfg->ReadBool(_T("/environment/tabs_list")))
1646
 
    {
1647
 
        nbstyle |= wxFNB_DROPDOWN_TABS_LIST;
1648
 
        nbstyle |= wxFNB_NO_NAV_BUTTONS;
1649
 
    }
 
1738
        nbstyle |= wxAUI_NB_WINDOWLIST_BUTTON;
1650
1739
 
1651
1740
    target->SetWindowStyleFlag(nbstyle);
1652
 
    target->SetGradientColorBorder(cfg->ReadColour(_T("/environment/gradient_border"), wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW))));
1653
 
    target->SetGradientColorFrom(cfg->ReadColour(_T("/environment/gradient_from"), wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE))));
1654
 
    target->SetGradientColorTo(cfg->ReadColour(_T("/environment/gradient_to"), *wxWHITE));
1655
1741
}
1656
1742
 
1657
1743
void MainFrame::DoUpdateEditorStyle()
1658
1744
{
1659
 
    wxFlatNotebook* fn = Manager::Get()->GetEditorManager()->GetNotebook();
1660
 
    DoUpdateEditorStyle(fn, _T("editor"), wxFNB_MOUSE_MIDDLE_CLOSES_TABS | wxFNB_X_ON_TAB | wxFNB_NO_X_BUTTON);
1661
 
 
1662
 
    fn = infoPane;
1663
 
    DoUpdateEditorStyle(fn, _T("message"), wxFNB_NO_X_BUTTON);
1664
 
 
1665
 
    fn = Manager::Get()->GetProjectManager()->GetNotebook();
1666
 
    DoUpdateEditorStyle(fn, _T("project"), wxFNB_NO_X_BUTTON);
 
1745
    long closestyle = Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/environment/tabs_close_on_all"))?wxAUI_NB_CLOSE_ON_ALL_TABS:0;
 
1746
    cbAuiNotebook* an = Manager::Get()->GetEditorManager()->GetNotebook();
 
1747
 
 
1748
    DoUpdateEditorStyle(an, _T("editor"), closestyle | wxAUI_NB_DEFAULT_STYLE | wxNO_FULL_REPAINT_ON_RESIZE | wxCLIP_CHILDREN);
 
1749
 
 
1750
    an = m_pInfoPane;
 
1751
    DoUpdateEditorStyle(an, _T("message"), closestyle | wxAUI_NB_DEFAULT_STYLE);
 
1752
 
 
1753
    an = Manager::Get()->GetProjectManager()->GetNotebook();
 
1754
    DoUpdateEditorStyle(an, _T("project"), wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_TAB_MOVE);
1667
1755
}
1668
1756
 
1669
1757
void MainFrame::DoUpdateLayoutColours()
1671
1759
    ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("app"));
1672
1760
    wxAuiDockArt* art = m_LayoutManager.GetArtProvider();
1673
1761
 
 
1762
#ifndef __WXGTK__
1674
1763
    m_LayoutManager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_ALLOW_ACTIVE_PANE | wxAUI_MGR_TRANSPARENT_DRAG);
 
1764
#else // #ifndef __WXGTK__
 
1765
    // workaround for a wxWidgets-bug that makes C::B crash when a floating window gets docked and composite-effects are enabled
 
1766
    m_LayoutManager.SetFlags((wxAUI_MGR_DEFAULT | wxAUI_MGR_ALLOW_ACTIVE_PANE | wxAUI_MGR_TRANSPARENT_DRAG | wxAUI_MGR_VENETIAN_BLINDS_HINT)& ~wxAUI_MGR_TRANSPARENT_HINT);
 
1767
#endif // #ifndef __WXGTK__
 
1768
 
1675
1769
    art->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE,   cfg->ReadInt(_T("/environment/aui/border_size"), art->GetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE)));
1676
1770
    art->SetMetric(wxAUI_DOCKART_SASH_SIZE,          cfg->ReadInt(_T("/environment/aui/sash_size"), art->GetMetric(wxAUI_DOCKART_SASH_SIZE)));
1677
1771
    art->SetMetric(wxAUI_DOCKART_CAPTION_SIZE,       cfg->ReadInt(_T("/environment/aui/caption_size"), art->GetMetric(wxAUI_DOCKART_CAPTION_SIZE)));
1696
1790
{
1697
1791
    EditorBase* ed = Manager::Get()->GetEditorManager() ? Manager::Get()->GetEditorManager()->GetActiveEditor() : 0L;
1698
1792
    cbProject* prj = 0;
1699
 
    if(ed && ed->IsBuiltinEditor())
 
1793
    if (ed && ed->IsBuiltinEditor())
1700
1794
    {
1701
1795
        ProjectFile* prjf = ((cbEditor*)ed)->GetProjectFile();
1702
 
        if(prjf)
 
1796
        if (prjf)
1703
1797
            prj = prjf->GetParentProject();
1704
1798
    }
1705
1799
    else
1707
1801
    wxString projname;
1708
1802
    wxString edname;
1709
1803
    wxString fulltitle;
1710
 
    if(ed || prj)
 
1804
    if (ed || prj)
1711
1805
    {
1712
 
        if(prj)
 
1806
        if (prj)
1713
1807
        {
1714
 
            if(Manager::Get()->GetProjectManager()->GetActiveProject() == prj)
 
1808
            if (Manager::Get()->GetProjectManager()->GetActiveProject() == prj)
1715
1809
                projname = wxString(_T(" [")) + prj->GetTitle() + _T("]");
1716
1810
            else
1717
1811
                projname = wxString(_T(" (")) + prj->GetTitle() + _T(")");
1718
1812
        }
1719
 
        if(ed)
 
1813
        if (ed)
1720
1814
            edname = ed->GetTitle();
1721
1815
        fulltitle = edname + projname;
1722
 
        if(!fulltitle.IsEmpty())
 
1816
        if (!fulltitle.IsEmpty())
1723
1817
            fulltitle.Append(_T(" - "));
1724
1818
    }
1725
1819
    fulltitle.Append(appglobals::AppName);
1737
1831
    // the EVT_PROJECT_OPEN event is fired *before* ProjectManager::GetProjects()
1738
1832
    // and ProjectManager::GetActiveProject() are updated...
1739
1833
 
1740
 
    if(m_InitiatedShutdown)
 
1834
    if (m_InitiatedShutdown)
1741
1835
    {
1742
1836
        EditorBase* sh = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
1743
1837
        if (sh)
1754
1848
        sh = new StartHerePage(this, Manager::Get()->GetEditorManager()->GetNotebook());
1755
1849
    else if (!show && sh)
1756
1850
        sh->Destroy();
 
1851
 
 
1852
    DoUpdateAppTitle();
1757
1853
}
1758
1854
 
1759
1855
void MainFrame::ShowHideScriptConsole()
1760
1856
{
1761
1857
    if (Manager::IsBatchBuild())
1762
1858
        return;
1763
 
    if (!m_pScriptConsole)
1764
 
    {
1765
 
        m_pScriptConsole = new ScriptConsole(this, -1);
1766
 
        infoPane->AddNonLogger(m_pScriptConsole, _("Script console"));
1767
 
    }
1768
 
    else
1769
 
    {
1770
 
        infoPane->DeleteNonLogger(m_pScriptConsole);
1771
 
        m_pScriptConsole = 0;
1772
 
    }
1773
 
    Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/show_script_console"), m_pScriptConsole != 0);
 
1859
    bool isVis = IsWindowReallyShown(m_pScriptConsole);
 
1860
    CodeBlocksDockEvent evt(isVis ? cbEVT_HIDE_DOCK_WINDOW : cbEVT_SHOW_DOCK_WINDOW);
 
1861
    evt.pWindow = m_pScriptConsole;
 
1862
    Manager::Get()->ProcessEvent(evt);
1774
1863
}
1775
1864
 
1776
1865
void MainFrame::OnStartHereLink(wxCommandEvent& event)
1778
1867
    wxCommandEvent evt;
1779
1868
    evt.SetId(idFileNewProject);
1780
1869
    wxString link = event.GetString();
1781
 
    if(link.IsSameAs(_T("CB_CMD_NEW_PROJECT")))
 
1870
    if (link.IsSameAs(_T("CB_CMD_NEW_PROJECT")))
1782
1871
        OnFileNewWhat(evt);
1783
 
    else if(link.IsSameAs(_T("CB_CMD_OPEN_PROJECT")))
 
1872
    else if (link.IsSameAs(_T("CB_CMD_OPEN_PROJECT")))
1784
1873
        DoOnFileOpen(true);
1785
1874
//    else if (link.IsSameAs(_T("CB_CMD_CONF_ENVIRONMENT")))
1786
1875
//        OnSettingsEnvironment(evt);
1788
1877
//        Manager::Get()->GetEditorManager()->Configure();
1789
1878
//    else if (link.IsSameAs(_T("CB_CMD_CONF_COMPILER")))
1790
1879
//        OnSettingsCompilerDebugger(evt);
1791
 
    else if(link.StartsWith(_T("CB_CMD_OPEN_HISTORY_")))
 
1880
    else if (link.StartsWith(_T("CB_CMD_OPEN_HISTORY_")))
1792
1881
    {
1793
1882
        wxFileHistory* hist = link.StartsWith(_T("CB_CMD_OPEN_HISTORY_PROJECT_")) ? m_pProjectsHistory : m_pFilesHistory;
1794
1883
        unsigned long count;
1795
1884
        link.AfterLast(_T('_')).ToULong(&count);
1796
1885
        --count;
1797
 
        if(count < hist->GetCount())
 
1886
        if (count < hist->GetCount())
1798
1887
        {
1799
1888
            if (!OpenGeneric(hist->GetHistoryFile(count), true))
1800
1889
            {
1802
1891
            }
1803
1892
        }
1804
1893
    }
 
1894
    else if (link.StartsWith(_T("CB_CMD_DELETE_HISTORY_")))
 
1895
    {
 
1896
        wxFileHistory* hist = link.StartsWith(_T("CB_CMD_DELETE_HISTORY_PROJECT_")) ? m_pProjectsHistory : m_pFilesHistory;
 
1897
        unsigned long count;
 
1898
        link.AfterLast(_T('_')).ToULong(&count);
 
1899
        --count;
 
1900
        if (count < hist->GetCount())
 
1901
        {
 
1902
            AskToRemoveFileFromHistory(hist, count, false);
 
1903
        }
 
1904
    }
1805
1905
}
1806
1906
 
1807
 
void MainFrame::AskToRemoveFileFromHistory(wxFileHistory* hist, int id)
 
1907
void MainFrame::AskToRemoveFileFromHistory(wxFileHistory* hist, int id, bool cannot_open)
1808
1908
{
1809
 
    if (cbMessageBox(_("Can't open file.\nDo you want to remove it from the recent files list?"),
1810
 
                    _("Question"),
1811
 
                    wxYES_NO | wxICON_QUESTION) == wxID_YES)
 
1909
    wxString question(_("Do you want to remove it from the recent files list?"));
 
1910
    wxString query(wxEmptyString);
 
1911
    if (cannot_open)
 
1912
    {
 
1913
        query << _("The file cannot be opened (probably it's not available anymore).")
 
1914
              << _T("\n") << question;
 
1915
    }
 
1916
    else
 
1917
    {
 
1918
        query << question;
 
1919
    }
 
1920
 
 
1921
 
 
1922
    if (cbMessageBox(query, _("Question"), wxYES_NO | wxICON_QUESTION) == wxID_YES)
1812
1923
    {
1813
1924
        hist->RemoveFileFromHistory(id);
1814
1925
        // update start here page
1829
1940
    wxString buf = event.GetString();
1830
1941
    wxString links;
1831
1942
 
1832
 
    links << _T("<b>Recent projects</b><br>\n");
 
1943
    links << _T("<table>\n<tr><td colspan=\"2\"><b>");
 
1944
    links << _("Recent projects");
 
1945
    links << _T("</b></td></tr>\n");
1833
1946
    if (m_pProjectsHistory->GetCount())
1834
1947
    {
1835
 
        links << _T("<ul>");
1836
 
        for (int i = 0; i < 9; ++i)
 
1948
        for (size_t i = 0; i < m_pProjectsHistory->GetCount(); ++i)
1837
1949
        {
1838
 
            if (i >= (int)m_pProjectsHistory->GetCount())
1839
 
                break;
1840
 
            links << wxString::Format(_T("<li><a href=\"CB_CMD_OPEN_HISTORY_PROJECT_%d\">%s</a></li>"),
1841
 
                                        i + 1, m_pProjectsHistory->GetHistoryFile(i).c_str());
 
1950
            links << _T("<tr><td width=\"50\"><img alt=\"\" width=\"20\" src=\"blank.png\" />");
 
1951
            links << wxString::Format(_T("<a href=\"CB_CMD_DELETE_HISTORY_PROJECT_%d\"><img alt=\"\" src=\"trash_16x16.png\" /></a>"),
 
1952
                                      i + 1);
 
1953
            links << _T("<img alt=\"\"  width=\"10\" src=\"blank.png\" /></td><td width=\"10\">");
 
1954
            links << wxString::Format(_T("<a href=\"CB_CMD_OPEN_HISTORY_PROJECT_%d\">%s</a>"),
 
1955
                                      i + 1, m_pProjectsHistory->GetHistoryFile(i).c_str());
 
1956
            links << _T("</td></tr>\n");
1842
1957
        }
1843
 
        links << _T("</ul><br>");
1844
1958
    }
1845
1959
    else
1846
 
        links << _T("&nbsp;&nbsp;&nbsp;&nbsp;No recent projects<br>\n");
 
1960
    {
 
1961
        links << _T("<tr><td style=\"width:2em;\"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;");
 
1962
        links << _("No recent projects");
 
1963
        links << _T("</td></tr>\n");
 
1964
    }
1847
1965
 
1848
 
    links << _T("<br><b>Recent files</b><br>\n");
 
1966
    links << _T("</table>\n<table>\n<tr><td colspan=\"2\"><b>");
 
1967
    links << _("Recent files");
 
1968
    links <<_T("</b></td></tr>\n");
1849
1969
    if (m_pFilesHistory->GetCount())
1850
1970
    {
1851
 
        links << _T("<ul>");
1852
 
        for (int i = 0; i < 9; ++i)
 
1971
        for (size_t i = 0; i < m_pFilesHistory->GetCount(); ++i)
1853
1972
        {
1854
 
            if (i >= (int)m_pFilesHistory->GetCount())
1855
 
                break;
1856
 
            links << wxString::Format(_T("<li><a href=\"CB_CMD_OPEN_HISTORY_FILE_%d\">%s</a></li>"),
1857
 
                                        i + 1, m_pFilesHistory->GetHistoryFile(i).c_str());
 
1973
            links << _T("<tr><td width=\"50\"><img alt=\"\" width=\"20\" src=\"blank.png\" />");
 
1974
            links << wxString::Format(_T("<a href=\"CB_CMD_DELETE_HISTORY_FILE_%d\"><img alt=\"\" src=\"trash_16x16.png\" /></a>"),
 
1975
                                      i + 1);
 
1976
            links << _T("<img alt=\"\"  width=\"10\" src=\"blank.png\" /></td><td width=\"10\">");
 
1977
            links << wxString::Format(_T("<a href=\"CB_CMD_OPEN_HISTORY_FILE_%d\">%s</a>"),
 
1978
                                      i + 1, m_pFilesHistory->GetHistoryFile(i).c_str());
 
1979
            links << _T("</td></tr>\n");
1858
1980
        }
1859
 
        links << _T("</ul>");
1860
1981
    }
1861
1982
    else
1862
 
        links << _T("&nbsp;&nbsp;&nbsp;&nbsp;No recent files<br>\n");
 
1983
    {
 
1984
        links << _T("<tr><td style=\"width:2em;\"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;");
 
1985
        links << _("No recent files");
 
1986
        links << _T("</td></tr>\n");
 
1987
    }
 
1988
 
 
1989
    links << _T("</table>\n");
1863
1990
 
1864
1991
 
1865
1992
    // update page
1866
1993
    buf.Replace(_T("CB_VAR_RECENT_FILES_AND_PROJECTS"), links);
 
1994
    buf.Replace(_T("CB_TXT_NEW_PROJECT"), _("Create a new project"));
 
1995
    buf.Replace(_T("CB_TXT_OPEN_PROJECT"), _("Open an existing project"));
 
1996
    buf.Replace(_T("CB_TXT_VISIT_FORUMS"), _("Visit the Code::Blocks forums"));
 
1997
    buf.Replace(_T("CB_TXT_REPORT_BUG"), _("Report a bug"));
 
1998
    buf.Replace(_T("CB_TXT_REQ_NEW_FEATURE"), _("Request a new feature"));
1867
1999
    ((StartHerePage*)sh)->SetPageContent(buf);
1868
2000
}
1869
2001
 
1883
2015
        if (!menu)
1884
2016
            return;
1885
2017
        wxMenu* recentFiles = 0;
1886
 
        wxMenuItem* clear = menu->FindItem(idFileOpenRecentFileClearHistory, &recentFiles);
 
2018
        menu->FindItem(idFileOpenRecentFileClearHistory, &recentFiles);
1887
2019
        if (recentFiles)
1888
2020
        {
1889
 
            recentFiles->Remove(clear);
1890
 
 
1891
2021
            wxArrayString files = Manager::Get()->GetConfigManager(_T("app"))->ReadArrayString(_T("/recent_files"));
1892
2022
            for (int i = (int)files.GetCount() - 1; i >= 0; --i)
1893
2023
            {
1894
 
                if(wxFileExists(files[i]))
 
2024
                if (wxFileExists(files[i]))
 
2025
                {
1895
2026
                    m_pFilesHistory->AddFileToHistory(files[i]);
1896
 
            }
1897
 
            m_pFilesHistory->UseMenu(recentFiles);
1898
 
            m_pFilesHistory->AddFilesToMenu(recentFiles);
1899
 
            if (recentFiles->GetMenuItemCount())
1900
 
                recentFiles->AppendSeparator();
1901
 
            recentFiles->Append(clear);
 
2027
                }
 
2028
            }
 
2029
            if (m_pFilesHistory->GetCount() > 0)
 
2030
            {
 
2031
                recentFiles->InsertSeparator(0);
 
2032
                for (size_t i = 0; i < m_pFilesHistory->GetCount(); ++i)
 
2033
                {
 
2034
                    recentFiles->Insert(recentFiles->GetMenuItemCount() - 2, wxID_FILE1 + i,
 
2035
                        wxString::Format(_T("&%d "), i + 1) + m_pFilesHistory->GetHistoryFile(i));
 
2036
                }
 
2037
            }
1902
2038
        }
1903
2039
        wxMenu* recentProjects = 0;
1904
 
        clear = menu->FindItem(idFileOpenRecentProjectClearHistory, &recentProjects);
 
2040
        menu->FindItem(idFileOpenRecentProjectClearHistory, &recentProjects);
1905
2041
        if (recentProjects)
1906
2042
        {
1907
2043
            m_pProjectsHistory = new wxFileHistory(9, wxID_FILE10);
1908
 
            recentProjects->Remove(clear);
1909
2044
 
1910
2045
            wxArrayString files = Manager::Get()->GetConfigManager(_T("app"))->ReadArrayString(_T("/recent_projects"));
1911
2046
            for (int i = (int)files.GetCount() - 1; i >= 0; --i)
1912
2047
            {
1913
 
                if(wxFileExists(files[i]))
 
2048
                if (wxFileExists(files[i]))
1914
2049
                    m_pProjectsHistory->AddFileToHistory(files[i]);
1915
2050
            }
1916
 
            m_pProjectsHistory->UseMenu(recentProjects);
1917
 
            m_pProjectsHistory->AddFilesToMenu(recentProjects);
1918
 
            if (recentProjects->GetMenuItemCount())
1919
 
                recentProjects->AppendSeparator();
1920
 
            recentProjects->Append(clear);
 
2051
            if (m_pProjectsHistory->GetCount() > 0)
 
2052
            {
 
2053
                recentProjects->InsertSeparator(0);
 
2054
                for (size_t i = 0; i < m_pProjectsHistory->GetCount(); ++i)
 
2055
                {
 
2056
                    recentProjects->Insert(recentProjects->GetMenuItemCount() - 2, wxID_FILE10 + i,
 
2057
                        wxString::Format(_T("&%d "), i + 1) + m_pProjectsHistory->GetHistoryFile(i));
 
2058
                }
 
2059
            }
1921
2060
        }
1922
2061
    }
1923
2062
}
1944
2083
 
1945
2084
    // because we append "clear history" menu to the end of the list,
1946
2085
    // each time we must add a history item we have to:
1947
 
    // a) remove "Clear history"
1948
 
    // b) clear the menu
1949
 
    // c) fill it with the history items
1950
 
    // and d) append "Clear history"...
 
2086
    // a) remove "Clear history" (Biplab#1: Don't remove or you'll loose icon)
 
2087
    // b) clear the menu (Biplab#1: except the last item)
 
2088
    // c) fill it with the history items (Biplab#1: by inserting them)
 
2089
    // and d) append "Clear history"... (Biplab#1: Not needed, item has not been removed)
1951
2090
    wxMenuBar* mbar = GetMenuBar();
1952
2091
    if (!mbar)
1953
2092
        return;
1958
2097
    if (!menu)
1959
2098
        return;
1960
2099
    wxMenu* recentFiles = 0;
1961
 
    wxMenuItem* clear = menu->FindItem(idFileOpenRecentFileClearHistory, &recentFiles);
1962
 
    if (clear && recentFiles)
 
2100
    menu->FindItem(idFileOpenRecentFileClearHistory, &recentFiles);
 
2101
    if (recentFiles)
1963
2102
    {
1964
 
        // a)
1965
 
        recentFiles->Remove(clear);
1966
 
        // b)
1967
 
        m_pFilesHistory->RemoveMenu(recentFiles);
1968
 
        while (recentFiles->GetMenuItemCount())
 
2103
        while (recentFiles->GetMenuItemCount() > 1)
 
2104
        {
1969
2105
            recentFiles->Delete(recentFiles->GetMenuItems()[0]);
1970
 
        // c)
1971
 
        m_pFilesHistory->UseMenu(recentFiles);
1972
 
        m_pFilesHistory->AddFilesToMenu(recentFiles);
1973
 
        // d)
1974
 
        if (recentFiles->GetMenuItemCount())
1975
 
            recentFiles->AppendSeparator();
1976
 
        recentFiles->Append(clear);
 
2106
        }
 
2107
        if (m_pFilesHistory->GetCount() > 0)
 
2108
        {
 
2109
            recentFiles->InsertSeparator(0);
 
2110
            for (size_t i = 0; i < m_pFilesHistory->GetCount(); ++i)
 
2111
            {
 
2112
                recentFiles->Insert(recentFiles->GetMenuItemCount() - 2, wxID_FILE1 + i,
 
2113
                    wxString::Format(_T("&%d "), i + 1) + m_pFilesHistory->GetHistoryFile(i));
 
2114
            }
 
2115
        }
1977
2116
    }
1978
2117
 
1979
2118
    // update start here page
2018
2157
    if (!menu)
2019
2158
        return;
2020
2159
    wxMenu* recentProjects = 0;
2021
 
    wxMenuItem* clear = menu->FindItem(idFileOpenRecentProjectClearHistory, &recentProjects);
2022
 
    if (clear && recentProjects)
 
2160
    menu->FindItem(idFileOpenRecentProjectClearHistory, &recentProjects);
 
2161
    if (recentProjects)
2023
2162
    {
2024
 
        // a)
2025
 
        recentProjects->Remove(clear);
2026
 
        // b)
2027
 
        m_pProjectsHistory->RemoveMenu(recentProjects);
2028
 
        while (recentProjects->GetMenuItemCount())
 
2163
        while (recentProjects->GetMenuItemCount() > 1)
 
2164
        {
2029
2165
            recentProjects->Delete(recentProjects->GetMenuItems()[0]);
2030
 
        // c)
2031
 
        m_pProjectsHistory->UseMenu(recentProjects);
2032
 
        m_pProjectsHistory->AddFilesToMenu(recentProjects);
2033
 
        // d)
2034
 
        if (recentProjects->GetMenuItemCount())
2035
 
            recentProjects->AppendSeparator();
2036
 
        recentProjects->Append(clear);
 
2166
        }
 
2167
        if (m_pProjectsHistory->GetCount() > 0)
 
2168
        {
 
2169
            recentProjects->InsertSeparator(0);
 
2170
            for (size_t i = 0; i < m_pProjectsHistory->GetCount(); ++i)
 
2171
            {
 
2172
                recentProjects->Insert(recentProjects->GetMenuItemCount() - 2, wxID_FILE10 + i,
 
2173
                    wxString::Format(_T("&%d "), i + 1) + m_pProjectsHistory->GetHistoryFile(i));
 
2174
            }
 
2175
        }
2037
2176
    }
2038
2177
 
2039
2178
    // update start here page
2063
2202
                    wxMenu* recentFiles = 0;
2064
2203
                    menu->FindItem(idFileOpenRecentFileClearHistory, &recentFiles);
2065
2204
                    if (recentFiles)
2066
 
                        m_pFilesHistory->RemoveMenu(recentFiles);
 
2205
                    {
 
2206
                        if (!Manager::IsAppShuttingDown())
 
2207
                        {
 
2208
                            while (recentFiles->GetMenuItemCount() > 1)
 
2209
                            {
 
2210
                                recentFiles->Delete(recentFiles->GetMenuItems()[0]);
 
2211
                            }
 
2212
                        }
 
2213
                        else
 
2214
                        {
 
2215
                            m_pFilesHistory->RemoveMenu(recentFiles);
 
2216
                        }
 
2217
                    }
2067
2218
                }
2068
2219
            }
2069
2220
        }
2075
2226
    {
2076
2227
        wxArrayString files;
2077
2228
        for (unsigned int i = 0; i < m_pProjectsHistory->GetCount(); ++i)
 
2229
        {
2078
2230
            files.Add(m_pProjectsHistory->GetHistoryFile(i));
 
2231
        }
2079
2232
        Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/recent_projects"), files);
2080
2233
 
2081
2234
        wxMenuBar* mbar = GetMenuBar();
2090
2243
                    wxMenu* recentProjects = 0;
2091
2244
                    menu->FindItem(idFileOpenRecentProjectClearHistory, &recentProjects);
2092
2245
                    if (recentProjects)
2093
 
                        m_pProjectsHistory->RemoveMenu(recentProjects);
 
2246
                    {
 
2247
                        if (!Manager::IsAppShuttingDown())
 
2248
                        {
 
2249
                            while (recentProjects->GetMenuItemCount() > 1)
 
2250
                            {
 
2251
                                recentProjects->Delete(recentProjects->GetMenuItems()[0]);
 
2252
                            }
 
2253
                        }
 
2254
                        else
 
2255
                        {
 
2256
                            m_pProjectsHistory->RemoveMenu(recentProjects);
 
2257
                        }
 
2258
                    }
2094
2259
                }
2095
2260
            }
2096
2261
        }
2193
2358
    if (project)
2194
2359
        wxSetWorkingDirectory(project->GetBasePath());
2195
2360
    cbEditor* ed = Manager::Get()->GetEditorManager()->New();
 
2361
    if (ed)
 
2362
    {
 
2363
        // initially start change-collection if configured on empty files
 
2364
        ed->GetControl()->SetChangeCollection(Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/margin/use_changebar"), true));
 
2365
    }
 
2366
 
2196
2367
    if (ed && ed->IsOK())
2197
2368
    {
2198
2369
        AddToRecentFilesHistory(ed->GetFilename());
2278
2449
    int StoredIndex = FileFilters::GetIndexForFilterAll();
2279
2450
    wxString Path;
2280
2451
    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("app"));
2281
 
    if(mgr)
 
2452
    if (mgr)
2282
2453
    {
2283
 
        if(!bProject)
 
2454
        if (!bProject)
2284
2455
        {
2285
2456
            wxString Filter = mgr->Read(_T("/file_dialogs/file_new_open/filter"));
2286
 
            if(!Filter.IsEmpty())
 
2457
            if (!Filter.IsEmpty())
2287
2458
            {
2288
2459
                FileFilters::GetFilterIndexFromName(Filters, Filter, StoredIndex);
2289
2460
            }
2294
2465
            FileFilters::GetFilterIndexFromName(Filters, _("Code::Blocks project files"), StoredIndex);
2295
2466
        }
2296
2467
    }
2297
 
    wxFileDialog* dlg = new wxFileDialog(this,
 
2468
    wxFileDialog dlg(this,
2298
2469
                            _("Open file"),
2299
2470
                            Path,
2300
2471
                            wxEmptyString,
2301
2472
                            Filters,
2302
 
                            wxOPEN | wxMULTIPLE | compatibility::wxHideReadonly);
2303
 
    dlg->SetFilterIndex(StoredIndex);
 
2473
                            wxFD_OPEN | wxFD_MULTIPLE | compatibility::wxHideReadonly);
 
2474
    dlg.SetFilterIndex(StoredIndex);
2304
2475
 
2305
 
    PlaceWindow(dlg);
2306
 
    if (dlg->ShowModal() == wxID_OK)
 
2476
    PlaceWindow(&dlg);
 
2477
    if (dlg.ShowModal() == wxID_OK)
2307
2478
    {
2308
2479
        // store the last used filter and directory
2309
2480
        // as said : don't do this in case of an 'open project'
2310
 
        if(mgr && !bProject)
 
2481
        if (mgr && !bProject)
2311
2482
        {
2312
 
            int Index = dlg->GetFilterIndex();
 
2483
            int Index = dlg.GetFilterIndex();
2313
2484
            wxString Filter;
2314
 
            if(FileFilters::GetFilterNameFromIndex(Filters, Index, Filter))
 
2485
            if (FileFilters::GetFilterNameFromIndex(Filters, Index, Filter))
2315
2486
            {
2316
2487
                mgr->Write(_T("/file_dialogs/file_new_open/filter"), Filter);
2317
2488
            }
2318
 
            wxString Test = dlg->GetDirectory();
2319
 
            mgr->Write(_T("/file_dialogs/file_new_open/directory"), dlg->GetDirectory());
 
2489
            wxString Test = dlg.GetDirectory();
 
2490
            mgr->Write(_T("/file_dialogs/file_new_open/directory"), dlg.GetDirectory());
2320
2491
        }
2321
2492
        wxArrayString files;
2322
 
        dlg->GetPaths(files);
 
2493
        dlg.GetPaths(files);
2323
2494
        OnDropFiles(0,0,files);
2324
2495
    }
2325
 
 
2326
 
    dlg->Destroy();
2327
2496
} // end of DoOnFileOpen
2328
2497
 
2329
2498
void MainFrame::OnFileOpen(wxCommandEvent& event)
2350
2519
    Manager::Get()->GetConfigManager(_T("app"))->DeleteSubPath(_T("/recent_projects"));
2351
2520
 
2352
2521
    // update start here page
 
2522
    InitializeRecentFilesHistory();
2353
2523
    EditorBase* sh = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
2354
2524
    if (sh)
2355
2525
        ((StartHerePage*)sh)->Reload();
2374
2544
    Manager::Get()->GetConfigManager(_T("app"))->DeleteSubPath(_T("/recent_files"));
2375
2545
 
2376
2546
    // update start here page
 
2547
    InitializeRecentFilesHistory();
2377
2548
    EditorBase* sh = Manager::Get()->GetEditorManager()->GetEditor(g_StartHereTitle);
2378
2549
    if (sh)
2379
2550
        ((StartHerePage*)sh)->Reload();
2583
2754
 
2584
2755
void MainFrame::OnApplicationClose(wxCloseEvent& event)
2585
2756
{
 
2757
    if (m_InitiatedShutdown)
 
2758
        return;
 
2759
 
2586
2760
    CodeBlocksEvent evt(cbEVT_APP_START_SHUTDOWN);
2587
2761
    Manager::Get()->ProcessEvent(evt);
2588
2762
    Manager::Yield();
2592
2766
    Manager::BlockYields(true);
2593
2767
 
2594
2768
    ProjectManager* prjman = Manager::Get()->GetProjectManager();
2595
 
    if(prjman)
 
2769
    if (prjman)
2596
2770
    {
2597
2771
        cbProject* prj = prjman->GetActiveProject();
2598
 
        if(prj && prj->GetCurrentlyCompilingTarget())
 
2772
        if (prj && prj->GetCurrentlyCompilingTarget())
2599
2773
        {
2600
2774
            event.Veto();
2601
2775
            wxBell();
2629
2803
        SaveWindowState();
2630
2804
 
2631
2805
    m_LayoutManager.DetachPane(Manager::Get()->GetProjectManager()->GetNotebook());
2632
 
    m_LayoutManager.DetachPane(infoPane);
 
2806
    m_LayoutManager.DetachPane(m_pInfoPane);
2633
2807
    m_LayoutManager.DetachPane(Manager::Get()->GetEditorManager()->GetNotebook());
2634
2808
 
2635
2809
    m_LayoutManager.UnInit();
2645
2819
 
2646
2820
    if (!Manager::IsBatchBuild())
2647
2821
    {
2648
 
        infoPane->Destroy();
2649
 
        infoPane = 0;
 
2822
        m_pInfoPane->Destroy();
 
2823
        m_pInfoPane = 0L;
2650
2824
    }
2651
2825
 
2652
2826
    Manager::Shutdown(); // Shutdown() is not Free(), Manager is automatically destroyed at exit
2701
2875
        ed->Redo();
2702
2876
}
2703
2877
 
 
2878
void MainFrame::OnEditClearHistory(wxCommandEvent& event)
 
2879
{
 
2880
    EditorBase* ed = Manager::Get()->GetEditorManager()->GetActiveEditor();
 
2881
    if (ed)
 
2882
        ed->ClearHistory();
 
2883
}
 
2884
 
2704
2885
void MainFrame::OnEditCopy(wxCommandEvent& event)
2705
2886
{
2706
2887
    EditorBase* ed = Manager::Get()->GetEditorManager()->GetActiveEditor();
2886
3067
 
2887
3068
void MainFrame::OnEditSelectAll(wxCommandEvent& event)
2888
3069
{
2889
 
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
2890
 
    if (ed)
2891
 
        ed->GetControl()->SelectAll();
2892
 
}
2893
 
 
2894
 
CommentToken GetCommentToken(cbStyledTextCtrl* stc)
2895
 
{
2896
 
    CommentToken comment;
2897
 
    comment.lineComment        = _T("");
2898
 
    comment.streamCommentStart = _T("");
2899
 
    comment.streamCommentEnd   = _T("");
2900
 
    comment.boxCommentStart    = _T("");
2901
 
    comment.boxCommentMid      = _T("");
2902
 
    comment.boxCommentEnd      = _T("");
2903
 
 
2904
 
    switch(stc->GetLexer())
2905
 
    {
2906
 
        case wxSCI_LEX_CONTAINER:  comment.lineComment = _T(""); break;
2907
 
        case wxSCI_LEX_NULL:       comment.lineComment = _T(""); break;
2908
 
        case wxSCI_LEX_PYTHON:     comment.lineComment = _T("#"); break;
2909
 
        case wxSCI_LEX_CPP:
2910
 
            comment.lineComment        = _T("//");
2911
 
            comment.streamCommentStart = _T("/*");
2912
 
            comment.streamCommentEnd   = _T("*/");
2913
 
            comment.boxCommentStart    = _T("/* ");
2914
 
            comment.boxCommentMid      = _T(" * ");
2915
 
            comment.boxCommentEnd      = _T(" */");
2916
 
            break;
2917
 
        case wxSCI_LEX_HTML:
2918
 
            comment.lineComment        = _T("//");
2919
 
            comment.streamCommentStart = _T("/*");
2920
 
            comment.streamCommentEnd   = _T("*/");
2921
 
            comment.boxCommentStart    = _T("/* ");
2922
 
            comment.boxCommentMid      = _T(" * ");
2923
 
            comment.boxCommentEnd      = _T(" */");
2924
 
            break; // PHP uses HTML lexer
2925
 
        case wxSCI_LEX_XML:
2926
 
            comment.streamCommentStart = _T("<!--");
2927
 
            comment.streamCommentEnd   = _T("-->");
2928
 
            comment.boxCommentStart    = _T("<!-- ");
2929
 
            comment.boxCommentMid      = _T("  -- ");
2930
 
            comment.boxCommentEnd      = _T("  -->");
2931
 
            break;
2932
 
        case wxSCI_LEX_PERL:       comment.lineComment = _T("#"); break;
2933
 
        case wxSCI_LEX_SQL:        comment.lineComment = _T("--"); break;
2934
 
        case wxSCI_LEX_VB:         comment.lineComment = _T("'"); break;
2935
 
        case wxSCI_LEX_PROPERTIES: comment.lineComment = _T("#"); break;
2936
 
        case wxSCI_LEX_ERRORLIST:  comment.lineComment = _T(""); break;
2937
 
        case wxSCI_LEX_MAKEFILE:   comment.lineComment = _T("#"); break;
2938
 
        case wxSCI_LEX_BATCH:      comment.lineComment = _T("REM "); break;
2939
 
        case wxSCI_LEX_XCODE:      comment.lineComment = _T(""); break;
2940
 
        case wxSCI_LEX_LATEX:      comment.lineComment = _T("%"); break;
2941
 
        case wxSCI_LEX_LUA:
2942
 
            comment.lineComment        = _T("--");
2943
 
            comment.streamCommentStart = _T("/*");
2944
 
            comment.streamCommentEnd   = _T("*/");
2945
 
            comment.boxCommentStart    = _T("/* ");
2946
 
            comment.boxCommentMid      = _T(" * ");
2947
 
            comment.boxCommentEnd      = _T(" */");
2948
 
            break;
2949
 
        case wxSCI_LEX_DIFF:       comment.lineComment = _T(""); break;
2950
 
        case wxSCI_LEX_CONF:       comment.lineComment = _T(""); break;
2951
 
        case wxSCI_LEX_PASCAL:
2952
 
            comment.lineComment        = _T("//");  //delphi style lineComments, otherwise use { } or (* and *)
2953
 
            comment.streamCommentStart = _T("{");
2954
 
            comment.streamCommentEnd   = _T("}");
2955
 
            comment.boxCommentStart    = _T("(* ");
2956
 
            comment.boxCommentMid      = _T(" * ");
2957
 
            comment.boxCommentEnd      = _T(" *)");
2958
 
            break;
2959
 
        case wxSCI_LEX_AVE:        comment.lineComment = _T(""); break;
2960
 
        case wxSCI_LEX_ADA:        comment.lineComment = _T("--"); break;
2961
 
        case wxSCI_LEX_LISP:
2962
 
            comment.lineComment        = _T(";");
2963
 
            comment.streamCommentStart = _T("#|");
2964
 
            comment.streamCommentEnd   = _T("|#");
2965
 
            comment.boxCommentStart    = _T("#| ");
2966
 
            comment.boxCommentMid      = _T(" | ");
2967
 
            comment.boxCommentEnd      = _T(" |#");
2968
 
            break;
2969
 
        case wxSCI_LEX_RUBY:
2970
 
            comment.lineComment        = _T("#");
2971
 
            comment.boxCommentStart    = _T("=begin");
2972
 
            comment.boxCommentEnd      = _T("=end");
2973
 
            break;
2974
 
        case wxSCI_LEX_EIFFEL:     comment.lineComment = _T("--"); break;
2975
 
        case wxSCI_LEX_EIFFELKW:   comment.lineComment = _T("--"); break;
2976
 
        case wxSCI_LEX_TCL:        comment.lineComment = _T("#"); break;
2977
 
        case wxSCI_LEX_NNCRONTAB:  comment.lineComment = _T(""); break;
2978
 
        case wxSCI_LEX_BULLANT:    comment.lineComment = _T(""); break;
2979
 
        case wxSCI_LEX_VBSCRIPT:   comment.lineComment = _T("'"); break;
2980
 
        case wxSCI_LEX_BAAN:       comment.lineComment = _T(""); break;
2981
 
        case wxSCI_LEX_MATLAB:
2982
 
            comment.lineComment        = _T("%");
2983
 
            comment.streamCommentStart = _T("%{");
2984
 
            comment.streamCommentEnd   = _T("}%");
2985
 
            comment.boxCommentStart    = _T("%{ ");
2986
 
            comment.boxCommentEnd      = _T(" }%");
2987
 
            break;
2988
 
        case wxSCI_LEX_SCRIPTOL:   comment.lineComment = _T("`"); break;
2989
 
        case wxSCI_LEX_ASM:        comment.lineComment = _T(";"); break;
2990
 
        case wxSCI_LEX_CPPNOCASE:
2991
 
            comment.lineComment        = _T("//");
2992
 
            comment.streamCommentStart = _T("/*");
2993
 
            comment.streamCommentEnd   = _T("*/");
2994
 
            comment.boxCommentStart    = _T("/* ");
2995
 
            comment.boxCommentMid      = _T(" * ");
2996
 
            comment.boxCommentEnd      = _T(" */");
2997
 
            break;
2998
 
        case wxSCI_LEX_FORTRAN:    comment.lineComment = _T("!"); break;
2999
 
        case wxSCI_LEX_CSS:
3000
 
            comment.lineComment        = _T("");
3001
 
            comment.streamCommentStart = _T("/*");
3002
 
            comment.streamCommentEnd   = _T("*/");
3003
 
            comment.boxCommentStart    = _T("/* ");
3004
 
            comment.boxCommentMid      = _T(" * ");
3005
 
            comment.boxCommentEnd      = _T(" */");
3006
 
            break;
3007
 
        case wxSCI_LEX_POV:
3008
 
            comment.lineComment        = _T("//"); // original here was "//@-" don't know why
3009
 
            comment.streamCommentStart = _T("/*");
3010
 
            comment.streamCommentEnd   = _T("*/");
3011
 
            comment.boxCommentStart    = _T("/* ");
3012
 
            comment.boxCommentMid      = _T(" * ");
3013
 
            comment.boxCommentEnd      = _T(" */");
3014
 
            break;
3015
 
        case wxSCI_LEX_LOUT:       comment.lineComment = _T("#"); break;
3016
 
        case wxSCI_LEX_ESCRIPT:    comment.lineComment = _T(""); break; //couldn't find
3017
 
        case wxSCI_LEX_PS:         comment.lineComment = _T("%"); break; // not sure if it's only one % or multiple
3018
 
        case wxSCI_LEX_NSIS:       comment.lineComment = _T(""); break;
3019
 
        case wxSCI_LEX_MMIXAL:     comment.lineComment = _T(""); break;
3020
 
        case wxSCI_LEX_CLW:        comment.lineComment = _T(""); break;
3021
 
        case wxSCI_LEX_CLWNOCASE:  comment.lineComment = _T(""); break;
3022
 
        case wxSCI_LEX_LOT:        comment.lineComment = _T(""); break;
3023
 
        case wxSCI_LEX_YAML:       comment.lineComment = _T(""); break;
3024
 
        case wxSCI_LEX_TEX:        comment.lineComment = _T("%"); break;
3025
 
        case wxSCI_LEX_METAPOST:   comment.lineComment = _T(""); break;
3026
 
        case wxSCI_LEX_POWERBASIC: comment.lineComment = _T(""); break;
3027
 
        case wxSCI_LEX_FORTH:      comment.lineComment = _T(""); break;
3028
 
        case wxSCI_LEX_ERLANG:     comment.lineComment = _T(""); break;
3029
 
        case wxSCI_LEX_OCTAVE:     comment.lineComment = _T("#"); break; // or '%'
3030
 
        case wxSCI_LEX_MSSQL:      comment.lineComment = _T(""); break;
3031
 
        case wxSCI_LEX_VERILOG:    comment.lineComment = _T("//"); break;
3032
 
        case wxSCI_LEX_KIX:        comment.lineComment = _T(""); break;
3033
 
        case wxSCI_LEX_SPECMAN:    comment.lineComment = _T(""); break;
3034
 
        case wxSCI_LEX_APDL:       comment.lineComment = _T(""); break;
3035
 
        case wxSCI_LEX_BASH:       comment.lineComment = _T("#"); break;
3036
 
        case wxSCI_LEX_VHDL:       comment.lineComment = _T("--"); break;
3037
 
        case wxSCI_LEX_CAML:       comment.lineComment = _T(""); break;
3038
 
        case wxSCI_LEX_BLITZBASIC: comment.lineComment = _T(""); break;
3039
 
        case wxSCI_LEX_PUREBASIC:  comment.lineComment = _T(""); break;
3040
 
        case wxSCI_LEX_HASKELL:    comment.lineComment = _T("--"); break;
3041
 
        case wxSCI_LEX_PHPSCRIPT:
3042
 
            comment.lineComment        = _T("#");
3043
 
            //comment.lineComment        = _T("//");
3044
 
            comment.streamCommentStart = _T("/*");
3045
 
            comment.streamCommentEnd   = _T("*/");
3046
 
            comment.boxCommentStart    = _T("/* ");
3047
 
            comment.boxCommentMid      = _T(" * ");
3048
 
            comment.boxCommentEnd      = _T(" */");
3049
 
            break;
3050
 
        case wxSCI_LEX_REBOL:      comment.lineComment = _T(""); break; // couldn't find
3051
 
        case wxSCI_LEX_SMALLTALK:  comment.lineComment = _T(""); break; // uses double quotes at start and end i.e. "lineComment"
3052
 
        case wxSCI_LEX_FLAGSHIP:   comment.lineComment = _T(""); break;
3053
 
        case wxSCI_LEX_CSOUND:     comment.lineComment = _T(""); break;
3054
 
        case wxSCI_LEX_FREEBASIC:  comment.lineComment = _T(""); break;
3055
 
        default: // Let the user decide if he wants to lineComment or not
3056
 
            comment.lineComment        = _T("//");
3057
 
            comment.streamCommentStart = _T("/*");
3058
 
            comment.streamCommentEnd   = _T("*/");
3059
 
            comment.boxCommentStart    = _T("/* ");
3060
 
            comment.boxCommentMid      = _T(" * ");
3061
 
            comment.boxCommentEnd      = _T(" */");
3062
 
    }
3063
 
    return comment;
3064
 
}
3065
 
 
 
3070
    EditorBase* eb = Manager::Get()->GetEditorManager()->GetActiveEditor();
 
3071
    if (eb)
 
3072
        eb->SelectAll();
 
3073
}
3066
3074
 
3067
3075
/* This is a shameless rip-off of the original OnEditCommentSelected function,
3068
3076
 * now more suitingly named OnEditToggleCommentSelected (because that's what
3074
3082
    if (ed)
3075
3083
    {
3076
3084
        cbStyledTextCtrl* stc = ed->GetControl();
3077
 
        CommentToken comment=GetCommentToken(stc);
3078
 
        if(comment.lineComment==wxEmptyString && comment.streamCommentStart==wxEmptyString)
 
3085
        CommentToken comment =
 
3086
            Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken( ed->GetLanguage() );
 
3087
        if (comment.lineComment==wxEmptyString && comment.streamCommentStart==wxEmptyString)
3079
3088
            return;
3080
3089
 
3081
3090
        stc->BeginUndoAction();
3082
 
        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
 
3091
        if ( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
3083
3092
        {
3084
3093
            int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
3085
3094
            int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
3101
3110
            while( curLine <= endLine )
3102
3111
            {
3103
3112
                // For each line: comment.
3104
 
                if(comment.lineComment!=wxEmptyString)
 
3113
                if (comment.lineComment!=wxEmptyString)
3105
3114
                    stc->InsertText( stc->PositionFromLine( curLine ), comment.lineComment );
3106
3115
                else // if the language doesn't support line comments use stream comments
3107
3116
                {
3110
3119
                }
3111
3120
                ++curLine;
3112
3121
            } // end while
3113
 
            stc->SetSelection(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
 
3122
            stc->SetSelectionVoid(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
3114
3123
        }
3115
3124
        stc->EndUndoAction();
3116
3125
    }
3123
3132
    if (ed)
3124
3133
    {
3125
3134
        cbStyledTextCtrl* stc = ed->GetControl();
3126
 
        CommentToken comment=GetCommentToken(stc);
3127
 
        if(comment.lineComment==wxEmptyString && comment.streamCommentStart==wxEmptyString)
 
3135
        CommentToken comment =
 
3136
            Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken( ed->GetLanguage() );
 
3137
 
 
3138
        if (comment.lineComment==wxEmptyString && comment.streamCommentStart==wxEmptyString)
3128
3139
            return;
3129
3140
 
3130
3141
        stc->BeginUndoAction();
3131
 
        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
 
3142
        if ( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
3132
3143
        {
3133
3144
            int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
3134
3145
            int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
3157
3168
 
3158
3169
                // check for line comment
3159
3170
                startsWithComment = strLine.Strip( wxString::leading ).StartsWith( comment.lineComment );
3160
 
                if( startsWithComment )
 
3171
                if ( startsWithComment )
3161
3172
                {      // we know the comment is there (maybe preceded by white space)
3162
3173
                    int Pos = strLine.Find(comment.lineComment);
3163
3174
                    int start = stc->PositionFromLine( curLine ) + Pos;
3170
3181
                // check for stream comment
3171
3182
                startsWithComment = strLine.Strip( wxString::leading  ).StartsWith( comment.streamCommentStart ); // check for stream comment start
3172
3183
                endsWithComment = strLine.Strip( wxString::trailing ).EndsWith( comment.streamCommentEnd); // check for stream comment end
3173
 
                if( startsWithComment && endsWithComment )
 
3184
                if ( startsWithComment && endsWithComment )
3174
3185
                {
3175
3186
                    int Pos;
3176
3187
                    int start;
3195
3206
                }
3196
3207
                ++curLine;
3197
3208
            } // end while
3198
 
            stc->SetSelection(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
 
3209
            stc->SetSelectionVoid(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
3199
3210
        }
3200
3211
        stc->EndUndoAction();
3201
3212
    }
3207
3218
    if (ed)
3208
3219
    {
3209
3220
        cbStyledTextCtrl* stc = ed->GetControl();
3210
 
        wxString comment=GetCommentToken(stc).lineComment;
3211
 
        if(comment==wxEmptyString)
 
3221
        wxString comment =
 
3222
            Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken( ed->GetLanguage() ).lineComment;
 
3223
        if (comment==wxEmptyString)
3212
3224
            return;
3213
3225
 
3214
3226
        stc->BeginUndoAction();
3215
 
        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
 
3227
        if ( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
3216
3228
        {
3217
3229
            int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
3218
3230
            int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
3237
3249
                wxString strLine = stc->GetLine( curLine );
3238
3250
                int commentPos = strLine.Strip( wxString::leading ).Find( comment );
3239
3251
 
3240
 
                if( -1 == commentPos || commentPos > 0 )
 
3252
                if ( -1 == commentPos || commentPos > 0 )
3241
3253
                {
3242
3254
                    stc->InsertText( stc->PositionFromLine( curLine ), comment );
3243
3255
                }
3252
3264
                }
3253
3265
                ++curLine;
3254
3266
            }
3255
 
            stc->SetSelection(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
 
3267
            stc->SetSelectionVoid(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
3256
3268
        }
3257
3269
        stc->EndUndoAction();
3258
3270
    }
3264
3276
    if (ed)
3265
3277
    {
3266
3278
        cbStyledTextCtrl* stc = ed->GetControl();
3267
 
        CommentToken comment=GetCommentToken(stc);
3268
 
        if(comment.streamCommentStart==wxEmptyString)
 
3279
        CommentToken comment =
 
3280
            Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken( ed->GetLanguage() );
 
3281
        if (comment.streamCommentStart==wxEmptyString)
3269
3282
            return;
3270
3283
 
3271
3284
        stc->BeginUndoAction();
3272
 
        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
 
3285
        if ( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
3273
3286
        {
3274
3287
            int startPos = stc->GetSelectionStart();
3275
3288
            int endPos   = stc->GetSelectionEnd();
3296
3309
             // we already inserted some characters so out endPos changed
3297
3310
            endPos += comment.streamCommentStart.Length();
3298
3311
            stc->InsertText( endPos, comment.streamCommentEnd );
3299
 
            stc->SetSelection(startPos,endPos);
 
3312
            stc->SetSelectionVoid(startPos,endPos);
3300
3313
        }
3301
3314
        stc->EndUndoAction();
3302
3315
    }
3309
3322
    {
3310
3323
 
3311
3324
        cbStyledTextCtrl* stc = ed->GetControl();
3312
 
        CommentToken comment=GetCommentToken(stc);
3313
 
        if(comment.boxCommentStart==wxEmptyString)
 
3325
        CommentToken comment =
 
3326
            Manager::Get()->GetEditorManager()->GetColourSet()->GetCommentToken( ed->GetLanguage() );
 
3327
        if (comment.boxCommentStart==wxEmptyString)
3314
3328
            return;
3315
3329
 
3316
3330
        wxString nlc;
3317
3331
        switch (stc->GetEOLMode())
3318
3332
        {
3319
 
            case wxSCI_EOL_CRLF: nlc=_T("\r\n");
3320
 
            case wxSCI_EOL_CR:   nlc=_T("\r");
3321
 
            case wxSCI_EOL_LF:   nlc=_T("\n");
 
3333
            case wxSCI_EOL_CRLF: nlc=_T("\r\n"); break;
 
3334
            case wxSCI_EOL_CR:   nlc=_T("\r");   break;
 
3335
            case wxSCI_EOL_LF:   nlc=_T("\n");   break;
3322
3336
 
3323
3337
        }
3324
3338
 
3325
3339
        stc->BeginUndoAction();
3326
 
        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
 
3340
        if ( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
3327
3341
        {
3328
3342
            int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
3329
3343
            int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
3365
3379
                // insert boxcomment end token and add a new line character
3366
3380
                stc->InsertText( stc->PositionFromLine( curLine ), comment.boxCommentEnd + nlc);
3367
3381
            } // end if
3368
 
            stc->SetSelection(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
 
3382
            stc->SetSelectionVoid(stc->PositionFromLine(startLine),stc->PositionFromLine(endLine)+stc->LineLength(endLine));
3369
3383
        }
3370
3384
        stc->EndUndoAction();
3371
3385
    }
3395
3409
                {
3396
3410
                    wxMenuItem* item = hl->FindItem(event.GetId());
3397
3411
                    if (item)
 
3412
                    #if wxCHECK_VERSION(2, 9, 0)
 
3413
                        lang = theme->GetHighlightLanguage(item->GetItemLabelText());
 
3414
                    #else
3398
3415
                        lang = theme->GetHighlightLanguage(item->GetLabel());
 
3416
                    #endif
3399
3417
                }
3400
3418
            }
3401
3419
            ed->SetLanguage(lang);
3517
3535
void MainFrame::OnViewLayoutSave(wxCommandEvent& event)
3518
3536
{
3519
3537
    wxString def = Manager::Get()->GetConfigManager(_T("app"))->Read(_T("/main_frame/layout/default"));
3520
 
    wxString name = wxGetTextFromUser(_("Enter the name for this layout"), _("Save current layout"), def);
 
3538
    wxString name = wxGetTextFromUser(_("Enter the name for this perspective"), _("Save current perspective"), def);
3521
3539
    if (!name.IsEmpty())
3522
3540
    {
3523
3541
        DoFixToolbarsLayout();
3529
3547
{
3530
3548
    if (m_LastLayoutName == gDefaultLayout)
3531
3549
    {
3532
 
        if (cbMessageBox(_("The default layout cannot be deleted. It can always be reverted to "
 
3550
        if (cbMessageBox(_("The default perspective cannot be deleted. It can always be reverted to "
3533
3551
                        "a predefined state though.\nDo you want to revert it now?"),
3534
3552
                        _("Confirmation"),
3535
3553
                        wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT) == wxID_YES)
3540
3558
        return;
3541
3559
    }
3542
3560
 
3543
 
    if (cbMessageBox(wxString::Format(_("Are you really sure you want to delete the layout '%s'?"), m_LastLayoutName.c_str()),
 
3561
    if (cbMessageBox(wxString::Format(_("Are you really sure you want to delete the perspective '%s'?"), m_LastLayoutName.c_str()),
3544
3562
                    _("Confirmation"),
3545
3563
                    wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT) == wxID_YES)
3546
3564
    {
3563
3581
                m_PluginIDsMap.erase(it2);
3564
3582
        }
3565
3583
 
3566
 
        cbMessageBox(wxString::Format(_("Layout '%s' deleted.\nWill now revert to layout '%s'..."), m_LastLayoutName.c_str(), gDefaultLayout.c_str()),
 
3584
        cbMessageBox(wxString::Format(_("Perspective '%s' deleted.\nWill now revert to perspective '%s'..."), m_LastLayoutName.c_str(), gDefaultLayout.c_str()),
3567
3585
                        _("Information"), wxICON_INFORMATION);
3568
3586
 
3569
3587
        // finally, revert to the default layout
3575
3593
void MainFrame::OnViewScriptConsole(wxCommandEvent& event)
3576
3594
{
3577
3595
    ShowHideScriptConsole();
3578
 
    if (m_pScriptConsole)
3579
 
        infoPane->ShowNonLogger(m_pScriptConsole);
3580
3596
}
3581
3597
 
3582
3598
void MainFrame::OnSearchFind(wxCommandEvent& event)
3583
3599
{
3584
3600
    bool bDoMultipleFiles = (event.GetId() == idSearchFindInFiles);
3585
 
    if(!bDoMultipleFiles)
 
3601
    if (!bDoMultipleFiles)
3586
3602
    {
3587
3603
        bDoMultipleFiles = !Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
3588
3604
    }
3598
3614
void MainFrame::OnSearchReplace(wxCommandEvent& event)
3599
3615
{
3600
3616
    bool bDoMultipleFiles = (event.GetId() == idSearchReplaceInFiles);
3601
 
    if(!bDoMultipleFiles)
 
3617
    if (!bDoMultipleFiles)
3602
3618
    {
3603
3619
        bDoMultipleFiles = !Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
3604
3620
    }
3633
3649
    }
3634
3650
}
3635
3651
 
 
3652
void MainFrame::OnSearchGotoNextChanged(wxCommandEvent& event)
 
3653
{
 
3654
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
 
3655
    if (ed)
 
3656
        ed->GotoNextChanged();
 
3657
}
 
3658
 
 
3659
void MainFrame::OnSearchGotoPrevChanged(wxCommandEvent& event)
 
3660
{
 
3661
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
 
3662
    if (ed)
 
3663
        ed->GotoPreviousChanged();
 
3664
}
 
3665
 
3636
3666
void MainFrame::OnHelpAbout(wxCommandEvent& WXUNUSED(event))
3637
3667
{
3638
 
    dlgAbout* dlg = new dlgAbout(this);
3639
 
    PlaceWindow(dlg, pdlHead);
3640
 
    dlg->ShowModal();
3641
 
    dlg->Destroy();
 
3668
    dlgAbout dlg(this);
 
3669
    PlaceWindow(&dlg, pdlHead);
 
3670
    dlg.ShowModal();
3642
3671
}
3643
3672
 
3644
3673
void MainFrame::OnHelpTips(wxCommandEvent& event)
3648
3677
 
3649
3678
void MainFrame::OnFileMenuUpdateUI(wxUpdateUIEvent& event)
3650
3679
{
3651
 
    if(Manager::isappShuttingDown())
 
3680
    if (Manager::isappShuttingDown())
3652
3681
    {
3653
3682
        event.Skip();
3654
3683
        return;
3686
3715
    if (m_pToolbar)
3687
3716
    {
3688
3717
        m_pToolbar->EnableTool(idFileSave, ed && ed->GetModified());
 
3718
        m_pToolbar->EnableTool(idFileSaveAllFiles, canSaveFiles);
3689
3719
        m_pToolbar->EnableTool(idFileSaveAll, canSaveAll);
3690
3720
        m_pToolbar->EnableTool(idFilePrint, Manager::Get()->GetEditorManager() && Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor());
3691
3721
    }
3695
3725
 
3696
3726
void MainFrame::OnEditMenuUpdateUI(wxUpdateUIEvent& event)
3697
3727
{
3698
 
    if(Manager::isappShuttingDown())
 
3728
    if (Manager::isappShuttingDown())
3699
3729
    {
3700
3730
        event.Skip();
3701
3731
        return;
3708
3738
    bool canRedo = false;
3709
3739
    bool canPaste = false;
3710
3740
    bool canCut = false;
 
3741
    bool canSelAll = false;
3711
3742
    int eolMode = -1;
3712
3743
 
3713
 
    if(Manager::Get()->GetEditorManager() && !Manager::isappShuttingDown())
 
3744
    if (Manager::Get()->GetEditorManager() && !Manager::isappShuttingDown())
3714
3745
    {
3715
3746
        ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
3716
3747
        eb = Manager::Get()->GetEditorManager()->GetActiveEditor();
3718
3749
 
3719
3750
    wxMenuBar* mbar = GetMenuBar();
3720
3751
 
3721
 
    if(ed)
 
3752
    if (ed)
3722
3753
        eolMode = ed->GetControl()->GetEOLMode();
3723
 
    if(eb)
 
3754
    if (eb)
3724
3755
    {
3725
3756
        canUndo = eb->CanUndo();
3726
3757
        canRedo = eb->CanRedo();
3727
3758
        hasSel = eb->HasSelection();
3728
3759
        canPaste = eb->CanPaste();
3729
3760
        canCut = !eb->IsReadOnly() && hasSel;
 
3761
        canSelAll = eb->CanSelectAll();
3730
3762
    }
3731
3763
 
3732
3764
    mbar->Enable(idEditUndo, canUndo);
3733
3765
    mbar->Enable(idEditRedo, canRedo);
 
3766
    mbar->Enable(idEditClearHistory, canUndo || canRedo);
3734
3767
    mbar->Enable(idEditCut, canCut);
3735
3768
    mbar->Enable(idEditCopy, hasSel);
3736
3769
    mbar->Enable(idEditPaste, canPaste);
3737
3770
    mbar->Enable(idEditSwapHeaderSource, ed);
3738
3771
    mbar->Enable(idEditGotoMatchingBrace, ed);
3739
3772
    mbar->Enable(idEditHighlightMode, ed);
3740
 
    mbar->Enable(idEditSelectAll, ed);
 
3773
    mbar->Enable(idEditSelectAll, canSelAll);
3741
3774
    mbar->Enable(idEditBookmarks, ed);
3742
3775
    mbar->Enable(idEditFolding, ed);
3743
3776
    mbar->Enable(idEditEOLMode, ed);
3798
3831
 
3799
3832
void MainFrame::OnViewMenuUpdateUI(wxUpdateUIEvent& event)
3800
3833
{
3801
 
    if(Manager::isappShuttingDown())
 
3834
    if (Manager::isappShuttingDown())
3802
3835
    {
3803
3836
        event.Skip();
3804
3837
        return;
3808
3841
    bool manVis = m_LayoutManager.GetPane(Manager::Get()->GetProjectManager()->GetNotebook()).IsShown();
3809
3842
 
3810
3843
    mbar->Check(idViewManager, manVis);
3811
 
    mbar->Check(idViewLogManager, m_LayoutManager.GetPane(infoPane).IsShown());
 
3844
    mbar->Check(idViewLogManager, m_LayoutManager.GetPane(m_pInfoPane).IsShown());
3812
3845
    mbar->Check(idViewStatusbar, GetStatusBar() && GetStatusBar()->IsShown());
3813
 
    mbar->Check(idViewScriptConsole, m_pScriptConsole != 0);
 
3846
    mbar->Check(idViewScriptConsole, m_LayoutManager.GetPane(m_pScriptConsole).IsShown());
3814
3847
    mbar->Check(idViewFullScreen, IsFullScreen());
3815
3848
    mbar->Enable(idViewFocusEditor, ed);
3816
3849
 
3838
3871
 
3839
3872
void MainFrame::OnSearchMenuUpdateUI(wxUpdateUIEvent& event)
3840
3873
{
3841
 
    if(Manager::isappShuttingDown())
 
3874
    if (Manager::isappShuttingDown())
3842
3875
    {
3843
3876
        event.Skip();
3844
3877
        return;
3845
3878
    }
3846
3879
    cbEditor* ed = Manager::Get()->GetEditorManager() ? Manager::Get()->GetEditorManager()->GetBuiltinEditor(Manager::Get()->GetEditorManager()->GetActiveEditor()) : 0;
 
3880
 
 
3881
    bool enableGotoChanged = false;
 
3882
 
 
3883
    if (ed)
 
3884
        enableGotoChanged = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/margin/use_changebar"), true) && (ed->CanUndo() || ed->CanRedo());
 
3885
 
3847
3886
    wxMenuBar* mbar = GetMenuBar();
3848
3887
 
3849
3888
    // 'Find' and 'Replace' are always enabled for (find|replace)-in-files
 
3889
    mbar->Enable(idSearchFind, ed);
3850
3890
    mbar->Enable(idSearchFindNext, ed);
3851
3891
    mbar->Enable(idSearchFindPrevious, ed);
 
3892
    mbar->Enable(idSearchReplace, ed);
3852
3893
    mbar->Enable(idSearchGotoLine, ed);
 
3894
    mbar->Enable(idSearchGotoNextChanged, enableGotoChanged);
 
3895
    mbar->Enable(idSearchGotoPreviousChanged, enableGotoChanged);
 
3896
 
3853
3897
 
3854
3898
//    if (m_pToolbar)
3855
3899
//    {
3862
3906
 
3863
3907
void MainFrame::OnProjectMenuUpdateUI(wxUpdateUIEvent& event)
3864
3908
{
3865
 
    if(Manager::isappShuttingDown())
 
3909
    if (Manager::isappShuttingDown())
3866
3910
    {
3867
3911
        event.Skip();
3868
3912
        return;
3883
3927
 
3884
3928
void MainFrame::OnEditorUpdateUI(CodeBlocksEvent& event)
3885
3929
{
3886
 
    if(Manager::isappShuttingDown())
 
3930
    if (Manager::isappShuttingDown())
3887
3931
    {
3888
3932
        event.Skip();
3889
3933
        return;
3890
3934
    }
 
3935
 
3891
3936
    if (Manager::Get()->GetEditorManager() && event.GetEditor() == Manager::Get()->GetEditorManager()->GetActiveEditor())
3892
 
    {
3893
3937
        DoUpdateStatusBar();
3894
 
    }
 
3938
 
3895
3939
    event.Skip();
3896
3940
}
3897
3941
 
3901
3945
    if (event.GetId() == idViewManager)
3902
3946
        win = Manager::Get()->GetProjectManager()->GetNotebook();
3903
3947
    else if (event.GetId() == idViewLogManager)
3904
 
        win = infoPane;
 
3948
        win = m_pInfoPane;
3905
3949
    else if (event.GetId() == idViewToolMain)
3906
3950
        win = m_pToolbar;
3907
3951
    else
3917
3961
 
3918
3962
    if (win)
3919
3963
    {
 
3964
        // use last visible size as BestSize, Logs & others does no longer "forget" it's size
 
3965
        if (!event.IsChecked())
 
3966
             m_LayoutManager.GetPane(win).BestSize(win->GetSize());
 
3967
 
3920
3968
        m_LayoutManager.GetPane(win).Show(event.IsChecked());
3921
3969
        DoUpdateLayout();
3922
3970
    }
3944
3992
        ed->GetControl()->SetFocus();
3945
3993
}
3946
3994
 
 
3995
void MainFrame::OnSwitchTabs(wxCommandEvent& event)
 
3996
{
 
3997
    // Get the notebook from the editormanager:
 
3998
    cbAuiNotebook* nb = Manager::Get()->GetEditorManager()->GetNotebook();
 
3999
    if (!nb)
 
4000
        return;
 
4001
 
 
4002
    // Create container and add all open editors:
 
4003
    wxSwitcherItems items;
 
4004
    items.AddGroup(_("Open files"), wxT("editors"));
 
4005
    for (size_t i = 0; i < nb->GetPageCount(); ++i)
 
4006
    {
 
4007
        wxString title = nb->GetPageText(i);
 
4008
        wxWindow* window = nb->GetPage(i);
 
4009
 
 
4010
        items.AddItem(title, title, i, nb->GetPageBitmap(i)).SetWindow(window);
 
4011
    }
 
4012
 
 
4013
    // Select the focused editor:
 
4014
    int idx = items.GetIndexForFocus();
 
4015
    if (idx != wxNOT_FOUND)
 
4016
        items.SetSelection(idx);
 
4017
 
 
4018
    // Create the switcher dialog
 
4019
    wxSwitcherDialog dlg(items, wxGetApp().GetTopWindow());
 
4020
 
 
4021
    // Ctrl+Tab workaround for non windows platforms:
 
4022
    if      (platform::cocoa)
 
4023
        dlg.SetModifierKey(WXK_ALT);
 
4024
    else if (platform::gtk)
 
4025
        dlg.SetExtraNavigationKey(wxT(','));
 
4026
 
 
4027
    // Finally show the dialog:
 
4028
    int answer = dlg.ShowModal();
 
4029
 
 
4030
    // If necessary change the selected editor:
 
4031
    if ((answer == wxID_OK) && (dlg.GetSelection() != -1))
 
4032
    {
 
4033
        wxSwitcherItem& item = items.GetItem(dlg.GetSelection());
 
4034
        wxWindow* win = item.GetWindow();
 
4035
        if (win)
 
4036
        {
 
4037
            nb->SetSelection(item.GetId());
 
4038
            win->SetFocus();
 
4039
        }
 
4040
    }
 
4041
}
 
4042
 
3947
4043
void MainFrame::OnToggleFullScreen(wxCommandEvent& event)
3948
4044
{
3949
4045
    ShowFullScreen( !IsFullScreen(), wxFULLSCREEN_NOTOOLBAR// | wxFULLSCREEN_NOSTATUSBAR
3950
4046
                    | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION );
3951
4047
 
3952
 
    // Create fullscreen-close button if we're in fullscreen
3953
 
    if( IsFullScreen() )
 
4048
    // Create full screen-close button if we're in full screen
 
4049
    if ( IsFullScreen() )
3954
4050
    {
3955
4051
        //
3956
4052
        // Show the button to the bottom-right of the container
3991
4087
        DoAddPlugin(plug);
3992
4088
        const PluginInfo* info = Manager::Get()->GetPluginManager()->GetPluginInfo(plug);
3993
4089
        wxString msg = info ? info->title : wxString(_("<Unknown plugin>"));
 
4090
        #if wxCHECK_VERSION(2, 9, 0)
 
4091
        Manager::Get()->GetLogManager()->DebugLog(F(_T("%s plugin activated"), msg.wx_str()));
 
4092
        #else
3994
4093
        Manager::Get()->GetLogManager()->DebugLog(F(_T("%s plugin activated"), msg.c_str()));
 
4094
        #endif
3995
4095
    }
3996
4096
}
3997
4097
 
4073
4173
void MainFrame::OnProjectOpened(CodeBlocksEvent& event)
4074
4174
{
4075
4175
    ShowHideStartPage(true);
4076
 
    DoUpdateAppTitle();
4077
4176
    event.Skip();
4078
4177
}
4079
4178
 
4112
4211
void MainFrame::OnProjectClosed(CodeBlocksEvent& event)
4113
4212
{
4114
4213
    ShowHideStartPage();
4115
 
    DoUpdateAppTitle();
4116
4214
    event.Skip();
4117
4215
}
4118
4216
 
4125
4223
void MainFrame::OnShiftTab(wxCommandEvent& event)
4126
4224
{
4127
4225
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); // Must make sure it's cbEditor and not EditorBase
4128
 
    if(ed)
 
4226
    if (ed)
4129
4227
        ed->DoUnIndent();
4130
4228
}
4131
4229
 
4217
4315
        return;
4218
4316
    wxWindow* p = event.window;
4219
4317
    if (p)
4220
 
        infoPane->AddNonLogger(p, event.title, event.icon);
 
4318
        m_pInfoPane->AddNonLogger(p, event.title, event.icon);
4221
4319
    else
4222
4320
    {
4223
 
        p = event.logger->CreateControl(infoPane);
4224
 
        if(p)
4225
 
            infoPane->AddLogger(event.logger, p, event.title, event.icon);
 
4321
        p = event.logger->CreateControl(m_pInfoPane);
 
4322
        if (p)
 
4323
            m_pInfoPane->AddLogger(event.logger, p, event.title, event.icon);
4226
4324
    }
4227
4325
    Manager::Get()->GetLogManager()->NotifyUpdate();
4228
4326
}
4232
4330
    if (Manager::IsAppShuttingDown())
4233
4331
        return;
4234
4332
    if (event.window)
4235
 
        infoPane->RemoveNonLogger(event.window);
 
4333
        m_pInfoPane->RemoveNonLogger(event.window);
4236
4334
    else
4237
 
        infoPane->DeleteLogger(event.logger);
 
4335
        m_pInfoPane->DeleteLogger(event.logger);
4238
4336
}
4239
4337
 
4240
4338
void MainFrame::OnSwitchToLogWindow(CodeBlocksLogEvent& event)
4241
4339
{
4242
4340
    if (event.window)
4243
 
        infoPane->ShowNonLogger(event.window);
 
4341
        m_pInfoPane->ShowNonLogger(event.window);
4244
4342
    else if (event.logger)
4245
 
        infoPane->Show(event.logger);
 
4343
        m_pInfoPane->Show(event.logger);
4246
4344
}
4247
4345
 
4248
4346
void MainFrame::OnShowLogManager(CodeBlocksLogEvent& event)
4249
4347
{
4250
 
    if (!m_AutoHideLogs)
 
4348
    if (!Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_hide"), false))
4251
4349
        return;
4252
4350
 
4253
 
    m_LayoutManager.GetPane(infoPane).Show(true);
 
4351
    m_LayoutManager.GetPane(m_pInfoPane).Show(true);
4254
4352
    DoUpdateLayout();
4255
4353
}
4256
4354
 
4257
4355
void MainFrame::OnHideLogManager(CodeBlocksLogEvent& event)
4258
4356
{
4259
 
    if (!m_AutoHideLogs || m_AutoHideLockCounter > 0)
 
4357
    if (!Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_hide"), false) ||
 
4358
           m_AutoHideLockCounter > 0)
4260
4359
        return;
4261
4360
 
4262
 
    m_LayoutManager.GetPane(infoPane).Show(false);
 
4361
    m_LayoutManager.GetPane(m_pInfoPane).Show(false);
4263
4362
    DoUpdateLayout();
4264
4363
}
4265
4364
 
4266
4365
void MainFrame::OnLockLogManager(CodeBlocksLogEvent& event)
4267
4366
{
4268
 
    if (!m_AutoHideLogs)
 
4367
    if (!Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_hide"), false))
4269
4368
        return;
4270
4369
    ++m_AutoHideLockCounter;
4271
4370
}
4272
4371
 
4273
4372
void MainFrame::OnUnlockLogManager(CodeBlocksLogEvent& event)
4274
4373
{
4275
 
    if (!m_AutoHideLogs && m_AutoHideLockCounter > 0)
 
4374
    if (!Manager::Get()->GetConfigManager(_T("message_manager"))->ReadBool(_T("/auto_hide"), false) &&
 
4375
           m_AutoHideLockCounter > 0)
4276
4376
        return;
4277
4377
    if (--m_AutoHideLockCounter == 0)
4278
4378
    {
4279
 
        m_LayoutManager.GetPane(infoPane).Show(false);
 
4379
        m_LayoutManager.GetPane(m_pInfoPane).Show(false);
4280
4380
        DoUpdateLayout();
4281
4381
    }
4282
4382
}
 
4383
 
 
4384
void MainFrame::StartupDone()
 
4385
{
 
4386
    m_StartupDone = true;
 
4387
    DoUpdateLayout();
 
4388
}