1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * color-palette.h - A color selector palette
4 * Copyright 2000, 2001, Ximian, Inc.
7 * This code was extracted from widget-color-combo.c
8 * written by Miguel de Icaza (miguel@kernel.org) and
9 * Dom Lachowicz (dominicl@seas.upenn.edu). The extracted
10 * code was re-packaged into a separate object by
11 * Michael Levy (mlevy@genoscope.cns.fr)
12 * And later revised and polished by
13 * Almer S. Tigelaar (almer@gnome.org)
15 * Modified for gLabels by:
16 * Jim Evins <evins@snaught.com>
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public
20 * License, version 2, as published by the Free Software Foundation.
22 * This library is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
27 * You should have received a copy of the GNU General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #ifndef GNUMERIC_COLOR_PALETTE_H
34 #define GNUMERIC_COLOR_PALETTE_H
36 #include <gtk/gtktooltips.h>
37 #include <gtk/gtkvbox.h>
38 #include <gtk/gtkwidget.h>
39 #include <gtk/gtkcolorbutton.h>
40 #include <libgnomecanvas/gnome-canvas.h>
41 #include "color-group.h"
45 typedef struct _ColorNamePair ColorNamePair;
47 typedef struct _ColorPalette {
49 GtkTooltips *tool_tip;
50 GtkColorButton *picker;
54 GnomeCanvasItem **items;
55 /* The (potentially NULL) default color */
56 GdkColor *default_color;
58 /* The current color */
59 GdkColor *current_color;
60 gboolean current_is_default;
63 * Position of the last possible position
64 * for custom colors in **items
65 * (i.e. custom colors go from items[custom_color_pos]
66 * to items[total - 1])
68 * If custom_color_pos == -1, there is no room for custom colors
72 * Number of default colors in **items
76 /* The table with our default color names */
77 ColorNamePair *default_set;
79 /* The color group to which we belong */
80 ColorGroup *color_group;
84 GtkVBoxClass parent_class;
86 /* Signals emited by this widget */
87 void (* color_changed) (ColorPalette *color_palette, GdkColor *color,
88 gboolean custom, gboolean by_user, gboolean is_default);
91 #define COLOR_PALETTE_TYPE (color_palette_get_type ())
92 #define COLOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), COLOR_PALETTE_TYPE, ColorPalette))
93 #define COLOR_PALETTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST(k), COLOR_PALETTE_TYPE)
94 #define IS_COLOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), COLOR_PALETTE_TYPE))
96 GtkType color_palette_get_type (void);
98 GtkWidget *color_palette_new (const char *no_color_label,
99 GdkColor *default_color,
100 ColorGroup *color_group);
101 void color_palette_set_group (ColorPalette *P,
104 void color_palette_set_current_color (ColorPalette *P, GdkColor *color);
105 void color_palette_set_color_to_default (ColorPalette *P);
106 GdkColor *color_palette_get_current_color (ColorPalette *P, gboolean *is_default);
107 GtkWidget *color_palette_get_color_picker (ColorPalette *P);
111 #endif /* GNUMERIC_PALETTE_H */