102 void add_child (T* child, std::list<Gtk::TargetEntry> targets = std::list<Gtk::TargetEntry>())
104 if (targets.empty ()) {
109 child->action_widget().signal_drag_begin().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_begin), child));
110 child->action_widget().signal_drag_data_get().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_data_get), child));
111 child->action_widget().signal_drag_end().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_end), child));
112 child->action_widget().signal_button_press_event().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::button_press), child));
113 child->action_widget().signal_button_release_event().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::button_release), child));
118 child->widget().show ();
124 std::list<T*> sorted_children;
127 for (std::list<Gtk::Widget*>::iterator i = widget_children.begin(); i != widget_children.end(); ++i) {
131 sorted_children.push_back (c);
135 return sorted_children;
145 for (
typename std::list<T*>::const_iterator i =
_children.begin(); i !=
_children.end(); ++i) {
181 for (
typename std::list<T*>::iterator i =
_children.begin(); i !=
_children.end(); ++i) {
193 for (
typename std::list<T*>::iterator i =
_children.begin(); i !=
_children.end(); ++i) {
215 std::pair<T*, double> r;
256 sigc::signal<void, Gtk::SelectionData const &, T*, Glib::RefPtr<Gdk::DragContext>
const & >
DropFromExternal;
292 *before = *at = *after = 0;
298 typename std::list<T*>::const_iterator j =
_children.begin ();
307 while (y >= bottom && j !=
_children.end()) {
331 return i + ((y - top) / (bottom - top));
334 void drag_begin (Glib::RefPtr<Gdk::DragContext>
const & context, T* child)
349 Glib::RefPtr<Gdk::Colormap const> c = s->get_rgba_colormap ();
371 Glib::RefPtr<Gdk::Pixmap> p =
_drag_child->action_widget().get_snapshot();
373 cairo_rectangle (cr, 0, 0, w, h);
382 if (!child->drag_data_get(context, selection_data)) {
383 selection_data.
set (selection_data.
get_target(), 8, (
const guchar *) &child, sizeof (&child));
388 Glib::RefPtr<Gdk::DragContext>
const & context,
int ,
int y,
Gtk::SelectionData const & selection_data, guint , guint time
396 context->drag_finish (
false,
false, time);
404 T* child = *((T *
const *) selection_data.
get_data());
406 if (drop.first == 0) {
411 int target = drop.second + 0.5;
415 typename std::list<T*>::const_iterator i =
_children.begin ();
416 while (i !=
_children.end() && *i != child && n < target) {
435 context->drag_finish (
false,
false, time);
438 void drag_end (Glib::RefPtr<Gdk::DragContext>
const &, T *)
463 int const n = c < 0 ? -1 : int (c + 0.5);
468 bool drag_motion (Glib::RefPtr<Gdk::DragContext>
const & ctx,
int ,
int y, guint tme)
482 bool top_half = (c - int (c)) < .5;
483 bool bottom_half = !top_half;
487 ctx->drag_refuse (tme);
499 top_half = (c - int (c)) < 0.33;
500 bottom_half = (c - int (c)) > 0.8;
521 if (top_half || bottom_half) {
526 ctx->drag_status (ctx->get_suggested_action (), tme);
535 void drag_leave (Glib::RefPtr<Gdk::DragContext>
const &, guint)
559 bool selecting =
false;
561 for (
typename std::list<T*>::const_iterator i =
_children.begin(); i !=
_children.end(); ++i) {
563 bool const was_selected =
selected (*i);
565 if (selecting && !was_selected) {
569 if (!selecting && !done) {
572 }
else if (*i == child) {
576 }
else if (selecting) {
577 if (was_selected || *i == child) {
637 for (
typename std::list<T*>::iterator i = old_selection.begin(); i != old_selection.end(); ++i) {
644 if (!child->is_selectable()) {
664 typename std::list<T*>::const_iterator i =
_children.begin();
665 while (i !=
_children.end() && &(*i)->widget() != w) {
void pack_start(Widget &child, bool expand, bool fill, guint padding=0)
void set_spacing(int spacing)
void reorder_child(Widget &child, int pos)
void remove(Widget &widget)
Glib::ListHandle< Widget * > get_children()
(internal) Operate on contained items (see foreach())
virtual void add(Widget &widget)
const guchar * get_data() const
std::string get_target() const
void set(int format, const guint8 *data, int length)
Glib::RefPtr< Gdk::Screen > get_screen()
void get_size(int &width, int &height) const
virtual bool drag_data_get(Glib::RefPtr< Gdk::DragContext > const, Gtk::SelectionData &)
virtual Gtk::Widget & widget()=0
virtual Gtk::EventBox & action_widget()=0
virtual void set_visual_state(VisualState, bool onoff)=0
virtual bool can_copy_state(DnDVBoxChild *) const =0
virtual std::string drag_text() const =0
virtual bool is_selectable() const =0
sigc::signal< void, DnDVBox *, T *, Glib::RefPtr< Gdk::DragContext > const & > DropFromAnotherBox
std::list< Gtk::TargetEntry > _targets
sigc::signal< void > SelectionChanged
std::list< T * > children()
void add_child(T *child, std::list< Gtk::TargetEntry > targets=std::list< Gtk::TargetEntry >())
static DnDVBox * _drag_source
bool icon_expose(GdkEventExpose *)
sigc::signal< void, T & > SelectionAdded
sigc::signal< void > Reordered
double bottom_of_child_ignoring_placeholder(T *child) const
bool _expecting_unwanted_button_event
sigc::signal< bool, GdkEventButton *, T * > ButtonPress
void remove_placeholder()
std::list< T * > _selection
bool selected(T *child) const
bool button_release(GdkEventButton *ev, T *child)
void add_to_selection(T *child)
sigc::signal< bool, GdkEventButton *, T * > ButtonRelease
std::pair< T *, double > get_child_at_position(int y) const
void setup_child_state(T *c)
int add_placeholder(double y)
std::list< T * > _children
double get_children_around_position(int y, T **before, T **at, T **after) const
bool button_press(GdkEventButton *ev, T *child)
void drag_begin(Glib::RefPtr< Gdk::DragContext > const &context, T *child)
void drag_data_received(Glib::RefPtr< Gdk::DragContext > const &context, int, int y, Gtk::SelectionData const &selection_data, guint, guint time)
T * child_from_widget(Gtk::Widget const *w) const
void drag_leave(Glib::RefPtr< Gdk::DragContext > const &, guint)
void drag_data_get(Glib::RefPtr< Gdk::DragContext > const &context, Gtk::SelectionData &selection_data, guint, guint, T *child)
int create_or_update_placeholder(double c)
void remove_from_selection(T *child)
void drag_end(Glib::RefPtr< Gdk::DragContext > const &, T *)
std::list< T * > selection(bool sorted=false) const
bool drag_motion(Glib::RefPtr< Gdk::DragContext > const &ctx, int, int y, guint tme)
DnDVBox(std::list< Gtk::TargetEntry > targets, Gdk::DragAction actions=Gdk::ACTION_COPY)
sigc::signal< void, Gtk::SelectionData const &, T *, Glib::RefPtr< Gdk::DragContext > const & > DropFromExternal
Gtk::Label * _placeholder
sigc::signal< bool, DnDVBox *, T * > DragRefuse
static const uint32_t PrimaryModifier
G_BEGIN_DECLS cairo_t * gdk_cairo_create(GdkDrawable *drawable)
void gdk_cairo_set_source_pixmap(cairo_t *cr, GdkPixmap *pixmap, double pixmap_x, double pixmap_y)