User forums > Using Code::Blocks
Misc questions around CB and wxWidgets integration
ollydbg:
--- Quote from: MortenMacFly on May 10, 2012, 07:44:33 pm ---
--- Quote from: eanon on May 10, 2012, 05:59:20 pm ---EDIT : OK, installed nightly build svn 7932 and I've now nice autocompletion and quick tip on mouse hover. So, It just remains to find a smart way to reach every no-default event handlers from resource browser and UI editor ::)
--- End quote ---
Use the CC toolbar - it offers quick access to all methods in/of that file.
--- End quote ---
Today, I have the same question about this, and search the forum, I found that it was discussed here.
Now, for the image below:
I think there need a context menu on the entry like "goto declaration and goto implementation", When I search the related code, I found that wxsmith definitely know those information.
Here is the code:
cb_trunk\src\plugins\contrib\wxSmith\wxwidgets\wxseventseditor.cpp
--- Code: ---void wxsEventsEditor::PGChanged(wxsItem* Item,wxsPropertyGridManager* Grid,wxPGId Id)
{
// Just small check to avoid some invalid updates
if ( Item != m_Item )
{
return;
}
int Index;
for ( Index=0; Index<(int)m_Ids.Count(); Index++ )
{
if ( m_Ids[Index] == Id ) break;
}
if ( Index>=(int)m_Ids.Count() )
{
return;
}
wxString Selection = Grid->GetPropertyValueAsString(Id);
if ( Selection == NoneStr )
{
m_Events->SetHandler(Index,_T(""));
}
else if ( Selection == AddNewStr )
{
m_Events->SetHandler(Index,GetNewFunction(m_Events->GetDesc(Index)));
BuildEvents(m_Item,Grid);
}
else
{
m_Events->SetHandler(Index,Selection);
GotoHandler(Index);
}
m_Data->NotifyChange(m_Item);
}
--- End code ---
and
--- Code: ---bool wxsEventsEditor::GotoHandler(int Index)
{
cbEditor* Editor = Manager::Get()->GetEditorManager()->Open(m_Source);
if ( !Editor )
{
return false;
}
wxString FunctionName = m_Events->GetHandler(Index);
if ( FunctionName.IsEmpty() )
{
return false;
}
cbStyledTextCtrl* Ctrl = Editor->GetControl();
wxString FullText = Ctrl->GetText();
int Begin = 0;
int End = Ctrl->GetLength();
while ( Begin < End )
{
int Pos = Ctrl->FindText(Begin,End,FunctionName,wxSCI_FIND_MATCHCASE);
if ( Pos < 0 ) break;
// Checking if there's <ClassName> :: sequence before function
int Before = Pos;
while ( --Before >= 0 )
{
wxChar Ch = Ctrl->GetCharAt(Before);
if ( Ch!=' ' && Ch!='\t' && Ch!='\r' && Ch!='\n' ) break;
}
if ( Before >= 1 )
{
if ( Ctrl->GetCharAt(Before) == ':' && Ctrl->GetCharAt(Before-1) == ':' )
{
Before--;
while ( --Before >= 0 )
{
wxChar Ch = Ctrl->GetCharAt(Before);
if ( Ch!=' ' && Ch!='\t' && Ch!='\r' && Ch!='\n' ) break;
}
if ( Before > 0 )
{
wxString ClassName;
while ( Before>=0 )
{
wxChar Ch = Ctrl->GetCharAt(Before--);
if ( (Ch<'a' || Ch>'z') && (Ch<'A' || Ch>'Z') && (Ch<'0' || Ch>'9') && (Ch!='_') ) break;
ClassName = Ch + ClassName;
}
if ( ClassName == m_Class )
{
// Test if there's ( after function name
int After = Pos + FunctionName.Length();
while ( After < End )
{
wxChar Ch = Ctrl->GetCharAt(After);
if ( Ch!=' ' && Ch!='\t' && Ch!='\r' && Ch!='\n' ) break;
After++;
}
if ( After < End )
{
if ( Ctrl->GetCharAt(After) == '(' )
{
Editor->GotoLine(Ctrl->LineFromPosition(Pos));
return true;
}
}
}
}
}
}
Begin = Pos + FunctionName.Length();
}
return false;
}
--- End code ---
So, you see the two default entry is:
--- Code: ---namespace
{
const wxString NoneStr = _("-- None --");
const wxString AddNewStr = _("-- Add new handler --");
}
--- End code ---
What I think is that we can call wxsmith's function
--- Code: ---GotoHandler(Index);
--- End code ---
I think wxsmith know every thing about this. (at least the implementation and declaration).
But I'm not a wxsmith guru, so you may find some time to implement this nice feature.
ollydbg:
I have a very dirty patch, that emulate the same OnChange event, so you double click on the event item, and it will jump to the event handler implementation.
--- Code: ---Index: wxspropertygridmanager.cpp
===================================================================
--- wxspropertygridmanager.cpp (revision 8067)
+++ wxspropertygridmanager.cpp (working copy)
@@ -101,6 +101,41 @@
MainContainer->OnExtraPropertyChanged(this,ID);
}
+void wxsPropertyGridManager::OnDoubleClick(wxPropertyGridEvent& event)
+{
+ wxPGId ID = event.GetProperty();
+ for ( size_t i = PGIDs.Count(); i-- > 0; )
+ {
+ if ( PGIDs[i] == ID )
+ {
+ wxsPropertyContainer* Container = PGContainers[i];
+ if ( !PGEnteries[i]->PGRead(Container,this,ID,PGIndexes[i]) )
+ {
+ wxString ErrorMsg;
+ ErrorMsg << _T("wxSmith: Couldn't read value from wxsPropertyGridManager")
+ << _T(", propgrid name=") << PGEnteries[i]->GetPGName()
+ << _T(", date name=") << PGEnteries[i]->GetDataName()
+ << _T(", type name=") << PGEnteries[i]->GetTypeName();
+ Manager::Get()->GetLogManager()->DebugLogError(ErrorMsg);
+ }
+
+ // Notifying about property change
+ Container->NotifyPropertyChangeFromPropertyGrid();
+
+ // Notifying about sub property change
+ if ( Container!=MainContainer && MainContainer!=0 )
+ {
+ MainContainer->OnSubPropertyChanged(Container);
+ }
+ Update(0);
+ return;
+ }
+ }
+
+ // Did not found changed id, it's time to say to container
+ MainContainer->OnExtraPropertyChanged(this,ID);
+}
+
void wxsPropertyGridManager::Update(wxsPropertyContainer* PC)
{
if ( PC && PGContainersSet.find(PC) == PGContainersSet.end() )
@@ -306,4 +341,5 @@
BEGIN_EVENT_TABLE(wxsPropertyGridManager,wxPropertyGridManager)
EVT_PG_CHANGED(-1,wxsPropertyGridManager::OnChange)
+ EVT_PG_DOUBLE_CLICK(-1,wxsPropertyGridManager::OnDoubleClick)
END_EVENT_TABLE()
Index: wxspropertygridmanager.h
===================================================================
--- wxspropertygridmanager.h (revision 8067)
+++ wxspropertygridmanager.h (working copy)
@@ -95,7 +95,7 @@
/** \brief Function unbinding given container
*
- * This function destroys all property enteries using given container.
+ * This function destroys all property entries using given container.
* It's automatically called in container's destructor but it may
* be used in other places too.
*
@@ -130,9 +130,12 @@
/** \brief Changing main property container */
void SetNewMainContainer(wxsPropertyContainer* NewMain);
- /** \brief Handler for roporting change event */
+ /** \brief Handler for reporting change event */
void OnChange(wxPropertyGridEvent& event);
+ /** \brief Handler for jumping to event handler */
+ void OnDoubleClick(wxPropertyGridEvent& event);
+
/** \brief Data of selected property */
struct SelectionData
{
@@ -150,7 +153,7 @@
/** \brief Restoring selected property
*
* \param Data structure containing selection data, if NULL,
- * selection will be resotred from internal variable
+ * selection will be restored from internal variable
*/
void RestoreSelected(const SelectionData* Data=0);
@@ -171,7 +174,7 @@
WX_DECLARE_HASH_SET(wxsPropertyContainer*,wxPointerHash,wxPointerEqual,wxSetCont);
wxArrayPGId PGIDs; ///< \brief Array of property identifiers
- wxArrayProps PGEnteries; ///< \brief Array mapping enteries in grid to properties
+ wxArrayProps PGEnteries; ///< \brief Array mapping entries in grid to properties
wxArrayLong PGIndexes; ///< \brief Array of internal property indexes used inside wxsProperty
wxArrayCont PGContainers; ///< \brief Array of container objects associated with properties
wxSetCont PGContainersSet; ///< \brief Set of used containers, will be used to quickly determine if given container is used in manager
@@ -190,7 +193,7 @@
friend class wxsPropertyContainer;
};
-/** \brief Macro for easy acces to property grid manager */
+/** \brief Macro for easy access to property grid manager */
#define wxsPGRID() wxsPropertyGridManager::Get()
#endif
--- End code ---
The patch is too dirty because I'm not quite familiar with wxsPropertyGridManager and related controls.
The function wxsPropertyGridManager::OnDoubleClick need to be refined to purely handle the "jump" feature. :)
eranon:
--- Quote from: ollydbg on June 30, 2012, 05:09:27 pm ---But I'm not a wxsmith guru, so you may find some time to implement this nice feature.
--- End quote ---
I was on other fields since june and this is the reason why of the delay between your post and my reaction, Ollydbg. I fully agree : it would be nice to have this kind of feature (a way to reach declaration or implementation of an event-handler from the events list).
Maybe there's an offcial place to submit feature ?!
ollydbg:
--- Quote from: eanon on August 11, 2012, 09:49:20 pm ---
--- Quote from: ollydbg on June 30, 2012, 05:09:27 pm ---But I'm not a wxsmith guru, so you may find some time to implement this nice feature.
--- End quote ---
I was on other fields since june and this is the reason why of the delay between your post and my reaction, Ollydbg. I fully agree : it would be nice to have this kind of feature (a way to reach declaration or implementation of an event-handler from the events list).
Maybe there's an offcial place to submit feature ?!
--- End quote ---
You can add a feature request, I have already add one days ago, see:
https://developer.berlios.de/feature/?func=detailfeature&feature_id=5540&group_id=5358
eranon:
Seen ! So, not necessary to create a double entry :)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version