I'd like to use the same configuration for my preview window as for the editor.
I am interested in all "already implemented" services concerning control management :
- colours
- folding
- indentation
- font
- bookmark
- contextual menu
- keyboard shortcuts (Ctrl+C)
For colours, I use :
EditorColourSet EdColSet;
EdColSet.Apply(EdColSet.GetLanguageForFilename(m_sPreviewFilePath), m_pSearchPreview);
But that's too limited.
Basically, for now, I need API to:
- create my control on my panel
- styling methods (SetEditorStyle()),
The idea is to provide a read only cbEditor to the user to be able to browse code without losing his "main" editor/position.
Thanks,
Dje
Just committed what I posted in my previous message. Feel free to test it.
Great !!! :D
It works as expected !!
Thanks for the evolution.
A problem still remains; I'd like to handle margin click and added this code :
index = m_pSearchPreview->GetId();
Connect(index, -1, wxEVT_SCI_MARGINCLICK, (wxObjectEventFunction) (wxEventFunction) (wxScintillaEventFunction) &cbEditor::OnMarginClick );
but cbEditor::OnMarginClick is private.
Is it possible to make it public too ?
Dje
Hi !!
but cbEditor::OnMarginClick is private.
Is it possible to make it public too ?
Waiting for an answer, I adapted the cbEditor::OnMarginClick in my class to handle only folding events.
I would like to use the default contextual menu.
I don't understand why the follwing code doesn't work:
// Panel constructor
id = m_pSearchPreview->GetId();
Connect(id, wxEVT_SCI_MARGINCLICK,
(wxObjectEventFunction) (wxEventFunction) (wxScintillaEventFunction)
&FindOccurrencesView::OnMarginClick); // OK
Connect(id, wxEVT_CONTEXT_MENU,
(wxObjectEventFunction) (wxEventFunction) (wxContextMenuEventFunction)
&FindOccurrencesView::OnContextMenu); // KO
Connect(id, wxEVT_RIGHT_UP,
(wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction)
&FindOccurrencesView::OnMouseRightUp); // KO
// End of panel constructor
// m_pSearchPreview is a cbStyledTextCtrl*
void FindOccurrencesView::OnContextMenu(wxContextMenuEvent& event)
{
m_pSearchPreview->ProcessEvent(event);
}
void FindOccurrencesView::OnMouseRightUp(wxMouseEvent& event)
{
m_pSearchPreview->ProcessEvent(event);
}
Any idea ??
When I use the EVT_CONTEXT_MENU and EVT_RIGHT_UP macros, the right clicks on panel are correctly handled, but not on cbStyledTextCtrl (for sure, no id provided...).
Thanks for support,
Dje
1) Your talking about using gui controls in a separate thread. This causes major problems with wxWidgets. Or, if executed properly, most likely needs critical sections that will cause present and future headachs to both CB and your plugin.
The list control si the only shared resource so it is not too difficult to avoid headachs.
2) If going to all this trouble, the "find in files" idea should be expanded to other utility features, such as maybe actually editing in the editor.
I already thought about it but, at the beginning, I prefer a first read only version and propose edition (if I succeed in implementation) later.
Pekan, I found one of your modification in cbEditor.cpp :
reinterpret_cast<cbEditor*>(m_pParent)->DisplayContextMenu(mp,mtEditorManager); //pecan 2006/03/22
What do you think about replacing it by :
cbEditor* pParent = dynamic_cast<cbEditor*>(m_pParent);
if ( pParent != NULL )
{
pParent->DisplayContextMenu(mp,mtEditorManager);
}
else
{
event.Skip();
}
Did you intentionnaly ommit the event.Skip ?
I think wxScintilla will be able to manage ctx menu with this evol.
Game_Ender, when you say :
It should be pretty simple to run the search in another thread and post events to the main thread when you get each result back. wxWidgets has function to posting messages from a worker thread back the main thread.
Do you mean creating a custom event in my panel class and using AddPendingEvent/ProcessEvent from my worker thread (called Search method in included in panel class for now) ?
Finally, I thought that wxWidgets was the quasi-unique multi-threaded ui framework.
When I read this post remarks, I doubt. Does any one have a sure answer on this point ??
Thanks to all,
Dje
Hi !!
Tested my cbEditor evolution from :
void cbStyledTextCtrl::OnContextMenu(wxContextMenuEvent& event)
{
if (m_pParent)
{
/* or use noeditor to handle "contect menu" key?
*/
const bool is_right_click = event.GetPosition()!=wxDefaultPosition;
const wxPoint mp(is_right_click ? event.GetPosition() : wxDefaultPosition);
reinterpret_cast<cbEditor*>(m_pParent)->DisplayContextMenu(mp,mtEditorManager); //pecan 2006/03/22
}
}
To :
void cbStyledTextCtrl::OnContextMenu(wxContextMenuEvent& event)
{
if ( m_pParent != NULL )
{
cbEditor* pParent = dynamic_cast<cbEditor*>(m_pParent);
if ( pParent != NULL )
{
const bool is_right_click = event.GetPosition()!=wxDefaultPosition;
const wxPoint mp(is_right_click ? event.GetPosition() : wxDefaultPosition);
pParent->DisplayContextMenu(mp,mtEditorManager);
}
else
{
event.Skip();
}
}
}
I don't see any side effects or undesired behaviour.
Unless any remaks, I'll SVN this change.
Dje