mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 23:30:07 +02:00
Add code to capture menus
So far, this only walks the menus, printing out their contents to debug.
This commit is contained in:
parent
879579475d
commit
c6b4e2fffe
@ -70,6 +70,7 @@ class ScreenFrame final : public wxFrame
|
||||
void OnCaptureWindowPlus(wxCommandEvent & event);
|
||||
void OnCaptureFullScreen(wxCommandEvent & event);
|
||||
void OnCaptureToolbars(wxCommandEvent & event);
|
||||
void OnCaptureMenus(wxCommandEvent & event);
|
||||
void OnCaptureSelectionBar(wxCommandEvent & event);
|
||||
void OnCaptureTools(wxCommandEvent & event);
|
||||
void OnCaptureTransport(wxCommandEvent & event);
|
||||
@ -178,6 +179,7 @@ enum
|
||||
IdDelayCheckBox,
|
||||
|
||||
IdCaptureToolbars,
|
||||
IdCaptureMenus,
|
||||
IdCaptureSelectionBar,
|
||||
IdCaptureTools,
|
||||
IdCaptureTransport,
|
||||
@ -222,6 +224,7 @@ BEGIN_EVENT_TABLE(ScreenFrame, wxFrame)
|
||||
EVT_BUTTON(IdCaptureFullScreen, ScreenFrame::OnCaptureFullScreen)
|
||||
|
||||
EVT_BUTTON(IdCaptureToolbars, ScreenFrame::OnCaptureToolbars)
|
||||
EVT_BUTTON(IdCaptureMenus, ScreenFrame::OnCaptureMenus)
|
||||
EVT_BUTTON(IdCaptureSelectionBar, ScreenFrame::OnCaptureSelectionBar)
|
||||
EVT_BUTTON(IdCaptureTools, ScreenFrame::OnCaptureTools)
|
||||
EVT_BUTTON(IdCaptureTransport, ScreenFrame::OnCaptureTransport)
|
||||
@ -382,6 +385,7 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S)
|
||||
S.StartHorizontalLay();
|
||||
{
|
||||
S.Id(IdCaptureToolbars).AddButton(_("All Toolbars"));
|
||||
S.Id(IdCaptureMenus).AddButton(_("All Menus"));
|
||||
S.Id(IdCaptureSelectionBar).AddButton(_("SelectionBar"));
|
||||
S.Id(IdCaptureTools).AddButton(_("Tools"));
|
||||
S.Id(IdCaptureTransport).AddButton(_("Transport"));
|
||||
@ -603,6 +607,11 @@ void ScreenFrame::OnCaptureToolbars(wxCommandEvent & WXUNUSED(event))
|
||||
DoCapture(wxT("toolbars"));
|
||||
}
|
||||
|
||||
void ScreenFrame::OnCaptureMenus(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
DoCapture(wxT("menus"));
|
||||
}
|
||||
|
||||
void ScreenFrame::OnCaptureSelectionBar(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
DoCapture(wxT("selectionbar"));
|
||||
|
@ -266,6 +266,59 @@ void ScreenshotCommand::CaptureDock(wxWindow *win, const wxString &fileName)
|
||||
Capture(fileName, win, x, y, width, height);
|
||||
}
|
||||
|
||||
void ExploreMenu( wxMenu * pMenu, int Id, int depth ){
|
||||
Id;//compiler food.
|
||||
if( !pMenu )
|
||||
return;
|
||||
|
||||
wxMenuItemList list = pMenu->GetMenuItems();
|
||||
size_t lcnt = list.GetCount();
|
||||
wxMenuItem * item;
|
||||
wxString Label;
|
||||
|
||||
for (size_t lndx = 0; lndx < lcnt; lndx++) {
|
||||
item = list.Item(lndx)->GetData();
|
||||
Label = item->GetItemLabelText();
|
||||
if( item->IsSeparator() )
|
||||
Label = "----";
|
||||
wxLogDebug("%2i: %s", depth, Label );
|
||||
if (item->IsSubMenu()) {
|
||||
pMenu = item->GetSubMenu();
|
||||
ExploreMenu( pMenu, item->GetId(), depth+1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenshotCommand::CaptureMenus(wxMenuBar*pBar, const wxString &fileName)
|
||||
{
|
||||
fileName;//compiler food.
|
||||
if(!pBar ){
|
||||
wxLogDebug("No menus");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t cnt = pBar->GetMenuCount();
|
||||
size_t i;
|
||||
wxString Label;
|
||||
for(i=0;i<cnt;i++)
|
||||
{
|
||||
Label = pBar->GetMenuLabelText( i );
|
||||
wxLogDebug( "MenuBar: %s", Label );
|
||||
ExploreMenu( pBar->GetMenu( i ), pBar->GetId(), 0 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
int x = 0, y = 0;
|
||||
int width, height;
|
||||
|
||||
win->ClientToScreen(&x, &y);
|
||||
win->GetParent()->ScreenToClient(&x, &y);
|
||||
win->GetClientSize(&width, &height);
|
||||
|
||||
Capture(fileName, win, x, y, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString ScreenshotCommandType::BuildName()
|
||||
{
|
||||
return wxT("Screenshot");
|
||||
@ -279,6 +332,7 @@ void ScreenshotCommandType::BuildSignature(CommandSignature &signature)
|
||||
captureModeValidator->AddOption(wxT("windowplus"));
|
||||
captureModeValidator->AddOption(wxT("fullscreen"));
|
||||
captureModeValidator->AddOption(wxT("toolbars"));
|
||||
captureModeValidator->AddOption(wxT("menus"));
|
||||
captureModeValidator->AddOption(wxT("selectionbar"));
|
||||
captureModeValidator->AddOption(wxT("tools"));
|
||||
captureModeValidator->AddOption(wxT("transport"));
|
||||
@ -423,6 +477,10 @@ bool ScreenshotCommand::Apply(CommandExecutionContext context)
|
||||
{
|
||||
CaptureDock(context.GetProject()->GetToolManager()->GetTopDock(), fileName);
|
||||
}
|
||||
else if (captureMode.IsSameAs(wxT("menus")))
|
||||
{
|
||||
CaptureMenus(context.GetProject()->GetMenuBar(), fileName);
|
||||
}
|
||||
else if (captureMode.IsSameAs(wxT("selectionbar")))
|
||||
{
|
||||
CaptureDock(context.GetProject()->GetToolManager()->GetBotDock(), fileName);
|
||||
|
@ -49,6 +49,7 @@ private:
|
||||
bool bg = false);
|
||||
void CaptureToolbar(ToolManager *man, int type, const wxString &name);
|
||||
void CaptureDock(wxWindow *win, const wxString &fileName);
|
||||
void CaptureMenus(wxMenuBar*pBar, const wxString &fileName);
|
||||
|
||||
public:
|
||||
wxTopLevelWindow *GetFrontWindow(AudacityProject *project);
|
||||
|
Loading…
x
Reference in New Issue
Block a user