File: x_sample_sb_view_lib.c

package info (click to toggle)
mlterm 3.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 21,204 kB
  • ctags: 9,659
  • sloc: ansic: 125,933; sh: 9,668; java: 2,310; makefile: 1,783; perl: 1,603; cpp: 1,101; xml: 42; sed: 16
file content (87 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *	$Id$
 */

#include  "x_sample_sb_view_lib.h"

#include  <stdio.h>


/* --- global functions --- */

Pixmap
x_get_icon_pixmap(
	x_sb_view_t *  view ,
	GC  gc ,
	char **  data ,
	unsigned int  width ,
	unsigned int  height ,
	unsigned int  depth ,
	unsigned long  black ,
	unsigned long  white
	)
{
	Pixmap  pix ;
	char  cur ;
	int  x ;
	int  y ;
	
	pix = XCreatePixmap( view->display , view->window , width , height , depth) ;

	cur = '\0' ;
	for( y = 0 ; y < height ; y ++)
	{
		for( x = 0 ; x < width ; x ++)
		{
			if( cur != data[y][x])
			{
				if( data[y][x] == ' ')
				{
					XSetForeground( view->display , gc , white) ;
				}
				else if( data[y][x] == '#')
				{
					XSetForeground( view->display , gc , black) ;
				}
				else
				{
					continue ;
				}

				cur = data[y][x] ;
			}

			XDrawPoint( view->display , pix , gc , x , y) ;
		}

		x = 0 ;
	}

	return  pix ;
}

int
x_draw_icon_pixmap_fg(
	x_sb_view_t *  view ,
	Pixmap  arrow ,
	char **  data ,
	unsigned int  width ,
	unsigned int  height
	)
{
	int  x ;
	int  y ;
	
	for( y = 0 ; y < height ; y ++)
	{
		for( x = 0 ; x < width ; x ++)
		{
			if( data[y][x] == '-')
			{
				XDrawPoint( view->display , arrow , view->gc , x , y) ;
			}
		}
	}

	return  1 ;
}