Rev 7096 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7089 | leency | 1 | struct _colors |
2 | { |
||
3 | int x,y; |
||
4 | unsigned rows, columns; |
||
5 | unsigned cell_size; |
||
6 | dword mas[MAX_COLORS*MAX_COLORS]; |
||
7 | dword image; |
||
8 | void set_default_values(); |
||
9 | void set_color(); |
||
10 | dword get_color(); |
||
11 | dword get_image(); |
||
12 | void draw_cell(); |
||
13 | void draw_all_cells(); |
||
7096 | leency | 14 | void move(); |
7089 | leency | 15 | } colors; |
16 | |||
17 | void _colors::set_default_values() |
||
18 | { |
||
19 | columns = 2; |
||
20 | rows = 2; |
||
21 | cell_size = 20; |
||
22 | |||
23 | set_color(0,0, 0x66b2ff); |
||
24 | set_color(0,1, 0x000066); |
||
25 | |||
26 | set_color(1,0, 0x000066); |
||
27 | set_color(1,1, 0x66b2ff); |
||
28 | } |
||
29 | |||
30 | void _colors::set_color(int _r, _c, _color) |
||
31 | { |
||
32 | mas[MAX_COLORS*_r + _c] = _color; |
||
33 | } |
||
34 | |||
35 | dword _colors::get_color(int _r, _c) |
||
36 | { |
||
37 | return mas[MAX_COLORS*_r + _c]; |
||
38 | } |
||
39 | |||
40 | dword _colors::get_image() |
||
41 | { |
||
42 | int r=0, c=0; |
||
43 | dword i; |
||
44 | |||
45 | free(image); |
||
46 | i = image = malloc(rows*columns*3); |
||
47 | |||
48 | for (r = 0; r < rows; r++) |
||
49 | { |
||
50 | for (c = 0; c < columns; c++) |
||
51 | { |
||
52 | rgb.DwordToRgb(get_color(r,c)); |
||
53 | ESBYTE[i] = rgb.b; |
||
54 | ESBYTE[i+1] = rgb.g; |
||
55 | ESBYTE[i+2] = rgb.r; |
||
56 | i += 3; |
||
57 | } |
||
58 | } |
||
59 | return image; |
||
60 | } |
||
61 | |||
62 | void _colors::draw_cell(int _x, _y, _color) |
||
63 | { |
||
7096 | leency | 64 | //DrawRectangle(_x, _y, cell_size, cell_size, system.color.work_graph); |
65 | //DrawBar(_x+1, _y+1, cell_size-1, cell_size-1, _color); |
||
66 | DrawBar(_x, _y, cell_size, cell_size, _color); |
||
7089 | leency | 67 | } |
68 | |||
69 | void _colors::draw_all_cells() |
||
70 | { |
||
71 | int r, c, i; |
||
72 | for (i=300; i |
||
73 | for (r = 0; r < rows; r++) |
||
74 | { |
||
75 | for (c = 0; c < columns; c++) |
||
76 | { |
||
77 | draw_cell(c*cell_size + x, r*cell_size + y, get_color(r, c)); |
||
7096 | leency | 78 | DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME); |
7089 | leency | 79 | } |
80 | } |
||
81 | } |
||
82 | |||
7096 | leency | 83 | enum { |
84 | DIRECTION_LEFT, |
||
85 | DIRECTION_RIGHT, |
||
86 | DIRECTION_UP, |
||
87 | DIRECTION_DOWN |
||
88 | }; |
||
89 | void _colors::move(int direction) |
||
90 | { |
||
91 | int r, c; |
||
92 | dword first_element_data; |
||
93 | |||
94 | if (direction == DIRECTION_LEFT) |
||
95 | { |
||
96 | for (r = 0; r < rows; r++) |
||
97 | { |
||
98 | first_element_data = get_color(r, 0); |
||
99 | for (c = 0; c < columns-1; c++) set_color(r, c, get_color(r, c+1)); |
||
100 | set_color(r, columns-1, first_element_data); |
||
101 | } |
||
102 | } |
||
103 | if (direction == DIRECTION_RIGHT) |
||
104 | { |
||
105 | for (r = 0; r < rows; r++) |
||
106 | { |
||
107 | first_element_data = get_color(r, columns-1); |
||
108 | for (c = columns-1; c > 0; c--) set_color(r, c, get_color(r, c-1)); |
||
109 | set_color(r, 0, first_element_data); |
||
110 | } |
||
111 | } |
||
7147 | leency | 112 | if (direction == DIRECTION_UP) |
113 | { |
||
114 | for (c = 0; c < columns; c++) |
||
115 | { |
||
116 | first_element_data = get_color(0, c); |
||
117 | for (r = 0; r < rows-1; r++) set_color(r, c, get_color(r+1, c)); |
||
118 | set_color(rows-1, c, first_element_data); |
||
119 | } |
||
120 | } |
||
121 | if (direction == DIRECTION_DOWN) |
||
122 | { |
||
123 | for (c = 0; c < columns; c++) |
||
124 | { |
||
125 | first_element_data = get_color(rows-1, c); |
||
126 | for (r = rows-1; r > 0; r--) set_color(r, c, get_color(r-1, c)); |
||
127 | set_color(0, c, first_element_data); |
||
128 | } |
||
129 | } |
||
7096 | leency | 130 | |
131 | draw_all_cells(); |
||
132 | }>>>>>>>>>> |
||
7147 | leency | 133 |