The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

749 lines
25KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. // Win32NativeFileChooser needs to be a reference counted object as there
  21. // is no way for the parent to know when the dialog HWND has actually been
  22. // created without pumping the message thread (which is forbidden when modal
  23. // loops are disabled). However, the HWND pointer is the only way to cancel
  24. // the dialog box. This means that the actual native FileChooser HWND may
  25. // not have been created yet when the user deletes JUCE's FileChooser class. If this
  26. // occurs the Win32NativeFileChooser will still have a reference count of 1 and will
  27. // simply delete itself immediately once the HWND will have been created a while later.
  28. class Win32NativeFileChooser : public ReferenceCountedObject,
  29. private Thread
  30. {
  31. public:
  32. using Ptr = ReferenceCountedObjectPtr<Win32NativeFileChooser>;
  33. enum { charsAvailableForResult = 32768 };
  34. Win32NativeFileChooser (Component* parent, int flags, FilePreviewComponent* previewComp,
  35. const File& startingFile, const String& titleToUse,
  36. const String& filtersToUse)
  37. : Thread ("Native Win32 FileChooser"),
  38. owner (parent), title (titleToUse), filtersString (filtersToUse),
  39. selectsDirectories ((flags & FileBrowserComponent::canSelectDirectories) != 0),
  40. isSave ((flags & FileBrowserComponent::saveMode) != 0),
  41. warnAboutOverwrite ((flags & FileBrowserComponent::warnAboutOverwriting) != 0),
  42. selectMultiple ((flags & FileBrowserComponent::canSelectMultipleItems) != 0),
  43. nativeDialogRef (nullptr), shouldCancel (0)
  44. {
  45. auto parentDirectory = startingFile.getParentDirectory();
  46. // Handle nonexistent root directories in the same way as existing ones
  47. files.calloc (static_cast<size_t> (charsAvailableForResult) + 1);
  48. if (startingFile.isDirectory() || startingFile.isRoot())
  49. {
  50. initialPath = startingFile.getFullPathName();
  51. }
  52. else
  53. {
  54. startingFile.getFileName().copyToUTF16 (files,
  55. static_cast<size_t> (charsAvailableForResult) * sizeof (WCHAR));
  56. initialPath = parentDirectory.getFullPathName();
  57. }
  58. if (! selectsDirectories)
  59. {
  60. if (previewComp != nullptr)
  61. customComponent.reset (new CustomComponentHolder (previewComp));
  62. setupFilters();
  63. }
  64. }
  65. ~Win32NativeFileChooser()
  66. {
  67. signalThreadShouldExit();
  68. waitForThreadToExit (-1);
  69. }
  70. void open (bool async)
  71. {
  72. results.clear();
  73. // the thread should not be running
  74. nativeDialogRef.set (nullptr);
  75. if (async)
  76. {
  77. jassert (! isThreadRunning());
  78. threadHasReference.reset();
  79. startThread();
  80. threadHasReference.wait (-1);
  81. }
  82. else
  83. {
  84. results = openDialog (false);
  85. owner->exitModalState (results.size() > 0 ? 1 : 0);
  86. }
  87. }
  88. void cancel()
  89. {
  90. ScopedLock lock (deletingDialog);
  91. customComponent = nullptr;
  92. shouldCancel.set (1);
  93. if (auto hwnd = nativeDialogRef.get())
  94. EndDialog (hwnd, 0);
  95. }
  96. Component* getCustomComponent() { return customComponent.get(); }
  97. Array<URL> results;
  98. private:
  99. //==============================================================================
  100. class CustomComponentHolder : public Component
  101. {
  102. public:
  103. CustomComponentHolder (Component* const customComp)
  104. {
  105. setVisible (true);
  106. setOpaque (true);
  107. addAndMakeVisible (customComp);
  108. setSize (jlimit (20, 800, customComp->getWidth()), customComp->getHeight());
  109. }
  110. void paint (Graphics& g) override
  111. {
  112. g.fillAll (Colours::lightgrey);
  113. }
  114. void resized() override
  115. {
  116. if (Component* const c = getChildComponent(0))
  117. c->setBounds (getLocalBounds());
  118. }
  119. private:
  120. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CustomComponentHolder)
  121. };
  122. //==============================================================================
  123. Component::SafePointer<Component> owner;
  124. String title, filtersString;
  125. std::unique_ptr<CustomComponentHolder> customComponent;
  126. String initialPath, returnedString, defaultExtension;
  127. WaitableEvent threadHasReference;
  128. CriticalSection deletingDialog;
  129. bool selectsDirectories, isSave, warnAboutOverwrite, selectMultiple;
  130. HeapBlock<WCHAR> files;
  131. HeapBlock<WCHAR> filters;
  132. Atomic<HWND> nativeDialogRef;
  133. Atomic<int> shouldCancel;
  134. bool showDialog (IFileDialog& dialog, bool async) const
  135. {
  136. FILEOPENDIALOGOPTIONS flags = {};
  137. if (FAILED (dialog.GetOptions (&flags)))
  138. return false;
  139. const auto setBit = [] (FILEOPENDIALOGOPTIONS& field, bool value, FILEOPENDIALOGOPTIONS option)
  140. {
  141. if (value)
  142. field |= option;
  143. else
  144. field &= ~option;
  145. };
  146. setBit (flags, selectsDirectories, FOS_PICKFOLDERS);
  147. setBit (flags, warnAboutOverwrite, FOS_OVERWRITEPROMPT);
  148. setBit (flags, selectMultiple, FOS_ALLOWMULTISELECT);
  149. setBit (flags, customComponent != nullptr, FOS_FORCEPREVIEWPANEON);
  150. if (FAILED (dialog.SetOptions (flags)) || FAILED (dialog.SetTitle (title.toUTF16())))
  151. return false;
  152. PIDLIST_ABSOLUTE pidl = {};
  153. if (FAILED (SHParseDisplayName (initialPath.toWideCharPointer(), nullptr, &pidl, SFGAO_FOLDER, nullptr)))
  154. return false;
  155. const auto item = [&]
  156. {
  157. ComSmartPtr<IShellItem> ptr;
  158. SHCreateShellItem (nullptr, nullptr, pidl, ptr.resetAndGetPointerAddress());
  159. return ptr;
  160. }();
  161. if (item == nullptr || FAILED (dialog.SetFolder (item)))
  162. return false;
  163. String filename (files.getData());
  164. if (FAILED (dialog.SetFileName (filename.toWideCharPointer())))
  165. return false;
  166. const auto extension = filename.fromLastOccurrenceOf (".", false, false);
  167. if (extension.isNotEmpty() && FAILED (dialog.SetDefaultExtension (extension.toWideCharPointer())))
  168. return false;
  169. const COMDLG_FILTERSPEC spec[] { { filtersString.toWideCharPointer(), filtersString.toWideCharPointer() } };
  170. if (! selectsDirectories && FAILED (dialog.SetFileTypes (numElementsInArray (spec), spec)))
  171. return false;
  172. return dialog.Show (static_cast<HWND> (async ? nullptr : owner->getWindowHandle())) == S_OK;
  173. }
  174. //==============================================================================
  175. Array<URL> openDialogVistaAndUp (bool async)
  176. {
  177. const auto getUrl = [] (IShellItem& item)
  178. {
  179. struct Free
  180. {
  181. void operator() (LPWSTR ptr) const noexcept { CoTaskMemFree (ptr); }
  182. };
  183. LPWSTR ptr = nullptr;
  184. item.GetDisplayName (SIGDN_URL, &ptr);
  185. return std::unique_ptr<WCHAR, Free> { ptr };
  186. };
  187. if (isSave)
  188. {
  189. const auto dialog = [&]
  190. {
  191. ComSmartPtr<IFileDialog> ptr;
  192. ptr.CoCreateInstance (CLSID_FileSaveDialog, CLSCTX_INPROC_SERVER);
  193. return ptr;
  194. }();
  195. if (dialog == nullptr)
  196. return {};
  197. showDialog (*dialog, async);
  198. const auto item = [&]
  199. {
  200. ComSmartPtr<IShellItem> ptr;
  201. dialog->GetResult (ptr.resetAndGetPointerAddress());
  202. return ptr;
  203. }();
  204. if (item == nullptr)
  205. return {};
  206. return { URL (String (getUrl (*item).get())) };
  207. }
  208. const auto dialog = [&]
  209. {
  210. ComSmartPtr<IFileOpenDialog> ptr;
  211. ptr.CoCreateInstance (CLSID_FileOpenDialog, CLSCTX_INPROC_SERVER);
  212. return ptr;
  213. }();
  214. if (dialog == nullptr)
  215. return {};
  216. showDialog (*dialog, async);
  217. const auto items = [&]
  218. {
  219. ComSmartPtr<IShellItemArray> ptr;
  220. dialog->GetResults (ptr.resetAndGetPointerAddress());
  221. return ptr;
  222. }();
  223. if (items == nullptr)
  224. return {};
  225. Array<URL> result;
  226. DWORD numItems = 0;
  227. items->GetCount (&numItems);
  228. for (DWORD i = 0; i < numItems; ++i)
  229. {
  230. ComSmartPtr<IShellItem> scope;
  231. items->GetItemAt (i, scope.resetAndGetPointerAddress());
  232. if (scope != nullptr)
  233. result.add (String (getUrl (*scope).get()));
  234. }
  235. return result;
  236. }
  237. Array<URL> openDialogPreVista (bool async)
  238. {
  239. Array<URL> selections;
  240. if (selectsDirectories)
  241. {
  242. BROWSEINFO bi = {};
  243. bi.hwndOwner = (HWND) (async ? nullptr : owner->getWindowHandle());
  244. bi.pszDisplayName = files;
  245. bi.lpszTitle = title.toWideCharPointer();
  246. bi.lParam = (LPARAM) this;
  247. bi.lpfn = browseCallbackProc;
  248. #ifdef BIF_USENEWUI
  249. bi.ulFlags = BIF_USENEWUI | BIF_VALIDATE;
  250. #else
  251. bi.ulFlags = 0x50;
  252. #endif
  253. LPITEMIDLIST list = SHBrowseForFolder (&bi);
  254. if (! SHGetPathFromIDListW (list, files))
  255. {
  256. files[0] = 0;
  257. returnedString.clear();
  258. }
  259. LPMALLOC al;
  260. if (list != nullptr && SUCCEEDED (SHGetMalloc (&al)))
  261. al->Free (list);
  262. if (files[0] != 0)
  263. {
  264. File result (String (files.get()));
  265. if (returnedString.isNotEmpty())
  266. result = result.getSiblingFile (returnedString);
  267. selections.add (URL (result));
  268. }
  269. }
  270. else
  271. {
  272. OPENFILENAMEW of = {};
  273. #ifdef OPENFILENAME_SIZE_VERSION_400W
  274. of.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
  275. #else
  276. of.lStructSize = sizeof (of);
  277. #endif
  278. of.hwndOwner = (HWND) (async ? nullptr : owner->getWindowHandle());
  279. of.lpstrFilter = filters.getData();
  280. of.nFilterIndex = 1;
  281. of.lpstrFile = files;
  282. of.nMaxFile = (DWORD) charsAvailableForResult;
  283. of.lpstrInitialDir = initialPath.toWideCharPointer();
  284. of.lpstrTitle = title.toWideCharPointer();
  285. of.Flags = getOpenFilenameFlags (async);
  286. of.lCustData = (LPARAM) this;
  287. of.lpfnHook = &openCallback;
  288. if (isSave)
  289. {
  290. StringArray tokens;
  291. tokens.addTokens (filtersString, ";,", "\"'");
  292. tokens.trim();
  293. tokens.removeEmptyStrings();
  294. if (tokens.size() == 1 && tokens[0].removeCharacters ("*.").isNotEmpty())
  295. {
  296. defaultExtension = tokens[0].fromFirstOccurrenceOf (".", false, false);
  297. of.lpstrDefExt = defaultExtension.toWideCharPointer();
  298. }
  299. if (! GetSaveFileName (&of))
  300. return {};
  301. }
  302. else
  303. {
  304. if (! GetOpenFileName (&of))
  305. return {};
  306. }
  307. if (selectMultiple && of.nFileOffset > 0 && files[of.nFileOffset - 1] == 0)
  308. {
  309. const WCHAR* filename = files + of.nFileOffset;
  310. while (*filename != 0)
  311. {
  312. selections.add (URL (File (String (files.get())).getChildFile (String (filename))));
  313. filename += wcslen (filename) + 1;
  314. }
  315. }
  316. else if (files[0] != 0)
  317. {
  318. selections.add (URL (File (String (files.get()))));
  319. }
  320. }
  321. return selections;
  322. }
  323. Array<URL> openDialog (bool async)
  324. {
  325. struct Remover
  326. {
  327. explicit Remover (Win32NativeFileChooser& chooser) : item (chooser) {}
  328. ~Remover() { getNativeDialogList().removeValue (&item); }
  329. Win32NativeFileChooser& item;
  330. };
  331. const Remover remover (*this);
  332. if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista)
  333. return openDialogVistaAndUp (async);
  334. return openDialogPreVista (async);
  335. }
  336. void run() override
  337. {
  338. // as long as the thread is running, don't delete this class
  339. Ptr safeThis (this);
  340. threadHasReference.signal();
  341. auto r = openDialog (true);
  342. MessageManager::callAsync ([safeThis, r]
  343. {
  344. safeThis->results = r;
  345. if (safeThis->owner != nullptr)
  346. safeThis->owner->exitModalState (r.size() > 0 ? 1 : 0);
  347. });
  348. }
  349. static HashMap<HWND, Win32NativeFileChooser*>& getNativeDialogList()
  350. {
  351. static HashMap<HWND, Win32NativeFileChooser*> dialogs;
  352. return dialogs;
  353. }
  354. static Win32NativeFileChooser* getNativePointerForDialog (HWND hWnd)
  355. {
  356. return getNativeDialogList()[hWnd];
  357. }
  358. //==============================================================================
  359. void setupFilters()
  360. {
  361. const size_t filterSpaceNumChars = 2048;
  362. filters.calloc (filterSpaceNumChars);
  363. const size_t bytesWritten = filtersString.copyToUTF16 (filters.getData(), filterSpaceNumChars * sizeof (WCHAR));
  364. filtersString.copyToUTF16 (filters + (bytesWritten / sizeof (WCHAR)),
  365. ((filterSpaceNumChars - 1) * sizeof (WCHAR) - bytesWritten));
  366. for (size_t i = 0; i < filterSpaceNumChars; ++i)
  367. if (filters[i] == '|')
  368. filters[i] = 0;
  369. }
  370. DWORD getOpenFilenameFlags (bool async)
  371. {
  372. DWORD ofFlags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_ENABLESIZING;
  373. if (warnAboutOverwrite)
  374. ofFlags |= OFN_OVERWRITEPROMPT;
  375. if (selectMultiple)
  376. ofFlags |= OFN_ALLOWMULTISELECT;
  377. if (async || customComponent != nullptr)
  378. ofFlags |= OFN_ENABLEHOOK;
  379. return ofFlags;
  380. }
  381. //==============================================================================
  382. void initialised (HWND hWnd)
  383. {
  384. SendMessage (hWnd, BFFM_SETSELECTIONW, TRUE, (LPARAM) initialPath.toWideCharPointer());
  385. initDialog (hWnd);
  386. }
  387. void validateFailed (const String& path)
  388. {
  389. returnedString = path;
  390. }
  391. void initDialog (HWND hdlg)
  392. {
  393. ScopedLock lock (deletingDialog);
  394. getNativeDialogList().set (hdlg, this);
  395. if (shouldCancel.get() != 0)
  396. {
  397. EndDialog (hdlg, 0);
  398. }
  399. else
  400. {
  401. nativeDialogRef.set (hdlg);
  402. if (customComponent != nullptr)
  403. {
  404. Component::SafePointer<Component> safeCustomComponent (customComponent.get());
  405. RECT dialogScreenRect, dialogClientRect;
  406. GetWindowRect (hdlg, &dialogScreenRect);
  407. GetClientRect (hdlg, &dialogClientRect);
  408. auto screenRectangle = Rectangle<int>::leftTopRightBottom (dialogScreenRect.left, dialogScreenRect.top,
  409. dialogScreenRect.right, dialogScreenRect.bottom);
  410. auto scale = Desktop::getInstance().getDisplays().findDisplayForRect (screenRectangle, true).scale;
  411. auto physicalComponentWidth = roundToInt (safeCustomComponent->getWidth() * scale);
  412. SetWindowPos (hdlg, nullptr, screenRectangle.getX(), screenRectangle.getY(),
  413. physicalComponentWidth + jmax (150, screenRectangle.getWidth()),
  414. jmax (150, screenRectangle.getHeight()),
  415. SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER);
  416. auto appendCustomComponent = [safeCustomComponent, dialogClientRect, scale, hdlg]() mutable
  417. {
  418. if (safeCustomComponent != nullptr)
  419. {
  420. auto scaledClientRectangle = Rectangle<int>::leftTopRightBottom (dialogClientRect.left, dialogClientRect.top,
  421. dialogClientRect.right, dialogClientRect.bottom) / scale;
  422. safeCustomComponent->setBounds (scaledClientRectangle.getRight(), scaledClientRectangle.getY(),
  423. safeCustomComponent->getWidth(), scaledClientRectangle.getHeight());
  424. safeCustomComponent->addToDesktop (0, hdlg);
  425. }
  426. };
  427. if (MessageManager::getInstance()->isThisTheMessageThread())
  428. appendCustomComponent();
  429. else
  430. MessageManager::callAsync (appendCustomComponent);
  431. }
  432. }
  433. }
  434. void destroyDialog (HWND hdlg)
  435. {
  436. ScopedLock exiting (deletingDialog);
  437. getNativeDialogList().remove (hdlg);
  438. nativeDialogRef.set (nullptr);
  439. if (MessageManager::getInstance()->isThisTheMessageThread())
  440. customComponent = nullptr;
  441. else
  442. MessageManager::callAsync ([this] { customComponent = nullptr; });
  443. }
  444. void selectionChanged (HWND hdlg)
  445. {
  446. ScopedLock lock (deletingDialog);
  447. if (customComponent != nullptr && shouldCancel.get() == 0)
  448. {
  449. if (FilePreviewComponent* comp = dynamic_cast<FilePreviewComponent*> (customComponent->getChildComponent (0)))
  450. {
  451. WCHAR path [MAX_PATH * 2] = { 0 };
  452. CommDlg_OpenSave_GetFilePath (hdlg, (LPARAM) &path, MAX_PATH);
  453. if (MessageManager::getInstance()->isThisTheMessageThread())
  454. {
  455. comp->selectedFileChanged (File (path));
  456. }
  457. else
  458. {
  459. Component::SafePointer<FilePreviewComponent> safeComp (comp);
  460. File selectedFile (path);
  461. MessageManager::callAsync ([safeComp, selectedFile]() mutable
  462. {
  463. safeComp->selectedFileChanged (selectedFile);
  464. });
  465. }
  466. }
  467. }
  468. }
  469. //==============================================================================
  470. static int CALLBACK browseCallbackProc (HWND hWnd, UINT msg, LPARAM lParam, LPARAM lpData)
  471. {
  472. auto* self = reinterpret_cast<Win32NativeFileChooser*> (lpData);
  473. switch (msg)
  474. {
  475. case BFFM_INITIALIZED: self->initialised (hWnd); break;
  476. case BFFM_VALIDATEFAILEDW: self->validateFailed (String ((LPCWSTR) lParam)); break;
  477. case BFFM_VALIDATEFAILEDA: self->validateFailed (String ((const char*) lParam)); break;
  478. default: break;
  479. }
  480. return 0;
  481. }
  482. static UINT_PTR CALLBACK openCallback (HWND hwnd, UINT uiMsg, WPARAM /*wParam*/, LPARAM lParam)
  483. {
  484. auto hdlg = getDialogFromHWND (hwnd);
  485. switch (uiMsg)
  486. {
  487. case WM_INITDIALOG:
  488. {
  489. if (auto* self = reinterpret_cast<Win32NativeFileChooser*> (((OPENFILENAMEW*) lParam)->lCustData))
  490. self->initDialog (hdlg);
  491. break;
  492. }
  493. case WM_DESTROY:
  494. {
  495. if (auto* self = getNativeDialogList()[hdlg])
  496. self->destroyDialog (hdlg);
  497. break;
  498. }
  499. case WM_NOTIFY:
  500. {
  501. auto ofn = reinterpret_cast<LPOFNOTIFY> (lParam);
  502. if (ofn->hdr.code == CDN_SELCHANGE)
  503. if (auto* self = reinterpret_cast<Win32NativeFileChooser*> (ofn->lpOFN->lCustData))
  504. self->selectionChanged (hdlg);
  505. break;
  506. }
  507. default:
  508. break;
  509. }
  510. return 0;
  511. }
  512. static HWND getDialogFromHWND (HWND hwnd)
  513. {
  514. if (hwnd == nullptr)
  515. return nullptr;
  516. HWND dialogH = GetParent (hwnd);
  517. if (dialogH == nullptr)
  518. dialogH = hwnd;
  519. return dialogH;
  520. }
  521. //==============================================================================
  522. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Win32NativeFileChooser)
  523. };
  524. class FileChooser::Native : public Component,
  525. public FileChooser::Pimpl
  526. {
  527. public:
  528. Native (FileChooser& fileChooser, int flags, FilePreviewComponent* previewComp)
  529. : owner (fileChooser),
  530. nativeFileChooser (new Win32NativeFileChooser (this, flags, previewComp, fileChooser.startingFile,
  531. fileChooser.title, fileChooser.filters))
  532. {
  533. auto mainMon = Desktop::getInstance().getDisplays().getMainDisplay().userArea;
  534. setBounds (mainMon.getX() + mainMon.getWidth() / 4,
  535. mainMon.getY() + mainMon.getHeight() / 4,
  536. 0, 0);
  537. setOpaque (true);
  538. setAlwaysOnTop (juce_areThereAnyAlwaysOnTopWindows());
  539. addToDesktop (0);
  540. }
  541. ~Native() override
  542. {
  543. exitModalState (0);
  544. nativeFileChooser->cancel();
  545. nativeFileChooser = nullptr;
  546. }
  547. void launch() override
  548. {
  549. SafePointer<Native> safeThis (this);
  550. enterModalState (true, ModalCallbackFunction::create (
  551. [safeThis] (int)
  552. {
  553. if (safeThis != nullptr)
  554. safeThis->owner.finished (safeThis->nativeFileChooser->results);
  555. }));
  556. nativeFileChooser->open (true);
  557. }
  558. void runModally() override
  559. {
  560. enterModalState (true);
  561. nativeFileChooser->open (false);
  562. exitModalState (nativeFileChooser->results.size() > 0 ? 1 : 0);
  563. nativeFileChooser->cancel();
  564. owner.finished (nativeFileChooser->results);
  565. }
  566. bool canModalEventBeSentToComponent (const Component* targetComponent) override
  567. {
  568. if (targetComponent == nullptr)
  569. return false;
  570. if (targetComponent == nativeFileChooser->getCustomComponent())
  571. return true;
  572. return targetComponent->findParentComponentOfClass<FilePreviewComponent>() != nullptr;
  573. }
  574. private:
  575. FileChooser& owner;
  576. Win32NativeFileChooser::Ptr nativeFileChooser;
  577. };
  578. //==============================================================================
  579. bool FileChooser::isPlatformDialogAvailable()
  580. {
  581. #if JUCE_DISABLE_NATIVE_FILECHOOSERS
  582. return false;
  583. #else
  584. return true;
  585. #endif
  586. }
  587. FileChooser::Pimpl* FileChooser::showPlatformDialog (FileChooser& owner, int flags,
  588. FilePreviewComponent* preview)
  589. {
  590. return new FileChooser::Native (owner, flags, preview);
  591. }
  592. } // namespace juce