Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AutomationCommands Class Referencefinal

Command which outputs a list of available menu commands on the status channel. More...

#include <AutomationCommands.h>

Inheritance diagram for AutomationCommands:
CommandImplementation Command

Public Member Functions

 AutomationCommands (CommandType &type, std::unique_ptr< CommandOutputTarget > &&target)
 
virtual ~AutomationCommands ()
 
bool Apply (CommandExecutionContext context) override
 
- Public Member Functions inherited from CommandImplementation
void Progress (double completed)
 
void Status (const wxString &status) override
 
void Error (const wxString &message) override
 
 CommandImplementation (CommandType &type, std::unique_ptr< CommandOutputTarget > &&output)
 
virtual ~CommandImplementation ()
 
wxString GetName ()
 An instance method for getting the command name (for consistency) More...
 
CommandSignatureGetSignature ()
 Get the signature of the command. More...
 
bool SetParameter (const wxString &paramName, const wxVariant &paramValue)
 
bool Apply (CommandExecutionContext context) override
 
- Public Member Functions inherited from Command
virtual ~Command ()
 

Private Member Functions

bool SendMenus (CommandExecutionContext context)
 
bool SendMenusPlus (CommandExecutionContext context)
 
bool SendClips (CommandExecutionContext context)
 
bool SendKeycodes (CommandExecutionContext context)
 
bool SendBoxes (CommandExecutionContext context)
 
void ExploreMenu (wxMenu *pMenu, int Id, int depth)
 
void ExploreTrackPanel (CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
 
void ExploreAdornments (CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
 
void ExploreWindows (CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
 

Private Attributes

wxString mMode
 

Additional Inherited Members

- Protected Member Functions inherited from CommandImplementation
void TypeCheck (const wxString &typeName, const wxString &paramName, const wxVariant &param)
 
void CheckParam (const wxString &paramName)
 
bool HasParam (const wxString &paramName)
 
bool GetBool (const wxString &paramName)
 
long GetLong (const wxString &paramName)
 
double GetDouble (const wxString &paramName)
 
wxString GetString (const wxString &paramName)
 
- Protected Attributes inherited from CommandImplementation
std::unique_ptr
< CommandOutputTarget
mOutput
 

Detailed Description

Command which outputs a list of available menu commands on the status channel.

Definition at line 39 of file AutomationCommands.h.

Constructor & Destructor Documentation

AutomationCommands::AutomationCommands ( CommandType type,
std::unique_ptr< CommandOutputTarget > &&  target 
)
inline

Definition at line 42 of file AutomationCommands.h.

References CommandType::BuildName(), and mMode.

44  : CommandImplementation(type, std::move(target))
45  { mMode = type.BuildName();}
virtual wxString BuildName()=0
CommandImplementation(CommandType &type, std::unique_ptr< CommandOutputTarget > &&output)
Definition: Command.cpp:94
virtual AutomationCommands::~AutomationCommands ( )
inlinevirtual

Definition at line 47 of file AutomationCommands.h.

48  { }

Member Function Documentation

bool AutomationCommands::Apply ( CommandExecutionContext  context)
overridevirtual

Implements Command.

Definition at line 309 of file AutomationCommands.cpp.

References mMode, SendBoxes(), SendClips(), SendKeycodes(), SendMenus(), and SendMenusPlus().

310 {
311  wxString mode = mMode;
312 
313  bool bOK = false;
314  if (mode.IsSameAs(wxT("GetMenus")))
315  {
316  bOK = SendMenus( context );
317  }
318  if (mode.IsSameAs(wxT("GetMenusPlus")))
319  {
320  bOK = SendMenusPlus( context );
321  }
322  else if (mode.IsSameAs(wxT("GetClips")))
323  {
324  bOK = SendClips( context );
325  }
326  else if (mode.IsSameAs(wxT("GetKeycodes")))
327  {
328  bOK = SendKeycodes( context );
329  }
330  else if (mode.IsSameAs(wxT("GetBoxes")))
331  {
332  bOK = SendBoxes( context );
333  }
334 
335  return bOK;
336 }
bool SendMenusPlus(CommandExecutionContext context)
bool SendClips(CommandExecutionContext context)
bool SendBoxes(CommandExecutionContext context)
bool SendKeycodes(CommandExecutionContext context)
bool SendMenus(CommandExecutionContext context)
void AutomationCommands::ExploreAdornments ( CommandExecutionContext  context,
wxPoint  P,
wxWindow *  pWin,
int  Id,
int  depth 
)
private

Definition at line 157 of file AutomationCommands.cpp.

References CommandImplementation::Status().

Referenced by SendBoxes().

159 {
160  // Dang! wxMenuBar returns bogus screen rect.
161  // We're going to have to fake it instead.
162  //wxMenuBar * pBar = context.GetProject()->GetMenuBar();
163  //wxRect R = pBar->GetScreenRect();
164  //R.SetPosition( R.GetPosition() - P );
165 
166  wxRect R1 = pWin->GetScreenRect();
167  wxSize s = pWin->GetWindowBorderSize();
168  wxRect R( 2,32, R1.GetWidth() - s.GetWidth() * 2 -16, 22 );
169 
170  Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
171  depth, R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom(), "MenuBar" ));
172 }
void Status(const wxString &status) override
Definition: Command.cpp:178
void AutomationCommands::ExploreMenu ( wxMenu *  pMenu,
int  Id,
int  depth 
)
private

Definition at line 50 of file AutomationCommands.cpp.

References CommandImplementation::Status().

Referenced by SendMenusPlus().

50  {
51  Id;//compiler food.
52  if( !pMenu )
53  return;
54 
55  wxMenuItemList list = pMenu->GetMenuItems();
56  size_t lcnt = list.GetCount();
57  wxMenuItem * item;
58  wxString Label;
59  wxString Accel;
60 
61  for (size_t lndx = 0; lndx < lcnt; lndx++) {
62  item = list.Item(lndx)->GetData();
63  Label = item->GetItemLabelText();
64  Accel = item->GetItemLabel();
65  if( Accel.Contains("\t") )
66  Accel = Accel.AfterLast('\t');
67  else
68  Accel = "";
69  if( item->IsSeparator() )
70  Label = "----";
71  int flags = 0;
72  if (item->IsSubMenu())
73  flags +=1;
74  if (item->IsCheck() && item->IsChecked())
75  flags +=2;
76 
77  Status( wxString::Format(" [ %2i, %2i, \"%s\", \"%s\" ],", depth, flags, Label,Accel ));
78  if (item->IsSubMenu()) {
79  pMenu = item->GetSubMenu();
80  ExploreMenu( pMenu, item->GetId(), depth+1 );
81  }
82  }
83 }
void ExploreMenu(wxMenu *pMenu, int Id, int depth)
void Status(const wxString &status) override
Definition: Command.cpp:178
void AutomationCommands::ExploreTrackPanel ( CommandExecutionContext  context,
wxPoint  P,
wxWindow *  pWin,
int  Id,
int  depth 
)
private

Definition at line 174 of file AutomationCommands.cpp.

References TrackListCondIterator::First(), Track::GetHeight(), TrackPanel::GetLabelWidth(), Track::GetLink(), CommandExecutionContext::GetProject(), Overlay::GetRectangle(), AudacityProject::GetTrackPanel(), TrackPanel::GetVRulerOffset(), TrackPanel::GetVRulerWidth(), kBottomMargin, kLeftInset, kTopInset, kTopMargin, Track::Label, TrackPanel::mViewInfo, TrackListCondIterator::Next(), CommandImplementation::Status(), Track::Time, ZoomInfo::vpos, and Track::Wave.

Referenced by ExploreWindows().

176 {
177  AudacityProject * pProj = context.GetProject();
178  TrackPanel * pTP = pProj->GetTrackPanel();
179 
180  wxRect trackRect = pWin->GetRect();
181 
182  VisibleTrackIterator iter(pProj);
183  for (Track *t = iter.First(); t; t = iter.Next()) {
184  trackRect.y = t->GetY() - pTP->mViewInfo->vpos;
185  trackRect.height = t->GetHeight();
186 
187 #if 0
188  // Work in progress on getting the TCP button positions and sizes.
189  wxRect rect = trackRect;
190  Track *l = t->GetLink();
191 
192  if (t->GetLinked()) {
193  rect.height += l->GetHeight();
194  }
195 
196  switch (t->GetKind()) {
197  case Track::Wave:
198  {
199  break;
200  }
201 #ifdef USE_MIDI
202  case Track::Note:
203  {
204  break;
205  }
206 #endif // USE_MIDI
207  case Track::Label:
208  break;
209  case Track::Time:
210  break;
211  }
212  {
213  // Start with whole track rect
214  wxRect R = trackRect;
215 
216  // Now exclude left, right, and top insets
217  R.x += kLeftInset;
218  R.y += kTopInset;
219  R.width -= kLeftInset * 2;
220  R.height -= kTopInset;
221 
222  int labelw = pTP->GetLabelWidth();
223  int vrul = pTP->GetVRulerOffset();
224  bool bIsWave = true;
225  //mTrackInfo.DrawBackground(dc, R, t->GetSelected(), bIsWave, labelw, vrul);
226 
227 
228  for (Overlay * pOverlay : pTP->mOverlays) {
229  auto R2(pOverlay->GetRectangle(trackRect.GetSize()).first);
230  Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
231  depth, R2.GetLeft(), R2.GetTop(), R2.GetRight(), R2.GetBottom(), "Overthing" ));
232  }
233  }
234 #endif
235 
236  // The VRuler.
237  {
238  wxRect R = trackRect;
239  R.x += pTP->GetVRulerOffset();
240  R.y += kTopMargin;
241  R.width = pTP->GetVRulerWidth();
242  R.height -= (kTopMargin + kBottomMargin);
243  R.SetPosition( R.GetPosition() + P );
244 
245  Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
246  depth, R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom(), "VRuler" ));
247  }
248  }
249 }
int GetLabelWidth() const
Definition: TrackPanel.h:395
int GetVRulerWidth() const
std::pair< wxRect, bool > GetRectangle(wxSize size)
Definition: Overlay.cpp:17
ViewInfo * mViewInfo
Definition: TrackPanel.h:463
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:257
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:67
void Status(const wxString &status) override
Definition: Command.cpp:178
int vpos
Definition: ViewInfo.h:45
Track * GetLink() const
Definition: Track.cpp:204
TrackPanel * GetTrackPanel()
Definition: Project.h:292
AudacityProject * GetProject() const
Definition: Command.h:60
int GetHeight() const
Definition: Track.cpp:160
int GetVRulerOffset() const
Definition: TrackPanel.h:393
void AutomationCommands::ExploreWindows ( CommandExecutionContext  context,
wxPoint  P,
wxWindow *  pWin,
int  Id,
int  depth 
)
private

Definition at line 252 of file AutomationCommands.cpp.

References ExploreTrackPanel(), and CommandImplementation::Status().

Referenced by SendBoxes().

254 {
255  Id;//Compiler food.
256 
257  if( pWin->GetName() == "Track Panel" )
258  {
259  wxRect R = pWin->GetScreenRect();
260  ExploreTrackPanel( context, R.GetPosition()-P, pWin, Id, depth );
261  return;
262  }
263  wxWindowList list = pWin->GetChildren();
264  size_t lcnt = list.GetCount();
265 
266  for (size_t lndx = 0; lndx < lcnt; lndx++) {
267  wxWindow * item = list[lndx];
268  if( !item->IsShown() )
269  continue;
270  wxRect R = item->GetScreenRect();
271  R.SetPosition( R.GetPosition() - P );
272  wxString Name = item->GetName();
273  // Ignore staticLine and StaticBitmap.
274  if( Name.StartsWith( "static" ) )
275  continue;
276  // Ignore anonymous panels.
277  if( Name == "panel" )
278  continue;
279  if( Name.IsEmpty() )
280  Name = wxString("*") + item->GetToolTipText();
281  Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
282  depth, R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom(), Name ));
283  ExploreWindows( context, P, item, item->GetId(), depth+1 );
284  }
285 }
void ExploreWindows(CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
void ExploreTrackPanel(CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
void Status(const wxString &status) override
Definition: Command.cpp:178
bool AutomationCommands::SendBoxes ( CommandExecutionContext  context)
private

Definition at line 288 of file AutomationCommands.cpp.

References ExploreAdornments(), ExploreWindows(), CommandExecutionContext::GetProject(), and CommandImplementation::Status().

Referenced by Apply().

289 {
290  Status("Boxes");
291  wxWindow * pWin = context.GetProject();
292 
293  Status( "AudacityBoxes[" );
294  wxRect R = pWin->GetScreenRect();
295 
296  //R.SetPosition( wxPoint(0,0) );
297 
298  //wxString Name = pWin->GetName();
299  Status( wxString::Format(" [ %2i, %3i, %3i, %3i, %3i, \"%s\" ],",
300  0, R.GetLeft(), R.GetTop(), R.GetRight(), R.GetBottom(), "Audacity Window" ));
301  ExploreAdornments( context, pWin->GetPosition()+wxSize( 6,-1), pWin, pWin->GetId(), 1 );
302  ExploreWindows( context, pWin->GetPosition()+wxSize( 6,-1), pWin, pWin->GetId(), 1 );
303  Status( "];" );
304  return true;
305 }
void ExploreWindows(CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
void Status(const wxString &status) override
Definition: Command.cpp:178
void ExploreAdornments(CommandExecutionContext context, wxPoint P, wxWindow *pWin, int Id, int depth)
AudacityProject * GetProject() const
Definition: Command.h:60
bool AutomationCommands::SendClips ( CommandExecutionContext  context)
private

Definition at line 130 of file AutomationCommands.cpp.

References CommandManager::GetAllCommandNames(), AudacityProject::GetCommandManager(), CommandManager::GetEnabled(), CommandExecutionContext::GetProject(), name, names(), and CommandImplementation::Status().

Referenced by Apply().

131 {
132  bool bShowStatus = true;
133  wxArrayString names;
134  CommandManager *cmdManager = context.GetProject()->GetCommandManager();
135  cmdManager->GetAllCommandNames(names, false);
136  wxArrayString::iterator iter;
137  for (iter = names.begin(); iter != names.end(); ++iter)
138  {
139  wxString name = *iter;
140  wxString out = name;
141  if (bShowStatus)
142  {
143  out += wxT("\t");
144  out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled");
145  }
146  Status(out);
147  }
148  return true;
149 }
bool GetEnabled(const wxString &name)
static wxArrayString names()
Definition: Tags.cpp:697
CommandManager * GetCommandManager()
Definition: Project.h:331
CommandManager implements a system for organizing all user-callable commands.
void Status(const wxString &status) override
Definition: Command.cpp:178
const wxChar * name
Definition: Distortion.cpp:94
AudacityProject * GetProject() const
Definition: Command.h:60
void GetAllCommandNames(wxArrayString &names, bool includeMultis)
bool AutomationCommands::SendKeycodes ( CommandExecutionContext  context)
private

Definition at line 151 of file AutomationCommands.cpp.

References CommandImplementation::Status().

Referenced by Apply().

152 {
153  Status("Keycodes");
154  return true;
155 }
void Status(const wxString &status) override
Definition: Command.cpp:178
bool AutomationCommands::SendMenus ( CommandExecutionContext  context)
private

Definition at line 109 of file AutomationCommands.cpp.

References CommandManager::GetAllCommandNames(), AudacityProject::GetCommandManager(), CommandManager::GetEnabled(), CommandExecutionContext::GetProject(), name, names(), and CommandImplementation::Status().

Referenced by Apply().

110 {
111  bool bShowStatus = true;
112  wxArrayString names;
113  CommandManager *cmdManager = context.GetProject()->GetCommandManager();
114  cmdManager->GetAllCommandNames(names, false);
115  wxArrayString::iterator iter;
116  for (iter = names.begin(); iter != names.end(); ++iter)
117  {
118  wxString name = *iter;
119  wxString out = name;
120  if (bShowStatus)
121  {
122  out += wxT("\t");
123  out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled");
124  }
125  Status(out);
126  }
127  return true;
128 }
bool GetEnabled(const wxString &name)
static wxArrayString names()
Definition: Tags.cpp:697
CommandManager * GetCommandManager()
Definition: Project.h:331
CommandManager implements a system for organizing all user-callable commands.
void Status(const wxString &status) override
Definition: Command.cpp:178
const wxChar * name
Definition: Distortion.cpp:94
AudacityProject * GetProject() const
Definition: Command.h:60
void GetAllCommandNames(wxArrayString &names, bool includeMultis)
bool AutomationCommands::SendMenusPlus ( CommandExecutionContext  context)
private

Definition at line 85 of file AutomationCommands.cpp.

References ExploreMenu(), CommandExecutionContext::GetProject(), and CommandImplementation::Status().

Referenced by Apply().

86 {
87  wxMenuBar * pBar = context.GetProject()->GetMenuBar();
88  if(!pBar ){
89  wxLogDebug("No menus");
90  return false;
91  }
92 
93  size_t cnt = pBar->GetMenuCount();
94  size_t i;
95  wxString Label;
96  Status( "AudacityMenus[" );
97  for(i=0;i<cnt;i++)
98  {
99  Label = pBar->GetMenuLabelText( i );
100  Status( wxString::Format(" [ %2i, %2i, \"%s\", \"%s\" ],", 0, 0, Label, "" ));
101  ExploreMenu( pBar->GetMenu( i ), pBar->GetId(), 1 );
102  }
103  Status( "];" );
104  return true;
105 }
void ExploreMenu(wxMenu *pMenu, int Id, int depth)
void Status(const wxString &status) override
Definition: Command.cpp:178
AudacityProject * GetProject() const
Definition: Command.h:60

Member Data Documentation

wxString AutomationCommands::mMode
private

Definition at line 52 of file AutomationCommands.h.

Referenced by Apply(), and AutomationCommands().


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