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 );
30 /**
31 * The color swatch you see on screen as a clickable box.
32 */
33 class ColorItem : public Inkscape::UI::Previewable
34 {
35 friend void _loadPaletteFile( gchar const *filename );
36 public:
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);
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 _isLive;
76 bool _linkIsTone;
77 int _linkPercent;
78 int _linkGray;
79 ColorItem* _linkSrc;
80 std::vector<ColorItem*> _listeners;
81 };
85 /**
86 * A panel that displays color swatches.
87 */
88 class SwatchesPanel : public Inkscape::UI::Widget::Panel
89 {
90 public:
91 SwatchesPanel(gchar const* prefsPath = "/dialogs/swatches");
92 virtual ~SwatchesPanel();
94 static SwatchesPanel& getInstance();
95 virtual void setOrientation( Gtk::AnchorType how );
97 protected:
98 virtual void _handleAction( int setId, int itemId );
100 private:
101 SwatchesPanel(SwatchesPanel const &); // no copy
102 SwatchesPanel &operator=(SwatchesPanel const &); // no assign
104 static SwatchesPanel* instance;
106 PreviewHolder* _holder;
107 };
109 } //namespace Dialogs
110 } //namespace UI
111 } //namespace Inkscape
115 #endif // SEEN_SWATCHES_H
117 /*
118 Local Variables:
119 mode:c++
120 c-file-style:"stroustrup"
121 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
122 indent-tabs-mode:nil
123 fill-column:99
124 End:
125 */
126 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :