Skip to content

Commit

Permalink
SDK: Moved all codelite internal events to a new file "codelite_event…
Browse files Browse the repository at this point in the history
…s.h"

SDK: changed wxEVT_FILE_SAVED and other file management events to use clCommandEvent (was: wxCommandEvent)
Diff Viewer: fire a "wxEVT_FILE_SAVED" when a modified file is saved
  • Loading branch information
eranif committed Feb 26, 2014
1 parent a0c691b commit 569740b
Show file tree
Hide file tree
Showing 34 changed files with 681 additions and 661 deletions.
1 change: 1 addition & 0 deletions CodeLite/CodeLite.project
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<File Name="wx_xml_compatibility.h"/>
<File Name="codelite_exports.h"/>
<File Name="cl_exception.h"/>
<File Name="browse_record.h"/>
</VirtualDirectory>
<VirtualDirectory Name="GeneratedFiles">
<File Name="expression_result.h"/>
Expand Down
14 changes: 7 additions & 7 deletions Plugin/browse_record.h → CodeLite/browse_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
#ifndef BROWSE_HISTORY_H
#define BROWSE_HISTORY_H

#include "wx/string.h"
#include <wx/string.h>

class BrowseRecord
{
public:
wxString filename;
wxString project;
int lineno;
int position;
wxString filename;
wxString project;
int lineno;
int position;
public:
BrowseRecord() : filename(wxEmptyString), project(wxEmptyString), lineno(wxNOT_FOUND), position(wxNOT_FOUND) {}
BrowseRecord() : filename(wxEmptyString), project(wxEmptyString), lineno(wxNOT_FOUND), position(wxNOT_FOUND) {}

~BrowseRecord() {}
~BrowseRecord() {}
};

#endif //BROWSE_HISTORY_H
10 changes: 10 additions & 0 deletions CodeLite/event_notifier.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "event_notifier.h"
#include <wx/app.h>
#include "cl_command_event.h"
#include "../Interfaces/codelite_events.h"

static EventNotifier *eventNotifier = NULL;

Expand Down Expand Up @@ -61,3 +63,11 @@ wxFrame* EventNotifier::TopFrame()
{
return static_cast<wxFrame*>(wxTheApp->GetTopWindow());
}

void EventNotifier::PostFileSavedEvent(const wxString& filename)
{
clCommandEvent event( wxEVT_FILE_SAVED );
event.SetString( filename );
event.SetFileName( filename );
AddPendingEvent( event );
}
5 changes: 5 additions & 0 deletions CodeLite/event_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class WXDLLIMPEXP_CL EventNotifier : public wxEvtHandler
bool SendCommandEvent(int eventId, void *clientData);
void PostCommandEvent(int eventId, void *clientData);
bool SendCommandEvent(int eventId, void *clientData, const wxString &s);

/**
* @brief post a wxEVT_FILE_SAVED event
*/
void PostFileSavedEvent( const wxString &filename );
};

#endif // EVENTNOTIFIER_H
6 changes: 3 additions & 3 deletions ContinuousBuild/continuousbuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ContinuousBuild::ContinuousBuild(IManager *manager)
m_mgr->GetOutputPaneNotebook()->AddPage(m_view, CONT_BUILD, false, LoadBitmapFile(wxT("compfile.png")));

m_topWin = m_mgr->GetTheApp();
EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, wxCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this);
EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, clCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this);
EventNotifier::Get()->Connect(wxEVT_FILE_SAVE_BY_BUILD_START, wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this);
EventNotifier::Get()->Connect(wxEVT_FILE_SAVE_BY_BUILD_END, wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this);
}
Expand Down Expand Up @@ -100,12 +100,12 @@ void ContinuousBuild::UnPlug()
break;
}
}
EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVED, wxCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVED, clCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVE_BY_BUILD_START, wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this);
EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVE_BY_BUILD_END, wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this);
}

void ContinuousBuild::OnFileSaved(wxCommandEvent& e)
void ContinuousBuild::OnFileSaved(clCommandEvent& e)
{
e.Skip();
CL_DEBUG(wxT("ContinuousBuild::OnFileSaved\n"));
Expand Down
55 changes: 28 additions & 27 deletions ContinuousBuild/continuousbuild.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,45 @@
#include "plugin.h"
#include "buildprocess.h"
#include "compiler.h"
#include "cl_command_event.h"

class wxEvtHandler;
class ContinousBuildPane;
class ShellCommand;

class ContinuousBuild : public IPlugin
{
ContinousBuildPane *m_view;
wxEvtHandler * m_topWin;
BuildProcess m_buildProcess;
wxArrayString m_files;
bool m_buildInProgress;
ContinousBuildPane *m_view;
wxEvtHandler * m_topWin;
BuildProcess m_buildProcess;
wxArrayString m_files;
bool m_buildInProgress;

public:
void DoBuild(const wxString &fileName);
void DoBuild(const wxString &fileName);

public:
ContinuousBuild(IManager *manager);
~ContinuousBuild();

//--------------------------------------------
//Abstract methods
//--------------------------------------------
virtual clToolBar *CreateToolBar(wxWindow *parent);
virtual void CreatePluginMenu(wxMenu *pluginsMenu);
virtual void HookPopupMenu(wxMenu *menu, MenuType type);
virtual void UnPlug();

void StopAll();

// Event handlers
DECLARE_EVENT_TABLE()

void OnFileSaved (wxCommandEvent &e);
void OnIgnoreFileSaved (wxCommandEvent &e);
void OnStopIgnoreFileSaved (wxCommandEvent &e);
void OnBuildProcessEnded (wxCommandEvent &e);
void OnBuildProcessOutput (wxCommandEvent &e);
ContinuousBuild(IManager *manager);
~ContinuousBuild();

//--------------------------------------------
//Abstract methods
//--------------------------------------------
virtual clToolBar *CreateToolBar(wxWindow *parent);
virtual void CreatePluginMenu(wxMenu *pluginsMenu);
virtual void HookPopupMenu(wxMenu *menu, MenuType type);
virtual void UnPlug();

void StopAll();

// Event handlers
DECLARE_EVENT_TABLE()

void OnFileSaved (clCommandEvent &e);
void OnIgnoreFileSaved (wxCommandEvent &e);
void OnStopIgnoreFileSaved (wxCommandEvent &e);
void OnBuildProcessEnded (wxCommandEvent &e);
void OnBuildProcessOutput (wxCommandEvent &e);
};

#endif //ContinuousBuild
1 change: 1 addition & 0 deletions Interfaces/Interfaces.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<File Name="plugin_version.h"/>
<File Name="ikeyboard.h"/>
<File Name="cl_defs.h"/>
<File Name="codelite_events.h"/>
</VirtualDirectory>
<Dependencies/>
<Settings Type="Static Library">
Expand Down
Loading

0 comments on commit 569740b

Please sign in to comment.