Debian Codegraph @

gtk/src/toolpalette.hg

raw
1 /* Copyright (C) 2009 The gtkmm 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, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtkmm/container.h>
18 #include <gtkmm/toolitem.h>
19 #include <gtkmm/orientable.h>
20 #include <gtkmm/scrollable.h>
21 #include <gtkmm/toolitemgroup.h>
22
23 _DEFS(gtkmm,gtk)
24 _PINCLUDE(gtkmm/private/container_p.h)
25
26 namespace Gtk
27 {
28
29 _WRAP_ENUM(ToolPaletteDragTargets, GtkToolPaletteDragTargets, decl_prefix GTKMM_API)
30
31 /** A ToolPalette allows you to add ToolItems to a palette-like container with
32 * various categories and drag and drop support.
33 *
34 * ToolItems cannot be added directly to a ToolPalette - instead they are added
35 * to a ToolItemGroup which can than be added to a ToolPalette. To add a
36 * ToolItemGroup to a ToolPalette, use Gtk::Container::add().
37 *
38 * The easiest way to use drag and drop with ToolPalette is to call
39 * add_drag_dest() with the desired drag source palette and the desired drag
40 * target widget. Then get_drag_item() can be used to get the dragged item in
41 * the "drag-data-received" signal handler of the drag target.
42 *
43 * @newin{2,20}
44 *
45 * @ingroup Widgets
46 * @ingroup Containers
47 */
48 class GTKMM_API ToolPalette
49 : public Container,
50 public Orientable,
51 public Scrollable
52 {
53 _CLASS_GTKOBJECT(ToolPalette, GtkToolPalette, GTK_TOOL_PALETTE, Gtk::Container, GtkContainer, , , GTKMM_API)
54 _IMPLEMENTS_INTERFACE(Orientable)
55 _IMPLEMENTS_INTERFACE(Scrollable)
56 public:
57 _CTOR_DEFAULT()
58
59
60 _WRAP_METHOD(void set_group_position(ToolItemGroup& group, int position), gtk_tool_palette_set_group_position)
61 _WRAP_METHOD(void set_exclusive(ToolItemGroup& group, bool exclusive), gtk_tool_palette_set_exclusive)
62 _WRAP_METHOD(void set_expand(ToolItemGroup& group, bool expand = true), gtk_tool_palette_set_expand)
63
64 _WRAP_METHOD(int get_group_position(ToolItemGroup& group) const, gtk_tool_palette_get_group_position)
65 _WRAP_METHOD(bool get_exclusive(ToolItemGroup& group) const, gtk_tool_palette_get_exclusive)
66 _WRAP_METHOD(bool get_expand(ToolItemGroup& group) const, gtk_tool_palette_get_expand)
67
68 _WRAP_METHOD(void set_icon_size(IconSize icon_size), gtk_tool_palette_set_icon_size)
69 _WRAP_METHOD(void unset_icon_size(), gtk_tool_palette_unset_icon_size)
70 _WRAP_METHOD(void set_style(ToolbarStyle style), gtk_tool_palette_set_style)
71 _WRAP_METHOD(void unset_style(), gtk_tool_palette_unset_style)
72
73 _WRAP_METHOD(IconSize get_icon_size() const, gtk_tool_palette_get_icon_size)
74 _WRAP_METHOD(ToolbarStyle get_style() const, gtk_tool_palette_get_style)
75
76 _WRAP_METHOD(ToolItem* get_drop_item(int x, int y), gtk_tool_palette_get_drop_item)
77 _WRAP_METHOD(const ToolItem* get_drop_item(int x, int y) const, gtk_tool_palette_get_drop_item, constversion)
78
79 //This conversion is needed because of https://bugzilla.gnome.org/show_bug.cgi?id=567729#c37
80 #m4 _CONVERSION(`GtkWidget*',`ToolItemGroup*',`Glib::wrap(GTK_TOOL_ITEM_GROUP($3))')
81 #m4 _CONVERSION(`GtkWidget*',`const ToolItemGroup*',`Glib::wrap(GTK_TOOL_ITEM_GROUP($3))')
82 _WRAP_METHOD(ToolItemGroup* get_drop_group(int x, int y), gtk_tool_palette_get_drop_group)
83 _WRAP_METHOD(const ToolItemGroup* get_drop_group(int x, int y) const, gtk_tool_palette_get_drop_group, constversion)
84
85 _WRAP_METHOD(ToolItem* get_drag_item(const SelectionData& selection), gtk_tool_palette_get_drag_item)
86 _WRAP_METHOD(const ToolItem* get_drag_item(const SelectionData& selection) const, gtk_tool_palette_get_drag_item, constversion)
87
88 _WRAP_METHOD(void set_drag_source(ToolPaletteDragTargets targets = TOOL_PALETTE_DRAG_ITEMS), gtk_tool_palette_set_drag_source)
89 _WRAP_METHOD(void add_drag_dest(Gtk::Widget& widget, DestDefaults flags = DEST_DEFAULT_ALL, ToolPaletteDragTargets targets = TOOL_PALETTE_DRAG_ITEMS, Gdk::DragAction actions = Gdk::ACTION_COPY), gtk_tool_palette_add_drag_dest)
90
91 _IGNORE(gtk_tool_palette_get_hadjustment, gtk_tool_palette_get_hadjustment,
92 gtk_tool_palette_get_vadjustment, gtk_tool_palette_get_vadjustment)
93
94
95 #m4 _CONVERSION(`const GtkTargetEntry*',`TargetEntry',`TargetEntry(*$3)')
96 _WRAP_METHOD(static TargetEntry get_drag_target_item(), gtk_tool_palette_get_drag_target_item)
97 _WRAP_METHOD(static TargetEntry get_drag_target_group(), gtk_tool_palette_get_drag_target_group)
98
99 _WRAP_PROPERTY("icon-size", IconSize)
100 _WRAP_PROPERTY("icon-size-set", bool)
101 _WRAP_PROPERTY("toolbar-style", ToolbarStyle)
102
103 _WRAP_CHILD_PROPERTY("exclusive", bool)
104 _WRAP_CHILD_PROPERTY("expand", bool)
105 };
106
107 } // namespace Gtk