mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
11e6236bec
2001-10-26 Hans Breuer <hans@breuer.org> * gdk-pixbuf/gdk_pixbuf.def : * gdk/gdk.def : * gtk/gtk.def : updated externals * gdk/win32/gdkpixmap-win32.c : removed duplicate of gdk_window_lookup implementation. It already was in gdk/win32/gdkwindow-win32.c * gdk/win32/gdkproperty-win32.c : made it compile again after GdkAtom API change * gtk/gtk/makefile.msc.in : updated
264 lines
7.8 KiB
C
264 lines
7.8 KiB
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.
|
|
*/
|
|
|
|
/*
|
|
* 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 <string.h>
|
|
|
|
#include "gdkproperty.h"
|
|
#include "gdkselection.h"
|
|
#include "gdkinternals.h"
|
|
#include "gdkprivate-win32.h"
|
|
#include "gdkdrawable-win32.h"
|
|
#include "gdkwindow-win32.h"
|
|
|
|
GdkAtom
|
|
gdk_atom_intern (const gchar *atom_name,
|
|
gint only_if_exists)
|
|
{
|
|
GdkAtom retval;
|
|
static GHashTable *atom_hash = NULL;
|
|
ATOM win32_atom;
|
|
|
|
if (!atom_hash)
|
|
atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
retval = g_hash_table_lookup (atom_hash, atom_name);
|
|
if (!retval)
|
|
{
|
|
if (strcmp (atom_name, "PRIMARY") == 0)
|
|
retval = GDK_SELECTION_PRIMARY;
|
|
else if (strcmp (atom_name, "SECONDARY") == 0)
|
|
retval = GDK_SELECTION_SECONDARY;
|
|
else if (strcmp (atom_name, "CLIPBOARD") == 0)
|
|
retval = GDK_SELECTION_CLIPBOARD;
|
|
else if (strcmp (atom_name, "ATOM") == 0)
|
|
retval = GDK_SELECTION_TYPE_ATOM;
|
|
else if (strcmp (atom_name, "BITMAP") == 0)
|
|
retval = GDK_SELECTION_TYPE_BITMAP;
|
|
else if (strcmp (atom_name, "COLORMAP") == 0)
|
|
retval = GDK_SELECTION_TYPE_COLORMAP;
|
|
else if (strcmp (atom_name, "DRAWABLE") == 0)
|
|
retval = GDK_SELECTION_TYPE_DRAWABLE;
|
|
else if (strcmp (atom_name, "INTEGER") == 0)
|
|
retval = GDK_SELECTION_TYPE_INTEGER;
|
|
else if (strcmp (atom_name, "PIXMAP") == 0)
|
|
retval = GDK_SELECTION_TYPE_PIXMAP;
|
|
else if (strcmp (atom_name, "WINDOW") == 0)
|
|
retval = GDK_SELECTION_TYPE_WINDOW;
|
|
else if (strcmp (atom_name, "STRING") == 0)
|
|
retval = GDK_SELECTION_TYPE_STRING;
|
|
else
|
|
{
|
|
win32_atom = GlobalFindAtom (atom_name);
|
|
if (only_if_exists && retval == 0)
|
|
win32_atom = 0;
|
|
else
|
|
win32_atom = GlobalAddAtom (atom_name);
|
|
retval = GUINT_TO_POINTER (win32_atom);
|
|
}
|
|
g_hash_table_insert (atom_hash,
|
|
g_strdup (atom_name),
|
|
retval);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
gchar *
|
|
gdk_atom_name (GdkAtom atom)
|
|
{
|
|
gchar name[256];
|
|
ATOM win32_atom;
|
|
|
|
if (GDK_SELECTION_PRIMARY == atom) return g_strdup ("PRIMARY");
|
|
else if (GDK_SELECTION_SECONDARY == atom) return g_strdup ("SECONDARY");
|
|
else if (GDK_SELECTION_CLIPBOARD == atom) return g_strdup ("CLIPBOARD");
|
|
else if (GDK_SELECTION_TYPE_ATOM == atom) return g_strdup ("ATOM");
|
|
else if (GDK_SELECTION_TYPE_BITMAP == atom) return g_strdup ("BITMAP");
|
|
else if (GDK_SELECTION_TYPE_COLORMAP == atom) return g_strdup ("COLORMAP");
|
|
else if (GDK_SELECTION_TYPE_DRAWABLE == atom) return g_strdup ("DRAWABLE");
|
|
else if (GDK_SELECTION_TYPE_INTEGER == atom) return g_strdup ("INTEGER");
|
|
else if (GDK_SELECTION_TYPE_PIXMAP == atom) return g_strdup ("PIXMAP");
|
|
else if (GDK_SELECTION_TYPE_WINDOW == atom) return g_strdup ("WINDOW");
|
|
else if (GDK_SELECTION_TYPE_STRING == atom) return g_strdup ("STRING");
|
|
|
|
win32_atom = GPOINTER_TO_UINT (atom);
|
|
|
|
if (win32_atom < 0xC000)
|
|
return g_strdup_printf ("#%x", atom);
|
|
else if (GlobalGetAtomName (win32_atom, name, sizeof (name)) == 0)
|
|
return NULL;
|
|
return g_strdup (name);
|
|
}
|
|
|
|
gint
|
|
gdk_property_get (GdkWindow *window,
|
|
GdkAtom property,
|
|
GdkAtom type,
|
|
gulong offset,
|
|
gulong length,
|
|
gint pdelete,
|
|
GdkAtom *actual_property_type,
|
|
gint *actual_format_type,
|
|
gint *actual_length,
|
|
guchar **data)
|
|
{
|
|
g_return_val_if_fail (window != NULL, FALSE);
|
|
g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
return FALSE;
|
|
|
|
g_warning ("gdk_property_get: Not implemented");
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void
|
|
gdk_property_change (GdkWindow *window,
|
|
GdkAtom property,
|
|
GdkAtom type,
|
|
gint format,
|
|
GdkPropMode mode,
|
|
const guchar *data,
|
|
gint nelements)
|
|
{
|
|
HGLOBAL hdata;
|
|
gint i, length;
|
|
gchar *prop_name, *type_name;
|
|
guchar *ptr;
|
|
|
|
g_return_if_fail (window != NULL);
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
if (GDK_WINDOW_DESTROYED (window))
|
|
return;
|
|
|
|
GDK_NOTE (MISC,
|
|
(prop_name = gdk_atom_name (property),
|
|
type_name = gdk_atom_name (type),
|
|
g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n",
|
|
(guint) GDK_WINDOW_HWND (window),
|
|
(guint) property, prop_name,
|
|
(guint) type, type_name,
|
|
(mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
|
|
(mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
|
|
(mode == GDK_PROP_MODE_APPEND ? "APPEND" :
|
|
"???"))),
|
|
format, nelements, data),
|
|
g_free (prop_name),
|
|
g_free (type_name)));
|
|
|
|
if (property == _gdk_selection_property
|
|
&& type == GDK_TARGET_STRING
|
|
&& format == 8
|
|
&& mode == GDK_PROP_MODE_REPLACE)
|
|
{
|
|
length = nelements;
|
|
for (i = 0; i < nelements; i++)
|
|
if (data[i] == '\n')
|
|
length++;
|
|
#if 1
|
|
GDK_NOTE (MISC, g_print ("...OpenClipboard(%#x)\n",
|
|
(guint) GDK_WINDOW_HWND (window)));
|
|
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
|
|
{
|
|
WIN32_API_FAILED ("OpenClipboard");
|
|
return;
|
|
}
|
|
#endif
|
|
hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1);
|
|
ptr = GlobalLock (hdata);
|
|
GDK_NOTE (MISC, g_print ("...hdata=%#x, ptr=%p\n", (guint) hdata, ptr));
|
|
|
|
for (i = 0; i < nelements; i++)
|
|
{
|
|
if (*data == '\n')
|
|
*ptr++ = '\r';
|
|
*ptr++ = *data++;
|
|
}
|
|
*ptr++ = '\0';
|
|
GlobalUnlock (hdata);
|
|
GDK_NOTE (MISC, g_print ("...SetClipboardData(CF_TEXT, %#x)\n",
|
|
(guint) hdata));
|
|
if (!SetClipboardData(CF_TEXT, hdata))
|
|
WIN32_API_FAILED ("SetClipboardData");
|
|
#if 1
|
|
GDK_NOTE (MISC, g_print ("...CloseClipboard()\n"));
|
|
if (!CloseClipboard ())
|
|
WIN32_API_FAILED ("CloseClipboard");
|
|
#endif
|
|
}
|
|
else
|
|
g_warning ("gdk_property_change: General case not implemented");
|
|
}
|
|
|
|
void
|
|
gdk_property_delete (GdkWindow *window,
|
|
GdkAtom property)
|
|
{
|
|
gchar *prop_name;
|
|
extern void gdk_selection_property_delete (GdkWindow *);
|
|
|
|
g_return_if_fail (window != NULL);
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
GDK_NOTE (MISC,
|
|
(prop_name = gdk_atom_name (property),
|
|
g_print ("gdk_property_delete: %#x %#x (%s)\n",
|
|
(window ? (guint) GDK_WINDOW_HWND (window) : 0),
|
|
(guint) property, prop_name),
|
|
g_free (prop_name)));
|
|
|
|
if (property == _gdk_selection_property)
|
|
gdk_selection_property_delete (window);
|
|
else
|
|
g_warning ("gdk_property_delete: General case not implemented");
|
|
}
|
|
|
|
gboolean
|
|
gdk_setting_get (const gchar *name,
|
|
GValue *value)
|
|
{
|
|
/*
|
|
* XXX : if these values get changed through the Windoze UI the
|
|
* respective gdk_events are not generated yet.
|
|
*/
|
|
if (strcmp ("double-click-timeout", name) == 0)
|
|
{
|
|
g_value_set_int (value, GetDoubleClickTime ());
|
|
return TRUE;
|
|
}
|
|
else if (strcmp ("drag-threshold", name) == 0)
|
|
{
|
|
g_value_set_int (value, MAX(GetSystemMetrics (SM_CXDRAG), GetSystemMetrics (SM_CYDRAG)));
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|