00001 #include "cursor.h"
00002
00003 Cursor_::Cursor_(BC_SubWindow *canvas)
00004 {
00005 this->canvas = canvas;
00006 selectionstart = selectionend = zoom_sample = viewstart = 0;
00007 }
00008
00009 Cursor_::~Cursor_()
00010 {
00011 }
00012
00013 int Cursor_::show(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
00014 {
00015 return 0;
00016 this->selectionstart = selectionstart;
00017 this->selectionend = selectionend;
00018 this->viewstart = viewstart;
00019 this->zoom_sample = zoom_sample;
00020 this->vertical = vertical;
00021 draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
00022 }
00023
00024 int Cursor_::hide(int flash)
00025 {
00026 return 0;
00027 draw(flash, selectionstart, selectionend, zoom_sample, viewstart, vertical);
00028 }
00029
00030 int Cursor_::draw(int flash, long selectionstart, long selectionend, long zoom_sample, long viewstart, int vertical)
00031 {
00032 return 0;
00033 if(canvas->get_h() * canvas->get_w() == 0) return 1;
00034 if(zoom_sample == 0) return 1;
00035
00036 long start = viewstart;
00037 long end = start + (long)(vertical ? canvas->get_h() : canvas->get_w()) * zoom_sample;
00038 int pixel1, pixel2;
00039
00040 if((selectionstart >= start && selectionstart <= end) ||
00041 (selectionend >= start && selectionend <= end) ||
00042 (start >= selectionstart && end <= selectionend))
00043 {
00044 if(selectionstart < start)
00045 {
00046 pixel1 = 0;
00047 }
00048 else
00049 {
00050 pixel1 = (selectionstart - start) / zoom_sample;
00051 }
00052
00053 if(selectionend > end)
00054 {
00055 pixel2 = (vertical ? canvas->get_h() : canvas->get_w());
00056 }
00057 else
00058 {
00059 pixel2 = (selectionend - start) / zoom_sample;
00060 }
00061 pixel2++;
00062
00063 canvas->set_inverse();
00064 canvas->set_color(WHITE);
00065
00066 if(vertical)
00067 canvas->draw_box(0, pixel1, canvas->get_w(), pixel2 - pixel1);
00068 else
00069 canvas->draw_box(pixel1, 0, pixel2 - pixel1, canvas->get_h());
00070
00071
00072 canvas->set_opaque();
00073 }
00074 if(flash) canvas->flash();
00075 }
00076
00077 int Cursor_::resize(int w, int h)
00078 {
00079 }