ARB
AW_device_size.cxx
Go to the documentation of this file.
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 
20  scaled.restart();
21  unscaled.restart();
22 }
23 
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 
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() {
95 }
AW::Vector transform(const AW::Vector &vec) const
Definition: aw_device.hxx:144
long AW_bitset
Definition: aw_base.hxx:44
const AW_bitset AW_SIZE
Definition: aw_device.hxx:37
const AW_bitset AW_PRINTER_EXT
Definition: aw_device.hxx:40
void track(const AW::Position &pos)
Definition: aw_device.hxx:613
const AW_world & get_size() const
Definition: aw_device.hxx:626
const AW_bitset AW_PRINTER
Definition: aw_device.hxx:39
const Position & start() const
double AW_pos
Definition: aw_base.hxx:29
int calc_overlap(AW_pos smaller, AW_pos bigger)
int get_string_size(int gc, long textlen) const
Definition: AW_device.cxx:443
AW_pos l
Definition: aw_base.hxx:32
const double & ypos() const
#define aw_assert(bed)
Definition: aw_position.hxx:29
AW_DEVICE_TYPE type()
const AW_GC * map_gc(int gc) const
Definition: aw_common.hxx:267
AW_common * get_common() const
Definition: aw_device.hxx:296
bool was_drawn() const
Definition: aw_device.hxx:625
AW_pos r
Definition: aw_base.hxx:32
AW_borders get_unscaleable_overlap() const
AW_bitset filter
Definition: aw_device.hxx:366
AW_pos b
Definition: aw_base.hxx:32
AW_pos t
Definition: aw_base.hxx:32
const AW_bitset AW_SIZE_UNSCALED
Definition: aw_device.hxx:38
Position head() const
const double & xpos() const
const char * cstr
Definition: defines.h:21
AW_DEVICE_TYPE
Definition: aw_device.hxx:48
const AW_font_limits & get_font_limits() const
Definition: aw_common.hxx:133
AW_pos x_alignment(AW_pos x_pos, AW_pos x_size, AW_pos alignment)
void clear()
Definition: aw_base.hxx:37