25 |
|
|
26 |
#include "library.h" |
#include "library.h" |
27 |
|
|
28 |
|
/* This is a convenience macro for specifying xlib drawing function |
29 |
|
prototypes. */ |
30 |
|
#ifndef XDRAWP |
31 |
|
#define XDRAWP drawing->display, drawing->window, drawing->gc |
32 |
|
#endif /* XDRAWP */ |
33 |
|
|
34 |
void |
void |
35 |
antiright_drawing_initialize(Widget drawing_widget, |
antiright_drawing_initialize(Widget drawing_widget, |
36 |
struct antiright_drawing_structure *drawing) |
struct antiright_drawing_structure *drawing) |
57 |
|
|
58 |
void |
void |
59 |
antiright_draw_line(struct antiright_drawing_structure *drawing, |
antiright_draw_line(struct antiright_drawing_structure *drawing, |
60 |
int x1, int y1, |
int x1, int y1, int x2, int y2) |
|
int x2, int y2) |
|
61 |
{ |
{ |
62 |
XDrawLine(drawing->display, drawing->window, drawing->gc, |
XDrawLine(XDRAWP, x1, y1, x2, y2); |
|
x1, y1, |
|
|
x2, y2); |
|
63 |
} |
} |
64 |
|
|
65 |
void |
void |
67 |
int x, int y, |
int x, int y, |
68 |
char *string) |
char *string) |
69 |
{ |
{ |
70 |
XDrawString(drawing->display, drawing->window, drawing->gc, |
XDrawString(XDRAWP, x, y, string, strlen(string)); |
|
x, y, |
|
|
string, |
|
|
strlen(string)); |
|
71 |
} |
} |
72 |
|
|
73 |
void |
void |
88 |
unsigned int width, unsigned int height, |
unsigned int width, unsigned int height, |
89 |
int angle1, int angle2) |
int angle1, int angle2) |
90 |
{ |
{ |
91 |
XDrawArc(drawing->display, drawing->window, drawing->gc, |
XDrawArc(XDRAWP, x, y, width, height, angle1, angle2); |
|
x, y, |
|
|
width, height, |
|
|
angle1, angle2); |
|
92 |
} |
} |
93 |
|
|
94 |
void |
void |
97 |
unsigned int width, unsigned int height, |
unsigned int width, unsigned int height, |
98 |
int angle1, int angle2) |
int angle1, int angle2) |
99 |
{ |
{ |
100 |
XFillArc(drawing->display, drawing->window, drawing->gc, |
XFillArc(XDRAWP, x, y, width, height, angle1, angle2); |
|
x, y, |
|
|
width, height, |
|
|
angle1, angle2); |
|
101 |
} |
} |
102 |
|
|
103 |
void |
void |
104 |
|
antiright_draw_set_all_color_flags(XColor *color) |
105 |
|
{ |
106 |
|
color->flags=DoRed|DoGreen|DoBlue; |
107 |
|
} |
108 |
|
void |
109 |
|
antiright_setup_default_colormap(Display *display, Colormap *colormap) |
110 |
|
{ |
111 |
|
(*colormap)=DefaultColormap(display, DefaultScreen(display)); |
112 |
|
} |
113 |
|
void |
114 |
antiright_draw_allocate_color(struct antiright_drawing_structure *drawing, |
antiright_draw_allocate_color(struct antiright_drawing_structure *drawing, |
115 |
XColor *color) |
XColor *color) |
116 |
{ |
{ |
118 |
|
|
119 |
/* These options are set often enough, so set them in this generic |
/* These options are set often enough, so set them in this generic |
120 |
function. */ |
function. */ |
121 |
color->flags=DoRed|DoGreen|DoBlue; |
antiright_draw_set_all_color_flags(color); |
122 |
colormap=DefaultColormap(drawing->display, DefaultScreen(drawing->display)); |
antiright_setup_default_colormap(drawing->display, &colormap); |
123 |
XAllocColor(drawing->display, colormap, color); |
XAllocColor(drawing->display, colormap, color); |
124 |
} |
} |
125 |
|
|
126 |
void |
void |
127 |
|
antiright_multiply_colors(XColor *color, |
128 |
|
int red_int, int green_int, int blue_int) |
129 |
|
{ |
130 |
|
color->red=red_int*256; |
131 |
|
color->green=green_int*256; |
132 |
|
color->blue=blue_int*256; |
133 |
|
} |
134 |
|
|
135 |
|
void |
136 |
antiright_draw_foreground(struct antiright_drawing_structure *drawing, |
antiright_draw_foreground(struct antiright_drawing_structure *drawing, |
137 |
int red_int, int green_int, int blue_int) |
int red_int, int green_int, int blue_int) |
138 |
{ |
{ |
139 |
XColor color; |
XColor color; |
140 |
|
antiright_multiply_colors(&color, red_int, green_int, blue_int); |
|
color.red=red_int*256; |
|
|
color.green=green_int*256; |
|
|
color.blue=blue_int*256; |
|
141 |
antiright_draw_allocate_color(drawing, &color); |
antiright_draw_allocate_color(drawing, &color); |
142 |
XSetForeground(drawing->display, drawing->gc, color.pixel); |
XSetForeground(drawing->display, drawing->gc, color.pixel); |
143 |
} |
} |