Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

bcdragwindow.C

Go to the documentation of this file.
00001 #include "bcdragwindow.h"
00002 #include "bcpixmap.h"
00003 
00004 #include "vframe.h"
00005 #include <unistd.h>
00006 
00007 BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window, 
00008         BC_Pixmap *pixmap, 
00009         int icon_x, 
00010         int icon_y)
00011  : BC_Popup(parent_window, 
00012         icon_x, 
00013         icon_y,
00014         pixmap->get_w(),
00015         pixmap->get_h(),
00016         -1,
00017         0,
00018         pixmap)
00019 {
00020         init_x = icon_x;
00021         init_y = icon_y;
00022         end_x = BC_INFINITY;
00023         end_y = BC_INFINITY;
00024         icon_offset_x = init_x - parent_window->get_abs_cursor_x(0);
00025         icon_offset_y = init_y - parent_window->get_abs_cursor_y(0);
00026 //printf("BC_DragWindow::BC_DragWindow 1 %d %d\n", icon_offset_x, icon_offset_y);
00027         do_animation = 1;
00028 }
00029 
00030 
00031 BC_DragWindow::BC_DragWindow(BC_WindowBase *parent_window, 
00032         VFrame *frame, 
00033         int icon_x, 
00034         int icon_y)
00035  : BC_Popup(parent_window, 
00036         icon_x, 
00037         icon_y,
00038         frame->get_w(),
00039         frame->get_h(),
00040         -1,
00041         0,
00042         prepare_frame(frame, parent_window))
00043 {
00044         delete temp_frame;  // created in prepare_frame inside constructor
00045         init_x = icon_x;
00046         init_y = icon_y;
00047         end_x = BC_INFINITY;
00048         end_y = BC_INFINITY;
00049         icon_offset_x = init_x - parent_window->get_abs_cursor_x(0);
00050         icon_offset_y = init_y - parent_window->get_abs_cursor_y(0);
00051 //printf("BC_DragWindow::BC_DragWindow 1 %d %d\n", icon_offset_x, icon_offset_y);
00052         do_animation = 1;
00053 }
00054 
00055 BC_DragWindow::~BC_DragWindow()
00056 {
00057 }
00058 
00059 int BC_DragWindow::get_init_x(BC_WindowBase *parent_window, int icon_x)
00060 {
00061         int output_x, temp = 0;
00062         Window tempwin;
00063         XTranslateCoordinates(parent_window->top_level->display, 
00064                 parent_window->win, 
00065                 parent_window->top_level->rootwin, 
00066                 icon_x, 
00067                 temp, 
00068                 &output_x, 
00069                 &temp, 
00070                 &tempwin);
00071         return output_x;
00072 }
00073 
00074 int BC_DragWindow::get_init_y(BC_WindowBase *parent_window, int icon_y)
00075 {
00076         int output_y, temp = 0;
00077         Window tempwin;
00078         XTranslateCoordinates(parent_window->top_level->display, 
00079                 parent_window->win, 
00080                 parent_window->top_level->rootwin, 
00081                 temp, 
00082                 icon_y, 
00083                 &temp, 
00084                 &output_y, 
00085                 &tempwin);
00086         return output_y;
00087 }
00088 
00089 int BC_DragWindow::cursor_motion_event()
00090 {
00091         reposition_window(get_abs_cursor_x(0) + icon_offset_x, 
00092                 get_abs_cursor_y(0) + icon_offset_y, 
00093                 get_w(), 
00094                 get_h());
00095         flush();
00096         return 1;
00097 }
00098 
00099 int BC_DragWindow::get_offset_x()
00100 {
00101         return icon_offset_x;
00102 }
00103 
00104 int BC_DragWindow::get_offset_y()
00105 {
00106         return icon_offset_y;
00107 }
00108 
00109 int BC_DragWindow::drag_failure_event()
00110 {
00111         if(!do_animation) return 0;
00112 
00113         if(end_x == BC_INFINITY)
00114         {
00115                 end_x = get_x();
00116                 end_y = get_y();
00117         }
00118 
00119         for(int i = 0; i < 10; i++)
00120         {
00121                 int new_x = end_x + (init_x - end_x) * i / 10;
00122                 int new_y = end_y + (init_y - end_y) * i / 10;
00123 
00124                 reposition_window(new_x, 
00125                         new_y, 
00126                         get_w(), 
00127                         get_h());
00128                 flush();
00129                 usleep(1000);
00130         }
00131         return 0;
00132 }
00133 
00134 void BC_DragWindow::set_animation(int value)
00135 {
00136         this->do_animation = value;
00137 }
00138 
00139 BC_Pixmap *BC_DragWindow::prepare_frame(VFrame *frame, BC_WindowBase *parent_window)
00140 {
00141         temp_frame = 0;
00142         
00143         if(frame->get_color_model() == BC_RGBA8888)
00144         {
00145                 temp_frame = new VFrame(*frame);
00146         }
00147         else
00148         {
00149                 temp_frame = new VFrame(0, 
00150                                         frame->get_w(), 
00151                                         frame->get_h(), 
00152                                         BC_RGBA8888); 
00153 
00154                 cmodel_transfer(temp_frame->get_rows(), 
00155                         frame->get_rows(),
00156                         0,
00157                         0,
00158                         0,
00159                         0,
00160                         0,
00161                         0,
00162                         0, 
00163                         0, 
00164                         frame->get_w(), 
00165                         frame->get_h(),
00166                         0, 
00167                         0, 
00168                         temp_frame->get_w(), 
00169                         temp_frame->get_h(),
00170                         frame->get_color_model(), 
00171                         temp_frame->get_color_model(),
00172                         0,
00173                         frame->get_w(),
00174                         temp_frame->get_w());
00175         }
00176         temp_frame->get_rows()[(temp_frame->get_h() / 2)][(temp_frame->get_w() / 2) * 4 + 3] = 0;
00177         my_pixmap = new BC_Pixmap(parent_window,
00178                         temp_frame,
00179                         PIXMAP_ALPHA);
00180 
00181         return (my_pixmap);
00182 }
00183 
00184 

Generated on Sun Jan 8 13:26:32 2006 for Guicast-svn by  doxygen 1.4.4