gtk+ r22165 - in trunk: . gdk/win32



Author: tml
Date: Wed Jan 21 20:51:22 2009
New Revision: 22165
URL: http://svn.gnome.org/viewvc/gtk+?rev=22165&view=rev

Log:
2009-01-21  Tor Lillqvist  <tml novell com>

	* gdk/win32/gdkcursor-win32.c: Rename static local functions and
	variables to not have any unnecessary _ or _gdk_win32 prefix.

	* gdk/win32/gdkcursor-win32.c (hcursor_from_type): Implement
	creating a GDK_BLANK_CURSOR.



Modified:
   trunk/ChangeLog
   trunk/gdk/win32/gdkcursor-win32.c

Modified: trunk/gdk/win32/gdkcursor-win32.c
==============================================================================
--- trunk/gdk/win32/gdkcursor-win32.c	(original)
+++ trunk/gdk/win32/gdkcursor-win32.c	Wed Jan 21 20:51:22 2009
@@ -61,26 +61,27 @@
 #endif
 
 static HCURSOR
-_gdk_win32_data_to_wcursor (GdkCursorType cursor_type)
+hcursor_from_type (GdkCursorType cursor_type)
 {
   gint i, j, x, y, ofs;
-  HCURSOR rv = NULL;
+  HCURSOR rv;
   gint w, h;
   guchar *and_plane, *xor_plane;
 
-  for (i = 0; i < G_N_ELEMENTS (cursors); i++)
-    if (cursors[i].type == cursor_type)
-      break;
-
-  if (i >= G_N_ELEMENTS (cursors) || !cursors[i].name)
-    return NULL;
-
-  /* use real win32 cursor if possible */
-  if (cursors[i].builtin)
+  if (cursor_type != GDK_BLANK_CURSOR)
     {
-      return LoadCursor (NULL, cursors[i].builtin);
+      for (i = 0; i < G_N_ELEMENTS (cursors); i++)
+	if (cursors[i].type == cursor_type)
+	  break;
+
+      if (i >= G_N_ELEMENTS (cursors) || !cursors[i].name)
+	return NULL;
+
+      /* Use real Win32 cursor if possible */
+      if (cursors[i].builtin)
+	return LoadCursor (NULL, cursors[i].builtin);
     }
-
+  
   w = GetSystemMetrics (SM_CXCURSOR);
   h = GetSystemMetrics (SM_CYCURSOR);
 
@@ -89,34 +90,43 @@
   xor_plane = g_malloc ((w/8) * h);
   memset (xor_plane, 0, (w/8) * h);
 
+  if (cursor_type != GDK_BLANK_CURSOR)
+    {
+
 #define SET_BIT(v,b)  (v |= (1 << b))
 #define RESET_BIT(v,b)  (v &= ~(1 << b))
 
-  for (j = 0, y = 0; y < cursors[i].height && y < h ; y++)
-    {
-      ofs = (y * w) / 8;
-      j = y * cursors[i].width;
-
-      for (x = 0; x < cursors[i].width && x < w ; x++, j++)
-      {
-        gint pofs = ofs + x / 8;
-        guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
-        gint bit = 7 - (j % cursors[i].width) % 8;
-
-        if (data)
-          {
-            RESET_BIT (and_plane[pofs], bit);
-            if (data == 1)
-              SET_BIT (xor_plane[pofs], bit);
-          }
-      }
-    }
+      for (j = 0, y = 0; y < cursors[i].height && y < h ; y++)
+	{
+	  ofs = (y * w) / 8;
+	  j = y * cursors[i].width;
+	  
+	  for (x = 0; x < cursors[i].width && x < w ; x++, j++)
+	    {
+	      gint pofs = ofs + x / 8;
+	      guchar data = (cursors[i].data[j/4] & (0xc0 >> (2 * (j%4)))) >> (2 * (3 - (j%4)));
+	      gint bit = 7 - (j % cursors[i].width) % 8;
+	      
+	      if (data)
+		{
+		  RESET_BIT (and_plane[pofs], bit);
+		  if (data == 1)
+		    SET_BIT (xor_plane[pofs], bit);
+		}
+	    }
+	}
 
 #undef SET_BIT
 #undef RESET_BIT
 
-  rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
-		     w, h, and_plane, xor_plane);
+      rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
+			 w, h, and_plane, xor_plane);
+    }
+  else
+    {
+      rv = CreateCursor (_gdk_app_hmodule, 0, 0,
+			 w, h, and_plane, xor_plane);
+    }
   if (rv == NULL)
     WIN32_API_FAILED ("CreateCursor");
   g_free (and_plane);
@@ -126,7 +136,8 @@
 }
 
 static GdkCursor*
-_gdk_win32_cursor_new_from_hcursor (HCURSOR hcursor, GdkCursorType cursor_type)
+cursor_new_from_hcursor (HCURSOR       hcursor,
+			 GdkCursorType cursor_type)
 {
   GdkCursorPrivate *private;
   GdkCursor *cursor;
@@ -148,15 +159,15 @@
 
   g_return_val_if_fail (display == _gdk_display, NULL);
 
-  hcursor = _gdk_win32_data_to_wcursor (cursor_type);
+  hcursor = hcursor_from_type (cursor_type);
 
   if (hcursor == NULL)
     g_warning ("gdk_cursor_new_for_display: no cursor %d found", cursor_type);
   else
-    GDK_NOTE (MISC, g_print ("gdk_cursor_new_for_display: %d: %p\n",
-			     cursor_type, hcursor));
+    GDK_NOTE (CURSOR, g_print ("gdk_cursor_new_for_display: %d: %p\n",
+			       cursor_type, hcursor));
 
-  return _gdk_win32_cursor_new_from_hcursor (hcursor, cursor_type);
+  return cursor_new_from_hcursor (hcursor, cursor_type);
 }
 
 static gboolean
@@ -216,9 +227,7 @@
   source_bpl = ((width - 1)/32 + 1)*4;
   mask_bpl = ((mask_impl->width - 1)/32 + 1)*4;
 
-#ifdef G_ENABLE_DEBUG
-  if (_gdk_debug_flags & GDK_DEBUG_CURSOR)
-    {
+  GDK_NOTE (CURSOR, {
       g_print ("gdk_cursor_new_from_pixmap: source=%p:\n",
 	       source_impl->parent_instance.handle);
       for (iy = 0; iy < height; iy++)
@@ -254,8 +263,7 @@
 	    }
 	  g_print ("\n");
 	}
-    }
-#endif
+    });
 
   /* Such complex bit manipulation for this simple task, sigh.
    * The X cursor and Windows cursor concepts are quite different.
@@ -319,22 +327,22 @@
   hcursor = CreateCursor (_gdk_app_hmodule, x, y, cursor_width, cursor_height,
 			  and_mask, xor_mask);
 
-  GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
-			   "%p (%dx%d) %p (%dx%d) = %p (%dx%d)\n",
-			   GDK_PIXMAP_HBITMAP (source),
-			   source_impl->width, source_impl->height,
-			   GDK_PIXMAP_HBITMAP (mask),
-			   mask_impl->width, mask_impl->height,
-			   hcursor, cursor_width, cursor_height));
+  GDK_NOTE (CURSOR, g_print ("gdk_cursor_new_from_pixmap: "
+			     "%p (%dx%d) %p (%dx%d) = %p (%dx%d)\n",
+			     GDK_PIXMAP_HBITMAP (source),
+			     source_impl->width, source_impl->height,
+			     GDK_PIXMAP_HBITMAP (mask),
+			     mask_impl->width, mask_impl->height,
+			     hcursor, cursor_width, cursor_height));
 
   g_free (xor_mask);
   g_free (and_mask);
 
-  return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
+  return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
 }
 
-/* The named cursors below are presumably not really useful, as the
- * names are Win32-specific. No GTK+ application developed on Unix
+/* FIXME: The named cursors below are presumably not really useful, as
+ * the names are Win32-specific. No GTK+ application developed on Unix
  * (and most cross-platform GTK+ apps are developed on Unix) is going
  * to look for cursors under these Win32 names anyway.
  *
@@ -350,7 +358,7 @@
 static struct {
   char *name;
   char *id;
-} _default_cursors[] = {
+} default_cursors[] = {
   { "appstarting", IDC_APPSTARTING },
   { "arrow", IDC_ARROW },
   { "cross", IDC_CROSS },
@@ -377,17 +385,17 @@
 
   g_return_val_if_fail (display == _gdk_display, NULL);
 
-  for (i = 0; i < G_N_ELEMENTS(_default_cursors); i++)
+  for (i = 0; i < G_N_ELEMENTS(default_cursors); i++)
     {
-      if (0 == strcmp(_default_cursors[i].name, name))
-        hcursor = LoadCursor (NULL, _default_cursors[i].id);
+      if (0 == strcmp(default_cursors[i].name, name))
+        hcursor = LoadCursor (NULL, default_cursors[i].id);
     }
   /* allow to load named cursor resources linked into the executable */
   if (!hcursor)
     hcursor = LoadCursor (_gdk_app_hmodule, name);
 
   if (hcursor)
-    return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_X_CURSOR);
+    return cursor_new_from_hcursor (hcursor, GDK_X_CURSOR);
 
   return NULL;
 }
@@ -400,8 +408,8 @@
   g_return_if_fail (cursor != NULL);
   private = (GdkCursorPrivate *) cursor;
 
-  GDK_NOTE (MISC, g_print ("_gdk_cursor_destroy: %p\n",
-			   (cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->hcursor : 0));
+  GDK_NOTE (CURSOR, g_print ("_gdk_cursor_destroy: %p\n",
+			     (cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->hcursor : 0));
 
   if (GetCursor () == private->hcursor)
     SetCursor (NULL);
@@ -618,7 +626,7 @@
   hcursor = _gdk_win32_pixbuf_to_hcursor (pixbuf, x, y);
   if (!hcursor)
     return NULL;
-  return _gdk_win32_cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
+  return cursor_new_from_hcursor (hcursor, GDK_CURSOR_IS_PIXMAP);
 }
 
 gboolean 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]