mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-13 08:06:32 +01:00
Add code to capture menus
So far, this only walks the menus, printing out their contents to debug.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user