summaryrefslogtreecommitdiff
path: root/gdk/win32
diff options
context:
space:
mode:
Diffstat (limited to 'gdk/win32')
-rw-r--r--gdk/win32/gdkdnd-win32.c153
-rw-r--r--gdk/win32/gdkdrawable-win32.c2
-rw-r--r--gdk/win32/gdkevents-win32.c15
-rw-r--r--gdk/win32/gdkfont-win32.c455
-rw-r--r--gdk/win32/gdkgc-win32.c3
-rw-r--r--gdk/win32/gdkinput-win32.c1
-rw-r--r--gdk/win32/gdkmain-win32.c1
-rw-r--r--gdk/win32/gdkpango-win32.c28
-rw-r--r--gdk/win32/gdkpixmap-win32.c3
-rw-r--r--gdk/win32/gdkprivate-win32.h2
-rw-r--r--gdk/win32/gdkwin32.h12
-rw-r--r--gdk/win32/gdkwindow-win32.c10
12 files changed, 403 insertions, 282 deletions
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index fc82e53eba..bfcf4b9d9d 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -37,7 +37,6 @@
#include "gdkproperty.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkdrawable-win32.h"
#ifdef OLE2_DND
#include <ole2.h>
@@ -50,7 +49,7 @@
#include <gdk/gdk.h>
-typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
+typedef struct _GdkDragContextPrivateWin32 GdkDragContextPrivateWin32;
typedef enum {
GDK_DRAG_STATUS_DRAG,
@@ -89,10 +88,8 @@ static int nformats;
/* Structure that holds information about a drag in progress.
* this is used on both source and destination sides.
*/
-struct _GdkDragContextPrivate {
- GdkDragContext context;
-
- guint ref_count;
+struct _GdkDragContextPrivateWin32 {
+ gint ref_count;
guint16 last_x; /* Coordinates from last event */
guint16 last_y;
@@ -100,65 +97,111 @@ struct _GdkDragContextPrivate {
guint drag_status; /* Current status of drag */
};
+#define PRIVATE_DATA(context) ((GdkDragContextPrivateWin32 *) GDK_DRAG_CONTEXT (context)->windowing_data)
+
GdkDragContext *current_dest_drag = NULL;
-/* Drag Contexts */
+static void gdk_drag_context_init (GdkDragContext *dragcontext);
+static void gdk_drag_context_class_init (GdkDragContextClass *klass);
+static void gdk_drag_context_finalize (GObject *object);
+static gpointer parent_class = NULL;
static GList *contexts;
-GdkDragContext *
-gdk_drag_context_new (void)
+GType
+gdk_drag_context_get_type (void)
{
- GdkDragContextPrivate *result;
+ static GType object_type = 0;
- result = g_new0 (GdkDragContextPrivate, 1);
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkDragContextClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gdk_drag_context_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkDragContext),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gdk_drag_context_init,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GdkDragContext",
+ &object_info);
+ }
+
+ return object_type;
+}
- result->ref_count = 1;
+static void
+gdk_drag_context_init (GdkDragContext *dragcontext)
+{
+ GdkDragContextPrivateWin32 *private = g_new0 (GdkDragContextPrivateWin32, 1);
- contexts = g_list_prepend (contexts, result);
+ dragcontext->windowing_data = private;
+ private->ref_count = 1;
- return (GdkDragContext *) result;
+ contexts = g_list_prepend (contexts, dragcontext);
}
-void
-gdk_drag_context_ref (GdkDragContext *context)
+static void
+gdk_drag_context_class_init (GdkDragContextClass *klass)
{
- g_return_if_fail (context != NULL);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
- ((GdkDragContextPrivate *)context)->ref_count++;
+ object_class->finalize = gdk_drag_context_finalize;
}
-void
-gdk_drag_context_unref (GdkDragContext *context)
+static void
+gdk_drag_context_finalize (GObject *object)
{
- GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
+ GdkDragContext *context = GDK_DRAG_CONTEXT (object);
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (context);
- g_return_if_fail (context != NULL);
+ g_list_free (context->targets);
- if (private->ref_count <= 0)
- abort ();
+ if (context->source_window)
+ {
+ gdk_window_unref (context->source_window);
+ }
+
+ if (context->dest_window)
+ gdk_window_unref (context->dest_window);
+
+ contexts = g_list_remove (contexts, context);
- private->ref_count--;
+ g_free (private);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
- GDK_NOTE (DND, g_print ("gdk_drag_context_unref: %d%s\n",
- private->ref_count,
- (private->ref_count == 0 ? " freeing" : "")));
+/* Drag Contexts */
- if (private->ref_count == 0)
- {
- g_dataset_destroy (private);
-
- g_list_free (context->targets);
+GdkDragContext *
+gdk_drag_context_new (void)
+{
+ return g_object_new (gdk_drag_context_get_type (), NULL);
+}
- if (context->source_window)
- gdk_drawable_unref (context->source_window);
+void
+gdk_drag_context_ref (GdkDragContext *context)
+{
+ g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
- if (context->dest_window)
- gdk_drawable_unref (context->dest_window);
+ g_object_ref (G_OBJECT (context));
+}
- contexts = g_list_remove (contexts, private);
- g_free (private);
- }
+void
+gdk_drag_context_unref (GdkDragContext *context)
+{
+ g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+
+ g_object_unref (G_OBJECT (context));
}
#if 0
@@ -223,13 +266,13 @@ static ULONG STDMETHODCALLTYPE
idroptarget_addref (LPDROPTARGET This)
{
target_drag_context *ctx = (target_drag_context *) This;
- GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (ctx->context);
+ int ref_count = ++private->ref_count;
gdk_drag_context_ref (ctx->context);
- GDK_NOTE (DND, g_print ("idroptarget_addref %#x %d\n",
- This, private->ref_count));
+ GDK_NOTE (DND, g_print ("idroptarget_addref %#x %d\n", This, ref_count));
- return private->ref_count;
+ return ref_count;
}
static HRESULT STDMETHODCALLTYPE
@@ -268,12 +311,11 @@ static ULONG STDMETHODCALLTYPE
idroptarget_release (LPDROPTARGET This)
{
target_drag_context *ctx = (target_drag_context *) This;
- GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
- int ref_count = private->ref_count - 1;
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (ctx->context);
+ int ref_count = --private->ref_count;
gdk_drag_context_unref (ctx->context);
- GDK_NOTE (DND, g_print ("idroptarget_release %#x %d\n",
- This, ref_count));
+ GDK_NOTE (DND, g_print ("idroptarget_release %#x %d\n", This, ref_count));
if (ref_count == 0)
g_free (This);
@@ -328,7 +370,7 @@ static ULONG STDMETHODCALLTYPE
idropsource_addref (LPDROPSOURCE This)
{
source_drag_context *ctx = (source_drag_context *) This;
- GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (ctx->context);
gdk_drag_context_ref (ctx->context);
GDK_NOTE (DND, g_print ("idropsource_addref %#x %d\n",
@@ -372,12 +414,11 @@ static ULONG STDMETHODCALLTYPE
idropsource_release (LPDROPSOURCE This)
{
source_drag_context *ctx = (source_drag_context *) This;
- GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
- int ref_count = private->ref_count - 1;
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (ctx->context);
+ int ref_count = --private->ref_count;
gdk_drag_context_unref (ctx->context);
- GDK_NOTE (DND, g_print ("idropsource_release %#x %d\n",
- This, ref_count));
+ GDK_NOTE (DND, g_print ("idropsource_release %#x %d\n", This, ref_count));
if (ref_count == 0)
g_free (This);
@@ -904,7 +945,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
gpointer data)
{
GdkDragContext *context;
- GdkDragContextPrivate *private;
+ GdkDragContextPrivateWin32 *private;
static GdkAtom text_uri_list_atom = GDK_NONE;
GString *result;
MSG *msg = (MSG *) xev;
@@ -921,7 +962,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
GDK_NOTE (DND, g_print ("WM_DROPFILES: %#x\n", msg->hwnd));
context = gdk_drag_context_new ();
- private = (GdkDragContextPrivate *) context;
+ private = PRIVATE_DATA (context);
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
context->source_window = gdk_parent_root;
@@ -1108,7 +1149,7 @@ gdk_drag_find_window (GdkDragContext *context,
GdkWindow **dest_window,
GdkDragProtocol *protocol)
{
- GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
+ GdkDragContextPrivateWin32 *private = PRIVATE_DATA (context);
HWND recipient;
POINT pt;
diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c
index 5c5e586bda..ab1a720c77 100644
--- a/gdk/win32/gdkdrawable-win32.c
+++ b/gdk/win32/gdkdrawable-win32.c
@@ -31,8 +31,6 @@
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkdrawable-win32.h"
-#include "gdkpixmap-win32.h"
static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 6ab1bb2749..2816390ba9 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -51,9 +51,6 @@
#include "gdk.h"
#include "gdkinternals.h"
-#include "gdkdrawable-win32.h"
-#include "gdkwindow-win32.h"
-#include "gdkpixmap-win32.h"
#include "gdkinput-win32.h"
#include "gdkkeysyms.h"
@@ -1366,7 +1363,7 @@ gdk_event_translate (GdkEvent *event,
GdkWindowImplWin32 *window_impl;
#define ASSIGN_WINDOW(rhs) \
(window = rhs, \
- window_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl))
+ window_impl = (window ? GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl) : NULL))
GdkWindow *orig_window, *new_window;
GdkColormapPrivateWin32 *colormap_private;
@@ -1387,15 +1384,13 @@ gdk_event_translate (GdkEvent *event,
if (ret_val_flagp)
*ret_val_flagp = FALSE;
- ASSIGN_WINDOW (gdk_win32_handle_table_lookup (msg->hwnd));
+ ASSIGN_WINDOW (gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd));
orig_window = window;
event->any.window = window;
event->any.send_event = FALSE;
- if (window != NULL)
- gdk_drawable_ref (window);
- else
+ if (window == NULL)
{
/* Handle WM_QUIT here ? */
if (msg->message == WM_QUIT)
@@ -1423,6 +1418,8 @@ gdk_event_translate (GdkEvent *event,
return FALSE;
}
+ gdk_drawable_ref (window);
+
if (!GDK_WINDOW_DESTROYED (window))
{
/* Check for filters for this window */
@@ -2124,7 +2121,7 @@ gdk_event_translate (GdkEvent *event,
if ((hwnd = WindowFromPoint (pt)) == NULL)
break;
msg->hwnd = hwnd;
- if ((new_window = gdk_win32_handle_table_lookup (msg->hwnd)) == NULL)
+ if ((new_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd)) == NULL)
break;
if (new_window != window)
{
diff --git a/gdk/win32/gdkfont-win32.c b/gdk/win32/gdkfont-win32.c
index 9fa7c1b63e..53f69ebc5f 100644
--- a/gdk/win32/gdkfont-win32.c
+++ b/gdk/win32/gdkfont-win32.c
@@ -24,11 +24,11 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include "config.h"
-
#include <stdio.h>
#include <ctype.h>
+#include <pango/pangowin32.h>
+
#include "gdkfont.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
@@ -1135,26 +1135,126 @@ check_unicode_subranges (UINT charset,
return retval;
}
-GdkWin32SingleFont*
-gdk_font_load_internal (const gchar *font_name)
+static GdkWin32SingleFont *
+gdk_font_load_logfont (LOGFONT *lfp)
{
GdkWin32SingleFont *singlefont;
HFONT hfont;
LOGFONT logfont;
CHARSETINFO csi;
- DWORD fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet,
- fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily;
HGDIOBJ oldfont;
- char *lpszFace;
+ int tries;
gchar face[100];
- int numfields, n1, n2, tries;
+ for (tries = 0; ; tries++)
+ {
+ GDK_NOTE (MISC, g_print ("... trying %d,%d,%d,%d,"
+ "%d,%d,%d,%d,"
+ "%d,%d,%d,"
+ "%d,%#.02x,\"%s\"\n",
+ lfp->lfHeight, lfp->lfWidth,
+ lfp->lfEscapement, lfp->lfOrientation,
+ lfp->lfWeight, lfp->lfItalic,
+ lfp->lfUnderline, lfp->lfStrikeOut,
+ lfp->lfCharSet,
+ lfp->lfOutPrecision, lfp->lfClipPrecision,
+ lfp->lfQuality, lfp->lfPitchAndFamily,
+ lfp->lfFaceName));
+ hfont = CreateFontIndirect (lfp);
+
+ if (hfont != NULL)
+ break;
+
+ /* If we fail, try some similar fonts often found on Windows. */
+ if (tries == 0)
+ {
+ if (g_strcasecmp (lfp->lfFaceName, "helvetica") == 0)
+ strcpy (lfp->lfFaceName, "arial");
+ else if (g_strcasecmp (lfp->lfFaceName, "new century schoolbook") == 0)
+ strcpy (lfp->lfFaceName, "century schoolbook");
+ else if (g_strcasecmp (lfp->lfFaceName, "courier") == 0)
+ strcpy (lfp->lfFaceName, "courier new");
+ else if (g_strcasecmp (lfp->lfFaceName, "lucida") == 0)
+ strcpy (lfp->lfFaceName, "lucida sans unicode");
+ else if (g_strcasecmp (lfp->lfFaceName, "lucidatypewriter") == 0)
+ strcpy (lfp->lfFaceName, "lucida console");
+ else if (g_strcasecmp (lfp->lfFaceName, "times") == 0)
+ strcpy (lfp->lfFaceName, "times new roman");
+ }
+ else if (tries == 1)
+ {
+ if (g_strcasecmp (lfp->lfFaceName, "courier") == 0)
+ {
+ strcpy (lfp->lfFaceName, "");
+ lfp->lfPitchAndFamily |= FF_MODERN;
+ }
+ else if (g_strcasecmp (lfp->lfFaceName, "times new roman") == 0)
+ {
+ strcpy (lfp->lfFaceName, "");
+ lfp->lfPitchAndFamily |= FF_ROMAN;
+ }
+ else if (g_strcasecmp (lfp->lfFaceName, "helvetica") == 0
+ || g_strcasecmp (lfp->lfFaceName, "lucida") == 0)
+ {
+ strcpy (lfp->lfFaceName, "");
+ lfp->lfPitchAndFamily |= FF_SWISS;
+ }
+ else
+ {
+ strcpy (lfp->lfFaceName, "");
+ lfp->lfPitchAndFamily = (lfp->lfPitchAndFamily & 0x0F) | FF_DONTCARE;
+ }
+ }
+ else
+ break;
+ tries++;
+ }
+
+ if (!hfont)
+ return NULL;
+
+ singlefont = g_new (GdkWin32SingleFont, 1);
+ singlefont->hfont = hfont;
+ GetObject (singlefont->hfont, sizeof (logfont), &logfont);
+ oldfont = SelectObject (gdk_display_hdc, singlefont->hfont);
+ memset (&singlefont->fs, 0, sizeof (singlefont->fs));
+ singlefont->charset = GetTextCharsetInfo (gdk_display_hdc, &singlefont->fs, 0);
+ GetTextFace (gdk_display_hdc, sizeof (face), face);
+ SelectObject (gdk_display_hdc, oldfont);
+ if (TranslateCharsetInfo ((DWORD *) singlefont->charset, &csi,
+ TCI_SRCCHARSET)
+ && singlefont->charset != MAC_CHARSET)
+ singlefont->codepage = csi.ciACP;
+ else
+ singlefont->codepage = 0;
+
+ GDK_NOTE (MISC, (g_print ("... = %#x %s cs %s cp%d\n",
+ singlefont->hfont, face,
+ charset_name (singlefont->charset),
+ singlefont->codepage),
+ g_print ("... Unicode subranges:"),
+ print_unicode_subranges (&singlefont->fs)));
+ if (check_unicode_subranges (singlefont->charset, &singlefont->fs))
+ GDK_NOTE (MISC, (g_print ("... Guesstimated Unicode subranges:"),
+ print_unicode_subranges (&singlefont->fs)));
+
+ return singlefont;
+}
+
+static GdkWin32SingleFont *
+gdk_font_load_internal (const gchar *font_name)
+{
+ GdkWin32SingleFont *singlefont;
+
+ LOGFONT logfont;
+
+ char *fn;
+ int numfields, n1, n2;
char foundry[32], family[100], weight[32], slant[32], set_width[32],
spacing[32], registry[32], encoding[32];
char pixel_size[10], point_size[10], res_x[10], res_y[10], avg_width[10];
int c;
char *p;
- int nHeight, nWidth, nEscapement, nOrientation, fnWeight;
int logpixelsy;
g_return_val_if_fail (font_name != NULL, NULL);
@@ -1172,20 +1272,22 @@ gdk_font_load_internal (const gchar *font_name)
if (numfields == 0)
{
/* Probably a plain Windows font name */
- nHeight = 0;
- nWidth = 0;
- nEscapement = 0;
- nOrientation = 0;
- fnWeight = FW_DONTCARE;
- fdwItalic = FALSE;
- fdwUnderline = FALSE;
- fdwStrikeOut = FALSE;
- fdwCharSet = ANSI_CHARSET;
- fdwOutputPrecision = OUT_TT_PRECIS;
- fdwClipPrecision = CLIP_DEFAULT_PRECIS;
- fdwQuality = PROOF_QUALITY;
- fdwPitchAndFamily = DEFAULT_PITCH;
- lpszFace = g_filename_from_utf8 (font_name);
+ logfont.lfHeight = 0;
+ logfont.lfWidth = 0;
+ logfont.lfEscapement = 0;
+ logfont.lfOrientation = 0;
+ logfont.lfWeight = FW_DONTCARE;
+ logfont.lfItalic = FALSE;
+ logfont.lfUnderline = FALSE;
+ logfont.lfStrikeOut = FALSE;
+ logfont.lfCharSet = ANSI_CHARSET;
+ logfont.lfOutPrecision = OUT_TT_PRECIS;
+ logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ logfont.lfQuality = PROOF_QUALITY;
+ logfont.lfPitchAndFamily = DEFAULT_PITCH;
+ fn = g_filename_from_utf8 (font_name);
+ strcpy (logfont.lfFaceName, fn);
+ g_free (fn);
}
else if (numfields != 5)
{
@@ -1238,260 +1340,157 @@ gdk_font_load_internal (const gchar *font_name)
if (strcmp (pixel_size, "*") == 0)
if (strcmp (point_size, "*") == 0)
- nHeight = 0;
+ logfont.lfHeight = 0;
else
- nHeight = (int) (((double) atoi (point_size))/720.*logpixelsy);
+ logfont.lfHeight = (int) (((double) atoi (point_size))/720.*logpixelsy);
else
- nHeight = atoi (pixel_size);
+ logfont.lfHeight = atoi (pixel_size);
- nWidth = 0;
- nEscapement = 0;
- nOrientation = 0;
+ logfont.lfWidth = 0;
+ logfont.lfEscapement = 0;
+ logfont.lfOrientation = 0;
if (g_strcasecmp (weight, "thin") == 0)
- fnWeight = FW_THIN;
+ logfont.lfWeight = FW_THIN;
else if (g_strcasecmp (weight, "extralight") == 0)
- fnWeight = FW_EXTRALIGHT;
+ logfont.lfWeight = FW_EXTRALIGHT;
else if (g_strcasecmp (weight, "ultralight") == 0)
#ifdef FW_ULTRALIGHT
- fnWeight = FW_ULTRALIGHT;
+ logfont.lfWeight = FW_ULTRALIGHT;
#else
- fnWeight = FW_EXTRALIGHT; /* In fact, FW_ULTRALIGHT really is
- * defined as FW_EXTRALIGHT anyway.
- */
+ logfont.lfWeight = FW_EXTRALIGHT; /* In fact, FW_ULTRALIGHT really is
+ * defined as FW_EXTRALIGHT anyway.
+ */
#endif
else if (g_strcasecmp (weight, "light") == 0)
- fnWeight = FW_LIGHT;
+ logfont.lfWeight = FW_LIGHT;
else if (g_strcasecmp (weight, "normal") == 0)
- fnWeight = FW_NORMAL;
+ logfont.lfWeight = FW_NORMAL;
else if (g_strcasecmp (weight, "regular") == 0)
- fnWeight = FW_REGULAR;
+ logfont.lfWeight = FW_REGULAR;
else if (g_strcasecmp (weight, "medium") == 0)
- fnWeight = FW_MEDIUM;
+ logfont.lfWeight = FW_MEDIUM;
else if (g_strcasecmp (weight, "semibold") == 0)
- fnWeight = FW_SEMIBOLD;
+ logfont.lfWeight = FW_SEMIBOLD;
else if (g_strcasecmp (weight, "demibold") == 0)
#ifdef FW_DEMIBOLD
- fnWeight = FW_DEMIBOLD;
+ logfont.lfWeight = FW_DEMIBOLD;
#else
- fnWeight = FW_SEMIBOLD; /* As above */
+ logfont.lfWeight = FW_SEMIBOLD; /* As above */
#endif
else if (g_strcasecmp (weight, "bold") == 0)
- fnWeight = FW_BOLD;
+ logfont.lfWeight = FW_BOLD;
else if (g_strcasecmp (weight, "extrabold") == 0)
- fnWeight = FW_EXTRABOLD;
+ logfont.lfWeight = FW_EXTRABOLD;
else if (g_strcasecmp (weight, "ultrabold") == 0)
#ifdef FW_ULTRABOLD
- fnWeight = FW_ULTRABOLD;
+ logfont.lfWeight = FW_ULTRABOLD;
#else
- fnWeight = FW_EXTRABOLD; /* As above */
+ logfont.lfWeight = FW_EXTRABOLD; /* As above */
#endif
else if (g_strcasecmp (weight, "heavy") == 0)
- fnWeight = FW_HEAVY;
+ logfont.lfWeight = FW_HEAVY;
else if (g_strcasecmp (weight, "black") == 0)
#ifdef FW_BLACK
- fnWeight = FW_BLACK;
+ logfont.lfWeight = FW_BLACK;
#else
- fnWeight = FW_HEAVY; /* As above */
+ logfont.lfWeight = FW_HEAVY; /* As above */
#endif
else
- fnWeight = FW_DONTCARE;
+ logfont.lfWeight = FW_DONTCARE;
if (g_strcasecmp (slant, "italic") == 0
|| g_strcasecmp (slant, "oblique") == 0
|| g_strcasecmp (slant, "i") == 0
|| g_strcasecmp (slant, "o") == 0)
- fdwItalic = TRUE;
+ logfont.lfItalic = TRUE;
else
- fdwItalic = FALSE;
- fdwUnderline = FALSE;
- fdwStrikeOut = FALSE;
+ logfont.lfItalic = FALSE;
+ logfont.lfUnderline = FALSE;
+ logfont.lfStrikeOut = FALSE;
if (g_strcasecmp (registry, "iso8859") == 0)
if (strcmp (encoding, "1") == 0)
- fdwCharSet = ANSI_CHARSET;
+ logfont.lfCharSet = ANSI_CHARSET;
else if (strcmp (encoding, "2") == 0)
- fdwCharSet = EASTEUROPE_CHARSET;
+ logfont.lfCharSet = EASTEUROPE_CHARSET;
else if (strcmp (encoding, "7") == 0)
- fdwCharSet = GREEK_CHARSET;
+ logfont.lfCharSet = GREEK_CHARSET;
else if (strcmp (encoding, "8") == 0)
- fdwCharSet = HEBREW_CHARSET;
+ logfont.lfCharSet = HEBREW_CHARSET;
else if (strcmp (encoding, "9") == 0)
- fdwCharSet = TURKISH_CHARSET;
+ logfont.lfCharSet = TURKISH_CHARSET;
else
- fdwCharSet = ANSI_CHARSET; /* XXX ??? */
+ logfont.lfCharSet = ANSI_CHARSET; /* XXX ??? */
else if (g_strcasecmp (registry, "jisx0208.1983") == 0)
- fdwCharSet = SHIFTJIS_CHARSET;
+ logfont.lfCharSet = SHIFTJIS_CHARSET;
else if (g_strcasecmp (registry, "ksc5601.1987") == 0)
- fdwCharSet = HANGEUL_CHARSET;
+ logfont.lfCharSet = HANGEUL_CHARSET;
else if (g_strcasecmp (registry, "gb2312.1980") == 0)
- fdwCharSet = GB2312_CHARSET;
+ logfont.lfCharSet = GB2312_CHARSET;
else if (g_strcasecmp (registry, "big5") == 0)
- fdwCharSet = CHINESEBIG5_CHARSET;
+ logfont.lfCharSet = CHINESEBIG5_CHARSET;
else if (g_strcasecmp (registry, "windows") == 0
|| g_strcasecmp (registry, "microsoft") == 0)
if (g_strcasecmp (encoding, "symbol") == 0)
- fdwCharSet = SYMBOL_CHARSET;
+ logfont.lfCharSet = SYMBOL_CHARSET;
else if (g_strcasecmp (encoding, "shiftjis") == 0)
- fdwCharSet = SHIFTJIS_CHARSET;
+ logfont.lfCharSet = SHIFTJIS_CHARSET;
else if (g_strcasecmp (encoding, "gb2312") == 0)
- fdwCharSet = GB2312_CHARSET;
+ logfont.lfCharSet = GB2312_CHARSET;
else if (g_strcasecmp (encoding, "hangeul") == 0)
- fdwCharSet = HANGEUL_CHARSET;
+ logfont.lfCharSet = HANGEUL_CHARSET;
else if (g_strcasecmp (encoding, "big5") == 0)
- fdwCharSet = CHINESEBIG5_CHARSET;
+ logfont.lfCharSet = CHINESEBIG5_CHARSET;
else if (g_strcasecmp (encoding, "johab") == 0)
- fdwCharSet = JOHAB_CHARSET;
+ logfont.lfCharSet = JOHAB_CHARSET;
else if (g_strcasecmp (encoding, "hebrew") == 0)
- fdwCharSet = HEBREW_CHARSET;
+ logfont.lfCharSet = HEBREW_CHARSET;
else if (g_strcasecmp (encoding, "arabic") == 0)
- fdwCharSet = ARABIC_CHARSET;
+ logfont.lfCharSet = ARABIC_CHARSET;
else if (g_strcasecmp (encoding, "greek") == 0)
- fdwCharSet = GREEK_CHARSET;
+ logfont.lfCharSet = GREEK_CHARSET;
else if (g_strcasecmp (encoding, "turkish") == 0)
- fdwCharSet = TURKISH_CHARSET;
+ logfont.lfCharSet = TURKISH_CHARSET;
else if (g_strcasecmp (encoding, "easteurope") == 0)
- fdwCharSet = EASTEUROPE_CHARSET;
+ logfont.lfCharSet = EASTEUROPE_CHARSET;
else if (g_strcasecmp (encoding, "russian") == 0)
- fdwCharSet = RUSSIAN_CHARSET;
+ logfont.lfCharSet = RUSSIAN_CHARSET;
else if (g_strcasecmp (encoding, "mac") == 0)
- fdwCharSet = MAC_CHARSET;
+ logfont.lfCharSet = MAC_CHARSET;
else if (g_strcasecmp (encoding, "baltic") == 0)
- fdwCharSet = BALTIC_CHARSET;
+ logfont.lfCharSet = BALTIC_CHARSET;
else if (g_strcasecmp (encoding, "cp1251") == 0)
- fdwCharSet = RUSSIAN_CHARSET;
+ logfont.lfCharSet = RUSSIAN_CHARSET;
else
- fdwCharSet = ANSI_CHARSET; /* XXX ??? */
+ logfont.lfCharSet = ANSI_CHARSET; /* XXX ??? */
else
- fdwCharSet = ANSI_CHARSET; /* XXX ??? */
- fdwOutputPrecision = OUT_TT_PRECIS;
- fdwClipPrecision = CLIP_DEFAULT_PRECIS;
- fdwQuality = PROOF_QUALITY;
+ logfont.lfCharSet = ANSI_CHARSET; /* XXX ??? */
+ logfont.lfOutPrecision = OUT_TT_PRECIS;
+ logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ logfont.lfQuality = PROOF_QUALITY;
if (g_strcasecmp (spacing, "m") == 0)
- fdwPitchAndFamily = FIXED_PITCH;
+ logfont.lfPitchAndFamily = FIXED_PITCH;
else if (g_strcasecmp (spacing, "p") == 0)
- fdwPitchAndFamily = VARIABLE_PITCH;
+ logfont.lfPitchAndFamily = VARIABLE_PITCH;
else
- fdwPitchAndFamily = DEFAULT_PITCH;
- lpszFace = g_filename_from_utf8 (family);
- }
-
- for (tries = 0; ; tries++)
- {
- GDK_NOTE (MISC, g_print ("... trying CreateFont(%d,%d,%d,%d,"
- "%d,%d,%d,%d,"
- "%d,%d,%d,"
- "%d,%#.02x,\"%s\")\n",
- nHeight, nWidth, nEscapement, nOrientation,
- fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
- fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
- fdwQuality, fdwPitchAndFamily, lpszFace));
- hfont = CreateFont (nHeight, nWidth, nEscapement, nOrientation,
- fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut,
- fdwCharSet, fdwOutputPrecision, fdwClipPrecision,
- fdwQuality, fdwPitchAndFamily, lpszFace);
- /* After the first try lpszFace contains a return value
- * from g_filename_from_utf8(), so free it.
- */
- if (tries == 0)
- g_free (lpszFace);
-
- if (hfont != NULL)
- break;
-
- /* If we fail, try some similar fonts often found on Windows. */
- if (tries == 0)
- {
- if (g_strcasecmp (family, "helvetica") == 0)
- lpszFace = "arial";
- else if (g_strcasecmp (family, "new century schoolbook") == 0)
- lpszFace = "century schoolbook";
- else if (g_strcasecmp (family, "courier") == 0)
- lpszFace = "courier new";
- else if (g_strcasecmp (family, "lucida") == 0)
- lpszFace = "lucida sans unicode";
- else if (g_strcasecmp (family, "lucidatypewriter") == 0)
- lpszFace = "lucida console";
- else if (g_strcasecmp (family, "times") == 0)
- lpszFace = "times new roman";
- }
- else if (tries == 1)
- {
- if (g_strcasecmp (family, "courier") == 0)
- {
- lpszFace = "";
- fdwPitchAndFamily |= FF_MODERN;
- }
- else if (g_strcasecmp (family, "times new roman") == 0)
- {
- lpszFace = "";
- fdwPitchAndFamily |= FF_ROMAN;
- }
- else if (g_strcasecmp (family, "helvetica") == 0
- || g_strcasecmp (family, "lucida") == 0)
- {
- lpszFace = "";
- fdwPitchAndFamily |= FF_SWISS;
- }
- else
- {
- lpszFace = "";
- fdwPitchAndFamily = (fdwPitchAndFamily & 0x0F) | FF_DONTCARE;
- }
- }
- else
- break;
- tries++;
+ logfont.lfPitchAndFamily = DEFAULT_PITCH;
+ fn = g_filename_from_utf8 (family);
+ strcpy (logfont.lfFaceName, fn);
+ g_free (fn);
}
-
- if (!hfont)
- return NULL;
-
- singlefont = g_new (GdkWin32SingleFont, 1);
- singlefont->hfont = hfont;
- GetObject (singlefont->hfont, sizeof (logfont), &logfont);
- oldfont = SelectObject (gdk_display_hdc, singlefont->hfont);
- memset (&singlefont->fs, 0, sizeof (singlefont->fs));
- singlefont->charset = GetTextCharsetInfo (gdk_display_hdc, &singlefont->fs, 0);
- GetTextFace (gdk_display_hdc, sizeof (face), face);
- SelectObject (gdk_display_hdc, oldfont);
- if (TranslateCharsetInfo ((DWORD *) singlefont->charset, &csi,
- TCI_SRCCHARSET)
- && singlefont->charset != MAC_CHARSET)
- singlefont->codepage = csi.ciACP;
- else
- singlefont->codepage = 0;
- GDK_NOTE (MISC, (g_print ("... = %#x %s cs %s cp%d\n",
- singlefont->hfont, face,
- charset_name (singlefont->charset),
- singlefont->codepage),
- g_print ("... Unicode subranges:"),
- print_unicode_subranges (&singlefont->fs)));
- if (check_unicode_subranges (singlefont->charset, &singlefont->fs))
- GDK_NOTE (MISC, (g_print ("... Guesstimated Unicode subranges:"),
- print_unicode_subranges (&singlefont->fs)));
-
- return singlefont;
+ return gdk_font_load_logfont (&logfont);
}
-GdkFont*
-gdk_font_load (const gchar *font_name)
+static GdkFont *
+gdk_font_from_one_singlefont (GdkWin32SingleFont *singlefont)
{
GdkFont *font;
GdkFontPrivateWin32 *private;
- GdkWin32SingleFont *singlefont;
HGDIOBJ oldfont;
HANDLE *f;
TEXTMETRIC textmetric;
- g_return_val_if_fail (font_name != NULL, NULL);
-
- font = gdk_font_hash_lookup (GDK_FONT_FONTSET, font_name);
- if (font)
- return font;
-
- singlefont = gdk_font_load_internal (font_name);
-
private = g_new (GdkFontPrivateWin32, 1);
font = (GdkFont*) private;
@@ -1513,9 +1512,71 @@ gdk_font_load (const gchar *font_name)
GDK_NOTE (MISC, g_print ("... asc %d desc %d\n",
font->ascent, font->descent));
+ return font;
+}
+
+GdkFont*
+gdk_font_load (const gchar *font_name)
+{
+ GdkFont *font;
+
+ g_return_val_if_fail (font_name != NULL, NULL);
+
+ font = gdk_font_hash_lookup (GDK_FONT_FONTSET, font_name);
+ if (font)
+ return font;
+
gdk_font_hash_insert (GDK_FONT_FONTSET, font, font_name);
- return font;
+ return gdk_font_from_one_singlefont (gdk_font_load_internal (font_name));
+}
+
+/**
+ * gdk_font_from_description:
+ * @font_desc: a #PangoFontDescription.
+ *
+ * Load a #GdkFont based on a Pango font description. This font will
+ * only be an approximation of the Pango font, and
+ * internationalization will not be handled correctly. This function
+ * should only be used for legacy code that cannot be easily converted
+ * to use Pango. Using Pango directly will produce better results.
+ *
+ * Return value: the newly loaded font, or %NULL if the font
+ * cannot be loaded.
+ **/
+GdkFont*
+gdk_font_from_description (PangoFontDescription *font_desc)
+{
+ PangoFontMap *font_map;
+ PangoFont *font;
+ GdkFont *result = NULL;
+
+ g_return_val_if_fail (font_desc != NULL, NULL);
+
+ font_map = pango_win32_font_map_for_display ();
+ font = pango_font_map_load_font (font_map, font_desc);
+
+ if (font)
+ {
+ gint n_subfonts;
+ PangoWin32Subfont *subfont_ids;
+
+ n_subfonts = pango_win32_list_subfonts (font, PANGO_WIN32_U_BASIC_LATIN,
+ &subfont_ids);
+ if (n_subfonts > 0)
+ {
+ LOGFONT *lfp =
+ pango_win32_font_subfont_logfont (font, subfont_ids[0]);
+ result = gdk_font_from_one_singlefont (gdk_font_load_logfont (lfp));
+ g_free (lfp);
+ }
+
+ g_free (subfont_ids);
+
+ g_object_unref (G_OBJECT (font));
+ }
+
+ return result;
}
GdkFont*
diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c
index 791f5f378d..89ae99a240 100644
--- a/gdk/win32/gdkgc-win32.c
+++ b/gdk/win32/gdkgc-win32.c
@@ -34,9 +34,6 @@
#include "gdkregion-generic.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkdrawable-win32.h"
-#include "gdkwindow-win32.h"
-#include "gdkpixmap-win32.h"
static void gdk_win32_gc_destroy (GdkGC *gc);
static void gdk_win32_gc_get_values (GdkGC *gc,
diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c
index d243f79e60..3e6f29c42d 100644
--- a/gdk/win32/gdkinput-win32.c
+++ b/gdk/win32/gdkinput-win32.c
@@ -34,7 +34,6 @@
#include "gdkinput.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkwindow-win32.h"
#include "gdkinput-win32.h"
#ifdef HAVE_WINTAB
diff --git a/gdk/win32/gdkmain-win32.c b/gdk/win32/gdkmain-win32.c
index 607bcfb497..5b9e43962e 100644
--- a/gdk/win32/gdkmain-win32.c
+++ b/gdk/win32/gdkmain-win32.c
@@ -37,7 +37,6 @@
#include "gdkkeysyms.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkwindow-win32.h"
#include "gdkinput-win32.h"
#include <objbase.h>
diff --git a/gdk/win32/gdkpango-win32.c b/gdk/win32/gdkpango-win32.c
new file mode 100644
index 0000000000..f4c4406933
--- /dev/null
+++ b/gdk/win32/gdkpango-win32.c
@@ -0,0 +1,28 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library 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.
+ */
+
+#include "gdkprivate-win32.h"
+#include "gdkpango.h"
+#include <pango/pangowin32.h>
+
+PangoContext *
+gdk_pango_context_get (void)
+{
+ return pango_win32_get_context ();
+}
diff --git a/gdk/win32/gdkpixmap-win32.c b/gdk/win32/gdkpixmap-win32.c
index 81f2d968e6..c0fc790e1c 100644
--- a/gdk/win32/gdkpixmap-win32.c
+++ b/gdk/win32/gdkpixmap-win32.c
@@ -34,9 +34,6 @@
#include "gdkpixmap.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkdrawable-win32.h"
-#include "gdkwindow-win32.h"
-#include "gdkpixmap-win32.h"
static void gdk_pixmap_impl_win32_get_size (GdkDrawable *drawable,
gint *width,
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 40a0d93998..7f72373ffb 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -39,7 +39,7 @@ GdkGC * _gdk_win32_gc_new (GdkDrawable *drawable,
GdkGCValuesMask values_mask);
COLORREF gdk_colormap_color (GdkColormap *colormap,
gulong pixel);
-HRGN BitmapToRegion (HBITMAP hBmp);
+HRGN BitmapToRegion (HBITMAP hBmp);
gchar *gdk_font_full_name_get (GdkFont *font);
diff --git a/gdk/win32/gdkwin32.h b/gdk/win32/gdkwin32.h
index 50b6ca306c..9bbf6ce7d7 100644
--- a/gdk/win32/gdkwin32.h
+++ b/gdk/win32/gdkwin32.h
@@ -36,6 +36,9 @@
#include <windows.h>
#include <commctrl.h>
+#include <gdk/win32/gdkwindow-win32.h>
+#include <gdk/win32/gdkpixmap-win32.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -306,11 +309,14 @@ GDKVAR gchar *gdk_progclass;
GDKVAR ATOM gdk_selection_property;
/* Functions to create GDK pixmaps and windows from their native equivalents */
-GdkPixmap *gdk_pixmap_foreign_new (guint32 anid);
-GdkWindow *gdk_window_foreign_new (guint32 anid);
+GdkPixmap *gdk_pixmap_foreign_new (GdkNativeWindow anid);
+GdkWindow *gdk_window_foreign_new (GdkNativeWindow anid);
/* Return the Gdk* for a particular HANDLE */
-gpointer gdk_win32_handle_table_lookup (HANDLE handle);
+gpointer gdk_win32_handle_table_lookup (GdkNativeWindow handle);
+
+#define gdk_window_lookup(hwnd) (GdkWindow*) gdk_win32_handle_table_lookup (hwnd)
+#define gdk_pixmap_lookup(hbm) (GdkPixmap*) gdk_win32_handle_table_lookup (hbm)
/* Return a device context to draw in a drawable, given a GDK GC,
* and a mask indicating which GC values might be used (for efficiency,
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index fd72bc5fb2..94cc5cd798 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -32,8 +32,6 @@
#include "gdkwindow.h"
#include "gdkinternals.h"
#include "gdkprivate-win32.h"
-#include "gdkwindow-win32.h"
-#include "gdkpixmap-win32.h"
static gboolean gdk_window_gravity_works (void);
static void gdk_window_set_static_win_gravity (GdkWindow *window,
@@ -157,7 +155,7 @@ gdk_window_impl_win32_get_colormap (GdkDrawable *drawable)
if (!((GdkWindowObject *) drawable_impl->wrapper)->input_only &&
drawable_impl->colormap == NULL)
{
- g_assert_not_reached ();
+ drawable_impl->colormap = gdk_colormap_get_system ();
}
return drawable_impl->colormap;
@@ -637,7 +635,7 @@ gdk_window_foreign_new (GdkNativeWindow anid)
draw_impl = GDK_DRAWABLE_IMPL_WIN32 (private->impl);
draw_impl->wrapper = GDK_DRAWABLE (window);
- private->parent = gdk_win32_handle_table_lookup (parent);
+ private->parent = gdk_win32_handle_table_lookup ((GdkNativeWindow) parent);
parent_private = (GdkWindowObject *)private->parent;
@@ -1638,7 +1636,7 @@ gdk_window_get_pointer (GdkWindow *window,
ScreenToClient (hwndc, &point);
} while (hwndc != hwnd && (hwnd = hwndc, 1)); /* Ouch! */
- return_val = gdk_win32_handle_table_lookup (hwnd);
+ return_val = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
if (mask)
{
@@ -1696,7 +1694,7 @@ gdk_window_at_pointer (gint *win_x,
ScreenToClient (hwndc, &point);
} while (hwndc != hwnd && (hwnd = hwndc, 1));
- window = gdk_win32_handle_table_lookup (hwnd);
+ window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
if (window && (win_x || win_y))
{