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