widget/windows/winrt/nsMetroFilePicker.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/windows/winrt/nsMetroFilePicker.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsMetroFilePicker_h__
    1.10 +#define nsMetroFilePicker_h__
    1.11 +
    1.12 +#include "../nsFilePicker.h"
    1.13 +#include "nsString.h"
    1.14 +#include "nsCOMArray.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsILocalFile.h"
    1.17 +
    1.18 +#include "mozwrlbase.h"
    1.19 +
    1.20 +#include <windows.system.h>
    1.21 +#include <windows.ui.core.h>
    1.22 +#include <windows.foundation.h>
    1.23 +#include <windows.storage.pickers.h>
    1.24 +#include <windows.storage.fileproperties.h>
    1.25 +
    1.26 +/**
    1.27 + * Metro file picker
    1.28 + */
    1.29 +
    1.30 +class nsMetroFilePicker :
    1.31 +  public nsBaseWinFilePicker
    1.32 +{
    1.33 +  typedef Microsoft::WRL::Wrappers::HString HString;
    1.34 +  typedef ABI::Windows::Storage::StorageFile StorageFile;
    1.35 +  typedef ABI::Windows::Foundation::AsyncStatus AsyncStatus;
    1.36 +  
    1.37 +public:
    1.38 +  nsMetroFilePicker(); 
    1.39 +  virtual ~nsMetroFilePicker();
    1.40 +
    1.41 +  NS_DECL_ISUPPORTS
    1.42 +  
    1.43 +  // nsIFilePicker (less what's in nsBaseFilePicker)
    1.44 +  NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex);
    1.45 +  NS_IMETHOD SetFilterIndex(int32_t aFilterIndex);
    1.46 +  NS_IMETHOD GetFile(nsIFile * *aFile);
    1.47 +  NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
    1.48 +  NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
    1.49 +  NS_IMETHOD Show(int16_t *aReturnVal); 
    1.50 +  NS_IMETHOD Open(nsIFilePickerShownCallback *aCallback); 
    1.51 +  NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
    1.52 +  NS_IMETHOD Init(nsIDOMWindow *parent, const nsAString& title,
    1.53 +                  int16_t mode);
    1.54 +
    1.55 +  // Async callbacks
    1.56 +  HRESULT OnPickSingleFile(ABI::Windows::Foundation::IAsyncOperation<StorageFile*>* aFile, AsyncStatus aStatus);
    1.57 +  HRESULT OnPickMultipleFiles(ABI::Windows::Foundation::IAsyncOperation<ABI::Windows::Foundation::Collections::IVectorView<StorageFile*>*>* aFileList, AsyncStatus aStatus);
    1.58 +
    1.59 +private:
    1.60 +  void InitNative(nsIWidget*, const nsAString&) {};
    1.61 +  nsresult ParseFiltersIntoVector(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<HSTRING>>& aVector,
    1.62 +                                  const nsAString& aFilter,
    1.63 +                                  bool aAllowAll);
    1.64 +  nsCOMArray<nsILocalFile> mFiles;
    1.65 +  Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileOpenPicker> mFileOpenPicker;
    1.66 +  Microsoft::WRL::ComPtr<ABI::Windows::Storage::Pickers::IFileSavePicker> mFileSavePicker;
    1.67 +  HString mFilePath;
    1.68 +  HString mFirstTitle;
    1.69 +  nsRefPtr<nsIFilePickerShownCallback> mCallback;
    1.70 +};
    1.71 +
    1.72 +#endif // nsMetroFilePicker_h__

mercurial