File: vertical_test.c

package info (click to toggle)
screentest 2.0-2.2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 1,652 kB
  • ctags: 149
  • sloc: sh: 8,940; ansic: 802; makefile: 65
file content (68 lines) | stat: -rw-r--r-- 1,724 bytes parent folder | download | duplicates (4)
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
/*
 *  Screentest - CRT/LCD monitor testing utility.
 *  http://screentest.sourceforge.net/
 *  Copyright (C) 2001 Jan "Yenya" Kasprzak <kas@fi.muni.cz>
 *  Copyright (C) 2006-2007 Tobias Gruetzmacher <tobias@portfolio16.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gtk/gtk.h>

#include "callbacks.h"

#define GRID_STEP 64
#define GRID_STEP_MIN 2

static gint vertical_step;

static void vertical_init(G_GNUC_UNUSED GtkWidget * widget)
{
	vertical_step = GRID_STEP;
}

static void vertical_cycle(G_GNUC_UNUSED GtkWidget * widget)
{
	vertical_step /= 2;
	if (vertical_step < GRID_STEP_MIN)
		vertical_step = GRID_STEP;
}

static void vertical_draw(GtkWidget * widget)
{
	GdkWindow *win = widget->window;
	gint w, h;
	gint i;
	gint d;

	gdk_window_get_size(win, &w, &h);

	d = w / 4;
	if (d > h / 4)
		d = h / 4;

	for (i = ((w - 1) % vertical_step) / 2; i < w; i += vertical_step)
		gdk_draw_line(win, gc, i, 0, i, h - 1);
}

struct test_ops vertical_ops = {
	init:vertical_init,
	draw:vertical_draw,
	cycle:vertical_cycle,
	close:NULL
};