Audacity 3.2.0
Functions | Variables
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp} Namespace Reference

Functions

auto HasName (const wxString &name)
 
auto SameName (const wxWindow &window)
 
template<typename Pred >
wxWindow * UniqueWindowAmongPeers (const wxWindowList &list, const Pred &pred)
 
bool HasUniqueNameAmongPeers (const wxWindow &window, const wxWindowList &list)
 
wxWindow * FindByNameAmongPeers (const wxString &name, const wxWindowList &list)
 
void PathComponents (const wxWindow &window, wxArrayStringEx &components)
 

Variables

constexpr auto PathSeparator = ':'
 
constexpr auto EscapeCharacter = '\\'
 

Function Documentation

◆ FindByNameAmongPeers()

wxWindow * Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::FindByNameAmongPeers ( const wxString &  name,
const wxWindowList &  list 
)

Definition at line 76 of file JournalWindowPaths.cpp.

78{
79 return UniqueWindowAmongPeers(list, HasName(name));
80}
const TranslatableString name
Definition: Distortion.cpp:76
wxWindow * UniqueWindowAmongPeers(const wxWindowList &list, const Pred &pred)

References HasName(), name, and UniqueWindowAmongPeers().

Referenced by Journal::WindowPaths::FindByPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasName()

auto Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::HasName ( const wxString &  name)
inline
Returns
a predicate, on a pointer to a window, that it has the given name.

Definition at line 33 of file JournalWindowPaths.cpp.

34{
35 return [name](const wxWindow *pWindow2){
36 return pWindow2 &&
37 // Ignore wxStaticText windows, which ShuttleGui may assign the same
38 // name as the related control. Those windows are non-interactive so
39 // don't interest us for journalling.
40 !dynamic_cast<const wxStaticText *>( pWindow2 ) &&
41 // Also exclude this special window type defined in Audacity.
42 !dynamic_cast<const auStaticText *>( pWindow2 ) &&
43 pWindow2->GetName() == name; };
44}
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: auStaticText.h:20

References name.

Referenced by FindByNameAmongPeers(), and SameName().

Here is the caller graph for this function:

◆ HasUniqueNameAmongPeers()

bool Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::HasUniqueNameAmongPeers ( const wxWindow &  window,
const wxWindowList &  list 
)
Returns
whether the window is uniquely named within the given list

Definition at line 70 of file JournalWindowPaths.cpp.

71{
72 return &window == UniqueWindowAmongPeers(list, SameName(window));
73}

References SameName(), and UniqueWindowAmongPeers().

Referenced by PathComponents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PathComponents()

void Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::PathComponents ( const wxWindow &  window,
wxArrayStringEx components 
)

Definition at line 85 of file JournalWindowPaths.cpp.

86{
87 if ( dynamic_cast<const wxTopLevelWindow*>( &window ) ) {
88 if ( HasUniqueNameAmongPeers( window, wxTopLevelWindows ) ) {
89 components.push_back( window.GetName() );
90 return;
91 }
92 }
93 else if ( auto pParent = window.GetParent() ) {
94 // Recur
95 PathComponents( *pParent, components );
96 if ( !components.empty() &&
97 HasUniqueNameAmongPeers( window, pParent->GetChildren() ) ) {
98 components.push_back( window.GetName() );
99 return;
100 }
101 }
102
103 // Failure
104 components.clear();
105}
void PathComponents(const wxWindow &window, wxArrayStringEx &components)
bool HasUniqueNameAmongPeers(const wxWindow &window, const wxWindowList &list)

References HasUniqueNameAmongPeers(), and PathComponents().

Referenced by Journal::WindowPaths::FindPath(), and PathComponents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SameName()

auto Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::SameName ( const wxWindow &  window)
inline
Returns
a predicate, on a pointer to a window, that it has the same name as the given window.

Definition at line 49 of file JournalWindowPaths.cpp.

50{
51 return HasName( window.GetName() );
52}

References HasName().

Referenced by HasUniqueNameAmongPeers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UniqueWindowAmongPeers()

template<typename Pred >
wxWindow * Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::UniqueWindowAmongPeers ( const wxWindowList &  list,
const Pred &  pred 
)
Returns
unique window in the list satisfying the predicate, or null

Definition at line 56 of file JournalWindowPaths.cpp.

58{
59 const auto begin = list.begin(), end = list.end();
60 auto iter1 = std::find_if(begin, end, pred);
61 if (iter1 == end)
62 return nullptr;
63 auto next = iter1, iter2 = std::find_if(++next, end, pred);
64 if (iter2 != end)
65 return nullptr;
66 return *iter1;
67}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), and details::end().

Referenced by FindByNameAmongPeers(), and HasUniqueNameAmongPeers().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ EscapeCharacter

constexpr auto Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::EscapeCharacter = '\\'
constexpr

Definition at line 28 of file JournalWindowPaths.cpp.

◆ PathSeparator

constexpr auto Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::PathSeparator = ':'
constexpr