2013-08-16 04:09:39 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef nsColorPicker_h_
|
|
|
|
#define nsColorPicker_h_
|
|
|
|
|
|
|
|
#include "nsIColorPicker.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
class nsIColorPickerShownCallback;
|
|
|
|
class nsIDOMWindow;
|
|
|
|
@class NSColorPanelWrapper;
|
|
|
|
@class NSColor;
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsColorPicker final : public nsIColorPicker
|
2013-08-16 04:09:39 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Init(nsIDOMWindow* aParent, const nsAString& aTitle,
|
2015-03-21 09:28:04 -07:00
|
|
|
const nsAString& aInitialColor) override;
|
|
|
|
NS_IMETHOD Open(nsIColorPickerShownCallback* aCallback) override;
|
2013-08-16 04:09:39 -07:00
|
|
|
|
|
|
|
// For NSColorPanelWrapper.
|
|
|
|
void Update(NSColor* aColor);
|
2014-03-13 13:52:14 -07:00
|
|
|
// Call this method if you are done with this input, but the color picker needs to
|
|
|
|
// stay open as it will be associated to another input
|
|
|
|
void DoneWithRetarget();
|
|
|
|
// Same as DoneWithRetarget + clean the static instance of sColorPanelWrapper,
|
|
|
|
// as it is not needed anymore for now
|
2013-08-16 04:09:39 -07:00
|
|
|
void Done();
|
|
|
|
|
|
|
|
private:
|
2014-07-06 08:25:31 -07:00
|
|
|
~nsColorPicker();
|
|
|
|
|
2013-08-16 04:09:39 -07:00
|
|
|
static NSColor* GetNSColorFromHexString(const nsAString& aColor);
|
|
|
|
static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult);
|
|
|
|
|
2014-03-13 13:52:14 -07:00
|
|
|
static NSColorPanelWrapper* sColorPanelWrapper;
|
|
|
|
|
2013-08-16 04:09:39 -07:00
|
|
|
nsString mTitle;
|
|
|
|
nsString mColor;
|
|
|
|
nsCOMPtr<nsIColorPickerShownCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsColorPicker_h_
|