📄 gdkgeometry-win32.c
字号:
/* GDK - The GIMP Drawing Kit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *//* gdkgeometry-win32.c: emulation of 32 bit coordinates within the * limits of Win32 GDI. The idea of big window emulation is more or less * a copy of the X11 version, and the equvalent of guffaw scrolling * is ScrollWindowEx(). While we determine the invalidated region * ourself during scrolling, we do not pass SW_INVALIDATE to * ScrollWindowEx() to avoid a unnecessary WM_PAINT. * * Bits are always scrolled correctly by ScrollWindowEx(), but * some big children may hit the coordinate boundary (i.e. * win32_x/win32_y < -16383) after scrolling. They needed to be moved * back to the real position determined by gdk_window_compute_position(). * This is handled in gdk_window_postmove(). * * The X11 version by Owen Taylor <otaylor@redhat.com> * Copyright Red Hat, Inc. 2000 * Win32 hack by Tor Lillqvist <tml@iki.fi> * and Hans Breuer <hans@breuer.org> * Modified by Ivan, Wong Yat Cheung <email@ivanwong.info> * so that big window emulation finally works. */#include <config.h>#include "gdk.h" /* For gdk_rectangle_intersect */#include "gdkregion.h"#include "gdkregion-generic.h"#include "gdkprivate-win32.h"#define SIZE_LIMIT 32767typedef struct _GdkWindowParentPos GdkWindowParentPos;struct _GdkWindowParentPos{ gint x; gint y; gint win32_x; gint win32_y; GdkRectangle clip_rect;};static void gdk_window_compute_position (GdkWindowImplWin32 *window, GdkWindowParentPos *parent_pos, GdkWin32PositionInfo *info);static void gdk_window_compute_parent_pos (GdkWindowImplWin32 *window, GdkWindowParentPos *parent_pos);static void gdk_window_postmove (GdkWindow *window, GdkWindowParentPos *parent_pos, gboolean anti_scroll);static void gdk_window_tmp_unset_bg (GdkWindow *window);static void gdk_window_tmp_reset_bg (GdkWindow *window);static GdkRegion *gdk_window_clip_changed (GdkWindow *window, GdkRectangle *old_clip, GdkRectangle *new_clip);static void gdk_window_post_scroll (GdkWindow *window, GdkRegion *new_clip_region);void_gdk_windowing_window_get_offsets (GdkWindow *window, gint *x_offset, gint *y_offset){ GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); *x_offset = impl->position_info.x_offset; *y_offset = impl->position_info.y_offset;}void_gdk_window_init_position (GdkWindow *window){ GdkWindowParentPos parent_pos; GdkWindowImplWin32 *impl; g_return_if_fail (GDK_IS_WINDOW (window)); impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); gdk_window_compute_parent_pos (impl, &parent_pos); gdk_window_compute_position (impl, &parent_pos, &impl->position_info);}voidgdk_window_scroll (GdkWindow *window, gint dx, gint dy){ GdkRegion *invalidate_region; GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkRectangle dest_rect; GList *tmp_list; GdkWindowParentPos parent_pos; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; GDK_NOTE (EVENTS, g_print ("gdk_window_scroll: %p %d,%d\n", GDK_WINDOW_HWND (window), dx, dy)); obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); if (dx == 0 && dy == 0) return; /* Move the current invalid region */ if (obj->update_area) gdk_region_offset (obj->update_area, dx, dy); invalidate_region = gdk_region_rectangle (&impl->position_info.clip_rect); dest_rect = impl->position_info.clip_rect; dest_rect.x += dx; dest_rect.y += dy; gdk_rectangle_intersect (&dest_rect, &impl->position_info.clip_rect, &dest_rect); if (dest_rect.width > 0 && dest_rect.height > 0) { GdkRegion *tmp_region; tmp_region = gdk_region_rectangle (&dest_rect); gdk_region_subtract (invalidate_region, tmp_region); gdk_region_destroy (tmp_region); } gdk_window_compute_parent_pos (impl, &parent_pos); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.win32_x += impl->position_info.x; parent_pos.win32_y += impl->position_info.y; parent_pos.clip_rect = impl->position_info.clip_rect; gdk_window_tmp_unset_bg (window); if (!ScrollWindowEx (GDK_WINDOW_HWND (window), dx, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN)) WIN32_API_FAILED ("ScrollWindowEx"); if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); tmp_list = obj->children; while (tmp_list) { GDK_WINDOW_OBJECT(tmp_list->data)->x += dx; GDK_WINDOW_OBJECT(tmp_list->data)->y += dy; gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region);}void_gdk_window_move_resize_child (GdkWindow *window, gint x, gint y, gint width, gint height){ GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkWin32PositionInfo new_info; GdkWindowParentPos parent_pos; GList *tmp_list; gint d_xoffset, d_yoffset; gint dx, dy; gboolean is_move; gboolean is_resize; GdkRegion *new_clip_region; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@+%d+%d %dx%d@+%d+%d\n", _gdk_win32_drawable_description (window), obj->x, obj->y, width, height, x, y)); dx = x - obj->x; dy = y - obj->y; is_move = dx != 0 || dy != 0; is_resize = impl->width != width || impl->height != height; if (!is_move && !is_resize) { GDK_NOTE (MISC, g_print ("...neither move or resize\n")); return; } GDK_NOTE (MISC, g_print ("...%s%s\n", is_move ? "is_move " : "", is_resize ? "is_resize" : "")); obj->x = x; obj->y = y; impl->width = width; impl->height = height; gdk_window_compute_parent_pos (impl, &parent_pos); gdk_window_compute_position (impl, &parent_pos, &new_info); new_clip_region = gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.win32_x += new_info.x; parent_pos.win32_y += new_info.y; parent_pos.clip_rect = new_info.clip_rect; d_xoffset = new_info.x_offset - impl->position_info.x_offset; d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { GDK_NOTE (MISC, g_print ("...d_xoffset=%d d_yoffset=%d\n", d_xoffset, d_yoffset)); if (!ScrollWindowEx (GDK_WINDOW_HWND (window), -d_xoffset, -d_yoffset, /* in: scroll offsets */ NULL, /* in: scroll rect, NULL == entire client area */ NULL, /* in: restrict to */ NULL, /* in: update region */ NULL, /* out: update rect */ SW_SCROLLCHILDREN)) WIN32_API_FAILED ("ScrollWindowEx"); if (dx != d_xoffset || dy != d_yoffset || is_resize) { GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%dx%d@+%d+%d)\n", GDK_WINDOW_HWND (window), new_info.width, new_info.height, new_info.x, new_info.y)); if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL, new_info.x, new_info.y, new_info.width, new_info.height, SWP_NOACTIVATE | SWP_NOZORDER | (is_move ? 0 : SWP_NOMOVE) | (is_resize ? 0 : SWP_NOSIZE))) WIN32_API_FAILED ("SetWindowPos"); } if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) { GDK_NOTE (MISC, g_print ("...ShowWindow(%p, SW_SHOWNA)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA); } impl->position_info = new_info; tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } } else { if (impl->position_info.mapped && !new_info.mapped) { GDK_NOTE (MISC, g_print ("...ShowWindow(%p, SW_HIDE)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE); } GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%dx%d@+%d+%d)\n", GDK_WINDOW_HWND (window), new_info.width, new_info.height, new_info.x, new_info.y)); if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL, new_info.x, new_info.y, new_info.width, new_info.height, SWP_NOACTIVATE | SWP_NOZORDER | (is_move ? 0 : SWP_NOMOVE) | (is_resize ? 0 : SWP_NOSIZE))) WIN32_API_FAILED ("SetWindowPos"); tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) { GDK_NOTE (MISC, g_print ("...ShowWindow(%p, SW_SHOWNA)\n", GDK_WINDOW_HWND (window))); ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA); } impl->position_info = new_info; } if (new_clip_region) gdk_window_post_scroll (window, new_clip_region);}static voidgdk_window_compute_position (GdkWindowImplWin32 *window, GdkWindowParentPos *parent_pos, GdkWin32PositionInfo *info){ GdkWindowObject *wrapper;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -