UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZBarDraw.H
1 // ZBarDraw.H $Revision: 1.7 $ (C) VSP,CGE:26 $Date: 2003/01/31 17:11:47 $
2 
3 #if !defined __ZBarDraw_H
4 
5 #define __ZBarDraw_H
6 
7 #include <zm/ZBase.H>
8 #include <zm/ZPalette.H>
9 
10 
11 #define AUTO_FLUSH 5000
12 #define BUFFER_GROW 500
13 
14 /*************************************************************
15  * Draw color bars (sticks) with simple color bufferization.
16  * Auto-flushing is set to AUTO_FLUSH segments at start.
17  *************************************************************/
18 
19 class ZBarDraw : public ZDrawable
20 {
21 protected:
22 
23  ZRect clip; /* clip rectangle area */
24 
25  Logic flip_flag; /* FALSE - vertical bars;
26  TRUE - horizontal bars */
27  ZPalette *pal; /* If NULL - all color indexes gives black */
28 
29  XSegmentAr buf; /* stores XSegments until flush_bars()
30  * or new bar to draw with different than
31  * previous color */
32  unsigned cindex; /* color index of bars in buf */
33  ColorPixel cpixel; /* exact color pixel */
34  enum {
35  NO_COLOR,
36  COLOR_PALETTE,
37  EXACT_COLOR
38  } color_mode; /* mode of color definition */
39  unsigned auto_flush; /* limits XSegment stacking in buf */
40 
41  XImage *image; /* NULL -- image is off */
42 
43  /* set foreground color to one with cindex */
44  void set_bars_color ();
45 
46 public:
47 
48  ZBarDraw (const ZConnect& zconnect, Drawable drawable);
49  ZBarDraw (const ZDrawable& zdrawable);
50 
51  /* interpret position as x-coord (vertical bars -- flip FALSE)
52  or as y-coord (horizontal bars -- flip TRUE) */
53  virtual void flip (Logic new_flag);
54 
55  /* return value of flip_flag */
56  Logic is_flipped () const
57  {return flip_flag;}
58 
59  /* set auto-flush threshold */
60  void set_autoflush (unsigned new_volume)
61  {auto_flush = new_volume;}
62 
63  /* set rectangle of clip drawings */
64  virtual void set_cliprect (ZRect& r);
65 
66  /* clip pointed bar to segment and flip it if needed */
67  Logic clip_and_flip (XSegment& dest, int pos,
68  int start, int end);
69 
70  /* attach palette of colors */
71  virtual void attach_palette (ZPalette* theColorPalette);
72 
73  /* draw one bar in pointed position from start to end
74  with color index in attached palette (Not ColorPixel!!!) */
75  virtual void draw_bar (int pos, int start, int end,
76  unsigned color);
77 
78  /* draw one bar in pointed position from start to end
79  with undefined color index -- will be known after set_color() */
80  virtual void draw_bar (int pos, int start, int end);
81 
82  /* assign color index to all previously "drawn" bars */
83  virtual void set_color (unsigned color);
84 
85  /* draw one bar in pointed position from start to end
86  with exact ColorPixel as a color */
87  virtual void draw_bar_cp (int pos, int start, int end,
88  ColorPixel cp);
89 
90  /* send all segment buffers to X-server */
91  virtual void flush_bars ();
92 
93  /* turn on XImage buffer (drawable -> image) */
94  virtual void image_on ();
95 
96  /* turn off XImage buffer (image -> drawable) */
97  virtual void image_off ();
98 
99 };
100 
101 
102 #endif // ZBarDraw.H
Definition: ZBase.H:87
Definition: ZBase.H:118
Definition: ZPalette.H:18
Definition: ZBase.H:259
Definition: ZBarDraw.H:19