00001 #ifndef VISIBLE_LINE_IMPLEMENTATION_FILE
00002 #define VISIBLE_LINE_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "visible_line.h"
00019 #include "wp_implementation.h"
00020
00021 visible_line::visible_line(canvas &draw_on, const c_line &init,
00022 const color &f, bool attach)
00023 : paintable(draw_on, init.endpoint_1(), f, attach),
00024 c_line(init)
00025 {}
00026
00027 c_line visible_line::base() const { return *this; }
00028
00029 c_rectangle visible_line::dimensions() const
00030 { return c_rectangle(endpoint_1(), endpoint_2()); }
00031
00032 void visible_line::base(const c_line &new_base)
00033 {
00034 (c_line &)*this = new_base;
00035 drawable::set_origin(new_base.endpoint_1());
00036 }
00037
00038 void visible_line::plot(const color &plot_in)
00039 {
00040 #ifdef __XWINDOWS__
00041 color to_plot_in = plot_in;
00042 if (to_plot_in.index() < 0) target().colormap().add(to_plot_in);
00043 XSetForeground(target().display(), target().details()._gc,
00044 to_plot_in.index());
00045 c_point dev_e1 = target().world_to_device(endpoint_1());
00046 c_point dev_e2 = target().world_to_device(endpoint_2());
00047 XDrawLine(target().display(), target().window(), target().details()._gc,
00048 int(dev_e1.x()), int(dev_e1.y()), int(dev_e2.x()), int(dev_e2.y()));
00049 #elif defined(MS_WINDOWS)
00050 #elif defined(OS_2)
00051 #endif
00052 }
00053
00054 void visible_line::set_origin(const c_point &new_origin)
00055 {
00056 bool was_visible(visible());
00057 if (was_visible) erase();
00058
00059 c_line new_dim(*this);
00060 new_dim += new_origin - drawable::origin();
00061 (c_line &)*this = new_dim;
00062
00063 drawable::set_origin(new_origin);
00064
00065 if (was_visible) draw();
00066 }
00067
00068
00069 #endif //VISIBLE_LINE_IMPLEMENTATION_FILE
00070