smallmap_gui.c
changeset 1815 733868a48ab3
parent 1516 dc914162ad01
child 1891 862800791170
equal deleted inserted replaced
1814:9fd6011c77d8 1815:733868a48ab3
   918 {   WIDGETS_END},
   918 {   WIDGETS_END},
   919 };
   919 };
   920 
   920 
   921 static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
   921 static void ExtraViewPortWndProc(Window *w, WindowEvent *e)
   922 {
   922 {
   923 	ViewPort *vp = w->viewport;
   923 	switch (e->event) {
   924 
   924 	case WE_CREATE: /* Disable zoom in button */
   925 	switch(e->event) {
   925 		w->disabled_state = (1 << 5);
   926 	case WE_PAINT: {
   926 		break;
       
   927 	case WE_PAINT:
   927 		// set the number in the title bar
   928 		// set the number in the title bar
   928 		SetDParam(0, (w->window_number+1));
   929 		SetDParam(0, (w->window_number+1));
   929 
   930 
   930 		DrawWindowWidgets(w);
   931 		DrawWindowWidgets(w);
   931 		DrawWindowViewport(w);
   932 		DrawWindowViewport(w);
   932 	}	break;
   933 		break;
       
   934 
   933 	case WE_CLICK: {
   935 	case WE_CLICK: {
   934 		switch(e->click.widget) {
   936 		switch (e->click.widget) {
   935 		case 5: { /* zoom in */
   937 		case 5: /* zoom in */
   936 			DoZoomInOutWindow(ZOOM_IN, w);
   938 			DoZoomInOutWindow(ZOOM_IN, w);
       
   939 			break;
       
   940 		case 6: /* zoom out */
       
   941 			DoZoomInOutWindow(ZOOM_OUT, w);
       
   942 			break;
       
   943 		case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */
       
   944 			Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
       
   945 			int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
       
   946 			int y = WP(w, vp_d).scrollpos_y;
       
   947 
       
   948 			// set this view to same location. Based on the center, adjusting for zoom
       
   949 			WP(w2, vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
       
   950 			WP(w2, vp_d).scrollpos_y =  y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   937 		} break;
   951 		} break;
   938 
   952 		case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
   939 		case 6: { /* zoom out */
   953 			const Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0);
   940 			DoZoomInOutWindow(ZOOM_OUT, w);
   954 			int x = WP(w2, vp_d).scrollpos_x;
       
   955 			int y = WP(w2, vp_d).scrollpos_y;
       
   956 
       
   957 			WP(w, vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  w->viewport->virtual_width) / 2;
       
   958 			WP(w, vp_d).scrollpos_y =  y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
   941 		} break;
   959 		} break;
   942 
       
   943 		case 7: { /* location button (move main view to same spot as this view) */
       
   944 			Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0);
       
   945 			int x = WP(w,vp_d).scrollpos_x; // Where is the main looking at
       
   946 			int y = WP(w,vp_d).scrollpos_y;
       
   947 
       
   948 			// set this view to same location. Based on the center, adjusting for zoom
       
   949 			WP(w2,vp_d).scrollpos_x =  x - (w2->viewport->virtual_width -  (w->viewport->virtual_width  << vp->zoom)) / 2;
       
   950 			WP(w2,vp_d).scrollpos_y =  y - (w2->viewport->virtual_height - (w->viewport->virtual_height << vp->zoom)) / 2;
       
   951 		} break;
       
   952 		case 8: { /* inverse location button (move this view to same spot as main view) */
       
   953 			Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0);
       
   954 			int x = WP(w2,vp_d).scrollpos_x;
       
   955 			int y = WP(w2,vp_d).scrollpos_y;
       
   956 
       
   957 			WP(w,vp_d).scrollpos_x =  x + (w2->viewport->virtual_width -  (w->viewport->virtual_width  << vp->zoom)) / 2;
       
   958 			WP(w,vp_d).scrollpos_y =  y + (w2->viewport->virtual_height - (w->viewport->virtual_height << vp->zoom)) / 2;
       
   959 		} break;
       
   960 		}
   960 		}
   961 	} break;
   961 	} break;
   962 	case WE_RESIZE: {
   962 
       
   963 	case WE_RESIZE:
   963 		w->viewport->width  += e->sizing.diff.x;
   964 		w->viewport->width  += e->sizing.diff.x;
   964 		w->viewport->height += e->sizing.diff.y;
   965 		w->viewport->height += e->sizing.diff.y;
   965 
   966 
   966 		w->viewport->virtual_width  += e->sizing.diff.x;
   967 		w->viewport->virtual_width  += e->sizing.diff.x;
   967 		w->viewport->virtual_height += e->sizing.diff.y;
   968 		w->viewport->virtual_height += e->sizing.diff.y;
   968 	} break;
   969 		break;
   969 	}
   970 	}
   970 }
   971 }
   971 
   972 
   972 static const WindowDesc _extra_view_port_desc = {
   973 static const WindowDesc _extra_view_port_desc = {
   973 	-1,-1, 300, 268,
   974 	-1,-1, 300, 268,
   988 	}
   989 	}
   989 
   990 
   990 	w = AllocateWindowDescFront(&_extra_view_port_desc, i);
   991 	w = AllocateWindowDescFront(&_extra_view_port_desc, i);
   991 	if (w) {
   992 	if (w) {
   992 		int x, y;
   993 		int x, y;
   993 		// disable zoom in button
       
   994 		w->disabled_state = (1 << 4);
       
   995 		// the main window with the main view
   994 		// the main window with the main view
   996 		v = FindWindowById(WC_MAIN_WINDOW, 0);
   995 		v = FindWindowById(WC_MAIN_WINDOW, 0);
   997 		// New viewport start ats (zero,zero)
   996 		// New viewport start ats (zero,zero)
   998 		AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
   997 		AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
   999 
   998 
  1000 		// center on same place as main window (zoom is maximum, no adjustment needed)
   999 		// center on same place as main window (zoom is maximum, no adjustment needed)
  1001 		x = WP(v,vp_d).scrollpos_x;
  1000 		x = WP(v, vp_d).scrollpos_x;
  1002 		y = WP(v,vp_d).scrollpos_y;
  1001 		y = WP(v, vp_d).scrollpos_y;
  1003 		WP(w,vp_d).scrollpos_x = x + (v->viewport->virtual_width  - (294)) / 2;
  1002 		WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width  - (294)) / 2;
  1004 		WP(w,vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2;
  1003 		WP(w, vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2;
  1005 	}
  1004 	}
  1006 }
  1005 }