204 switch (wi->type & WWT_MASK) { |
204 switch (wi->type & WWT_MASK) { |
205 case WWT_IMGBTN: |
205 case WWT_IMGBTN: |
206 case WWT_IMGBTN_2: { |
206 case WWT_IMGBTN_2: { |
207 int img = wi->data; |
207 int img = wi->data; |
208 assert(img != 0); |
208 assert(img != 0); |
209 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
209 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
210 |
210 |
211 /* show different image when clicked for WWT_IMGBTN_2 */ |
211 /* show different image when clicked for WWT_IMGBTN_2 */ |
212 if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; |
212 if ((wi->type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; |
213 DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked); |
213 DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked); |
214 goto draw_default; |
214 goto draw_default; |
215 } |
215 } |
216 |
216 |
217 case WWT_PANEL: { |
217 case WWT_PANEL: { |
218 assert(wi->data == 0); |
218 assert(wi->data == 0); |
219 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
219 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
220 goto draw_default; |
220 goto draw_default; |
221 } |
221 } |
222 |
222 |
223 case WWT_TEXTBTN: |
223 case WWT_TEXTBTN: |
224 case WWT_TEXTBTN_2: { |
224 case WWT_TEXTBTN_2: { |
225 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
225 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
226 } |
226 } |
227 /* fall through */ |
227 /* fall through */ |
228 |
228 |
229 case WWT_LABEL: { |
229 case WWT_LABEL: { |
230 StringID str = wi->data; |
230 StringID str = wi->data; |
246 case WWT_MATRIX: { |
246 case WWT_MATRIX: { |
247 int c, d, ctr; |
247 int c, d, ctr; |
248 int x, amt1, amt2; |
248 int x, amt1, amt2; |
249 int color; |
249 int color; |
250 |
250 |
251 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
251 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
252 |
252 |
253 c = GB(wi->data, 0, 8); |
253 c = GB(wi->data, 0, 8); |
254 amt1 = (wi->right - wi->left + 1) / c; |
254 amt1 = (wi->right - wi->left + 1) / c; |
255 |
255 |
256 d = GB(wi->data, 8, 8); |
256 d = GB(wi->data, 8, 8); |
294 |
294 |
295 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
295 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
296 |
296 |
297 // draw up/down buttons |
297 // draw up/down buttons |
298 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); |
298 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); |
299 DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
299 DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
300 DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
300 DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
301 |
301 |
302 clicked = (((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); |
302 clicked = (((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); |
303 DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
303 DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
304 DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
304 DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
305 |
305 |
306 c1 = _colour_gradient[wi->color&0xF][3]; |
306 c1 = _colour_gradient[wi->color&0xF][3]; |
307 c2 = _colour_gradient[wi->color&0xF][7]; |
307 c2 = _colour_gradient[wi->color&0xF][7]; |
308 |
308 |
315 GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
315 GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
316 GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
316 GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
317 GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
317 GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
318 |
318 |
319 pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
319 pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
320 DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : 0); |
320 DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : FR_NONE); |
321 break; |
321 break; |
322 } |
322 } |
323 case WWT_SCROLL2BAR: { |
323 case WWT_SCROLL2BAR: { |
324 Point pt; |
324 Point pt; |
325 int c1,c2; |
325 int c1,c2; |
326 |
326 |
327 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
327 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
328 |
328 |
329 // draw up/down buttons |
329 // draw up/down buttons |
330 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); |
330 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); |
331 DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
331 DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
332 DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
332 DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10); |
333 |
333 |
334 clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); |
334 clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); |
335 DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
335 DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
336 DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
336 DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
337 |
337 |
338 c1 = _colour_gradient[wi->color&0xF][3]; |
338 c1 = _colour_gradient[wi->color&0xF][3]; |
339 c2 = _colour_gradient[wi->color&0xF][7]; |
339 c2 = _colour_gradient[wi->color&0xF][7]; |
340 |
340 |
347 GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
347 GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
348 GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
348 GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
349 GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
349 GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
350 |
350 |
351 pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
351 pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
352 DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : 0); |
352 DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? FR_LOWERED : FR_NONE); |
353 break; |
353 break; |
354 } |
354 } |
355 |
355 |
356 // horizontal scrollbar |
356 // horizontal scrollbar |
357 case WWT_HSCROLLBAR: { |
357 case WWT_HSCROLLBAR: { |
359 int c1,c2; |
359 int c1,c2; |
360 |
360 |
361 assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere! |
361 assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere! |
362 |
362 |
363 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL)); |
363 clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL)); |
364 DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
364 DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
365 DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked); |
365 DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked); |
366 |
366 |
367 clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL)); |
367 clicked = ((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL)); |
368 DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
368 DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
369 DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked); |
369 DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked); |
370 |
370 |
371 c1 = _colour_gradient[wi->color&0xF][3]; |
371 c1 = _colour_gradient[wi->color&0xF][3]; |
372 c2 = _colour_gradient[wi->color&0xF][7]; |
372 c2 = _colour_gradient[wi->color&0xF][7]; |
373 |
373 |
381 GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
381 GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
382 GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
382 GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
383 |
383 |
384 // draw actual scrollbar |
384 // draw actual scrollbar |
385 pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
385 pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
386 DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : 0); |
386 DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE); |
387 |
387 |
388 break; |
388 break; |
389 } |
389 } |
390 |
390 |
391 case WWT_FRAME: { |
391 case WWT_FRAME: { |
421 |
421 |
422 case WWT_STICKYBOX: { |
422 case WWT_STICKYBOX: { |
423 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
423 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
424 |
424 |
425 clicked = !!(w->flags4 & WF_STICKY); |
425 clicked = !!(w->flags4 & WF_STICKY); |
426 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
426 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
427 DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); |
427 DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); |
428 break; |
428 break; |
429 } |
429 } |
430 |
430 |
431 case WWT_RESIZEBOX: { |
431 case WWT_RESIZEBOX: { |
432 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
432 assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
433 |
433 |
434 clicked = !!(w->flags4 & WF_SIZING); |
434 clicked = !!(w->flags4 & WF_SIZING); |
435 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
435 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : FR_NONE); |
436 DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked); |
436 DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked); |
437 break; |
437 break; |
438 } |
438 } |
439 |
439 |
440 case WWT_CLOSEBOX: { |
440 case WWT_CLOSEBOX: { |
441 assert(r.right - r.left == 10); // ensure the same sizes are used everywhere |
441 assert(r.right - r.left == 10); // ensure the same sizes are used everywhere |
442 |
442 |
443 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0); |
443 DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_NONE); |
444 DrawString(r.left + 2, r.top + 2, STR_00C5, 0); |
444 DrawString(r.left + 2, r.top + 2, STR_00C5, 0); |
445 break; |
445 break; |
446 } |
446 } |
447 |
447 |
448 case WWT_CAPTION: { |
448 case WWT_CAPTION: { |