ARB
aw_device.hxx
Go to the documentation of this file.
1 #ifndef AW_DEVICE_HXX
2 #define AW_DEVICE_HXX
3 
4 #ifndef SIZED_CSTR_H
5 #include <sized_cstr.h>
6 #endif
7 #ifndef AW_POSITION_HXX
8 #include <aw_position.hxx>
9 #endif
10 #ifndef AW_FONT_LIMITS_HXX
11 #include <aw_font_limits.hxx>
12 #endif
13 #ifndef ATTRIBUTES_H
14 #include <attributes.h>
15 #endif
16 #ifndef ARBTOOLS_H
17 #include <arbtools.h>
18 #endif
19 
20 #if defined(DEBUG) && defined(DEBUG_GRAPHICS)
21 // if you want flush() to be called after every motif command :
22 #define AUTO_FLUSH(device) (device)->flush()
23 #else
24 #define AUTO_FLUSH(device)
25 #endif
26 
27 #define AW_INT(x) ((int)(((x)>=0.0) ? ((float)(x)+.5) : ((float)(x)-.5)))
28 
29 // #define AW_PIXELS_PER_MM 1.0001 // stupid and wrong
30 
31 #define DPI_SCREEN 80 // fixed
32 #define DPI_PRINTER 1200 // default resolution of xfig 3.2
33 
34 const AW_bitset AW_SCREEN = 1;
35 const AW_bitset AW_CLICK = 2;
37 const AW_bitset AW_SIZE = 8;
38 const AW_bitset AW_SIZE_UNSCALED = 16; // for text and text-size dependant parts
39 const AW_bitset AW_PRINTER = 32; // print/xfig-export
40 const AW_bitset AW_PRINTER_EXT = 64; // (+Handles) use combined with AW_PRINTER only
41 const AW_bitset AW_PRINTER_CLIP = 128; // print screen only
42 const AW_bitset AW_TRACK = 256; // species tracking
43 
44 const AW_bitset AW_ALL_DEVICES = (AW_bitset)-1; // @@@ allowed to used this ?
47 
53 };
54 
55 enum {
56  AW_FIXED = -1,
57  AW_TIMES = 0,
61 
62  AW_COURIER = 12,
66 
75 
88 
90  AW_NUM_FONTS_XFIG = 35, // immutable
91 
95 };
96 
100 };
101 
102 // --------------------------------------------------
103 // general note on world- vs. pixel-positions:(WORLD_vs_PIXEL)
104 //
105 // A position is interpreted as the center of the corresponding pixel
106 // (pixel refers to screen; printer pixel are 15 times smaller!)
107 //
108 // Hence, when scaling factor is 1.0, then
109 // - any position inside [-0.5, 0.5[ will fall into the pixel 0, any inside [0.5, 1.5[ into pixel 1.
110 // - a line from 0.0 to 2.0 will paint THREE pixels (0, 1 and 2). A line from -0.5 to 2.499 will to the same
111 // - clipping to area [0, 100] should in fact clip to [-0.5, 100.5[ (@@@ check this)
112 
113 class AW_zoomable {
114  AW::Vector offset;
115  AW_pos scale;
116  AW_pos unscale; // = 1.0/scale
117 
118 public:
119  AW_zoomable() { this->reset(); };
120  virtual ~AW_zoomable() {}
121 
122  void zoom(AW_pos scale);
123 
124  AW_pos get_scale() const { return scale; };
125  AW_pos get_unscale() const { return unscale; };
126  AW::Vector get_offset() const { return offset; }
127 
128  void rotate(AW_pos angle);
129 
130  void set_offset(const AW::Vector& off) { offset = off*scale; }
131  void shift(const AW::Vector& doff) { offset += doff*scale; }
132 
133  void reset();
134 
135  double transform_size(const double& size) const { return size*scale; }
136  double rtransform_size(const double& size) const { return size*unscale; }
137 
138  double rtransform_pixelsize(int pixelsize) const {
139  // return world-size needed to draw line/box with length/size == 'pixelsize'
140  return (pixelsize-1)*unscale;
141  }
142 
143  // transforming a Vector only scales the vector (a Vector has no position!)
144  AW::Vector transform (const AW::Vector& vec) const { return vec*scale; }
145  AW::Vector rtransform(const AW::Vector& vec) const { return vec*unscale; }
146 
147  // transform a Position
148  AW::Position transform (const AW::Position& pos) const { return transform(AW::Vector(pos+offset)).endpoint(); }
149  AW::Position rtransform(const AW::Position& pos) const { return rtransform(AW::Vector(pos)).endpoint()-offset; }
150 #if defined(WARN_TODO) && 0
151 #warning fix transformations
152  // @@@ I think this calculation is wrong, cause offset is already scaled
153  // (same applies to old-style transform/rtransform below)
154 #endif
155 
156  AW::LineVector transform (const AW::LineVector& lvec) const { return AW::LineVector(transform(lvec.start()), transform(lvec.line_vector())); }
158 
159  AW::Rectangle transform (const AW::Rectangle& rect) const { return AW::Rectangle(transform(static_cast<const AW::LineVector&>(rect))); }
160  AW::Rectangle rtransform(const AW::Rectangle& rect) const { return AW::Rectangle(rtransform(static_cast<const AW::LineVector&>(rect))); }
161 
162  // old style functions, not preferred:
163  void transform(AW_pos x, AW_pos y, AW_pos& xout, AW_pos& yout) const {
164  xout = (x+offset.x())*scale;
165  yout = (y+offset.y())*scale;
166  }
167  void rtransform(AW_pos x, AW_pos y, AW_pos& xout, AW_pos& yout) const {
168  xout = x*unscale - offset.x();
169  yout = y*unscale - offset.y();
170  }
171 };
172 
173 struct AW_font_overlap { bool top, bottom, left, right; };
174 
175 class AW_clipable {
176  const AW_screen_area& common_screen;
177  const AW_screen_area& get_screen() const { return common_screen; }
178 
179  AW_screen_area clip_rect; // holds the clipping rectangle coordinates
180  AW_font_overlap font_overlap;
181 
182  void set_cliprect_oversize(const AW_screen_area& rect, bool allow_oversize);
183 
184  bool need_extra_clip_position(const AW::Position& p1, const AW::Position& p2, AW::Position& extra);
185 
186 protected:
187  int compoutcode(AW_pos xx, AW_pos yy) const {
188  // calculate outcode for clipping the current line
189  // order - top,bottom,right,left
190  int code = 0;
191  if (clip_rect.b - yy < 0) code = 4;
192  else if (yy - clip_rect.t < 0) code = 8;
193  if (clip_rect.r - xx < 0) code |= 2;
194  else if (xx - clip_rect.l < 0) code |= 1;
195  return code;
196  };
197 
198  void set_cliprect(const AW_screen_area& rect) { clip_rect = rect; }
199 
200 public:
201 
203  : common_screen(screen)
204  {
205  clip_rect.clear();
206  set_font_overlap(false);
207  }
208  virtual ~AW_clipable() {}
209 
210  bool is_below_clip(double ypos) const { return ypos > clip_rect.b; }
211  bool is_above_clip(double ypos) const { return ypos < clip_rect.t; }
212  bool is_leftof_clip(double xpos) const { return xpos < clip_rect.l; }
213  bool is_rightof_clip(double xpos) const { return xpos > clip_rect.r; }
214 
215  bool is_outside_clip(AW::Position pos) const {
216  return
217  is_below_clip(pos.ypos()) || is_above_clip(pos.ypos()) ||
218  is_leftof_clip(pos.xpos()) || is_rightof_clip(pos.xpos());
219  }
220  bool is_outside_clip(AW::Rectangle rect) const {
222  }
223 
224  bool clip(AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_pos& x0out, AW_pos& y0out, AW_pos& x1out, AW_pos& y1out);
225  bool clip(const AW::LineVector& line, AW::LineVector& clippedLine);
226 
227  bool box_clip(AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_pos& x0out, AW_pos& y0out, AW_pos& x1out, AW_pos& y1out);
228  bool box_clip(const AW::Rectangle& rect, AW::Rectangle& clippedRect);
229  bool box_clip(int npos, const AW::Position *pos, int& nclippedPos, AW::Position*& clippedPos);
230  bool force_into_clipbox(const AW::Position& pos, AW::Position& forcedPos);
231 
232  void set_top_clip_border(int top, bool allow_oversize = false);
233  void set_bottom_clip_border(int bottom, bool allow_oversize = false); // absolute
234  void set_bottom_clip_margin(int bottom, bool allow_oversize = false); // relative
235  void set_left_clip_border(int left, bool allow_oversize = false);
236  void set_right_clip_border(int right, bool allow_oversize = false);
237  const AW_screen_area& get_cliprect() const { return clip_rect; }
238 
239  void set_clipall() {
240  // clip all -> nothing drawn afterwards
241  AW_screen_area rect = { 0, -1, 0, -1};
242  set_cliprect_oversize(rect, false);
243  }
244 
245  bool completely_clipped() const { return clip_rect.l>clip_rect.r || clip_rect.t>clip_rect.b; }
246 
247  bool allow_top_font_overlap() const { return font_overlap.top; }
248  bool allow_bottom_font_overlap() const { return font_overlap.bottom; }
249  bool allow_left_font_overlap() const { return font_overlap.left; }
250  bool allow_right_font_overlap() const { return font_overlap.right; }
251  const AW_font_overlap& get_font_overlap() const { return font_overlap; }
252 
253  void set_top_font_overlap(bool allow) { font_overlap.top = allow; }
254  void set_bottom_font_overlap(bool allow) { font_overlap.bottom = allow; }
255  void set_left_font_overlap(bool allow) { font_overlap.left = allow; }
256  void set_right_font_overlap(bool allow) { font_overlap.right = allow; }
257 
258  void set_vertical_font_overlap(bool allow) { font_overlap.top = font_overlap.bottom = allow; }
259  void set_horizontal_font_overlap(bool allow) { font_overlap.left = font_overlap.right = allow; }
261  void set_font_overlap(const AW_font_overlap& fo) { font_overlap = fo; }
262 
263  // like set_xxx_clip_border but make window only smaller:
264 
265  void reduce_top_clip_border(int top);
266  void reduce_bottom_clip_border(int bottom);
267  void reduce_left_clip_border(int left);
268  void reduce_right_clip_border(int right);
269 
270  int reduceClipBorders(int top, int bottom, int left, int right);
271 };
272 
273 // -----------------------------------------------
274 // Graphic context (linestyle, width ...)
275 
280 };
281 
282 
286 };
287 
288 class AW_common;
289 
290 class AW_stylable : virtual Noncopyable {
291  AW_common *common;
292 public:
293  AW_stylable(AW_common *common_) : common(common_) {}
294  virtual ~AW_stylable() {};
295 
296  AW_common *get_common() const { return common; }
297 
298  void new_gc(int gc);
299 
300  void set_grey_level(int gc, AW_grey_level grey_level);
302 
303  void set_font(int gc, AW_font fontnr, int size, int *found_size);
304  void set_line_attributes(int gc, short width, AW_linestyle style);
305  void set_function(int gc, AW_function function);
306  void establish_default(int gc);
307  void set_foreground_color(int gc, AW_color_idx color);
308 
309  int get_string_size(int gc, long textlen) const;
310  int get_string_size(int gc, const SizedCstr& cstr) const;
311 
312  const AW_font_limits& get_font_limits(int gc, char c) const; // for one characters (c == 0 -> for all characters)
313 
314  int get_available_fontsizes(int gc, AW_font font_nr, int *available_sizes);
315 
316  void reset_style();
317 };
318 
319 class AW_clip_scale_stack;
320 struct AW_world;
321 class AW_device;
322 
323 class AW_click_cd : virtual Noncopyable {
324  AW_CL cd1;
325  AW_CL cd2;
326  AW_device *my_device;
327  const AW_click_cd *previous;
328 
329  void link();
330 
331 public:
332  AW_click_cd(AW_device *device, AW_CL CD1, AW_CL CD2)
333  : cd1(CD1),
334  cd2(CD2),
335  my_device(device)
336  { link(); }
338  : cd1(CD1),
339  cd2(0),
340  my_device(device)
341  { link(); }
342  ~AW_click_cd();
343 
344  void disable();
345  void enable();
346 
347  AW_CL get_cd1() const { return cd1; }
348  AW_CL get_cd2() const { return cd2; }
349 
350  void set_cd1(AW_CL cd) { cd1 = cd; }
351  void set_cd2(AW_CL cd) { cd2 = cd; }
352 };
353 
354 typedef bool (*TextOverlayCallback)(AW_device *device, int gc, const char *textBuffer, size_t textStart, size_t textLen, const AW::Position& pos, AW_CL cduser);
355 
356 class AW_device : public AW_zoomable, public AW_stylable, public AW_clipable {
357  AW_device(const AW_device& other);
358  AW_device& operator=(const AW_device& other);
359 
360 protected:
362 
364  friend class AW_click_cd;
365 
367 
369 
370  static const AW_screen_area& get_common_screen(const AW_common *common_);
371 
372 public:
373  AW_device(class AW_common *common_) :
374  AW_stylable(common_),
375  AW_clipable(get_common_screen(common_)),
376  clip_scale_stack(NULp),
377  click_cd(NULp),
378  filter(AW_ALL_DEVICES)
379  {}
380  virtual ~AW_device() {}
381 
382  const AW_click_cd *get_click_cd() const { return click_cd; }
383  AW_bitset get_filter() const { return filter; }
384 
385  void reset(); // pops all clip_scales
386 
387  const AW_screen_area& get_area_size() const;
389 
390  void set_filter(AW_bitset filteri); // set the main filter mask
391 
392  void push_clip_scale(); // push clipping area and scale
393  void pop_clip_scale(); // pop them
394 
395  virtual AW_DEVICE_TYPE type() = 0;
396 
397  bool ready_to_draw(int gc); // unused atm
398 
399 private:
400  // * functions below return 1 if any pixel is drawn, 0 otherwise
401  // * primary functions (always virtual; pure virtual in all devices used as baseclass)
402 
403  virtual bool line_impl(int gc, const AW::LineVector& Line, AW_bitset filteri) = 0;
404  virtual bool text_impl(int gc, const SizedCstr& cstr, const AW::Position& pos, AW_pos alignment, AW_bitset filteri) = 0;
405  virtual bool box_impl(int gc, AW::FillStyle filled, const AW::Rectangle& rect, AW_bitset filteri) = 0;
406  virtual bool polygon_impl(int gc, AW::FillStyle filled, int npos, const AW::Position *pos, AW_bitset filteri) = 0;
407 
408  virtual bool circle_impl(int gc, AW::FillStyle filled, const AW::Position& center, const AW::Vector& radius, AW_bitset filteri) = 0;
409  virtual bool arc_impl(int gc, AW::FillStyle filled, const AW::Position& center, const AW::Vector& radius, int start_degrees, int arc_degrees, AW_bitset filteri) = 0;
410 
411  virtual bool invisible_impl(const AW::Position& pos, AW_bitset filteri) = 0;
412 
413  virtual void specific_reset() = 0;
414 
415 protected:
416 
417  // * second level functions
418  // generic implementations which may be used by primary functions of derived classes
419 
420  bool generic_box(int gc, const AW::Rectangle& rect, AW_bitset filteri);
421  bool generic_circle(int gc, const AW::Position& center, const AW::Vector& radius, AW_bitset filteri) {
422  return generic_box(gc, AW::Rectangle(center-radius, center+radius), filteri);
423  }
424  bool generic_polygon(int gc, int npos, const AW::Position *pos, AW_bitset filteri);
425  bool generic_invisible(const AW::Position& pos, AW_bitset filteri);
426 
427 public:
428  // * third level functions (never virtual/overloaded by derived classes)
429 
430  bool line(int gc, const AW::LineVector& Line, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
431  return line_impl(gc, Line, filteri);
432  }
433  bool line(int gc, const AW::Position& pos1, const AW::Position& pos2, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
434  return line_impl(gc, AW::LineVector(pos1, pos2), filteri);
435  }
436  bool line(int gc, AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
437  return line_impl(gc, AW::LineVector(x0, y0, x1, y1), filteri);
438  }
439 
440  bool text(int gc,
441  const SizedCstr& cstr,
442  const AW::Position& pos,
443  AW_pos alignment = 0.0, // 0.0 alignment left 0.5 centered 1.0 right justified
445  {
446  return text_impl(gc, cstr, pos, alignment, filteri);
447  }
448  bool text(int gc,
449  const char *str,
450  const AW::Position& pos,
451  AW_pos alignment = 0.0, // 0.0 alignment left 0.5 centered 1.0 right justified
453  {
454  return text_impl(gc, SizedCstr(str), pos, alignment, filteri);
455  }
456 
457  bool text(int gc,
458  const char *str,
459  AW_pos x,
460  AW_pos y,
461  AW_pos alignment = 0.0, // 0.0 alignment left 0.5 centered 1.0 right justified
463  {
464  return text_impl(gc, SizedCstr(str), AW::Position(x, y), alignment, filteri);
465  }
466 
468  return invisible_impl(pos, filteri);
469  }
470 
471  bool box(int gc, AW::FillStyle filled, const AW::Rectangle& rect, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
472  return box_impl(gc, filled, rect, filteri);
473  }
474  bool box(int gc, AW::FillStyle filled, const AW::Position& pos, const AW::Vector& size, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
475  return box_impl(gc, filled, AW::Rectangle(pos, size), filteri);
476  }
477  bool box(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos width, AW_pos height, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
478  return box_impl(gc, filled, AW::Rectangle(AW::Position(x0, y0), AW::Vector(width, height)), filteri);
479  }
480 
481  bool circle(int gc, AW::FillStyle filled, const AW::Position& center, const AW::Vector& radius, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
482  return circle_impl(gc, filled, center, radius, filteri);
483  }
484  bool circle(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos xradius, AW_pos yradius, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
485  return circle_impl(gc, filled, AW::Position(x0, y0), AW::Vector(xradius, yradius), filteri);
486  }
487  bool circle(int gc, AW::FillStyle filled, const AW::Rectangle& rect, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
488  // draw ellipse into Rectangle
489  return circle_impl(gc, filled, rect.centroid(), AW::Vector(rect.width()/2, rect.height()/2), filteri);
490  }
491 
492  // draw arcs (Note: passed degrees are non-standard: 90 degrees = downwards)
493  bool arc(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos xradius, AW_pos yradius, int start_degrees, int arc_degrees, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
494  return arc_impl(gc, filled, AW::Position(x0, y0), AW::Vector(xradius, yradius), start_degrees, arc_degrees, filteri);
495  }
496  bool arc(int gc, AW::FillStyle filled, const AW::Position& pos, const AW::Vector& radius, int start_degrees, int arc_degrees, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
497  return arc_impl(gc, filled, pos, radius, start_degrees, arc_degrees, filteri);
498  }
499 
500  bool polygon(int gc, AW::FillStyle filled, int npoints, const AW_pos *points, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
501  AW::Position *pos = new AW::Position[npoints];
502  for (int n = 0; n<npoints; ++n) {
503  pos[n].setx(points[n*2]);
504  pos[n].sety(points[n*2+1]);
505  }
506  bool result = polygon_impl(gc, filled, npoints, pos, filteri);
507  delete [] pos;
508  return result;
509  }
510  bool polygon(int gc, AW::FillStyle filled, int npos, const AW::Position *pos, AW_bitset filteri = AW_ALL_DEVICES_SCALED) {
511  return polygon_impl(gc, filled, npos, pos, filteri);
512  }
513 
514  bool text_overlay(int gc, const SizedCstr& cstr, const AW::Position& pos, AW_pos alignment, AW_bitset filteri, TextOverlayCallback toc, AW_CL cduser = 0);
515 
516  // ********* X11 Device only ********
517  virtual void clear(AW_bitset filteri);
518  virtual void clear_part(const AW::Rectangle& rect, AW_bitset filteri);
519 
520  void clear_part(AW_pos x, AW_pos y, AW_pos width, AW_pos height, AW_bitset filteri) {
521  clear_part(AW::Rectangle(AW::Position(x, y), AW::Vector(width, height)), filteri);
522  }
523 
524  virtual void move_region(AW_pos src_x, AW_pos src_y, AW_pos width, AW_pos height, AW_pos dest_x, AW_pos dest_y);
525  virtual void fast(); // e.g. zoom linewidth off
526  virtual void slow();
527  virtual void flush(); // empty X11 buffers
528 };
533 
534 inline void AW_click_cd::link() {
535  previous = my_device->click_cd;
536  my_device->click_cd = this;
537 }
538 inline AW_click_cd::~AW_click_cd() { my_device->click_cd = previous; }
539 inline void AW_click_cd::disable() { my_device->click_cd = NULp; }
540 inline void AW_click_cd::enable() { my_device->click_cd = this; }
541 
542 class AW_device_print FINAL_TYPE : public AW_device { // derived from a Noncopyable
543  FILE *xfig;
544  class SPOOLER *spooler;
545  bool color_mode;
546 
547  bool line_impl(int gc, const AW::LineVector& Line, AW_bitset filteri) OVERRIDE;
548  bool text_impl(int gc, const SizedCstr& cstr, const AW::Position& pos, AW_pos alignment, AW_bitset filteri) OVERRIDE;
549  bool box_impl(int gc, AW::FillStyle filled, const AW::Rectangle& rect, AW_bitset filteri) OVERRIDE;
550  bool circle_impl(int gc, AW::FillStyle filled, const AW::Position& center, const AW::Vector& radius, AW_bitset filteri) OVERRIDE;
551  bool arc_impl(int gc, AW::FillStyle filled, const AW::Position& center, const AW::Vector& radius, int start_degrees, int arc_degrees, AW_bitset filteri) OVERRIDE;
552  bool polygon_impl(int gc, AW::FillStyle filled, int npos, const AW::Position *pos, AW_bitset filteri) OVERRIDE;
553  bool invisible_impl(const AW::Position& pos, AW_bitset filteri) OVERRIDE;
554 
555  void specific_reset() {}
556 
557  int find_color_idx(AW_rgb color);
558 
559  AW_device::Fill_Style detectFillstyleForGreylevel(int gc, AW::FillStyle filled);
560  int calcAreaFill(AW_device::Fill_Style fillStyle, AW_grey_level grey_level);
561 
562  friend class SPOOLER;
563 
564 public:
566  AW_device(common_),
567  xfig(NULp),
568  spooler(NULp),
569  color_mode(false)
570  {}
571 
572  GB_ERROR open(const char *path) __ATTR__USERESULT;
573  void close();
574 
575  void set_color_mode(bool mode) { color_mode = mode; }
576 
577  // AW_device interface:
579 
580  // internal (do not use):
581  void draw_text(int gc, const char *textBuffer, size_t textStart, size_t textLen, const AW::Position& pos);
582 };
583 
584 class AW_simple_device : public AW_device {
585  bool box_impl(int gc, AW::FillStyle /*filled*/, const AW::Rectangle& rect, AW_bitset filteri) OVERRIDE {
586  return generic_box(gc, rect, filteri);
587  }
588  bool polygon_impl(int gc, AW::FillStyle /*filled*/, int npos, const AW::Position *pos, AW_bitset filteri) OVERRIDE {
589  return generic_polygon(gc, npos, pos, filteri);
590  }
591  bool circle_impl(int gc, AW::FillStyle /*filled*/, const AW::Position& center, const AW::Vector& radius, AW_bitset filteri) OVERRIDE {
592  return generic_circle(gc, center, radius, filteri);
593  }
594  bool arc_impl(int gc, AW::FillStyle /*filled*/, const AW::Position& center, const AW::Vector& radius, int /*start_degrees*/, int /*arc_degrees*/, AW_bitset filteri) OVERRIDE {
595  return generic_circle(gc, center, radius, filteri);
596  }
597 public:
598  AW_simple_device(AW_common *common_) : AW_device(common_) {}
599 };
600 
602  bool drawn;
603  AW_world size;
604 
605  void extend(AW_pos& low, AW_pos val, AW_pos& high) {
606  low = std::min(low, val);
607  high = std::max(high, val);
608  }
609 public:
611 
612  void restart() { drawn = false; size.clear(); }
613  void track(const AW::Position& pos) {
614  if (drawn) {
615  extend(size.l, pos.xpos(), size.r);
616  extend(size.t, pos.ypos(), size.b);
617  }
618  else {
619  size.l = size.r = pos.xpos();
620  size.t = size.b = pos.ypos();
621  drawn = true;
622  }
623  }
624 
625  bool was_drawn() const { return drawn; }
626  const AW_world& get_size() const { return size; }
628  return AW::Rectangle(AW::Position(size.l, size.t), AW::Position(size.r, size.b));
629  }
630 };
631 
633  AW_size_tracker scaled; // all zoomable parts (e.g. tree skeleton)
634  AW_size_tracker unscaled; // all unzoomable parts (e.g. text at tree-tips or group-brackets)
635 
636  void dot_transformed(const AW::Position& pos, AW_bitset filteri);
637  void dot_transformed(AW_pos X, AW_pos Y, AW_bitset filteri) { dot_transformed(AW::Position(X, Y), filteri); }
638 
639  void dot(const AW::Position& p, AW_bitset filteri) { dot_transformed(transform(p), filteri); }
640  void dot(AW_pos x, AW_pos y, AW_bitset filteri) { dot(AW::Position(x, y), filteri); }
641 
642  bool line_impl(int gc, const AW::LineVector& Line, AW_bitset filteri) OVERRIDE;
643  bool text_impl(int gc, const SizedCstr& cstr, const AW::Position& pos, AW_pos alignment, AW_bitset filteri) OVERRIDE;
644  bool invisible_impl(const AW::Position& pos, AW_bitset filteri) OVERRIDE;
645 
646  void specific_reset();
647 
648 public:
649  AW_device_size(AW_common *common_) : AW_simple_device(common_) {}
650 
651  void restart_tracking();
652 
654 
655  // all get_size_information...() return screen coordinates
656 
657  void get_size_information(AW_world *ptr) const __ATTR__DEPRECATED_TODO("whole AW_world is deprecated") {
658  *ptr = scaled.get_size();
659  }
664  }
665 
667 };
668 
669 #else
670 #error aw_device.hxx included twice
671 #endif
AW::Vector transform(const AW::Vector &vec) const
Definition: aw_device.hxx:144
virtual void clear(AW_bitset filteri)
Definition: AW_device.cxx:313
bool circle(int gc, AW::FillStyle filled, const AW::Rectangle &rect, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:487
const char * GB_ERROR
Definition: arb_core.h:25
bool allow_left_font_overlap() const
Definition: aw_device.hxx:249
AW::Rectangle rtransform(const AW::Rectangle &rect) const
Definition: aw_device.hxx:160
long AW_bitset
Definition: aw_base.hxx:44
bool line(int gc, AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:436
string result
bool allow_right_font_overlap() const
Definition: aw_device.hxx:250
bool is_outside_clip(AW::Position pos) const
Definition: aw_device.hxx:215
AW::Rectangle get_size_information() const
Definition: aw_device.hxx:660
void set_grey_level(int gc, AW_grey_level grey_level)
Definition: AW_device.cxx:450
AW_pos get_scale() const
Definition: aw_device.hxx:124
const AW_bitset AW_PRINTER_CLIP
Definition: aw_device.hxx:41
const AW_bitset AW_SIZE
Definition: aw_device.hxx:37
void disable()
Definition: aw_device.hxx:539
bool box_clip(AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_pos &x0out, AW_pos &y0out, AW_pos &x1out, AW_pos &y1out)
Definition: AW_clipable.cxx:25
const AW_bitset AW_PRINTER_EXT
Definition: aw_device.hxx:40
const AW_bitset AW_SCREEN
Definition: aw_device.hxx:34
AW_clipable(const AW_screen_area &screen)
Definition: aw_device.hxx:202
const AW_screen_area & get_area_size() const
Definition: AW_device.cxx:57
Position centroid() const
static char * y[maxsp+1]
void clear_part(AW_pos x, AW_pos y, AW_pos width, AW_pos height, AW_bitset filteri)
Definition: aw_device.hxx:520
void reduce_bottom_clip_border(int bottom)
AW::Position transform(const AW::Position &pos) const
Definition: aw_device.hxx:148
void set_left_clip_border(int left, bool allow_oversize=false)
int reduceClipBorders(int top, int bottom, int left, int right)
void set_cd2(AW_CL cd)
Definition: aw_device.hxx:351
void set_line_attributes(int gc, short width, AW_linestyle style)
Definition: AW_device.cxx:465
void set_function(int gc, AW_function function)
Definition: AW_device.cxx:468
double width() const
void establish_default(int gc)
Definition: AW_device.cxx:474
void shift(const AW::Vector &doff)
Definition: aw_device.hxx:131
const AW_screen_area & get_cliprect() const
Definition: aw_device.hxx:237
void reduce_left_clip_border(int left)
virtual void clear_part(const AW::Rectangle &rect, AW_bitset filteri)
Definition: AW_device.cxx:317
virtual ~AW_zoomable()
Definition: aw_device.hxx:120
virtual ~AW_device()
Definition: aw_device.hxx:380
bool is_below_clip(double ypos) const
Definition: aw_device.hxx:210
void reduce_top_clip_border(int top)
void reduce_right_clip_border(int right)
MARK_NONFINAL_METHOD(AW_device, move_region,(AW_pos, AW_pos, AW_pos, AW_pos, AW_pos, AW_pos))
bool arc(int gc, AW::FillStyle filled, const AW::Position &pos, const AW::Vector &radius, int start_degrees, int arc_degrees, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:496
static int pos1
Definition: ClustalV.cxx:58
const AW_font_overlap & get_font_overlap() const
Definition: aw_device.hxx:251
AW::Vector get_offset() const
Definition: aw_device.hxx:126
static const AW_screen_area & get_common_screen(const AW_common *common_)
Definition: AW_device.cxx:298
void track(const AW::Position &pos)
Definition: aw_device.hxx:613
void set_top_clip_border(int top, bool allow_oversize=false)
bool clip(AW_pos x0, AW_pos y0, AW_pos x1, AW_pos y1, AW_pos &x0out, AW_pos &y0out, AW_pos &x1out, AW_pos &y1out)
bool generic_polygon(int gc, int npos, const AW::Position *pos, AW_bitset filteri)
Definition: AW_device.cxx:251
AW::Rectangle transform(const AW::Rectangle &rect) const
Definition: aw_device.hxx:159
unsigned long AW_rgb
Definition: aw_base.hxx:51
AW_color_idx
Definition: aw_base.hxx:83
void set_offset(const AW::Vector &off)
Definition: aw_device.hxx:130
const AW_bitset AW_ALL_DEVICES
Definition: aw_device.hxx:44
AW_device(class AW_common *common_)
Definition: aw_device.hxx:373
bool polygon(int gc, AW::FillStyle filled, int npoints, const AW_pos *points, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:500
AW::Rectangle get_size_information_inclusive_text() const
Definition: aw_device.hxx:662
AW_simple_device(AW_common *common_)
Definition: aw_device.hxx:598
bool circle(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos xradius, AW_pos yradius, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:484
void zoom(AW_pos scale)
Definition: AW_device.cxx:336
void reset()
Definition: AW_device.cxx:331
AW_stylable(AW_common *common_)
Definition: aw_device.hxx:293
const AW_bitset AW_ALL_DEVICES_SCALED
Definition: aw_device.hxx:45
const AW_bitset AW_TRACK
Definition: aw_device.hxx:42
AW_click_cd(AW_device *device, AW_CL CD1, AW_CL CD2)
Definition: aw_device.hxx:332
AW::Rectangle get_size_information_unscaled() const
Definition: aw_device.hxx:661
void sety(const double &Y)
const AW_font_limits & get_font_limits(int gc, char c) const
Definition: AW_device.cxx:399
const AW_world & get_size() const
Definition: aw_device.hxx:626
const AW_bitset AW_PRINTER
Definition: aw_device.hxx:39
virtual void fast()
Definition: AW_device.cxx:325
bool is_above_clip(double ypos) const
Definition: aw_device.hxx:211
const Position & start() const
void reset_style()
Definition: AW_device.cxx:477
bool invisible(const AW::Position &pos, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:467
double transform_size(const double &size) const
Definition: aw_device.hxx:135
double AW_pos
Definition: aw_base.hxx:29
double rtransform_size(const double &size) const
Definition: aw_device.hxx:136
AW_bitset get_filter() const
Definition: aw_device.hxx:383
AW::Rectangle get_size_as_Rectangle() const
Definition: aw_device.hxx:627
void set_font(int gc, AW_font fontnr, int size, int *found_size)
Definition: AW_device.cxx:458
void set_bottom_font_overlap(bool allow)
Definition: aw_device.hxx:254
void transform(AW_pos x, AW_pos y, AW_pos &xout, AW_pos &yout) const
Definition: aw_device.hxx:163
void set_foreground_color(int gc, AW_color_idx color)
Definition: AW_device.cxx:471
int get_string_size(int gc, long textlen) const
Definition: AW_device.cxx:443
void push_clip_scale()
Definition: AW_device.cxx:91
void rotate(AW_pos angle)
bool circle(int gc, AW::FillStyle filled, const AW::Position &center, const AW::Vector &radius, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:481
AW_pos l
Definition: aw_base.hxx:32
const double & ypos() const
AW_cursor_type
Definition: aw_device.hxx:97
void clear()
Definition: aw_base.hxx:33
void new_gc(int gc)
Definition: AW_device.cxx:449
void set_bottom_clip_border(int bottom, bool allow_oversize=false)
bool line(int gc, const AW::Position &pos1, const AW::Position &pos2, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:433
AW_pos get_unscale() const
Definition: aw_device.hxx:125
void set_color_mode(bool mode)
Definition: aw_device.hxx:575
double height() const
#define false
Definition: ureadseq.h:13
AW_CL get_cd1() const
Definition: aw_device.hxx:347
bool line(int gc, const AW::LineVector &Line, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:430
void pop_clip_scale()
Definition: AW_device.cxx:62
AW::LineVector rtransform(const AW::LineVector &lvec) const
Definition: aw_device.hxx:157
AW_DEVICE_TYPE type()
#define __ATTR__DEPRECATED_TODO(reason)
Definition: attributes.h:104
AW::Vector rtransform(const AW::Vector &vec) const
Definition: aw_device.hxx:145
const AW_bitset AW_CLICK_DROP
Definition: aw_device.hxx:36
AW::Rectangle get_rtransformed_cliprect() const
Definition: aw_device.hxx:388
AW_CL get_cd2() const
Definition: aw_device.hxx:348
bool generic_box(int gc, const AW::Rectangle &rect, AW_bitset filteri)
Definition: AW_device.cxx:302
AW::LineVector transform(const AW::LineVector &lvec) const
Definition: aw_device.hxx:156
bool allow_bottom_font_overlap() const
Definition: aw_device.hxx:248
void set_cd1(AW_CL cd)
Definition: aw_device.hxx:350
bool polygon(int gc, AW::FillStyle filled, int npos, const AW::Position *pos, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:510
bool text(int gc, const char *str, AW_pos x, AW_pos y, AW_pos alignment=0.0, AW_bitset filteri=AW_ALL_DEVICES_UNSCALED)
Definition: aw_device.hxx:457
bool is_leftof_clip(double xpos) const
Definition: aw_device.hxx:212
AW_grey_level get_grey_level(int gc)
Definition: AW_device.cxx:454
AW_common * get_common() const
Definition: aw_device.hxx:296
const double & y() const
void set_bottom_clip_margin(int bottom, bool allow_oversize=false)
bool was_drawn() const
Definition: aw_device.hxx:625
virtual AW_DEVICE_TYPE type()=0
void setx(const double &X)
void set_font_overlap(bool allow)
Definition: aw_device.hxx:260
const AW_bitset AW_CLICK
Definition: aw_device.hxx:35
AW_pos r
Definition: aw_base.hxx:32
static int pos2
Definition: ClustalV.cxx:59
AW_borders get_unscaleable_overlap() const
bool generic_invisible(const AW::Position &pos, AW_bitset filteri)
Definition: AW_device.cxx:294
float AW_grey_level
Definition: aw_base.hxx:46
AW_bitset filter
Definition: aw_device.hxx:366
AW_click_cd(AW_device *device, AW_CL CD1)
Definition: aw_device.hxx:337
Rectangle bounding_box(const Rectangle &rect) const
AW_clip_scale_stack * clip_scale_stack
Definition: aw_device.hxx:361
void set_top_font_overlap(bool allow)
Definition: aw_device.hxx:253
AW_pos b
Definition: aw_base.hxx:32
const Vector & line_vector() const
void set_right_clip_border(int right, bool allow_oversize=false)
const AW_click_cd * click_cd
Definition: aw_device.hxx:363
bool generic_circle(int gc, const AW::Position &center, const AW::Vector &radius, AW_bitset filteri)
Definition: aw_device.hxx:421
void enable()
Definition: aw_device.hxx:540
xml element
long AW_CL
Definition: cb.h:21
void get_size_information(AW_world *ptr) const __ATTR__DEPRECATED_TODO("whole AW_world is deprecated")
Definition: aw_device.hxx:657
#define OVERRIDE
Definition: cxxforward.h:112
bool text(int gc, const char *str, const AW::Position &pos, AW_pos alignment=0.0, AW_bitset filteri=AW_ALL_DEVICES_UNSCALED)
Definition: aw_device.hxx:448
AW_pos t
Definition: aw_base.hxx:32
#define __ATTR__USERESULT
Definition: attributes.h:58
void set_cliprect(const AW_screen_area &rect)
Definition: aw_device.hxx:198
bool box(int gc, AW::FillStyle filled, const AW::Position &pos, const AW::Vector &size, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:474
bool overlaps_with(const Rectangle &rect) const
void set_right_font_overlap(bool allow)
Definition: aw_device.hxx:256
void rtransform(AW_pos x, AW_pos y, AW_pos &xout, AW_pos &yout) const
Definition: aw_device.hxx:167
void reset()
Definition: AW_device.cxx:280
const AW_bitset AW_ALL_DEVICES_UNSCALED
Definition: aw_device.hxx:46
const AW_bitset AW_SIZE_UNSCALED
Definition: aw_device.hxx:38
bool(* TextOverlayCallback)(AW_device *device, int gc, const char *textBuffer, size_t textStart, size_t textLen, const AW::Position &pos, AW_CL cduser)
Definition: aw_device.hxx:354
bool arc(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos xradius, AW_pos yradius, int start_degrees, int arc_degrees, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:493
const double & xpos() const
static int line
Definition: arb_a2ps.c:296
#define NULp
Definition: cxxforward.h:116
const char * cstr
Definition: defines.h:21
void set_filter(AW_bitset filteri)
Definition: AW_device.cxx:321
virtual ~AW_stylable()
Definition: aw_device.hxx:294
AW_DEVICE_TYPE
Definition: aw_device.hxx:48
AW_function
Definition: aw_device.hxx:283
AW_device_size(AW_common *common_)
Definition: aw_device.hxx:649
virtual void move_region(AW_pos src_x, AW_pos src_y, AW_pos width, AW_pos height, AW_pos dest_x, AW_pos dest_y)
Definition: AW_device.cxx:263
bool is_rightof_clip(double xpos) const
Definition: aw_device.hxx:213
virtual ~AW_clipable()
Definition: aw_device.hxx:208
bool ready_to_draw(int gc)
Definition: AW_device.cxx:327
virtual void flush()
Definition: AW_device.cxx:268
bool force_into_clipbox(const AW::Position &pos, AW::Position &forcedPos)
bool box(int gc, AW::FillStyle filled, const AW::Rectangle &rect, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:471
int compoutcode(AW_pos xx, AW_pos yy) const
Definition: aw_device.hxx:187
void set_clipall()
Definition: aw_device.hxx:239
void set_horizontal_font_overlap(bool allow)
Definition: aw_device.hxx:259
void set_left_font_overlap(bool allow)
Definition: aw_device.hxx:255
#define min(a, b)
Definition: f2c.h:153
int get_available_fontsizes(int gc, AW_font font_nr, int *available_sizes)
Definition: AW_device.cxx:462
double rtransform_pixelsize(int pixelsize) const
Definition: aw_device.hxx:138
bool is_outside_clip(AW::Rectangle rect) const
Definition: aw_device.hxx:220
virtual void slow()
Definition: AW_device.cxx:326
AW_linestyle
Definition: aw_device.hxx:276
AW::Position rtransform(const AW::Position &pos) const
Definition: aw_device.hxx:149
void set_font_overlap(const AW_font_overlap &fo)
Definition: aw_device.hxx:261
bool text(int gc, const SizedCstr &cstr, const AW::Position &pos, AW_pos alignment=0.0, AW_bitset filteri=AW_ALL_DEVICES_UNSCALED)
Definition: aw_device.hxx:440
const double & x() const
void clear()
Definition: aw_base.hxx:37
const AW_click_cd * get_click_cd() const
Definition: aw_device.hxx:382
AW_device_print(AW_common *common_)
Definition: aw_device.hxx:565
void set_vertical_font_overlap(bool allow)
Definition: aw_device.hxx:258
bool allow_top_font_overlap() const
Definition: aw_device.hxx:247
bool text_overlay(int gc, const SizedCstr &cstr, const AW::Position &pos, AW_pos alignment, AW_bitset filteri, TextOverlayCallback toc, AW_CL cduser=0)
Definition: AW_device.cxx:107
bool completely_clipped() const
Definition: aw_device.hxx:245
bool box(int gc, AW::FillStyle filled, AW_pos x0, AW_pos y0, AW_pos width, AW_pos height, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
Definition: aw_device.hxx:477
#define max(a, b)
Definition: f2c.h:154