"Fossies" - the Fresh Open Source Software Archive

Member "screentest-2.0/vertical_test.c" (28 Jul 2007, 1724 Bytes) of package /linux/privat/old/screentest-2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "vertical_test.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *  Screentest - CRT/LCD monitor testing utility.
    3  *  http://screentest.sourceforge.net/
    4  *  Copyright (C) 2001 Jan "Yenya" Kasprzak <kas@fi.muni.cz>
    5  *  Copyright (C) 2006-2007 Tobias Gruetzmacher <tobias@portfolio16.de>
    6  *
    7  *  This program is free software; you can redistribute it and/or modify
    8  *  it under the terms of the GNU General Public License version 2 as
    9  *  published by the Free Software Foundation.
   10  *
   11  *  This program is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with this program; if not, write to the Free Software
   18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
   19  */
   20 
   21 #ifdef HAVE_CONFIG_H
   22 #  include <config.h>
   23 #endif
   24 
   25 #include <gtk/gtk.h>
   26 
   27 #include "callbacks.h"
   28 
   29 #define GRID_STEP 64
   30 #define GRID_STEP_MIN 2
   31 
   32 static gint vertical_step;
   33 
   34 static void vertical_init(G_GNUC_UNUSED GtkWidget * widget)
   35 {
   36     vertical_step = GRID_STEP;
   37 }
   38 
   39 static void vertical_cycle(G_GNUC_UNUSED GtkWidget * widget)
   40 {
   41     vertical_step /= 2;
   42     if (vertical_step < GRID_STEP_MIN)
   43         vertical_step = GRID_STEP;
   44 }
   45 
   46 static void vertical_draw(GtkWidget * widget)
   47 {
   48     GdkWindow *win = widget->window;
   49     gint w, h;
   50     gint i;
   51     gint d;
   52 
   53     gdk_window_get_size(win, &w, &h);
   54 
   55     d = w / 4;
   56     if (d > h / 4)
   57         d = h / 4;
   58 
   59     for (i = ((w - 1) % vertical_step) / 2; i < w; i += vertical_step)
   60         gdk_draw_line(win, gc, i, 0, i, h - 1);
   61 }
   62 
   63 struct test_ops vertical_ops = {
   64     init:vertical_init,
   65     draw:vertical_draw,
   66     cycle:vertical_cycle,
   67     close:NULL
   68 };