OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_GTK_CUSTOM_DRAG_H_ | |
6 #define CHROME_BROWSER_UI_GTK_CUSTOM_DRAG_H_ | |
7 | |
8 #include <gtk/gtk.h> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "ui/base/gtk/gtk_signal.h" | |
12 | |
13 namespace gfx { | |
14 class Image; | |
15 } | |
16 | |
17 // Base class for programatically generated drags. | |
18 class CustomDrag { | |
19 protected: | |
20 CustomDrag(gfx::Image* icon, int code_mask, GdkDragAction action); | |
21 virtual ~CustomDrag(); | |
22 | |
23 virtual void OnDragDataGet(GtkWidget* widget, | |
24 GdkDragContext* context, | |
25 GtkSelectionData* selection_data, | |
26 guint target_type, | |
27 guint time) = 0; | |
28 | |
29 private: | |
30 CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragBegin, GdkDragContext*); | |
31 CHROMEGTK_CALLBACK_1(CustomDrag, void, OnDragEnd, GdkDragContext*); | |
32 | |
33 // Since this uses a virtual function, we can't use a macro. | |
34 static void OnDragDataGetThunk(GtkWidget* widget, GdkDragContext* context, | |
35 GtkSelectionData* selection_data, | |
36 guint target_type, guint time, | |
37 CustomDrag* custom_drag) { | |
38 return custom_drag->OnDragDataGet(widget, context, selection_data, | |
39 target_type, time); | |
40 } | |
41 | |
42 // Can't use a OwnedWidgetGtk because the initialization of GtkInvisible | |
43 // sinks the reference. | |
44 GtkWidget* drag_widget_; | |
45 | |
46 // The image for the drag. The lifetime of the image should be managed outside | |
47 // this object. Most icons are owned by the IconManager. | |
48 gfx::Image* image_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(CustomDrag); | |
51 }; | |
52 | |
53 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_DRAG_H_ | |
OLD | NEW |