Code

Changed objects to only get linked to "linkable" colors.
[inkscape.git] / src / dialogs / swatches.h
2 #ifndef SEEN_SWATCHES_H
3 #define SEEN_SWATCHES_H
4 /*
5  * A simple dialog for previewing icon representation.
6  *
7  * Authors:
8  *   Jon A. Cruz
9  *
10  * Copyright (C) 2005 Jon A. Cruz
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include <gtkmm/textview.h>
16 #include <gtkmm/tooltips.h>
18 #include "ui/widget/panel.h"
19 #include "ui/previewholder.h"
20 #include "dialogs/eek-color-def.h"
22 using eek::ColorDef;
24 namespace Inkscape {
25 namespace UI {
26 namespace Dialogs {
29 void _loadPaletteFile( gchar const *filename );
32 /**
33  * The color swatch you see on screen as a clickable box.
34  */
35 class ColorItem : public Inkscape::UI::Previewable
36 {
37     friend void _loadPaletteFile( gchar const *filename );
38 public:
39     ColorItem( unsigned int r, unsigned int g, unsigned int b,
40                Glib::ustring& name );
41     virtual ~ColorItem();
42     ColorItem(ColorItem const &other);
43     virtual ColorItem &operator=(ColorItem const &other);
44     virtual Gtk::Widget* getPreview(PreviewStyle style,
45                                     ViewType view,
46                                     Gtk::BuiltinIconSize size);
47     void buttonClicked(bool secondary = false);
49     ColorDef def;
51 private:
52     static void _dropDataIn( GtkWidget *widget,
53                              GdkDragContext *drag_context,
54                              gint x, gint y,
55                              GtkSelectionData *data,
56                              guint info,
57                              guint event_time,
58                              gpointer user_data);
60     static void _dragGetColorData( GtkWidget *widget,
61                                    GdkDragContext *drag_context,
62                                    GtkSelectionData *data,
63                                    guint info,
64                                    guint time,
65                                    gpointer user_data);
67     static void _wireMagicColors( void* p );
68     static void _colorDefChanged(void* data);
70     void _linkTint( ColorItem& other, int percent );
71     void _linkTone( ColorItem& other, int percent, int grayLevel );
73     Gtk::Tooltips tips;
74     std::vector<Gtk::Widget*> _previews;
76     bool _isLive;
77     bool _linkIsTone;
78     int _linkPercent;
79     int _linkGray;
80     ColorItem* _linkSrc;
81     std::vector<ColorItem*> _listeners;
82 };
84         
86 /**
87  * A panel that displays color swatches.
88  */
89 class SwatchesPanel : public Inkscape::UI::Widget::Panel
90 {
91 public:
92     SwatchesPanel();
93     virtual ~SwatchesPanel();
95     static SwatchesPanel& getInstance();
96     virtual void setOrientation( Gtk::AnchorType how );
98 protected:
99     virtual void _handleAction( int setId, int itemId );
101 private:
102     SwatchesPanel(SwatchesPanel const &); // no copy
103     SwatchesPanel &operator=(SwatchesPanel const &); // no assign
105     static SwatchesPanel* instance;
107     PreviewHolder* _holder;
108 };
110 } //namespace Dialogs
111 } //namespace UI
112 } //namespace Inkscape
116 #endif // SEEN_SWATCHES_H
118 /*
119   Local Variables:
120   mode:c++
121   c-file-style:"stroustrup"
122   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
123   indent-tabs-mode:nil
124   fill-column:99
125   End:
126 */
127 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :