本文整理汇总了C++中CommandExecutionContext::GetProject方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandExecutionContext::GetProject方法的具体用法?C++ CommandExecutionContext::GetProject怎么用?C++ CommandExecutionContext::GetProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandExecutionContext
的用法示例。
在下文中一共展示了CommandExecutionContext::GetProject方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Apply
bool SaveProjectCommand::Apply(CommandExecutionContext context)
{
wxString fileName = GetString(wxT("Filename"));
bool saveCompressed = GetBool(wxT("Compress"));
bool addToHistory = GetBool(wxT("AddToHistory"));
if(fileName == wxEmptyString)
return context.GetProject()->SaveAs(saveCompressed);
else
return context.GetProject()->SaveAs(fileName,saveCompressed,addToHistory);
}
示例2: Apply
bool SetTrackInfoCommand::Apply(CommandExecutionContext context)
{
wxString mode = GetString(wxT("Type"));
long trackIndex = GetLong(wxT("TrackIndex"));
// (Note: track selection ought to be somewhere else)
long i = 0;
TrackListIterator iter(context.GetProject()->GetTracks());
Track *t = iter.First();
while (t && i != trackIndex)
{
t = iter.Next();
++i;
}
if (i != trackIndex || !t)
{
Error(wxT("TrackIndex was invalid."));
return false;
}
if (mode.IsSameAs(wxT("Name")))
{
wxString name = GetString(wxT("Name"));
t->SetName(name);
}
else
{
Error(wxT("Invalid info type!"));
return false;
}
return true;
}
示例3: Apply
bool ExportCommand::Apply(CommandExecutionContext context)
{
wxString mode = GetString(wxT("Mode"));
wxString filename = GetString(wxT("Filename"));
long numChannels = GetLong(wxT("Channels"));
bool selection = mode.IsSameAs(wxT("Selection"));
double t0, t1;
if (selection)
{
t0 = context.GetProject()->mViewInfo.selectedRegion.t0();
t1 = context.GetProject()->mViewInfo.selectedRegion.t1();
}
else
{
t0 = 0.0;
t1 = context.GetProject()->GetTracks()->GetEndTime();
}
// Find the extension and check it's valid
int splitAt = filename.Find(wxUniChar('.'), true);
if (splitAt < 0)
{
Error(wxT("Export filename must have an extension!"));
return false;
}
wxString extension = filename.Mid(splitAt+1).MakeUpper();
Exporter exporter;
bool exportSuccess = exporter.Process(context.GetProject(),
std::max(0L, numChannels),
extension, filename,
selection, t0, t1);
if (exportSuccess)
{
Status(wxString::Format(wxT("Exported to %s format: %s"),
extension, filename));
return true;
}
Error(wxString::Format(wxT("Could not export to %s format!"), extension));
return false;
}
示例4: Apply
bool ExecMenuCommand::Apply(CommandExecutionContext context)
{
CommandManager *cmdManager = context.GetProject()->GetCommandManager();
wxString cmdName = GetString(wxT("CommandName"));
auto cmdFlags = AlwaysEnabledFlag; // TODO ?
auto cmdMask = AlwaysEnabledFlag;
return cmdManager->HandleTextualCommand(cmdName, cmdFlags, cmdMask);
}
示例5: Apply
// *********************** Public Methods *******************
bool SetProjectInfoCommand::Apply(CommandExecutionContext context)
{
wxString mode = GetString(wxT("Type"));
wxString settingsString = GetString(wxT(kSetOfTracksStr));
if (mode.IsSameAs(wxT("SelectedTracks")))
SetAllTracksParam( context.GetProject()->GetTracks(), settingsString,
&SetProjectInfoCommand::setSelected);
else if (mode.IsSameAs(wxT("SoloTracks")))
SetAllTracksParam( context.GetProject()->GetTracks(), settingsString, &SetProjectInfoCommand::setSolo);
else if (mode.IsSameAs(wxT("MuteTracks")))
SetAllTracksParam( context.GetProject()->GetTracks(), settingsString, &SetProjectInfoCommand::setMute);
else
{
Error(wxT("Invalid info type!"));
return false;
}
return true;
}
示例6: Apply
// *********************** Public Methods *******************
bool GetProjectInfoCommand::Apply(CommandExecutionContext context)
{
wxString mode = GetString(wxT("Type"));
TrackList *projTracks = context.GetProject()->GetTracks();
if (mode.IsSameAs(wxT("Name")))
{
Status(context.GetProject()->GetFileName());
}
else if (mode.IsSameAs(wxT("FocusedTrackID")))
{
SendFocusedTrackIndex(context);
}
else if (mode.IsSameAs(wxT("NumberOfTracks")))
{
SendNumberOfTracks(context);
}
else if (mode.IsSameAs(wxT("SelectedTracks")))
{
SendTracksInfo(projTracks, &GetProjectInfoCommand::testSelected);
}
else if (mode.IsSameAs(wxT("LinkedTracks")))
{
SendTracksInfo(projTracks, &GetProjectInfoCommand::testLinked);
}
else if (mode.IsSameAs(wxT("SoloTracks")))
{
SendTracksInfo(projTracks, &GetProjectInfoCommand::testSolo);
}
else if (mode.IsSameAs(wxT("MuteTracks")))
{
SendTracksInfo(projTracks, &GetProjectInfoCommand::testMute);
}
else
{
Error(wxT("Invalid info type!"));
return false;
}
return true;
}
示例7: SendFocusedTrackIndex
int GetProjectInfoCommand::SendFocusedTrackIndex(CommandExecutionContext context)
{
int returnVal=0;
int focusTrackIndex=0;
TrackPanel *panel = context.GetProject()->GetTrackPanel();
Track* focusedTrack = panel->GetFocusedTrack();
TrackListIterator iter(context.GetProject()->GetTracks());
Track *t = iter.First();
while (t)
{
if(t == focusedTrack) // when we've found the focused track, we know the trackIndex
{
returnVal = focusTrackIndex;
break;
}
focusTrackIndex++;
t = iter.Next();
}
wxString trackIndexStr;
trackIndexStr << returnVal; // convert to a string to send over named pipe
Status(trackIndexStr);
return returnVal;
}
示例8: SendNumberOfTracks
int GetProjectInfoCommand::SendNumberOfTracks(CommandExecutionContext context)
{
int returnVal=0;
TrackListIterator iter(context.GetProject()->GetTracks());
Track *t = iter.First();
while (t)
{
returnVal++;
t = iter.Next();
}
wxString trackNumStr;
trackNumStr << returnVal; // convert to a string to send over named pipe
Status(trackNumStr);
return returnVal;
}
示例9: Apply
bool GetAllMenuCommands::Apply(CommandExecutionContext context)
{
bool showStatus = GetBool(wxT("ShowStatus"));
wxArrayString names;
CommandManager *cmdManager = context.GetProject()->GetCommandManager();
cmdManager->GetAllCommandNames(names, false);
wxArrayString::iterator iter;
for (iter = names.begin(); iter != names.end(); ++iter)
{
wxString name = *iter;
wxString out = name;
if (showStatus)
{
out += wxT("\t");
out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled");
}
Status(out);
}
return true;
}
示例10: Apply
bool ScreenshotCommand::Apply(CommandExecutionContext context)
{
// Read the parameters that were passed in
wxString filePath = GetString(wxT("FilePath"));
wxString captureMode = GetString(wxT("CaptureMode"));
wxString background = GetString(wxT("Background"));
// Build a suitable filename
wxString fileName = MakeFileName(filePath, captureMode);
if (background.IsSameAs(wxT("Blue")))
{
mBackground = true;
mBackColor = wxColour(51, 102, 153);
}
else if (background.IsSameAs(wxT("White")))
{
mBackground = true;
mBackColor = wxColour(255, 255, 255);
}
else
{
mBackground = false;
}
// Reset the toolbars to a known state
context.GetProject()->mToolManager->Reset();
wxTopLevelWindow *w = GetFrontWindow(context.GetProject());
if (!w)
{
return false;
}
if (captureMode.IsSameAs(wxT("window")))
{
int x = 0, y = 0;
int width, height;
w->ClientToScreen(&x, &y);
w->GetClientSize(&width, &height);
if (w != context.GetProject() && w->GetTitle() != wxT("")) {
fileName = MakeFileName(filePath,
captureMode + (wxT("-") + w->GetTitle() + wxT("-")));
}
Capture(fileName, w, x, y, width, height);
}
else if (captureMode.IsSameAs(wxT("fullwindow"))
|| captureMode.IsSameAs(wxT("windowplus")))
{
wxRect r = w->GetRect();
r.SetPosition(w->GetScreenPosition());
r = w->GetScreenRect();
if (w != context.GetProject() && w->GetTitle() != wxT("")) {
fileName = MakeFileName(filePath,
captureMode + (wxT("-") + w->GetTitle() + wxT("-")));
}
#if defined(__WXGTK__)
// In wxGTK, we need to include decoration sizes
r.width += (wxSystemSettings::GetMetric(wxSYS_BORDER_X, w) * 2);
r.height += wxSystemSettings::GetMetric(wxSYS_CAPTION_Y, w) +
wxSystemSettings::GetMetric(wxSYS_BORDER_Y, w);
#endif
if (!mBackground && captureMode.IsSameAs(wxT("windowplus")))
{
// background colour not selected but we want a background
wxRect b = GetBackgroundRect();
r.x = (r.x - b.x) >= 0 ? (r.x - b.x): 0;
r.y = (r.y - b.y) >= 0 ? (r.y - b.y): 0;
r.width += b.width;
r.height += b.height;
}
Capture(fileName, w, r.x, r.y, r.width, r.height, true);
}
else if (captureMode.IsSameAs(wxT("fullscreen")))
{
int width, height;
wxDisplaySize(&width, &height);
Capture(fileName, w, 0, 0, width, height);
}
else if (captureMode.IsSameAs(wxT("toolbars")))
{
CaptureDock(context.GetProject()->mToolManager->GetTopDock(), fileName);
}
else if (captureMode.IsSameAs(wxT("selectionbar")))
{
CaptureDock(context.GetProject()->mToolManager->GetBotDock(), fileName);
}
else if (captureMode.IsSameAs(wxT("tools")))
{
CaptureToolbar(context.GetProject()->mToolManager, ToolsBarID, fileName);
}
else if (captureMode.IsSameAs(wxT("transport")))
//.........这里部分代码省略.........
示例11: Apply
bool SelectCommand::Apply(CommandExecutionContext context)
{
wxString mode = GetString(wxT("Mode"));
if (mode.IsSameAs(wxT("None")))
{
// select none
context.GetProject()->OnSelectNone();
}
else if (mode.IsSameAs(wxT("All")))
{
// select all
context.GetProject()->OnSelectAll();
}
else if (mode.IsSameAs(wxT("Range")))
{
// select range
double t0 = GetDouble(wxT("StartTime"));
double t1 = GetDouble(wxT("EndTime"));
TrackList *tracks = context.GetProject()->GetTracks();
if (t0 < context.GetProject()->GetTracks()->GetMinOffset())
{
Error(wxT("Start time is before start of track!"));
return false;
}
if (t1 > context.GetProject()->GetTracks()->GetEndTime())
{
Error(wxT("End time is after end of track!"));
return false;
}
// PRL: to do: only setting time boundaries of current selection.
// Should other fields be left alone, or rather
// defaulted, as in the second branch?
// Or should this command take more parameters?
#if 1
context.GetProject()->mViewInfo.selectedRegion.setTimes(t0, t1);
#else
context.GetProject()->mViewInfo.selectedRegion = SelectedRegion(t0, t1);
#endif
// select specified tracks
long firstTrack = GetLong(wxT("FirstTrack"));
long lastTrack = GetLong(wxT("LastTrack"));
if (firstTrack < 0)
{
Error(wxT("Trying to select a negatively numbered track!"));
return false;
}
if (lastTrack >= tracks->GetCount())
{
Error(wxT("Trying to select higher number track than exists!"));
return false;
}
int index = 0;
TrackListIterator iter(tracks);
Track *t = iter.First();
while (t) {
bool sel = firstTrack <= index && index <= lastTrack;
t->SetSelected(sel);
if (sel)
Status(wxT("Selected track '") + t->GetName() + wxT("'"));
t = iter.Next();
++index;
}
wxASSERT(index >= lastTrack);
}
else if (mode.IsSameAs(wxT("Name")))
{
wxString name = GetString(wxT("TrackName"));
TrackList *tracks = context.GetProject()->GetTracks();
TrackListIterator iter(tracks);
Track *t = iter.First();
while (t) {
bool sel = t->GetName().IsSameAs(name);
t->SetSelected(sel);
if (sel)
Status(wxT("Selected track '") + t->GetName() + wxT("'"));
t = iter.Next();
}
}
else
{
Error(wxT("Invalid selection mode!"));
return false;
}
return true;
}