widget.c
changeset 867 581154a08a78
parent 860 d756b3e0e171
child 876 d275d6d2aa65
equal deleted inserted replaced
866:6a02d5c675ad 867:581154a08a78
    67 			sb = &w->vscroll2;
    67 			sb = &w->vscroll2;
    68 			break;
    68 			break;
    69 		}
    69 		}
    70 		case  WWT_HSCROLLBAR: {
    70 		case  WWT_HSCROLLBAR: {
    71 			// horizontal scroller
    71 			// horizontal scroller
    72 			assert(wi->type == WWT_HSCROLLBAR);
    72 			w->flags4 &= ~WF_SCROLL2;
    73 			w->flags4 |= WF_HSCROLL;
    73 			w->flags4 |= WF_HSCROLL;
    74 			mi = wi->left;
    74 			mi = wi->left;
    75 			ma = wi->right;
    75 			ma = wi->right;
    76 			pos = x;
    76 			pos = x;
    77 			sb = &w->hscroll;
    77 			sb = &w->hscroll;
       
    78 			break;
    78 		}
    79 		}
    79 		default: return; //this should never happen
    80 		default: return; //this should never happen
    80 	}
    81 	}
    81 	if (pos <= mi+9) {
    82 	if (pos <= mi+9) {
    82 		// Pressing the upper button?
    83 		// Pressing the upper button?
   392 			goto restore_dparam;
   393 			goto restore_dparam;
   393 		}
   394 		}
   394 
   395 
   395 		case WWT_STICKYBOX: {
   396 		case WWT_STICKYBOX: {
   396 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0);
   397 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0);
   397 			DrawSprite((cur_click & 1) ? SPR_PIN_UP :SPR_PIN_DOWN, r.left + 2, r.top + 3);
   398 			DrawSprite((cur_click & 1) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2, r.top + 3);
   398 			break;
   399 			break;
   399 		}
   400 		}
   400 		
   401 
       
   402 		case WWT_RESIZEBOX: {
       
   403 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0);
       
   404 			DrawSprite(SPR_WINDOW_RESIZE, r.left + 2, r.top + 3);
       
   405 			break;
       
   406 		}
       
   407 
   401 		case WWT_CAPTION: {
   408 		case WWT_CAPTION: {
   402 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10);
   409 			DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10);
   403 			DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70);
   410 			DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70);
   404 
   411 
   405 			if (w->caption_color != 0xFF) {
   412 			if (w->caption_color != 0xFF) {
   434 static WindowClass _dropdown_windowclass;
   441 static WindowClass _dropdown_windowclass;
   435 static WindowNumber _dropdown_windownum;
   442 static WindowNumber _dropdown_windownum;
   436 static byte _dropdown_var1;
   443 static byte _dropdown_var1;
   437 static byte _dropdown_var2;
   444 static byte _dropdown_var2;
   438 
   445 
   439 static Widget _dropdown_menu_widgets[] = {
   446 static const Widget _dropdown_menu_widgets[] = {
   440 {     WWT_IMGBTN,     0,     0, 0,     0, 0, 0x0, STR_NULL},
   447 {     WWT_IMGBTN,   RESIZE_NONE,     0,     0, 0,     0, 0, 0x0, STR_NULL},
   441 {   WIDGETS_END},
   448 {   WIDGETS_END},
   442 };
   449 };
   443 
   450 
   444 static int GetDropdownItem(Window *w)
   451 static int GetDropdownItem(Window *w)
   445 {
   452 {
   476 			x = 1;
   483 			x = 1;
   477 			y = 2;
   484 			y = 2;
   478 			sel    = _dropdown_selindex;
   485 			sel    = _dropdown_selindex;
   479 			dis    = _dropdown_disabled;
   486 			dis    = _dropdown_disabled;
   480 			hidden = _dropdown_hide_disabled;
   487 			hidden = _dropdown_hide_disabled;
   481 		
   488 
   482 
   489 
   483 			for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) {
   490 			for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) {
   484 				if (!(hidden) | !(dis & 1)) {
   491 				if (!(hidden && (dis & 1))) {
   485 					if (_dropdown_items[i] != 0) {
   492 					if (_dropdown_items[i] != 0) {
   486 						if (sel == 0) {
   493 						if (sel == 0) {
   487 							GfxFillRect(x+1, y, x+w->width-4, y + 9, 0);
   494 							GfxFillRect(x+1, y, x+w->width-4, y + 9, 0);
   488 						}
   495 						}
   489 						DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16);
   496 						DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16);
   561 
   568 
   562 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings)
   569 void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings)
   563 {
   570 {
   564 	WindowNumber num;
   571 	WindowNumber num;
   565 	WindowClass cls;
   572 	WindowClass cls;
   566 	int i,t1,t2;
   573 	int i;
   567 	const Widget *wi;
   574 	const Widget *wi;
   568 	Window *w2;
   575 	Window *w2;
   569 	uint32 old_click_state = w->click_state;
   576 	uint32 old_click_state = w->click_state;
   570 
   577 
   571 	_dropdown_disabled = disabled_mask;
   578 	_dropdown_disabled = disabled_mask;
   608 				i--;
   615 				i--;
   609 			}
   616 			}
   610 		}
   617 		}
   611 	}
   618 	}
   612 
   619 
   613 	_dropdown_menu_widgets[0].color = wi->color;
       
   614 
       
   615 	w2 = AllocateWindow(
   620 	w2 = AllocateWindow(
   616 		w->left + wi[-1].left + 1,
   621 		w->left + wi[-1].left + 1,
   617 		w->top + wi->bottom + 2,
   622 		w->top + wi->bottom + 2,
   618 		(_dropdown_menu_widgets[0].right=t1=wi->right - wi[-1].left, t1 + 1),
   623 		wi->right - wi[-1].left + 1,
   619 		(_dropdown_menu_widgets[0].bottom=t2=i*10+3, t2+1),
   624 		i * 10 + 4,
   620 		DropdownMenuWndProc,
   625 		DropdownMenuWndProc,
   621 		0x3F,
   626 		0x3F,
   622 		_dropdown_menu_widgets);
   627 		_dropdown_menu_widgets);
   623 
   628 
       
   629 	w2->widget[0].color = wi->color;
       
   630 	w2->widget[0].right = wi->right - wi[-1].left;
       
   631 	w2->widget[0].bottom = i * 10 + 3;
   624 
   632 
   625 	w2->flags4 &= ~WF_WHITE_BORDER_MASK;
   633 	w2->flags4 &= ~WF_WHITE_BORDER_MASK;
   626 }
   634 }