]> git.sur5r.net Git - glabels/blob - src/mygal/color-palette.h
Imported Upstream version 2.2.8
[glabels] / src / mygal / color-palette.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* 
3  * color-palette.h - A color selector palette
4  * Copyright 2000, 2001, Ximian, Inc.
5  *
6  * Authors:
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)
14  *
15  * Modified for gLabels by:
16  *   Jim Evins <evins@snaught.com>
17  *
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.
21  *
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.
26  *
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
30  * 02111-1307, USA.
31  */
32
33 #ifndef GNUMERIC_COLOR_PALETTE_H
34 #define GNUMERIC_COLOR_PALETTE_H
35
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"
42
43 G_BEGIN_DECLS
44
45 typedef struct _ColorNamePair ColorNamePair;
46
47 typedef struct _ColorPalette {
48         GtkVBox          vbox;
49         GtkTooltips      *tool_tip;
50         GtkColorButton   *picker;
51         /*
52          * Array of colors
53          */
54         GnomeCanvasItem **items;
55         /* The (potentially NULL) default color */
56         GdkColor *default_color;
57
58         /* The current color */
59         GdkColor *current_color;
60         gboolean  current_is_default;
61         
62         /*
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])
67          *
68          * If custom_color_pos == -1, there is no room for custom colors
69          */
70         int custom_color_pos;
71         /*
72          * Number of default colors in **items
73          */
74         int total;
75
76         /* The table with our default color names */
77         ColorNamePair *default_set;
78         
79         /* The color group to which we belong */
80         ColorGroup *color_group;
81 } ColorPalette;
82
83 typedef struct {
84         GtkVBoxClass parent_class;
85         
86         /* Signals emited by this widget */
87         void (* color_changed) (ColorPalette *color_palette, GdkColor *color,
88                                 gboolean custom, gboolean by_user, gboolean is_default);
89 } ColorPaletteClass;
90
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))
95
96 GtkType         color_palette_get_type (void);
97
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,
102                                           ColorGroup *cg);
103
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);
108
109 G_END_DECLS
110
111 #endif /* GNUMERIC_PALETTE_H */
112
113