1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-24 01:54:22 +00:00

A few minor clean-ups.

This commit is contained in:
jules 2014-08-26 10:17:40 +01:00
parent 37d8f5ca41
commit 2fd89b0ac4
7 changed files with 57 additions and 61 deletions

View file

@ -26,32 +26,7 @@
==============================================================================
*/
WildcardFileFilter::WildcardFileFilter (const String& fileWildcardPatterns,
const String& directoryWildcardPatterns,
const String& desc)
: FileFilter (desc.isEmpty() ? fileWildcardPatterns
: (desc + " (" + fileWildcardPatterns + ")"))
{
parse (fileWildcardPatterns, fileWildcards);
parse (directoryWildcardPatterns, directoryWildcards);
}
WildcardFileFilter::~WildcardFileFilter()
{
}
bool WildcardFileFilter::isFileSuitable (const File& file) const
{
return match (file, fileWildcards);
}
bool WildcardFileFilter::isDirectorySuitable (const File& file) const
{
return match (file, directoryWildcards);
}
//==============================================================================
void WildcardFileFilter::parse (const String& pattern, StringArray& result)
static void parseWildcard (const String& pattern, StringArray& result)
{
result.addTokens (pattern.toLowerCase(), ";,", "\"'");
@ -65,7 +40,7 @@ void WildcardFileFilter::parse (const String& pattern, StringArray& result)
result.set (i, "*");
}
bool WildcardFileFilter::match (const File& file, const StringArray& wildcards)
static bool matchWildcard (const File& file, const StringArray& wildcards)
{
const String filename (file.getFileName());
@ -75,3 +50,27 @@ bool WildcardFileFilter::match (const File& file, const StringArray& wildcards)
return false;
}
WildcardFileFilter::WildcardFileFilter (const String& fileWildcardPatterns,
const String& directoryWildcardPatterns,
const String& desc)
: FileFilter (desc.isEmpty() ? fileWildcardPatterns
: (desc + " (" + fileWildcardPatterns + ")"))
{
parseWildcard (fileWildcardPatterns, fileWildcards);
parseWildcard (directoryWildcardPatterns, directoryWildcards);
}
WildcardFileFilter::~WildcardFileFilter()
{
}
bool WildcardFileFilter::isFileSuitable (const File& file) const
{
return matchWildcard (file, fileWildcards);
}
bool WildcardFileFilter::isDirectorySuitable (const File& file) const
{
return matchWildcard (file, directoryWildcards);
}

View file

@ -75,12 +75,8 @@ private:
//==============================================================================
StringArray fileWildcards, directoryWildcards;
static void parse (const String& pattern, StringArray& result);
static bool match (const File& file, const StringArray& wildcards);
JUCE_LEAK_DETECTOR (WildcardFileFilter)
};
#endif // JUCE_WILDCARDFILEFILTER_H_INCLUDED

View file

@ -1204,16 +1204,16 @@ public:
//==============================================================================
#if JUCE_MAC || JUCE_IOS || DOXYGEN
/** MAC ONLY - Creates a String from an OSX CFString. */
/** OSX ONLY - Creates a String from an OSX CFString. */
static String fromCFString (CFStringRef cfString);
/** MAC ONLY - Converts this string to a CFString.
/** OSX ONLY - Converts this string to a CFString.
Remember that you must use CFRelease() to free the returned string when you're
finished with it.
*/
CFStringRef toCFString() const;
/** MAC ONLY - Returns a copy of this string in which any decomposed unicode characters have
/** OSX ONLY - Returns a copy of this string in which any decomposed unicode characters have
been converted to their precomposed equivalents. */
String convertToPrecomposedUnicode() const;
#endif

View file

@ -252,7 +252,7 @@ bool KeyPressMappingSet::restoreFromXml (const XmlElement& xmlVersion)
XmlElement* KeyPressMappingSet::createXml (const bool saveDifferencesFromDefaultSet) const
{
ScopedPointer <KeyPressMappingSet> defaultSet;
ScopedPointer<KeyPressMappingSet> defaultSet;
if (saveDifferencesFromDefaultSet)
{

View file

@ -22,7 +22,7 @@
==============================================================================
*/
MenuBarComponent::MenuBarComponent (MenuBarModel* model_)
MenuBarComponent::MenuBarComponent (MenuBarModel* m)
: model (nullptr),
itemUnderMouse (-1),
currentPopupIndex (-1),
@ -32,7 +32,7 @@ MenuBarComponent::MenuBarComponent (MenuBarModel* model_)
setWantsKeyboardFocus (false);
setMouseClickGrabsKeyboardFocus (false);
setModel (model_);
setModel (m);
}
MenuBarComponent::~MenuBarComponent()
@ -284,22 +284,26 @@ void MenuBarComponent::mouseMove (const MouseEvent& e)
bool MenuBarComponent::keyPressed (const KeyPress& key)
{
bool used = false;
const int numMenus = menuNames.size();
const int currentIndex = jlimit (0, menuNames.size() - 1, currentPopupIndex);
if (key.isKeyCode (KeyPress::leftKey))
if (numMenus > 0)
{
showMenu ((currentIndex + numMenus - 1) % numMenus);
used = true;
}
else if (key.isKeyCode (KeyPress::rightKey))
{
showMenu ((currentIndex + 1) % numMenus);
used = true;
const int currentIndex = jlimit (0, numMenus - 1, currentPopupIndex);
if (key.isKeyCode (KeyPress::leftKey))
{
showMenu ((currentIndex + numMenus - 1) % numMenus);
return true;
}
if (key.isKeyCode (KeyPress::rightKey))
{
showMenu ((currentIndex + 1) % numMenus);
return true;
}
}
return used;
return false;
}
void MenuBarComponent::menuBarItemsChanged (MenuBarModel* /*menuBarModel*/)

View file

@ -40,9 +40,9 @@ public:
//==============================================================================
/** Creates a menu bar.
@param model the model object to use to control this bar. You can
pass 0 into this if you like, and set the model later
using the setModel() method
@param model the model object to use to control this bar. You can
pass nullptr into this if you like, and set the model
later using the setModel() method
*/
MenuBarComponent (MenuBarModel* model);
@ -57,8 +57,7 @@ public:
*/
void setModel (MenuBarModel* newModel);
/** Returns the current menu bar model being used.
*/
/** Returns the current menu bar model being used. */
MenuBarModel* getModel() const noexcept;
//==============================================================================

View file

@ -80,8 +80,7 @@ public:
virtual ~Listener() {}
//==============================================================================
/** This callback is made when items are changed in the menu bar model.
*/
/** This callback is made when items are changed in the menu bar model. */
virtual void menuBarItemsChanged (MenuBarModel* menuBarModel) = 0;
/** This callback is made when an application command is invoked that
@ -101,7 +100,6 @@ public:
void addListener (Listener* listenerToAdd) noexcept;
/** Removes a listener.
@see addListener
*/
void removeListener (Listener* listenerToRemove) noexcept;
@ -130,7 +128,7 @@ public:
//==============================================================================
#if JUCE_MAC || DOXYGEN
/** MAC ONLY - Sets the model that is currently being shown as the main
/** OSX ONLY - Sets the model that is currently being shown as the main
menu bar at the top of the screen on the Mac.
You can pass 0 to stop the current model being displayed. Be careful
@ -151,12 +149,12 @@ public:
const PopupMenu* extraAppleMenuItems = nullptr,
const String& recentItemsMenuName = String::empty);
/** MAC ONLY - Returns the menu model that is currently being shown as
/** OSX ONLY - Returns the menu model that is currently being shown as
the main menu bar.
*/
static MenuBarModel* getMacMainMenu();
/** MAC ONLY - Returns the menu that was last passed as the extraAppleMenuItems
/** OSX ONLY - Returns the menu that was last passed as the extraAppleMenuItems
argument to setMacMainMenu(), or nullptr if none was specified.
*/
static const PopupMenu* getMacExtraAppleItemsMenu();
@ -164,7 +162,7 @@ public:
//==============================================================================
/** @internal */
void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo& info) override;
void applicationCommandInvoked (const ApplicationCommandTarget::InvocationInfo&) override;
/** @internal */
void applicationCommandListChanged() override;
/** @internal */
@ -172,7 +170,7 @@ public:
private:
ApplicationCommandManager* manager;
ListenerList <Listener> listeners;
ListenerList<Listener> listeners;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuBarModel)
};