Code::Blocks  SVN r11506
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ClassBrowser Class Reference

symbol browser panel is shown in the Management panel besides projects browser panel. More...

#include <classbrowser.h>

Inheritance diagram for ClassBrowser:
Collaboration diagram for ClassBrowser:

Public Member Functions

 ClassBrowser (wxWindow *parent, NativeParser *np)
 class constructor More...
 
virtual ~ClassBrowser ()
 class destructor More...
 
void SetParser (ParserBase *parser)
 Set the Parser object associated with the class browser. More...
 
void UpdateClassBrowserView (bool checkHeaderSwap=false)
 update or refresh the symbol browser trees More...
 
void UpdateSash ()
 update the position sash bar between top tree and the bottom tree, the position (percentage) of the two trees are saved in the C::B's configuration file. More...
 

Private Member Functions

void OnTreeItemDoubleClick (wxTreeEvent &event)
 handler for the mouse double click on a tree item, we usually make a jump to the associated token's position. More...
 
void OnTreeItemRightClick (wxTreeEvent &event)
 show a context menu More...
 
void OnJumpTo (wxCommandEvent &event)
 the handler for jump to declaration or jump to definition menu item More...
 
void OnRefreshTree (wxCommandEvent &event)
 force rebuilding the tree More...
 
void OnForceReparse (wxCommandEvent &event)
 reparse the current project More...
 
void OnCBViewMode (wxCommandEvent &event)
 user change the view mode (View Inheritance or View the bottom tree) More...
 
void OnCBExpandNS (wxCommandEvent &event)
 whether automatically expand the namespace option switch More...
 
void OnViewScope (wxCommandEvent &event)
 the view scope choice has changed, user can switch between view everything, view a single file, or view the project More...
 
void OnDebugSmartSense (wxCommandEvent &event)
 whether print the debug log message More...
 
void OnSetSortType (wxCommandEvent &event)
 sort type changed More...
 
void OnSearch (wxCommandEvent &event)
 when user try to search a word in the symbols tree More...
 
bool FoundMatch (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &item)
 string compare between the search and the token's name associated with item More...
 
wxTreeItemId FindNext (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &start)
 get the next item of the "start" item, if no next item in the current level, go up one level More...
 
wxTreeItemId FindChild (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &start, bool recurse=false, bool partialMatch=false)
 get a child of the parent item, which matches the "search" key More...
 
bool RecursiveSearch (const wxString &search, wxTreeCtrl *tree, const wxTreeItemId &parent, wxTreeItemId &result)
 find an item whose item name matches the "search" key string in the sub-tree More...
 
void ShowMenu (wxTreeCtrl *tree, wxTreeItemId id, const wxPoint &pt)
 build and show a context menu when user right click on the tree item "id" More...
 
void ThreadedBuildTree (cbProject *activeProject)
 create a thread to update the symbol tree, if the thread is already created, just pause and resume the thread. More...
 
void OnTreeItemExpanding (wxTreeEvent &event)
 expanding one node of top tree More...
 
void OnTreeItemCollapsing (wxTreeEvent &event)
 collapse one node of the top tree More...
 
void OnTreeSelChanged (wxTreeEvent &event)
 item selection changed in the top tree More...
 
void OnThreadEvent (wxCommandEvent &event)
 class browser builder thread will send notification event to the parent, this is the event handler function currently, there are three kinds of events send from the builder thread More...
 

Private Attributes

NativeParserm_NativeParser
 the pointer to parser manager object More...
 
CCTreeCtrlm_CCTreeCtrl
 the top(main) level tree control, see above diagram for details More...
 
CCTreeCtrlm_CCTreeCtrlBottom
 the bottom tree control, mainly used to show the member variable and member functions More...
 
wxTreeCtrlm_TreeForPopupMenu
 remember the context menu is created from which tree control, the upper or the bottom More...
 
ParserBasem_Parser
 a pointer to the associated parser object More...
 
wxString m_ActiveFilename
 source file name of active editor, used for filtering(if view option is Current file's symbols) More...
 
wxSemaphore m_ClassBrowserSemaphore
 semaphore to synchronize the GUI(class browser) and the tree builder thread, when the GUI post the semaphore, the waiting thread start doing the job More...
 
ClassBrowserBuilderThreadm_ClassBrowserBuilderThread
 a wxThread used to build the wxTreeCtrl for the top and bottom in the class(symbol) browser because it always take many seconds to build the trees, so those work were delegated to a worker thread. More...
 

Detailed Description

symbol browser panel is shown in the Management panel besides projects browser panel.

It mainly has four parts, see the simple diagram below.

+----------------+
| view option |
+----------------+
| search box |
+----------------+
| top tree |
| |
+----------------+
| bottom tree |
| |
+----------------+

1, the view option is a list box to let user choose which tokens should be shown in the trees it can either show the tokens for the whole workspace, or only the active C::B project, or the active editor (source files) 2, search box, a combo-box lets user enter texts for searching a specific symbol 3, top tree, a wxTreeCtrl shows the mostly top level symbols, such as the global namespaces, macro definitions, class definition in global namesapces. 4, bottom tree, shows members of the select item in the top tree, e.g. if a user select a class, then, this tree will show all the member variables of the class. Note, this tree can be hidden by the user in CC's setting dialog, in this case only the top tree is shown on the panel.

Definition at line 53 of file classbrowser.h.

Constructor & Destructor Documentation

◆ ClassBrowser()

ClassBrowser::ClassBrowser ( wxWindow parent,
NativeParser np 
)

class constructor

Parameters
parentthe parent window
npthe NativeParser instance, which contains all the images for the wxTreeCtrl

Definition at line 132 of file classbrowser.cpp.

References _T, bdfFile, wxXmlResource::Get(), Manager::Get(), wxSystemSettings::GetColour(), Manager::GetConfigManager(), wxXmlResource::LoadPanel(), ConfigManager::ReadInt(), wxSYS_COLOUR_BTNFACE, and wxTE_PROCESS_ENTER.

◆ ~ClassBrowser()

ClassBrowser::~ClassBrowser ( )
virtual

Member Function Documentation

◆ FindChild()

wxTreeItemId ClassBrowser::FindChild ( const wxString search,
wxTreeCtrl tree,
const wxTreeItemId start,
bool  recurse = false,
bool  partialMatch = false 
)
private

get a child of the parent item, which matches the "search" key

Parameters
recursewhether recursive search to the children of the children "search" key is the prefix of the item's text

Definition at line 408 of file classbrowser.cpp.

References wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetItemText(), wxTreeCtrl::GetNextChild(), wxTreeItemId::IsOk(), wxTreeCtrl::ItemHasChildren(), m_CCTreeCtrl, wxString::StartsWith(), and wxTreeItemId::Unset().

Referenced by OnSearch().

◆ FindNext()

wxTreeItemId ClassBrowser::FindNext ( const wxString search,
wxTreeCtrl tree,
const wxTreeItemId start 
)
private

get the next item of the "start" item, if no next item in the current level, go up one level

Note
it looks like the "search" parameter is not used in this function
--node1
|--start item
|--returned item(a)
--node2
|--returned item(b)
return the item(a) in the same level, if there is no such item, then return item(b)

Definition at line 393 of file classbrowser.cpp.

References wxTreeCtrl::GetItemParent(), wxTreeCtrl::GetNextSibling(), and wxTreeItemId::IsOk().

Referenced by RecursiveSearch().

◆ FoundMatch()

bool ClassBrowser::FoundMatch ( const wxString search,
wxTreeCtrl tree,
const wxTreeItemId item 
)
private

string compare between the search and the token's name associated with item

Parameters
searchthe search key
treetree control
itemthe item id of the tree
Returns
true if their name matches

Definition at line 378 of file classbrowser.cpp.

References _T, wxTreeCtrl::GetItemData(), ClassTreeData::GetToken(), wxString::Lower(), Token::m_Name, and wxString::StartsWith().

Referenced by RecursiveSearch().

◆ OnCBExpandNS()

void ClassBrowser::OnCBExpandNS ( wxCommandEvent event)
private

whether automatically expand the namespace option switch

Definition at line 663 of file classbrowser.cpp.

References ParserBase::ClassBrowserOptions(), BrowserOptions::expandNS, idCBExpandNS, m_Parser, UpdateClassBrowserView(), and ParserBase::WriteOptions().

◆ OnCBViewMode()

void ClassBrowser::OnCBViewMode ( wxCommandEvent event)
private

◆ OnDebugSmartSense()

void ClassBrowser::OnDebugSmartSense ( wxCommandEvent event)
private

whether print the debug log message

Definition at line 702 of file classbrowser.cpp.

References s_DebugSmartSense.

◆ OnForceReparse()

void ClassBrowser::OnForceReparse ( wxCommandEvent event)
private

reparse the current project

Definition at line 639 of file classbrowser.cpp.

References m_NativeParser, and NativeParser::ReparseCurrentProject().

◆ OnJumpTo()

void ClassBrowser::OnJumpTo ( wxCommandEvent event)
private

◆ OnRefreshTree()

void ClassBrowser::OnRefreshTree ( wxCommandEvent event)
private

force rebuilding the tree

Definition at line 634 of file classbrowser.cpp.

References UpdateClassBrowserView().

◆ OnSearch()

void ClassBrowser::OnSearch ( wxCommandEvent event)
private

◆ OnSetSortType()

void ClassBrowser::OnSetSortType ( wxCommandEvent event)
private

◆ OnThreadEvent()

void ClassBrowser::OnThreadEvent ( wxCommandEvent event)
private

class browser builder thread will send notification event to the parent, this is the event handler function currently, there are three kinds of events send from the builder thread

See also
EThreadEvent for details.

Definition at line 972 of file classbrowser.cpp.

References ClassBrowserBuilderThread::buildTreeEnd, ClassBrowserBuilderThread::buildTreeStart, ParserBase::ClassBrowserOptions(), CCLogger::DebugLog(), CCLogger::Get(), m_ClassBrowserBuilderThread, m_Parser, ClassBrowserBuilderThread::selectItemRequired, ClassBrowserBuilderThread::SelectItemRequired(), BrowserOptions::treeMembers, and wxT.

◆ OnTreeItemCollapsing()

void ClassBrowser::OnTreeItemCollapsing ( wxTreeEvent event)
private

collapse one node of the top tree

Definition at line 952 of file classbrowser.cpp.

References ClassBrowserBuilderThread::CollapseItem(), wxTreeEvent::GetItem(), and m_ClassBrowserBuilderThread.

◆ OnTreeItemDoubleClick()

void ClassBrowser::OnTreeItemDoubleClick ( wxTreeEvent event)
private

◆ OnTreeItemExpanding()

void ClassBrowser::OnTreeItemExpanding ( wxTreeEvent event)
private

expanding one node of top tree

Note
that the bottom tree do not actually show a tree structure, it just list the members of the selected node in the top tree

Definition at line 942 of file classbrowser.cpp.

References ClassBrowserBuilderThread::ExpandItem(), wxTreeEvent::GetItem(), and m_ClassBrowserBuilderThread.

◆ OnTreeItemRightClick()

void ClassBrowser::OnTreeItemRightClick ( wxTreeEvent event)
private

show a context menu

Definition at line 474 of file classbrowser.cpp.

References wxTreeEvent::GetItem(), wxTreeCtrl::SelectItem(), and ShowMenu().

◆ OnTreeSelChanged()

void ClassBrowser::OnTreeSelChanged ( wxTreeEvent event)
private

◆ OnViewScope()

void ClassBrowser::OnViewScope ( wxCommandEvent event)
private

◆ RecursiveSearch()

bool ClassBrowser::RecursiveSearch ( const wxString search,
wxTreeCtrl tree,
const wxTreeItemId parent,
wxTreeItemId result 
)
private

find an item whose item name matches the "search" key string in the sub-tree

Parameters
parentsearch will start from this parent item, and recursively to the sub-tree

Definition at line 436 of file classbrowser.cpp.

References FindNext(), FoundMatch(), wxTreeCtrl::GetFirstChild(), wxTreeCtrl::GetNextChild(), wxTreeItemId::IsOk(), and wxTreeCtrl::ItemHasChildren().

◆ SetParser()

void ClassBrowser::SetParser ( ParserBase parser)

Set the Parser object associated with the class browser.

the browser tree must access to the TokenTree, so it needs a ParserBase pointer

Parameters
parserthe Parser instance

Definition at line 184 of file classbrowser.cpp.

References bdfProject, bdfWorkspace, ParserBase::ClassBrowserOptions(), CCLogger::DebugLog(), BrowserOptions::displayFilter, CCLogger::Get(), NativeParser::IsParserPerWorkspace(), m_NativeParser, m_Parser, UpdateClassBrowserView(), ParserBase::WriteOptions(), and wxT.

Referenced by NativeParser::CreateClassBrowser(), NativeParser::SetParser(), and ~ClassBrowser().

◆ ShowMenu()

void ClassBrowser::ShowMenu ( wxTreeCtrl tree,
wxTreeItemId  id,
const wxPoint pt 
)
private

◆ ThreadedBuildTree()

void ClassBrowser::ThreadedBuildTree ( cbProject activeProject)
private

◆ UpdateClassBrowserView()

void ClassBrowser::UpdateClassBrowserView ( bool  checkHeaderSwap = false)

update or refresh the symbol browser trees

There are many cases the tree need to be updated. E.g. if the View option of the tree is the "Current file's symbols", the user switch the editor to a new source file, then the tree should be updated(rebuild).

Parameters
checkHeaderSwapif true, we should check if the new editor opened has the same base file as the old file. E.g. If you are currently viewing a file named A.cpp, and you switch to A.h in this case, the tree should not be updated, because tokens(symbols) in both files were already shown. False if you need to update the tree without such optimization.

Definition at line 212 of file classbrowser.cpp.

References _T, wxString::AfterLast(), wxString::BeforeLast(), ParserBase::ClassBrowserOptions(), wxString::Clear(), CCLogger::DebugLog(), wxString::Find(), CCLogger::Get(), Manager::Get(), EditorManager::GetBuiltinActiveEditor(), NativeParser::GetCurrentProject(), Manager::GetEditorManager(), EditorBase::GetFilename(), NativeParser::GetProjectByParser(), Manager::IsAppShuttingDown(), NativeParser::IsParserPerWorkspace(), wxString::IsSameAs(), m_ActiveFilename, m_CCTreeCtrl, m_CCTreeCtrlBottom, m_NativeParser, m_Parser, wxSplitterWindow::SplitHorizontally(), ThreadedBuildTree(), TRACE, BrowserOptions::treeMembers, wxSplitterWindow::Unsplit(), wxString::wx_str(), wxNOT_FOUND, and wxT.

Referenced by OnCBExpandNS(), OnCBViewMode(), NativeParser::OnEditorActivated(), OnRefreshTree(), OnSetSortType(), OnViewScope(), SetParser(), and NativeParser::UpdateClassBrowser().

◆ UpdateSash()

void ClassBrowser::UpdateSash ( )

update the position sash bar between top tree and the bottom tree, the position (percentage) of the two trees are saved in the C::B's configuration file.

Definition at line 205 of file classbrowser.cpp.

References _T, Manager::Get(), Manager::GetConfigManager(), and ConfigManager::ReadInt().

Referenced by NativeParser::CreateClassBrowser().

Member Data Documentation

◆ m_ActiveFilename

wxString ClassBrowser::m_ActiveFilename
private

source file name of active editor, used for filtering(if view option is Current file's symbols)

Definition at line 210 of file classbrowser.h.

Referenced by ThreadedBuildTree(), and UpdateClassBrowserView().

◆ m_CCTreeCtrl

CCTreeCtrl* ClassBrowser::m_CCTreeCtrl
private

the top(main) level tree control, see above diagram for details

Definition at line 195 of file classbrowser.h.

Referenced by FindChild(), OnSearch(), ShowMenu(), ThreadedBuildTree(), and UpdateClassBrowserView().

◆ m_CCTreeCtrlBottom

CCTreeCtrl* ClassBrowser::m_CCTreeCtrlBottom
private

the bottom tree control, mainly used to show the member variable and member functions

Definition at line 198 of file classbrowser.h.

Referenced by OnSearch(), ThreadedBuildTree(), and UpdateClassBrowserView().

◆ m_ClassBrowserBuilderThread

ClassBrowserBuilderThread* ClassBrowser::m_ClassBrowserBuilderThread
private

a wxThread used to build the wxTreeCtrl for the top and bottom in the class(symbol) browser because it always take many seconds to build the trees, so those work were delegated to a worker thread.

Definition at line 221 of file classbrowser.h.

Referenced by OnThreadEvent(), OnTreeItemCollapsing(), OnTreeItemExpanding(), OnTreeSelChanged(), ThreadedBuildTree(), and ~ClassBrowser().

◆ m_ClassBrowserSemaphore

wxSemaphore ClassBrowser::m_ClassBrowserSemaphore
private

semaphore to synchronize the GUI(class browser) and the tree builder thread, when the GUI post the semaphore, the waiting thread start doing the job

Definition at line 215 of file classbrowser.h.

Referenced by ThreadedBuildTree(), and ~ClassBrowser().

◆ m_NativeParser

NativeParser* ClassBrowser::m_NativeParser
private

the pointer to parser manager object

Definition at line 192 of file classbrowser.h.

Referenced by OnForceReparse(), OnJumpTo(), OnTreeItemDoubleClick(), OnViewScope(), SetParser(), ThreadedBuildTree(), and UpdateClassBrowserView().

◆ m_Parser

ParserBase* ClassBrowser::m_Parser
private

◆ m_Search

wxComboBox* ClassBrowser::m_Search
private

the search combobox in the header of the window

Definition at line 204 of file classbrowser.h.

Referenced by OnSearch().

◆ m_TreeForPopupMenu

wxTreeCtrl* ClassBrowser::m_TreeForPopupMenu
private

remember the context menu is created from which tree control, the upper or the bottom

Definition at line 201 of file classbrowser.h.

Referenced by OnJumpTo(), and ShowMenu().


The documentation for this class was generated from the following files: