From 57db92b2765363ffeb85a53e8f81ca0bed5ef4e5 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 17 Sep 2013 18:45:48 +0100 Subject: [PATCH] Cleaned up some ints that should have been CommandIDs. --- .../ui/jucer_JucerCommandIDs.h | 45 +++++++++--------- .../juce_gui_basics/buttons/juce_Button.cpp | 4 +- modules/juce_gui_basics/buttons/juce_Button.h | 7 +-- .../commands/juce_ApplicationCommandID.h | 47 ++++++++++--------- .../commands/juce_ApplicationCommandInfo.cpp | 5 +- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 2 +- .../juce_gui_basics/menus/juce_PopupMenu.h | 2 +- .../code_editor/juce_CodeEditorComponent.cpp | 2 +- .../code_editor/juce_CodeEditorComponent.h | 2 +- 9 files changed, 61 insertions(+), 55 deletions(-) diff --git a/extras/Introjucer/Source/ComponentEditor/ui/jucer_JucerCommandIDs.h b/extras/Introjucer/Source/ComponentEditor/ui/jucer_JucerCommandIDs.h index 5efd253460..459b7aa11c 100644 --- a/extras/Introjucer/Source/ComponentEditor/ui/jucer_JucerCommandIDs.h +++ b/extras/Introjucer/Source/ComponentEditor/ui/jucer_JucerCommandIDs.h @@ -27,32 +27,35 @@ */ namespace JucerCommandIDs { - static const int test = 0xf20009; - static const int toFront = 0xf2000a; - static const int toBack = 0xf2000b; + enum + { + test = 0xf20009, + toFront = 0xf2000a, + toBack = 0xf2000b, - static const int group = 0xf20017; - static const int ungroup = 0xf20018; + group = 0xf20017, + ungroup = 0xf20018, - static const int showGrid = 0xf2000e; - static const int enableSnapToGrid = 0xf2000f; + showGrid = 0xf2000e, + enableSnapToGrid = 0xf2000f, - static const int editCompLayout = 0xf20010; - static const int editCompGraphics = 0xf20011; + editCompLayout = 0xf20010, + editCompGraphics = 0xf20011, - static const int bringBackLostItems = 0xf20012; + bringBackLostItems = 0xf20012, - static const int zoomIn = 0xf20013; - static const int zoomOut = 0xf20014; - static const int zoomNormal = 0xf20015; - static const int spaceBarDrag = 0xf20016; + zoomIn = 0xf20013, + zoomOut = 0xf20014, + zoomNormal = 0xf20015, + spaceBarDrag = 0xf20016, - static const int compOverlay0 = 0xf20020; - static const int compOverlay33 = 0xf20021; - static const int compOverlay66 = 0xf20022; - static const int compOverlay100 = 0xf20023; + compOverlay0 = 0xf20020, + compOverlay33 = 0xf20021, + compOverlay66 = 0xf20022, + compOverlay100 = 0xf20023, - static const int newDocumentBase = 0xf32001; - static const int newComponentBase = 0xf30001; - static const int newElementBase = 0xf31001; + newDocumentBase = 0xf32001, + newComponentBase = 0xf30001, + newElementBase = 0xf31001 + }; } diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 4cfcb497be..1b981220ae 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -45,8 +45,8 @@ Button::Button (const String& name) autoRepeatSpeed (0), autoRepeatMinimumDelay (-1), radioGroupId (0), - commandID (0), connectedEdgeFlags (0), + commandID(), buttonState (buttonNormal), lastToggleState (false), clickTogglesState (false), @@ -464,7 +464,7 @@ void Button::parentHierarchyChanged() //============================================================================== void Button::setCommandToTrigger (ApplicationCommandManager* const newCommandManager, - const int newCommandID, const bool generateTip) + const CommandID newCommandID, const bool generateTip) { commandID = newCommandID; generateTooltip = generateTip; diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index bf14ce0056..2daf940b4e 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -212,11 +212,11 @@ public: @see addShortcut, getCommandID */ void setCommandToTrigger (ApplicationCommandManager* commandManagerToUse, - int commandID, + CommandID commandID, bool generateTooltip); /** Returns the command ID that was set by setCommandToTrigger(). */ - int getCommandID() const noexcept { return commandID; } + CommandID getCommandID() const noexcept { return commandID; } //============================================================================== /** Assigns a shortcut key to trigger the button. @@ -457,7 +457,8 @@ private: uint32 buttonPressTime, lastRepeatTime; ApplicationCommandManager* commandManagerToUse; int autoRepeatDelay, autoRepeatSpeed, autoRepeatMinimumDelay; - int radioGroupId, commandID, connectedEdgeFlags; + int radioGroupId, connectedEdgeFlags; + CommandID commandID; ButtonState buttonState; Value isOn; diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h index 6dbd8b11fe..9a00cbc8c5 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandID.h @@ -51,37 +51,40 @@ typedef int CommandID; */ namespace StandardApplicationCommandIDs { - /** This command ID should be used to send a "Quit the App" command. + enum + { + /** This command ID should be used to send a "Quit the App" command. - This command is recognised by the JUCEApplication class, so if it is invoked - and no other ApplicationCommandTarget handles the event first, the JUCEApplication - object will catch it and call JUCEApplicationBase::systemRequestedQuit(). - */ - static const CommandID quit = 0x1001; + This command is recognised by the JUCEApplication class, so if it is invoked + and no other ApplicationCommandTarget handles the event first, the JUCEApplication + object will catch it and call JUCEApplicationBase::systemRequestedQuit(). + */ + quit = 0x1001, - /** The command ID that should be used to send a "Delete" command. */ - static const CommandID del = 0x1002; + /** The command ID that should be used to send a "Delete" command. */ + del = 0x1002, - /** The command ID that should be used to send a "Cut" command. */ - static const CommandID cut = 0x1003; + /** The command ID that should be used to send a "Cut" command. */ + cut = 0x1003, - /** The command ID that should be used to send a "Copy to clipboard" command. */ - static const CommandID copy = 0x1004; + /** The command ID that should be used to send a "Copy to clipboard" command. */ + copy = 0x1004, - /** The command ID that should be used to send a "Paste from clipboard" command. */ - static const CommandID paste = 0x1005; + /** The command ID that should be used to send a "Paste from clipboard" command. */ + paste = 0x1005, - /** The command ID that should be used to send a "Select all" command. */ - static const CommandID selectAll = 0x1006; + /** The command ID that should be used to send a "Select all" command. */ + selectAll = 0x1006, - /** The command ID that should be used to send a "Deselect all" command. */ - static const CommandID deselectAll = 0x1007; + /** The command ID that should be used to send a "Deselect all" command. */ + deselectAll = 0x1007, - /** The command ID that should be used to send a "undo" command. */ - static const CommandID undo = 0x1008; + /** The command ID that should be used to send a "undo" command. */ + undo = 0x1008, - /** The command ID that should be used to send a "redo" command. */ - static const CommandID redo = 0x1009; + /** The command ID that should be used to send a "redo" command. */ + redo = 0x1009 + }; } diff --git a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp index 28b4b28cd3..174ec80f33 100644 --- a/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp +++ b/modules/juce_gui_basics/commands/juce_ApplicationCommandInfo.cpp @@ -22,9 +22,8 @@ ============================================================================== */ -ApplicationCommandInfo::ApplicationCommandInfo (const CommandID commandID_) noexcept - : commandID (commandID_), - flags (0) +ApplicationCommandInfo::ApplicationCommandInfo (const CommandID cid) noexcept + : commandID (cid), flags (0) { } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 1269680054..837e23c052 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -1302,7 +1302,7 @@ void PopupMenu::addItem (const int itemResultID, const String& itemText, } void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager, - const int commandID, + const CommandID commandID, const String& displayName) { jassert (commandManager != nullptr && commandID != 0); diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.h b/modules/juce_gui_basics/menus/juce_PopupMenu.h index 71341d1cbf..8d39c82b1b 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.h +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.h @@ -133,7 +133,7 @@ public: the command's registered name */ void addCommandItem (ApplicationCommandManager* commandManager, - int commandID, + CommandID commandID, const String& displayName = String::empty); diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp index 95d3296314..e751d515bf 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp @@ -1267,7 +1267,7 @@ bool CodeEditorComponent::perform (const InvocationInfo& info) return performCommand (info.commandID); } -bool CodeEditorComponent::performCommand (const int commandID) +bool CodeEditorComponent::performCommand (const CommandID commandID) { switch (commandID) { diff --git a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h index 3e2553de5f..d772a46e0e 100644 --- a/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h +++ b/modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.h @@ -408,7 +408,7 @@ private: void cut(); void indentSelectedLines (int spacesToAdd); bool skipBackwardsToPreviousTab(); - bool performCommand (int); + bool performCommand (CommandID); int indexToColumn (int line, int index) const noexcept; int columnToIndex (int line, int column) const noexcept;