⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkwindow-win32.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 5 页
字号:
/* GDK - The GIMP Drawing Kit * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald * Copyright (C) 1998-2004 Tor Lillqvist * Copyright (C) 2001-2004 Hans Breuer * * 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. *//* * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS * file for a list of people on the GTK+ Team.  See the ChangeLog * files for a list of changes.  These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/.  */#include <config.h>#include <stdlib.h>#include "gdk.h" /* gdk_rectangle_intersect */#include "gdkevents.h"#include "gdkpixmap.h"#include "gdkwindow.h"#include "gdkdisplay.h"#include "gdkprivate-win32.h"#include "gdkinput-win32.h"#if 0#include <gdk-pixbuf/gdk-pixbuf.h>#include <stdio.h>#endifstatic GdkColormap* gdk_window_impl_win32_get_colormap (GdkDrawable *drawable);static void         gdk_window_impl_win32_set_colormap (GdkDrawable *drawable,							GdkColormap *cmap);static void         gdk_window_impl_win32_get_size     (GdkDrawable *drawable,							gint *width,							gint *height);static GdkRegion*   gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable);static void gdk_window_impl_win32_init       (GdkWindowImplWin32      *window);static void gdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass);static void gdk_window_impl_win32_finalize   (GObject                 *object);static gpointer parent_class = NULL;GType_gdk_window_impl_win32_get_type (void){  static GType object_type = 0;  if (!object_type)    {      static const GTypeInfo object_info =      {        sizeof (GdkWindowImplWin32Class),        (GBaseInitFunc) NULL,        (GBaseFinalizeFunc) NULL,        (GClassInitFunc) gdk_window_impl_win32_class_init,        NULL,           /* class_finalize */        NULL,           /* class_data */        sizeof (GdkWindowImplWin32),        0,              /* n_preallocs */        (GInstanceInitFunc) gdk_window_impl_win32_init,      };            object_type = g_type_register_static (GDK_TYPE_DRAWABLE_IMPL_WIN32,                                            "GdkWindowImplWin32",                                            &object_info, 0);    }    return object_type;}GType_gdk_window_impl_get_type (void){  return _gdk_window_impl_win32_get_type ();}static voidgdk_window_impl_win32_init (GdkWindowImplWin32 *impl){  impl->width = 1;  impl->height = 1;  impl->hcursor = NULL;  impl->hicon_big = NULL;  impl->hicon_small = NULL;  impl->hint_flags = 0;  impl->extension_events_selected = FALSE;}static voidgdk_window_impl_win32_class_init (GdkWindowImplWin32Class *klass){  GObjectClass *object_class = G_OBJECT_CLASS (klass);  GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);    parent_class = g_type_class_peek_parent (klass);  object_class->finalize = gdk_window_impl_win32_finalize;  drawable_class->set_colormap = gdk_window_impl_win32_set_colormap;  drawable_class->get_colormap = gdk_window_impl_win32_get_colormap;  drawable_class->get_size = gdk_window_impl_win32_get_size;  /* Visible and clip regions are the same */  drawable_class->get_clip_region = gdk_window_impl_win32_get_visible_region;  drawable_class->get_visible_region = gdk_window_impl_win32_get_visible_region;}static voidgdk_window_impl_win32_finalize (GObject *object){  GdkWindowObject *wrapper;  GdkDrawableImplWin32 *draw_impl;  GdkWindowImplWin32 *window_impl;    g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (object));  draw_impl = GDK_DRAWABLE_IMPL_WIN32 (object);  window_impl = GDK_WINDOW_IMPL_WIN32 (object);    wrapper = (GdkWindowObject*) draw_impl->wrapper;  if (!GDK_WINDOW_DESTROYED (wrapper))    {      gdk_win32_handle_table_remove (draw_impl->handle);    }  if (window_impl->hcursor != NULL)    {      if (GetCursor () == window_impl->hcursor)	SetCursor (NULL);      GDI_CALL (DestroyCursor, (window_impl->hcursor));      window_impl->hcursor = NULL;    }  if (window_impl->hicon_big != NULL)    {      GDI_CALL (DestroyIcon, (window_impl->hicon_big));      window_impl->hicon_big = NULL;    }  if (window_impl->hicon_small != NULL)    {      GDI_CALL (DestroyIcon, (window_impl->hicon_small));      window_impl->hicon_small = NULL;    }  G_OBJECT_CLASS (parent_class)->finalize (object);}void_gdk_win32_adjust_client_rect (GdkWindow *window,			       RECT      *rect){  LONG style, exstyle;  style = GetWindowLong (GDK_WINDOW_HWND (window), GWL_STYLE);  exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE);  API_CALL (AdjustWindowRectEx, (rect, style, FALSE, exstyle));}void_gdk_win32_get_adjusted_client_rect (GdkWindow *window,				     RECT      *rect){  GetClientRect (GDK_WINDOW_HWND (window), rect);  _gdk_win32_adjust_client_rect (window, rect);}static GdkColormap*gdk_window_impl_win32_get_colormap (GdkDrawable *drawable){  GdkDrawableImplWin32 *drawable_impl;    g_return_val_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable), NULL);  drawable_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);  if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&       drawable_impl->colormap == NULL)    {      drawable_impl->colormap =         gdk_screen_get_system_colormap (gdk_drawable_get_screen (drawable));      g_object_ref (drawable_impl->colormap);    }    return drawable_impl->colormap;}static voidgdk_window_impl_win32_set_colormap (GdkDrawable *drawable,				    GdkColormap *cmap){  GdkWindowImplWin32 *impl;  GdkDrawableImplWin32 *draw_impl;    g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable));  impl = GDK_WINDOW_IMPL_WIN32 (drawable);  draw_impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);  /* chain up */  GDK_DRAWABLE_CLASS (parent_class)->set_colormap (drawable, cmap);    if (cmap)    {      /* XXX */      g_print("gdk_window_impl_win32_set_colormap: XXX\n");    }}static voidgdk_window_impl_win32_get_size (GdkDrawable *drawable,				gint        *width,				gint        *height){  g_return_if_fail (GDK_IS_WINDOW_IMPL_WIN32 (drawable));  if (width)    *width = GDK_WINDOW_IMPL_WIN32 (drawable)->width;  if (height)    *height = GDK_WINDOW_IMPL_WIN32 (drawable)->height;}static GdkRegion*gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable){  GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (drawable);  GdkRectangle result_rect;  HDC hdc;  result_rect.x = 0;  result_rect.y = 0;  result_rect.width = impl->width;  result_rect.height = impl->height;  gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);  /* take this win32 specific part into account (smaller when obscured) */  hdc = GetDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (impl));  if (hdc)    {      RECT r;      if (SIMPLEREGION == GetClipBox (hdc, &r))        {          GdkRectangle gr;          gr.x = r.left + impl->position_info.x_offset;          gr.y = r.top + impl->position_info.y_offset;          gr.width = r.right - r.left;          gr.height = r.bottom - r.top;          gdk_rectangle_intersect (&result_rect, &gr, &result_rect);        }      ReleaseDC (GDK_DRAWABLE_IMPL_WIN32_HANDLE (drawable), hdc);    }  return gdk_region_rectangle (&result_rect);}void_gdk_root_window_size_init (void){  GdkWindowImplWin32 *impl;  GdkRectangle rect;  int i;  impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) _gdk_parent_root)->impl);  rect = _gdk_monitors[0];  for (i = 1; i < _gdk_num_monitors; i++)    gdk_rectangle_union (&rect, _gdk_monitors+i, &rect);  impl->width = rect.width;  impl->height = rect.height;}void_gdk_windowing_window_init (void){  GdkWindowObject *private;  GdkDrawableImplWin32 *draw_impl;  g_assert (_gdk_parent_root == NULL);    _gdk_parent_root = g_object_new (GDK_TYPE_WINDOW, NULL);  private = (GdkWindowObject *)_gdk_parent_root;  draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);    draw_impl->handle = _gdk_root_window;  draw_impl->wrapper = GDK_DRAWABLE (private);  draw_impl->colormap = gdk_colormap_get_system ();  g_object_ref (draw_impl->colormap);    private->window_type = GDK_WINDOW_ROOT;  private->depth = gdk_visual_get_system ()->depth;  _gdk_root_window_size_init ();   _gdk_window_init_position (GDK_WINDOW (private));  gdk_win32_handle_table_insert (&_gdk_root_window, _gdk_parent_root);  GDK_NOTE (MISC, g_print ("_gdk_parent_root=%p\n", GDK_WINDOW_HWND (_gdk_parent_root)));}static const gchar *get_default_title (void){  const char *title;  title = g_get_application_name ();  if (!title)    title = g_get_prgname ();  return title;}/* RegisterGdkClass *   is a wrapper function for RegisterWindowClassEx. *   It creates at least one unique class for every  *   GdkWindowType. If support for single window-specific icons *   is ever needed (e.g Dialog specific), every such window should *   get its own class */static ATOMRegisterGdkClass (GdkWindowType wtype){  static ATOM klassTOPLEVEL = 0;  static ATOM klassDIALOG   = 0;  static ATOM klassCHILD    = 0;  static ATOM klassTEMP     = 0;  static HICON hAppIcon = NULL;  static WNDCLASSEX wcl;   ATOM klass = 0;  wcl.cbSize = sizeof (WNDCLASSEX);  wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw                  * on WM_SIZE and WM_MOVE. Flicker, Performance!                  */  wcl.lpfnWndProc = _gdk_win32_window_procedure;  wcl.cbClsExtra = 0;  wcl.cbWndExtra = 0;  wcl.hInstance = _gdk_app_hmodule;  wcl.hIcon = 0;  /* initialize once! */  if (0 == hAppIcon)    {      gchar sLoc [MAX_PATH+1];      if (0 != GetModuleFileName (_gdk_app_hmodule, sLoc, MAX_PATH))	{	  hAppIcon = ExtractIcon (_gdk_app_hmodule, sLoc, 0);	  if (0 == hAppIcon)	    {	      if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))		hAppIcon = ExtractIcon (_gdk_dll_hinstance, sLoc, 0);	    }	}      if (0 == hAppIcon) 	hAppIcon = LoadIcon (NULL, IDI_APPLICATION);    }  wcl.lpszMenuName = NULL;  wcl.hIconSm = 0;  /* initialize once per class */  /*   * HB: Setting the background brush leads to flicker, because we   * don't get asked how to clear the background. This is not what   * we want, at least not for input_only windows ...   */#define ONCE_PER_CLASS() \  wcl.hIcon = CopyIcon (hAppIcon); \  wcl.hIconSm = CopyIcon (hAppIcon); \  wcl.hbrBackground = NULL; \  wcl.hCursor = LoadCursor (NULL, IDC_ARROW);     switch (wtype)    {    case GDK_WINDOW_TOPLEVEL:      if (0 == klassTOPLEVEL)	{	  wcl.lpszClassName = "gdkWindowToplevel";	  	  ONCE_PER_CLASS();	  klassTOPLEVEL = RegisterClassEx (&wcl);	}      klass = klassTOPLEVEL;      break;          case GDK_WINDOW_CHILD:      if (0 == klassCHILD)	{	  wcl.lpszClassName = "gdkWindowChild";	  	  wcl.style |= CS_PARENTDC; /* MSDN: ... enhances system performance. */	  ONCE_PER_CLASS();	  klassCHILD = RegisterClassEx (&wcl);	}      klass = klassCHILD;      break;          case GDK_WINDOW_DIALOG:      if (0 == klassDIALOG)	{	  wcl.lpszClassName = "gdkWindowDialog";	  wcl.style |= CS_SAVEBITS;	  ONCE_PER_CLASS();	  klassDIALOG = RegisterClassEx (&wcl);	}      klass = klassDIALOG;      break;          case GDK_WINDOW_TEMP:      if (0 == klassTEMP)	{	  wcl.lpszClassName = "gdkWindowTemp";	  wcl.style |= CS_SAVEBITS;	  ONCE_PER_CLASS();	  klassTEMP = RegisterClassEx (&wcl);	}      klass = klassTEMP;      break;          default:      g_assert_not_reached ();      break;    }    if (klass == 0)    {      WIN32_API_FAILED ("RegisterClassEx");      g_error ("That is a fatal error");    }  return klass;}static GdkWindow*gdk_window_new_internal (GdkWindow     *parent,			 GdkWindowAttr *attributes,			 gint           attributes_mask,			 gboolean       from_set_skip_taskbar_hint){  HANDLE hparent;  ATOM klass = 0;  DWORD dwStyle = 0, dwExStyle;  RECT rect;  GdkWindow *window;  GdkWindowObject *private;  GdkWindowImplWin32 *impl;  GdkDrawableImplWin32 *draw_impl;  GdkScreen *screen;  GdkVisual *visual;  const gchar *title;  char *mbtitle;  gint window_width, window_height;  gint offset_x = 0, offset_y = 0;  g_return_val_if_fail (attributes != NULL, NULL);  if (!parent)    {      screen = gdk_screen_get_default ();      parent = gdk_screen_get_root_window (screen);    }  else    screen = gdk_drawable_get_screen (parent);  g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);    GDK_NOTE (MISC,	    g_print ("gdk_window_new: %s\n",		     (attributes->window_type == GDK_WINDOW_TOPLEVEL ? "TOPLEVEL" :		      (attributes->window_type == GDK_WINDOW_CHILD ? "CHILD" :		       (attributes->window_type == GDK_WINDOW_DIALOG ? "DIALOG" :			(attributes->window_type == GDK_WINDOW_TEMP ? "TEMP" :			 "???"))))));  if (GDK_WINDOW_DESTROYED (parent))    return NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -