1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #include "gdkproperty.h"
32 #include "gdkselection.h"
33 #include "gdkinternals.h"
34 #include "gdkprivate-win32.h"
35 #include "gdkdrawable-win32.h"
36 #include "gdkwindow-win32.h"
39 gdk_atom_intern (const gchar *atom_name,
43 static GHashTable *atom_hash = NULL;
47 atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
49 retval = g_hash_table_lookup (atom_hash, atom_name);
52 if (strcmp (atom_name, "PRIMARY") == 0)
53 retval = GDK_SELECTION_PRIMARY;
54 else if (strcmp (atom_name, "SECONDARY") == 0)
55 retval = GDK_SELECTION_SECONDARY;
56 else if (strcmp (atom_name, "CLIPBOARD") == 0)
57 retval = GDK_SELECTION_CLIPBOARD;
58 else if (strcmp (atom_name, "ATOM") == 0)
59 retval = GDK_SELECTION_TYPE_ATOM;
60 else if (strcmp (atom_name, "BITMAP") == 0)
61 retval = GDK_SELECTION_TYPE_BITMAP;
62 else if (strcmp (atom_name, "COLORMAP") == 0)
63 retval = GDK_SELECTION_TYPE_COLORMAP;
64 else if (strcmp (atom_name, "DRAWABLE") == 0)
65 retval = GDK_SELECTION_TYPE_DRAWABLE;
66 else if (strcmp (atom_name, "INTEGER") == 0)
67 retval = GDK_SELECTION_TYPE_INTEGER;
68 else if (strcmp (atom_name, "PIXMAP") == 0)
69 retval = GDK_SELECTION_TYPE_PIXMAP;
70 else if (strcmp (atom_name, "WINDOW") == 0)
71 retval = GDK_SELECTION_TYPE_WINDOW;
72 else if (strcmp (atom_name, "STRING") == 0)
73 retval = GDK_SELECTION_TYPE_STRING;
76 win32_atom = GlobalFindAtom (atom_name);
77 if (only_if_exists && retval == 0)
80 win32_atom = GlobalAddAtom (atom_name);
81 retval = GUINT_TO_POINTER (win32_atom);
83 g_hash_table_insert (atom_hash,
92 gdk_atom_name (GdkAtom atom)
97 if (GDK_SELECTION_PRIMARY == atom) return g_strdup ("PRIMARY");
98 else if (GDK_SELECTION_SECONDARY == atom) return g_strdup ("SECONDARY");
99 else if (GDK_SELECTION_CLIPBOARD == atom) return g_strdup ("CLIPBOARD");
100 else if (GDK_SELECTION_TYPE_ATOM == atom) return g_strdup ("ATOM");
101 else if (GDK_SELECTION_TYPE_BITMAP == atom) return g_strdup ("BITMAP");
102 else if (GDK_SELECTION_TYPE_COLORMAP == atom) return g_strdup ("COLORMAP");
103 else if (GDK_SELECTION_TYPE_DRAWABLE == atom) return g_strdup ("DRAWABLE");
104 else if (GDK_SELECTION_TYPE_INTEGER == atom) return g_strdup ("INTEGER");
105 else if (GDK_SELECTION_TYPE_PIXMAP == atom) return g_strdup ("PIXMAP");
106 else if (GDK_SELECTION_TYPE_WINDOW == atom) return g_strdup ("WINDOW");
107 else if (GDK_SELECTION_TYPE_STRING == atom) return g_strdup ("STRING");
109 win32_atom = GPOINTER_TO_UINT (atom);
111 if (win32_atom < 0xC000)
112 return g_strdup_printf ("#%x", atom);
113 else if (GlobalGetAtomName (win32_atom, name, sizeof (name)) == 0)
115 return g_strdup (name);
119 gdk_property_get (GdkWindow *window,
125 GdkAtom *actual_property_type,
126 gint *actual_format_type,
130 g_return_val_if_fail (window != NULL, FALSE);
131 g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
133 if (GDK_WINDOW_DESTROYED (window))
136 g_warning ("gdk_property_get: Not implemented");
142 gdk_property_change (GdkWindow *window,
152 gchar *prop_name, *type_name;
155 g_return_if_fail (window != NULL);
156 g_return_if_fail (GDK_IS_WINDOW (window));
158 if (GDK_WINDOW_DESTROYED (window))
162 (prop_name = gdk_atom_name (property),
163 type_name = gdk_atom_name (type),
164 g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n",
165 (guint) GDK_WINDOW_HWND (window),
166 (guint) property, prop_name,
167 (guint) type, type_name,
168 (mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
169 (mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
170 (mode == GDK_PROP_MODE_APPEND ? "APPEND" :
172 format, nelements, data),
174 g_free (type_name)));
176 if (property == _gdk_selection_property
177 && type == GDK_TARGET_STRING
179 && mode == GDK_PROP_MODE_REPLACE)
182 for (i = 0; i < nelements; i++)
186 GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
187 (guint) GDK_WINDOW_HWND (window)));
188 if (!OpenClipboard (GDK_WINDOW_HWND (window)))
190 WIN32_API_FAILED ("OpenClipboard");
194 hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1);
195 ptr = GlobalLock (hdata);
196 GDK_NOTE (MISC, g_print ("...hdata=%#x, ptr=%p\n", (guint) hdata, ptr));
198 for (i = 0; i < nelements; i++)
205 GlobalUnlock (hdata);
206 GDK_NOTE (MISC, g_print ("...SetClipboardData(CF_TEXT, %#x)\n",
208 if (!SetClipboardData(CF_TEXT, hdata))
209 WIN32_API_FAILED ("SetClipboardData");
211 GDK_NOTE (MISC, g_print ("...CloseClipboard()\n"));
212 if (!CloseClipboard ())
213 WIN32_API_FAILED ("CloseClipboard");
217 g_warning ("gdk_property_change: General case not implemented");
221 gdk_property_delete (GdkWindow *window,
226 g_return_if_fail (window != NULL);
227 g_return_if_fail (GDK_IS_WINDOW (window));
230 (prop_name = gdk_atom_name (property),
231 g_print ("gdk_property_delete: %#x %#x (%s)\n",
232 (window ? (guint) GDK_WINDOW_HWND (window) : 0),
233 (guint) property, prop_name),
234 g_free (prop_name)));
236 if (property == _gdk_selection_property)
237 _gdk_selection_property_delete (window);
239 g_warning ("gdk_property_delete: General case not implemented");
243 gdk_setting_get (const gchar *name,
247 * XXX : if these values get changed through the Windoze UI the
248 * respective gdk_events are not generated yet.
250 if (strcmp ("double-click-timeout", name) == 0)
252 g_value_set_int (value, GetDoubleClickTime ());
255 else if (strcmp ("drag-threshold", name) == 0)
257 g_value_set_int (value, MAX(GetSystemMetrics (SM_CXDRAG), GetSystemMetrics (SM_CYDRAG)));