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 }

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 excluse this special window type defined in Audacity.
42  !dynamic_cast<const auStaticText *>( pWindow2 ) &&
43  pWindow2->GetName() == name; };
44 }

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 }

References HasUniqueNameAmongPeers().

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

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 }

Referenced by FindByNameAmongPeers(), and HasUniqueNameAmongPeers().

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
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::UniqueWindowAmongPeers
wxWindow * UniqueWindowAmongPeers(const wxWindowList &list, const Pred &pred)
Definition: JournalWindowPaths.cpp:56
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::HasName
auto HasName(const wxString &name)
Definition: JournalWindowPaths.cpp:33
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::HasUniqueNameAmongPeers
bool HasUniqueNameAmongPeers(const wxWindow &window, const wxWindowList &list)
Definition: JournalWindowPaths.cpp:70
name
const TranslatableString name
Definition: Distortion.cpp:98
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::SameName
auto SameName(const wxWindow &window)
Definition: JournalWindowPaths.cpp:49
auStaticText
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: auStaticText.h:20
Journal::WindowPaths::anonymous_namespace{JournalWindowPaths.cpp}::PathComponents
void PathComponents(const wxWindow &window, wxArrayStringEx &components)
Definition: JournalWindowPaths.cpp:85