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

« back to all changes in this revision

Viewing changes to LiteEditor/mainbook.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:
29
29
#include "frame.h"
30
30
#include <wx/wupdlock.h>
31
31
#include "manager.h"
 
32
#include "clang_code_completion.h"
32
33
#include "close_all_dlg.h"
33
34
#include "filechecklist.h"
34
35
#include "editor_config.h"
75
76
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_CLOSING,         NotebookEventHandler(MainBook::OnPageClosing),  NULL, this);
76
77
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_CLOSED,          NotebookEventHandler(MainBook::OnPageClosed),   NULL, this);
77
78
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_CHANGED,         NotebookEventHandler(MainBook::OnPageChanged),  NULL, this);
 
79
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_CHANGING,        NotebookEventHandler(MainBook::OnPageChanging), NULL, this);
78
80
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_X_CLICKED,       NotebookEventHandler(MainBook::OnClosePage),    NULL, this);
79
81
        m_book->Connect(wxEVT_COMMAND_BOOK_PAGE_MIDDLE_CLICKED,  NotebookEventHandler(MainBook::OnClosePage),    NULL, this);
80
82
        m_book->Connect(wxEVT_COMMAND_BOOK_BG_DCLICK,            NotebookEventHandler(MainBook::OnMouseDClick),  NULL, this);
116
118
void MainBook::OnPageClosing(NotebookEvent &e)
117
119
{
118
120
        LEditor *editor = dynamic_cast<LEditor*>(m_book->GetPage(e.GetSelection()));
119
 
        if (!editor) {
120
 
                ; // the page is not an editor
121
 
        } else if (AskUserToSave(editor)) {
 
121
        if (!editor)
 
122
                return;
 
123
        
 
124
        ClangCodeCompletion::Instance()->CancelCodeComplete();
 
125
                
 
126
        if (AskUserToSave(editor)) {
122
127
                SendCmdEvent(wxEVT_EDITOR_CLOSING, (IEditor*)editor);
123
128
        } else {
124
129
                e.Veto();
537
542
                        // We got at least one page, close the last used
538
543
                        wxWindow *tab = static_cast<wxWindow*>(arr.Item(arr.GetCount()-1));
539
544
                        ClosePage(tab);
540
 
                }
 
545
                }
541
546
        }
542
547
 
543
548
#ifdef __WXMAC__
705
710
 
706
711
        // Delete the files without notifications (it will be faster)
707
712
        wxWindowUpdateLocker locker(this);
 
713
        ClangCodeCompletion::Instance()->CancelCodeComplete();
 
714
        
708
715
        m_book->DeleteAllPages(false);
709
716
 
710
717
        // Since we got no more editors opened,
878
885
        return true;
879
886
}
880
887
 
881
 
void MainBook::ShowMessage(const wxString &message, bool showHideButton, const wxBitmap &bmp, const ButtonDetails &btn1, const ButtonDetails &btn2, const ButtonDetails &btn3)
 
888
void MainBook::ShowMessage(const wxString &message, bool showHideButton, const wxBitmap &bmp, const ButtonDetails &btn1, const ButtonDetails &btn2, const ButtonDetails &btn3)
882
889
{
883
890
        m_messagePane->ShowMessage(message, showHideButton, bmp, btn1, btn2, btn3);
884
 
}
 
891
}
885
892
 
886
 
void MainBook::OnPageChanged(NotebookEvent& e)
 
893
void MainBook::OnPageChanged(NotebookEvent& e)
887
894
{
888
895
        int newSel = e.GetSelection();
889
896
        if(newSel != wxNOT_FOUND) {
893
900
                }
894
901
        }
895
902
        e.Skip();
896
 
}
 
903
}
897
904
 
898
 
wxWindow* MainBook::GetCurrentPage()
 
905
wxWindow* MainBook::GetCurrentPage()
899
906
{
900
 
        return m_book->GetCurrentPage();
901
 
}
902
 
 
903
 
 
904
 
void MainBook::OnClosePage(NotebookEvent& e)
 
907
        return m_book->GetCurrentPage();
 
908
}
 
909
 
 
910
 
 
911
void MainBook::OnClosePage(NotebookEvent& e)
905
912
{
906
913
        wxWindowUpdateLocker locker( this );
907
914
        int where = e.GetSelection();
910
917
        }
911
918
        wxWindow *page = m_book->GetPage((size_t)where);
912
919
        if(page)
913
 
                ClosePage(page);
914
 
}
 
920
                ClosePage(page);
 
921
}
915
922
 
916
 
void MainBook::DoPositionFindBar(int where)
 
923
void MainBook::DoPositionFindBar(int where)
917
924
{
918
925
        wxWindowUpdateLocker locker(this);
919
926
        // the find bar is already placed on the MainBook, detach it
925
932
        else
926
933
                GetSizer()->Insert(where, m_quickFindBar, 0, wxTOP|wxBOTTOM|wxEXPAND);
927
934
        GetSizer()->Layout();
928
 
}
 
935
}
929
936
 
930
 
void MainBook::OnDebugEnded(wxCommandEvent& e)
 
937
void MainBook::OnDebugEnded(wxCommandEvent& e)
931
938
{
932
939
        std::vector<LEditor*> editors;
933
940
        GetAllEditors(editors);
934
941
 
935
942
        ManagerST::Get()->GetDebuggerTip()->HideDialog();
936
 
        e.Skip();
937
 
}
 
943
        e.Skip();
 
944
}
938
945
 
939
 
void MainBook::DoHandleFrameMenu(LEditor* editor)
 
946
void MainBook::DoHandleFrameMenu(LEditor* editor)
940
947
{
941
948
        // Incase of no editor or an editor with context other than C++
942
949
        // remove the context menu from the main frame
946
953
                        delete Frame::Get()->GetMenuBar()->Remove(idx);
947
954
                }
948
955
        }
949
 
}
 
956
}
950
957
 
951
 
void MainBook::OnStringHighlight(wxCommandEvent& e)
 
958
void MainBook::OnStringHighlight(wxCommandEvent& e)
952
959
{
953
960
        StringHighlightOutput *result = reinterpret_cast<StringHighlightOutput*>( e.GetClientData() );
954
961
        if(result) {
959
966
                        editor->HighlightWord( result );
960
967
                }
961
968
                delete result;
962
 
        }
 
969
        }
 
970
}
 
971
 
 
972
void MainBook::OnPageChanging(NotebookEvent& e)
 
973
{
 
974
        LEditor *editor = GetActiveEditor();
 
975
        if(editor) {
 
976
                editor->HideCompletionBox();
 
977
                editor->CallTipCancel();
 
978
        }
 
979
        e.Skip();
963
980
}