summaryrefslogtreecommitdiff
authorerik <erik>2007-01-24 23:29:42 (UTC)
committer erik <erik>2007-01-24 23:29:42 (UTC)
commit0076a11b467dce1233194ce228287a2a127b1f5d (patch) (unidiff)
treef2136a1a3e9b5fd6bede52251ed7249365838752
parent48d9219a96096cf44df8ac24413b36d1b718b1d5 (diff)
downloadopie-0076a11b467dce1233194ce228287a2a127b1f5d.zip
opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.gz
opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.bz2
Each file in this commit has the issue where it is possible for code to
overrun static buffers. This could lead to serious problems. Granted it is almost impossible to do that. But it isn't totally impossible. So this commit makes it impossible to overrun.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/moveengine.cpp6
-rw-r--r--noncore/games/kbill/UI.cpp31
-rw-r--r--noncore/games/kcheckers/echeckers.cpp12
-rw-r--r--noncore/games/kcheckers/rcheckers.cpp36
-rw-r--r--noncore/settings/sysinfo/contrib/fft.c2
-rw-r--r--noncore/styles/theme/othemebase.cpp2
6 files changed, 51 insertions, 38 deletions
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp
index a4145cc..b102258 100644
--- a/noncore/games/backgammon/moveengine.cpp
+++ b/noncore/games/backgammon/moveengine.cpp
@@ -1,557 +1,559 @@
1#include "moveengine.h" 1#include "moveengine.h"
2 2
3#include <qtimer.h> 3#include <qtimer.h>
4#include <stdlib.h> 4#include <stdlib.h>
5 5
6MoveEngine::MoveEngine() 6MoveEngine::MoveEngine()
7 : QObject() 7 : QObject()
8{ 8{
9 int offset=7; 9 int offset=7;
10 int a=0; //counter variable 10 int a=0; //counter variable
11 int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210}; 11 int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210};
12 for(a=0;a<26;a++) 12 for(a=0;a<26;a++)
13 { 13 {
14 x_coord[a]=xfill[a]; 14 x_coord[a]=xfill[a];
15 } 15 }
16 16
17 int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40}; 17 int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40};
18 int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5}; 18 int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5};
19 for(a=0;a<15;a++) 19 for(a=0;a<15;a++)
20 { 20 {
21 yup_coord[a]=yfill[a]; 21 yup_coord[a]=yfill[a];
22 ylow_coord[a]=185-(yfill[a]); 22 ylow_coord[a]=185-(yfill[a]);
23 z_coord[a]=zfill[a]; 23 z_coord[a]=zfill[a];
24 } 24 }
25 for(a=0;a<5;a++) 25 for(a=0;a<5;a++)
26 { 26 {
27 if(a<3) 27 if(a<3)
28 { 28 {
29 x_fin1[a]=65+a*15; 29 x_fin1[a]=65+a*15;
30 x_fin2[a]=155-a*15; 30 x_fin2[a]=155-a*15;
31 } 31 }
32 y_fin[a]=225-a*5; 32 y_fin[a]=225-a*5;
33 } 33 }
34 z_fin=1; 34 z_fin=1;
35 35
36 reset(); 36 reset();
37} 37}
38 38
39MoveEngine::~MoveEngine() 39MoveEngine::~MoveEngine()
40{} 40{}
41 41
42void MoveEngine::position(Pieces& pieces,bool non_qte) 42void MoveEngine::position(Pieces& pieces,bool non_qte)
43{ 43{
44 int player1_counter=0; 44 int player1_counter=0;
45 int player2_counter=0; 45 int player2_counter=0;
46 46
47 //non qte styles are smaller !! 47 //non qte styles are smaller !!
48 int offset=(non_qte) ? 5 : 0; 48 int offset=(non_qte) ? 5 : 0;
49 49
50 for(int a=0;a<28;a++) 50 for(int a=0;a<28;a++)
51 { 51 {
52 for(int b=0;b<abs(population[a].total);b++) 52 for(int b=0;b<abs(population[a].total);b++)
53 { 53 {
54 if(population[a].total>0) //player 1 pieces 54 if(population[a].total>0) //player 1 pieces
55 { 55 {
56 pieces.player1[player1_counter].x=x_coord[a]-offset; 56 if (a < 26)
57 pieces.player1[player1_counter].x=x_coord[a]-offset;
57 if(a>=0 && a<13) 58 if(a>=0 && a<13)
58 { 59 {
59 pieces.player1[player1_counter].y=yup_coord[b]-offset; 60 pieces.player1[player1_counter].y=yup_coord[b]-offset;
60 pieces.player1[player1_counter].z=z_coord[b]; 61 pieces.player1[player1_counter].z=z_coord[b];
61 pieces.player1[player1_counter].side=false; 62 pieces.player1[player1_counter].side=false;
62 player1_counter++; 63 player1_counter++;
63 } 64 }
64 else if(a>12 && a<26) 65 else if(a>12 && a<26)
65 { 66 {
66 pieces.player1[player1_counter].y=ylow_coord[b]-offset; 67 pieces.player1[player1_counter].y=ylow_coord[b]-offset;
67 pieces.player1[player1_counter].z=z_coord[b]; 68 pieces.player1[player1_counter].z=z_coord[b];
68 pieces.player1[player1_counter].side=false; 69 pieces.player1[player1_counter].side=false;
69 player1_counter++; 70 player1_counter++;
70 } 71 }
71 else if(a==26) 72 else if(a==26)
72 { 73 {
73 if(b<5) 74 if(b<5)
74 { 75 {
75 pieces.player1[player1_counter].x=x_fin1[0]-offset; 76 pieces.player1[player1_counter].x=x_fin1[0]-offset;
76 pieces.player1[player1_counter].y=y_fin[b]-offset; 77 pieces.player1[player1_counter].y=y_fin[b]-offset;
77 pieces.player1[player1_counter].z=z_fin; 78 pieces.player1[player1_counter].z=z_fin;
78 } 79 }
79 else if(b>=5 && b<10) 80 else if(b>=5 && b<10)
80 { 81 {
81 pieces.player1[player1_counter].x=x_fin1[1]-offset; 82 pieces.player1[player1_counter].x=x_fin1[1]-offset;
82 pieces.player1[player1_counter].y=y_fin[b-5]-offset; 83 pieces.player1[player1_counter].y=y_fin[b-5]-offset;
83 pieces.player1[player1_counter].z=z_fin; 84 pieces.player1[player1_counter].z=z_fin;
84 } 85 }
85 else 86 else
86 { 87 {
87 pieces.player1[player1_counter].x=x_fin1[2]-offset; 88 pieces.player1[player1_counter].x=x_fin1[2]-offset;
88 pieces.player1[player1_counter].y=y_fin[b-10]-offset; 89 pieces.player1[player1_counter].y=y_fin[b-10]-offset;
89 pieces.player1[player1_counter].z=z_fin; 90 pieces.player1[player1_counter].z=z_fin;
90 } 91 }
91 pieces.player1[player1_counter].side=true; 92 pieces.player1[player1_counter].side=true;
92 player1_counter++; 93 player1_counter++;
93 94
94 } 95 }
95 } 96 }
96 97
97 else if(population[a].total<0) //player 2 pieces 98 else if(population[a].total<0) //player 2 pieces
98 { 99 {
99 pieces.player2[player2_counter].x=x_coord[a]-offset; 100 if (a < 26)
101 pieces.player2[player2_counter].x=x_coord[a]-offset;
100 if(a>=0 && a<13) 102 if(a>=0 && a<13)
101 { 103 {
102 pieces.player2[player2_counter].y=yup_coord[b]-offset; 104 pieces.player2[player2_counter].y=yup_coord[b]-offset;
103 pieces.player2[player2_counter].z=z_coord[b]; 105 pieces.player2[player2_counter].z=z_coord[b];
104 pieces.player2[player2_counter].side=false; 106 pieces.player2[player2_counter].side=false;
105 player2_counter++; 107 player2_counter++;
106 } 108 }
107 else if(a>12 && a<26) 109 else if(a>12 && a<26)
108 { 110 {
109 pieces.player2[player2_counter].y=ylow_coord[b]-offset; 111 pieces.player2[player2_counter].y=ylow_coord[b]-offset;
110 pieces.player2[player2_counter].z=z_coord[b]; 112 pieces.player2[player2_counter].z=z_coord[b];
111 pieces.player2[player2_counter].side=false; 113 pieces.player2[player2_counter].side=false;
112 player2_counter++; 114 player2_counter++;
113 } 115 }
114 else if(a==27) 116 else if(a==27)
115 { 117 {
116 if(b<5) 118 if(b<5)
117 { 119 {
118 pieces.player2[player2_counter].x=x_fin2[0]-offset; 120 pieces.player2[player2_counter].x=x_fin2[0]-offset;
119 pieces.player2[player2_counter].y=y_fin[b]-offset; 121 pieces.player2[player2_counter].y=y_fin[b]-offset;
120 pieces.player2[player2_counter].z=z_fin; 122 pieces.player2[player2_counter].z=z_fin;
121 } 123 }
122 else if(b>=5 && b<10) 124 else if(b>=5 && b<10)
123 { 125 {
124 pieces.player2[player2_counter].x=x_fin2[1]-offset; 126 pieces.player2[player2_counter].x=x_fin2[1]-offset;
125 pieces.player2[player2_counter].y=y_fin[b-5]-offset; 127 pieces.player2[player2_counter].y=y_fin[b-5]-offset;
126 pieces.player2[player2_counter].z=z_fin; 128 pieces.player2[player2_counter].z=z_fin;
127 } 129 }
128 else 130 else
129 { 131 {
130 pieces.player2[player2_counter].x=x_fin2[2]-offset; 132 pieces.player2[player2_counter].x=x_fin2[2]-offset;
131 pieces.player2[player2_counter].y=y_fin[b-10]-offset; 133 pieces.player2[player2_counter].y=y_fin[b-10]-offset;
132 pieces.player2[player2_counter].z=z_fin; 134 pieces.player2[player2_counter].z=z_fin;
133 } 135 }
134 pieces.player2[player2_counter].side=true; 136 pieces.player2[player2_counter].side=true;
135 player2_counter++; 137 player2_counter++;
136 138
137 } 139 }
138 } 140 }
139 } 141 }
140 } 142 }
141} 143}
142 144
143void MoveEngine::diceroll(const int& newplayer,const int& face1,const int& face2,const int& face3,const int& face4,bool computer) 145void MoveEngine::diceroll(const int& newplayer,const int& face1,const int& face2,const int& face3,const int& face4,bool computer)
144{ 146{
145 checkstate(); 147 checkstate();
146 player=newplayer; 148 player=newplayer;
147 otherplayer=(player==1) ? 2 : 1; 149 otherplayer=(player==1) ? 2 : 1;
148 dice[0]=face1; 150 dice[0]=face1;
149 dice[1]=face2; 151 dice[1]=face2;
150 dice[2]=face3; 152 dice[2]=face3;
151 dice[3]=face4; 153 dice[3]=face4;
152 marker_current=-1; 154 marker_current=-1;
153 if(getPossibleMoves()==0) 155 if(getPossibleMoves()==0)
154 { 156 {
155 emit nomove(); 157 emit nomove();
156 return; // player will be changed 158 return; // player will be changed
157 } 159 }
158 if(!computer) 160 if(!computer)
159 return; //human intervention required 161 return; //human intervention required
160 162
161 QTimer::singleShot(2000,this,SLOT(automove())); 163 QTimer::singleShot(2000,this,SLOT(automove()));
162} 164}
163 165
164 166
165void MoveEngine::automove() 167void MoveEngine::automove()
166{ 168{
167 //the maximimum possibility 169 //the maximimum possibility
168 int maxpos=0; 170 int maxpos=0;
169 //the position in the moves array 171 //the position in the moves array
170 int from=-1; 172 int from=-1;
171 int to=-1; 173 int to=-1;
172 //dice1 or dice 2 ?? 174 //dice1 or dice 2 ??
173 int index_dice=0; 175 int index_dice=0;
174 for(int counter=0;counter<26;counter++) 176 for(int counter=0;counter<26;counter++)
175 { 177 {
176 int a=(player==1) ? counter : 25-counter; 178 int a=(player==1) ? counter : 25-counter;
177 for(int b=0;b<4;b++) 179 for(int b=0;b<4;b++)
178 { 180 {
179 if(moves[a].weight[b]>maxpos) 181 if(moves[a].weight[b]>maxpos)
180 { 182 {
181 maxpos=moves[a].weight[b]; 183 maxpos=moves[a].weight[b];
182 from=a; 184 from=a;
183 to=moves[a].to[b]; 185 to=moves[a].to[b];
184 index_dice=b+1; 186 index_dice=b+1;
185 } 187 }
186 } 188 }
187 } 189 }
188 move(from,to,index_dice); 190 move(from,to,index_dice);
189} 191}
190 192
191 193
192void MoveEngine::boardpressed(const int& x,const int& y,Marker& marker,bool non_qte) 194void MoveEngine::boardpressed(const int& x,const int& y,Marker& marker,bool non_qte)
193{ 195{
194 //get the position of the mouse click 196 //get the position of the mouse click
195 bool upper=true; 197 bool upper=true;
196 bool found=false; 198 bool found=false;
197 199
198 int offset=(non_qte) ? 5 : 0; 200 int offset=(non_qte) ? 5 : 0;
199 201
200 if(y<=85) // board slots 0 to 12 202 if(y<=85) // board slots 0 to 12
201 marker.y_current=0; 203 marker.y_current=0;
202 else if(y>=105) //board slots 13 to 25 204 else if(y>=105) //board slots 13 to 25
203 { 205 {
204 marker.y_current=195-2*offset; 206 marker.y_current=195-2*offset;
205 upper=false; 207 upper=false;
206 } 208 }
207 209
208 int index=13; // the clicked board slot 210 int index=13; // the clicked board slot
209 211
210 while(index<25 && !found) 212 while(index<25 && !found)
211 { 213 {
212 if(x>=x_coord[index] && x<x_coord[index+1]) 214 if(x>=x_coord[index] && x<x_coord[index+1])
213 { 215 {
214 marker.x_current=x_coord[index]; 216 marker.x_current=x_coord[index];
215 found=true; 217 found=true;
216 ; 218 ;
217 } 219 }
218 else 220 else
219 { 221 {
220 index++; 222 index++;
221 } 223 }
222 } 224 }
223 if(!found) 225 if(!found)
224 { 226 {
225 marker.x_current=x_coord[25]; 227 marker.x_current=x_coord[25];
226 index=25; 228 index=25;
227 } 229 }
228 if(upper) 230 if(upper)
229 { 231 {
230 index=25-index; 232 index=25-index;
231 } 233 }
232 234
233 int a=0; 235 int a=0;
234 int usedice=-1; 236 int usedice=-1;
235 int dice_value=7; 237 int dice_value=7;
236 for(a=0;a<4;a++) 238 for(a=0;a<4;a++)
237 { 239 {
238 if(index==marker_next[a] && marker_next[a]!=-1 && dice_value>dice[a]) 240 if(index==marker_next[a] && marker_next[a]!=-1 && dice_value>dice[a])
239 { 241 {
240 usedice=a; 242 usedice=a;
241 dice_value=dice[0]; 243 dice_value=dice[0];
242 } 244 }
243 } 245 }
244 if(usedice!=-1) 246 if(usedice!=-1)
245 { 247 {
246 move(marker_current,marker_next[usedice],usedice+1); 248 move(marker_current,marker_next[usedice],usedice+1);
247 nomarker(marker); 249 nomarker(marker);
248 return; 250 return;
249 251
250 } 252 }
251 253
252 254
253 if(dice[0]==7 && dice[1]==7 && dice[2]==7 && dice[3]==7) //no dice rolled 255 if(dice[0]==7 && dice[1]==7 && dice[2]==7 && dice[3]==7) //no dice rolled
254 { 256 {
255 nomarker(marker); 257 nomarker(marker);
256 return; 258 return;
257 } 259 }
258 else if(fieldColor(index)==player) 260 else if(fieldColor(index)==player)
259 { 261 {
260 marker.visible_current=true; 262 marker.visible_current=true;
261 marker_current=index; 263 marker_current=index;
262 } 264 }
263 else 265 else
264 { 266 {
265 nomarker(marker); 267 nomarker(marker);
266 return; 268 return;
267 } 269 }
268 270
269 for(a=0;a<4;a++) 271 for(a=0;a<4;a++)
270 { 272 {
271 if(moves[index].weight[a]>0) 273 if(moves[index].weight[a]>0)
272 { 274 {
273 int nextfield=moves[index].to[a]; 275 int nextfield=moves[index].to[a];
274 marker.x_next[a]=x_coord[nextfield]; 276 marker.x_next[a]=x_coord[nextfield];
275 marker_next[a]=nextfield; 277 marker_next[a]=nextfield;
276 if(nextfield<13) //upper half 278 if(nextfield<13) //upper half
277 marker.y_next[a]=0; 279 marker.y_next[a]=0;
278 else //lower half 280 else //lower half
279 marker.y_next[a]=195-2*offset; 281 marker.y_next[a]=195-2*offset;
280 marker.visible_next[a]=true; 282 marker.visible_next[a]=true;
281 } 283 }
282 else 284 else
283 { 285 {
284 marker.x_next[a]=0; 286 marker.x_next[a]=0;
285 marker.y_next[a]=0; 287 marker.y_next[a]=0;
286 marker_next[a]=-1; 288 marker_next[a]=-1;
287 marker.visible_next[a]=false; 289 marker.visible_next[a]=false;
288 } 290 }
289 } 291 }
290 return; 292 return;
291} 293}
292 294
293void MoveEngine::reset() 295void MoveEngine::reset()
294{ 296{
295 int a=0; 297 int a=0;
296 for(a=0;a<28;a++) 298 for(a=0;a<28;a++)
297 { 299 {
298 population[a].total=0; 300 population[a].total=0;
299 } 301 }
300 302
301 int p1_index[]={1,1,12,12,12,12,12,17,17,17,19,19,19,19,19}; 303 int p1_index[]={1,1,12,12,12,12,12,17,17,17,19,19,19,19,19};
302 int p2_index[]={24,24,13,13,13,13,13,8,8,8,6,6,6,6,6}; 304 int p2_index[]={24,24,13,13,13,13,13,8,8,8,6,6,6,6,6};
303 //int p1_index[]={19,20,21,22,22,23,23,18,18,23,24,24,24,24,24}; 305 //int p1_index[]={19,20,21,22,22,23,23,18,18,23,24,24,24,24,24};
304 //int p2_index[]={6,5,4,3,3,2,2,2,2,2,1,7,7,1,1}; 306 //int p2_index[]={6,5,4,3,3,2,2,2,2,2,1,7,7,1,1};
305 for(a=0;a<15;a++) 307 for(a=0;a<15;a++)
306 { 308 {
307 population[p1_index[a]].total++; 309 population[p1_index[a]].total++;
308 population[p2_index[a]].total--; 310 population[p2_index[a]].total--;
309 } 311 }
310 312
311 player=0; 313 player=0;
312 dice[0]=7; 314 dice[0]=7;
313 dice[1]=7; 315 dice[1]=7;
314 dice[2]=7; 316 dice[2]=7;
315 dice[3]=7; 317 dice[3]=7;
316 318
317 marker_current=-1; 319 marker_current=-1;
318 marker_next[0]=-1; 320 marker_next[0]=-1;
319 marker_next[1]=-1; 321 marker_next[1]=-1;
320 marker_next[2]=-1; 322 marker_next[2]=-1;
321 marker_next[3]=-1; 323 marker_next[3]=-1;
322 //allclear[0]==false; 324 //allclear[0]==false;
323 allclear[1]=false; 325 allclear[1]=false;
324 allclear[2]=false; 326 allclear[2]=false;
325 last_piece[1]=0; 327 last_piece[1]=0;
326 last_piece[2]=25; 328 last_piece[2]=25;
327} 329}
328 330
329void MoveEngine::loadGame(const LoadSave& load) 331void MoveEngine::loadGame(const LoadSave& load)
330{ 332{
331 for(int a=0;a<28;a++) 333 for(int a=0;a<28;a++)
332 { 334 {
333 population[a].total=load.pop[a].total; 335 population[a].total=load.pop[a].total;
334 } 336 }
335 checkstate(); 337 checkstate();
336} 338}
337 339
338LoadSave MoveEngine::saveGame() 340LoadSave MoveEngine::saveGame()
339{ 341{
340 LoadSave save; 342 LoadSave save;
341 for(int a=0;a<28;a++) 343 for(int a=0;a<28;a++)
342 { 344 {
343 save.pop[a].total=population[a].total; 345 save.pop[a].total=population[a].total;
344 } 346 }
345 return save; 347 return save;
346} 348}
347 349
348AISettings MoveEngine::getAISettings() 350AISettings MoveEngine::getAISettings()
349{ 351{
350 return ai; 352 return ai;
351} 353}
352 354
353void MoveEngine::setAISettings(const AISettings& new_ai) 355void MoveEngine::setAISettings(const AISettings& new_ai)
354{ 356{
355 ai=new_ai; 357 ai=new_ai;
356} 358}
357 359
358void MoveEngine::setRules(Rules rules) 360void MoveEngine::setRules(Rules rules)
359{ 361{
360 move_with_pieces_out=rules.move_with_pieces_out; 362 move_with_pieces_out=rules.move_with_pieces_out;
361 nice_dice=rules.generous_dice; 363 nice_dice=rules.generous_dice;
362} 364}
363 365
364 366
365int MoveEngine::getPossibleMoves() 367int MoveEngine::getPossibleMoves()
366{ 368{
367 int homezone[]={0,25,0}; 369 int homezone[]={0,25,0};
368 int lastToHomeZone=abs(last_piece[player]-homezone[player]); 370 int lastToHomeZone=abs(last_piece[player]-homezone[player]);
369 for(int field=0;field<26;field++) 371 for(int field=0;field<26;field++)
370 { 372 {
371 373
372 for(int b=0;b<4;b++) 374 for(int b=0;b<4;b++)
373 { 375 {
374 int dice_tmp=dice[b]; 376 int dice_tmp=dice[b];
375 if(dice[b]!=7 && dice[b]> lastToHomeZone) 377 if(dice[b]!=7 && dice[b]> lastToHomeZone)
376 dice_tmp=lastToHomeZone; 378 dice_tmp=lastToHomeZone;
377 379
378 int nextfield=(player==1) ? field+dice_tmp : field-dice_tmp; 380 int nextfield=(player==1) ? field+dice_tmp : field-dice_tmp;
379 381
380 if(nice_dice) 382 if(nice_dice)
381 { 383 {
382 if(player==1 && nextfield>homezone[1]) 384 if(player==1 && nextfield>homezone[1])
383 nextfield=homezone[1]; 385 nextfield=homezone[1];
384 else if(player==2 && nextfield<homezone[2]) 386 else if(player==2 && nextfield<homezone[2])
385 nextfield=homezone[2]; 387 nextfield=homezone[2];
386 } 388 }
387 389
388 moves[field].weight[b]=0; 390 moves[field].weight[b]=0;
389 moves[field].to[b]=nextfield; 391 moves[field].to[b]=nextfield;
390 392
391 int out_of_board[]={-1,0,25}; 393 int out_of_board[]={-1,0,25};
392 if(!move_with_pieces_out && field!=out_of_board[player] && pieces_out[player]) 394 if(!move_with_pieces_out && field!=out_of_board[player] && pieces_out[player])
393 { 395 {
394 continue; 396 continue;
395 } 397 }
396 398
397 399
398 400
399 if(dice[b]!=7 && fieldColor(field)==player ) //player can only move his own pieces 401 if(dice[b]!=7 && fieldColor(field)==player ) //player can only move his own pieces
400 { 402 {
401 if((player==1 && nextfield > homezone[1]) || (player==2 && nextfield < homezone[2])) 403 if((player==1 && nextfield > homezone[1]) || (player==2 && nextfield < homezone[2]))
402 { 404 {
403 moves[field].weight[b]=0; //movement would be far out of board 405 moves[field].weight[b]=0; //movement would be far out of board
404 } 406 }
405 else if(nextfield==homezone[player] && !allclear[player]) 407 else if(nextfield==homezone[player] && !allclear[player])
406 { 408 {
407 moves[field].weight[b]=0; //can not rescue pieces until all are in the endzone 409 moves[field].weight[b]=0; //can not rescue pieces until all are in the endzone
408 } 410 }
409 else if(nextfield==homezone[player] && allclear[player]) 411 else if(nextfield==homezone[player] && allclear[player])
410 { 412 {
411 moves[field].weight[b]=ai.rescue; //rescue your pieces : nuff said ;-) 413 moves[field].weight[b]=ai.rescue; //rescue your pieces : nuff said ;-)
412 } 414 }
413 else if(fieldColor(nextfield)==otherplayer) 415 else if(fieldColor(nextfield)==otherplayer)
414 { 416 {
415 if(abs(population[nextfield].total)>1) //can not move to this field 417 if(abs(population[nextfield].total)>1) //can not move to this field
416 moves[field].weight[b]=0; 418 moves[field].weight[b]=0;
417 else if(abs(population[nextfield].total)==1) //eliminate opponent : very nice 419 else if(abs(population[nextfield].total)==1) //eliminate opponent : very nice
418 moves[field].weight[b]=ai.eliminate; 420 moves[field].weight[b]=ai.eliminate;
419 } 421 }
420 else if(fieldColor(nextfield)==player) //nextfield already occupied by player 422 else if(fieldColor(nextfield)==player) //nextfield already occupied by player
421 { 423 {
422 if(abs(population[field].total)==2) //expose own piece : not diserable 424 if(abs(population[field].total)==2) //expose own piece : not diserable
423 moves[field].weight[b]=ai.expose; 425 moves[field].weight[b]=ai.expose;
424 else if(abs(population[nextfield].total)>1) //own pices already there : safe 426 else if(abs(population[nextfield].total)>1) //own pices already there : safe
425 moves[field].weight[b]=ai.safe; 427 moves[field].weight[b]=ai.safe;
426 else if(abs(population[nextfield].total)==1) //protect own piece : most importatnt 428 else if(abs(population[nextfield].total)==1) //protect own piece : most importatnt
427 moves[field].weight[b]=ai.protect; 429 moves[field].weight[b]=ai.protect;
428 } 430 }
429 else if(population[nextfield].total==0) //nextfield empty 431 else if(population[nextfield].total==0) //nextfield empty
430 { 432 {
431 if(abs(population[field].total)==2) //expose own piece : not diserable 433 if(abs(population[field].total)==2) //expose own piece : not diserable
432 moves[field].weight[b]=ai.expose; 434 moves[field].weight[b]=ai.expose;
433 else 435 else
434 moves[field].weight[b]=ai.empty; 436 moves[field].weight[b]=ai.empty;
435 } 437 }
436 else 438 else
437 moves[field].weight[b]=0; //default. 439 moves[field].weight[b]=0; //default.
438 } 440 }
439 441
440 442
441 443
442 else 444 else
443 moves[field].weight[b]=0; //dice already used or field not used by player 445 moves[field].weight[b]=0; //dice already used or field not used by player
444 } 446 }
445 447
446 448
447 449
448 } 450 }
449 451
450 int total=0; 452 int total=0;
451 for(int field=0;field<26;field++) 453 for(int field=0;field<26;field++)
452 { 454 {
453 total+=moves[field].weight[0]+moves[field].weight[1]+moves[field].weight[2]+moves[field].weight[3]; 455 total+=moves[field].weight[0]+moves[field].weight[1]+moves[field].weight[2]+moves[field].weight[3];
454 } 456 }
455 return total; 457 return total;
456} 458}
457 459
458void MoveEngine::move(const int& from, int to, const int& dice) 460void MoveEngine::move(const int& from, int to, const int& dice)
459{ 461{
460 //odebug << "" << player << " moves from " << from << " to " << to << " (" << to-from << ") with dice " << dice << "" << oendl; 462 //odebug << "" << player << " moves from " << from << " to " << to << " (" << to-from << ") with dice " << dice << "" << oendl;
461 463
462 if(player==1 && to==25) 464 if(player==1 && to==25)
463 to=26; 465 to=26;
464 if(player==2 && to==0) 466 if(player==2 && to==0)
465 to=27; 467 to=27;
466 468
467 //if space is occupied by enemy move pieces to startzone 469 //if space is occupied by enemy move pieces to startzone
468 if(fieldColor(to)==otherplayer) 470 if(fieldColor(to)==otherplayer)
469 { 471 {
470 population[to].total=0; 472 population[to].total=0;
471 if(otherplayer==1) 473 if(otherplayer==1)
472 population[0].total++; 474 population[0].total++;
473 else 475 else
474 population[25].total--; 476 population[25].total--;
475 } 477 }
476 478
477 if(player==1) 479 if(player==1)
478 { 480 {
479 population[from].total--; 481 population[from].total--;
480 population[to].total++; 482 population[to].total++;
481 } 483 }
482 else //player=2 484 else //player=2
483 { 485 {
484 population[from].total++; 486 population[from].total++;
485 population[to].total--; 487 population[to].total--;
486 } 488 }
487 489
488 if(dice==1) 490 if(dice==1)
489 emit done_dice1(); 491 emit done_dice1();
490 else if(dice==2) 492 else if(dice==2)
491 emit done_dice2(); 493 emit done_dice2();
492 else if(dice==3) 494 else if(dice==3)
493 emit done_dice3(); 495 emit done_dice3();
494 else 496 else
495 emit done_dice4(); 497 emit done_dice4();
496 498
497 if(abs(population[26].total)==15) 499 if(abs(population[26].total)==15)
498 emit player_finished(1); 500 emit player_finished(1);
499 if(abs(population[27].total)==15) 501 if(abs(population[27].total)==15)
500 emit player_finished(2); 502 emit player_finished(2);
501} 503}
502 504
503void MoveEngine::checkstate() 505void MoveEngine::checkstate()
504{ 506{
505 //check if pieces are out 507 //check if pieces are out
506 pieces_out[1]=(population[0].total>0) ? true : false; 508 pieces_out[1]=(population[0].total>0) ? true : false;
507 pieces_out[2]=(population[25].total<0) ? true : false; 509 pieces_out[2]=(population[25].total<0) ? true : false;
508 510
509 //check if all pieces are in the endzones 511 //check if all pieces are in the endzones
510 allclear[1]=true; 512 allclear[1]=true;
511 allclear[2]=true; 513 allclear[2]=true;
512 514
513 last_piece[1]=25; 515 last_piece[1]=25;
514 bool found_last_piece1=false; 516 bool found_last_piece1=false;
515 last_piece[2]=0; 517 last_piece[2]=0;
516 518
517 for(int a=0;a<26;a++) 519 for(int a=0;a<26;a++)
518 { 520 {
519 if(a<19 && population[a].total>0) 521 if(a<19 && population[a].total>0)
520 allclear[1]=false; 522 allclear[1]=false;
521 if(a>6 && population[a].total<0) 523 if(a>6 && population[a].total<0)
522 allclear[2]=false; 524 allclear[2]=false;
523 525
524 if(population[a].total>0 && !found_last_piece1) 526 if(population[a].total>0 && !found_last_piece1)
525 { 527 {
526 last_piece[1]=a; 528 last_piece[1]=a;
527 found_last_piece1=true; 529 found_last_piece1=true;
528 } 530 }
529 if(population[a].total<0) 531 if(population[a].total<0)
530 last_piece[2]=a; 532 last_piece[2]=a;
531 } 533 }
532} 534}
533 535
534void MoveEngine::nomarker(Marker& marker) 536void MoveEngine::nomarker(Marker& marker)
535{ 537{
536 marker.visible_current=false; 538 marker.visible_current=false;
537 marker_current=-1; 539 marker_current=-1;
538 for(int a=0;a<4;a++) 540 for(int a=0;a<4;a++)
539 { 541 {
540 marker.x_next[a]=0; 542 marker.x_next[a]=0;
541 marker.y_next[a]=0; 543 marker.y_next[a]=0;
542 marker_next[a]=-1; 544 marker_next[a]=-1;
543 marker.visible_next[a]=false; 545 marker.visible_next[a]=false;
544 } 546 }
545} 547}
546 548
547int MoveEngine::fieldColor(const int& index) const 549int MoveEngine::fieldColor(const int& index) const
548{ 550{
549 if(population[index].total>0) 551 if(population[index].total>0)
550 return 1; 552 return 1;
551 else if(population[index].total<0) 553 else if(population[index].total<0)
552 return 2; 554 return 2;
553 else 555 else
554 return 0; 556 return 0;
555} 557}
556 558
557 559
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
index 611cebf..a49c3c1 100644
--- a/noncore/games/kbill/UI.cpp
+++ b/noncore/games/kbill/UI.cpp
@@ -1,172 +1,171 @@
1/*************************************************************************** 1/***************************************************************************
2 UI.cc - description 2 UI.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "objects.h" 17#include "objects.h"
18#include "Strings.h" 18#include "Strings.h"
19#ifdef KDEVER 19#ifdef KDEVER
20#include <kapplication.h> 20#include <kapplication.h>
21#endif 21#endif
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23 23
24#include "inputbox.h" 24#include "inputbox.h"
25 25
26/**************************/ 26/**************************/
27/* Timer control routines */ 27/* Timer control routines */
28/**************************/ 28/**************************/
29 29
30UI::~UI() { 30UI::~UI() {
31 paint.end(); 31 paint.end();
32 delete pix; 32 delete pix;
33} 33}
34 34
35void UI::restart_timer() { 35void UI::restart_timer() {
36 field->startTimer(); 36 field->startTimer();
37} 37}
38 38
39void UI::kill_timer() { 39void UI::kill_timer() {
40 field->stopTimer(); 40 field->stopTimer();
41} 41}
42 42
43/*******************/ 43/*******************/
44/* Window routines */ 44/* Window routines */
45/*******************/ 45/*******************/
46 46
47void UI::initialize(int *argc, char **argv) { 47void UI::initialize(int *argc, char **argv) {
48 #ifdef KDEVER 48 #ifdef KDEVER
49 app = new KApplication(*argc, argv, "kbill"); 49 app = new KApplication(*argc, argv, "kbill");
50 #endif 50 #endif
51 app = new QPEApplication(*argc, argv); 51 app = new QPEApplication(*argc, argv);
52} 52}
53 53
54void UI::graph_init() { 54void UI::graph_init() {
55 pix = new QPixmap(Game::scrwidth, Game::scrheight); 55 pix = new QPixmap(Game::scrwidth, Game::scrheight);
56 paint.begin(pix, field); 56 paint.begin(pix, field);
57 paint.setPen(QPen(Qt::black, 3)); 57 paint.setPen(QPen(Qt::black, 3));
58} 58}
59 59
60void UI::make_mainwin() { 60void UI::make_mainwin() {
61 main = new KBill(); 61 main = new KBill();
62 app->showMainWidget(main,true); 62 app->showMainWidget(main,true);
63 main->showMaximized(); 63 main->showMaximized();
64 field = main->getField(); 64 field = main->getField();
65} 65}
66 66
67void UI::popup_dialog (int dialog) { 67void UI::popup_dialog (int dialog) {
68 kill_timer(); 68 kill_timer();
69 switch (dialog) { 69 switch (dialog) {
70 case Game::ENDGAME: 70 case Game::ENDGAME:
71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); 71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
72 break; 72 break;
73 case Game::HIGHSCORE: 73 case Game::HIGHSCORE:
74 //QMessageBox::message(("HighScore"), highscorestr); 74 break;
75 break; 75 case Game::ENTERNAME:
76 case Game::ENTERNAME: { 76 {
77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); 77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr));
78 bool state = b.exec() == 2; 78 bool state = b.exec() == 2;
79 char str[20], *nl; 79 char str[20], *nl;
80 strcpy(str, b.getText()); 80 strncpy(str, b.getText(), 19);
81 if (!str[0] || state) 81 if (!str[0] || state)
82 strcpy(str, "Anonymous"); 82 strcpy(str, "Anonymous");
83 else if ((nl = strchr(str, '\n'))) 83 else if ((nl = strchr(str, '\n')))
84 *nl = '\0'; 84 *nl = '\0';
85 if (strlen(str) > 20) 85 if (strlen(str) > 19)
86 str[20] = 0; /* truncate string if too long */ 86 str[19] = '\0'; /* truncate/terminate the string if it is too long */
87 // scores.recalc(str); 87 }
88 } 88 break;
89 break;
90 case Game::SCORE: 89 case Game::SCORE:
91 QMessageBox::message(("Score"), scorestr); 90 QMessageBox::message(("Score"), scorestr);
92 break; 91 break;
93 } 92 }
94 restart_timer(); 93 restart_timer();
95} 94}
96 95
97/*********************/ 96/*********************/
98/* Graphics routines */ 97/* Graphics routines */
99/*********************/ 98/*********************/
100 99
101void UI::set_cursor(int cursor) { 100void UI::set_cursor(int cursor) {
102 QCursor *cur; 101 QCursor *cur;
103 switch (cursor) { 102 switch (cursor) {
104 case Game::BUCKETC: 103 case Game::BUCKETC:
105 cur = bucket.cursor.cursor; 104 cur = bucket.cursor.cursor;
106 break; 105 break;
107 case Game::DOWNC: 106 case Game::DOWNC:
108 cur = downcursor.cursor; 107 cur = downcursor.cursor;
109 break; 108 break;
110 case Game::DEFAULTC: 109 case Game::DEFAULTC:
111 cur = defaultcursor.cursor; 110 cur = defaultcursor.cursor;
112 break; 111 break;
113 default: 112 default:
114 cur = OS.cursor[cursor].cursor; 113 cur = OS.cursor[cursor].cursor;
115 } 114 }
116 field->setCursor(*cur); 115 field->setCursor(*cur);
117} 116}
118 117
119void UI::load_cursors() { 118void UI::load_cursors() {
120 defaultcursor.load("hand_up", MCursor::SEP_MASK); 119 defaultcursor.load("hand_up", MCursor::SEP_MASK);
121 field->setCursor(*defaultcursor.cursor); 120 field->setCursor(*defaultcursor.cursor);
122 downcursor.load("hand_down", MCursor::SEP_MASK); 121 downcursor.load("hand_down", MCursor::SEP_MASK);
123} 122}
124 123
125void UI::clear() { 124void UI::clear() {
126 paint.eraseRect(0, 0, field->width(), field->height()); 125 paint.eraseRect(0, 0, field->width(), field->height());
127} 126}
128 127
129void UI::refresh() { 128void UI::refresh() {
130 paint.flush(); 129 paint.flush();
131 field->setPixmap(pix); 130 field->setPixmap(pix);
132 field->repaint(FALSE); 131 field->repaint(FALSE);
133} 132}
134 133
135void UI::draw (Picture pict, int x, int y) { 134void UI::draw (Picture pict, int x, int y) {
136 paint.drawPixmap(x, y, *pict.pix); 135 paint.drawPixmap(x, y, *pict.pix);
137} 136}
138 137
139void UI::draw_centered (Picture pict) { 138void UI::draw_centered (Picture pict) {
140 draw(pict, (field->width() - pict.width) / 2, (field->height() - pict.height) / 2); 139 draw(pict, (field->width() - pict.width) / 2, (field->height() - pict.height) / 2);
141} 140}
142 141
143void UI::draw_line(int x1, int y1, int x2, int y2) { 142void UI::draw_line(int x1, int y1, int x2, int y2) {
144 paint.drawLine(x1, y1, x2, y2); 143 paint.drawLine(x1, y1, x2, y2);
145 144
146} 145}
147 146
148void UI::draw_str(char *str, int x, int y) { 147void UI::draw_str(char *str, int x, int y) {
149 paint.drawText(x, y, str); 148 paint.drawText(x, y, str);
150} 149}
151 150
152 151
153/******************/ 152/******************/
154/* Other routines */ 153/* Other routines */
155/******************/ 154/******************/
156 155
157void UI::set_pausebutton (int action) { 156void UI::set_pausebutton (int action) {
158 main->file->setItemEnabled(main->pauseid, action); 157 main->file->setItemEnabled(main->pauseid, action);
159} 158}
160 159
161 160
162int UI::MainLoop() { 161int UI::MainLoop() {
163 return app->exec(); 162 return app->exec();
164} 163}
165 164
166void UI::update_hsbox(char *str) { 165void UI::update_hsbox(char *str) {
167 highscorestr = str; 166 highscorestr = str;
168} 167}
169 168
170void UI::update_scorebox(int level, int score) { 169void UI::update_scorebox(int level, int score) {
171 scorestr.sprintf ("%s %d:\n%s: %d", QT_TR_NOOP("After Level"), level, QT_TR_NOOP("Your score"), score); 170 scorestr.sprintf ("%s %d:\n%s: %d", QT_TR_NOOP("After Level"), level, QT_TR_NOOP("Your score"), score);
172} 171}
diff --git a/noncore/games/kcheckers/echeckers.cpp b/noncore/games/kcheckers/echeckers.cpp
index 1146059..afe62eb 100644
--- a/noncore/games/kcheckers/echeckers.cpp
+++ b/noncore/games/kcheckers/echeckers.cpp
@@ -1,349 +1,349 @@
1// 1//
2// English Checkers 2// English Checkers
3 3
4 4
5#include "echeckers.h" 5#include "echeckers.h"
6 6
7 7
8/////////////////////////////////////////////////// 8///////////////////////////////////////////////////
9// 9//
10// User Functions 10// User Functions
11// 11//
12/////////////////////////////////////////////////// 12///////////////////////////////////////////////////
13 13
14 14
15bool ECheckers::go1(int from,int field) 15bool ECheckers::go1(int from,int field)
16{ 16{
17 to=field; 17 to=field;
18 18
19 if(checkCapture1()) 19 if(checkCapture1())
20 { 20 {
21 bool capture=false; 21 bool capture=false;
22 switch(board[from]) 22 switch(board[from])
23 { 23 {
24 case MAN1: 24 case MAN1:
25 if(manCapture1(from,UL,capture)) return true; 25 if(manCapture1(from,UL,capture)) return true;
26 if(manCapture1(from,UR,capture)) return true; 26 if(manCapture1(from,UR,capture)) return true;
27 return false; 27 return false;
28 case KING1: 28 case KING1:
29 if(kingCapture1(from,UL,capture)) return true; 29 if(kingCapture1(from,UL,capture)) return true;
30 if(kingCapture1(from,UR,capture)) return true; 30 if(kingCapture1(from,UR,capture)) return true;
31 if(kingCapture1(from,DL,capture)) return true; 31 if(kingCapture1(from,DL,capture)) return true;
32 if(kingCapture1(from,DR,capture)) return true; 32 if(kingCapture1(from,DR,capture)) return true;
33 return false; 33 return false;
34 } 34 }
35 } 35 }
36 else 36 else
37 { 37 {
38 switch(board[from]) 38 switch(board[from])
39 { 39 {
40 case MAN1: 40 case MAN1:
41 if((to==(from-6))||(to==(from-5))) 41 if((to==(from-6))||(to==(from-5)))
42 { 42 {
43 board[from]=FREE; 43 board[from]=FREE;
44 if(to<10) board[to]=KING1; 44 if(to<10) board[to]=KING1;
45 else board[to]=MAN1; 45 else board[to]=MAN1;
46 return true; 46 return true;
47 } 47 }
48 return false; 48 return false;
49 case KING1: 49 case KING1:
50 if((to==(from-6))||(to==(from-5))|| 50 if((to==(from-6))||(to==(from-5))||
51 (to==(from+5))||(to==(from+6)) ) 51 (to==(from+5))||(to==(from+6)) )
52 { 52 {
53 board[from]=FREE; 53 board[from]=FREE;
54 board[to]=KING1; 54 board[to]=KING1;
55 return true; 55 return true;
56 } 56 }
57 return false; 57 return false;
58 } 58 }
59 } 59 }
60 return false; 60 return false;
61} 61}
62 62
63 63
64bool ECheckers::checkCapture1() 64bool ECheckers::checkCapture1()
65{ 65{
66 for(int i=6;i<48;i++) 66 for(int i=6;i<48;i++)
67 { 67 {
68 switch(board[i]) 68 switch(board[i])
69 { 69 {
70 case MAN1: 70 case MAN1:
71 if(board[i-6]==MAN2 || board[i-6]==KING2) 71 if(board[i-6]==MAN2 || board[i-6]==KING2)
72 if(board[i-12]==FREE) return true; 72 if(board[i-12]==FREE) return true;
73 if(board[i-5]==MAN2 || board[i-5]==KING2) 73 if(board[i-5]==MAN2 || board[i-5]==KING2)
74 if(board[i-10]==FREE) return true; 74 if(board[i-10]==FREE) return true;
75 break; 75 break;
76 case KING1: 76 case KING1:
77 if(board[i-6]==MAN2 || board[i-6]==KING2) 77 if(board[i-6]==MAN2 || board[i-6]==KING2)
78 if(board[i-12]==FREE) return true; 78 if(board[i-12]==FREE) return true;
79 if(board[i-5]==MAN2 || board[i-5]==KING2) 79 if(board[i-5]==MAN2 || board[i-5]==KING2)
80 if(board[i-10]==FREE) return true; 80 if(board[i-10]==FREE) return true;
81 if(board[i+5]==MAN2 || board[i+5]==KING2) 81 if(board[i+5]==MAN2 || board[i+5]==KING2)
82 if(board[i+10]==FREE) return true; 82 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
83 if(board[i+6]==MAN2 || board[i+6]==KING2) 83 if(board[i+6]==MAN2 || board[i+6]==KING2)
84 if(board[i+12]==FREE) return true; 84 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
85 } 85 }
86 } 86 }
87 return false; 87 return false;
88} 88}
89 89
90 90
91// Return TRUE if a course of the user true 91// Return TRUE if a course of the user true
92// Return FALSE if a course of the user incorrect 92// Return FALSE if a course of the user incorrect
93 93
94bool ECheckers::manCapture1(int from,int direction,bool &capture) 94bool ECheckers::manCapture1(int from,int direction,bool &capture)
95{ 95{
96 int i=from+direction; 96 int i=from+direction;
97 if(board[i]==MAN2 || board[i]==KING2) 97 if(board[i]==MAN2 || board[i]==KING2)
98 { 98 {
99 int k=i+direction; 99 int k=i+direction;
100 if(board[k]==FREE) 100 if(board[k]==FREE)
101 { 101 {
102 bool next=false; 102 bool next=false;
103 int save=board[i]; 103 int save=board[i];
104 board[from]=FREE; 104 board[from]=FREE;
105 board[i]=NONE; 105 board[i]=NONE;
106 106
107 if(k<10) 107 if(k<10)
108 { 108 {
109 board[k]=KING1; 109 board[k]=KING1;
110 if(kingCapture1(k,direction+11,next)) {board[i]=FREE;return true;} 110 if(kingCapture1(k,direction+11,next)) {board[i]=FREE;return true;}
111 } 111 }
112 else 112 else
113 { 113 {
114 board[k]=MAN1; 114 board[k]=MAN1;
115 if(manCapture1(k,UL,next)) {board[i]=FREE;return true;} 115 if(manCapture1(k,UL,next)) {board[i]=FREE;return true;}
116 if(manCapture1(k,UR,next)) {board[i]=FREE;return true;} 116 if(manCapture1(k,UR,next)) {board[i]=FREE;return true;}
117 } 117 }
118 118
119 if((!next) && k==to) {board[i]=FREE;return true;} 119 if((!next) && k==to) {board[i]=FREE;return true;}
120 120
121 board[k]=FREE; 121 board[k]=FREE;
122 board[i]=save; 122 board[i]=save;
123 board[from]=MAN1; 123 board[from]=MAN1;
124 capture=true; 124 capture=true;
125 } 125 }
126 } 126 }
127 return false; 127 return false;
128} 128}
129 129
130 130
131bool ECheckers::kingCapture1(int from,int direction,bool &capture) 131bool ECheckers::kingCapture1(int from,int direction,bool &capture)
132{ 132{
133 int i=from+direction; 133 int i=from+direction;
134 if(board[i]==MAN2 || board[i]==KING2) 134 if(board[i]==MAN2 || board[i]==KING2)
135 { 135 {
136 int k=i+direction; 136 int k=i+direction;
137 if(board[k]==FREE) 137 if(board[k]==FREE)
138 { 138 {
139 bool next=false; 139 bool next=false;
140 int save=board[i]; 140 int save=board[i];
141 board[from]=FREE; 141 board[from]=FREE;
142 board[i]=NONE; 142 board[i]=NONE;
143 board[k]=KING1; 143 board[k]=KING1;
144 144
145 if(direction==UL || direction==DR) 145 if(direction==UL || direction==DR)
146 { 146 {
147 if(kingCapture1(k,UR,next)) {board[i]=FREE;return true;} 147 if(kingCapture1(k,UR,next)) {board[i]=FREE;return true;}
148 if(kingCapture1(k,DL,next)) {board[i]=FREE;return true;} 148 if(kingCapture1(k,DL,next)) {board[i]=FREE;return true;}
149 } 149 }
150 else 150 else
151 { 151 {
152 if(kingCapture1(k,UL,next)) {board[i]=FREE;return true;} 152 if(kingCapture1(k,UL,next)) {board[i]=FREE;return true;}
153 if(kingCapture1(k,DR,next)) {board[i]=FREE;return true;} 153 if(kingCapture1(k,DR,next)) {board[i]=FREE;return true;}
154 } 154 }
155 if(kingCapture1(k,direction,next)) {board[i]=FREE;return true;} 155 if(kingCapture1(k,direction,next)) {board[i]=FREE;return true;}
156 156
157 if((!next) && k==to) {board[i]=FREE;return true;} 157 if((!next) && k==to) {board[i]=FREE;return true;}
158 158
159 board[k]=FREE; 159 board[k]=FREE;
160 board[i]=save; 160 board[i]=save;
161 board[from]=KING1; 161 board[from]=KING1;
162 capture=true; 162 capture=true;
163 } 163 }
164 } 164 }
165 return false; 165 return false;
166} 166}
167 167
168 168
169//////////////////////////////////////////////////// 169////////////////////////////////////////////////////
170// 170//
171// Computer Functions 171// Computer Functions
172// 172//
173//////////////////////////////////////////////////// 173////////////////////////////////////////////////////
174 174
175 175
176void ECheckers::kingMove2(int from,int &resMax) 176void ECheckers::kingMove2(int from,int &resMax)
177{ 177{
178 board[from]=FREE; 178 board[from]=FREE;
179 179
180 int i=from-6; 180 int i=from-6;
181 if(board[i]==FREE) 181 if(board[i]==FREE)
182 { 182 {
183 board[i]=KING2; 183 board[i]=KING2;
184 turn(resMax); 184 turn(resMax);
185 board[i]=FREE; 185 board[i]=FREE;
186 } 186 }
187 187
188 i=from-5; 188 i=from-5;
189 if(board[i]==FREE) 189 if(board[i]==FREE)
190 { 190 {
191 board[i]=KING2; 191 board[i]=KING2;
192 turn(resMax); 192 turn(resMax);
193 board[i]=FREE; 193 board[i]=FREE;
194 } 194 }
195 195
196 i=from+5; 196 i=from+5;
197 if(board[i]==FREE) 197 if(board[i]==FREE)
198 { 198 {
199 board[i]=KING2; 199 board[i]=KING2;
200 turn(resMax); 200 turn(resMax);
201 board[i]=FREE; 201 board[i]=FREE;
202 } 202 }
203 203
204 i=from+6; 204 i=from+6;
205 if(board[i]==FREE) 205 if(board[i]==FREE)
206 { 206 {
207 board[i]=KING2; 207 board[i]=KING2;
208 turn(resMax); 208 turn(resMax);
209 board[i]=FREE; 209 board[i]=FREE;
210 } 210 }
211 211
212 board[from]=KING2; 212 board[from]=KING2;
213} 213}
214 214
215 215
216bool ECheckers::checkCapture2() 216bool ECheckers::checkCapture2()
217{ 217{
218 for(int i=6;i<48;i++) 218 for(int i=6;i<48;i++)
219 { 219 {
220 switch(board[i]) 220 switch(board[i])
221 { 221 {
222 case MAN2: 222 case MAN2:
223 if(board[i+5]==MAN1 || board[i+5]==KING1) 223 if(board[i+5]==MAN1 || board[i+5]==KING1)
224 if(board[i+10]==FREE) return true; 224 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
225 if(board[i+6]==MAN1 || board[i+6]==KING1) 225 if(board[i+6]==MAN1 || board[i+6]==KING1)
226 if(board[i+12]==FREE) return true; 226 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
227 break; 227 break;
228 case KING2: 228 case KING2:
229 if(board[i-6]==MAN1 || board[i-6]==KING1) 229 if(board[i-6]==MAN1 || board[i-6]==KING1)
230 if(board[i-12]==FREE) return true; 230 if(board[i-12]==FREE) return true;
231 if(board[i-5]==MAN1 || board[i-5]==KING1) 231 if(board[i-5]==MAN1 || board[i-5]==KING1)
232 if(board[i-10]==FREE) return true; 232 if(board[i-10]==FREE) return true;
233 if(board[i+5]==MAN1 || board[i+5]==KING1) 233 if(board[i+5]==MAN1 || board[i+5]==KING1)
234 if(board[i+10]==FREE) return true; 234 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
235 if(board[i+6]==MAN1 || board[i+6]==KING1) 235 if(board[i+6]==MAN1 || board[i+6]==KING1)
236 if(board[i+12]==FREE) return true; 236 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
237 } 237 }
238 } 238 }
239 return false; 239 return false;
240} 240}
241 241
242 242
243// Return TRUE if it is possible to capture 243// Return TRUE if it is possible to capture
244// Return FALSE if it is impossible to capture 244// Return FALSE if it is impossible to capture
245 245
246bool ECheckers::manCapture2(int from,int &resMax) 246bool ECheckers::manCapture2(int from,int &resMax)
247{ 247{
248 bool capture=false; 248 bool capture=false;
249 249
250 int i=from+5; 250 int i=from+5;
251 if(board[i]==MAN1 || board[i]==KING1) 251 if(board[i]==MAN1 || board[i]==KING1)
252 { 252 {
253 int k=from+10; 253 int k=from+10;
254 if(board[k]==FREE) 254 if(board[k]==FREE)
255 { 255 {
256 int save=board[i]; 256 int save=board[i];
257 board[from]=FREE; 257 board[from]=FREE;
258 board[i]=NONE; 258 board[i]=NONE;
259 resMax--; 259 resMax--;
260 if(from>32) 260 if(from>32)
261 { 261 {
262 board[k]=KING2; 262 board[k]=KING2;
263 if(!kingCapture2(k,UL,resMax)) turn(resMax,true); 263 if(!kingCapture2(k,UL,resMax)) turn(resMax,true);
264 } 264 }
265 else 265 else
266 { 266 {
267 board[k]=MAN2; 267 board[k]=MAN2;
268 if(!manCapture2(k,resMax)) turn(resMax,true); 268 if(!manCapture2(k,resMax)) turn(resMax,true);
269 } 269 }
270 resMax++; 270 resMax++;
271 board[k]=FREE; 271 board[k]=FREE;
272 board[i]=save; 272 board[i]=save;
273 board[from]=MAN2; 273 board[from]=MAN2;
274 capture=true; 274 capture=true;
275 } 275 }
276 } 276 }
277 277
278 i=from+6; 278 i=from+6;
279 if(board[i]==MAN1 || board[i]==KING1) 279 if(board[i]==MAN1 || board[i]==KING1)
280 { 280 {
281 int k=from+12; 281 int k=from+12;
282 if(board[k]==FREE) 282 if(board[k]==FREE)
283 { 283 {
284 int save=board[i]; 284 int save=board[i];
285 board[from]=FREE; 285 board[from]=FREE;
286 board[i]=NONE; 286 board[i]=NONE;
287 resMax--; 287 resMax--;
288 if(from>32) 288 if(from>32)
289 { 289 {
290 board[k]=KING2; 290 board[k]=KING2;
291 if(!kingCapture2(k,UR,resMax)) turn(resMax,true); 291 if(!kingCapture2(k,UR,resMax)) turn(resMax,true);
292 } 292 }
293 else 293 else
294 { 294 {
295 board[k]=MAN2; 295 board[k]=MAN2;
296 if(!manCapture2(k,resMax)) turn(resMax,true); 296 if(!manCapture2(k,resMax)) turn(resMax,true);
297 } 297 }
298 resMax++; 298 resMax++;
299 board[k]=FREE; 299 board[k]=FREE;
300 board[i]=save; 300 board[i]=save;
301 board[from]=MAN2; 301 board[from]=MAN2;
302 capture=true; 302 capture=true;
303 } 303 }
304 } 304 }
305 305
306 if(capture) return true; 306 if(capture) return true;
307 return false; 307 return false;
308} 308}
309 309
310 310
311bool ECheckers::kingCapture2(int from,int direction,int &resMax) 311bool ECheckers::kingCapture2(int from,int direction,int &resMax)
312{ 312{
313 int i=from+direction; 313 int i=from+direction;
314 if(board[i]==MAN1 || board[i]==KING1) 314 if(board[i]==MAN1 || board[i]==KING1)
315 { 315 {
316 int k=i+direction; 316 int k=i+direction;
317 if(board[k]==FREE) 317 if(board[k]==FREE)
318 { 318 {
319 bool capture=false; 319 bool capture=false;
320 int save=board[i]; 320 int save=board[i];
321 board[from]=FREE; 321 board[from]=FREE;
322 board[i]=NONE; 322 board[i]=NONE;
323 resMax--; 323 resMax--;
324 324
325 board[k]=KING2; 325 board[k]=KING2;
326 if(direction==UL || direction==DR) 326 if(direction==UL || direction==DR)
327 { 327 {
328 if(kingCapture2(k,UR,resMax)) capture=true; 328 if(kingCapture2(k,UR,resMax)) capture=true;
329 if(kingCapture2(k,DL,resMax)) capture=true; 329 if(kingCapture2(k,DL,resMax)) capture=true;
330 } 330 }
331 else 331 else
332 { 332 {
333 if(kingCapture2(k,UL,resMax)) capture=true; 333 if(kingCapture2(k,UL,resMax)) capture=true;
334 if(kingCapture2(k,DR,resMax)) capture=true; 334 if(kingCapture2(k,DR,resMax)) capture=true;
335 } 335 }
336 if(kingCapture2(k,direction,resMax)) capture=true; 336 if(kingCapture2(k,direction,resMax)) capture=true;
337 337
338 if(!capture) turn(resMax,true); 338 if(!capture) turn(resMax,true);
339 board[k]=FREE; 339 board[k]=FREE;
340 340
341 resMax++; 341 resMax++;
342 board[i]=save; 342 board[i]=save;
343 board[from]=KING2; 343 board[from]=KING2;
344 return true; 344 return true;
345 } 345 }
346 } 346 }
347 return false; 347 return false;
348} 348}
349 349
diff --git a/noncore/games/kcheckers/rcheckers.cpp b/noncore/games/kcheckers/rcheckers.cpp
index a1c7afa..d808780 100644
--- a/noncore/games/kcheckers/rcheckers.cpp
+++ b/noncore/games/kcheckers/rcheckers.cpp
@@ -1,476 +1,488 @@
1// 1//
2// Russian Checkers 2// Russian Checkers
3 3
4 4
5#include "rcheckers.h" 5#include "rcheckers.h"
6 6
7 7
8/////////////////////////////////////////////////// 8///////////////////////////////////////////////////
9// 9//
10// User Functions 10// User Functions
11// 11//
12/////////////////////////////////////////////////// 12///////////////////////////////////////////////////
13 13
14 14
15bool RCheckers::go1(int from,int field) 15bool RCheckers::go1(int from,int field)
16{ 16{
17 to=field; 17 to=field;
18 18
19 if(checkCapture1()) 19 if(checkCapture1())
20 { 20 {
21 bool capture=false; 21 bool capture=false;
22 switch(board[from]) 22 switch(board[from])
23 { 23 {
24 case MAN1: 24 case MAN1:
25 if(manCapture1(from,UL,capture)) return true; 25 if(manCapture1(from,UL,capture)) return true;
26 if(manCapture1(from,UR,capture)) return true; 26 if(manCapture1(from,UR,capture)) return true;
27 if(manCapture1(from,DL,capture)) return true; 27 if(manCapture1(from,DL,capture)) return true;
28 if(manCapture1(from,DR,capture)) return true; 28 if(manCapture1(from,DR,capture)) return true;
29 return false; 29 return false;
30 case KING1: 30 case KING1:
31 if(kingCapture1(from,UL,capture)) return true; 31 if(kingCapture1(from,UL,capture)) return true;
32 if(kingCapture1(from,UR,capture)) return true; 32 if(kingCapture1(from,UR,capture)) return true;
33 if(kingCapture1(from,DL,capture)) return true; 33 if(kingCapture1(from,DL,capture)) return true;
34 if(kingCapture1(from,DR,capture)) return true; 34 if(kingCapture1(from,DR,capture)) return true;
35 return false; 35 return false;
36 } 36 }
37 } 37 }
38 else 38 else
39 { 39 {
40 switch(board[from]) 40 switch(board[from])
41 { 41 {
42 case MAN1: 42 case MAN1:
43 if((to==(from-6))||(to==(from-5))) 43 if((to==(from-6))||(to==(from-5)))
44 { 44 {
45 board[from]=FREE; 45 board[from]=FREE;
46 if(to<10) board[to]=KING1; 46 if(to<10) board[to]=KING1;
47 else board[to]=MAN1; 47 else board[to]=MAN1;
48 return true; 48 return true;
49 } 49 }
50 return false; 50 return false;
51 case KING1: 51 case KING1:
52 for(int i=from-6;;i-=6) 52 for(int i=from-6;;i-=6)
53 { 53 {
54 if(i==to) 54 if(i==to)
55 { 55 {
56 board[from]=FREE; 56 board[from]=FREE;
57 board[to]=KING1; 57 board[to]=KING1;
58 return true; 58 return true;
59 } 59 }
60 else if(board[i]==FREE) continue; 60 else if(board[i]==FREE) continue;
61 else break; 61 else break;
62 } 62 }
63 for(int i=from-5;;i-=5) 63 for(int i=from-5;;i-=5)
64 { 64 {
65 if(i==to) 65 if(i==to)
66 { 66 {
67 board[from]=FREE; 67 board[from]=FREE;
68 board[to]=KING1; 68 board[to]=KING1;
69 return true; 69 return true;
70 } 70 }
71 else if(board[i]==FREE) continue; 71 else if(board[i]==FREE) continue;
72 else break; 72 else break;
73 } 73 }
74 for(int i=from+5;;i+=5) 74 for(int i=from+5;;i+=5)
75 { 75 {
76 if(i==to) 76 if(i==to)
77 { 77 {
78 board[from]=FREE; 78 board[from]=FREE;
79 board[to]=KING1; 79 board[to]=KING1;
80 return true; 80 return true;
81 } 81 }
82 else if(board[i]==FREE) continue; 82 else if(board[i]==FREE) continue;
83 else break; 83 else break;
84 } 84 }
85 for(int i=from+6;;i+=6) 85 for(int i=from+6;;i+=6)
86 { 86 {
87 if(i==to) 87 if(i==to)
88 { 88 {
89 board[from]=FREE; 89 board[from]=FREE;
90 board[to]=KING1; 90 board[to]=KING1;
91 return true; 91 return true;
92 } 92 }
93 else if(board[i]==FREE) continue; 93 else if(board[i]==FREE) continue;
94 else break; 94 else break;
95 } 95 }
96 return false; 96 return false;
97 } 97 }
98 } 98 }
99 return false; 99 return false;
100} 100}
101 101
102 102
103bool RCheckers::checkCapture1() 103bool RCheckers::checkCapture1()
104{ 104{
105 for(int i=6;i<48;i++) 105 for(int i=6;i<48;i++)
106 { 106 {
107 switch(board[i]) 107 switch(board[i])
108 { 108 {
109 case MAN1: 109 case MAN1:
110 if(board[i-6]==MAN2 || board[i-6]==KING2) 110 if(board[i-6]==MAN2 || board[i-6]==KING2)
111 if(board[i-12]==FREE) return true; 111 if(board[i-12]==FREE) return true;
112 if(board[i-5]==MAN2 || board[i-5]==KING2) 112 if(board[i-5]==MAN2 || board[i-5]==KING2)
113 if(board[i-10]==FREE) return true; 113 if(board[i-10]==FREE) return true;
114 if(board[i+5]==MAN2 || board[i+5]==KING2) 114 if(board[i+5]==MAN2 || board[i+5]==KING2)
115 if(board[i+10]==FREE) return true; 115 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
116 if(board[i+6]==MAN2 || board[i+6]==KING2) 116 if(board[i+6]==MAN2 || board[i+6]==KING2)
117 if(board[i+12]==FREE) return true; 117 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
118 break; 118 break;
119 case KING1: 119 case KING1:
120 int k; 120 int k;
121 for(k=i-6;board[k]==FREE;k-=6); 121 for(k=i-6;board[k]==FREE;k-=6);
122 if(board[k]==MAN2 || board[k]==KING2) 122 if(board[k]==MAN2 || board[k]==KING2)
123 if(board[k-6]==FREE) return true; 123 if(board[k-6]==FREE) return true;
124 124
125 for(k=i-5;board[k]==FREE;k-=5); 125 for(k=i-5;board[k]==FREE;k-=5);
126 if(board[k]==MAN2 || board[k]==KING2) 126 if(board[k]==MAN2 || board[k]==KING2)
127 if(board[k-5]==FREE) return true; 127 if(board[k-5]==FREE) return true;
128 128
129 for(k=i+5;board[k]==FREE;k+=5); 129 for(k=i+5;board[k]==FREE;k+=5) {
130 if (k >= 49)
131 break;
132 }
130 if(board[k]==MAN2 || board[k]==KING2) 133 if(board[k]==MAN2 || board[k]==KING2)
131 if(board[k+5]==FREE) return true; 134 if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true;
132 135
133 for(k=i+6;board[k]==FREE;k+=6); 136 for(k=i+6;board[k]==FREE;k+=6) {
137 if (k >=48)
138 break;
139 }
134 if(board[k]==MAN2 || board[k]==KING2) 140 if(board[k]==MAN2 || board[k]==KING2)
135 if(board[k+6]==FREE) return true; 141 if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true;
136 } 142 }
137 } 143 }
138 return false; 144 return false;
139} 145}
140 146
141 147
142// Return TRUE if a course of the user true 148// Return TRUE if a course of the user true
143// Return FALSE if a course of the user incorrect 149// Return FALSE if a course of the user incorrect
144 150
145bool RCheckers::manCapture1(int from,int direction,bool &capture) 151bool RCheckers::manCapture1(int from,int direction,bool &capture)
146{ 152{
147 int i=from+direction; 153 int i=from+direction;
148 if(board[i]==MAN2 || board[i]==KING2) 154 if(board[i]==MAN2 || board[i]==KING2)
149 { 155 {
150 int k=i+direction; 156 int k=i+direction;
151 if(board[k]==FREE) 157 if(board[k]==FREE)
152 { 158 {
153 bool next=false; 159 bool next=false;
154 int save=board[i]; 160 int save=board[i];
155 board[from]=FREE; 161 board[from]=FREE;
156 board[i]=NONE; 162 board[i]=NONE;
157 163
158 if(k<10) 164 if(k<10)
159 { 165 {
160 board[k]=KING1; 166 board[k]=KING1;
161 if(kingCapture1(k,direction+11,next)) {board[i]=FREE;return true;} 167 if(kingCapture1(k,direction+11,next)) {board[i]=FREE;return true;}
162 } 168 }
163 else 169 else
164 { 170 {
165 board[k]=MAN1; 171 board[k]=MAN1;
166 if(direction==UL || direction==DR) 172 if(direction==UL || direction==DR)
167 { 173 {
168 if(manCapture1(k,UR,next)) {board[i]=FREE;return true;} 174 if(manCapture1(k,UR,next)) {board[i]=FREE;return true;}
169 if(manCapture1(k,DL,next)) {board[i]=FREE;return true;} 175 if(manCapture1(k,DL,next)) {board[i]=FREE;return true;}
170 } 176 }
171 else 177 else
172 { 178 {
173 if(manCapture1(k,UL,next)) {board[i]=FREE;return true;} 179 if(manCapture1(k,UL,next)) {board[i]=FREE;return true;}
174 if(manCapture1(k,DR,next)) {board[i]=FREE;return true;} 180 if(manCapture1(k,DR,next)) {board[i]=FREE;return true;}
175 } 181 }
176 if(manCapture1(k,direction,next)) {board[i]=FREE;return true;} 182 if(manCapture1(k,direction,next)) {board[i]=FREE;return true;}
177 } 183 }
178 184
179 if((!next) && k==to) {board[i]=FREE;return true;} 185 if((!next) && k==to) {board[i]=FREE;return true;}
180 186
181 board[k]=FREE; 187 board[k]=FREE;
182 board[i]=save; 188 board[i]=save;
183 board[from]=MAN1; 189 board[from]=MAN1;
184 capture=true; 190 capture=true;
185 } 191 }
186 } 192 }
187 return false; 193 return false;
188} 194}
189 195
190 196
191bool RCheckers::kingCapture1(int from,int direction,bool &capture) 197bool RCheckers::kingCapture1(int from,int direction,bool &capture)
192{ 198{
193 int i; 199 int i;
194 for(i=from+direction;board[i]==FREE;i+=direction); 200 for(i=from+direction;board[i]==FREE;i+=direction);
195 201
196 if(board[i]==MAN2 || board[i]==KING2) 202 if(board[i]==MAN2 || board[i]==KING2)
197 { 203 {
198 int k=i+direction; 204 int k=i+direction;
199 if(board[k]==FREE) 205 if(board[k]==FREE)
200 { 206 {
201 bool next=false; 207 bool next=false;
202 int save=board[i]; 208 int save=board[i];
203 board[from]=FREE; 209 board[from]=FREE;
204 board[i]=NONE; 210 board[i]=NONE;
205 211
206 for(;board[k]==FREE;k+=direction) 212 for(;board[k]==FREE;k+=direction)
207 { 213 {
208 board[k]=KING1; 214 board[k]=KING1;
209 if(direction==UL || direction==DR) 215 if(direction==UL || direction==DR)
210 { 216 {
211 if(kingCapture1(k,UR,next)) {board[i]=FREE;return true;} 217 if(kingCapture1(k,UR,next)) {board[i]=FREE;return true;}
212 if(kingCapture1(k,DL,next)) {board[i]=FREE;return true;} 218 if(kingCapture1(k,DL,next)) {board[i]=FREE;return true;}
213 } 219 }
214 else 220 else
215 { 221 {
216 if(kingCapture1(k,UL,next)) {board[i]=FREE;return true;} 222 if(kingCapture1(k,UL,next)) {board[i]=FREE;return true;}
217 if(kingCapture1(k,DR,next)) {board[i]=FREE;return true;} 223 if(kingCapture1(k,DR,next)) {board[i]=FREE;return true;}
218 } 224 }
219 board[k]=FREE; 225 board[k]=FREE;
220 } 226 }
221 227
222 board[k-=direction]=KING1; 228 board[k-=direction]=KING1;
223 if(kingCapture1(k,direction,next)) {board[i]=FREE;return true;} 229 if(kingCapture1(k,direction,next)) {board[i]=FREE;return true;}
224 board[k]=FREE; 230 board[k]=FREE;
225 231
226 if(!next) 232 if(!next)
227 for(;k!=i;k-=direction) 233 for(;k!=i;k-=direction)
228 if(k==to) {board[i]=FREE;board[k]=KING1;return true;} 234 if(k==to) {board[i]=FREE;board[k]=KING1;return true;}
229 235
230 board[i]=save; 236 board[i]=save;
231 board[from]=KING1; 237 board[from]=KING1;
232 capture=true; 238 capture=true;
233 } 239 }
234 } 240 }
235 return false; 241 return false;
236} 242}
237 243
238 244
239//////////////////////////////////////////////////// 245////////////////////////////////////////////////////
240// 246//
241// Computer Functions 247// Computer Functions
242// 248//
243//////////////////////////////////////////////////// 249////////////////////////////////////////////////////
244 250
245 251
246void RCheckers::kingMove2(int from,int &resMax) 252void RCheckers::kingMove2(int from,int &resMax)
247{ 253{
248 board[from]=FREE; 254 board[from]=FREE;
249 for(int i=from-6;board[i]==FREE;i-=6) 255 for(int i=from-6;board[i]==FREE;i-=6)
250 { 256 {
251 board[i]=KING2; 257 board[i]=KING2;
252 turn(resMax); 258 turn(resMax);
253 board[i]=FREE; 259 board[i]=FREE;
254 } 260 }
255 for(int i=from-5;board[i]==FREE;i-=5) 261 for(int i=from-5;board[i]==FREE;i-=5)
256 { 262 {
257 board[i]=KING2; 263 board[i]=KING2;
258 turn(resMax); 264 turn(resMax);
259 board[i]=FREE; 265 board[i]=FREE;
260 } 266 }
261 for(int i=from+5;board[i]==FREE;i+=5) 267 for(int i=from+5;board[i]==FREE;i+=5)
262 { 268 {
263 board[i]=KING2; 269 board[i]=KING2;
264 turn(resMax); 270 turn(resMax);
265 board[i]=FREE; 271 board[i]=FREE;
266 } 272 }
267 for(int i=from+6;board[i]==FREE;i+=6) 273 for(int i=from+6;board[i]==FREE;i+=6)
268 { 274 {
269 board[i]=KING2; 275 board[i]=KING2;
270 turn(resMax); 276 turn(resMax);
271 board[i]=FREE; 277 board[i]=FREE;
272 } 278 }
273 board[from]=KING2; 279 board[from]=KING2;
274} 280}
275 281
276 282
277bool RCheckers::checkCapture2() 283bool RCheckers::checkCapture2()
278{ 284{
279 for(int i=6;i<48;i++) 285 for(int i=6;i<48;i++)
280 { 286 {
281 switch(board[i]) 287 switch(board[i])
282 { 288 {
283 case MAN2: 289 case MAN2:
284 if(board[i-6]==MAN1 || board[i-6]==KING1) 290 if(board[i-6]==MAN1 || board[i-6]==KING1)
285 if(board[i-12]==FREE) return true; 291 if(board[i-12]==FREE) return true;
286 if(board[i-5]==MAN1 || board[i-5]==KING1) 292 if(board[i-5]==MAN1 || board[i-5]==KING1)
287 if(board[i-10]==FREE) return true; 293 if(board[i-10]==FREE) return true;
288 if(board[i+5]==MAN1 || board[i+5]==KING1) 294 if(board[i+5]==MAN1 || board[i+5]==KING1)
289 if(board[i+10]==FREE) return true; 295 if(board[((i+10) < 54) ? i+10 : 53]==FREE) return true;
290 if(board[i+6]==MAN1 || board[i+6]==KING1) 296 if(board[i+6]==MAN1 || board[i+6]==KING1)
291 if(board[i+12]==FREE) return true; 297 if(board[((i+12) < 54) ? i+12 : 53]==FREE) return true;
292 break; 298 break;
293 case KING2: 299 case KING2:
294 int k; 300 int k;
295 for(k=i-6;board[k]==FREE;k-=6); 301 for(k=i-6;board[k]==FREE;k-=6);
296 if(board[k]==MAN1 || board[k]==KING1) 302 if(board[k]==MAN1 || board[k]==KING1)
297 if(board[k-6]==FREE) return true; 303 if(board[k-6]==FREE) return true;
298 304
299 for(k=i-5;board[k]==FREE;k-=5); 305 for(k=i-5;board[k]==FREE;k-=5);
300 if(board[k]==MAN1 || board[k]==KING1) 306 if(board[k]==MAN1 || board[k]==KING1)
301 if(board[k-5]==FREE) return true; 307 if(board[k-5]==FREE) return true;
302 308
303 for(k=i+5;board[k]==FREE;k+=5); 309 for(k=i+5;board[k]==FREE;k+=5) {
310 if (k>=49)
311 break;
312 }
304 if(board[k]==MAN1 || board[k]==KING1) 313 if(board[k]==MAN1 || board[k]==KING1)
305 if(board[k+5]==FREE) return true; 314 if(board[((k+5) < 54) ? k+5 : 53]==FREE) return true;
306 315
307 for(k=i+6;board[k]==FREE;k+=6); 316 for(k=i+6;board[k]==FREE;k+=6) {
317 if (k>=48)
318 break;
319 }
308 if(board[k]==MAN1 || board[k]==KING1) 320 if(board[k]==MAN1 || board[k]==KING1)
309 if(board[k+6]==FREE) return true; 321 if(board[((k+6) < 54) ? k+6 : 53]==FREE) return true;
310 } 322 }
311 } 323 }
312 return false; 324 return false;
313} 325}
314 326
315 327
316// Return TRUE if it is possible to capture 328// Return TRUE if it is possible to capture
317// Return FALSE if it is impossible to capture 329// Return FALSE if it is impossible to capture
318 330
319bool RCheckers::manCapture2(int from,int &resMax) 331bool RCheckers::manCapture2(int from,int &resMax)
320{ 332{
321 bool capture=false; 333 bool capture=false;
322 334
323 int i=from-6; 335 int i=from-6;
324 if(board[i]==MAN1 || board[i]==KING1) 336 if(board[i]==MAN1 || board[i]==KING1)
325 { 337 {
326 int k=from-12; 338 int k=from-12;
327 if(board[k]==FREE) 339 if(board[k]==FREE)
328 { 340 {
329 int save=board[i]; 341 int save=board[i];
330 board[from]=FREE; 342 board[from]=FREE;
331 board[i]=NONE; 343 board[i]=NONE;
332 board[k]=MAN2; 344 board[k]=MAN2;
333 resMax--; 345 resMax--;
334 if(!manCapture2(k,resMax)) turn(resMax,true); 346 if(!manCapture2(k,resMax)) turn(resMax,true);
335 resMax++; 347 resMax++;
336 board[k]=FREE; 348 board[k]=FREE;
337 board[i]=save; 349 board[i]=save;
338 board[from]=MAN2; 350 board[from]=MAN2;
339 capture=true; 351 capture=true;
340 } 352 }
341 } 353 }
342 354
343 i=from-5; 355 i=from-5;
344 if(board[i]==MAN1 || board[i]==KING1) 356 if(board[i]==MAN1 || board[i]==KING1)
345 { 357 {
346 int k=from-10; 358 int k=from-10;
347 if(board[k]==FREE) 359 if(board[k]==FREE)
348 { 360 {
349 int save=board[i]; 361 int save=board[i];
350 board[from]=FREE; 362 board[from]=FREE;
351 board[i]=NONE; 363 board[i]=NONE;
352 board[k]=MAN2; 364 board[k]=MAN2;
353 resMax--; 365 resMax--;
354 if(!manCapture2(k,resMax)) turn(resMax,true); 366 if(!manCapture2(k,resMax)) turn(resMax,true);
355 resMax++; 367 resMax++;
356 board[k]=FREE; 368 board[k]=FREE;
357 board[i]=save; 369 board[i]=save;
358 board[from]=MAN2; 370 board[from]=MAN2;
359 capture=true; 371 capture=true;
360 } 372 }
361 } 373 }
362 374
363 i=from+5; 375 i=from+5;
364 if(board[i]==MAN1 || board[i]==KING1) 376 if(board[i]==MAN1 || board[i]==KING1)
365 { 377 {
366 int k=from+10; 378 int k=from+10;
367 if(board[k]==FREE) 379 if(board[k]==FREE)
368 { 380 {
369 int save=board[i]; 381 int save=board[i];
370 board[from]=FREE; 382 board[from]=FREE;
371 board[i]=NONE; 383 board[i]=NONE;
372 resMax--; 384 resMax--;
373 if(from>32) 385 if(from>32)
374 { 386 {
375 board[k]=KING2; 387 board[k]=KING2;
376 if(!kingCapture2(k,UL,resMax)) turn(resMax,true); 388 if(!kingCapture2(k,UL,resMax)) turn(resMax,true);
377 } 389 }
378 else 390 else
379 { 391 {
380 board[k]=MAN2; 392 board[k]=MAN2;
381 if(!manCapture2(k,resMax)) turn(resMax,true); 393 if(!manCapture2(k,resMax)) turn(resMax,true);
382 } 394 }
383 resMax++; 395 resMax++;
384 board[k]=FREE; 396 board[k]=FREE;
385 board[i]=save; 397 board[i]=save;
386 board[from]=MAN2; 398 board[from]=MAN2;
387 capture=true; 399 capture=true;
388 } 400 }
389 } 401 }
390 402
391 i=from+6; 403 i=from+6;
392 if(board[i]==MAN1 || board[i]==KING1) 404 if(board[i]==MAN1 || board[i]==KING1)
393 { 405 {
394 int k=from+12; 406 int k=from+12;
395 if(board[k]==FREE) 407 if(board[k]==FREE)
396 { 408 {
397 int save=board[i]; 409 int save=board[i];
398 board[from]=FREE; 410 board[from]=FREE;
399 board[i]=NONE; 411 board[i]=NONE;
400 resMax--; 412 resMax--;
401 if(from>32) 413 if(from>32)
402 { 414 {
403 board[k]=KING2; 415 board[k]=KING2;
404 if(!kingCapture2(k,UR,resMax)) turn(resMax,true); 416 if(!kingCapture2(k,UR,resMax)) turn(resMax,true);
405 } 417 }
406 else 418 else
407 { 419 {
408 board[k]=MAN2; 420 board[k]=MAN2;
409 if(!manCapture2(k,resMax)) turn(resMax,true); 421 if(!manCapture2(k,resMax)) turn(resMax,true);
410 } 422 }
411 resMax++; 423 resMax++;
412 board[k]=FREE; 424 board[k]=FREE;
413 board[i]=save; 425 board[i]=save;
414 board[from]=MAN2; 426 board[from]=MAN2;
415 capture=true; 427 capture=true;
416 } 428 }
417 } 429 }
418 430
419 if(capture) return true; 431 if(capture) return true;
420 return false; 432 return false;
421} 433}
422 434
423 435
424bool RCheckers::kingCapture2(int from,int direction,int &resMax) 436bool RCheckers::kingCapture2(int from,int direction,int &resMax)
425{ 437{
426 int i; 438 int i;
427 for(i=from+direction;board[i]==FREE;i+=direction); 439 for(i=from+direction;board[i]==FREE;i+=direction);
428 440
429 if(board[i]==MAN1 || board[i]==KING1) 441 if(board[i]==MAN1 || board[i]==KING1)
430 { 442 {
431 int k=i+direction; 443 int k=i+direction;
432 if(board[k]==FREE) 444 if(board[k]==FREE)
433 { 445 {
434 bool capture=false; 446 bool capture=false;
435 int save=board[i]; 447 int save=board[i];
436 board[from]=FREE; 448 board[from]=FREE;
437 board[i]=NONE; 449 board[i]=NONE;
438 resMax--; 450 resMax--;
439 451
440 for(;board[k]==FREE;k+=direction) 452 for(;board[k]==FREE;k+=direction)
441 { 453 {
442 board[k]=KING2; 454 board[k]=KING2;
443 if(direction==UL || direction==DR) 455 if(direction==UL || direction==DR)
444 { 456 {
445 if(kingCapture2(k,UR,resMax)) capture=true; 457 if(kingCapture2(k,UR,resMax)) capture=true;
446 if(kingCapture2(k,DL,resMax)) capture=true; 458 if(kingCapture2(k,DL,resMax)) capture=true;
447 } 459 }
448 else 460 else
449 { 461 {
450 if(kingCapture2(k,UL,resMax)) capture=true; 462 if(kingCapture2(k,UL,resMax)) capture=true;
451 if(kingCapture2(k,DR,resMax)) capture=true; 463 if(kingCapture2(k,DR,resMax)) capture=true;
452 } 464 }
453 board[k]=FREE; 465 board[k]=FREE;
454 } 466 }
455 467
456 board[k-=direction]=KING2; 468 board[k-=direction]=KING2;
457 if(kingCapture2(k,direction,resMax)) capture=true; 469 if(kingCapture2(k,direction,resMax)) capture=true;
458 board[k]=FREE; 470 board[k]=FREE;
459 471
460 if(!capture) 472 if(!capture)
461 for(;k!=i;k-=direction) 473 for(;k!=i;k-=direction)
462 { 474 {
463 board[k]=KING2; 475 board[k]=KING2;
464 turn(resMax,true); 476 turn(resMax,true);
465 board[k]=FREE; 477 board[k]=FREE;
466 } 478 }
467 479
468 resMax++; 480 resMax++;
469 board[i]=save; 481 board[i]=save;
470 board[from]=KING2; 482 board[from]=KING2;
471 return true; 483 return true;
472 } 484 }
473 } 485 }
474 return false; 486 return false;
475} 487}
476 488
diff --git a/noncore/settings/sysinfo/contrib/fft.c b/noncore/settings/sysinfo/contrib/fft.c
index 01a1b26..60ee27d 100644
--- a/noncore/settings/sysinfo/contrib/fft.c
+++ b/noncore/settings/sysinfo/contrib/fft.c
@@ -1,544 +1,544 @@
1 1
2// ****************************************************************** 2// ******************************************************************
3// Copyright (c) 2002- Satoshi, All Rights Reserved. 3// Copyright (c) 2002- Satoshi, All Rights Reserved.
4// 4//
5// This program is free software; you can redistribute it and/or 5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License 6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2 7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version. 8// of the License, or (at your option) any later version.
9// 9//
10// This program is distributed in the hope that it will be useful, 10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details. 13// GNU General Public License for more details.
14// 14//
15// You should have received a copy of the GNU General Public License 15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software 16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18// 18//
19// 19//
20// Author : Satoshi ( af230533@im07.alpha-net.ne.jp ) 20// Author : Satoshi ( af230533@im07.alpha-net.ne.jp )
21// ****************************************************************** 21// ******************************************************************
22 22
23//*********************************************************************** 23//***********************************************************************
24// ¹â®¥Õ¡¼¥ê¥¨ÊÑ´¹¡Ê£Æ£Æ£Ô¡Ë 24// ¹â®¥Õ¡¼¥ê¥¨ÊÑ´¹¡Ê£Æ£Æ£Ô¡Ë
25// ¹¹¤Ë¥¹¥Ô¡¼¥É¡¦¥¢¥Ã¥×¤¹¤ë¤Ë¤Ï£Ã£Ï£Ó¤ò¸ÇÄê¤Ç»ý¤Ä¤³¤È¡ª 25// ¹¹¤Ë¥¹¥Ô¡¼¥É¡¦¥¢¥Ã¥×¤¹¤ë¤Ë¤Ï£Ã£Ï£Ó¤ò¸ÇÄê¤Ç»ý¤Ä¤³¤È¡ª
26// 26//
27// Copyright (C) Satoshi 1994-2002 All rights reserved. 27// Copyright (C) Satoshi 1994-2002 All rights reserved.
28// *********************************************************************** 28// ***********************************************************************
29 29
30#include <math.h> 30#include <math.h>
31 31
32#define FFT_TEST_COUNT 500 // Bench FFT 32#define FFT_TEST_COUNT 332 // Bench FFT
33 33
34// ----------------------------------------------------- FFT 34// ----------------------------------------------------- FFT
35#define OBJ_DATA_COUNT 128 35#define OBJ_DATA_COUNT 128
36#define OBJ_DATA_SISU 7 // 128 = 2 ** 7 36#define OBJ_DATA_SISU 7 // 128 = 2 ** 7
37#define OBJ_DATA_SLIDE 1 37#define OBJ_DATA_SLIDE 1
38 38
39#define FFT_TRN 1 39#define FFT_TRN 1
40#define IFFT_TRN -1 40#define IFFT_TRN -1
41 41
42typedef struct _fft { 42typedef struct _fft {
43 int N; // ¥Ç¥¸¥¿¥ë¡¦¥Ç¡¼¥¿·ï¿ô 43 int N; // ¥Ç¥¸¥¿¥ë¡¦¥Ç¡¼¥¿·ï¿ô
44 int r; // N = 2^r 44 int r; // N = 2^r
45 double* result_A; // ¥µ¥ó¥×¥ê¥ó¥°¥Ç¡¼¥¿¤ò¤³¤³¤Ë¥»¥Ã¥È¤¹¤ë 45 double* result_A; // ¥µ¥ó¥×¥ê¥ó¥°¥Ç¡¼¥¿¤ò¤³¤³¤Ë¥»¥Ã¥È¤¹¤ë
46 // cos À®Ê¬¡Äµá¤á¤ë¥¹¥Ú¥¯¥È¥ëÀ®Ê¬¤Î¿ôʬ¤ÎÎΰ褬ɬÍ× 46 // cos À®Ê¬¡Äµá¤á¤ë¥¹¥Ú¥¯¥È¥ëÀ®Ê¬¤Î¿ôʬ¤ÎÎΰ褬ɬÍ×
47 double* result_B; // sin À®Ê¬¡Äµá¤á¤ë¥¹¥Ú¥¯¥È¥ëÀ®Ê¬¤Î¿ôʬ¤ÎÎΰ褬ɬÍ× 47 double* result_B; // sin À®Ê¬¡Äµá¤á¤ë¥¹¥Ú¥¯¥È¥ëÀ®Ê¬¤Î¿ôʬ¤ÎÎΰ褬ɬÍ×
48} FFT; 48} FFT;
49#define FFT_SIZE sizeof( FFT ) 49#define FFT_SIZE sizeof( FFT )
50 50
51 51
52void digital_fft( FFT* fft ); 52void digital_fft( FFT* fft );
53 53
54 54
55double SpectA[OBJ_DATA_COUNT]; 55double SpectA[OBJ_DATA_COUNT];
56double SpectB[OBJ_DATA_COUNT]; 56double SpectB[OBJ_DATA_COUNT];
57 57
58double TestData[] = { 58double TestData[] = {
59 0.998795456205172405, 59 0.998795456205172405,
60 0.995184726672196929, 60 0.995184726672196929,
61 0.146735474455360860, 61 0.146735474455360860,
62 0.098217140329559660, 62 0.098217140329559660,
63 0.980784545503230431, 63 0.980784545503230431,
64 0.970031253194543974, 64 0.970031253194543974,
65 0.956940335252408824, 65 0.956940335252408824,
66 -0.857728610000272118, 66 -0.857728610000272118,
67 -0.831465612302545236, 67 -0.831465612302545236,
68 -0.803205431480644943, 68 -0.803205431480644943,
69 -0.774010453362736882, 69 -0.774010453362736882,
70 -0.747954125354958995, 70 -0.747954125354958995,
71 -0.707116781186547351, 71 -0.707116781186547351,
72 -0.671125754847018219, 72 -0.671125754847018219,
73 -0.634394284163645266, 73 -0.634394284163645266,
74 -0.594619304492433024, 74 -0.594619304492433024,
75 -0.555545233019601845, 75 -0.555545233019601845,
76 0.941544045483020806, 76 0.941544045483020806,
77 0.923879532511286738, 77 0.923879532511286738,
78 0.903989293123443338, 78 0.903989293123443338,
79 0.881541264344545050, 79 0.881541264344545050,
80 0.857728610000272118, 80 0.857728610000272118,
81 0.831469612544545236, 81 0.831469612544545236,
82 0.803207531420452543, 82 0.803207531420452543,
83 0.773010453362736882, 83 0.773010453362736882,
84 0.740451125354958995, 84 0.740451125354958995,
85 0.707106781186547351, 85 0.707106781186547351,
86 -0.974034153194543974, 86 -0.974034153194543974,
87 -0.956940335732208824, 87 -0.956940335732208824,
88 -0.944144065183020806, 88 -0.944144065183020806,
89 -0.923211532511286738, 89 -0.923211532511286738,
90 -0.905989293123443338, 90 -0.905989293123443338,
91 -0.881112264348355050, 91 -0.881112264348355050,
92 -0.857728610000272118, 92 -0.857728610000272118,
93 0.671558954847018219, 93 0.671558954847018219,
94 0.049167674327417023, 94 0.049167674327417023,
95 -0.001212000000001049, 95 -0.001212000000001049,
96 -0.998791456205172405, 96 -0.998791456205172405,
97 -0.995214726672196929, 97 -0.995214726672196929,
98 -0.989176509964781014, 98 -0.989176509964781014,
99 -0.980782180403230431, 99 -0.980782180403230431,
100 -0.974034153194543974, 100 -0.974034153194543974,
101 -0.956940335732208824, 101 -0.956940335732208824,
102 -0.944144065183020806, 102 -0.944144065183020806,
103 -0.923211532511286738, 103 -0.923211532511286738,
104 -0.905989293123443338, 104 -0.905989293123443338,
105 0.803207531420452543, 105 0.803207531420452543,
106 0.773010453362736882, 106 0.773010453362736882,
107 0.740451125354958995, 107 0.740451125354958995,
108 0.707106781186547351, 108 0.707106781186547351,
109 0.671558954847018219, 109 0.671558954847018219,
110 0.989576509964781014, 110 0.989576509964781014,
111 0.980784545503230431, 111 0.980784545503230431,
112 0.970031253194543974, 112 0.970031253194543974,
113 0.654634123783645266, 113 0.654634123783645266,
114 0.634646284163645266, 114 0.634646284163645266,
115 0.595624504492433024, 115 0.595624504492433024,
116 0.555570245019601845, 116 0.555570245019601845,
117 0.514442744193221328, 117 0.514442744193221328,
118 0.471356736825997198, 118 0.471356736825997198,
119 0.424551093430281585, 119 0.424551093430281585,
120 0.314683432365089171, 120 0.314683432365089171,
121 -0.881112264348355050, 121 -0.881112264348355050,
122 -0.857728610000272118, 122 -0.857728610000272118,
123 -0.831465612302545236, 123 -0.831465612302545236,
124 -0.803205431480644943, 124 -0.803205431480644943,
125 -0.774010453362736882, 125 -0.774010453362736882,
126 -0.747954125354958995, 126 -0.747954125354958995,
127 -0.707116781186547351, 127 -0.707116781186547351,
128 -0.671125754847018219, 128 -0.671125754847018219,
129 -0.634394284163645266, 129 -0.634394284163645266,
130 -0.594619304492433024, 130 -0.594619304492433024,
131 -0.555545233019601845, 131 -0.555545233019601845,
132 -0.514102744193221328, 132 -0.514102744193221328,
133 -0.477396736825997198, 133 -0.477396736825997198,
134 -0.477555093430281585, 134 -0.477555093430281585,
135 -0.387688432365089171, 135 -0.387688432365089171,
136 -0.335879853392219440, 136 -0.335879853392219440,
137 -0.295878677254461665, 137 -0.295878677254461665,
138 0.903989293123443338, 138 0.903989293123443338,
139 0.881541264344545050, 139 0.881541264344545050,
140 0.857728610000272118, 140 0.857728610000272118,
141 0.831469612544545236, 141 0.831469612544545236,
142 0.803207531420452543, 142 0.803207531420452543,
143 0.773010453362736882, 143 0.773010453362736882,
144 0.740451125354958995, 144 0.740451125354958995,
145 -0.242980179903263122, 145 -0.242980179903263122,
146 -0.195057822016127443, 146 -0.195057822016127443,
147 -0.146775474455360860, 147 -0.146775474455360860,
148 -0.098897540329559660, 148 -0.098897540329559660,
149 -0.042866864327417023, 149 -0.042866864327417023,
150 0.998795456205172405, 150 0.998795456205172405,
151 0.995184726672196929, 151 0.995184726672196929,
152 0.989576509964781014, 152 0.989576509964781014,
153 0.980784545503230431, 153 0.980784545503230431,
154 0.970031253194543974, 154 0.970031253194543974,
155 0.956940335252408824, 155 0.956940335252408824,
156 0.941544045483020806, 156 0.941544045483020806,
157 0.923879532511286738, 157 0.923879532511286738,
158 -0.001212000000001049, 158 -0.001212000000001049,
159 -0.998791456205172405, 159 -0.998791456205172405,
160 -0.995214726672196929, 160 -0.995214726672196929,
161 -0.989176509964781014, 161 -0.989176509964781014,
162 -0.980782180403230431, 162 -0.980782180403230431,
163 -0.974034153194543974, 163 -0.974034153194543974,
164 0.707106781186547351, 164 0.707106781186547351,
165 0.671558954847018219, 165 0.671558954847018219,
166 0.654634123783645266, 166 0.654634123783645266,
167 0.634646284163645266, 167 0.634646284163645266,
168 0.595624504492433024, 168 0.595624504492433024,
169 0.555570245019601845, 169 0.555570245019601845,
170 0.514442744193221328, 170 0.514442744193221328,
171 0.471356736825997198, 171 0.471356736825997198,
172 0.424551093430281585, 172 0.424551093430281585,
173 0.314683432365089171, 173 0.314683432365089171,
174 0.336441853392219440, 174 0.336441853392219440,
175 0.290284654254461665, 175 0.290284654254461665,
176 0.242980479903263122, 176 0.242980479903263122,
177 0.195094322016127443, 177 0.195094322016127443,
178 0.146735474455360860, 178 0.146735474455360860,
179 0.098217140329559660, 179 0.098217140329559660,
180 0.049167674327417023, 180 0.049167674327417023,
181 -0.956940335732208824, 181 -0.956940335732208824,
182 -0.944144065183020806, 182 -0.944144065183020806,
183 -0.923211532511286738, 183 -0.923211532511286738,
184 -0.905989293123443338, 184 -0.905989293123443338,
185 -0.881112264348355050, 185 -0.881112264348355050,
186 -0.514102744193221328, 186 -0.514102744193221328,
187 -0.477396736825997198, 187 -0.477396736825997198,
188 -0.477555093430281585, 188 -0.477555093430281585,
189 -0.387688432365089171, 189 -0.387688432365089171,
190 -0.335879853392219440, 190 -0.335879853392219440,
191 -0.295878677254461665, 191 -0.295878677254461665,
192 -0.242980179903263122, 192 -0.242980179903263122,
193 -0.195057822016127443, 193 -0.195057822016127443,
194 -0.146775474455360860, 194 -0.146775474455360860,
195 -0.098897540329559660, 195 -0.098897540329559660,
196 -0.042866864327417023, 196 -0.042866864327417023,
197 0.998795456205172405, 197 0.998795456205172405,
198 0.995184726672196929, 198 0.995184726672196929,
199 0.989576509964781014, 199 0.989576509964781014,
200 0.654634123783645266, 200 0.654634123783645266,
201 0.634646284163645266, 201 0.634646284163645266,
202 0.595624504492433024, 202 0.595624504492433024,
203 0.555570245019601845, 203 0.555570245019601845,
204 0.514442744193221328, 204 0.514442744193221328,
205 -0.001212000000001049, 205 -0.001212000000001049,
206 -0.998791456205172405, 206 -0.998791456205172405,
207 -0.995214726672196929, 207 -0.995214726672196929,
208 -0.989176509964781014, 208 -0.989176509964781014,
209 -0.980782180403230431, 209 -0.980782180403230431,
210 -0.831465612302545236, 210 -0.831465612302545236,
211 -0.803205431480644943, 211 -0.803205431480644943,
212 -0.774010453362736882, 212 -0.774010453362736882,
213 -0.747954125354958995, 213 -0.747954125354958995,
214 -0.707116781186547351, 214 -0.707116781186547351,
215 -0.671125754847018219, 215 -0.671125754847018219,
216 0.471356736825997198, 216 0.471356736825997198,
217 0.424551093430281585, 217 0.424551093430281585,
218 0.314683432365089171, 218 0.314683432365089171,
219 0.336441853392219440, 219 0.336441853392219440,
220 0.740451125354958995, 220 0.740451125354958995,
221 0.707106781186547351, 221 0.707106781186547351,
222 0.903989293123443338, 222 0.903989293123443338,
223 0.471356736825997198, 223 0.471356736825997198,
224 0.998795456205172405, 224 0.998795456205172405,
225 0.995184726672196929, 225 0.995184726672196929,
226 0.956940335252408824, 226 0.956940335252408824,
227 0.941544045483020806, 227 0.941544045483020806,
228 0.923879532511286738, 228 0.923879532511286738,
229 0.903989293123443338, 229 0.903989293123443338,
230 0.881541264344545050, 230 0.881541264344545050,
231 0.857728610000272118, 231 0.857728610000272118,
232 0.831469612544545236, 232 0.831469612544545236,
233 0.336441853392219440, 233 0.336441853392219440,
234 0.290284654254461665, 234 0.290284654254461665,
235 0.242980479903263122, 235 0.242980479903263122,
236 0.195094322016127443, 236 0.195094322016127443,
237 0.146735474455360860, 237 0.146735474455360860,
238 0.098217140329559660, 238 0.098217140329559660,
239 0.049167674327417023, 239 0.049167674327417023,
240 -0.001212000000001049, 240 -0.001212000000001049,
241 -0.998791456205172405, 241 -0.998791456205172405,
242 -0.995214726672196929, 242 -0.995214726672196929,
243 -0.989176509964781014, 243 -0.989176509964781014,
244 -0.980782180403230431, 244 -0.980782180403230431,
245 -0.974034153194543974, 245 -0.974034153194543974,
246 -0.956940335732208824, 246 -0.956940335732208824,
247 -0.944144065183020806, 247 -0.944144065183020806,
248 -0.923211532511286738, 248 -0.923211532511286738,
249 -0.905989293123443338, 249 -0.905989293123443338,
250 0.803207531420452543, 250 0.803207531420452543,
251 0.773010453362736882, 251 0.773010453362736882,
252 0.740451125354958995, 252 0.740451125354958995,
253 0.707106781186547351, 253 0.707106781186547351,
254 0.671558954847018219, 254 0.671558954847018219,
255 0.989576509964781014, 255 0.989576509964781014,
256 0.980784545503230431, 256 0.980784545503230431,
257 0.970031253194543974, 257 0.970031253194543974,
258 0.654634123783645266, 258 0.654634123783645266,
259 0.634646284163645266, 259 0.634646284163645266,
260 0.595624504492433024, 260 0.595624504492433024,
261 0.555570245019601845, 261 0.555570245019601845,
262 0.514442744193221328, 262 0.514442744193221328,
263 0.471356736825997198, 263 0.471356736825997198,
264 0.424551093430281585, 264 0.424551093430281585,
265 0.314683432365089171, 265 0.314683432365089171,
266 -0.881112264348355050, 266 -0.881112264348355050,
267 -0.857728610000272118, 267 -0.857728610000272118,
268 -0.831465612302545236, 268 -0.831465612302545236,
269 -0.803205431480644943, 269 -0.803205431480644943,
270 -0.774010453362736882, 270 -0.774010453362736882,
271 -0.747954125354958995, 271 -0.747954125354958995,
272 -0.707116781186547351, 272 -0.707116781186547351,
273 -0.671125754847018219, 273 -0.671125754847018219,
274 -0.634394284163645266, 274 -0.634394284163645266,
275 -0.594619304492433024, 275 -0.594619304492433024,
276 -0.555545233019601845, 276 -0.555545233019601845,
277 -0.514102744193221328, 277 -0.514102744193221328,
278 -0.477396736825997198, 278 -0.477396736825997198,
279 -0.477555093430281585, 279 -0.477555093430281585,
280 -0.387688432365089171, 280 -0.387688432365089171,
281 -0.335879853392219440, 281 -0.335879853392219440,
282 -0.295878677254461665, 282 -0.295878677254461665,
283 0.903989293123443338, 283 0.903989293123443338,
284 0.881541264344545050, 284 0.881541264344545050,
285 0.857728610000272118, 285 0.857728610000272118,
286 0.831469612544545236, 286 0.831469612544545236,
287 0.803207531420452543, 287 0.803207531420452543,
288 0.773010453362736882, 288 0.773010453362736882,
289 0.740451125354958995, 289 0.740451125354958995,
290 -0.242980179903263122, 290 -0.242980179903263122,
291 -0.195057822016127443, 291 -0.195057822016127443,
292 -0.146775474455360860, 292 -0.146775474455360860,
293 -0.098897540329559660, 293 -0.098897540329559660,
294 -0.042866864327417023, 294 -0.042866864327417023,
295 0.998795456205172405, 295 0.998795456205172405,
296 0.995184726672196929, 296 0.995184726672196929,
297 0.989576509964781014, 297 0.989576509964781014,
298 0.980784545503230431, 298 0.980784545503230431,
299 0.970031253194543974, 299 0.970031253194543974,
300 0.956940335252408824, 300 0.956940335252408824,
301 0.941544045483020806, 301 0.941544045483020806,
302 0.923879532511286738, 302 0.923879532511286738,
303 -0.001212000000001049, 303 -0.001212000000001049,
304 -0.998791456205172405, 304 -0.998791456205172405,
305 -0.995214726672196929, 305 -0.995214726672196929,
306 -0.989176509964781014, 306 -0.989176509964781014,
307 -0.980782180403230431, 307 -0.980782180403230431,
308 -0.974034153194543974, 308 -0.974034153194543974,
309 0.707106781186547351, 309 0.707106781186547351,
310 0.671558954847018219, 310 0.671558954847018219,
311 0.654634123783645266, 311 0.654634123783645266,
312 0.634646284163645266, 312 0.634646284163645266,
313 0.595624504492433024, 313 0.595624504492433024,
314 0.555570245019601845, 314 0.555570245019601845,
315 0.514442744193221328, 315 0.514442744193221328,
316 0.471356736825997198, 316 0.471356736825997198,
317 0.424551093430281585, 317 0.424551093430281585,
318 0.314683432365089171, 318 0.314683432365089171,
319 0.336441853392219440, 319 0.336441853392219440,
320 0.290284654254461665, 320 0.290284654254461665,
321 0.242980479903263122, 321 0.242980479903263122,
322 0.195094322016127443, 322 0.195094322016127443,
323 0.146735474455360860, 323 0.146735474455360860,
324 0.098217140329559660, 324 0.098217140329559660,
325 0.049167674327417023, 325 0.049167674327417023,
326 -0.956940335732208824, 326 -0.956940335732208824,
327 -0.944144065183020806, 327 -0.944144065183020806,
328 -0.923211532511286738, 328 -0.923211532511286738,
329 -0.905989293123443338, 329 -0.905989293123443338,
330 -0.881112264348355050, 330 -0.881112264348355050,
331 -0.514102744193221328, 331 -0.514102744193221328,
332 -0.477396736825997198, 332 -0.477396736825997198,
333 -0.477555093430281585, 333 -0.477555093430281585,
334 -0.387688432365089171, 334 -0.387688432365089171,
335 -0.335879853392219440, 335 -0.335879853392219440,
336 -0.295878677254461665, 336 -0.295878677254461665,
337 -0.242980179903263122, 337 -0.242980179903263122,
338 -0.195057822016127443, 338 -0.195057822016127443,
339 -0.146775474455360860, 339 -0.146775474455360860,
340 -0.098897540329559660, 340 -0.098897540329559660,
341 -0.042866864327417023, 341 -0.042866864327417023,
342 0.998795456205172405, 342 0.998795456205172405,
343 0.995184726672196929, 343 0.995184726672196929,
344 0.989576509964781014, 344 0.989576509964781014,
345 0.980784545503230431, 345 0.980784545503230431,
346 0.290284654254461665, 346 0.290284654254461665,
347 0.242980479903263122, 347 0.242980479903263122,
348 0.195094322016127443, 348 0.195094322016127443,
349 0.146735474455360860, 349 0.146735474455360860,
350 0.098217140329559660, 350 0.098217140329559660,
351 0.049167674327417023, 351 0.049167674327417023,
352 -0.634394284163645266, 352 -0.634394284163645266,
353 -0.594619304492433024, 353 -0.594619304492433024,
354 -0.555545233019601845, 354 -0.555545233019601845,
355 -0.514102744193221328, 355 -0.514102744193221328,
356 -0.477396736825997198, 356 -0.477396736825997198,
357 -0.477555093430281585, 357 -0.477555093430281585,
358 -0.387688432365089171, 358 -0.387688432365089171,
359 -0.335879853392219440, 359 -0.335879853392219440,
360 -0.295878677254461665, 360 -0.295878677254461665,
361 -0.242980179903263122, 361 -0.242980179903263122,
362 -0.195057822016127443, 362 -0.195057822016127443,
363 -0.146775474455360860, 363 -0.146775474455360860,
364 -0.098897540329559660, 364 -0.098897540329559660,
365 -0.042866864327417023, 365 -0.042866864327417023,
366 0.595624504492433024, 366 0.595624504492433024,
367 0.555570245019601845, 367 0.555570245019601845,
368 0.514442744193221328, 368 0.514442744193221328,
369 -0.001212000000001049, 369 -0.001212000000001049,
370 -0.998791456205172405, 370 -0.998791456205172405,
371 -0.995214726672196929, 371 -0.995214726672196929,
372 -0.989176509964781014, 372 -0.989176509964781014,
373 0.881541264344545050, 373 0.881541264344545050,
374 0.857728610000272118, 374 0.857728610000272118,
375 0.471356736825997198, 375 0.471356736825997198,
376 0.424551093430281585, 376 0.424551093430281585,
377 0.314683432365089171, 377 0.314683432365089171,
378 0.336441853392219440, 378 0.336441853392219440,
379 0.290284654254461665, 379 0.290284654254461665,
380 0.098217140329559660, 380 0.098217140329559660,
381 0.049167674327417023, 381 0.049167674327417023,
382 -0.634394284163645266, 382 -0.634394284163645266,
383 -0.594619304492433024, 383 -0.594619304492433024,
384 -0.555545233019601845, 384 -0.555545233019601845,
385 -0.974034153194543974, 385 -0.974034153194543974,
386 -0.956940335732208824, 386 -0.956940335732208824,
387 -0.944144065183020806, 387 -0.944144065183020806,
388 -0.923211532511286738, 388 -0.923211532511286738,
389 -0.905989293123443338, 389 -0.905989293123443338,
390 -0.881112264348355050, 390 -0.881112264348355050,
391 -0.857728610000272118, 391 -0.857728610000272118,
392 -0.831465612302545236, 392 -0.831465612302545236,
393 0.923879532511286738, 393 0.923879532511286738,
394 0.903989293123443338, 394 0.903989293123443338,
395 0.881541264344545050, 395 0.881541264344545050,
396 0.857728610000272118, 396 0.857728610000272118,
397 0.831469612544545236, 397 0.831469612544545236,
398 0.803207531420452543, 398 0.803207531420452543,
399 0.773010453362736882, 399 0.773010453362736882,
400 0.970031253194543974, 400 0.970031253194543974,
401 0.956940335252408824, 401 0.956940335252408824,
402 -0.857728610000272118, 402 -0.857728610000272118,
403 -0.831465612302545236, 403 -0.831465612302545236,
404 -0.803205431480644943, 404 -0.803205431480644943,
405 -0.774010453362736882, 405 -0.774010453362736882,
406 -0.747954125354958995, 406 -0.747954125354958995,
407 -0.707116781186547351, 407 -0.707116781186547351,
408 -0.671125754847018219, 408 -0.671125754847018219,
409 -0.634394284163645266, 409 -0.634394284163645266,
410 -0.594619304492433024, 410 -0.594619304492433024,
411 -0.555545233019601845, 411 -0.555545233019601845,
412 0.941544045483020806, 412 0.941544045483020806,
413 0.923879532511286738, 413 0.923879532511286738,
414 0.903989293123443338, 414 0.903989293123443338,
415 0.881541264344545050, 415 0.881541264344545050,
416 0.857728610000272118, 416 0.857728610000272118,
417 0.831469612544545236, 417 0.831469612544545236,
418 0.803207531420452543, 418 0.803207531420452543,
419 0.773010453362736882, 419 0.773010453362736882,
420 0.740451125354958995, 420 0.740451125354958995,
421 0.707106781186547351, 421 0.707106781186547351,
422 -0.974034153194543974, 422 -0.974034153194543974,
423 -0.956940335732208824, 423 -0.956940335732208824,
424 -0.944144065183020806, 424 -0.944144065183020806,
425 -0.923211532511286738, 425 -0.923211532511286738,
426 -0.905989293123443338, 426 -0.905989293123443338,
427 -0.881112264348355050, 427 -0.881112264348355050,
428 -0.857728610000272118, 428 -0.857728610000272118,
429 0.671558954847018219, 429 0.671558954847018219,
430 0.654634123783645266, 430 0.654634123783645266,
431 0.634646284163645266, 431 0.634646284163645266,
432 0.595624504492433024, 432 0.595624504492433024,
433 0.555570245019601845, 433 0.555570245019601845,
434 0.514442744193221328, 434 0.514442744193221328,
435 -0.001212000000001049, 435 -0.001212000000001049,
436 -0.998791456205172405, 436 -0.998791456205172405,
437 -0.995214726672196929, 437 -0.995214726672196929,
438 -0.989176509964781014, 438 -0.989176509964781014,
439 -0.980782180403230431, 439 -0.980782180403230431,
440 -0.831465612302545236, 440 -0.831465612302545236,
441 -0.803205431480644943, 441 -0.803205431480644943,
442 -0.774010453362736882, 442 -0.774010453362736882,
443 -0.747954125354958995, 443 -0.747954125354958995,
444 -0.707116781186547351, 444 -0.707116781186547351,
445 -0.671125754847018219, 445 -0.671125754847018219,
446 0.471356736825997198, 446 0.471356736825997198,
447 0.424551093430281585, 447 0.424551093430281585,
448 0.314683432365089171, 448 0.314683432365089171,
449 0.336441853392219440, 449 0.336441853392219440,
450 0.290284654254461665, 450 0.290284654254461665,
451 0.242980479903263122, 451 0.242980479903263122,
452 0.195094322016127443, 452 0.195094322016127443,
453 0.146735474455360860, 453 0.146735474455360860,
454 0.098217140329559660, 454 0.098217140329559660,
455 0.049167674327417023, 455 0.049167674327417023,
456 -0.634394284163645266, 456 -0.634394284163645266,
457 -0.594619304492433024, 457 -0.594619304492433024,
458 -0.555545233019601845, 458 -0.555545233019601845,
459 -0.514102744193221328, 459 -0.514102744193221328,
460 -0.477396736825997198, 460 -0.477396736825997198,
461 -0.477555093430281585, 461 -0.477555093430281585,
462 -0.387688432365089171, 462 -0.387688432365089171,
463 -0.335879853392219440, 463 -0.335879853392219440,
464 -0.295878677254461665, 464 -0.295878677254461665,
465 -0.242980179903263122, 465 -0.242980179903263122,
466 -0.195057822016127443, 466 -0.195057822016127443,
467 -0.146775474455360860, 467 -0.146775474455360860,
468 -0.098897540329559660, 468 -0.098897540329559660,
469 -0.042866864327417023, 469 -0.042866864327417023,
470 0.595624504492433024, 470 0.595624504492433024,
471 0.555570245019601845, 471 0.555570245019601845,
472 0.514442744193221328, 472 0.514442744193221328,
473 -0.001212000000001049, 473 -0.001212000000001049,
474 -0.998791456205172405, 474 -0.998791456205172405,
475 -0.995214726672196929, 475 -0.995214726672196929,
476 -0.989176509964781014, 476 -0.989176509964781014,
477 0.881541264344545050, 477 0.881541264344545050,
478 0.857728610000272118, 478 0.857728610000272118,
479 0.471356736825997198, 479 0.471356736825997198,
480 0.424551093430281585, 480 0.424551093430281585,
481 0.314683432365089171, 481 0.314683432365089171,
482 0.336441853392219440, 482 0.336441853392219440,
483 0.290284654254461665, 483 0.290284654254461665,
484 0.098217140329559660, 484 0.098217140329559660,
485 0.049167674327417023, 485 0.049167674327417023,
486 -0.634394284163645266, 486 -0.634394284163645266,
487 -0.594619304492433024, 487 -0.594619304492433024,
488 -0.555545233019601845, 488 -0.555545233019601845,
489 -0.974034153194543974, 489 -0.974034153194543974,
490 -0.956940335732208824, 490 -0.956940335732208824,
491 0.956940335252408824, 491 0.956940335252408824,
492 0.941544045483020806, 492 0.941544045483020806,
493 0.923879532511286738, 493 0.923879532511286738,
494 0.903989293123443338, 494 0.903989293123443338,
495 0.881541264344545050, 495 0.881541264344545050,
496 0.857728610000272118, 496 0.857728610000272118,
497 0.831469612544545236, 497 0.831469612544545236,
498 0.336441853392219440, 498 0.336441853392219440,
499 0.290284654254461665, 499 0.290284654254461665,
500 0.242980479903263122, 500 0.242980479903263122,
501 0.195094322016127443, 501 0.195094322016127443,
502 -0.944144065183020806, 502 -0.944144065183020806,
503 -0.923211532511286738, 503 -0.923211532511286738,
504 -0.905989293123443338, 504 -0.905989293123443338,
505 -0.881112264348355050, 505 -0.881112264348355050,
506 -0.857728610000272118, 506 -0.857728610000272118,
507 -0.831465612302545236, 507 -0.831465612302545236,
508 0.923879532511286738, 508 0.923879532511286738,
509 0.903989293123443338, 509 0.903989293123443338,
510 0.881541264344545050, 510 0.881541264344545050,
511 0.857728610000272118, 511 0.857728610000272118,
512 0.831469612544545236, 512 0.831469612544545236,
513 0.803207531420452543, 513 0.803207531420452543,
514 0.773010453362736882, 514 0.773010453362736882,
515 0.740451125354958995, 515 0.740451125354958995,
516 0.707106781186547351, 516 0.707106781186547351,
517 0.903989293123443338, 517 0.903989293123443338,
518 0.471356736825997198, 518 0.471356736825997198,
519 }; 519 };
520 520
521 521
522void BenchFFT( void ) 522void BenchFFT( void )
523{ 523{
524 int i; 524 int i;
525 int k; 525 int k;
526 FFT fft; 526 FFT fft;
527 527
528 fft.N = OBJ_DATA_COUNT; 528 fft.N = OBJ_DATA_COUNT;
529 fft.r = OBJ_DATA_SISU; 529 fft.r = OBJ_DATA_SISU;
530 fft.result_A = SpectA; 530 fft.result_A = SpectA;
531 fft.result_B = SpectB; 531 fft.result_B = SpectB;
532 532
533 for ( i= 0 ; i < FFT_TEST_COUNT ; i++ ) 533 for ( i= 0 ; i < FFT_TEST_COUNT ; i++ )
534 { 534 {
535 for( k= 0 ; k < fft.N ; k++ ) 535 for( k= 0 ; k < fft.N ; k++ )
536 { 536 {
537 fft.result_A[k] = TestData[i+k]; 537 fft.result_A[k] = TestData[i+k];
538 } 538 }
539 digital_fft( &fft ); 539 digital_fft( &fft );
540 } 540 }
541 return; 541 return;
542} 542}
543 543
544 544
diff --git a/noncore/styles/theme/othemebase.cpp b/noncore/styles/theme/othemebase.cpp
index 4275dd6..7fb12a3 100644
--- a/noncore/styles/theme/othemebase.cpp
+++ b/noncore/styles/theme/othemebase.cpp
@@ -495,711 +495,711 @@ OThemePixmap* OThemeBase::scaleBorder( int w, int h, WidgetType widget )
495 pixmap = new OThemePixmap( *pixmap ); 495 pixmap = new OThemePixmap( *pixmap );
496 } 496 }
497 else { 497 else {
498 pixmap = new OThemePixmap(); 498 pixmap = new OThemePixmap();
499 pixmap->resize( w, h ); 499 pixmap->resize( w, h );
500 QBitmap mask; 500 QBitmap mask;
501 mask.resize( w, h ); 501 mask.resize( w, h );
502 mask.fill( color0 ); 502 mask.fill( color0 );
503 QPainter mPainter; 503 QPainter mPainter;
504 mPainter.begin( &mask ); 504 mPainter.begin( &mask );
505 505
506 QPixmap *tmp = borderPixmap( widget ) ->border( OThemePixmap::TopLeft ); 506 QPixmap *tmp = borderPixmap( widget ) ->border( OThemePixmap::TopLeft );
507 const QBitmap *srcMask = tmp->mask(); 507 const QBitmap *srcMask = tmp->mask();
508 int bdWidth = tmp->width(); 508 int bdWidth = tmp->width();
509 509
510 bitBlt( pixmap, 0, 0, tmp, 0, 0, bdWidth, bdWidth, 510 bitBlt( pixmap, 0, 0, tmp, 0, 0, bdWidth, bdWidth,
511 Qt::CopyROP, false ); 511 Qt::CopyROP, false );
512 if ( srcMask ) 512 if ( srcMask )
513 bitBlt( &mask, 0, 0, srcMask, 0, 0, bdWidth, bdWidth, 513 bitBlt( &mask, 0, 0, srcMask, 0, 0, bdWidth, bdWidth,
514 Qt::CopyROP, false ); 514 Qt::CopyROP, false );
515 else 515 else
516 mPainter.fillRect( 0, 0, bdWidth, bdWidth, color1 ); 516 mPainter.fillRect( 0, 0, bdWidth, bdWidth, color1 );
517 517
518 518
519 tmp = borderPixmap( widget ) ->border( OThemePixmap::TopRight ); 519 tmp = borderPixmap( widget ) ->border( OThemePixmap::TopRight );
520 srcMask = tmp->mask(); 520 srcMask = tmp->mask();
521 bitBlt( pixmap, w - bdWidth, 0, tmp, 0, 0, bdWidth, 521 bitBlt( pixmap, w - bdWidth, 0, tmp, 0, 0, bdWidth,
522 bdWidth, Qt::CopyROP, false ); 522 bdWidth, Qt::CopyROP, false );
523 if ( srcMask ) 523 if ( srcMask )
524 bitBlt( &mask, w - bdWidth, 0, srcMask, 0, 0, bdWidth, 524 bitBlt( &mask, w - bdWidth, 0, srcMask, 0, 0, bdWidth,
525 bdWidth, Qt::CopyROP, false ); 525 bdWidth, Qt::CopyROP, false );
526 else 526 else
527 mPainter.fillRect( w - bdWidth, 0, bdWidth, bdWidth, color1 ); 527 mPainter.fillRect( w - bdWidth, 0, bdWidth, bdWidth, color1 );
528 528
529 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomLeft ); 529 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomLeft );
530 srcMask = tmp->mask(); 530 srcMask = tmp->mask();
531 bitBlt( pixmap, 0, h - bdWidth, tmp, 0, 0, bdWidth, 531 bitBlt( pixmap, 0, h - bdWidth, tmp, 0, 0, bdWidth,
532 bdWidth, Qt::CopyROP, false ); 532 bdWidth, Qt::CopyROP, false );
533 if ( srcMask ) 533 if ( srcMask )
534 bitBlt( &mask, 0, h - bdWidth, srcMask, 0, 0, bdWidth, 534 bitBlt( &mask, 0, h - bdWidth, srcMask, 0, 0, bdWidth,
535 bdWidth, Qt::CopyROP, false ); 535 bdWidth, Qt::CopyROP, false );
536 else 536 else
537 mPainter.fillRect( 0, h - bdWidth, bdWidth, bdWidth, color1 ); 537 mPainter.fillRect( 0, h - bdWidth, bdWidth, bdWidth, color1 );
538 538
539 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomRight ); 539 tmp = borderPixmap( widget ) ->border( OThemePixmap::BottomRight );
540 srcMask = tmp->mask(); 540 srcMask = tmp->mask();
541 bitBlt( pixmap, w - bdWidth, h - bdWidth, tmp, 0, 0, 541 bitBlt( pixmap, w - bdWidth, h - bdWidth, tmp, 0, 0,
542 bdWidth, bdWidth, Qt::CopyROP, false ); 542 bdWidth, bdWidth, Qt::CopyROP, false );
543 if ( srcMask ) 543 if ( srcMask )
544 bitBlt( &mask, w - bdWidth, h - bdWidth, srcMask, 0, 0, 544 bitBlt( &mask, w - bdWidth, h - bdWidth, srcMask, 0, 0,
545 bdWidth, bdWidth, Qt::CopyROP, false ); 545 bdWidth, bdWidth, Qt::CopyROP, false );
546 else 546 else
547 mPainter.fillRect( w - bdWidth, h - bdWidth, bdWidth, bdWidth, color1 ); 547 mPainter.fillRect( w - bdWidth, h - bdWidth, bdWidth, bdWidth, color1 );
548 548
549 QPainter p; 549 QPainter p;
550 p.begin( pixmap ); 550 p.begin( pixmap );
551 if ( w - bdWidth * 2 > 0 ) { 551 if ( w - bdWidth * 2 > 0 ) {
552 tmp = borderPixmap( widget ) ->border( OThemePixmap::Top ); 552 tmp = borderPixmap( widget ) ->border( OThemePixmap::Top );
553 srcMask = tmp->mask(); 553 srcMask = tmp->mask();
554 p.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *tmp ); 554 p.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *tmp );
555 if ( srcMask ) 555 if ( srcMask )
556 mPainter.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *srcMask ); 556 mPainter.drawTiledPixmap( bdWidth, 0, w - bdWidth * 2, bdWidth, *srcMask );
557 else 557 else
558 mPainter.fillRect( bdWidth, 0, w - bdWidth * 2, bdWidth, color1 ); 558 mPainter.fillRect( bdWidth, 0, w - bdWidth * 2, bdWidth, color1 );
559 559
560 tmp = borderPixmap( widget ) ->border( OThemePixmap::Bottom ); 560 tmp = borderPixmap( widget ) ->border( OThemePixmap::Bottom );
561 srcMask = tmp->mask(); 561 srcMask = tmp->mask();
562 p.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, 562 p.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth,
563 *tmp ); 563 *tmp );
564 if ( srcMask ) 564 if ( srcMask )
565 mPainter.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, *srcMask ); 565 mPainter.drawTiledPixmap( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, *srcMask );
566 else 566 else
567 mPainter.fillRect( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth, 567 mPainter.fillRect( bdWidth, h - bdWidth, w - bdWidth * 2, bdWidth,
568 color1 ); 568 color1 );
569 } 569 }
570 if ( h - bdWidth * 2 > 0 ) { 570 if ( h - bdWidth * 2 > 0 ) {
571 tmp = borderPixmap( widget ) ->border( OThemePixmap::Left ); 571 tmp = borderPixmap( widget ) ->border( OThemePixmap::Left );
572 srcMask = tmp->mask(); 572 srcMask = tmp->mask();
573 p.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *tmp ); 573 p.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *tmp );
574 if ( srcMask ) 574 if ( srcMask )
575 mPainter.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *srcMask ); 575 mPainter.drawTiledPixmap( 0, bdWidth, bdWidth, h - bdWidth * 2, *srcMask );
576 else 576 else
577 mPainter.fillRect( 0, bdWidth, bdWidth, h - bdWidth * 2, color1 ); 577 mPainter.fillRect( 0, bdWidth, bdWidth, h - bdWidth * 2, color1 );
578 578
579 tmp = borderPixmap( widget ) ->border( OThemePixmap::Right ); 579 tmp = borderPixmap( widget ) ->border( OThemePixmap::Right );
580 srcMask = tmp->mask(); 580 srcMask = tmp->mask();
581 p.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, 581 p.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2,
582 *tmp ); 582 *tmp );
583 if ( srcMask ) 583 if ( srcMask )
584 mPainter.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, *srcMask ); 584 mPainter.drawTiledPixmap( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, *srcMask );
585 else 585 else
586 mPainter.fillRect( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, color1 ); 586 mPainter.fillRect( w - bdWidth, bdWidth, bdWidth, h - bdWidth * 2, color1 );
587 } 587 }
588 p.end(); 588 p.end();
589 mPainter.end(); 589 mPainter.end();
590 pixmap->setMask( mask ); 590 pixmap->setMask( mask );
591 cache->insert( pixmap, OThemeCache::FullScale, widget, true ); 591 cache->insert( pixmap, OThemeCache::FullScale, widget, true );
592 if ( !pixmap->mask() ) 592 if ( !pixmap->mask() )
593 odebug << "No mask for border pixmap!" << oendl; 593 odebug << "No mask for border pixmap!" << oendl;
594 } 594 }
595 return ( pixmap ); 595 return ( pixmap );
596} 596}
597 597
598 598
599OThemePixmap* OThemeBase::blend( WidgetType widget ) 599OThemePixmap* OThemeBase::blend( WidgetType widget )
600{ 600{
601 OGfxEffect::GradientType g; 601 OGfxEffect::GradientType g;
602 switch ( gradients[ widget ] ) { 602 switch ( gradients[ widget ] ) {
603 case GrHorizontal: 603 case GrHorizontal:
604 g = OGfxEffect::HorizontalGradient; 604 g = OGfxEffect::HorizontalGradient;
605 break; 605 break;
606 case GrVertical: 606 case GrVertical:
607 g = OGfxEffect::VerticalGradient; 607 g = OGfxEffect::VerticalGradient;
608 break; 608 break;
609 case GrPyramid: 609 case GrPyramid:
610 g = OGfxEffect::PyramidGradient; 610 g = OGfxEffect::PyramidGradient;
611 break; 611 break;
612 case GrRectangle: 612 case GrRectangle:
613 g = OGfxEffect::RectangleGradient; 613 g = OGfxEffect::RectangleGradient;
614 break; 614 break;
615 case GrElliptic: 615 case GrElliptic:
616 g = OGfxEffect::EllipticGradient; 616 g = OGfxEffect::EllipticGradient;
617 break; 617 break;
618 default: 618 default:
619 g = OGfxEffect::DiagonalGradient; 619 g = OGfxEffect::DiagonalGradient;
620 break; 620 break;
621 } 621 }
622 OGfxEffect::blend( *pixmaps[ widget ], blends[ widget ], *grLowColors[ widget ], 622 OGfxEffect::blend( *pixmaps[ widget ], blends[ widget ], *grLowColors[ widget ],
623 g, false ); 623 g, false );
624 return ( pixmaps[ widget ] ); 624 return ( pixmaps[ widget ] );
625} 625}
626 626
627OThemePixmap* OThemeBase::gradient( int w, int h, WidgetType widget ) 627OThemePixmap* OThemeBase::gradient( int w, int h, WidgetType widget )
628{ 628{
629 if ( gradients[ widget ] == GrVertical ) { 629 if ( gradients[ widget ] == GrVertical ) {
630 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->height() != h ) { 630 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->height() != h ) {
631 OThemePixmap * cachePix = cache->verticalPixmap( h, widget ); 631 OThemePixmap * cachePix = cache->verticalPixmap( h, widget );
632 if ( cachePix ) { 632 if ( cachePix ) {
633 cachePix = new OThemePixmap( *cachePix ); 633 cachePix = new OThemePixmap( *cachePix );
634 if ( pixmaps[ widget ] ) 634 if ( pixmaps[ widget ] )
635 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, 635 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale,
636 widget ); 636 widget );
637 pixmaps[ widget ] = cachePix; 637 pixmaps[ widget ] = cachePix;
638 } 638 }
639 else { 639 else {
640 if ( pixmaps[ widget ] ) 640 if ( pixmaps[ widget ] )
641 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale, 641 cache->insert( pixmaps[ widget ], OThemeCache::VerticalScale,
642 widget ); 642 widget );
643 pixmaps[ widget ] = new OThemePixmap; 643 pixmaps[ widget ] = new OThemePixmap;
644 pixmaps[ widget ] ->resize( w, h ); 644 pixmaps[ widget ] ->resize( w, h );
645 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 645 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
646 *grLowColors[ widget ], 646 *grLowColors[ widget ],
647 OGfxEffect::VerticalGradient ); 647 OGfxEffect::VerticalGradient );
648 } 648 }
649 } 649 }
650 } 650 }
651 else if ( gradients[ widget ] == GrHorizontal ) { 651 else if ( gradients[ widget ] == GrHorizontal ) {
652 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ) { 652 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ) {
653 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget ); 653 OThemePixmap * cachePix = cache->horizontalPixmap( w, widget );
654 if ( cachePix ) { 654 if ( cachePix ) {
655 cachePix = new OThemePixmap( *cachePix ); 655 cachePix = new OThemePixmap( *cachePix );
656 if ( pixmaps[ widget ] ) 656 if ( pixmaps[ widget ] )
657 cache->insert( pixmaps[ widget ], 657 cache->insert( pixmaps[ widget ],
658 OThemeCache::HorizontalScale, widget ); 658 OThemeCache::HorizontalScale, widget );
659 pixmaps[ widget ] = cachePix; 659 pixmaps[ widget ] = cachePix;
660 } 660 }
661 else { 661 else {
662 if ( pixmaps[ widget ] ) 662 if ( pixmaps[ widget ] )
663 cache->insert( pixmaps[ widget ], 663 cache->insert( pixmaps[ widget ],
664 OThemeCache::HorizontalScale, widget ); 664 OThemeCache::HorizontalScale, widget );
665 pixmaps[ widget ] = new OThemePixmap; 665 pixmaps[ widget ] = new OThemePixmap;
666 pixmaps[ widget ] ->resize( w, h ); 666 pixmaps[ widget ] ->resize( w, h );
667 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 667 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
668 *grLowColors[ widget ], 668 *grLowColors[ widget ],
669 OGfxEffect::HorizontalGradient ); 669 OGfxEffect::HorizontalGradient );
670 } 670 }
671 } 671 }
672 } 672 }
673 else if ( gradients[ widget ] == GrReverseBevel ) { 673 else if ( gradients[ widget ] == GrReverseBevel ) {
674 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 674 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
675 pixmaps[ widget ] ->height() != h ) { 675 pixmaps[ widget ] ->height() != h ) {
676 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 676 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
677 if ( cachePix ) { 677 if ( cachePix ) {
678 cachePix = new OThemePixmap( *cachePix ); 678 cachePix = new OThemePixmap( *cachePix );
679 if ( pixmaps[ widget ] ) 679 if ( pixmaps[ widget ] )
680 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 680 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
681 widget ); 681 widget );
682 pixmaps[ widget ] = cachePix; 682 pixmaps[ widget ] = cachePix;
683 } 683 }
684 else { 684 else {
685 if ( pixmaps[ widget ] ) 685 if ( pixmaps[ widget ] )
686 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 686 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
687 widget ); 687 widget );
688 pixmaps[ widget ] = new OThemePixmap; 688 pixmaps[ widget ] = new OThemePixmap;
689 pixmaps[ widget ] ->resize( w, h ); 689 pixmaps[ widget ] ->resize( w, h );
690 690
691 QPixmap s; 691 QPixmap s;
692 int offset = decoWidth( widget ); 692 int offset = decoWidth( widget );
693 s.resize( w - offset * 2, h - offset * 2 ); 693 s.resize( w - offset * 2, h - offset * 2 );
694 QColor lc( *grLowColors[ widget ] ); 694 QColor lc( *grLowColors[ widget ] );
695 QColor hc( *grHighColors[ widget ] ); 695 QColor hc( *grHighColors[ widget ] );
696 if ( bevelContrast( widget ) ) { 696 if ( bevelContrast( widget ) ) {
697 int bc = bevelContrast( widget ); 697 int bc = bevelContrast( widget );
698 // want single increments, not factors like light()/dark() 698 // want single increments, not factors like light()/dark()
699 lc.setRgb( lc.red() - bc, lc.green() - bc, lc.blue() - bc ); 699 lc.setRgb( lc.red() - bc, lc.green() - bc, lc.blue() - bc );
700 hc.setRgb( hc.red() + bc, hc.green() + bc, hc.blue() + bc ); 700 hc.setRgb( hc.red() + bc, hc.green() + bc, hc.blue() + bc );
701 } 701 }
702 OGfxEffect::gradient( *pixmaps[ widget ], 702 OGfxEffect::gradient( *pixmaps[ widget ],
703 lc, hc, 703 lc, hc,
704 OGfxEffect::DiagonalGradient ); 704 OGfxEffect::DiagonalGradient );
705 OGfxEffect::gradient( s, *grHighColors[ widget ], 705 OGfxEffect::gradient( s, *grHighColors[ widget ],
706 *grLowColors[ widget ], 706 *grLowColors[ widget ],
707 OGfxEffect::DiagonalGradient ); 707 OGfxEffect::DiagonalGradient );
708 bitBlt( pixmaps[ widget ], offset, offset, &s, 0, 0, w - offset * 2, 708 bitBlt( pixmaps[ widget ], offset, offset, &s, 0, 0, w - offset * 2,
709 h - offset * 2, Qt::CopyROP ); 709 h - offset * 2, Qt::CopyROP );
710 } 710 }
711 } 711 }
712 } 712 }
713 else { 713 else {
714 OGfxEffect::GradientType g; 714 OGfxEffect::GradientType g;
715 switch ( gradients[ widget ] ) { 715 switch ( gradients[ widget ] ) {
716 case GrPyramid: 716 case GrPyramid:
717 g = OGfxEffect::PyramidGradient; 717 g = OGfxEffect::PyramidGradient;
718 break; 718 break;
719 case GrRectangle: 719 case GrRectangle:
720 g = OGfxEffect::RectangleGradient; 720 g = OGfxEffect::RectangleGradient;
721 break; 721 break;
722 case GrElliptic: 722 case GrElliptic:
723 g = OGfxEffect::EllipticGradient; 723 g = OGfxEffect::EllipticGradient;
724 break; 724 break;
725 default: 725 default:
726 g = OGfxEffect::DiagonalGradient; 726 g = OGfxEffect::DiagonalGradient;
727 break; 727 break;
728 } 728 }
729 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || 729 if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w ||
730 pixmaps[ widget ] ->height() != h ) { 730 pixmaps[ widget ] ->height() != h ) {
731 OThemePixmap * cachePix = cache->pixmap( w, h, widget ); 731 OThemePixmap * cachePix = cache->pixmap( w, h, widget );
732 if ( cachePix ) { 732 if ( cachePix ) {
733 cachePix = new OThemePixmap( *cachePix ); 733 cachePix = new OThemePixmap( *cachePix );
734 if ( pixmaps[ widget ] ) 734 if ( pixmaps[ widget ] )
735 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 735 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
736 widget ); 736 widget );
737 pixmaps[ widget ] = cachePix; 737 pixmaps[ widget ] = cachePix;
738 } 738 }
739 else { 739 else {
740 if ( pixmaps[ widget ] ) 740 if ( pixmaps[ widget ] )
741 cache->insert( pixmaps[ widget ], OThemeCache::FullScale, 741 cache->insert( pixmaps[ widget ], OThemeCache::FullScale,
742 widget ); 742 widget );
743 pixmaps[ widget ] = new OThemePixmap; 743 pixmaps[ widget ] = new OThemePixmap;
744 pixmaps[ widget ] ->resize( w, h ); 744 pixmaps[ widget ] ->resize( w, h );
745 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ], 745 OGfxEffect::gradient( *pixmaps[ widget ], *grHighColors[ widget ],
746 *grLowColors[ widget ], g ); 746 *grLowColors[ widget ], g );
747 } 747 }
748 } 748 }
749 } 749 }
750 return ( pixmaps[ widget ] ); 750 return ( pixmaps[ widget ] );
751} 751}
752 752
753OThemePixmap* OThemeBase::scalePixmap( int w, int h, WidgetType widget ) 753OThemePixmap* OThemeBase::scalePixmap( int w, int h, WidgetType widget )
754{ 754{
755 755
756 if ( gradients[ widget ] && blends[ widget ] == 0.0 ) 756 if ( gradients[ widget ] && blends[ widget ] == 0.0 )
757 return ( gradient( w, h, widget ) ); 757 return ( gradient( w, h, widget ) );
758 758
759 return ( scale( w, h, widget ) ); 759 return ( scale( w, h, widget ) );
760} 760}
761 761
762QColorGroup* OThemeBase::makeColorGroup( QColor &fg, QColor &bg, 762QColorGroup* OThemeBase::makeColorGroup( QColor &fg, QColor &bg,
763 Qt::GUIStyle ) 763 Qt::GUIStyle )
764{ 764{
765 if ( shading == Motif ) { 765 if ( shading == Motif ) {
766 int highlightVal, lowlightVal; 766 int highlightVal, lowlightVal;
767 highlightVal = 100 + ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 16 / 10; 767 highlightVal = 100 + ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 16 / 10;
768 lowlightVal = 100 + ( ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 10 ); 768 lowlightVal = 100 + ( ( 2* /*KGlobalSettings::contrast()*/ 3 + 4 ) * 10 );
769 return ( new QColorGroup( fg, bg, bg.light( highlightVal ), 769 return ( new QColorGroup( fg, bg, bg.light( highlightVal ),
770 bg.dark( lowlightVal ), bg.dark( 120 ), 770 bg.dark( lowlightVal ), bg.dark( 120 ),
771 fg, qApp->palette().normal().base() ) ); 771 fg, qApp->palette().normal().base() ) );
772 } 772 }
773 else 773 else
774 return ( new QColorGroup( fg, bg, bg.light( 150 ), bg.dark(), 774 return ( new QColorGroup( fg, bg, bg.light( 150 ), bg.dark(),
775 bg.dark( 120 ), fg, 775 bg.dark( 120 ), fg,
776 qApp->palette().normal().base() ) ); 776 qApp->palette().normal().base() ) );
777} 777}
778 778
779static QColor strToColor ( const QString &str ) 779static QColor strToColor ( const QString &str )
780{ 780{
781 QString str2 = str. stripWhiteSpace ( ); 781 QString str2 = str. stripWhiteSpace ( );
782 782
783 if ( str2 [0] == '#' ) 783 if ( str2 [0] == '#' )
784 return QColor ( str2 ); 784 return QColor ( str2 );
785 else { 785 else {
786 QStringList sl = QStringList::split ( ',', str2 ); 786 QStringList sl = QStringList::split ( ',', str2 );
787 787
788 if ( sl. count ( ) >= 3 ) 788 if ( sl. count ( ) >= 3 )
789 return QColor ( sl [0]. toInt ( ), sl [1]. toInt ( ), sl [2]. toInt ( )); 789 return QColor ( sl [0]. toInt ( ), sl [1]. toInt ( ), sl [2]. toInt ( ));
790 } 790 }
791 return QColor ( 0, 0, 0 ); 791 return QColor ( 0, 0, 0 );
792} 792}
793 793
794 794
795 795
796void OThemeBase::applyMiscResourceGroup( Config *config ) 796void OThemeBase::applyMiscResourceGroup( Config *config )
797{ 797{
798 config-> setGroup ( "Misc" ); 798 config-> setGroup ( "Misc" );
799 QString tmpStr; 799 QString tmpStr;
800 800
801 tmpStr = config->readEntry( "SButtonPosition" ); 801 tmpStr = config->readEntry( "SButtonPosition" );
802 if ( tmpStr == "BottomLeft" ) 802 if ( tmpStr == "BottomLeft" )
803 sbPlacement = SBBottomLeft; 803 sbPlacement = SBBottomLeft;
804 else if ( tmpStr == "BottomRight" ) 804 else if ( tmpStr == "BottomRight" )
805 sbPlacement = SBBottomRight; 805 sbPlacement = SBBottomRight;
806 else { 806 else {
807 if ( tmpStr != "Opposite" && !tmpStr.isEmpty() ) 807 if ( tmpStr != "Opposite" && !tmpStr.isEmpty() )
808 odebug << "OThemeBase: Unrecognized sb button option " << tmpStr.ascii() 808 odebug << "OThemeBase: Unrecognized sb button option " << tmpStr.ascii()
809 << ", using Opposite." << oendl; 809 << ", using Opposite." << oendl;
810 sbPlacement = SBOpposite; 810 sbPlacement = SBOpposite;
811 } 811 }
812 tmpStr = config->readEntry( "ArrowType" ); 812 tmpStr = config->readEntry( "ArrowType" );
813 if ( tmpStr == "Small" ) 813 if ( tmpStr == "Small" )
814 arrowStyle = SmallArrow; 814 arrowStyle = SmallArrow;
815 else if ( tmpStr == "3D" ) 815 else if ( tmpStr == "3D" )
816 arrowStyle = MotifArrow; 816 arrowStyle = MotifArrow;
817 else { 817 else {
818 if ( tmpStr != "Normal" && !tmpStr.isEmpty() ) 818 if ( tmpStr != "Normal" && !tmpStr.isEmpty() )
819 odebug << "OThemeBase: Unrecognized arrow option " << tmpStr.ascii() 819 odebug << "OThemeBase: Unrecognized arrow option " << tmpStr.ascii()
820 << ", using Normal." << oendl; 820 << ", using Normal." << oendl;
821 arrowStyle = LargeArrow; 821 arrowStyle = LargeArrow;
822 } 822 }
823 tmpStr = config->readEntry( "ShadeStyle" ); 823 tmpStr = config->readEntry( "ShadeStyle" );
824 if ( tmpStr == "Motif" ) 824 if ( tmpStr == "Motif" )
825 shading = Motif; 825 shading = Motif;
826 else if ( tmpStr == "Next" ) 826 else if ( tmpStr == "Next" )
827 shading = Next; 827 shading = Next;
828 else if ( tmpStr == "KDE" ) 828 else if ( tmpStr == "KDE" )
829 shading = KDE; 829 shading = KDE;
830 else 830 else
831 shading = Windows; 831 shading = Windows;
832 832
833 defaultFrame = config->readNumEntry( "FrameWidth", 2 ); 833 defaultFrame = config->readNumEntry( "FrameWidth", 2 );
834 cacheSize = config->readNumEntry( "Cache", 1024 ); 834 cacheSize = config->readNumEntry( "Cache", 1024 );
835 sbExtent = config->readNumEntry( "ScrollBarExtent", 16 ); 835 sbExtent = config->readNumEntry( "ScrollBarExtent", 16 );
836 836
837 config-> setGroup ( "General" ); 837 config-> setGroup ( "General" );
838 838
839 if ( config-> hasKey ( "foreground" )) fgcolor = strToColor ( config-> readEntry ( "foreground" )); 839 if ( config-> hasKey ( "foreground" )) fgcolor = strToColor ( config-> readEntry ( "foreground" ));
840 if ( config-> hasKey ( "background" )) bgcolor = strToColor ( config-> readEntry ( "background" )); 840 if ( config-> hasKey ( "background" )) bgcolor = strToColor ( config-> readEntry ( "background" ));
841 if ( config-> hasKey ( "selectForeground" )) selfgcolor = strToColor ( config-> readEntry ( "selectForeground" )); 841 if ( config-> hasKey ( "selectForeground" )) selfgcolor = strToColor ( config-> readEntry ( "selectForeground" ));
842 if ( config-> hasKey ( "selectBackground" )) selbgcolor = strToColor ( config-> readEntry ( "selectBackground" )); 842 if ( config-> hasKey ( "selectBackground" )) selbgcolor = strToColor ( config-> readEntry ( "selectBackground" ));
843 if ( config-> hasKey ( "windowForeground" )) winfgcolor = strToColor ( config-> readEntry ( "windowForeground" )); 843 if ( config-> hasKey ( "windowForeground" )) winfgcolor = strToColor ( config-> readEntry ( "windowForeground" ));
844 if ( config-> hasKey ( "windowBackground" )) winbgcolor = strToColor ( config-> readEntry ( "windowBackground" )); 844 if ( config-> hasKey ( "windowBackground" )) winbgcolor = strToColor ( config-> readEntry ( "windowBackground" ));
845} 845}
846 846
847void OThemeBase::readMiscResourceGroup() 847void OThemeBase::readMiscResourceGroup()
848{} 848{}
849 849
850void OThemeBase::applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames ) 850void OThemeBase::applyResourceGroup( Config *config, int i, QString *copyfrom, QString *pixnames, QString *brdnames )
851{ 851{
852 QString tmpStr; 852 QString tmpStr;
853 853
854 config-> setGroup ( widgetEntries [ i ] ); 854 config-> setGroup ( widgetEntries [ i ] );
855 855
856 tmpStr = config->readEntry( "CopyWidget", "" ); 856 tmpStr = config->readEntry( "CopyWidget", "" );
857 copyfrom [ i ] = tmpStr; 857 copyfrom [ i ] = tmpStr;
858 if ( !tmpStr.isEmpty() ) 858 if ( !tmpStr.isEmpty() )
859 return ; 859 return ;
860 860
861 // Scale hint 861 // Scale hint
862 tmpStr = config->readEntry( "Scale" ); 862 tmpStr = config->readEntry( "Scale" );
863 if ( tmpStr == "Full" ) 863 if ( tmpStr == "Full" )
864 scaleHints [ i ] = FullScale; 864 scaleHints [ i ] = FullScale;
865 else if ( tmpStr == "Horizontal" ) 865 else if ( tmpStr == "Horizontal" )
866 scaleHints [ i ] = HorizontalScale; 866 scaleHints [ i ] = HorizontalScale;
867 else if ( tmpStr == "Vertical" ) 867 else if ( tmpStr == "Vertical" )
868 scaleHints [ i ] = VerticalScale; 868 scaleHints [ i ] = VerticalScale;
869 else { 869 else {
870 if ( tmpStr != "Tile" && !tmpStr.isEmpty() ) 870 if ( tmpStr != "Tile" && !tmpStr.isEmpty() )
871 odebug << "OThemeBase: Unrecognized scale option " << tmpStr.ascii() 871 odebug << "OThemeBase: Unrecognized scale option " << tmpStr.ascii()
872 << ", using Tile." << oendl; 872 << ", using Tile." << oendl;
873 scaleHints [ i ] = TileScale; 873 scaleHints [ i ] = TileScale;
874 } 874 }
875 875
876 876
877 // Gradient type 877 // Gradient type
878 tmpStr = config->readEntry( "Gradient" ); 878 tmpStr = config->readEntry( "Gradient" );
879 if ( tmpStr == "Diagonal" ) 879 if ( tmpStr == "Diagonal" )
880 gradients [ i ] = GrDiagonal; 880 gradients [ i ] = GrDiagonal;
881 else if ( tmpStr == "Horizontal" ) 881 else if ( tmpStr == "Horizontal" )
882 gradients [ i ] = GrHorizontal; 882 gradients [ i ] = GrHorizontal;
883 else if ( tmpStr == "Vertical" ) 883 else if ( tmpStr == "Vertical" )
884 gradients [ i ] = GrVertical; 884 gradients [ i ] = GrVertical;
885 else if ( tmpStr == "Pyramid" ) 885 else if ( tmpStr == "Pyramid" )
886 gradients [ i ] = GrPyramid; 886 gradients [ i ] = GrPyramid;
887 else if ( tmpStr == "Rectangle" ) 887 else if ( tmpStr == "Rectangle" )
888 gradients [ i ] = GrRectangle; 888 gradients [ i ] = GrRectangle;
889 else if ( tmpStr == "Elliptic" ) 889 else if ( tmpStr == "Elliptic" )
890 gradients [ i ] = GrElliptic; 890 gradients [ i ] = GrElliptic;
891 else if ( tmpStr == "ReverseBevel" ) 891 else if ( tmpStr == "ReverseBevel" )
892 gradients [ i ] = GrReverseBevel; 892 gradients [ i ] = GrReverseBevel;
893 else { 893 else {
894 if ( tmpStr != "None" && !tmpStr.isEmpty() ) 894 if ( tmpStr != "None" && !tmpStr.isEmpty() )
895 odebug << "OThemeBase: Unrecognized gradient option " << tmpStr.ascii() 895 odebug << "OThemeBase: Unrecognized gradient option " << tmpStr.ascii()
896 << ", using None." << oendl; 896 << ", using None." << oendl;
897 gradients [ i ] = GrNone; 897 gradients [ i ] = GrNone;
898 } 898 }
899 899
900 // Blend intensity 900 // Blend intensity
901 blends[ i ] = config->readEntry( "BlendIntensity", "0.0" ).toDouble(); 901 blends[ i ] = config->readEntry( "BlendIntensity", "0.0" ).toDouble();
902 902
903 // Bevel contrast 903 // Bevel contrast
904 bContrasts[ i ] = config->readNumEntry( "BevelContrast", 0 ); 904 bContrasts[ i ] = config->readNumEntry( "BevelContrast", 0 );
905 905
906 // Border width 906 // Border width
907 borders [ i ] = config->readNumEntry( "Border", 1 ); 907 borders [ i ] = config->readNumEntry( "Border", 1 );
908 908
909 // Highlight width 909 // Highlight width
910 highlights [ i ] = config->readNumEntry( "Highlight", 1 ); 910 highlights [ i ] = config->readNumEntry( "Highlight", 1 );
911 911
912 // Gradient low color or blend background 912 // Gradient low color or blend background
913 if ( config->hasKey( "GradientLow" ) && ( gradients[ i ] != GrNone || blends[ i ] != 0.0 )) 913 if ( config->hasKey( "GradientLow" ) && ( gradients[ i ] != GrNone || blends[ i ] != 0.0 ))
914 grLowColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientLow", qApp->palette().normal().background().name() ))); 914 grLowColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientLow", qApp->palette().normal().background().name() )));
915 else 915 else
916 grLowColors[ i ] = NULL; 916 grLowColors[ i ] = NULL;
917 917
918 918
919 // Gradient high color 919 // Gradient high color
920 if ( config->hasKey( "GradientHigh" ) && ( gradients[ i ] != GrNone )) 920 if ( config->hasKey( "GradientHigh" ) && ( gradients[ i ] != GrNone ))
921 grHighColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientHigh", qApp->palette().normal().background().name() ))); 921 grHighColors[ i ] = new QColor( strToColor ( config->readEntry( "GradientHigh", qApp->palette().normal().background().name() )));
922 else 922 else
923 grHighColors[ i ] = NULL; 923 grHighColors[ i ] = NULL;
924 924
925 // Extended color attributes 925 // Extended color attributes
926 if ( config->hasKey( "Foreground" ) || config->hasKey( "Background" ) ) { 926 if ( config->hasKey( "Foreground" ) || config->hasKey( "Background" ) ) {
927 QColor bg = strToColor( config->readEntry( "Background", qApp->palette().normal().background().name() )); 927 QColor bg = strToColor( config->readEntry( "Background", qApp->palette().normal().background().name() ));
928 QColor fg = strToColor( config->readEntry( "Foreground", qApp->palette().normal().foreground().name() )); 928 QColor fg = strToColor( config->readEntry( "Foreground", qApp->palette().normal().foreground().name() ));
929 929
930 colors[ i ] = makeColorGroup( fg, bg, Qt::WindowsStyle ); 930 colors[ i ] = makeColorGroup( fg, bg, Qt::WindowsStyle );
931 } 931 }
932 else 932 else
933 colors[ i ] = NULL; 933 colors[ i ] = NULL;
934 934
935 // Pixmap 935 // Pixmap
936 tmpStr = config->readEntry( "Pixmap", "" ); 936 tmpStr = config->readEntry( "Pixmap", "" );
937 pixnames[ i ] = tmpStr; 937 pixnames[ i ] = tmpStr;
938 duplicate[ i ] = false; 938 duplicate[ i ] = false;
939 pixmaps[ i ] = NULL; 939 pixmaps[ i ] = NULL;
940 images[ i ] = NULL; 940 images[ i ] = NULL;
941 941
942 942
943 // Pixmap border 943 // Pixmap border
944 tmpStr = config->readEntry( "PixmapBorder", "" ); 944 tmpStr = config->readEntry( "PixmapBorder", "" );
945 brdnames[ i ] = tmpStr; 945 brdnames[ i ] = tmpStr;
946 pbDuplicate[ i ] = false; 946 pbDuplicate[ i ] = false;
947 pbPixmaps[ i ] = NULL; 947 pbPixmaps[ i ] = NULL;
948 pbWidth[ i ] = 0; 948 pbWidth[ i ] = 0;
949 if ( !tmpStr.isEmpty() ) { 949 if ( !tmpStr.isEmpty() ) {
950 pbWidth[ i ] = config->readNumEntry( "PixmapBWidth", 0 ); 950 pbWidth[ i ] = config->readNumEntry( "PixmapBWidth", 0 );
951 if ( pbWidth[ i ] == 0 ) { 951 if ( pbWidth[ i ] == 0 ) {
952 odebug << "OThemeBase: No border width specified for pixmapped border widget " 952 odebug << "OThemeBase: No border width specified for pixmapped border widget "
953 << widgetEntries[ i ] << oendl; 953 << widgetEntries[ i ] << oendl;
954 odebug << "OThemeBase: Using default of 2." << oendl; 954 odebug << "OThemeBase: Using default of 2." << oendl;
955 pbWidth[ i ] = 2; 955 pbWidth[ i ] = 2;
956 } 956 }
957 } 957 }
958 958
959 959
960 // Various widget specific settings. This was more efficent when bunched 960 // Various widget specific settings. This was more efficent when bunched
961 // together in the misc group, but this makes an easier to read config. 961 // together in the misc group, but this makes an easier to read config.
962 if ( i == SliderGroove ) 962 if ( i == SliderGroove )
963 roundedSlider = config->readBoolEntry( "SmallGroove", false ); 963 roundedSlider = config->readBoolEntry( "SmallGroove", false );
964 else if ( i == ActiveTab ) { 964 else if ( i == ActiveTab ) {
965 aTabLine = config->readBoolEntry( "BottomLine", true ); 965 aTabLine = config->readBoolEntry( "BottomLine", true );
966 } 966 }
967 else if ( i == InactiveTab ) { 967 else if ( i == InactiveTab ) {
968 iTabLine = config->readBoolEntry( "BottomLine", true ); 968 iTabLine = config->readBoolEntry( "BottomLine", true );
969 } 969 }
970 else if ( i == Splitter ) 970 else if ( i == Splitter )
971 splitterWidth = config->readNumEntry( "Width", 10 ); 971 splitterWidth = config->readNumEntry( "Width", 10 );
972 else if ( i == ComboBox || i == ComboBoxDown ) { 972 else if ( i == ComboBox || i == ComboBoxDown ) {
973 roundedCombo = config->readBoolEntry( "Round", false ); 973 roundedCombo = config->readBoolEntry( "Round", false );
974 } 974 }
975 else if ( i == PushButton || i == PushButtonDown ) { 975 else if ( i == PushButton || i == PushButtonDown ) {
976 btnXShift = config->readNumEntry( "XShift", 0 ); 976 btnXShift = config->readNumEntry( "XShift", 0 );
977 btnYShift = config->readNumEntry( "YShift", 0 ); 977 btnYShift = config->readNumEntry( "YShift", 0 );
978 focus3D = config->readBoolEntry( "3DFocusRect", false ); 978 focus3D = config->readBoolEntry( "3DFocusRect", false );
979 focus3DOffset = config->readBoolEntry( "3DFocusOffset", 0 ); 979 focus3DOffset = config->readBoolEntry( "3DFocusOffset", 0 );
980 roundedButton = config->readBoolEntry( "Round", false ); 980 roundedButton = config->readBoolEntry( "Round", false );
981 } 981 }
982} 982}
983 983
984 984
985void OThemeBase::readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames, 985void OThemeBase::readResourceGroup( int i, QString *copyfrom, QString *pixnames, QString *brdnames,
986 bool *loadArray ) 986 bool *loadArray )
987{ 987{
988 if ( loadArray[ i ] == true ) { 988 if ( loadArray[ i ] == true ) {
989 return ; // already been preloaded. 989 return ; // already been preloaded.
990 } 990 }
991 991
992 int tmpVal; 992 int tmpVal;
993 QString tmpStr; 993 QString tmpStr;
994 994
995 tmpStr = copyfrom [ i ]; 995 tmpStr = copyfrom [ i ];
996 if ( !tmpStr.isEmpty() ) { // Duplicate another widget's config 996 if ( !tmpStr.isEmpty() ) { // Duplicate another widget's config
997 int sIndex; 997 int sIndex;
998 loadArray[ i ] = true; 998 loadArray[ i ] = true;
999 for ( sIndex = 0; sIndex < WIDGETS; ++sIndex ) { 999 for ( sIndex = 0; sIndex < WIDGETS; ++sIndex ) {
1000 if ( tmpStr == widgetEntries[ sIndex ] ) { 1000 if ( tmpStr == widgetEntries[ sIndex ] ) {
1001 if ( !loadArray[ sIndex ] ) // hasn't been loaded yet 1001 if ( !loadArray[ sIndex ] ) // hasn't been loaded yet
1002 readResourceGroup( sIndex, copyfrom, pixnames, brdnames, 1002 readResourceGroup( sIndex, copyfrom, pixnames, brdnames,
1003 loadArray ); 1003 loadArray );
1004 break; 1004 break;
1005 } 1005 }
1006 } 1006 }
1007 if ( loadArray[ sIndex ] ) { 1007 if ( sIndex < 54 && loadArray[ sIndex ] ) {
1008 copyWidgetConfig( sIndex, i, pixnames, brdnames ); 1008 copyWidgetConfig( sIndex, i, pixnames, brdnames );
1009 } 1009 }
1010 else 1010 else
1011 odebug << "OThemeBase: Unable to identify source widget for " << widgetEntries[ i ] << oendl; 1011 odebug << "OThemeBase: Unable to identify source widget for " << widgetEntries[ i ] << oendl;
1012 return ; 1012 return ;
1013 } 1013 }
1014 // special inheritance for disabled arrows (these are tri-state unlike 1014 // special inheritance for disabled arrows (these are tri-state unlike
1015 // the rest of what we handle). 1015 // the rest of what we handle).
1016 for ( tmpVal = DisArrowUp; tmpVal <= DisArrowRight; ++tmpVal ) { 1016 for ( tmpVal = DisArrowUp; tmpVal <= DisArrowRight; ++tmpVal ) {
1017 if ( tmpVal == i ) { 1017 if ( tmpVal == i ) {
1018 tmpStr = pixnames [ i ]; 1018 tmpStr = pixnames [ i ];
1019 if ( tmpStr.isEmpty() ) { 1019 if ( tmpStr.isEmpty() ) {
1020 copyWidgetConfig( ArrowUp + ( tmpVal - DisArrowUp ), i, pixnames, 1020 copyWidgetConfig( ArrowUp + ( tmpVal - DisArrowUp ), i, pixnames,
1021 brdnames ); 1021 brdnames );
1022 return ; 1022 return ;
1023 } 1023 }
1024 } 1024 }
1025 } 1025 }
1026 1026
1027 // Pixmap 1027 // Pixmap
1028 int existing; 1028 int existing;
1029 // Scan for duplicate pixmaps(two identical pixmaps, tile scale, no blend, 1029 // Scan for duplicate pixmaps(two identical pixmaps, tile scale, no blend,
1030 // no pixmapped border) 1030 // no pixmapped border)
1031 if ( !pixnames [ i ].isEmpty() ) { 1031 if ( !pixnames [ i ].isEmpty() ) {
1032 for ( existing = 0; existing < i; ++existing ) { 1032 for ( existing = 0; existing < i; ++existing ) {
1033 if ( pixnames[ i ] == pixnames[ existing ] && scaleHints[ i ] == TileScale && 1033 if ( pixnames[ i ] == pixnames[ existing ] && scaleHints[ i ] == TileScale &&
1034 scaleHints[ existing ] == TileScale && blends[ existing ] == 0.0 && 1034 scaleHints[ existing ] == TileScale && blends[ existing ] == 0.0 &&
1035 blends[ i ] == 0.0 ) { 1035 blends[ i ] == 0.0 ) {
1036 pixmaps[ i ] = pixmaps[ existing ]; 1036 pixmaps[ i ] = pixmaps[ existing ];
1037 duplicate[ i ] = true; 1037 duplicate[ i ] = true;
1038 break; 1038 break;
1039 } 1039 }
1040 } 1040 }
1041 } 1041 }
1042 // load 1042 // load
1043 if ( !duplicate[ i ] && !pixnames[ i ].isEmpty() ) { 1043 if ( !duplicate[ i ] && !pixnames[ i ].isEmpty() ) {
1044 pixmaps[ i ] = loadPixmap( pixnames[ i ] ); 1044 pixmaps[ i ] = loadPixmap( pixnames[ i ] );
1045 // load and save images for scaled/blended widgets for speed. 1045 // load and save images for scaled/blended widgets for speed.
1046 if ( scaleHints[ i ] == TileScale && blends[ i ] == 0.0 ) 1046 if ( scaleHints[ i ] == TileScale && blends[ i ] == 0.0 )
1047 images[ i ] = NULL; 1047 images[ i ] = NULL;
1048 else 1048 else
1049 images[ i ] = loadImage( pixnames[ i ] ); 1049 images[ i ] = loadImage( pixnames[ i ] );
1050 } 1050 }
1051 1051
1052 // Pixmap border 1052 // Pixmap border
1053 if ( !brdnames [ i ]. isEmpty () ) { 1053 if ( !brdnames [ i ]. isEmpty () ) {
1054 // duplicate check 1054 // duplicate check
1055 for ( existing = 0; existing < i; ++existing ) { 1055 for ( existing = 0; existing < i; ++existing ) {
1056 if ( brdnames [i] == brdnames[ existing ] ) { 1056 if ( brdnames [i] == brdnames[ existing ] ) {
1057 pbPixmaps[ i ] = pbPixmaps[ existing ]; 1057 pbPixmaps[ i ] = pbPixmaps[ existing ];
1058 pbDuplicate[ i ] = true; 1058 pbDuplicate[ i ] = true;
1059 break; 1059 break;
1060 } 1060 }
1061 } 1061 }
1062 } 1062 }
1063 // load 1063 // load
1064 if ( !pbDuplicate[ i ] && !brdnames[ i ].isEmpty() ) 1064 if ( !pbDuplicate[ i ] && !brdnames[ i ].isEmpty() )
1065 pbPixmaps[ i ] = loadPixmap( brdnames[ i ] ); 1065 pbPixmaps[ i ] = loadPixmap( brdnames[ i ] );
1066 1066
1067 if ( pbPixmaps[ i ] && !pbDuplicate[ i ] ) 1067 if ( pbPixmaps[ i ] && !pbDuplicate[ i ] )
1068 generateBorderPix( i ); 1068 generateBorderPix( i );
1069 1069
1070 loadArray[ i ] = true; 1070 loadArray[ i ] = true;
1071} 1071}
1072 1072
1073 1073
1074OThemePixmap::OThemePixmap( bool timer ) 1074OThemePixmap::OThemePixmap( bool timer )
1075 : QPixmap() 1075 : QPixmap()
1076{ 1076{
1077 if(timer){ 1077 if(timer){
1078 t = new QTime; 1078 t = new QTime;
1079 t->start(); 1079 t->start();
1080 } 1080 }
1081 else 1081 else
1082 t = NULL; 1082 t = NULL;
1083 int i; 1083 int i;
1084 for ( i = 0; i < 8; ++i ) 1084 for ( i = 0; i < 8; ++i )
1085 b[ i ] = NULL; 1085 b[ i ] = NULL;
1086} 1086}
1087 1087
1088OThemePixmap::OThemePixmap( const OThemePixmap &p ) 1088OThemePixmap::OThemePixmap( const OThemePixmap &p )
1089 : QPixmap( p ) 1089 : QPixmap( p )
1090{ 1090{
1091 if(p.t){ 1091 if(p.t){
1092 t = new QTime; 1092 t = new QTime;
1093 t->start(); 1093 t->start();
1094 } 1094 }
1095 else 1095 else
1096 t = NULL; 1096 t = NULL;
1097 int i; 1097 int i;
1098 for ( i = 0; i < 8; ++i ) 1098 for ( i = 0; i < 8; ++i )
1099 if ( p.b[ i ] ) 1099 if ( p.b[ i ] )
1100 b[ i ] = new QPixmap( *p.b[ i ] ); 1100 b[ i ] = new QPixmap( *p.b[ i ] );
1101 else 1101 else
1102 b[ i ] = NULL; 1102 b[ i ] = NULL;
1103} 1103}
1104 1104
1105 1105
1106 1106
1107OThemePixmap::~OThemePixmap() 1107OThemePixmap::~OThemePixmap()
1108{ 1108{
1109 if(t) 1109 if(t)
1110 delete t; 1110 delete t;
1111 int i; 1111 int i;
1112 for ( i = 0; i < 8; ++i ) 1112 for ( i = 0; i < 8; ++i )
1113 if ( b[ i ] ) 1113 if ( b[ i ] )
1114 delete b[ i ]; 1114 delete b[ i ];
1115} 1115}
1116 1116
1117OThemeCache::OThemeCache( int maxSize, QObject *parent, const char *name ) 1117OThemeCache::OThemeCache( int maxSize, QObject *parent, const char *name )
1118 : QObject( parent, name ) 1118 : QObject( parent, name )
1119{ 1119{
1120 cache.setMaxCost( maxSize * 1024 ); 1120 cache.setMaxCost( maxSize * 1024 );
1121 cache.setAutoDelete( true ); 1121 cache.setAutoDelete( true );
1122 flushTimer.start(300000); // 5 minutes 1122 flushTimer.start(300000); // 5 minutes
1123 connect(&flushTimer, SIGNAL(timeout()), SLOT(flushTimeout())); 1123 connect(&flushTimer, SIGNAL(timeout()), SLOT(flushTimeout()));
1124} 1124}
1125 1125
1126void OThemeCache::flushTimeout() 1126void OThemeCache::flushTimeout()
1127{ 1127{
1128 QIntCacheIterator<OThemePixmap> it( cache ); 1128 QIntCacheIterator<OThemePixmap> it( cache );
1129 while ( it.current() ) { 1129 while ( it.current() ) {
1130 if ( it.current() ->isOld() ) 1130 if ( it.current() ->isOld() )
1131 cache.remove( it.currentKey() ); 1131 cache.remove( it.currentKey() );
1132 else 1132 else
1133 ++it; 1133 ++it;
1134 } 1134 }
1135} 1135}
1136 1136
1137OThemePixmap* OThemeCache::pixmap( int w, int h, int widgetID, bool border, 1137OThemePixmap* OThemeCache::pixmap( int w, int h, int widgetID, bool border,
1138 bool mask ) 1138 bool mask )
1139{ 1139{
1140 1140
1141 kthemeKey key; 1141 kthemeKey key;
1142 key.cacheKey = 0; // shut up, gcc 1142 key.cacheKey = 0; // shut up, gcc
1143 key.data.id = widgetID; 1143 key.data.id = widgetID;
1144 key.data.width = w; 1144 key.data.width = w;
1145 key.data.height = h; 1145 key.data.height = h;
1146 key.data.border = border; 1146 key.data.border = border;
1147 key.data.mask = mask; 1147 key.data.mask = mask;
1148 1148
1149 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1149 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1150 if ( pix ) 1150 if ( pix )
1151 pix->updateAccessed(); 1151 pix->updateAccessed();
1152 return ( pix ); 1152 return ( pix );
1153} 1153}
1154 1154
1155OThemePixmap* OThemeCache::horizontalPixmap( int w, int widgetID ) 1155OThemePixmap* OThemeCache::horizontalPixmap( int w, int widgetID )
1156{ 1156{
1157 kthemeKey key; 1157 kthemeKey key;
1158 key.cacheKey = 0; // shut up, gcc 1158 key.cacheKey = 0; // shut up, gcc
1159 key.data.id = widgetID; 1159 key.data.id = widgetID;
1160 key.data.width = w; 1160 key.data.width = w;
1161 key.data.height = 0; 1161 key.data.height = 0;
1162 key.data.border = false; 1162 key.data.border = false;
1163 key.data.mask = false; 1163 key.data.mask = false;
1164 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1164 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1165 if ( pix ) 1165 if ( pix )
1166 pix->updateAccessed(); 1166 pix->updateAccessed();
1167 return ( pix ); 1167 return ( pix );
1168} 1168}
1169 1169
1170OThemePixmap* OThemeCache::verticalPixmap( int h, int widgetID ) 1170OThemePixmap* OThemeCache::verticalPixmap( int h, int widgetID )
1171{ 1171{
1172 kthemeKey key; 1172 kthemeKey key;
1173 key.cacheKey = 0; // shut up, gcc 1173 key.cacheKey = 0; // shut up, gcc
1174 key.data.id = widgetID; 1174 key.data.id = widgetID;
1175 key.data.width = 0; 1175 key.data.width = 0;
1176 key.data.height = h; 1176 key.data.height = h;
1177 key.data.border = false; 1177 key.data.border = false;
1178 key.data.mask = false; 1178 key.data.mask = false;
1179 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey ); 1179 OThemePixmap *pix = cache.find( ( unsigned long ) key.cacheKey );
1180 if ( pix ) 1180 if ( pix )
1181 pix->updateAccessed(); 1181 pix->updateAccessed();
1182 return ( pix ); 1182 return ( pix );
1183} 1183}
1184 1184
1185bool OThemeCache::insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID, 1185bool OThemeCache::insert( OThemePixmap *pixmap, ScaleHint scale, int widgetID,
1186 bool border, bool mask ) 1186 bool border, bool mask )
1187{ 1187{
1188 kthemeKey key; 1188 kthemeKey key;
1189 key.cacheKey = 0; // shut up, gcc 1189 key.cacheKey = 0; // shut up, gcc
1190 key.data.id = widgetID; 1190 key.data.id = widgetID;
1191 key.data.width = ( scale == FullScale || scale == HorizontalScale ) ? 1191 key.data.width = ( scale == FullScale || scale == HorizontalScale ) ?
1192 pixmap->width() : 0; 1192 pixmap->width() : 0;
1193 key.data.height = ( scale == FullScale || scale == VerticalScale ) ? 1193 key.data.height = ( scale == FullScale || scale == VerticalScale ) ?
1194 pixmap->height() : 0; 1194 pixmap->height() : 0;
1195 key.data.border = border; 1195 key.data.border = border;
1196 key.data.mask = mask; 1196 key.data.mask = mask;
1197 1197
1198 if ( cache.find( ( unsigned long ) key.cacheKey, true ) != NULL ) { 1198 if ( cache.find( ( unsigned long ) key.cacheKey, true ) != NULL ) {
1199 return ( true ); // a pixmap of this scale is already in there 1199 return ( true ); // a pixmap of this scale is already in there
1200 } 1200 }
1201 return ( cache.insert( ( unsigned long ) key.cacheKey, pixmap, 1201 return ( cache.insert( ( unsigned long ) key.cacheKey, pixmap,
1202 pixmap->width() * pixmap->height() * pixmap->depth() / 8 ) ); 1202 pixmap->width() * pixmap->height() * pixmap->depth() / 8 ) );
1203} 1203}
1204 1204
1205//#include "kthemebase.moc" 1205//#include "kthemebase.moc"