Code

Objects will now change when their linked colors change.
[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 _wireMagicColors( void* p );
61     static void _colorDefChanged(void* data);
63     void _linkTint( ColorItem& other, int percent );
64     void _linkTone( ColorItem& other, int percent, int grayLevel );
66     Gtk::Tooltips tips;
67     std::vector<Gtk::Widget*> _previews;
69     bool _linkIsTone;
70     int _linkPercent;
71     int _linkGray;
72     ColorItem* _linkSrc;
73     std::vector<ColorItem*> _listeners;
74 };
76         
78 /**
79  * A panel that displays color swatches.
80  */
81 class SwatchesPanel : public Inkscape::UI::Widget::Panel
82 {
83 public:
84     SwatchesPanel();
85     virtual ~SwatchesPanel();
87     static SwatchesPanel& getInstance();
88     virtual void setOrientation( Gtk::AnchorType how );
90 protected:
91     virtual void _handleAction( int setId, int itemId );
93 private:
94     SwatchesPanel(SwatchesPanel const &); // no copy
95     SwatchesPanel &operator=(SwatchesPanel const &); // no assign
97     static SwatchesPanel* instance;
99     PreviewHolder* _holder;
100 };
102 } //namespace Dialogs
103 } //namespace UI
104 } //namespace Inkscape
108 #endif // SEEN_SWATCHES_H
110 /*
111   Local Variables:
112   mode:c++
113   c-file-style:"stroustrup"
114   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
115   indent-tabs-mode:nil
116   fill-column:99
117   End:
118 */
119 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :