示例#1
0
void GPSView::OnMouseWheel(wxMouseEvent &event){

	int rotation = event.GetWheelRotation();
	if (rotation > 0){
		m_zoom *= ZOOM_ADJUST;
	}
	else{
		m_zoom /= ZOOM_ADJUST;
	}
	RefreshBackground();
	Refresh();
}
示例#2
0
void GPSView::AddGPSPoints(GPSPoints &p){

	int width;
	int height;
	GetClientSize(&width, &height);

	Point minXY(-1, -1);
	Point maxXY(-1, -1);

	for (size_t i = 0; i < p.Count(); i++){
		Point point = ProjectPoint(p[i]);
		minXY.x = ((minXY.x == -1) ? point.x : std::min(minXY.x, point.x));
		minXY.y = ((minXY.y == -1) ? point.y : std::min(minXY.y, point.y));
		m_trackPoints.Add(point);
	}

	for (size_t i = 0; i < m_trackPoints.size(); i++){
		Point point = m_trackPoints[i];
		point.x = point.x - minXY.x;
        point.y = point.y - minXY.y;
        // now, we need to keep track the max X and Y values
        maxXY.x = (maxXY.x == -1) ? point.x : std::max(maxXY.x, point.x);
        maxXY.y = (maxXY.y == -1) ? point.y : std::max(maxXY.y, point.y);
	}

	int paddingBothSides = MIN_PADDING * 2;

	// the actual drawing space for the map on the image
    int mapWidth = width - paddingBothSides;
    int mapHeight = height - paddingBothSides;

    // determine the width and height ratio because we need to magnify the map to fit into the given image dimension
    double mapWidthRatio = mapWidth / maxXY.x;
    double mapHeightRatio = mapHeight / maxXY.y;

    // using different ratios for width and height will cause the map to be stretched. So, we have to determine
    // the global ratio that will perfectly fit into the given image dimension
    m_globalRatio = std::min(mapWidthRatio, mapHeightRatio);

    // now we need to readjust the padding to ensure the map is always drawn on the center of the given image dimension
    m_heightPadding = (height - (m_globalRatio * maxXY.y)) / 2;
    m_widthPadding = (width - (m_globalRatio * maxXY.x)) / 2;
    m_offsetPoint = minXY;
    UpdateMinMax(m_trackPoints);
    RefreshBackground();
}
示例#3
0
void GPSView::OnSize(wxSizeEvent& event)
{
	RefreshBackground();
}
示例#4
0
文件: window.cpp 项目: cheerjo/Player
void Window::Draw() {
	if (!visible) return;
	if (width <= 0 || height <= 0) return;
	if (x < -width || x > DisplayUi->GetWidth() || y < -height || y > DisplayUi->GetHeight()) return;


	if (windowskin) {
		if (width > 4 && height > 4 && (back_opacity * opacity / 255 > 0)) {
			if (background_needs_refresh) RefreshBackground();

			if (animation_frames > 0) {
				int ianimation_count = (int)animation_count;

				Rect src_rect(0, height / 2 - ianimation_count, width, ianimation_count * 2);

				background->BlitScreen(x, y + src_rect.y, src_rect);
			} else {
				background->BlitScreen(x, y);
			}
		}

		if (width > 0 && height > 0 && opacity > 0) {
			if (frame_needs_refresh) RefreshFrame();

			if (animation_frames > 0) {
				int ianimation_count = (int)animation_count;

				if (ianimation_count > 8) {
					Rect src_rect(0, height / 2 - ianimation_count, 8, ianimation_count * 2 - 16);

					frame_left->BlitScreen(x, y + 8 + src_rect.y, src_rect);
					frame_right->BlitScreen(x + width - 8, y + 8 + src_rect.y, src_rect);

					frame_up->BlitScreen(x, y + height / 2 - ianimation_count);
					frame_down->BlitScreen(x, y + height / 2 + ianimation_count - 8);
				} else {
					frame_up->BlitScreen(x, y + height / 2 - ianimation_count, Rect(0, 0, width, ianimation_count));
					frame_down->BlitScreen(x, y + height / 2, Rect(0, 8 - ianimation_count, width, ianimation_count));
				}
			} else {
				frame_up->BlitScreen(x, y);
				frame_down->BlitScreen(x, y + height - 8);
				frame_left->BlitScreen(x, y + 8);
				frame_right->BlitScreen(x + width - 8, y + 8);
			}
		}

		if (width > 16 && height > 16 && cursor_rect.width > 4 && cursor_rect.height > 4 && animation_frames == 0) {
			if (cursor_needs_refresh) RefreshCursor();

			Rect src_rect(
				-min(cursor_rect.x + border_x, 0),
				-min(cursor_rect.y + border_y, 0),
				min(cursor_rect.width, width - cursor_rect.x + border_x),
				min(cursor_rect.height, height - cursor_rect.y + border_y)
			);

			if (cursor_frame < 16)
				cursor1->BlitScreen(x + cursor_rect.x + border_x, y + cursor_rect.y + border_y, src_rect);
			else
				cursor2->BlitScreen(x + cursor_rect.x + border_x, y + cursor_rect.y + border_y, src_rect);
		}
	}

	if (contents) {
		if (width > 2 * border_x && height > 2 * border_y &&
			-ox < width - 2 * border_x && -oy < height - 2 * border_y &&
			contents_opacity > 0 && animation_frames == 0) {
			Rect src_rect(-min(-ox, 0), -min(-oy, 0),
						  min(width - 2 * border_x, width - 2 * border_x + ox),
						  min(height - 2 * border_y, height - 2 * border_y + oy));

			contents_screen->SetOpacityEffect(contents_opacity);

			contents_screen->BlitScreen(max(x + border_x, x + border_x - ox),
										max(y + border_y, y + border_y - oy), src_rect);
		}
	}

	if (pause && pause_frame > 16 && animation_frames <= 0) {
		Rect src_rect(40, 16, 16, 8);
		windowskin_screen->BlitScreen(x + width / 2 - 8, y + height - 8, src_rect);
	}

	if (up_arrow) {
		Rect src_rect(40, 8, 16, 8);
		windowskin_screen->BlitScreen(x + width / 2 - 8, y, src_rect);
	}

	if (down_arrow) {
		Rect src_rect(40, 16, 16, 8);
		windowskin_screen->BlitScreen(x + width / 2 - 8, y + height - 8, src_rect);
	}

	if (animation_frames > 0) {
		// Open/Close Animation
		animation_frames -= 1;
		animation_count += animation_increment;
		if (closing && animation_frames <= 0) {
			visible = false;
			closing = false;
		}
	}
}