juce_DirectoryContentsDisplayComponent.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. DirectoryContentsDisplayComponent::DirectoryContentsDisplayComponent (DirectoryContentsList& listToShow)
  18. : fileList (listToShow)
  19. {
  20. }
  21. DirectoryContentsDisplayComponent::~DirectoryContentsDisplayComponent()
  22. {
  23. }
  24. //==============================================================================
  25. FileBrowserListener::~FileBrowserListener()
  26. {
  27. }
  28. void DirectoryContentsDisplayComponent::addListener (FileBrowserListener* const listener)
  29. {
  30. listeners.add (listener);
  31. }
  32. void DirectoryContentsDisplayComponent::removeListener (FileBrowserListener* const listener)
  33. {
  34. listeners.remove (listener);
  35. }
  36. void DirectoryContentsDisplayComponent::sendSelectionChangeMessage()
  37. {
  38. Component::BailOutChecker checker (dynamic_cast <Component*> (this));
  39. listeners.callChecked (checker, &FileBrowserListener::selectionChanged);
  40. }
  41. void DirectoryContentsDisplayComponent::sendMouseClickMessage (const File& file, const MouseEvent& e)
  42. {
  43. if (fileList.getDirectory().exists())
  44. {
  45. Component::BailOutChecker checker (dynamic_cast <Component*> (this));
  46. listeners.callChecked (checker, &FileBrowserListener::fileClicked, file, e);
  47. }
  48. }
  49. void DirectoryContentsDisplayComponent::sendDoubleClickMessage (const File& file)
  50. {
  51. if (fileList.getDirectory().exists())
  52. {
  53. Component::BailOutChecker checker (dynamic_cast <Component*> (this));
  54. listeners.callChecked (checker, &FileBrowserListener::fileDoubleClicked, file);
  55. }
  56. }