1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : AW_size.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #include "aw_common.hxx" |
---|
12 | |
---|
13 | inline int calc_overlap(AW_pos smaller, AW_pos bigger) { |
---|
14 | if (smaller<bigger) return AW_INT(bigger-smaller); |
---|
15 | return 0; |
---|
16 | } |
---|
17 | |
---|
18 | |
---|
19 | void AW_device_size::restart_tracking() { |
---|
20 | scaled.restart(); |
---|
21 | unscaled.restart(); |
---|
22 | } |
---|
23 | |
---|
24 | AW_borders AW_device_size::get_unscaleable_overlap() const { |
---|
25 | AW_borders unscalable_overlap; |
---|
26 | if (scaled.was_drawn() && unscaled.was_drawn()) { |
---|
27 | const AW_world& scaled_size = scaled.get_size(); |
---|
28 | const AW_world& unscaled_size = unscaled.get_size(); |
---|
29 | |
---|
30 | unscalable_overlap.t = calc_overlap(unscaled_size.t, scaled_size.t); |
---|
31 | unscalable_overlap.l = calc_overlap(unscaled_size.l, scaled_size.l); |
---|
32 | unscalable_overlap.b = calc_overlap(scaled_size.b, unscaled_size.b); |
---|
33 | unscalable_overlap.r = calc_overlap(scaled_size.r, unscaled_size.r); |
---|
34 | } |
---|
35 | else { |
---|
36 | unscalable_overlap.clear(); |
---|
37 | } |
---|
38 | return unscalable_overlap; |
---|
39 | } |
---|
40 | |
---|
41 | AW_DEVICE_TYPE AW_device_size::type() { |
---|
42 | return AW_DEVICE_SIZE; |
---|
43 | } |
---|
44 | |
---|
45 | bool AW_device_size::line_impl(int /*gc*/, const AW::LineVector& Line, AW_bitset filteri) { |
---|
46 | if (!(filteri & filter)) return false; |
---|
47 | dot(Line.start(), filteri); |
---|
48 | dot(Line.head(), filteri); |
---|
49 | return true; |
---|
50 | } |
---|
51 | |
---|
52 | bool AW_device_size::text_impl(int gc, const SizedCstr& cstr, const AW::Position& pos, AW_pos alignment, AW_bitset filteri) { |
---|
53 | if (!(filteri & filter)) return false; |
---|
54 | |
---|
55 | AW::Position transPos = transform(pos); |
---|
56 | const AW_font_limits& font = get_common()->map_gc(gc)->get_font_limits(); |
---|
57 | |
---|
58 | AW_pos l_ascent = font.ascent; |
---|
59 | AW_pos l_descent = font.descent; |
---|
60 | AW_pos l_width = get_string_size(gc, cstr); |
---|
61 | |
---|
62 | AW::Position upperLeft(AW::x_alignment(transPos.xpos(), l_width, alignment), |
---|
63 | transPos.ypos()-l_ascent); |
---|
64 | |
---|
65 | dot_transformed(upperLeft, filteri); |
---|
66 | dot_transformed(upperLeft + AW::Vector(l_width, l_ascent+l_descent), filteri); |
---|
67 | |
---|
68 | return true; |
---|
69 | } |
---|
70 | |
---|
71 | bool AW_device_size::invisible_impl(const AW::Position& pos, AW_bitset filteri) { |
---|
72 | if (!(filteri & filter)) return false; |
---|
73 | dot(pos, filteri); |
---|
74 | return true; |
---|
75 | } |
---|
76 | |
---|
77 | inline void AW_device_size::dot_transformed(const AW::Position& pos, AW_bitset filteri) { |
---|
78 | if (filter == (AW_PRINTER|AW_PRINTER_EXT)) { // detect graphic size for print-scaling |
---|
79 | scaled.track(pos); |
---|
80 | } |
---|
81 | else { |
---|
82 | if (filteri&AW_SIZE) { |
---|
83 | aw_assert((filteri&AW_SIZE_UNSCALED) == 0); |
---|
84 | scaled.track(pos); |
---|
85 | } |
---|
86 | else { |
---|
87 | aw_assert((filteri&AW_SIZE) == 0); |
---|
88 | unscaled.track(pos); |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | void AW_device_size::specific_reset() { |
---|
94 | restart_tracking(); |
---|
95 | } |
---|