]> git.cworth.org Git - grrobot/blob - src/grr_board_view.h
* src/grrobot.c (grr_game_read_notices): Call new board_view timer
[grrobot] / src / grr_board_view.h
1 /* grr_board_view - GTK+ widget for displaying an rr_board
2  *
3  * Copyright © 2003 Carl Worth
4  *
5  * Permission to use, copy, modify, distribute, and sell this software
6  * and its documentation for any purpose is hereby granted without
7  * fee, provided that the above copyright notice appear in all copies
8  * and that both that copyright notice and this permission notice
9  * appear in supporting documentation, and that the name of Carl Worth
10  * not be used in advertising or publicity pertaining to distribution
11  * of the software without specific, written prior permission.
12  * Carl Worth makes no representations about the suitability of this
13  * software for any purpose.  It is provided "as is" without express
14  * or implied warranty.
15  * 
16  * CARL WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18  * NO EVENT SHALL CARL WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23  *
24  * Author: Carl Worth <carl@theworths.org>
25  */
26
27 #ifndef GRR_BOARD_VIEW_H
28 #define GRR_BOARD_VIEW_H
29
30 #include <gdk/gdk.h>
31 #include <gtk/gtkadjustment.h>
32 #include <gtk/gtkwidget.h>
33
34 #include <rr.h>
35
36 #include "grr_icon.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41
42 #define GRR_BOARD_VIEW(obj)     GTK_CHECK_CAST (obj, grr_board_view_get_type (), grr_board_view_t)
43 #define GRR_BOARD_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, grr_board_view_get_type (), grr_board_view_class_t)
44 #define GRR_IS_BOARD_VIEW(obj)  GTK_CHECK_TYPE (obj, grr_board_view_get_type ())
45
46 typedef struct grr_board_view           grr_board_view_t;
47 typedef struct grr_board_view_class     grr_board_view_class_t;
48
49 struct grr_board_view
50 {
51     /* GtkWidget has to be first for GTK+ object magic? */
52     GtkWidget widget;
53
54     rr_board_t *board;
55
56     int board_width, board_height;
57     int board_pad_x, board_pad_y;
58
59     int **damaged;
60
61     int cell_width, cell_height;
62
63     rr_robot_t active_robot;
64
65     rr_client_t *client;
66     
67     /* Button currently pressed or 0 if none */
68     guint8 button;
69     
70     double time;
71     double drift_correct;
72     guint timer;
73
74     grr_icon_t *cell1_icon;
75     grr_icon_t *cell2_icon;
76     grr_icon_t *wall_icon;
77
78     grr_icon_t *robot_icon[RR_NUM_ROBOTS];
79     grr_icon_t *target_icon[RR_NUM_TARGETS];
80 };
81
82 struct grr_board_view_class
83 {
84     GtkWidgetClass parent_class;
85 };
86
87 grr_board_view_t *
88 grr_board_view_new (rr_board_t *board);
89
90 void
91 grr_board_view_set_client (grr_board_view_t *view, rr_client_t *client);
92
93 GtkType
94 grr_board_view_get_type (void);
95
96 void
97 grr_board_view_set_active_robot (grr_board_view_t *view, rr_robot_t robot);
98
99 void
100 grr_board_view_move_active (grr_board_view_t *view, rr_direction_t dir);
101
102 void
103 grr_board_view_undo (grr_board_view_t *view);
104
105 void
106 grr_board_view_mark_damage (grr_board_view_t *view, int i, int j);
107
108 void
109 grr_board_view_start_timer (grr_board_view_t *view, double time);
110
111 void
112 grr_board_view_stop_timer (grr_board_view_t *view);
113
114 void
115 grr_board_view_reset_timer (grr_board_view_t *view);
116
117 void
118 grr_board_view_transform_pixel_to_cell (grr_board_view_t *view,
119                                         int pixel_x, int pixel_y,
120                                         int *cell_x, int *cell_y);
121
122 void
123 grr_board_view_transform_cell_to_pixel (grr_board_view_t *view,
124                                         int cell_x, int cell_y,
125                                         int *pixel_x, int *pixel_y);
126
127 #ifdef __cplusplus
128 }
129 #endif /* __cplusplus */
130
131 #endif /* GRR_BOARD_VIEW_H */