1 #ifndef CANVAS_H_HEADER
2 #define CANVAS_H_HEADER
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #if !defined(DEBUG_ALLOCS) && defined(DEBUG_TRACE)
9 #define TRACE_update_canvas_display
10 #define TRACE_render_astbar
11 #endif
12 
13 /* define that if you want all geometry being updated just before setting shape*/
14 #undef	STRICT_GEOMETRY
15 
16 
17 struct MyStyle ;
18 struct ASImage;
19 struct icon_t;
20 struct button_t;
21 struct ASImageManager;
22 struct ASBalloon;
23 struct ASVector;
24 struct ASGrid;
25 
26 typedef struct ASCanvas
27 {
28 #define CANVAS_DIRTY				(0x01<<0)
29 #define CANVAS_OUT_OF_SYNC			(0x01<<1)
30 #define CANVAS_MASK_OUT_OF_SYNC		(0x01<<2)
31 #define CANVAS_CONFIG_INVALID		(0x01<<3)
32 #define CANVAS_MAPPED				(0x01<<4)
33 
34 /* these are not really a states but rather flags : */
35 #define CANVAS_CONTAINER            (0x01<<16) /* user drawn - should not maintain our canvas Pixmap,
36 												* also should monitor chnages in user defined shape,
37 												* and update mask pixmap accordingly */
38 #define CANVAS_FORCE_MASK           (0x01<<18)  /* forces rendering of the canvas mask even if MyStyle is not shaped */
39 #define CANVAS_SHAPE_SET            (0x01<<19)  /* */
40 
41 #define IsCanvasShaped(pc)            get_flags((pc)->state,CANVAS_SHAPE_SET)
42 
43 	ASFlagType  state ;
44 	Window w;
45 	int root_x, root_y;
46 	unsigned short width, height ;
47 	unsigned int bw ;
48 
49 	Pixmap 		saved_canvas ;
50 	struct ASVector 	*saved_shape ;
51 
52 	/* these two are shortcuts to above values */
53 	Pixmap canvas;
54 	struct ASVector *shape;                     /* vector of XRectangles */
55 	/* 32 bytes */
56 }ASCanvas;
57 
58 /* synonim for backporting of parts of as-devel */
59 #define ASWidget ASCanvas
60 #define AS_WIDGET_SCREEN(c) (ASDefaultScr)
61 #define AS_WIDGET_WINDOW(c) ((c)?(c)->w:None)
62 #define AS_WIDGET_X(c)      ((c)?(int)(c)->root_x:0)
63 #define AS_WIDGET_Y(c)      ((c)?(int)(c)->root_y:0)
64 #define AS_WIDGET_WIDTH(c)  ((c)?(int)(c)->width:0)
65 #define AS_WIDGET_HEIGHT(c) ((c)?(int)(c)->height:0)
66 #define AS_WIDGET_BW(c) 	((c)?(int)(c)->bw:0)
67 #define AS_WIDGET_FEEL(c)   (&(ASDefaultScr->Feel))
68 #define AS_WIDGET_LOOK(c)   (&(ASDefaultScr->Look))
69 
70 
71 
72 ASCanvas* create_ascanvas(Window w);
73 ASCanvas* create_ascanvas_container (Window w);
74 
75 void destroy_ascanvas( ASCanvas **pcanvas );
76 #define CANVAS_X_CHANGED            (0x01<<0)
77 #define CANVAS_Y_CHANGED            (0x01<<1)
78 #define CANVAS_MOVED                (CANVAS_X_CHANGED|CANVAS_Y_CHANGED)
79 #define CANVAS_WIDTH_CHANGED        (0x01<<2)
80 #define CANVAS_HEIGHT_CHANGED       (0x01<<3)
81 #define CANVAS_RESIZED              (CANVAS_WIDTH_CHANGED|CANVAS_HEIGHT_CHANGED)
82 
83 ASFlagType handle_canvas_config( ASCanvas *canvas ); /* Returns True if moved/resized */
84 Bool get_canvas_position( ASCanvas *pc, Window *pparent, int *px, int *py, unsigned int *pbw );
85 void clear_canvas_shape (ASCanvas * pc, Bool force_for_container);
86 void invalidate_canvas_config( ASCanvas *canvas );
87 Bool get_current_canvas_size( ASCanvas * pc, unsigned int *pwidth, unsigned int *pheight );
88 Bool get_current_canvas_geometry( ASCanvas * pc, int *px, int *py, unsigned int *pwidth, unsigned int *pheight, unsigned int *pbw );
89 
90 
91 Pixmap get_canvas_canvas( ASCanvas *pc );
92 Pixmap get_canvas_mask( ASCanvas *pc );
93 Bool draw_canvas_image( ASCanvas *pc, struct ASImage *im, int x, int y );
94 void fill_canvas_mask (ASCanvas * pc, int win_x, int win_y, int width, int height);
95 Bool draw_canvas_mask (ASCanvas * pc, ASImage * im, int x, int y);
96 
97 #ifdef TRACE_update_canvas_display
98 void  trace_update_canvas_display (ASCanvas * pc, const char *file, int line);
99 #define update_canvas_display(p)  trace_update_canvas_display((p),__FILE__,__LINE__)
100 #else
101 void update_canvas_display( ASCanvas *pc );
102 #endif
103 void update_canvas_display_mask (ASCanvas * pc, Bool force);
104 
105 Bool save_canvas( ASCanvas *pc );
106 Bool swap_save_canvas( ASCanvas *pc );
107 
108 void invalidate_canvas_save( ASCanvas *pc );
109 Bool restore_canvas( ASCanvas *pc );
110 
111 Bool check_canvas_shaped( ASCanvas *pc);
112 Bool refresh_container_shape( ASCanvas *pc );
113 Bool combine_canvas_shape (ASCanvas *parent, ASCanvas *child );
114 Bool combine_canvas_shape_at_geom (ASCanvas *parent, ASCanvas *child, int child_x, int child_y, int child_w, int child_h, int child_bw );
115 Bool combine_canvas_shape_at (ASCanvas *parent, ASCanvas *child, int child_x, int child_y );
116 
117 
118 
119 ASFlagType resize_canvas( ASCanvas *pc, unsigned int width, unsigned int height );
120 void move_canvas (ASCanvas * pc, int x, int y);
121 ASFlagType moveresize_canvas (ASCanvas * pc, int x, int y, unsigned int width, unsigned int height);
122 ASFlagType configure_canvas (ASCanvas * pc, int x, int y, unsigned int width, unsigned int height, ASFlagType mask );
123 
124 void map_canvas_window( ASCanvas *pc, Bool raised );
125 void unmap_canvas_window( ASCanvas *pc );
126 void reparent_canvas_window( ASCanvas *pc, Window dst, int x, int y );
127 void quietly_reparent_canvas( ASCanvas *pc, Window dst, long event_mask, Bool use_root_pos, Window below );
128 
129 
130 Bool is_canvas_needs_redraw( ASCanvas *pc );
131 Bool is_canvas_dirty( ASCanvas *pc );
132 void add_canvas_grid( struct ASGrid *grid, ASCanvas *canvas, int outer_gravity, int inner_gravity, Bool absolute);
133 void set_root_clip_area( ASCanvas *canvas );
134 
135 void send_canvas_configure_notify(ASCanvas *parent, ASCanvas *canvas);
136 
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif
143 
144