blob: 5caf966556571939549003c32c11675f3fe95abf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
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);
}
}
}
|