2013-08-16 15:09:39 +04: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;
|
2016-01-30 20:05:36 +03:00
|
|
|
class mozIDOMWindowProxy;
|
2013-08-16 15:09:39 +04:00
|
|
|
@class NSColorPanelWrapper;
|
|
|
|
@class NSColor;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsColorPicker final : public nsIColorPicker
|
2013-08-16 15:09:39 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
NS_IMETHOD Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsAString& aInitialColor) override;
|
|
|
|
NS_IMETHOD Open(nsIColorPickerShownCallback* aCallback) override;
|
2013-08-16 15:09:39 +04:00
|
|
|
|
|
|
|
// For NSColorPanelWrapper.
|
|
|
|
void Update(NSColor* aColor);
|
2014-03-14 00:52:14 +04: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 15:09:39 +04:00
|
|
|
void Done();
|
|
|
|
|
|
|
|
private:
|
2014-07-06 19:25:31 +04:00
|
|
|
~nsColorPicker();
|
|
|
|
|
2013-08-16 15:09:39 +04:00
|
|
|
static NSColor* GetNSColorFromHexString(const nsAString& aColor);
|
|
|
|
static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult);
|
|
|
|
|
2014-03-14 00:52:14 +04:00
|
|
|
static NSColorPanelWrapper* sColorPanelWrapper;
|
|
|
|
|
2013-08-16 15:09:39 +04:00
|
|
|
nsString mTitle;
|
|
|
|
nsString mColor;
|
|
|
|
nsCOMPtr<nsIColorPickerShownCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsColorPicker_h_
|