smallmap_gui.c
changeset 4000 4009d092b306
parent 3882 c2e3e12e71d6
child 4171 5c6e60c392c3
equal deleted inserted replaced
3999:69dfaadb5c3c 4000:4009d092b306
   936 {
   936 {
   937 	switch (e->event) {
   937 	switch (e->event) {
   938 	case WE_CREATE: /* Disable zoom in button */
   938 	case WE_CREATE: /* Disable zoom in button */
   939 		w->disabled_state = (1 << 5);
   939 		w->disabled_state = (1 << 5);
   940 		break;
   940 		break;
       
   941 
   941 	case WE_PAINT:
   942 	case WE_PAINT:
   942 		// set the number in the title bar
   943 		// set the number in the title bar
   943 		SetDParam(0, (w->window_number+1));
   944 		SetDParam(0, w->window_number + 1);
   944 
   945 
   945 		DrawWindowWidgets(w);
   946 		DrawWindowWidgets(w);
   946 		DrawWindowViewport(w);
   947 		DrawWindowViewport(w);
   947 		break;
   948 		break;
   948 
   949 
   949 	case WE_CLICK: {
   950 	case WE_CLICK:
   950 		switch (e->click.widget) {
   951 		switch (e->click.widget) {
   951 		case 5: /* zoom in */
   952 			case 5: DoZoomInOutWindow(ZOOM_IN,  w); break;
   952 			DoZoomInOutWindow(ZOOM_IN, w);
   953 			case 6: DoZoomInOutWindow(ZOOM_OUT, w); break;
   953 			break;
   954 
   954 		case 6: /* zoom out */
       
   955 			DoZoomInOutWindow(ZOOM_OUT, w);
       
   956 			break;
       
   957 		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
   955 		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
   958 			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
   956 			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
   959 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
   957 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
   960 			int y = WP(w, vp_d).scrollpos_y;
   958 			int y = WP(w, vp_d).scrollpos_y;
   961 
   959 
   962 			// set this view to same location. Based on the center, adjusting for zoom
   960 			// set this view to same location. Based on the center, adjusting for zoom
   963 			WP(w2, vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
   961 			WP(w2, vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
   964 			WP(w2, vp_d).scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   962 			WP(w2, vp_d).scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   965 		} break;
   963 		} break;
       
   964 
   966 		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
   965 		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
   967 			const Window* w2 = FindWindowById(WC_MAIN_WINDOW, 0);
   966 			const Window* w2 = FindWindowById(WC_MAIN_WINDOW, 0);
   968 			int x = WP(w2, const vp_d).scrollpos_x;
   967 			int x = WP(w2, const vp_d).scrollpos_x;
   969 			int y = WP(w2, const vp_d).scrollpos_y;
   968 			int y = WP(w2, const vp_d).scrollpos_y;
   970 
   969 
   971 			WP(w, vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
   970 			WP(w, vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
   972 			WP(w, vp_d).scrollpos_y =  y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   971 			WP(w, vp_d).scrollpos_y =  y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   973 		} break;
   972 		} break;
   974 		}
   973 		}
   975 	} break;
   974 		break;
   976 
   975 
   977 	case WE_RESIZE:
   976 	case WE_RESIZE:
   978 		w->viewport->width  += e->sizing.diff.x;
   977 		w->viewport->width  += e->sizing.diff.x;
   979 		w->viewport->height += e->sizing.diff.y;
   978 		w->viewport->height += e->sizing.diff.y;
   980 
       
   981 		w->viewport->virtual_width  += e->sizing.diff.x;
   979 		w->viewport->virtual_width  += e->sizing.diff.x;
   982 		w->viewport->virtual_height += e->sizing.diff.y;
   980 		w->viewport->virtual_height += e->sizing.diff.y;
   983 		break;
   981 		break;
   984 	}
   982 	}
   985 }
   983 }