Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / widget / gtk / nsColorPicker.h
blobd6931757175cbaaedfe2de7b014c50961edbca05
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsColorPicker_h__
7 #define nsColorPicker_h__
9 #include <gtk/gtk.h>
11 #include "nsCOMPtr.h"
12 #include "nsIColorPicker.h"
13 #include "nsString.h"
15 // Enable Gtk3 system color picker.
16 #define ACTIVATE_GTK3_COLOR_PICKER 1
18 class nsIWidget;
20 class nsColorPicker final : public nsIColorPicker {
21 public:
22 NS_DECL_ISUPPORTS
23 NS_DECL_NSICOLORPICKER
25 nsColorPicker() = default;
27 private:
28 ~nsColorPicker() = default;
30 static nsString ToHexString(int n);
32 static void OnResponse(GtkWidget* dialog, gint response_id,
33 gpointer user_data);
34 static void OnDestroy(GtkWidget* dialog, gpointer user_data);
36 #if defined(ACTIVATE_GTK3_COLOR_PICKER)
37 static void OnColorChanged(GtkColorChooser* color_chooser, GdkRGBA* color,
38 gpointer user_data);
40 static int convertGdkRgbaComponent(gdouble color_component);
41 static gdouble convertToGdkRgbaComponent(int color_component);
42 static GdkRGBA convertToRgbaColor(nscolor color);
44 void Update(GdkRGBA* color);
45 void SetColor(const GdkRGBA* color);
46 #else
47 static void OnColorChanged(GtkColorSelection* colorselection,
48 gpointer user_data);
50 // Conversion functions for color
51 static int convertGdkColorComponent(guint16 color_component);
52 static guint16 convertToGdkColorComponent(int color_component);
53 static GdkColor convertToGdkColor(nscolor color);
55 static GtkColorSelection* WidgetGetColorSelection(GtkWidget* widget);
57 void Update(GtkColorSelection* colorselection);
58 void ReadValueFromColorSelection(GtkColorSelection* colorselection);
59 #endif
61 void Done(GtkWidget* dialog, gint response_id);
63 nsCOMPtr<nsIWidget> mParentWidget;
64 nsCOMPtr<nsIColorPickerShownCallback> mCallback;
65 nsString mTitle;
66 nsString mColor;
67 nsString mInitialColor;
68 nsTArray<nsString> mDefaultColors;
71 #endif // nsColorPicker_h__