1 /* Copyright (C) 2008 The goocanvasmm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free
15  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17 
18 #ifndef _GOOCANVASMM_EXAMPLEWINDOW_H
19 #define _GOOCANVASMM_EXAMPLEWINDOW_H
20 
21 #include <gtkmm.h>
22 #include <goocanvasmm.h>
23 
24 class ExampleWindow : public Gtk::Window
25 {
26 public:
27   ExampleWindow();
28 
29 protected:
30 
31   enum DragItem
32   {
33     DRAG_ITEM_NONE,
34     DRAG_ITEM_RECTANGLE,
35     DRAG_ITEM_ELLIPSE
36   };
37 
38   void make_widget_draggable(Gtk::Widget& widget, DragItem drag_item);
39 
40   void on_button_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::SelectionData& selection_data, guint info, guint time, DragItem drag_item);
41   bool on_canvas_drag_drop(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint timestamp);
42   bool on_canvas_drag_motion(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint timestamp);
43   void on_canvas_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint timestamp);
44 
45   Glib::RefPtr<Goocanvas::Item> create_canvas_item(DragItem drag_item, int x, int y);
46 
47   static DragItem get_drag_item_from_selection_data(const Gtk::SelectionData& selection_data);
48 
49   Goocanvas::Canvas m_canvas;
50 
51   Gtk::VBox m_vbox;
52   Gtk::HBox m_hbox;
53   Gtk::Button m_button_rect, m_button_ellipse;
54 
55   std::vector<Gtk::TargetEntry> m_drag_targets;
56   Glib::RefPtr<Goocanvas::Item> m_layout_item_dropping;
57   bool m_drag_preview_requested;
58 };
59 
60 #endif //_GOOCANVASMM_EXAMPLEWINDOW_H
61 
62