/* ui/bitmap.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #include "auxiliary/functions.h" #include "ui/bitmap.h" #include "ui/paint.h" #include "sys/sys.h" namespace ui { Bitmap::Bitmap(Widget *parent, const char *texture) : Widget(parent) { set_border(false); set_background(true); set_preserve_aspect(false); set_label("bitmap"); set_texture(texture); } Bitmap::~Bitmap() {} void Bitmap::print(const size_t indent) const { std::string marker(""); con_print << aux::pad_left(marker, indent*2) << label() << " \"" << texture() << "\"" << std::endl; } void Bitmap::set_texture(const std::string & texture) { bitmap_texture.assign(texture); } void Bitmap::set_texture(const char *texture) { if (texture) bitmap_texture.assign(texture); else bitmap_texture.clear(); } void Bitmap::set_color(const math::Color & color) { bitmap_color.assign(color); } void Bitmap::set_preserve_aspect(const bool preserve_aspect) { bitmap_preserve_aspect = preserve_aspect; } void Bitmap::draw_background() { if (bitmap_texture.size()) { Paint::draw_bitmap(global_location(), size(), bitmap_color, bitmap_texture, bitmap_preserve_aspect); } else { Paint::set_color(bitmap_color); Paint::draw_rectangle(global_location(), size()); Paint::set_color(palette()->foreground()); } } }