23
23
#include "pocket.h"
25
#include "pixmaps/left_blue.xpm"
26
#include "pixmaps/left_green.xpm"
27
#include "pixmaps/left_red.xpm"
28
#include "pixmaps/left_yellow.xpm"
29
#include "pixmaps/lower_blue.xpm"
30
#include "pixmaps/lower_green.xpm"
31
#include "pixmaps/lower_red.xpm"
32
#include "pixmaps/lower_yellow.xpm"
33
#include "pixmaps/right_blue.xpm"
34
#include "pixmaps/right_green.xpm"
35
#include "pixmaps/right_red.xpm"
36
#include "pixmaps/right_yellow.xpm"
37
#include "pixmaps/upper_blue.xpm"
38
#include "pixmaps/upper_green.xpm"
39
#include "pixmaps/upper_red.xpm"
40
#include "pixmaps/upper_yellow.xpm"
43
Pocket::Pocket(GtkWidget* table) : _table(table), _element(0), _ball(0)
48
Pocket::InsertInTable(int row, int col, GdkPixmap* pixmap)
26
Pocket::Pocket(GtkWidget* table, int row, int col) : _table(table),
50
29
/* a pixmap widget to contain the pixmap */
51
_pixmapwid = gtk_pixmap_new(_red_pixmap, _mask);
52
gtk_widget_show(_pixmapwid);
54
gtk_table_attach_defaults(GTK_TABLE(_table), _pixmapwid, col, col + 1,
59
Pocket::CreateFromXpm(char** data)
61
GtkStyle* style = gtk_widget_get_style(_table);
62
return gdk_pixmap_colormap_create_from_xpm_d(
63
_table->window, gtk_widget_get_colormap(_table), &_mask,
64
&style->bg[GTK_STATE_NORMAL], data);
30
_pixmapwid = gtk_image_new_from_stock(GROUNDHOG_STOCK_LEFT_RED,
32
/* gtk_table_attach_defaults(GTK_TABLE(_table), _pixmapwid, col, col + 1,
34
gtk_table_attach(GTK_TABLE(_table), _pixmapwid, col, col + 1,
35
row, row + 1, GTK_EXPAND, GTK_EXPAND, 0, 0);
68
39
Pocket::PutBall(Ball* ball)
41
const gchar* stock_id = 0;
71
44
switch (ball->GetColor()) {
73
gtk_pixmap_set(GTK_PIXMAP(_pixmapwid), _red_pixmap, 0);
46
stock_id = GetRedPixmap();
76
gtk_pixmap_set(GTK_PIXMAP(_pixmapwid), _green_pixmap, 0);
49
stock_id = GetGreenPixmap();
79
gtk_pixmap_set(GTK_PIXMAP(_pixmapwid), _blue_pixmap, 0);
52
stock_id = GetBluePixmap();
82
gtk_pixmap_set(GTK_PIXMAP(_pixmapwid), _yellow_pixmap, 0);
55
stock_id = GetYellowPixmap();
58
gtk_image_set_from_stock(GTK_IMAGE(_pixmapwid), stock_id, Icons::Size());
85
59
Element::PutBall(ball);
105
79
std::not1(std::mem_fun(&Pocket::HasRightBall))) == _set.end();
108
LeftPocket::LeftPocket(GtkWidget* table, int row, int col) : Pocket(table)
110
_red_pixmap = CreateFromXpm(left_red_xpm);
111
_green_pixmap = CreateFromXpm(left_green_xpm);
112
_blue_pixmap = CreateFromXpm(left_blue_xpm);
113
_yellow_pixmap = CreateFromXpm(left_yellow_xpm);
114
InsertInTable(row, col, _red_pixmap);
118
83
LeftPocket::MoveBall(Ball* ball)
132
97
_ball->SetDirection(Ball::MovingRight);
135
UpperPocket::UpperPocket(GtkWidget* table, int row, int col) : Pocket(table)
137
_red_pixmap = CreateFromXpm(upper_red_xpm);
138
_green_pixmap = CreateFromXpm(upper_green_xpm);
139
_blue_pixmap = CreateFromXpm(upper_blue_xpm);
140
_yellow_pixmap = CreateFromXpm(upper_yellow_xpm);
141
InsertInTable(row, col, _red_pixmap);
145
101
UpperPocket::MoveBall(Ball* ball)
159
115
_ball->SetDirection(Ball::MovingDown);
162
RightPocket::RightPocket(GtkWidget* table, int row, int col) : Pocket(table)
164
_red_pixmap = CreateFromXpm(right_red_xpm);
165
_green_pixmap = CreateFromXpm(right_green_xpm);
166
_blue_pixmap = CreateFromXpm(right_blue_xpm);
167
_yellow_pixmap = CreateFromXpm(right_yellow_xpm);
168
InsertInTable(row, col, _red_pixmap);
172
119
RightPocket::MoveBall(Ball* ball)
186
133
_ball->SetDirection(Ball::MovingLeft);
189
LowerPocket::LowerPocket(GtkWidget* table, int row, int col) : Pocket(table)
191
_red_pixmap = CreateFromXpm(lower_red_xpm);
192
_green_pixmap = CreateFromXpm(lower_green_xpm);
193
_blue_pixmap = CreateFromXpm(lower_blue_xpm);
194
_yellow_pixmap = CreateFromXpm(lower_yellow_xpm);
195
InsertInTable(row, col, _red_pixmap);
199
137
LowerPocket::MoveBall(Ball* ball)