101 void add_child (T* child, std::list<Gtk::TargetEntry> targets = std::list<Gtk::TargetEntry>())
103 if (targets.empty ()) {
108 child->action_widget().signal_drag_begin().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_begin), child));
109 child->action_widget().signal_drag_data_get().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_data_get), child));
110 child->action_widget().signal_drag_end().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::drag_end), child));
111 child->action_widget().signal_button_press_event().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::button_press), child));
112 child->action_widget().signal_button_release_event().connect (sigc::bind (mem_fun (*
this, &
DnDVBox::button_release), child));
117 child->widget().show ();
123 std::list<T*> sorted_children;
126 for (std::list<Gtk::Widget*>::iterator i = widget_children.begin(); i != widget_children.end(); ++i) {
130 sorted_children.push_back (c);
134 return sorted_children;
144 for (
typename std::list<T*>::const_iterator i =
_children.begin(); i !=
_children.end(); ++i) {
180 for (
typename std::list<T*>::iterator i =
_children.begin(); i !=
_children.end(); ++i) {
192 for (
typename std::list<T*>::iterator i =
_children.begin(); i !=
_children.end(); ++i) {
214 std::pair<T*, double> r;
255 sigc::signal<void, Gtk::SelectionData const &, T*, Glib::RefPtr<Gdk::DragContext>
const & >
DropFromExternal;
291 *before = *at = *after = 0;
297 typename std::list<T*>::const_iterator j =
_children.begin ();
306 while (y >= bottom && j !=
_children.end()) {
330 return i + ((y - top) / (bottom - top));
333 void drag_begin (Glib::RefPtr<Gdk::DragContext>
const & context, T* child)
348 Glib::RefPtr<Gdk::Colormap const> c = s->get_rgba_colormap ();
370 Glib::RefPtr<Gdk::Pixmap> p =
_drag_child->action_widget().get_snapshot();
372 cairo_rectangle (cr, 0, 0, w, h);
381 if (!child->drag_data_get(context, selection_data)) {
382 selection_data.
set (selection_data.
get_target(), 8, (
const guchar *) &child, sizeof (&child));
387 Glib::RefPtr<Gdk::DragContext>
const & context,
int ,
int y,
Gtk::SelectionData const & selection_data, guint , guint time
395 context->drag_finish (
false,
false, time);
403 T* child = *((T *
const *) selection_data.
get_data());
405 if (drop.first == 0) {
410 int target = drop.second + 0.5;
414 typename std::list<T*>::const_iterator i =
_children.begin ();
415 while (i !=
_children.end() && *i != child && n < target) {
434 context->drag_finish (
false,
false, time);
437 void drag_end (Glib::RefPtr<Gdk::DragContext>
const &, T *)
462 int const n = c < 0 ? -1 : int (c + 0.5);
467 bool drag_motion (Glib::RefPtr<Gdk::DragContext>
const & ctx,
int ,
int y, guint tme)
481 bool top_half = (c - int (c)) < .5;
482 bool bottom_half = !top_half;
486 ctx->drag_refuse (tme);
498 top_half = (c - int (c)) < 0.33;
499 bottom_half = (c - int (c)) > 0.8;
520 if (top_half || bottom_half) {
525 ctx->drag_status (ctx->get_suggested_action (), tme);
534 void drag_leave (Glib::RefPtr<Gdk::DragContext>
const &, guint)
558 bool selecting =
false;
560 for (
typename std::list<T*>::const_iterator i =
_children.begin(); i !=
_children.end(); ++i) {
562 bool const was_selected =
selected (*i);
564 if (selecting && !was_selected) {
568 if (!selecting && !done) {
571 }
else if (*i == child) {
575 }
else if (selecting) {
576 if (was_selected || *i == child) {
636 for (
typename std::list<T*>::iterator i = old_selection.begin(); i != old_selection.end(); ++i) {
643 if (!child->is_selectable()) {
663 typename std::list<T*>::const_iterator i =
_children.begin();
664 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
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)