1 /** @file
2 * @brief Color swatches dialog
3 */
4 /* Authors:
5 * Jon A. Cruz
6 *
7 * Copyright (C) 2005 Jon A. Cruz
8 * Released under GNU GPL, read the file 'COPYING' for more information
9 */
10 #ifndef SEEN_DIALOGS_SWATCHES_H
11 #define SEEN_DIALOGS_SWATCHES_H
13 #include <gtkmm/textview.h>
14 #include <gtkmm/tooltips.h>
16 #include "ui/widget/panel.h"
17 #include "ui/previewholder.h"
18 #include "dialogs/eek-color-def.h"
20 using eek::ColorDef;
22 namespace Inkscape {
23 namespace UI {
24 namespace Dialogs {
27 void _loadPaletteFile( gchar const *filename );
29 /**
30 * The color swatch you see on screen as a clickable box.
31 */
32 class ColorItem : public Inkscape::UI::Previewable
33 {
34 friend void _loadPaletteFile( gchar const *filename );
35 public:
36 ColorItem();
37 ColorItem( unsigned int r, unsigned int g, unsigned int b,
38 Glib::ustring& name );
39 virtual ~ColorItem();
40 ColorItem(ColorItem const &other);
41 virtual ColorItem &operator=(ColorItem const &other);
42 virtual Gtk::Widget* getPreview(PreviewStyle style,
43 ViewType view,
44 ::PreviewSize size,
45 guint ratio);
46 void buttonClicked(bool secondary = false);
47 bool isRemove(){ return _isRemove; }
48 ColorDef def;
50 private:
51 static void _dropDataIn( GtkWidget *widget,
52 GdkDragContext *drag_context,
53 gint x, gint y,
54 GtkSelectionData *data,
55 guint info,
56 guint event_time,
57 gpointer user_data);
59 static void _dragGetColorData( GtkWidget *widget,
60 GdkDragContext *drag_context,
61 GtkSelectionData *data,
62 guint info,
63 guint time,
64 gpointer user_data);
66 static void _wireMagicColors( void* p );
67 static void _colorDefChanged(void* data);
69 void _linkTint( ColorItem& other, int percent );
70 void _linkTone( ColorItem& other, int percent, int grayLevel );
72 Gtk::Tooltips tips;
73 std::vector<Gtk::Widget*> _previews;
75 bool _isRemove;
76 bool _isLive;
77 bool _linkIsTone;
78 int _linkPercent;
79 int _linkGray;
80 ColorItem* _linkSrc;
81 std::vector<ColorItem*> _listeners;
82 };
84 class RemoveColorItem;
86 /**
87 * A panel that displays color swatches.
88 */
89 class SwatchesPanel : public Inkscape::UI::Widget::Panel
90 {
91 public:
92 SwatchesPanel(gchar const* prefsPath = "/dialogs/swatches");
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 ColorItem* _remove;
109 };
111 } //namespace Dialogs
112 } //namespace UI
113 } //namespace Inkscape
117 #endif // SEEN_SWATCHES_H
119 /*
120 Local Variables:
121 mode:c++
122 c-file-style:"stroustrup"
123 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
124 indent-tabs-mode:nil
125 fill-column:99
126 End:
127 */
128 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :