Code

Merging from trunk
[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                                     ::PreviewSize size,
47                                     guint ratio);
48     void buttonClicked(bool secondary = false);
50     ColorDef def;
52 private:
53     static void _dropDataIn( GtkWidget *widget,
54                              GdkDragContext *drag_context,
55                              gint x, gint y,
56                              GtkSelectionData *data,
57                              guint info,
58                              guint event_time,
59                              gpointer user_data);
61     static void _dragGetColorData( GtkWidget *widget,
62                                    GdkDragContext *drag_context,
63                                    GtkSelectionData *data,
64                                    guint info,
65                                    guint time,
66                                    gpointer user_data);
68     static void _wireMagicColors( void* p );
69     static void _colorDefChanged(void* data);
71     void _linkTint( ColorItem& other, int percent );
72     void _linkTone( ColorItem& other, int percent, int grayLevel );
74     Gtk::Tooltips tips;
75     std::vector<Gtk::Widget*> _previews;
77     bool _isLive;
78     bool _linkIsTone;
79     int _linkPercent;
80     int _linkGray;
81     ColorItem* _linkSrc;
82     std::vector<ColorItem*> _listeners;
83 };
85         
87 /**
88  * A panel that displays color swatches.
89  */
90 class SwatchesPanel : public Inkscape::UI::Widget::Panel
91 {
92 public:
93     SwatchesPanel(gchar const* prefsPath = "dialogs.swatches");
94     virtual ~SwatchesPanel();
96     static SwatchesPanel& getInstance();
97     virtual void setOrientation( Gtk::AnchorType how );
99 protected:
100     virtual void _handleAction( int setId, int itemId );
102 private:
103     SwatchesPanel(SwatchesPanel const &); // no copy
104     SwatchesPanel &operator=(SwatchesPanel const &); // no assign
106     static SwatchesPanel* instance;
108     PreviewHolder* _holder;
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 :