Audacity  3.0.3
ModNullCallback.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ModNullCallback.cpp
6 
7  James Crook
8 
9  Audacity is free software.
10  This file is licensed under the wxWidgets license, see License.txt
11 
12 ********************************************************************//*****************************************************************//********************************************************************/
27 
28 #include <wx/wx.h>
29 #include "ModNullCallback.h"
30 #include "ModuleConstants.h"
31 #include "ShuttleGui.h"
32 #include "Project.h"
34 #include "CommonCommandFlags.h"
35 
36 /*
37 //#define ModuleDispatchName "ModuleDispatch"
38 See the example in this file. It has several cases/options in it.
39 */
40 
41 // derived from wxFrame as it needs to be some kind of event handler.
42 class ModNullCallback : public wxFrame
43 {
44 public:
45 // Name these OnFuncXXX functions by whatever they will do.
46  void OnFuncFirst(const CommandContext &);
47  void OnFuncSecond(const CommandContext &);
48 };
49 
51 {
52  int k=32;
53 }
54 
56 {
57  int k=42;
58 }
60 
61 #define ModNullFN(X) static_cast<CommandFunctorPointer>((&ModNullCallback:: X))
62 
63 extern "C" {
64 
66 {
67 // no specific command handler object ... use the project.
68 return project;
69 }
70 
72 
73 namespace {
75 {
76  // Get here only after the module version check passes
77  using namespace MenuTable;
78  // We add two new commands into the Analyze menu.
79  static AttachedItem sAttachment{ wxT("Analyze"),
80  ( FinderScope( ident ), Section( wxT("NullModule"),
81  Command(
82  _T("A New Command"), // internal name
83  XXO("1st Experimental Command..."), //displayed name
84  ModNullFN( OnFuncFirst ),
86  Command(
87  _T("Another New Command"),
88  XXO("2nd Experimental Command"),
89  ModNullFN( OnFuncSecond ),
91  ) )
92  };
93 }
94 }
95 
96 // This is the function that connects us to Audacity.
99 {
100  switch (type)
101  {
102  case ModuleInitialize:
104  break;
105  case AppInitialized:
106  break;
107  case AppQuiting:
108  break;
109  default:
110  break;
111  }
112 
113  return 1;
114 }
115 
116 //Example code commented out.
117 #if 0
118 // This is an example function to hijack the main panel
119 int DLL_API MainPanelFunc(int ix)
120 {
121  ix=ix;//compiler food
122  // If we wanted to hide Audacity's Project,
123  // we'd create a new wxFrame right here and return a pointer to it
124  // as our return result.
125 
126 // Don't hijack the main panel, just return a NULL;
127  return NULL;
128 }
129 #endif
130 
131 } // End extern "C"
ModuleDispatch
int DLL_API ModuleDispatch(ModuleDispatchTypes type)
Definition: ModNullCallback.cpp:98
DLL_API
#define DLL_API
Definition: ModuleConstants.h:22
ModNullCallback
ModNullCallback is a class containing all the callback functions for this demonstartion module....
Definition: ModNullCallback.cpp:43
MenuTable::FinderScope
Definition: CommandManager.h:485
Project.h
ident
static CommandHandlerObject & ident(AudacityProject &project)
Definition: ModNullCallback.cpp:65
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:128
CommandManager.h
MenuTable::AttachedItem
Definition: CommandManager.h:708
AppQuiting
@ AppQuiting
Definition: ModuleConstants.h:31
ModNullCallback.h
XXO
#define XXO(s)
Definition: Internat.h:44
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:34
anonymous_namespace{Contrast.cpp}::sAttachment
AttachedItem sAttachment
Definition: Contrast.cpp:697
ModNullCallback::OnFuncSecond
void OnFuncSecond(const CommandContext &)
Definition: ModNullCallback.cpp:55
ShuttleGui.h
ModuleConstants.h
ModNullCallback::OnFuncFirst
void OnFuncFirst(const CommandContext &)
Definition: ModNullCallback.cpp:50
ModuleDispatchTypes
ModuleDispatchTypes
Definition: ModuleConstants.h:27
AppInitialized
@ AppInitialized
Definition: ModuleConstants.h:30
DEFINE_VERSION_CHECK::RegisterMenuItems
void RegisterMenuItems()
Definition: ModNullCallback.cpp:74
ModNullFN
#define ModNullFN(X)
Definition: ModNullCallback.cpp:61
MenuTable::Command
std::unique_ptr< CommandItem > Command(const CommandID &name, const TranslatableString &label_in, void(Handler::*pmf)(const CommandContext &), CommandFlag flags, const CommandManager::Options &options={}, CommandHandlerFinder finder=FinderScope::DefaultFinder())
Definition: CommandManager.h:675
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
CommandHandlerObject
wxEvtHandler CommandHandlerObject
Definition: CommandFunctors.h:28
DEFINE_VERSION_CHECK
Definition: ModNullCallback.cpp:73
MenuTable::Section
std::unique_ptr< MenuPart > Section(const Identifier &internalName, Args &&... args)
Definition: CommandManager.h:611
pModNullCallback
ModNullCallback * pModNullCallback
Definition: ModNullCallback.cpp:59
MenuTable
Definition: CommandManager.h:416
CommonCommandFlags.h
ModuleInitialize
@ ModuleInitialize
Definition: ModuleConstants.h:28