"Fossies" - the Fresh Open Source Software Archive

Member "screentest-2.0/blink_test.c" (28 Jul 2007, 2400 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 "blink_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 static guint timeout;
   30 
   31 static gint blink_type;
   32 static gint blink_step;
   33 
   34 static void blink_draw(GtkWidget * widget)
   35 {
   36     GdkWindow *win = widget->window;
   37     gint w, h;
   38     GdkGC *gc1, *gc2;
   39 
   40     gdk_window_get_size(win, &w, &h);
   41 
   42     if (blink_step) {
   43         gc1 = backgc;
   44         gc2 = gc;
   45     } else {
   46         gc1 = gc;
   47         gc2 = backgc;
   48     }
   49 
   50     if (blink_type) {
   51         gdk_draw_rectangle(win, gc1, TRUE, 5, 5, w / 3 - 5,
   52                    h - 10);
   53         gdk_draw_rectangle(win, gc2, TRUE, w / 3, 5, w / 3,
   54                    h - 10);
   55         gdk_draw_rectangle(win, gc1, TRUE, 2 * w / 3, 5, w / 3 - 5,
   56                    h - 10);
   57     } else {
   58         gdk_draw_rectangle(win, gc1, TRUE, 5, 5, w - 10,
   59                    h / 3 - 5);
   60         gdk_draw_rectangle(win, gc2, TRUE, 5, h / 3, w - 10,
   61                    h / 3);
   62         gdk_draw_rectangle(win, gc1, TRUE, 5, 2 * h / 3, w - 10,
   63                    h / 3 - 5);
   64     }
   65     gdk_draw_rectangle(win, gc, FALSE, 0, 0, w - 1, h - 1);
   66 }
   67 
   68 static gboolean blink_timeout(gpointer data)
   69 {
   70     GtkWidget *widget = (GtkWidget *) data;
   71     blink_step = !blink_step;
   72     blink_draw(widget);
   73     return TRUE;
   74 }
   75 
   76 static void blink_init(GtkWidget * widget)
   77 {
   78     blink_type = 0;
   79     blink_step = 0;
   80     timeout = gtk_timeout_add(1000, blink_timeout, widget);
   81 }
   82 
   83 void blink_cycle(G_GNUC_UNUSED GtkWidget * widget)
   84 {
   85     blink_type = !blink_type;
   86 }
   87 
   88 static void blink_close(G_GNUC_UNUSED GtkWidget * widget)
   89 {
   90     gtk_timeout_remove(timeout);
   91 }
   92 
   93 struct test_ops blink_ops = {
   94     init:blink_init,
   95     draw:blink_draw,
   96     cycle:blink_cycle,
   97     close:blink_close
   98 };