1 #include "bcdragwindow.h"
7 BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window,
11 : BC_Popup(parent_window,
24 icon_offset_x = init_x - parent_window->get_abs_cursor_x(0);
25 icon_offset_y = init_y - parent_window->get_abs_cursor_y(0);
26 //printf("BC_DragWindow::BC_DragWindow 1 %d %d\n", icon_offset_x, icon_offset_y);
31 BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window,
35 : BC_Popup(parent_window,
42 prepare_frame(frame, parent_window))
44 delete temp_frame; // created in prepare_frame inside constructor
49 icon_offset_x = init_x - parent_window->get_abs_cursor_x(0);
50 icon_offset_y = init_y - parent_window->get_abs_cursor_y(0);
51 //printf("BC_DragWindow::BC_DragWindow 1 %d %d\n", icon_offset_x, icon_offset_y);
55 BC_DragWindow::~BC_DragWindow()
59 int BC_DragWindow::get_init_x(BC_WindowBase *parent_window, int icon_x)
61 int output_x, temp = 0;
63 XTranslateCoordinates(parent_window->top_level->display,
65 parent_window->top_level->rootwin,
74 int BC_DragWindow::get_init_y(BC_WindowBase *parent_window, int icon_y)
76 int output_y, temp = 0;
78 XTranslateCoordinates(parent_window->top_level->display,
80 parent_window->top_level->rootwin,
89 int BC_DragWindow::cursor_motion_event()
91 reposition_window(get_abs_cursor_x(0) + icon_offset_x,
92 get_abs_cursor_y(0) + icon_offset_y,
99 int BC_DragWindow::get_offset_x()
101 return icon_offset_x;
104 int BC_DragWindow::get_offset_y()
106 return icon_offset_y;
109 int BC_DragWindow::drag_failure_event()
111 if(!do_animation) return 0;
113 if(end_x == BC_INFINITY)
119 for(int i = 0; i < 10; i++)
121 int new_x = end_x + (init_x - end_x) * i / 10;
122 int new_y = end_y + (init_y - end_y) * i / 10;
124 reposition_window(new_x,
134 void BC_DragWindow::set_animation(int value)
136 this->do_animation = value;
139 BC_Pixmap *BC_DragWindow::prepare_frame(VFrame *frame, BC_WindowBase *parent_window)
143 if(frame->get_color_model() == BC_RGBA8888)
145 temp_frame = new VFrame(*frame);
149 temp_frame = new VFrame(0,
154 cmodel_transfer(temp_frame->get_rows(),
170 frame->get_color_model(),
171 temp_frame->get_color_model(),
174 temp_frame->get_w());
176 temp_frame->get_rows()[(temp_frame->get_h() / 2)][(temp_frame->get_w() / 2) * 4 + 3] = 0;
177 my_pixmap = new BC_Pixmap(parent_window,