1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/**********************************************************************
Audacity: A Digital Audio Editor
ModNullCallback.cpp
James Crook
Audacity is free software.
This file is licensed under the wxWidgets license, see License.txt
********************************************************************//**
\class ModNullCallback
\brief ModNullCallback is a class containing all the callback
functions for this demonstartion module. These functions are
added into the standard Audacity Project Menus.
*//*****************************************************************//**
\class ModNullCommandFunctor
\brief We create one of these functors for each menu item or
command which we register with the Command Manager. These take the
click from the menu into the actual function to be called.
*//********************************************************************/
#include <wx/wx.h>
#include "ModNullCallback.h"
#include "ModuleConstants.h"
#include "ShuttleGui.h"
#include "Project.h"
#include "commands/CommandManager.h"
#include "CommonCommandFlags.h"
/*
//#define ModuleDispatchName "ModuleDispatch"
See the example in this file. It has several cases/options in it.
*/
// derived from wxFrame as it needs to be some kind of event handler.
class ModNullCallback : public wxFrame
{
public:
// Name these OnFuncXXX functions by whatever they will do.
void OnFuncFirst(const CommandContext &);
void OnFuncSecond(const CommandContext &);
};
void ModNullCallback::OnFuncFirst(const CommandContext &)
{
int k=32;
}
void ModNullCallback::OnFuncSecond(const CommandContext &)
{
int k=42;
}
ModNullCallback * pModNullCallback=NULL;
#define ModNullFN(X) static_cast<CommandFunctorPointer>((&ModNullCallback:: X))
extern "C" {
static CommandHandlerObject &ident(AudacityProject&project)
{
// no specific command handler object ... use the project.
return project;
}
DEFINE_VERSION_CHECK
namespace {
void RegisterMenuItems()
{
// Get here only after the module version check passes
using namespace MenuTable;
// We add two new commands into the Analyze menu.
static AttachedItem sAttachment{ wxT("Analyze"),
( FinderScope( ident ), Section( wxT("NullModule"),
Command(
_T("A New Command"), // internal name
XXO("1st Experimental Command..."), //displayed name
ModNullFN( OnFuncFirst ),
AudioIONotBusyFlag() ),
Command(
_T("Another New Command"),
XXO("2nd Experimental Command"),
ModNullFN( OnFuncSecond ),
AudioIONotBusyFlag() )
) )
};
}
}
// This is the function that connects us to Audacity.
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type)
{
case ModuleInitialize:
RegisterMenuItems();
break;
case AppInitialized:
break;
case AppQuiting:
break;
default:
break;
}
return 1;
}
//Example code commented out.
#if 0
// This is an example function to hijack the main panel
int DLL_API MainPanelFunc(int ix)
{
ix=ix;//compiler food
// If we wanted to hide Audacity's Project,
// we'd create a new wxFrame right here and return a pointer to it
// as our return result.
// Don't hijack the main panel, just return a NULL;
return NULL;
}
#endif
} // End extern "C"
|