andrewm@0: /*
andrewm@0: TouchKeys: multi-touch musical keyboard control software
andrewm@0: Copyright (c) 2013 Andrew McPherson
andrewm@0:
andrewm@0: This program is free software: you can redistribute it and/or modify
andrewm@0: it under the terms of the GNU General Public License as published by
andrewm@0: the Free Software Foundation, either version 3 of the License, or
andrewm@0: (at your option) any later version.
andrewm@0:
andrewm@0: This program is distributed in the hope that it will be useful,
andrewm@0: but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0: GNU General Public License for more details.
andrewm@0:
andrewm@0: You should have received a copy of the GNU General Public License
andrewm@0: along with this program. If not, see .
andrewm@0:
andrewm@0: =====================================================================
andrewm@0:
andrewm@0: MainWindow.h: the control window, plus menu bar and Juce application methods
andrewm@0: */
andrewm@0:
andrewm@0: #ifndef MAINWINDOW_H_INCLUDED
andrewm@0: #define MAINWINDOW_H_INCLUDED
andrewm@0:
andrewm@50: #ifndef TOUCHKEYS_NO_GUI
andrewm@50:
andrewm@0: #include "../../JuceLibraryCode/JuceHeader.h"
andrewm@0: #include "ControlWindowMainComponent.h"
andrewm@0: #include "../MainApplicationController.h"
andrewm@0:
andrewm@0: //==============================================================================
andrewm@0: /*
andrewm@0: */
andrewm@0:
andrewm@0: class MainWindow : public DocumentWindow, public Timer,
andrewm@0: public MenuBarModel, public ApplicationCommandTarget
andrewm@0: {
andrewm@0: private:
andrewm@0: // Commands this application responds to
andrewm@0: enum CommandIDs
andrewm@0: {
andrewm@0: // File menu
andrewm@33: kCommandClearPreset = 0x2001,
andrewm@0: kCommandOpenPreset,
andrewm@0: kCommandSavePreset,
andrewm@0:
andrewm@0: // Edit menu
andrewm@0: // (all standard)
andrewm@0:
andrewm@0: // Control menu
andrewm@0: kCommandRescanDevices = 0x2020,
andrewm@31: kCommandLoggingStartStop,
andrewm@31: kCommandLoggingPlay,
andrewm@0: kCommandEnableExperimentalMappings,
andrewm@17: kCommandTestTouchkeySensors,
andrewm@53: kCommandJumpToBootloader,
andrewm@41: kCommandPreferences,
andrewm@0:
andrewm@0: // Window menu
andrewm@0: kCommandShowControlWindow = 0x2030,
andrewm@0: kCommandShowKeyboardWindow
andrewm@0: };
andrewm@0:
andrewm@0: public:
andrewm@0: MainWindow(MainApplicationController& controller);
andrewm@0: ~MainWindow();
andrewm@0:
andrewm@0: void closeButtonPressed()
andrewm@0: {
andrewm@0: // This is called when the user tries to close this window. Here, we'll just
andrewm@0: // ask the app to quit when this happens, but you can change this to do
andrewm@0: // whatever you need.
andrewm@0: JUCEApplication::getInstance()->systemRequestedQuit();
andrewm@0: }
andrewm@0:
andrewm@0: // Method used by Juce timer which we will use for periodic UI updates
andrewm@0: // from the underlying system state, in a configuration similar to how the
andrewm@0: // Juce audio plugins work
andrewm@0: void timerCallback();
andrewm@0:
andrewm@0: // ***** Menu Bar methods *****
andrewm@0:
andrewm@0: StringArray getMenuBarNames();
andrewm@0: PopupMenu getMenuForIndex (int menuIndex, const String& menuName);
andrewm@0: void menuItemSelected (int menuItemID, int topLevelMenuIndex);
andrewm@0:
andrewm@0: // ***** Application Command Manager methods *****
andrewm@0:
andrewm@0: // this will return the next parent component that is an ApplicationCommandTarget (in this
andrewm@0: // case, there probably isn't one, but it's best to use this method in your own apps).
andrewm@0: ApplicationCommandTarget* getNextCommandTarget();
andrewm@0:
andrewm@0: // this returns the set of all commands that this target can perform..
andrewm@0: void getAllCommands (Array & commands);
andrewm@0:
andrewm@0: // This method is used when something needs to find out the details about one of the commands
andrewm@0: // that this object can perform..
andrewm@0: void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result);
andrewm@0:
andrewm@0: // Perform a command
andrewm@0: bool perform (const InvocationInfo& info);
andrewm@0:
andrewm@37: // Callback for alert box
andrewm@37: static void alertBoxResultChosen(int result, MainWindow *item);
andrewm@37:
andrewm@37: // Clear preset (called from alert box
andrewm@37: void clearPreset() { controller_.clearPreset(); }
andrewm@37:
andrewm@0: /* Note: Be careful if you override any DocumentWindow methods - the base
andrewm@0: class uses a lot of them, so by overriding you might break its functionality.
andrewm@0: It's best to do all your work in your content component instead, but if
andrewm@0: you really have to override any DocumentWindow methods, make sure your
andrewm@0: subclass also calls the superclass's method.
andrewm@0: */
andrewm@0:
andrewm@0: private:
andrewm@0: // The command manager object used to dispatch command events
andrewm@0: MainApplicationController& controller_;
andrewm@0: ApplicationCommandManager commandManager_;
andrewm@0: ControlWindowMainComponent mainComponent_;
andrewm@0:
andrewm@0: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
andrewm@0: };
andrewm@0:
andrewm@50: #endif // TOUCHKEYS_NO_GUI
andrewm@0:
andrewm@0: #endif // MAINWINDOW_H_INCLUDED