Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Using 'cbEVT_COMPILER_STARTED'

<< < (2/3) > >>

LETARTARE:
Thank you for the reply.
Well, I misspoke, you have right , of course.
The menu item 'Build-> Build' is the origin of the triggered by the event's compiler plugin 'cbEVT_COMPILER_STARTED'.


--- Quote ---'Build->Build'  or  'Build->Run'  or .... -> ? ? ? ? ? ->

--- Code: ---CompilerGCC::DoPrepareQueue(bool clearLog) {
....
CodeBlocksEvent evt(cbEVT_COMPILER_STARTED, 0, m_pProject, 0, this);
Manager::Get()->ProcessEvent(evt);
....
}
--- End code ---

--- End quote ---

'CompilerGCC::DoPrepareQueue' is the only place where one generates this event.

I seek to know the origin (Build, Run, Rebuild, Compile current file).
Is this possible?
If so, how ?

LETARTARE:
I solved half the problem.
In

--- Code: ---CodeBlocksEvent evt(cbEVT_COMPILER_STARTED, 0, m_pProject, 0, this);
--- End code ---
the first two parameters are used to call

--- Code: ---: wxCommandEvent(commandType, id) -> wxCommandEvent(cbEVT_COMPILER_STARTED, 0)
--- End code ---
we see that the 2nd parameter = 0, simply replace 0 by the identifier of the item in the call menu.

For this purpose in 'CompilerGCC' class :
1- create a private variable:  'int m_IdwxEvent;'
2- in ' Dispatcher(wxCommandEvent& event)' memorize 'm_IdwxEvent = event.GetId();'
3- replace the 2nd parameter '0' in all

--- Code: ---'CodeBlocksEvent evt(cbEVT_COMPILER_STARTED, m_IdwxEvent, m_pProject, 0, this);
--- End code ---

Recompiling svn10035 with those changes, obtained in

--- Code: ---void cbPre::OnPrebuild(CodeBlocksEvent& event) {
         int idevent = event.GetId();
}
--- End code ---
values ​​'idevent' only dependent on the used menu item :

* Build -> 1660
* Rebuild -> 1671
* Compile file -> 1668...
these values ​​are found identical from one cession to another.

Requires access to menus identifiers that are defined in 'compilergcc.cpp' so

--- Code: ---int idMenuCompileFromProjectManager                = wxNewId();
--- End code ---

How to access another plugin? I do not know!
Can you help me ?

oBFusCATed:

--- Quote from: LETARTARE on January 24, 2015, 09:25:42 pm ---How to access another plugin? I do not know!

--- End quote ---
It is hard and unreliable, so don't do it.


--- Quote from: LETARTARE on January 24, 2015, 09:25:42 pm ---Can you help me ?

--- End quote ---
Nope because you're not telling us what you want to do.

Keep in mind that you'll have to give a use case for a possible patch you make, if you want it to be included in repo.
So better start early and don't waste precious time.

BlueHazzard:
My be you can register a wxEVT_MENU with the ID of the menu in your plugin, but i don't know if this is working (it should be possible with some fiddeling, but there is for sure a better way)

LETARTARE:
Thank you for your advice.
@BlueHazzard

--- Quote ---you can register a wxEVT_MENU with the ID of the menu in your plugin
--- End quote ---
Of course, obviously!

Here is the solution:

--- Code: ---void cbPre::BuildMenu(wxMenuBar* menuBar)
{
int pos = menuBar->FindMenu(_("Build"));
if (pos !=-1) {
wxMenu * builder = menuBar->GetMenu(pos);
IdBuild = builder->FindItem(_("Build"));
IdCompile = builder->FindItem(_("Compile current file"));
IdRun = builder->FindItem(_("Run"));
IdBuildRun = builder->FindItem(_("Build and run"));
IdRebuild = builder->FindItem(_("Rebuild"));
IdClean = builder->FindItem(_("Clean"));
}
}
--- End code ---

IdBuild, ...are class variables.


--- Code: ---void cbPre::OnPrebuild(CodeBlocksEvent& event) {
     ....
     int eventId = event.GetId();
     print(_("eventId = ") + wxString()<<eventId);
     if (eventId ==  IdBuild) {
print(Tab + _T("Build->Build"));
      .....
      }
      else
      if (eventId ==  IdCompile) {
      ...
      }
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version