Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef nsColorPicker_h_ |
michael@0 | 8 | #define nsColorPicker_h_ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsIColorPicker.h" |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | |
michael@0 | 14 | class nsIColorPickerShownCallback; |
michael@0 | 15 | class nsIDOMWindow; |
michael@0 | 16 | @class NSColorPanelWrapper; |
michael@0 | 17 | @class NSColor; |
michael@0 | 18 | |
michael@0 | 19 | class nsColorPicker MOZ_FINAL : public nsIColorPicker |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | NS_DECL_ISUPPORTS |
michael@0 | 23 | |
michael@0 | 24 | NS_IMETHOD Init(nsIDOMWindow* aParent, const nsAString& aTitle, |
michael@0 | 25 | const nsAString& aInitialColor); |
michael@0 | 26 | NS_IMETHOD Open(nsIColorPickerShownCallback* aCallback); |
michael@0 | 27 | |
michael@0 | 28 | // For NSColorPanelWrapper. |
michael@0 | 29 | void Update(NSColor* aColor); |
michael@0 | 30 | // Call this method if you are done with this input, but the color picker needs to |
michael@0 | 31 | // stay open as it will be associated to another input |
michael@0 | 32 | void DoneWithRetarget(); |
michael@0 | 33 | // Same as DoneWithRetarget + clean the static instance of sColorPanelWrapper, |
michael@0 | 34 | // as it is not needed anymore for now |
michael@0 | 35 | void Done(); |
michael@0 | 36 | |
michael@0 | 37 | private: |
michael@0 | 38 | static NSColor* GetNSColorFromHexString(const nsAString& aColor); |
michael@0 | 39 | static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult); |
michael@0 | 40 | |
michael@0 | 41 | static NSColorPanelWrapper* sColorPanelWrapper; |
michael@0 | 42 | |
michael@0 | 43 | nsString mTitle; |
michael@0 | 44 | nsString mColor; |
michael@0 | 45 | nsCOMPtr<nsIColorPickerShownCallback> mCallback; |
michael@0 | 46 | }; |
michael@0 | 47 | |
michael@0 | 48 | #endif // nsColorPicker_h_ |