src/train_gui.cpp
changeset 5821 31fa8234ebc6
parent 5779 a694ce1457bb
child 5822 f71317de4ab6
equal deleted inserted replaced
5820:4a9da174bf1b 5821:31fa8234ebc6
   504 			}
   504 			}
   505 		}
   505 		}
   506 	}
   506 	}
   507 }
   507 }
   508 
   508 
       
   509 static void TrainDetailButtonResize(Window *w)
       
   510 {
       
   511 	/* Make the buttons in the bottom equal in size */
       
   512 	w->widget[12].right = w->widget[13].left - 1; // right point of the buttons (4/4)
       
   513 	w->widget[10].right = w->widget[12].right / 2; // the middle of the buttons (2/4)
       
   514 	w->widget[ 9].right = w->widget[10].right / 2; // 1/4 of the buttons
       
   515 	w->widget[11].right = w->widget[10].right + w->widget[ 9].right; // (2+1)/4 = 3/4 of the buttons
       
   516 	/* Now the right side of the buttons are set. We will now set the left sides next to them */
       
   517 	w->widget[10].left  = w->widget[ 9].right + 1;
       
   518 	w->widget[11].left  = w->widget[10].right + 1;
       
   519 	w->widget[12].left  = w->widget[11].right + 1;
       
   520 }
       
   521 
   509 static void TrainDetailsWndProc(Window *w, WindowEvent *e)
   522 static void TrainDetailsWndProc(Window *w, WindowEvent *e)
   510 {
   523 {
   511 	switch (e->event) {
   524 	switch (e->event) {
   512 	case WE_PAINT:
   525 	case WE_PAINT:
   513 		DrawTrainDetailsWindow(w);
   526 		DrawTrainDetailsWindow(w);
   558 				CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
   571 				CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
   559 		}
   572 		}
   560 		break;
   573 		break;
   561 
   574 
   562 	case WE_RESIZE:
   575 	case WE_RESIZE:
       
   576 		if (e->we.sizing.diff.x != 0) TrainDetailButtonResize(w);
   563 		if (e->we.sizing.diff.y == 0) break;
   577 		if (e->we.sizing.diff.y == 0) break;
   564 
   578 
   565 		w->vscroll.cap += e->we.sizing.diff.y / 14;
   579 		w->vscroll.cap += e->we.sizing.diff.y / 14;
   566 		w->widget[4].data = (w->vscroll.cap << 8) + 1;
   580 		w->widget[4].data = (w->vscroll.cap << 8) + 1;
   567 		break;
   581 		break;
   568 	}
   582 	}
   569 }
   583 }
   570 
   584 
   571 static const Widget _train_details_widgets[] = {
   585 static const Widget _train_details_widgets[] = {
   572 {   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
   586 {   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
   573 {    WWT_CAPTION, RESIZE_NONE,   14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
   587 {    WWT_CAPTION, RESIZE_RIGHT,  14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
   574 { WWT_PUSHTXTBTN, RESIZE_NONE,   14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
   588 { WWT_PUSHTXTBTN, RESIZE_LR,     14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
   575 {      WWT_PANEL, RESIZE_NONE,   14,   0, 369,  14,  55, 0x0,                  STR_NULL},
   589 {      WWT_PANEL, RESIZE_RIGHT,  14,   0, 369,  14,  55, 0x0,                  STR_NULL},
   576 {     WWT_MATRIX, RESIZE_BOTTOM, 14,   0, 357,  56, 139, 0x601,                STR_NULL},
   590 {     WWT_MATRIX, RESIZE_RB,     14,   0, 357,  56, 139, 0x601,                STR_NULL},
   577 {  WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
   591 {  WWT_SCROLLBAR, RESIZE_LRB,    14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
   578 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
   592 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
   579 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
   593 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
   580 {      WWT_PANEL, RESIZE_TB,     14,  11, 369, 140, 151, 0x0,                  STR_NULL},
   594 {      WWT_PANEL, RESIZE_RTB,    14,  11, 369, 140, 151, 0x0,                  STR_NULL},
   581 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
   595 { WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
   582 { WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
   596 { WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
   583 { WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
   597 { WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
   584 { WWT_PUSHTXTBTN, RESIZE_TB,     14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
   598 { WWT_PUSHTXTBTN, RESIZE_TB,     14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
   585 {  WWT_RESIZEBOX, RESIZE_TB,     14, 358, 369, 152, 163, 0x0,                  STR_RESIZE_BUTTON},
   599 {  WWT_RESIZEBOX, RESIZE_LRTB,   14, 358, 369, 152, 163, 0x0,                  STR_RESIZE_BUTTON},
   586 {   WIDGETS_END},
   600 {   WIDGETS_END},
   587 };
   601 };
   588 
   602 
   589 
   603 
   590 static const WindowDesc _train_details_desc = {
   604 static const WindowDesc _train_details_desc = {