box.cpp

Go to the documentation of this file.
00001 #ifndef BOX_IMPLEMENTATION_FILE
00002 #define BOX_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : box                                                               *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1991-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "box.h"
00019 #include "wp_implementation.h"
00020 
00021 box::box(canvas &draw_on, const c_rectangle &dims, const color &foreground,
00022     bool attach)
00023 : c_rectangle(dims),
00024   paintable(draw_on, dims.vertex_1(), foreground, attach) {}
00025 
00026 c_rectangle box::dimensions() const { return *this; }
00027 
00028 c_rectangle box::base() const { return *this; }
00029 
00030 void box::base(const c_rectangle &to_set) { (c_rectangle &)*this = to_set; }
00031 
00032 void box::set_origin(const c_point &new_origin)
00033 {
00034   bool was_visible(visible());
00035   if (was_visible) erase();
00036 
00037   c_rectangle new_dim(*this - drawable::origin() + new_origin);
00038   (c_rectangle &)*this = new_dim;
00039 
00040   drawable::set_origin(new_origin);
00041 
00042   if (was_visible) draw();
00043 }
00044 
00045 void box::plot(const color &plot_in)
00046 {
00047   color to_plot_in = plot_in;
00048   if (to_plot_in.index() < 0) target().colormap().add(to_plot_in);
00049   c_rectangle in_dev(target().world_to_device(*this));
00050 #ifdef __XWINDOWS__
00051   XSetForeground(target().display(), target().details()._gc,
00052       to_plot_in.index());
00053   if (filled()) XFillRectangle
00054     (target().display(), target().window(), target().details()._gc,
00055      int(in_dev.vertex_1().x()), int(in_dev.vertex_1().y()),
00056      int(in_dev.width()), int(in_dev.height()));
00057   else XDrawRectangle
00058     (target().display(), target().window(), target().details()._gc,
00059      int(in_dev.vertex_1().x()), int(in_dev.vertex_1().y()),
00060      int(in_dev.width()), int(in_dev.height()));
00061 #elif defined(MS_WINDOWS)
00062 #elif defined(OS_2)
00063 #endif
00064 }
00065 
00066 
00067 #endif //BOX_IMPLEMENTATION_FILE
00068 

Generated on Fri Nov 28 04:29:04 2008 for HOOPLE Libraries by  doxygen 1.5.1