~ubuntu-branches/ubuntu/maverick/codelite/maverick

« back to all changes in this revision

Viewing changes to LiteEditor/frame.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-07-29 19:42:47 UTC
  • mfrom: (1.1.9 upstream) (18.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100729194247-cuibfk03wog33nxq
Tags: 2.6.0.4189~dfsg-1
* New upstream release.
* Bump Standards.
* Refresh patches.
* Add license information about files under ./Debugger/

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
#include "tabgroupdlg.h"
119
119
#include "tabgroupmanager.h"
120
120
#include "tabgroupspane.h"
 
121
#include "clang_code_completion.h"
121
122
#include "cl_defs.h"
122
123
 
123
124
// from auto-generated file svninfo.cpp:
124
125
extern wxString CODELITE_VERSION_STR;
125
126
extern const wxChar *SvnRevision;
126
127
 
 
128
static wxStopWatch gStopWatch;
 
129
 
127
130
// from iconsextra.cpp:
128
131
extern char *cubes_xpm[];
129
132
extern unsigned char cubes_alpha[];
138
141
                        return;\
139
142
                }\
140
143
        }
 
144
#ifdef __WXGTK__
 
145
#    define FACTOR_1 0.0
 
146
#    define FACTOR_2 0.0
 
147
#else
 
148
#    define FACTOR_1 2.0
 
149
#    define FACTOR_2 2.0
 
150
#endif
141
151
 
142
152
//----------------------------------------------------------------
143
153
// Our main frame
484
494
        EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_UPDATED_FILE_SYMBOLS, Frame::OnParsingThreadDone   )
485
495
        EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_MESSAGE             , Frame::OnParsingThreadMessage)
486
496
        EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE,     Frame::OnClearTagsCache)
 
497
        EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_RETAGGING_COMPLETED,  Frame::OnRetaggingCompelted)
 
498
        EVT_COMMAND(wxID_ANY, wxEVT_PARSE_THREAD_RETAGGING_PROGRESS,   Frame::OnRetaggingProgress)
 
499
 
487
500
        EVT_COMMAND(wxID_ANY, wxEVT_UPDATE_STATUS_BAR,                 Frame::OnSetStatusMessage)
488
501
        EVT_COMMAND(wxID_ANY, wxEVT_TAGS_DB_UPGRADE,                   Frame::OnDatabaseUpgrade )
489
502
        EVT_COMMAND(wxID_ANY, wxEVT_SHELL_COMMAND_PROCESS_ENDED,       Frame::OnBuildEnded)
636
649
        wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("go_home"));
637
650
        m_theFrame->GetFileExplorer()->GetEventHandler()->ProcessEvent(e);
638
651
 
639
 
        //load last session?
640
 
        if (m_theFrame->m_frameGeneralInfo.GetFlags() & CL_LOAD_LAST_SESSION && loadLastSession) {
641
 
                m_theFrame->LoadSession(SessionManager::Get().GetLastSession());
642
 
        }
643
 
 
644
652
        m_theFrame->SendSizeEvent();
645
653
        m_theFrame->StartTimer();
646
654
 
660
668
 
661
669
void Frame::CreateGUIControls(void)
662
670
{
 
671
        this->Freeze();
 
672
 
663
673
#ifdef __WXMSW__
664
674
        SetIcon(wxICON(aaaaa));
665
675
#else
682
692
 
683
693
        // Mac / Linux
684
694
        m_mgr.SetFlags(m_mgr.GetFlags() | wxAUI_MGR_ALLOW_ACTIVE_PANE);
 
695
        m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE,                   wxAUI_GRADIENT_VERTICAL);
 
696
 
 
697
#ifndef __WXGTK__
685
698
        wxColor col1 = DrawingUtils::DarkColour(DrawingUtils::GetPanelBgColour(), 5.0);
686
699
        wxColor col2 = DrawingUtils::DarkColour(DrawingUtils::GetPanelBgColour(), 2.0);
687
 
 
688
 
        m_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE,                   wxAUI_GRADIENT_VERTICAL);
689
 
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR,   col2);
690
 
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR, col2);
691
 
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR,            col1);
692
 
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR,          col1);
 
700
//      m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR,   col2);
 
701
//      m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR, col2);
 
702
//      m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR,            col1);
 
703
//      m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR,          col1);
 
704
#endif
693
705
 
694
706
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,       wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
695
707
        m_mgr.GetArtProvider()->SetColor(wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,     wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT));
824
836
                CreateToolbars24();
825
837
        }
826
838
 
 
839
        ClangCodeCompletion::Instance()->Initialize(PluginManager::Get());
 
840
 
827
841
        GetWorkspacePane()->GetNotebook()->SetRightClickMenu( wxXmlResource::Get()->LoadMenu(wxT("workspace_view_rmenu")) );
828
842
        GetDebuggerPane()->GetNotebook()->SetRightClickMenu(wxXmlResource::Get()->LoadMenu( wxT("debugger_view_rmenu") ) );
829
843
 
876
890
                EditorConfig::ConstIterator iter = EditorConfigST::Get()->LexerBegin();
877
891
                for (; iter != EditorConfigST::Get()->LexerEnd(); iter++) {
878
892
                        LexerConfPtr lex = iter->second;
 
893
                        wxString lexName = lex->GetName();
 
894
                        lexName.Trim().Trim(false);
 
895
 
 
896
                        if(lexName.IsEmpty())
 
897
                                continue;
 
898
 
879
899
                        item = new wxMenuItem(submenu, minId, lex->GetName(), wxEmptyString, wxITEM_CHECK);
880
900
                        m_viewAsMap[minId] = lex->GetName();
881
901
                        minId++;
1390
1410
{
1391
1411
        SessionEntry session;
1392
1412
 
1393
 
        wxWindowUpdateLocker locker(this);
1394
 
 
1395
1413
        if (SessionManager::Get().FindSession(sessionName, session)) {
1396
1414
                wxString wspFile = session.GetWorkspaceName();
1397
1415
                if (wspFile.IsEmpty() == false && wspFile != wxT("Default")) {
2238
2256
        if (GetMainBook()->GetCurrentPage() == 0) {
2239
2257
                NavMgr::Get()->Clear();
2240
2258
        }
 
2259
 
 
2260
        // Load last session?
 
2261
        if (m_frameGeneralInfo.GetFlags() & CL_LOAD_LAST_SESSION) {
 
2262
                wxWindowUpdateLocker locker(this);
 
2263
                LoadSession(SessionManager::Get().GetLastSession());
 
2264
        }
 
2265
        
 
2266
        // For some reason, under Linux we need to force the menu accelerator again
 
2267
        // otherwise some shortcuts are getting lose (e.g. Ctrl-/ to comment line)
 
2268
        ManagerST::Get()->UpdateMenuAccelerators();
2241
2269
        event.Skip();
2242
2270
}
2243
2271
 
2790
2818
        OutputViewControlBar* outputViewControlBar = new OutputViewControlBar(this, GetOutputPane()->GetNotebook(), &m_mgr, wxID_ANY);
2791
2819
        outputViewControlBar->AddAllButtons();
2792
2820
 
 
2821
 
2793
2822
        GetSizer()->Add(outputViewControlBar, 0, wxEXPAND);
2794
2823
        Layout();
2795
2824
        SetEnvStatusMessage();
 
2825
 
 
2826
        this->Thaw();
2796
2827
}
2797
2828
 
2798
2829
void Frame::OnAppActivated(wxActivateEvent &e)
2800
2831
        if (m_theFrame && e.GetActive()) {
2801
2832
                m_theFrame->ReloadExternallyModifiedProjectFiles();
2802
2833
                m_theFrame->GetMainBook()->ReloadExternallyModified(true);
 
2834
        } else if(m_theFrame) {
 
2835
                LEditor *editor = GetMainBook()->GetActiveEditor();
 
2836
                if(editor) {
 
2837
                        // we are loosing the focus
 
2838
                        editor->CallTipCancel();
 
2839
                        editor->HideCompletionBox();
 
2840
                }
2803
2841
        }
2804
2842
        e.Skip();
2805
2843
}
3081
3119
                        btn.isDefault   = true;
3082
3120
                        btn.window      = this;
3083
3121
 
3084
 
                        GetMainBook()->ShowMessage(wxT("A new version of CodeLite is available. Download it?"), true, wxXmlResource::Get()->LoadBitmap(wxT("message_pane_software_update")), btn);
 
3122
                        GetMainBook()->ShowMessage(wxT("A new version of CodeLite is available. Would you like to download it?"), true, wxXmlResource::Get()->LoadBitmap(wxT("message_pane_software_update")), btn);
3085
3123
 
3086
3124
                } else {
3087
3125
                        if (!data->GetShowMessage()) {
3722
3760
 
3723
3761
void Frame::StartTimer()
3724
3762
{
3725
 
        m_timer->Start(2500, true);
 
3763
        m_timer->Start(2000, true);
3726
3764
}
3727
3765
 
3728
3766
void Frame::OnLoadPerspective(wxCommandEvent& e)
3729
3767
{
3730
 
        wxWindowUpdateLocker locker(this);
3731
 
 
3732
3768
        long loadIt(1);
3733
3769
        EditorConfigST::Get()->GetLongValue(wxT("LoadSavedPrespective"), loadIt);
3734
3770
        if (loadIt) {
3742
3778
                        ReadFileWithConversion(file_name, pers);
3743
3779
                }
3744
3780
 
 
3781
                //wxWindowUpdateLocker locker(this);
3745
3782
                if ( pers.IsEmpty() == false && EditorConfigST::Get()->GetRevision() == SvnRevision) {
3746
3783
                        m_mgr.LoadPerspective(pers);
3747
3784
 
3889
3926
                m_mgr.Update();
3890
3927
        }
3891
3928
}
 
3929
 
 
3930
void Frame::OnRetaggingCompelted(wxCommandEvent& e)
 
3931
{
 
3932
        e.Skip();
 
3933
#if USE_PARSER_TREAD_FOR_RETAGGING_WORKSPACE
 
3934
        SetStatusMessage(wxT("Done"), 0);
 
3935
        GetWorkspacePane()->ClearProgress();
 
3936
 
 
3937
        // Clear all cached tags now that we got our database updated
 
3938
        TagsManagerST::Get()->ClearAllCaches();
 
3939
 
 
3940
        // Send event notifying parsing completed
 
3941
        std::vector<std::string>* files = (std::vector<std::string>*) e.GetClientData();
 
3942
        if(files) {
 
3943
 
 
3944
                // Print the parsing end time
 
3945
                wxLogMessage(wxT("INFO: Retag workspace completed in %d seconds (%d files were scanned)"), gStopWatch.Time()/1000, files->size());
 
3946
 
 
3947
                std::vector<wxFileName> taggedFiles;
 
3948
                for(size_t i=0; i<files->size(); i++) {
 
3949
                        taggedFiles.push_back( wxFileName(wxString(files->at(i).c_str(), wxConvUTF8)) );
 
3950
                }
 
3951
 
 
3952
                SendCmdEvent ( wxEVT_FILE_RETAGGED, ( void* ) &taggedFiles );
 
3953
                delete files;
 
3954
 
 
3955
        } else {
 
3956
 
 
3957
                wxLogMessage(wxT("INFO: Retag workspace completed in %d seconds (%d files were scanned)"), gStopWatch.Time()/1000, 0);
 
3958
        }
 
3959
#endif
 
3960
}
 
3961
 
 
3962
void Frame::OnRetaggingProgress(wxCommandEvent& e)
 
3963
{
 
3964
        e.Skip();
 
3965
#if USE_PARSER_TREAD_FOR_RETAGGING_WORKSPACE
 
3966
        if(e.GetInt() == 1) {
 
3967
                // parsing started
 
3968
                gStopWatch.Start();
 
3969
        }
 
3970
 
 
3971
        GetWorkspacePane()->UpdateProgress( e.GetInt() );
 
3972
#endif
 
3973
}