Intermediate commit. I go to bed now.

This commit is contained in:
Tor Lillqvist 1999-11-17 00:45:37 +00:00
parent 3a330a3d6b
commit eec6970fe2
10 changed files with 546 additions and 1365 deletions

View File

@ -293,10 +293,10 @@ alloc_color(Colormap colormap,
*/
static void
XFreeColors(Colormap colormap,
gulong *pixels,
gint npixels,
gulong planes)
free_colors (Colormap colormap,
gulong *pixels,
gint npixels,
gulong planes)
{
gint i;
PALETTEENTRY entries[256];
@ -329,11 +329,11 @@ XFreeColors(Colormap colormap,
if (SetPaletteEntries (colormap->palette, lowestpixel,
highestpixel - lowestpixel + 1,
entries + lowestpixel) == 0)
g_warning ("XFreeColors: SetPaletteEntries failed");
g_warning ("free_colors: SetPaletteEntries failed");
#endif
colormap->stale = TRUE;
#if 0
g_print("XFreeColors %#x lowestpixel = %d, highestpixel = %d\n",
g_print("free_colors %#x lowestpixel = %d, highestpixel = %d\n",
colormap->palette, lowestpixel, highestpixel);
#endif
}
@ -358,7 +358,7 @@ XFreeColors(Colormap colormap,
static Colormap
create_colormap (HWND w,
Visual *visual,
int alloc)
gboolean alloc)
{
char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
LOGPALETTE *logPalettePtr;
@ -420,7 +420,7 @@ create_colormap (HWND w,
*/
static void
XFreeColormap(Colormap colormap)
free_colormap(Colormap colormap)
{
if (!DeleteObject (colormap->palette))
@ -1304,7 +1304,7 @@ parse_color(Colormap map,
/* End of code from Tk8.0 */
static Colormap
DefaultColormap ()
default_colormap ()
{
static Colormap colormap;
gint i;
@ -1312,7 +1312,7 @@ DefaultColormap ()
if (colormap)
return colormap;
colormap = create_colormap ( NULL, NULL, AllocNone);
colormap = create_colormap ( NULL, NULL, FALSE);
return colormap;
}
@ -1321,18 +1321,18 @@ gdk_colormap_new (GdkVisual *visual,
gint private_cmap)
{
GdkColormap *colormap;
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
Visual *xvisual;
int size;
unsigned int i;
int i;
g_return_val_if_fail (visual != NULL, NULL);
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateWin32, 1);
colormap = (GdkColormap*) private;
private->visual = visual;
private->ref_count = 1;
private->base.visual = visual;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
@ -1354,7 +1354,7 @@ gdk_colormap_new (GdkVisual *visual,
private->private_val = private_cmap;
private->xcolormap = create_colormap (gdk_root_window, xvisual,
(private_cmap) ? (AllocAll) : (AllocNone));
private_cmap);
if (private_cmap)
{
@ -1387,7 +1387,7 @@ gdk_colormap_new (GdkVisual *visual,
case GDK_VISUAL_TRUE_COLOR:
private->private_val = FALSE;
private->xcolormap = create_colormap (gdk_root_window,
xvisual, AllocNone);
xvisual, FALSE);
break;
}
@ -1399,13 +1399,13 @@ gdk_colormap_new (GdkVisual *visual,
void
_gdk_colormap_real_destroy (GdkColormap *colormap)
{
GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap;
g_return_if_fail (colormap != NULL);
g_return_if_fail (private->ref_count == 0);
g_return_if_fail (private->base.ref_count == 0);
gdk_colormap_remove (colormap);
XFreeColormap (private->xcolormap);
free_colormap (private->xcolormap);
if (private->hash)
g_hash_table_destroy (private->hash);
@ -1422,7 +1422,7 @@ gdk_colormap_sync (GdkColormap *colormap,
gboolean force)
{
time_t current_time;
GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
GdkColormapPrivateWin32 *private = (GdkColormapPrivateWin32 *) colormap;
XColor *xpalette;
gint nlookup;
gint i;
@ -1460,33 +1460,32 @@ gdk_colormap_sync (GdkColormap *colormap,
g_free (xpalette);
}
GdkColormap*
gdk_colormap_get_system (void)
{
static GdkColormap *colormap = NULL;
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i;
if (!colormap)
{
private = g_new (GdkColormapPrivate, 1);
private = g_new (GdkColormapPrivateWin32, 1);
colormap = (GdkColormap*) private;
private->xcolormap = DefaultColormap ();
private->visual = gdk_visual_get_system ();
private->xcolormap = default_colormap ();
private->base.visual = gdk_visual_get_system ();
private->private_val = FALSE;
private->ref_count = 1;
private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
private->info = NULL;
colormap->colors = NULL;
colormap->size = private->visual->colormap_size;
colormap->size = private->base.visual->colormap_size;
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
@ -1527,7 +1526,7 @@ void
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkVisual *visual;
XColor *palette;
gint shift;
@ -1539,8 +1538,8 @@ gdk_colormap_change (GdkColormap *colormap,
palette = g_new (XColor, ncolors);
private = (GdkColormapPrivate*) colormap;
switch (private->visual->type)
private = (GdkColormapPrivateWin32 *) colormap;
switch (private->base.visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
@ -1573,13 +1572,13 @@ gdk_colors_alloc (GdkColormap *colormap,
gulong *pixels,
gint npixels)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint return_val;
gint i;
g_return_val_if_fail (colormap != NULL, 0);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
return_val = alloc_color_cells (private->xcolormap, contiguous,
planes, nplanes, pixels, npixels);
@ -1593,7 +1592,7 @@ gdk_colors_alloc (GdkColormap *colormap,
}
}
return return_val;
return return_val != 0;
}
gboolean
@ -1602,19 +1601,13 @@ gdk_color_parse (const gchar *spec,
{
Colormap xcolormap;
XColor xcolor;
gboolean return_val;
g_return_val_if_fail (spec != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
xcolormap = DefaultColormap ();
xcolormap = default_colormap ();
if (parse_color (xcolormap, spec, color))
return_val = TRUE;
else
return_val = FALSE;
return return_val;
return parse_color (xcolormap, spec, color);
}
/* This is almost identical to gdk_colormap_free_colors.
@ -1626,7 +1619,7 @@ gdk_colors_free (GdkColormap *colormap,
gint in_npixels,
gulong planes)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
gint npixels = 0;
gint i;
@ -1634,10 +1627,10 @@ gdk_colors_free (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (in_pixels != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, in_npixels);
@ -1654,15 +1647,14 @@ gdk_colors_free (GdkColormap *colormap,
{
pixels[npixels++] = pixel;
if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
g_hash_table_remove (private->hash, &colormap->colors[pixel]);
private->info[pixel].flags = 0;
}
}
}
if (npixels)
XFreeColors (private->xcolormap, pixels, npixels, planes);
free_colors (private->xcolormap, pixels, npixels, planes);
g_free (pixels);
}
@ -1675,7 +1667,7 @@ gdk_colormap_free_colors (GdkColormap *colormap,
GdkColor *colors,
gint ncolors)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
gint npixels = 0;
gint i;
@ -1683,10 +1675,10 @@ gdk_colormap_free_colors (GdkColormap *colormap,
g_return_if_fail (colormap != NULL);
g_return_if_fail (colors != NULL);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->visual->type != GDK_VISUAL_GRAYSCALE))
if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
(private->base.visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, ncolors);
@ -1703,13 +1695,13 @@ gdk_colormap_free_colors (GdkColormap *colormap,
{
pixels[npixels++] = pixel;
if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
g_hash_table_remove (private->hash, &colors[i]);
g_hash_table_remove (private->hash, &colormap->colors[pixel]);
private->info[pixel].flags = 0;
}
}
}
if (npixels)
XFreeColors (private->xcolormap, pixels, npixels, 0);
free_colors (private->xcolormap, pixels, npixels, 0);
g_free (pixels);
}
@ -1725,10 +1717,10 @@ gdk_colormap_alloc1 (GdkColormap *colormap,
GdkColor *color,
GdkColor *ret)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
XColor xcolor;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
xcolor.peRed = color->red >> 8;
xcolor.peGreen = color->green >> 8;
@ -1772,12 +1764,12 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gulong *pixels;
Status status;
gint i, index;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
if (private->private_val)
{
@ -1802,8 +1794,8 @@ gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
else
{
pixels = g_new (gulong, ncolors);
/* Allocation of a writeable color cells */
status = alloc_color_cells (private->xcolormap, FALSE, NULL,
0, pixels, ncolors);
if (status)
@ -1830,13 +1822,13 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i, index;
XColor *store = g_new (XColor, ncolors);
gint nstore = 0;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
index = -1;
/* First, store the colors we have room for */
@ -1892,6 +1884,7 @@ gdk_colormap_alloc_colors_private (GdkColormap *colormap,
{
colors[i] = colormap->colors[index];
private->info[index].ref_count++;
success[i] = TRUE;
nremaining--;
}
@ -1911,12 +1904,12 @@ gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
gint i, index;
gint nremaining = 0;
gint nfailed = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
index = -1;
for (i=0; i<ncolors; i++)
@ -2003,12 +1996,12 @@ gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkColor *lookup_color;
gint i;
gint nremaining = 0;
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
/* Check for an exact match among previously allocated colors */
@ -2050,7 +2043,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
gboolean best_match,
gboolean *success)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
GdkVisual *visual;
gint i;
gint nremaining = 0;
@ -2059,14 +2052,14 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
for (i=0; i<ncolors; i++)
{
success[i] = FALSE;
}
switch (private->visual->type)
switch (private->base.visual->type)
{
case GDK_VISUAL_PSEUDO_COLOR:
case GDK_VISUAL_GRAYSCALE:
@ -2079,7 +2072,7 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
break;
case GDK_VISUAL_TRUE_COLOR:
visual = private->visual;
visual = private->base.visual;
for (i=0; i<ncolors; i++)
{
@ -2111,13 +2104,13 @@ gboolean
gdk_color_change (GdkColormap *colormap,
GdkColor *color)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
XColor xcolor;
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (color != NULL, FALSE);
private = (GdkColormapPrivate*) colormap;
private = (GdkColormapPrivateWin32 *) colormap;
xcolor.peRed = color->red >> 8;
xcolor.peGreen = color->green >> 8;
@ -2184,13 +2177,13 @@ gdk_colormap_lookup (Colormap xcolormap)
static void
gdk_colormap_add (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateWin32 *) cmap;
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
}
@ -2198,13 +2191,13 @@ gdk_colormap_add (GdkColormap *cmap)
static void
gdk_colormap_remove (GdkColormap *cmap)
{
GdkColormapPrivate *private;
GdkColormapPrivateWin32 *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
private = (GdkColormapPrivate*) cmap;
private = (GdkColormapPrivateWin32 *) cmap;
g_hash_table_remove (colormap_hash, &private->xcolormap);
}
@ -2223,7 +2216,7 @@ gdk_colormap_cmp (Colormap *a,
}
char *
gdk_color_to_string (GdkColor *color)
gdk_color_to_string (const GdkColor *color)
{
static char buf[100];

View File

@ -20,7 +20,7 @@
#include "config.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
#include "gdkwin32.h"
static const struct { const char *name; int type; } cursors[] = {
{ "x_cursor", 0 },
@ -109,7 +109,6 @@ gdk_cursor_new (GdkCursorType cursor_type)
GdkCursorPrivate *private;
GdkCursor *cursor;
HCURSOR xcursor;
int i;
for (i = 0; cursors[i].name != NULL && cursors[i].type != cursor_type; i++)
@ -235,9 +234,9 @@ gdk_cursor_new_from_pixmap (GdkPixmap *source,
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
GDK_DRAWABLE_XID (source),
source_private->width, source_private->height,
mask_private->xwindow,
GDK_DRAWABLE_XID (mask),
mask_private->width, mask_private->height,
xcursor, cursor_width, cursor_height));

View File

@ -36,7 +36,7 @@
#include "gdkdnd.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include "gdkx.h"
#include "gdkwin32.h"
#ifdef OLE2_DND
#include <ole2.h>
@ -671,7 +671,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
private = (GdkDragContextPrivate *) context;
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
context->source_window = (GdkWindow *) gdk_root_parent;
context->source_window = gdk_parent_root;
context->dest_window = event->any.window;
gdk_window_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
@ -713,8 +713,8 @@ gdk_dropfiles_filter (GdkXEvent *xev,
}
g_string_append (result, "\015\012");
}
gdk_sel_prop_store ((GdkWindow *) gdk_root_parent,
text_uri_list_atom, 8, result->str, result->len + 1);
gdk_sel_prop_store (gdk_parent_root, text_uri_list_atom, 8,
result->str, result->len + 1);
DragFinish (hdrop);
@ -816,7 +816,7 @@ gdk_drag_find_window (GdkDragContext *context,
POINT pt;
GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n",
(drag_window ? drag_window_private->xwindow : 0),
(drag_window ? GDK_DRAWABLE_XID (drag_window) : 0),
x_root, y_root));
pt.x = x_root;
@ -911,7 +911,6 @@ gdk_destroy_filter (GdkXEvent *xev,
void
gdk_window_register_dnd (GdkWindow *window)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *) window;
#ifdef OLE2_DND
target_drag_context *context;
HRESULT hres;
@ -919,7 +918,8 @@ gdk_window_register_dnd (GdkWindow *window)
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", private->xwindow));
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n",
GDK_DRAWABLE_XID (window)));
/* We always claim to accept dropped files, but in fact we might not,
* of course. This function is called in such a way that it cannot know
@ -927,7 +927,7 @@ gdk_window_register_dnd (GdkWindow *window)
* (in gtk, data of type text/uri-list) or not.
*/
gdk_window_add_filter (window, gdk_dropfiles_filter, NULL);
DragAcceptFiles (private->xwindow, TRUE);
DragAcceptFiles (GDK_DRAWABLE_XID (window), TRUE);
#ifdef OLE2_DND
/* Register for OLE2 d&d */
@ -937,7 +937,7 @@ gdk_window_register_dnd (GdkWindow *window)
g_warning ("gdk_window_register_dnd: CoLockObjectExternal failed");
else
{
hres = RegisterDragDrop (private->xwindow, &context->idt);
hres = RegisterDragDrop (GDK_DRAWABLE_XID (window), &context->idt);
if (hres == DRAGDROP_E_ALREADYREGISTERED)
{
g_print ("DRAGDROP_E_ALREADYREGISTERED\n");

View File

@ -27,57 +27,111 @@
#include "config.h"
#include <math.h>
#include "gdkdrawable.h"
#include "gdkprivate.h"
#include "gdkwindow.h"
#include "gdkx.h"
#include <glib.h>
#ifndef G_PI
#define G_PI 3.14159265358979323846
#endif
/* Manipulation of drawables
*/
void
gdk_drawable_set_data (GdkDrawable *drawable,
const gchar *key,
gpointer data,
GDestroyNotify destroy_func)
{
g_dataset_set_data_full (drawable, key, data, destroy_func);
}
#include "gdkdrawable.h"
#include "gdkprivate.h"
#include "gdkwindow.h"
#include "gdkwin32.h"
void
gdk_drawable_get_data (GdkDrawable *drawable,
const gchar *key)
{
g_dataset_get_data (drawable, key);
}
static void gdk_win32_drawable_destroy (GdkDrawable *drawable);
GdkDrawableType
gdk_drawable_get_type (GdkDrawable *drawable)
{
g_return_val_if_fail (drawable != NULL, (GdkDrawableType) -1);
return GDK_DRAWABLE_TYPE (drawable);
}
static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height);
static void gdk_win32_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
static void gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints);
static void gdk_win32_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length);
static void gdk_win32_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length);
static void gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static void gdk_win32_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_win32_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
static void gdk_win32_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints);
void
gdk_drawable_get_size (GdkDrawable *drawable,
gint *width,
gint *height)
GdkDrawableClass _gdk_win32_drawable_class = {
gdk_win32_drawable_destroy,
_gdk_win32_gc_new,
gdk_win32_draw_rectangle,
gdk_win32_draw_arc,
gdk_win32_draw_polygon,
gdk_win32_draw_text,
gdk_win32_draw_text_wc,
gdk_win32_draw_drawable,
gdk_win32_draw_points,
gdk_win32_draw_segments,
gdk_win32_draw_lines
};
/*****************************************************
* Win32 specific implementations of generic functions *
*****************************************************/
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
g_return_if_fail (drawable != NULL);
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL)
return gdk_colormap_get_system (); /* XXX ??? */
else
return drawable_private->colormap;
}
if (width)
*width = drawable_private->width;
if (height)
*height = drawable_private->height;
return NULL;
}
void
@ -85,13 +139,13 @@ gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
GdkColormapPrivate *colormap_private;
GdkColormapPrivateWin32 *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
colormap_private = (GdkColormapPrivate*) colormap;
drawable_private = (GdkDrawablePrivate *) drawable;
colormap_private = (GdkColormapPrivateWin32 *) colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
@ -115,137 +169,33 @@ gdk_drawable_set_colormap (GdkDrawable *drawable,
}
}
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
/* Drawing
*/
static void
gdk_win32_drawable_destroy (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL)
return gdk_colormap_get_system (); /* XXX ??? */
else
return drawable_private->colormap;
}
return NULL;
}
GdkVisual*
gdk_drawable_get_visual (GdkDrawable *drawable)
static void
gdk_win32_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{
GdkColormap *colormap;
g_return_val_if_fail (drawable != NULL, NULL);
colormap = gdk_drawable_get_colormap (drawable);
return colormap ? gdk_colormap_get_visual (colormap) : NULL;
}
void
gdk_draw_point (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
/* We use LineTo because SetPixel wants the COLORREF directly,
* and doesn't use the current pen, which is what we want.
*/
if (!MoveToEx (hdc, x, y, NULL))
g_warning ("gdk_draw_point: MoveToEx failed");
if (!LineTo (hdc, x + 1, y))
g_warning ("gdk_draw_point: LineTo failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_line (GdkDrawable *drawable,
GdkGC *gc,
gint x1,
gint y1,
gint x2,
gint y2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_line: %#x (%d) +%d+%d..+%d+%d\n",
drawable_private->xwindow, gc_private,
x1, y1, x2, y2));
MoveToEx (hdc, x1, y1, NULL);
if (!LineTo (hdc, x2, y2))
g_warning ("gdk_draw_line: LineTo #1 failed");
/* LineTo doesn't draw the last point, so if we have a pen width of 1,
* we draw the end pixel separately... With wider pens we don't care.
* //HB: But the NT developers don't read their API documentation ...
*/
if (gc_private->pen_width == 1 && windows_version > 0x80000000)
if (!LineTo (hdc, x2 + 1, y2))
g_warning ("gdk_draw_line: LineTo #2 failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
HGDIOBJ oldpen, oldbrush;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n",
drawable_private->xwindow,
GDK_DRAWABLE_XID (drawable),
gc_private,
(filled ? "fill " : ""),
width, height, x, y));
@ -282,45 +232,33 @@ gdk_draw_rectangle (GdkDrawable *drawable,
else
SelectObject (hdc, oldbrush);
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
static void
gdk_win32_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n",
drawable_private->xwindow,
GDK_DRAWABLE_XID (drawable),
x, y, width, height, angle1, angle2));
if (width != 0 && height != 0 && angle2 != 0)
{
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
if (angle2 >= 360*64)
{
@ -360,39 +298,32 @@ gdk_draw_arc (GdkDrawable *drawable,
Arc (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc);
}
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
}
void
gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
static void
gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
GDK_NOTE (MISC, g_print ("gdk_draw_polygon: %#x (%d) %d\n",
drawable_private->xwindow, gc_private,
GDK_DRAWABLE_XID (drawable), gc_private,
npoints));
if (npoints < 2)
return;
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
pts = g_malloc ((npoints+1) * sizeof (POINT));
for (i = 0; i < npoints; i++)
@ -419,7 +350,7 @@ gdk_draw_polygon (GdkDrawable *drawable,
g_warning ("gdk_draw_polygon: Polyline failed");
}
g_free (pts);
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
typedef struct
@ -428,19 +359,6 @@ typedef struct
HDC hdc;
} gdk_draw_text_arg;
/* gdk_draw_string
*/
void
gdk_draw_string (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *string)
{
gdk_draw_text (drawable, font, gc, x, y, string, strlen (string));
}
static void
gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
const wchar_t *wcstr,
@ -468,28 +386,20 @@ gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
SelectObject (argp->hdc, oldfont);
}
/* gdk_draw_text
*
*/
void
gdk_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
static void
gdk_win32_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
wchar_t *wcstr;
gint wlen;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
@ -499,15 +409,14 @@ gdk_draw_text (GdkDrawable *drawable,
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
arg.hdc = gdk_gc_predraw (drawable, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
drawable_private->xwindow,
GDK_DRAWABLE_XID (drawable),
x, y,
(text_length > 10 ? 10 : text_length),
text, text_length));
@ -521,28 +430,23 @@ gdk_draw_text (GdkDrawable *drawable,
g_free (wcstr);
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
static void
gdk_win32_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
gint i, wlen;
wchar_t *wcstr;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
@ -552,15 +456,14 @@ gdk_draw_text_wc (GdkDrawable *drawable,
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
arg.hdc = gdk_gc_predraw (drawable, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
drawable_private->xwindow,
GDK_DRAWABLE_XID (drawable),
x, y, text_length));
if (sizeof (wchar_t) != sizeof (GdkWChar))
@ -578,21 +481,20 @@ gdk_draw_text_wc (GdkDrawable *drawable,
if (sizeof (wchar_t) != sizeof (GdkWChar))
g_free (wcstr);
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
static void
gdk_win32_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkDrawablePrivate *src_private;
GdkGCPrivate *gc_private;
HDC hdc;
@ -601,37 +503,25 @@ gdk_draw_pixmap (GdkDrawable *drawable,
HRGN src_rgn, draw_rgn, outside_rgn;
RECT r;
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
src_private = (GdkDrawablePrivate*) src;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = src_private->width; /* Or should we subtract xsrc? */
if (height == -1)
height = src_private->height; /* Ditto? */
GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x "
"src: %#x %dx%d@+%d+%d"
" dest: %#x @+%d+%d\n",
drawable_private->xwindow,
src_private->xwindow,
GDK_DRAWABLE_XID (drawable),
GDK_DRAWABLE_XID (src),
width, height, xsrc, ysrc,
drawable_private->xwindow, xdest, ydest));
GDK_DRAWABLE_XID (drawable), xdest, ydest));
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1);
draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
SetRectEmpty (&r);
outside_rgn = CreateRectRgnIndirect (&r);
if (drawable_private->window_type != GDK_DRAWABLE_PIXMAP)
if (GDK_DRAWABLE_TYPE (drawable) != GDK_DRAWABLE_PIXMAP)
{
/* If we are drawing on a window, calculate the region that is
* outside the source pixmap, and invalidate that, causing it to
@ -645,7 +535,7 @@ gdk_draw_pixmap (GdkDrawable *drawable,
"bbox: %dx%d@+%d+%d\n",
r.right - r.left - 1, r.bottom - r.top - 1,
r.left, r.top)));
InvalidateRgn (drawable_private->xwindow, outside_rgn, TRUE);
InvalidateRgn (GDK_DRAWABLE_XID (drawable), outside_rgn, TRUE);
}
}
@ -685,7 +575,7 @@ gdk_draw_pixmap (GdkDrawable *drawable,
if ((srcdc = CreateCompatibleDC (hdc)) == NULL)
g_warning ("gdk_draw_pixmap: CreateCompatibleDC failed");
if ((hgdiobj = SelectObject (srcdc, src_private->xwindow)) == NULL)
if ((hgdiobj = SelectObject (srcdc, GDK_DRAWABLE_XID (src))) == NULL)
g_warning ("gdk_draw_pixmap: SelectObject #1 failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
@ -700,7 +590,7 @@ gdk_draw_pixmap (GdkDrawable *drawable,
}
else
{
if (drawable_private->xwindow == src_private->xwindow)
if (GDK_DRAWABLE_XID(drawable) == GDK_DRAWABLE_XID (src))
{
/* Blitting inside a window, use ScrollDC */
RECT scrollRect, clipRect, emptyRect;
@ -722,80 +612,43 @@ gdk_draw_pixmap (GdkDrawable *drawable,
&scrollRect, &clipRect,
updateRgn, NULL))
g_warning ("gdk_draw_pixmap: ScrollDC failed");
if (!InvalidateRgn (drawable_private->xwindow, updateRgn, FALSE))
if (!InvalidateRgn (GDK_DRAWABLE_XID (drawable), updateRgn, FALSE))
g_warning ("gdk_draw_pixmap: InvalidateRgn failed");
if (!UpdateWindow (drawable_private->xwindow))
if (!UpdateWindow (GDK_DRAWABLE_XID (drawable)))
g_warning ("gdk_draw_pixmap: UpdateWindow failed");
}
else
{
if ((srcdc = GetDC (src_private->xwindow)) == NULL)
if ((srcdc = GetDC (GDK_DRAWABLE_XID (src))) == NULL)
g_warning ("gdk_draw_pixmap: GetDC failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_draw_pixmap: BitBlt failed");
ReleaseDC (src_private->xwindow, srcdc);
ReleaseDC (GDK_DRAWABLE_XID (src), srcdc);
}
}
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_image (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
static void
gdk_win32_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkImagePrivate *image_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
image_private = (GdkImagePrivate*) image;
g_return_if_fail (image_private->image_put != NULL);
if (width == -1)
width = image->width;
if (height == -1)
height = image->height;
(* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
xdest, ydest, width, height);
}
void
gdk_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail ((points != NULL) && (npoints > 0));
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x destdc: (%d) %#x "
"npoints: %d\n",
drawable_private->xwindow, gc_private, hdc,
GDK_DRAWABLE_XID (drawable),
gc_private, hdc,
npoints));
for (i = 0; i < npoints; i++)
@ -805,33 +658,22 @@ gdk_draw_points (GdkDrawable *drawable,
if (!LineTo (hdc, points[i].x + 1, points[i].y))
g_warning ("gdk_draw_points: LineTo failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
static void
gdk_win32_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
if (nsegs <= 0)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (segs != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
for (i = 0; i < nsegs; i++)
{
@ -841,20 +683,19 @@ gdk_draw_segments (GdkDrawable *drawable,
g_warning ("gdk_draw_segments: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (GDK_GC_WIN32DATA (gc)->pen_width == 1)
if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2))
g_warning ("gdk_draw_segments: LineTo #2 failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}
void
gdk_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
static void
gdk_win32_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
@ -863,16 +704,9 @@ gdk_draw_lines (GdkDrawable *drawable,
if (npoints < 2)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (points != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
hdc = gdk_gc_predraw (drawable, gc_private);
#if 1
pts = g_malloc (npoints * sizeof (POINT));
@ -888,7 +722,7 @@ gdk_draw_lines (GdkDrawable *drawable,
g_free (pts);
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (GDK_GC_WIN32DATA (gc)->pen_width == 1)
{
MoveToEx (hdc, points[npoints-1].x, points[npoints-1].y, NULL);
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
@ -901,9 +735,13 @@ gdk_draw_lines (GdkDrawable *drawable,
g_warning ("gdk_draw_lines: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
/* LineTo doesn't draw the last point, so if we have a pen width of 1,
* we draw the end pixel separately... With wider pens we don't care.
* //HB: But the NT developers don't read their API documentation ...
*/
if (GDK_GC_WIN32DATA (gc)->pen_width == 1 && windows_version > 0x80000000)
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
g_warning ("gdk_draw_lines: LineTo #2 failed");
#endif
gdk_gc_postdraw (drawable_private, gc_private);
gdk_gc_postdraw (drawable, gc_private);
}

File diff suppressed because it is too large Load Diff

View File

@ -899,9 +899,10 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
}
HDC
gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private)
gdk_gc_predraw (GdkDrawable *drawable,
GdkGCPrivate *gc_private)
{
GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;
GdkColormapPrivate *colormap_private =
(GdkColormapPrivate *) drawable_private->colormap;
COLORREF bg;
@ -912,7 +913,7 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
g_assert (gc_private->xgc == NULL);
if (drawable_private->window_type == GDK_DRAWABLE_PIXMAP)
if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP)
{
if ((gc_private->xgc = CreateCompatibleDC (NULL)) == NULL)
g_warning ("gdk_gc_predraw: CreateCompatibleDC failed");
@ -1082,13 +1083,14 @@ gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
}
void
gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private)
gdk_gc_postdraw (GdkDrawable *drawable_private,
GdkGCPrivate *gc_private)
{
HGDIOBJ hpen;
HGDIOBJ hbr;
GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable;
GdkColormapPrivate *colormap_private =
(GdkColormapPrivate *) drawable_private->colormap;
HGDIOBJ hpen;
HGDIOBJ hbr;
if ((hpen = GetCurrentObject (gc_private->xgc, OBJ_PEN)) == NULL)
g_warning ("gdk_gc_postdraw: GetCurrentObject #1 failed");
@ -1108,7 +1110,7 @@ gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
g_warning ("gdk_gc_postraw: UnrealizeObject failed");
}
#endif
if (drawable_private->window_type == GDK_DRAWABLE_PIXMAP)
if (GDK_DRAWABLE_TYPE (drawable) == GDK_DRAWABLE_PIXMAP)
{
if (!DeleteDC (gc_private->xgc))
g_warning ("gdk_gc_postdraw: DeleteDC failed");

View File

@ -1001,7 +1001,10 @@ gdk_input_win32_other_event (GdkEvent *event,
gint x, y;
if (event->any.window != wintab_window)
g_warning ("gdk_input_win32_other_event: not wintab_window?");
{
g_warning ("gdk_input_win32_other_event: not wintab_window?");
return FALSE;
}
#if USE_SYSCONTEXT
window = gdk_window_at_pointer (&x, &y);

View File

@ -24,8 +24,8 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_PRIVATE_H__
#define __GDK_PRIVATE_H__
#ifndef __GDK_PRIVATE_WIN32_H__
#define __GDK_PRIVATE_WIN32_H__
#define STRICT /* We want strict type checks */
#include <windows.h>
@ -58,6 +58,7 @@
#include <time.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkevents.h>
@ -65,19 +66,9 @@
#include <gdk/gdkgc.h>
#include <gdk/gdkim.h>
#include <gdk/gdkimage.h>
#include <gdk/gdkregion.h>
#include <gdk/gdkvisual.h>
#include <gdk/gdkwindow.h>
#define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
#define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
#define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
#define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -85,13 +76,8 @@ extern "C" {
/* Define corresponding Windows types for some X11 types, just for laziness.
*/
typedef HANDLE XID;
typedef PALETTEENTRY XColor;
typedef HDC GC;
typedef ATOM Atom;
typedef HCURSOR Cursor;
typedef guint VisualID;
typedef DWORD KeySym;
typedef int Status;
/* Define some of the X11 constants also here, again just for laziness */
@ -106,10 +92,6 @@ typedef int Status;
#define GrabSuccess 0
#define AlreadyGrabbed 2
/* For CreateColormap */
#define AllocNone 0
#define AllocAll 1
/* Some structs are somewhat useful to emulate internally, just to
keep the code less #ifdefed. */
typedef struct {
@ -139,46 +121,62 @@ typedef struct {
unsigned long base_pixel;
} XStandardColormap;
typedef struct _GdkDrawablePrivate GdkDrawablePrivate;
/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */
typedef struct _GdkWindowPrivate GdkWindowPrivate;
typedef struct _GdkImagePrivate GdkImagePrivate;
typedef struct _GdkGCPrivate GdkGCPrivate;
typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkColorInfo GdkColorInfo;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkClientFilter GdkClientFilter;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
typedef struct _GdkGCWin32Data GdkGCWin32Data;
typedef struct _GdkDrawableWin32Data GdkDrawableWin32Data;
typedef struct _GdkWindowWin32Data GdkWindowWin32Data;
typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkFontPrivateWin32 GdkFontPrivateWin32;
typedef struct _GdkImagePrivateWin32 GdkImagePrivateWin32;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
typedef struct _GdkICPrivate GdkICPrivate;
struct _GdkDrawablePrivate
#define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
#define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
#define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data))
struct _GdkGCWin32Data
{
GdkDrawable drawable;
guint8 window_type;
guint ref_count;
guint16 width;
guint16 height;
HANDLE xwindow;
GdkColormap *colormap;
guint destroyed : 2;
/* A Windows Device Context (DC) is not equivalent to an X11
* GC. We can use a DC only in the window for which it was
* allocated, or (in the case of a memory DC) with the bitmap that
* has been selected into it. Thus, we have to release and
* reallocate a DC each time the GdkGC is used to paint into a new
* window or pixmap. We thus keep all the necessary values in the
* GdkGCPrivate struct.
*/
HDC xgc;
GdkGCValuesMask values_mask;
GdkColor foreground;
GdkColor background;
GdkFont *font;
gint rop2;
GdkFill fill_style;
GdkPixmap *tile;
GdkPixmap *stipple;
HRGN clip_region;
GdkSubwindowMode subwindow_mode;
gint ts_x_origin;
gint ts_y_origin;
gint clip_x_origin;
gint clip_y_origin;
gint graphics_exposures;
gint pen_width;
DWORD pen_style;
HANDLE hwnd; /* If a DC is allocated, for which window
or what bitmap is selected into it */
int saved_dc;
};
struct _GdkWindowPrivate
struct _GdkDrawableWin32Data
{
GdkDrawablePrivate drawable;
HANDLE xid;
};
GdkWindow *parent;
gint16 x;
gint16 y;
guint8 resize_count;
guint mapped : 1;
guint guffaw_gravity : 1;
struct _GdkWindowWin32Data
{
GdkDrawableWin32Data drawable;
/* We must keep the event mask here to filter them ourselves */
gint event_mask;
@ -206,93 +204,14 @@ struct _GdkWindowPrivate
gint extension_events;
gboolean extension_events_selected;
GList *filters;
GList *children;
HKL input_locale;
CHARSETINFO charset_info;
};
struct _GdkImagePrivate
struct _GdkCursorPrivate
{
GdkImage image;
HBITMAP ximage;
gpointer x_shm_info;
void (*image_put) (GdkDrawable *window,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
};
struct _GdkGCPrivate
{
GdkGC gc;
GC xgc;
/* A Windows Device Context (DC) is not equivalent to an X11
* GC. We can use a DC only in the window for which it was
* allocated, or (in the case of a memory DC) with the bitmap that
* has been selected into it. Thus, we have to release and
* reallocate a DC each time the GdkGC is used to paint into a new
* window or pixmap. We thus keep all the necessary values in the
* GdkGCPrivate struct.
*/
GdkGCValuesMask values_mask;
GdkColor foreground;
GdkColor background;
GdkFont *font;
gint rop2;
GdkFill fill_style;
GdkPixmap *tile;
GdkPixmap *stipple;
HRGN clip_region;
GdkSubwindowMode subwindow_mode;
gint ts_x_origin;
gint ts_y_origin;
gint clip_x_origin;
gint clip_y_origin;
gint graphics_exposures;
gint pen_width;
DWORD pen_style;
HANDLE hwnd; /* If a DC is allocated, for which window
or what bitmap is selected into it */
int saved_dc;
guint ref_count;
};
typedef enum {
GDK_COLOR_WRITEABLE = 1 << 0
} GdkColorInfoFlags;
struct _GdkColorInfo
{
GdkColorInfoFlags flags;
guint ref_count;
};
struct _GdkColormapPrivate
{
GdkColormap colormap;
Colormap xcolormap;
GdkVisual *visual;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
guint ref_count;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
Visual *xvisual;
GdkCursor cursor;
HCURSOR xcursor;
};
typedef struct
@ -304,30 +223,35 @@ typedef struct
FONTSIGNATURE fs;
} GdkWin32SingleFont;
struct _GdkFontPrivate
struct _GdkFontPrivateWin32
{
GdkFont font;
guint ref_count;
GSList *fonts;
GdkFontPrivate base;
GSList *fonts; /* Points to a list of GdkWin32SingleFonts */
GSList *names;
};
struct _GdkCursorPrivate
struct _GdkVisualPrivate
{
GdkCursor cursor;
Cursor xcursor;
GdkVisual visual;
Visual *xvisual;
};
struct _GdkEventFilter {
GdkFilterFunc function;
gpointer data;
struct _GdkColormapPrivateWin32
{
GdkColormapPrivate base;
Colormap xcolormap;
GdkVisual *visual;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
};
struct _GdkClientFilter {
GdkAtom type;
GdkFilterFunc function;
gpointer data;
struct _GdkImagePrivateWin32
{
GdkImagePrivate base;
HBITMAP ximage;
};
struct _GdkRegionPrivate
@ -336,85 +260,58 @@ struct _GdkRegionPrivate
HRGN xregion;
};
typedef enum {
GDK_DEBUG_MISC = 1 << 0,
GDK_DEBUG_EVENTS = 1 << 1,
GDK_DEBUG_DND = 1 << 2,
GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
GDK_DEBUG_XIM = 1 << 4,
GDK_DEBUG_SELECTION = 1 << 5
} GdkDebugFlag;
void gdk_events_init (void);
void gdk_window_init (void);
void gdk_visual_init (void);
void gdk_selection_init (void);
void gdk_dnd_init (void);
void gdk_dnd_exit (void);
void gdk_image_init (void);
void gdk_image_exit (void);
void gdk_dnd_exit (void);
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
GdkVisual* gdk_visual_lookup (Visual *xvisual);
void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_xid_table_insert (HANDLE *hnd,
gpointer data);
void gdk_xid_table_remove (HANDLE xid);
gpointer gdk_xid_table_lookup (HANDLE xid);
void gdk_xid_table_insert (XID *xid,
gpointer data);
void gdk_xid_table_remove (XID xid);
gpointer gdk_xid_table_lookup (XID xid);
GdkGC * _gdk_win32_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
HDC gdk_gc_predraw (GdkDrawable *drawable,
GdkGCPrivate *gc_private);
void gdk_gc_postdraw (GdkDrawable *drawable,
GdkGCPrivate *gc_private);
HRGN BitmapToRegion (HBITMAP hBmp);
/* Internal functions */
void gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length);
HDC gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
void gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
HRGN BitmapToRegion (HBITMAP hBmp);
gint gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max);
gint gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max);
void gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length);
void gdk_wchar_text_handle (GdkFont *font,
const wchar_t *wcstr,
int wclen,
void (*handler)(GdkWin32SingleFont *,
const wchar_t *,
int,
void *),
void *arg);
void gdk_event_queue_append (GdkEvent *event);
char *gdk_color_to_string (const GdkColor *);
gint gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max);
gint gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max);
extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
void gdk_wchar_text_handle (GdkFont *font,
const wchar_t *wcstr,
int wclen,
void (*handler)(GdkWin32SingleFont *,
const wchar_t *,
int,
void *),
void *arg);
/* Please see gdkwindow.c for comments on how to use */
HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
extern gint gdk_debug_level;
extern gint gdk_show_events;
extern gint gdk_stack_trace;
extern HWND gdk_root_window;
extern HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent;
GDKVAR Atom gdk_selection_property;
GDKVAR ATOM gdk_selection_property;
GDKVAR gchar *gdk_progclass;
GDKVAR gint gdk_error_code;
GDKVAR gint gdk_error_warnings;
GDKVAR gint gdk_null_window_warnings;
extern gint gdk_event_func_from_window_proc;
extern gboolean gdk_event_func_from_window_proc;
extern HDC gdk_DC;
extern HINSTANCE gdk_DLLInstance;
@ -427,33 +324,11 @@ extern GdkAtom gdk_clipboard_atom;
extern GdkAtom gdk_win32_dropfiles_atom;
extern GdkAtom gdk_ole2_dnd_atom;
extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
extern DWORD windows_version;
/* Debugging support */
#ifdef G_ENABLE_DEBUG
#define GDK_NOTE(type,action) G_STMT_START { \
if (gdk_debug_flags & GDK_DEBUG_##type) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GDK_NOTE(type,action)
#endif /* G_ENABLE_DEBUG */
GDKVAR guint gdk_debug_flags;
/* Internal functions for debug output etc. */
char *gdk_color_to_string (GdkColor *);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_PRIVATE_H__ */
#endif /* __GDK_PRIVATE_WIN32_H__ */

View File

@ -36,9 +36,7 @@
#define GDK_ROOT_PARENT() ((GdkWindow *) gdk_root_parent)
#define GDK_DISPLAY() NULL
#define GDK_DRAWABLE_XDISPLAY(win) NULL
#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_DRAWABLE_XID(win) (GDK_DRAWABLE_WIN32DATA(win)->xid)
#define GDK_IMAGE_XDISPLAY(image) NULL
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) NULL
@ -47,6 +45,9 @@
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* Functions to create GDK pixmaps and windows from their native equivalents */

View File

@ -121,6 +121,7 @@ gdk_window_init (void)
gdk_root_parent->drawable.height = height;
gdk_root_parent->drawable.ref_count = 1;
gdk_root_parent->drawable.colormap = NULL;
gdk_root_parent->parent = NULL;
gdk_root_parent->children = NULL;
gdk_xid_table_insert (&gdk_root_window, gdk_root_parent);