gtk2/gdk/win32/gdkdrawable-win32.c

1983 lines
53 KiB
C
Raw Normal View History

/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 1998-2004 Tor Lillqvist
* Copyright (C) 2001-2005 Hans Breuer
*
* 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 <math.h>
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
#include <stdio.h>
1999-11-17 00:45:37 +00:00
#include <glib.h>
#include <pango/pangowin32.h>
#include <cairo-win32.h>
#include "gdkscreen.h" /* gdk_screen_get_default() */
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
#include "gdkregion-generic.h"
Large changes to the Win32 backend, partially made necessary by the 2000-05-02 Tor Lillqvist <tml@iki.fi> Large changes to the Win32 backend, partially made necessary by the changes to the backend-independent internal structures. Attempts to implement similar backing store stuff as on X11. The current (CVS) version of the Win32 backend is *not* as stable as it was before the no-flicker branch was merged. A zipfile with that version is available from http://www.gimp.org/win32/. That should be use by "production" code until this CVS version is usable. (But note, the Win32 backend has never been claimed to be "production quality".) * README.win32: Add the above comment about versions. * gdk/gdkwindow.c: Don't use backing store for now on Win32. * gdk/gdk.def: Update. * gdk/gdkfont.h: Declare temporary Win32-only functions. Will presumably be replaced by some more better mechanism as 1.4 gets closer to release shape. * gdk/makefile.{cygwin,msc}: Update. * gdk/win32/*.c: Correct inclusions of the backend-specific and internal headers. Change code according to changes in these. Use gdk_drawable_*, not gdk_window_* where necessary. * gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not our old DND. * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try to interpret single characters as UTF-8. Thanks to Hans Breuer. Use correct function name in warning messages. * gdk/win32/gdkevents-win32.c: Use correct parameter lists for the GSourceFuncs gdk_event_prepare and gdk_event_check. (gdk_event_get_graphics_expose): Do implement, use PeekMessage. Thanks to Hans Breuer. (event_mask_string): Debugging function to print an GdkEventMask. (gdk_pointer_grab): Use it. * gdk/win32/gdkfont-win32.c: The Unicode subrange that the (old) book I used claimed was Hangul actually is CJK Unified Ideographs Extension A. Also, Hangul Syllables were missing. Improve logging. * gdk/win32/gdkgc-win32.c: Largish changes. * gdk/win32/gdkim-win32.c (gdk_set_locale): Use g_win32_getlocale() from GLib, and not setlocale() to get current locale name. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to gdkwin32.h, similarily as in the X11 backend. * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix, assignment was used instead of equals in if test. Thanks to Hans Breuer. * gdk/win32/makefile.{cygwin,msc} * gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the path to the Win32 headers that works also with the mingw compiler. * gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
#include "gdkprivate-win32.h"
1999-11-17 00:45:37 +00:00
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
#define ROP3_D 0x00AA0029
#define ROP3_DSna 0x00220326
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
#define ROP3_DSPDxax 0x00E20746
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
#define LINE_ATTRIBUTES (GDK_GC_LINE_WIDTH|GDK_GC_LINE_STYLE| \
GDK_GC_CAP_STYLE|GDK_GC_JOIN_STYLE)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
#define MUST_RENDER_DASHES_MANUALLY(gcwin32) \
(gcwin32->line_style == GDK_LINE_DOUBLE_DASH || \
(gcwin32->line_style == GDK_LINE_ON_OFF_DASH && gcwin32->pen_dash_offset))
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_rectangle (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_arc (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_polygon (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
gboolean filled,
GdkPoint *points,
gint npoints);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_text (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_text_wc (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_drawable (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkPixmap *src,
GdkDrawable *original_src,
2009-02-16 18:26:35 +00:00
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_points (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkPoint *points,
gint npoints);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_segments (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkSegment *segs,
gint nsegs);
1999-11-17 00:45:37 +00:00
static void gdk_win32_draw_lines (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkPoint *points,
gint npoints);
static void gdk_win32_draw_image (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static cairo_surface_t *gdk_win32_ref_cairo_surface (GdkDrawable *drawable);
static void gdk_win32_set_colormap (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkColormap *colormap);
static GdkColormap* gdk_win32_get_colormap (GdkDrawable *drawable);
static gint gdk_win32_get_depth (GdkDrawable *drawable);
Changes multihead reorganizing code for win32 support, mostly from a patch Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com> Changes multihead reorganizing code for win32 support, mostly from a patch by Hans Breuer. * gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c gdk/gdkscreen.c gdk/x11/gdkmain-x11.c gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c gdk/x11/gdkpango-x11.c gdk/gdkselection.c gdk/x11/gdkselection-x11.c gdk/gdkwindow.c gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c: Move port-independent singlehead wrapper functions into port-independent part of GDK. (#80009) * gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c: Turn singlehead functions into "multihead" functions that ignore their GdkDisplay or GdkScreen arguments. * gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h: Misc multihead-compatibility changes. * gtk/gtk.def gdk/gdk.def: Update for multihead functions. * gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c gdk/x11/gdkvisual-x11.c: Remove the screen fields from the public parts of the colormap/visual structures, add accessors instead. * gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen for colormaps, visuals; move the fields into the private structures for the x11 backend. * gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c: Remove virtualization of screen and display functions. (#79990, patch from Erwann Chenede) * gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}: New files containing stub implementations of Display, Screen functions. * gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkx.h: Clean up function exports and what headers they are in. (#79954) * gdk/x11/gdkx.h: Fix macro that was referring to a non-existant screen->screen_num. (In the patch for #79972, Erwann Chenede) * gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer() to use window hooks. (#79972, patch partly from Erwann Chenede) * gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix some warnings.
2002-06-06 00:26:42 +00:00
static GdkScreen * gdk_win32_get_screen (GdkDrawable *drawable);
static GdkVisual* gdk_win32_get_visual (GdkDrawable *drawable);
static void gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass);
static void gdk_drawable_impl_win32_finalize (GObject *object);
static gpointer parent_class = NULL;
static const cairo_user_data_key_t gdk_win32_cairo_key;
GType
gdk_drawable_impl_win32_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info =
{
sizeof (GdkDrawableImplWin32Class),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_drawable_impl_win32_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkDrawableImplWin32),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (GDK_TYPE_DRAWABLE,
"GdkDrawableImplWin32",
&object_info, 0);
}
return object_type;
}
1999-11-17 00:45:37 +00:00
static void
gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
{
GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_drawable_impl_win32_finalize;
drawable_class->create_gc = _gdk_win32_gc_new;
drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
drawable_class->draw_arc = gdk_win32_draw_arc;
drawable_class->draw_polygon = gdk_win32_draw_polygon;
drawable_class->draw_text = gdk_win32_draw_text;
drawable_class->draw_text_wc = gdk_win32_draw_text_wc;
drawable_class->draw_drawable = gdk_win32_draw_drawable;
drawable_class->draw_points = gdk_win32_draw_points;
drawable_class->draw_segments = gdk_win32_draw_segments;
drawable_class->draw_lines = gdk_win32_draw_lines;
drawable_class->draw_image = gdk_win32_draw_image;
drawable_class->ref_cairo_surface = gdk_win32_ref_cairo_surface;
drawable_class->set_colormap = gdk_win32_set_colormap;
drawable_class->get_colormap = gdk_win32_get_colormap;
drawable_class->get_depth = gdk_win32_get_depth;
Changes multihead reorganizing code for win32 support, mostly from a patch Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com> Changes multihead reorganizing code for win32 support, mostly from a patch by Hans Breuer. * gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c gdk/gdkscreen.c gdk/x11/gdkmain-x11.c gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c gdk/x11/gdkpango-x11.c gdk/gdkselection.c gdk/x11/gdkselection-x11.c gdk/gdkwindow.c gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c: Move port-independent singlehead wrapper functions into port-independent part of GDK. (#80009) * gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c: Turn singlehead functions into "multihead" functions that ignore their GdkDisplay or GdkScreen arguments. * gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h: Misc multihead-compatibility changes. * gtk/gtk.def gdk/gdk.def: Update for multihead functions. * gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c gdk/x11/gdkvisual-x11.c: Remove the screen fields from the public parts of the colormap/visual structures, add accessors instead. * gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen for colormaps, visuals; move the fields into the private structures for the x11 backend. * gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c: Remove virtualization of screen and display functions. (#79990, patch from Erwann Chenede) * gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}: New files containing stub implementations of Display, Screen functions. * gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkx.h: Clean up function exports and what headers they are in. (#79954) * gdk/x11/gdkx.h: Fix macro that was referring to a non-existant screen->screen_num. (In the patch for #79972, Erwann Chenede) * gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer() to use window hooks. (#79972, patch partly from Erwann Chenede) * gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix some warnings.
2002-06-06 00:26:42 +00:00
drawable_class->get_screen = gdk_win32_get_screen;
drawable_class->get_visual = gdk_win32_get_visual;
drawable_class->_copy_to_image = _gdk_win32_copy_to_image;
}
1999-11-17 00:45:37 +00:00
static void
gdk_drawable_impl_win32_finalize (GObject *object)
{
gdk_drawable_set_colormap (GDK_DRAWABLE (object), NULL);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
1999-11-17 00:45:37 +00:00
/*****************************************************
* Win32 specific implementations of generic functions *
*****************************************************/
static GdkColormap*
gdk_win32_get_colormap (GdkDrawable *drawable)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
return GDK_DRAWABLE_IMPL_WIN32 (drawable)->colormap;
}
static void
gdk_win32_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
if (impl->colormap == colormap)
return;
if (impl->colormap)
gdk_colormap_unref (impl->colormap);
impl->colormap = colormap;
if (impl->colormap)
gdk_colormap_ref (impl->colormap);
}
1999-11-17 00:45:37 +00:00
/* Drawing
*/
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
static int
rop2_to_rop3 (int rop2)
{
switch (rop2)
{
/* Oh, Microsoft's silly names for binary and ternary rops. */
#define CASE(rop2,rop3) case R2_##rop2: return rop3
CASE (BLACK, BLACKNESS);
CASE (NOTMERGEPEN, NOTSRCERASE);
CASE (MASKNOTPEN, 0x00220326);
CASE (NOTCOPYPEN, NOTSRCCOPY);
CASE (MASKPENNOT, SRCERASE);
CASE (NOT, DSTINVERT);
CASE (XORPEN, SRCINVERT);
CASE (NOTMASKPEN, 0x007700E6);
CASE (MASKPEN, SRCAND);
CASE (NOTXORPEN, 0x00990066);
CASE (NOP, 0x00AA0029);
CASE (MERGENOTPEN, MERGEPAINT);
CASE (COPYPEN, SRCCOPY);
CASE (MERGEPENNOT, 0x00DD0228);
CASE (MERGEPEN, SRCPAINT);
CASE (WHITE, WHITENESS);
#undef CASE
default: return SRCCOPY;
}
}
static int
rop2_to_patblt_rop (int rop2)
{
switch (rop2)
{
#define CASE(rop2,patblt_rop) case R2_##rop2: return patblt_rop
CASE (COPYPEN, PATCOPY);
CASE (XORPEN, PATINVERT);
CASE (NOT, DSTINVERT);
CASE (BLACK, BLACKNESS);
CASE (WHITE, WHITENESS);
#undef CASE
default:
g_warning ("Unhandled rop2 in GC to be used in PatBlt: %#x", rop2);
return PATCOPY;
}
}
static inline int
align_with_dash_offset (int a, DWORD *dashes, int num_dashes, GdkGCWin32 *gcwin32)
{
int n = 0;
int len_sum = 0;
/*
* We can't simply add the dashoffset, it can be an arbitrary larger
* or smaller value not even between x1 and x2. It just says use the
* dash pattern aligned to the offset. So ensure x1 is smaller _x1
* and we start with the appropriate dash.
*/
for (n = 0; n < num_dashes; n++)
len_sum += dashes[n];
if ( len_sum > 0 /* pathological api usage? */
&& gcwin32->pen_dash_offset > a)
a -= (((gcwin32->pen_dash_offset/len_sum - a/len_sum) + 1) * len_sum);
else
a = gcwin32->pen_dash_offset;
return a;
}
/* Render a dashed line 'by hand'. Used for all dashes on Win9x (where
* GDI is way too limited), and for double dashes on all Windowses.
*/
static inline gboolean
render_line_horizontal (GdkGCWin32 *gcwin32,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int x1,
int x2,
int y)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int n = 0;
const int pen_width = MAX (gcwin32->pen_width, 1);
const int _x1 = x1;
g_assert (gcwin32->pen_dashes);
x1 = align_with_dash_offset (x1, gcwin32->pen_dashes, gcwin32->pen_num_dashes, gcwin32);
for (n = 0; x1 < x2; n++)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int len = gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
if (x1 + len > x2)
len = x2 - x1;
if (n % 2 == 0 && x1 + len > _x1)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (!GDI_CALL (PatBlt, (gcwin32->hdc,
x1 < _x1 ? _x1 : x1,
y - pen_width / 2,
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
len, pen_width,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
rop2_to_patblt_rop (gcwin32->rop2))))
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
return FALSE;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
x1 += gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (gcwin32->line_style == GDK_LINE_DOUBLE_DASH)
{
HBRUSH hbr;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if ((hbr = SelectObject (gcwin32->hdc, gcwin32->pen_hbrbg)) == HGDI_ERROR)
return FALSE;
x1 = _x1;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
x1 += gcwin32->pen_dash_offset;
for (n = 0; x1 < x2; n++)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int len = gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
if (x1 + len > x2)
len = x2 - x1;
if (n % 2)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (!GDI_CALL (PatBlt, (gcwin32->hdc, x1, y - pen_width / 2,
len, pen_width,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
rop2_to_patblt_rop (gcwin32->rop2))))
return FALSE;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
x1 += gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (SelectObject (gcwin32->hdc, hbr) == HGDI_ERROR)
return FALSE;
}
return TRUE;
}
static inline gboolean
render_line_vertical (GdkGCWin32 *gcwin32,
2009-02-16 18:26:35 +00:00
int x,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int y1,
int y2)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int n;
const int pen_width = MAX (gcwin32->pen_width, 1);
const int _y1 = y1;
g_assert (gcwin32->pen_dashes);
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
y1 = align_with_dash_offset (y1, gcwin32->pen_dashes, gcwin32->pen_num_dashes, gcwin32);
for (n = 0; y1 < y2; n++)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int len = gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
if (y1 + len > y2)
len = y2 - y1;
if (n % 2 == 0 && y1 + len > _y1)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (!GDI_CALL (PatBlt, (gcwin32->hdc, x - pen_width / 2,
y1 < _y1 ? _y1 : y1,
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
pen_width, len,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
rop2_to_patblt_rop (gcwin32->rop2))))
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
return FALSE;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
y1 += gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (gcwin32->line_style == GDK_LINE_DOUBLE_DASH)
{
HBRUSH hbr;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if ((hbr = SelectObject (gcwin32->hdc, gcwin32->pen_hbrbg)) == HGDI_ERROR)
return FALSE;
y1 = _y1;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
y1 += gcwin32->pen_dash_offset;
for (n = 0; y1 < y2; n++)
{
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
int len = gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
if (y1 + len > y2)
len = y2 - y1;
if (n % 2)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (!GDI_CALL (PatBlt, (gcwin32->hdc, x - pen_width / 2, y1,
pen_width, len,
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
rop2_to_patblt_rop (gcwin32->rop2))))
return FALSE;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
y1 += gcwin32->pen_dashes[n % gcwin32->pen_num_dashes];
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (SelectObject (gcwin32->hdc, hbr) == HGDI_ERROR)
return FALSE;
}
return TRUE;
}
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
static void
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
draw_tiles_lowlevel (HDC dest,
2009-02-16 18:26:35 +00:00
HDC tile,
int rop3,
gint dest_x,
gint dest_y,
gint tile_x_origin,
gint tile_y_origin,
gint width,
gint height,
gint tile_width,
gint tile_height)
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
{
gint x, y;
GDK_NOTE (DRAW, g_print ("draw_tiles_lowlevel: %p %+d%+d tile=%p:%dx%d@%+d%+d %dx%d\n",
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
dest,
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
dest_x, dest_y,
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
tile, tile_width, tile_height,
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
tile_x_origin, tile_y_origin,
width, height));
y = tile_y_origin % tile_height;
if (y > 0)
y -= tile_height;
while (y < dest_y + height)
{
if (y + tile_height >= dest_y)
{
x = tile_x_origin % tile_width;
if (x > 0)
x -= tile_width;
while (x < dest_x + width)
{
if (x + tile_width >= dest_x)
{
gint src_x = MAX (0, dest_x - x);
gint src_y = MAX (0, dest_y - y);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
if (!GDI_CALL (BitBlt, (dest, x + src_x, y + src_y,
MIN (tile_width, dest_x + width - (x + src_x)),
MIN (tile_height, dest_y + height - (y + src_y)),
tile,
src_x, src_y,
rop3)))
return;
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
}
x += tile_width;
}
}
y += tile_height;
}
}
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
static void
draw_tiles (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
int rop3,
GdkPixmap *tile,
gint dest_x,
gint dest_y,
gint tile_x_origin,
gint tile_y_origin,
gint width,
gint height)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
const GdkGCValuesMask mask = GDK_GC_FOREGROUND;
gint tile_width, tile_height;
GdkGC *gc_copy;
HDC dest_hdc, tile_hdc;
gc_copy = gdk_gc_new (tile);
gdk_gc_copy (gc_copy, gc);
dest_hdc = gdk_win32_hdc_get (drawable, gc, mask);
tile_hdc = gdk_win32_hdc_get (tile, gc_copy, mask);
gdk_drawable_get_size (tile, &tile_width, &tile_height);
draw_tiles_lowlevel (dest_hdc, tile_hdc, rop3,
dest_x, dest_y, tile_x_origin, tile_y_origin,
width, height, tile_width, tile_height);
gdk_win32_hdc_release (drawable, gc, mask);
gdk_win32_hdc_release (tile, gc_copy, mask);
gdk_gc_unref (gc_copy);
}
static void
generic_draw (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkGCValuesMask mask,
void (*function) (GdkGCWin32 *, HDC, gint, gint, va_list),
const GdkRegion *region,
...)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
GdkGCWin32 *gcwin32 = GDK_GC_WIN32 (gc);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
HDC hdc;
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
va_list args;
GdkFill fill_style = _gdk_gc_get_fill (gc);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
va_start (args, region);
/* If tiled or stippled, draw to a temp pixmap and do blitting magic.
*/
if (gcwin32->values_mask & GDK_GC_FILL &&
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
((fill_style == GDK_TILED &&
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
gcwin32->values_mask & GDK_GC_TILE &&
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
_gdk_gc_get_tile (gc) != NULL)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
||
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
((fill_style == GDK_OPAQUE_STIPPLED ||
fill_style == GDK_STIPPLED) &&
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
gcwin32->values_mask & GDK_GC_STIPPLE &&
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
_gdk_gc_get_stipple (gc) != NULL)))
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
const GdkGCValuesMask blitting_mask = 0;
GdkGCValuesMask drawing_mask = GDK_GC_FOREGROUND;
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
gint ts_x_origin = 0, ts_y_origin = 0;
gint width = region->extents.x2 - region->extents.x1;
gint height = region->extents.y2 - region->extents.y1;
GdkPixmap *mask_pixmap =
gdk_pixmap_new (drawable, width, height, 1);
GdkPixmap *tile_pixmap =
gdk_pixmap_new (drawable, width, height, -1);
GdkPixmap *stipple_bitmap = NULL;
GdkColor fg;
GdkGC *mask_gc = gdk_gc_new (mask_pixmap);
GdkGC *tile_gc = gdk_gc_new (tile_pixmap);
HDC mask_hdc;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
HDC tile_hdc;
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
HGDIOBJ old_mask_hbm;
HGDIOBJ old_tile_hbm;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GdkGCValues gcvalues;
hdc = gdk_win32_hdc_get (drawable, gc, blitting_mask);
tile_hdc = CreateCompatibleDC (hdc);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
if (gcwin32->values_mask & GDK_GC_TS_X_ORIGIN)
ts_x_origin = gc->ts_x_origin;
if (gcwin32->values_mask & GDK_GC_TS_Y_ORIGIN)
ts_y_origin = gc->ts_y_origin;
ts_x_origin -= region->extents.x1;
ts_y_origin -= region->extents.y1;
/* Fill mask bitmap with zeros */
gdk_gc_set_function (mask_gc, GDK_CLEAR);
gdk_draw_rectangle (mask_pixmap, mask_gc, TRUE,
0, 0, width, height);
/* Paint into mask bitmap, drawing ones */
gdk_gc_set_function (mask_gc, GDK_COPY);
fg.pixel = 1;
gdk_gc_set_foreground (mask_gc, &fg);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
/* If the drawing function uses line attributes, set them as in
* the real GC.
*/
if (mask & LINE_ATTRIBUTES)
{
gdk_gc_get_values (gc, &gcvalues);
if (gcvalues.line_width != 0 ||
gcvalues.line_style != GDK_LINE_SOLID ||
gcvalues.cap_style != GDK_CAP_BUTT ||
gcvalues.join_style != GDK_JOIN_MITER)
gdk_gc_set_line_attributes (mask_gc,
gcvalues.line_width,
gcvalues.line_style,
gcvalues.cap_style,
gcvalues.join_style);
drawing_mask |= LINE_ATTRIBUTES;
}
/* Ditto, if the drawing function draws text, set up for that. */
if (mask & GDK_GC_FONT)
drawing_mask |= GDK_GC_FONT;
mask_hdc = gdk_win32_hdc_get (mask_pixmap, mask_gc, drawing_mask);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
(*function) (GDK_GC_WIN32 (mask_gc), mask_hdc,
region->extents.x1, region->extents.y1, args);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gdk_win32_hdc_release (mask_pixmap, mask_gc, drawing_mask);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
if (fill_style == GDK_TILED)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
/* Tile pixmap with tile */
draw_tiles (tile_pixmap, tile_gc, SRCCOPY,
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
_gdk_gc_get_tile (gc),
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
0, 0, ts_x_origin, ts_y_origin,
width, height);
}
else
{
/* Tile with stipple */
GdkGC *stipple_gc;
stipple_bitmap = gdk_pixmap_new (NULL, width, height, 1);
stipple_gc = gdk_gc_new (stipple_bitmap);
/* Tile stipple bitmap */
draw_tiles (stipple_bitmap, stipple_gc, SRCCOPY,
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
_gdk_gc_get_stipple (gc),
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
0, 0, ts_x_origin, ts_y_origin,
width, height);
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
if (fill_style == GDK_OPAQUE_STIPPLED)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
/* Fill tile pixmap with background */
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
fg.pixel = _gdk_gc_get_bg_pixel (gc);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
gdk_gc_set_foreground (tile_gc, &fg);
gdk_draw_rectangle (tile_pixmap, tile_gc, TRUE,
0, 0, width, height);
}
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
gdk_gc_unref (stipple_gc);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
}
gdk_gc_unref (mask_gc);
gdk_gc_unref (tile_gc);
mask_hdc = CreateCompatibleDC (hdc);
if ((old_mask_hbm = SelectObject (mask_hdc, GDK_PIXMAP_HBITMAP (mask_pixmap))) == NULL)
WIN32_GDI_FAILED ("SelectObject");
if ((old_tile_hbm = SelectObject (tile_hdc, GDK_PIXMAP_HBITMAP (tile_pixmap))) == NULL)
WIN32_GDI_FAILED ("SelectObject");
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
if (fill_style == GDK_STIPPLED ||
fill_style == GDK_OPAQUE_STIPPLED)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
HDC stipple_hdc;
HGDIOBJ old_stipple_hbm;
HBRUSH fg_brush;
HGDIOBJ old_tile_brush;
if ((stipple_hdc = CreateCompatibleDC (hdc)) == NULL)
WIN32_GDI_FAILED ("CreateCompatibleDC");
if ((old_stipple_hbm =
SelectObject (stipple_hdc,
GDK_PIXMAP_HBITMAP (stipple_bitmap))) == NULL)
WIN32_GDI_FAILED ("SelectObject");
if ((fg_brush = CreateSolidBrush
(_gdk_win32_colormap_color (impl->colormap,
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
_gdk_gc_get_fg_pixel (gc)))) == NULL)
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
WIN32_GDI_FAILED ("CreateSolidBrush");
if ((old_tile_brush = SelectObject (tile_hdc, fg_brush)) == NULL)
WIN32_GDI_FAILED ("SelectObject");
/* Paint tile with foreround where stipple is one
*
* Desired ternary ROP: (P=foreground, S=stipple, D=destination)
* P S D ?
* 0 0 0 0
* 0 0 1 1
* 0 1 0 0
* 0 1 1 0
* 1 0 0 0
* 1 0 1 1
* 1 1 0 1
* 1 1 1 1
*
* Reading bottom-up: 11100010 = 0xE2. PSDK docs say this is
* known as DSPDxax, with hex value 0x00E20746.
*/
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (BitBlt, (tile_hdc, 0, 0, width, height,
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
stipple_hdc, 0, 0, ROP3_DSPDxax));
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
if (fill_style == GDK_STIPPLED)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
/* Punch holes in mask where stipple is zero */
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (BitBlt, (mask_hdc, 0, 0, width, height,
stipple_hdc, 0, 0, SRCAND));
}
GDI_CALL (SelectObject, (tile_hdc, old_tile_brush));
GDI_CALL (DeleteObject, (fg_brush));
GDI_CALL (SelectObject, (stipple_hdc, old_stipple_hbm));
GDI_CALL (DeleteDC, (stipple_hdc));
g_object_unref (stipple_bitmap);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
}
/* Tile pixmap now contains the pattern that we should paint in
* the areas where mask is one. (It is filled with said pattern.)
*/
GDI_CALL (MaskBlt, (hdc, region->extents.x1, region->extents.y1,
width, height,
tile_hdc, 0, 0,
GDK_PIXMAP_HBITMAP (mask_pixmap), 0, 0,
MAKEROP4 (rop2_to_rop3 (gcwin32->rop2), ROP3_D)));
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
/* Cleanup */
GDI_CALL (SelectObject, (mask_hdc, old_mask_hbm));
GDI_CALL (SelectObject, (tile_hdc, old_tile_hbm));
GDI_CALL (DeleteDC, (mask_hdc));
GDI_CALL (DeleteDC, (tile_hdc));
g_object_unref (mask_pixmap);
g_object_unref (tile_pixmap);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gdk_win32_hdc_release (drawable, gc, blitting_mask);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
}
else
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
{
hdc = gdk_win32_hdc_get (drawable, gc, mask);
(*function) (gcwin32, hdc, 0, 0, args);
gdk_win32_hdc_release (drawable, gc, mask);
}
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
va_end (args);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
}
static GdkRegion *
widen_bounds (GdkRectangle *bounds,
2009-02-16 18:26:35 +00:00
gint pen_width)
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
{
if (pen_width == 0)
pen_width = 1;
bounds->x -= pen_width;
bounds->y -= pen_width;
bounds->width += 2 * pen_width;
bounds->height += 2 * pen_width;
return gdk_region_rectangle (bounds);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
}
static void
draw_rectangle (GdkGCWin32 *gcwin32,
2009-02-16 18:26:35 +00:00
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
HGDIOBJ old_pen_or_brush;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gboolean filled;
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
gint x;
gint y;
gint width;
gint height;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
filled = va_arg (args, gboolean);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
x = va_arg (args, gint);
y = va_arg (args, gint);
width = va_arg (args, gint);
height = va_arg (args, gint);
x -= x_offset;
y -= y_offset;
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (!filled && MUST_RENDER_DASHES_MANUALLY (gcwin32))
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
{
render_line_vertical (gcwin32, x, y, y+height+1) &&
render_line_horizontal (gcwin32, x, x+width+1, y) &&
render_line_vertical (gcwin32, x+width+1, y, y+height+1) &&
render_line_horizontal (gcwin32, x, x+width+1, y+height+1);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
}
else
{
if (filled)
old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
else
old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
if (old_pen_or_brush == NULL)
WIN32_GDI_FAILED ("SelectObject");
else
GDI_CALL (Rectangle, (hdc, x, y, x+width+1, y+height+1));
if (old_pen_or_brush != NULL)
GDI_CALL (SelectObject, (hdc, old_pen_or_brush));
}
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_rectangle (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height)
{
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GdkRectangle bounds;
GdkRegion *region;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_rectangle: %s (%p) %s%dx%d@%+d%+d\n",
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
_gdk_win32_drawable_description (drawable),
gc,
(filled ? "fill " : ""),
width, height, x, y));
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
bounds.x = x;
bounds.y = y;
bounds.width = width;
bounds.height = height;
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
generic_draw (drawable, gc,
GDK_GC_FOREGROUND | GDK_GC_BACKGROUND |
(filled ? 0 : LINE_ATTRIBUTES),
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
draw_rectangle, region, filled, x, y, width, height);
gdk_region_destroy (region);
}
1999-11-17 00:45:37 +00:00
static void
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_arc (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
HGDIOBJ old_pen;
gboolean filled;
gint x, y;
gint width, height;
gint angle1, angle2;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
filled = va_arg (args, gboolean);
x = va_arg (args, gint);
y = va_arg (args, gint);
width = va_arg (args, gint);
height = va_arg (args, gint);
angle1 = va_arg (args, gint);
angle2 = va_arg (args, gint);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
x -= x_offset;
y -= y_offset;
if (angle2 >= 360*64)
{
nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0;
}
else if (angle2 > 0)
{
nXStartArc = x + width/2 + width * cos(angle1/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -height * sin(angle1/64.*2.*G_PI/360.);
nXEndArc = x + width/2 + width * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -height * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
else
{
nXEndArc = x + width/2 + width * cos(angle1/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -height * sin(angle1/64.*2.*G_PI/360.);
nXStartArc = x + width/2 + width * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -height * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
if (filled)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
old_pen = SelectObject (hdc, GetStockObject (NULL_PEN));
GDK_NOTE (DRAW, g_print ("... Pie(%p,%d,%d,%d,%d,%d,%d,%d,%d)\n",
hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GDI_CALL (Pie, (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
GDI_CALL (SelectObject, (hdc, old_pen));
}
else
{
GDK_NOTE (DRAW, g_print ("... Arc(%p,%d,%d,%d,%d,%d,%d,%d,%d)\n",
hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GDI_CALL (Arc, (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc));
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
}
static void
gdk_win32_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkRectangle bounds;
GdkRegion *region;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_arc: %s %d,%d,%d,%d %d %d\n",
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
_gdk_win32_drawable_description (drawable),
x, y, width, height, angle1, angle2));
if (width <= 2 || height <= 2 || angle2 == 0)
return;
bounds.x = x;
bounds.y = y;
bounds.width = width;
bounds.height = height;
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
generic_draw (drawable, gc,
GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_arc, region, filled, x, y, width, height, angle1, angle2);
gdk_region_destroy (region);
}
static void
draw_polygon (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
gboolean filled;
POINT *pts;
HGDIOBJ old_pen_or_brush;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gint npoints;
gint i;
filled = va_arg (args, gboolean);
pts = va_arg (args, POINT *);
npoints = va_arg (args, gint);
if (x_offset != 0 || y_offset != 0)
for (i = 0; i < npoints; i++)
{
pts[i].x -= x_offset;
pts[i].y -= y_offset;
}
if (filled)
old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
else
old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
if (old_pen_or_brush == NULL)
WIN32_GDI_FAILED ("SelectObject");
GDI_CALL (Polygon, (hdc, pts, npoints));
if (old_pen_or_brush != NULL)
GDI_CALL (SelectObject, (hdc, old_pen_or_brush));
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gboolean filled,
1999-11-17 00:45:37 +00:00
GdkPoint *points,
gint npoints)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GdkRectangle bounds;
GdkRegion *region;
POINT *pts;
int i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_polygon: %s %d points\n",
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
_gdk_win32_drawable_description (drawable),
npoints));
if (npoints < 2)
return;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
bounds.x = G_MAXINT;
bounds.y = G_MAXINT;
bounds.width = 0;
bounds.height = 0;
pts = g_new (POINT, npoints);
for (i = 0; i < npoints; i++)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
bounds.x = MIN (bounds.x, points[i].x);
bounds.y = MIN (bounds.y, points[i].y);
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
for (i = 0; i < npoints; i++)
{
bounds.width = MAX (bounds.width, points[i].x - bounds.x);
bounds.height = MAX (bounds.height, points[i].y - bounds.y);
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
Merge from stable: 2002-12-09 Tor Lillqvist <tml@iki.fi> Merge from stable: * gdk/win32/gdkdrawable-win32.c (generic_draw): Don't leak stipple_gc. More checks for errors. Use correct ternary ROP when blitting the foreground into the tile pixmap onto those pixels where the stipple is set. (I didn't notice that I had used the wrong one, as it didn't matter on Win2k, where DIB sections apparently are zeroed upon creation. But on Win98 they have random initial contents. Thanks to Hans Breuer for reporting this.) (gdk_win32_draw_rectangle, gdk_win32_draw_arc, gdk_win32_draw_polygon): Don't pass the LINE_ATTRIBUTES bits to generic_draw() if drawing a filled figure. * gdk/win32/gdkmain-win32.c (_gdk_win32_print_dc): Minor cosmetics. (_gdk_win32_gcvalues_mask_to_string): Initialize buffer as empty. (_gdk_win32_window_state_to_string): New debugging output helper function. * gdk/win32/gdkevents-win32.c: Minor debugging output changes. (gdk_event_translate): Ignore the WM_SHOWWINDOW/SW_OTHERUNZOOM or SW_OTHERZOOM messages. Do not generate a GDK_UNMAP event for WM_SIZE/SIZE_MINIMIZED messages, they do not really corrspond to unmapping on X11. Set window state correctly for all three of SIZE_{MINIMIZED,MAXIMIZED,RESTORED}. A maximized and then iconified ("minimized" in Windows terminology) window still has the "maximized" property, i.e. when deiconified, it will reappear as maximized. (#10557) * gdk/win32/gdkprivate-win32.h: Declare new function. (WIN32_API_FAILED, WIN32_GDI_FAILED, OTHER_API_FAILED): Don't use __PRETTY_FUNCTION__ if __GNUC__ >= 3, to avoid warning message. * gdk/win32/gdkwindow-win32.c (show_window_internal): Handle more situations. Add parameter to tell whether deiconifying. Code reorg: Return early when appropriate instead of using nested if statements. If just deiconifying without raising, restore active window. (#10557) (gdk_window_hide, gdk_window_withdraw, gdk_window_iconify, gdk_window_deiconify, gdk_window_maximize, gdk_window_unmaximize, gdk_window_focus): Use _gdk_win32_window_state_to_string() in debugging output. (gdk_window_iconify): Restore active window after calling ShowWindow(). Otherwise the "next" window gets activated. (gdk_window_stick, gdk_window_unstick): Don't output any warnings. (gdk_window_set_transient_for): Rewrite. Just call SetWindowLong() with GWL_HWNDPARENT, which despite its name sets the *owner* window, which should be exactly what we want. The PSDK documentation is said to be misleading. testgtk's modal window test now works much better. (#50586)
2002-12-09 00:43:42 +00:00
generic_draw (drawable, gc,
GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_polygon, region, filled, pts, npoints);
gdk_region_destroy (region);
g_free (pts);
}
typedef struct
{
gint x, y;
HDC hdc;
} gdk_draw_text_arg;
static void
gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
const wchar_t *wcstr,
int wclen,
void *arg)
{
HGDIOBJ oldfont;
SIZE size;
gdk_draw_text_arg *argp = (gdk_draw_text_arg *) arg;
if (!singlefont)
return;
if ((oldfont = SelectObject (argp->hdc, singlefont->hfont)) == NULL)
{
WIN32_GDI_FAILED ("SelectObject");
return;
}
if (!TextOutW (argp->hdc, argp->x, argp->y, wcstr, wclen))
WIN32_GDI_FAILED ("TextOutW");
GetTextExtentPoint32W (argp->hdc, wcstr, wclen, &size);
argp->x += size.cx;
SelectObject (argp->hdc, oldfont);
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_FONT;
wchar_t *wcstr, wc;
gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text) 2004-07-07 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text) * gdk/win32/gdkfont-win32.c (gdk_text_extents) * gdk/win32/gdkproperty-win32.c (find_common_locale, gdk_property_change) * gdk/win32/gdkselection-win32.c (gdk_selection_convert): Use g_utf8_to_utf16() instead of the removed _gdk_utf8_to_ucs2() (see below). * gdk/win32/gdkglobals-win32.c * gdk/win32/gdkmain-win32.c (_gdk_windowing_init) * gdk/win3/gdkprivate-win32.h: Add a variable for the TARGETS atom. Initialize it. Declare it. Drop the variable for the COMPOUND_TEXT atom. * gdk/win32/gdkim-win32.c (gdk_wcstombs): Don't return UTF-8. This function is supposed to return the string in the locale's charset and encoding. Use g_convert(). (gdk_mbstowcs): Similarily, don't take an UTF-8 string, but a string in the locale's charset. Use g_convert(). (_gdk_ucs2_to_utf8, _gdk_utf8_to_wcs, _gdk_utf8_to_ucs2): Delete. The UCS-2 functions didn't handle surrogates anyway. Use GLib's UTF-16 functions instead. Windows uses UTF-16. * gdk/win32/gdkprivate-win32.h: Remove declarations of the deleted functions mentioned above. * gdk/win32/gdkproperty-win32.c (gdk_property_change): Use CF_TEXT also if the string is of type STRING, i.e. ISO-8859-1, and the current codepage is 1252, and contains no C1 chars. Accept also UTF8_STRING. * gdk/win32/gdkselection-win32.c (_gdk_selection_property_store): Mark as static. When storing STRING data, convert to Latin-1. (#140537) (gdk_selection_owner_set_for_display): Now that STRING is always ISO-8859-1, use UTF8_STRING when sending the selection request to ourselves. (gdk_selection_convert): Handle also UTF8_STRING. (#140537, John Ehresman) (gdk_text_property_to_text_list_for_display): Make work more like X11 version. Do obey the encoding parameter. (gdk_string_to_compound_text_for_display, gdk_utf8_to_compound_text_for_display): Don't even pretend supporting COMPOUND_TEXT. (gdk_utf8_to_string_target): Convert to ISO-8859-1, like on X11. (sanitize_utf8): Zero-terminate string.
2004-07-07 00:10:03 +00:00
glong wlen;
gdk_draw_text_arg arg;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
arg.x = x;
arg.y = y;
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_text: %s (%d,%d) \"%.*s\" (len %d)\n",
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
_gdk_win32_drawable_description (drawable),
x, y,
(text_length > 10 ? 10 : text_length),
text, text_length));
Large changes to the Win32 backend, partially made necessary by the 2000-05-02 Tor Lillqvist <tml@iki.fi> Large changes to the Win32 backend, partially made necessary by the changes to the backend-independent internal structures. Attempts to implement similar backing store stuff as on X11. The current (CVS) version of the Win32 backend is *not* as stable as it was before the no-flicker branch was merged. A zipfile with that version is available from http://www.gimp.org/win32/. That should be use by "production" code until this CVS version is usable. (But note, the Win32 backend has never been claimed to be "production quality".) * README.win32: Add the above comment about versions. * gdk/gdkwindow.c: Don't use backing store for now on Win32. * gdk/gdk.def: Update. * gdk/gdkfont.h: Declare temporary Win32-only functions. Will presumably be replaced by some more better mechanism as 1.4 gets closer to release shape. * gdk/makefile.{cygwin,msc}: Update. * gdk/win32/*.c: Correct inclusions of the backend-specific and internal headers. Change code according to changes in these. Use gdk_drawable_*, not gdk_window_* where necessary. * gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not our old DND. * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try to interpret single characters as UTF-8. Thanks to Hans Breuer. Use correct function name in warning messages. * gdk/win32/gdkevents-win32.c: Use correct parameter lists for the GSourceFuncs gdk_event_prepare and gdk_event_check. (gdk_event_get_graphics_expose): Do implement, use PeekMessage. Thanks to Hans Breuer. (event_mask_string): Debugging function to print an GdkEventMask. (gdk_pointer_grab): Use it. * gdk/win32/gdkfont-win32.c: The Unicode subrange that the (old) book I used claimed was Hangul actually is CJK Unified Ideographs Extension A. Also, Hangul Syllables were missing. Improve logging. * gdk/win32/gdkgc-win32.c: Largish changes. * gdk/win32/gdkim-win32.c (gdk_set_locale): Use g_win32_getlocale() from GLib, and not setlocale() to get current locale name. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to gdkwin32.h, similarily as in the X11 backend. * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix, assignment was used instead of equals in if test. Thanks to Hans Breuer. * gdk/win32/makefile.{cygwin,msc} * gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the path to the Win32 headers that works also with the mingw compiler. * gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
if (text_length == 1)
{
/* For single characters, don't try to interpret as UTF-8. */
wc = (guchar) text[0];
_gdk_wchar_text_handle (font, &wc, 1, gdk_draw_text_handler, &arg);
Large changes to the Win32 backend, partially made necessary by the 2000-05-02 Tor Lillqvist <tml@iki.fi> Large changes to the Win32 backend, partially made necessary by the changes to the backend-independent internal structures. Attempts to implement similar backing store stuff as on X11. The current (CVS) version of the Win32 backend is *not* as stable as it was before the no-flicker branch was merged. A zipfile with that version is available from http://www.gimp.org/win32/. That should be use by "production" code until this CVS version is usable. (But note, the Win32 backend has never been claimed to be "production quality".) * README.win32: Add the above comment about versions. * gdk/gdkwindow.c: Don't use backing store for now on Win32. * gdk/gdk.def: Update. * gdk/gdkfont.h: Declare temporary Win32-only functions. Will presumably be replaced by some more better mechanism as 1.4 gets closer to release shape. * gdk/makefile.{cygwin,msc}: Update. * gdk/win32/*.c: Correct inclusions of the backend-specific and internal headers. Change code according to changes in these. Use gdk_drawable_*, not gdk_window_* where necessary. * gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not our old DND. * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try to interpret single characters as UTF-8. Thanks to Hans Breuer. Use correct function name in warning messages. * gdk/win32/gdkevents-win32.c: Use correct parameter lists for the GSourceFuncs gdk_event_prepare and gdk_event_check. (gdk_event_get_graphics_expose): Do implement, use PeekMessage. Thanks to Hans Breuer. (event_mask_string): Debugging function to print an GdkEventMask. (gdk_pointer_grab): Use it. * gdk/win32/gdkfont-win32.c: The Unicode subrange that the (old) book I used claimed was Hangul actually is CJK Unified Ideographs Extension A. Also, Hangul Syllables were missing. Improve logging. * gdk/win32/gdkgc-win32.c: Largish changes. * gdk/win32/gdkim-win32.c (gdk_set_locale): Use g_win32_getlocale() from GLib, and not setlocale() to get current locale name. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to gdkwin32.h, similarily as in the X11 backend. * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix, assignment was used instead of equals in if test. Thanks to Hans Breuer. * gdk/win32/makefile.{cygwin,msc} * gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the path to the Win32 headers that works also with the mingw compiler. * gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
}
else
Large changes to the Win32 backend, partially made necessary by the 2000-05-02 Tor Lillqvist <tml@iki.fi> Large changes to the Win32 backend, partially made necessary by the changes to the backend-independent internal structures. Attempts to implement similar backing store stuff as on X11. The current (CVS) version of the Win32 backend is *not* as stable as it was before the no-flicker branch was merged. A zipfile with that version is available from http://www.gimp.org/win32/. That should be use by "production" code until this CVS version is usable. (But note, the Win32 backend has never been claimed to be "production quality".) * README.win32: Add the above comment about versions. * gdk/gdkwindow.c: Don't use backing store for now on Win32. * gdk/gdk.def: Update. * gdk/gdkfont.h: Declare temporary Win32-only functions. Will presumably be replaced by some more better mechanism as 1.4 gets closer to release shape. * gdk/makefile.{cygwin,msc}: Update. * gdk/win32/*.c: Correct inclusions of the backend-specific and internal headers. Change code according to changes in these. Use gdk_drawable_*, not gdk_window_* where necessary. * gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not our old DND. * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try to interpret single characters as UTF-8. Thanks to Hans Breuer. Use correct function name in warning messages. * gdk/win32/gdkevents-win32.c: Use correct parameter lists for the GSourceFuncs gdk_event_prepare and gdk_event_check. (gdk_event_get_graphics_expose): Do implement, use PeekMessage. Thanks to Hans Breuer. (event_mask_string): Debugging function to print an GdkEventMask. (gdk_pointer_grab): Use it. * gdk/win32/gdkfont-win32.c: The Unicode subrange that the (old) book I used claimed was Hangul actually is CJK Unified Ideographs Extension A. Also, Hangul Syllables were missing. Improve logging. * gdk/win32/gdkgc-win32.c: Largish changes. * gdk/win32/gdkim-win32.c (gdk_set_locale): Use g_win32_getlocale() from GLib, and not setlocale() to get current locale name. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to gdkwin32.h, similarily as in the X11 backend. * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix, assignment was used instead of equals in if test. Thanks to Hans Breuer. * gdk/win32/makefile.{cygwin,msc} * gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the path to the Win32 headers that works also with the mingw compiler. * gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
{
gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text) 2004-07-07 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text) * gdk/win32/gdkfont-win32.c (gdk_text_extents) * gdk/win32/gdkproperty-win32.c (find_common_locale, gdk_property_change) * gdk/win32/gdkselection-win32.c (gdk_selection_convert): Use g_utf8_to_utf16() instead of the removed _gdk_utf8_to_ucs2() (see below). * gdk/win32/gdkglobals-win32.c * gdk/win32/gdkmain-win32.c (_gdk_windowing_init) * gdk/win3/gdkprivate-win32.h: Add a variable for the TARGETS atom. Initialize it. Declare it. Drop the variable for the COMPOUND_TEXT atom. * gdk/win32/gdkim-win32.c (gdk_wcstombs): Don't return UTF-8. This function is supposed to return the string in the locale's charset and encoding. Use g_convert(). (gdk_mbstowcs): Similarily, don't take an UTF-8 string, but a string in the locale's charset. Use g_convert(). (_gdk_ucs2_to_utf8, _gdk_utf8_to_wcs, _gdk_utf8_to_ucs2): Delete. The UCS-2 functions didn't handle surrogates anyway. Use GLib's UTF-16 functions instead. Windows uses UTF-16. * gdk/win32/gdkprivate-win32.h: Remove declarations of the deleted functions mentioned above. * gdk/win32/gdkproperty-win32.c (gdk_property_change): Use CF_TEXT also if the string is of type STRING, i.e. ISO-8859-1, and the current codepage is 1252, and contains no C1 chars. Accept also UTF8_STRING. * gdk/win32/gdkselection-win32.c (_gdk_selection_property_store): Mark as static. When storing STRING data, convert to Latin-1. (#140537) (gdk_selection_owner_set_for_display): Now that STRING is always ISO-8859-1, use UTF8_STRING when sending the selection request to ourselves. (gdk_selection_convert): Handle also UTF8_STRING. (#140537, John Ehresman) (gdk_text_property_to_text_list_for_display): Make work more like X11 version. Do obey the encoding parameter. (gdk_string_to_compound_text_for_display, gdk_utf8_to_compound_text_for_display): Don't even pretend supporting COMPOUND_TEXT. (gdk_utf8_to_string_target): Convert to ISO-8859-1, like on X11. (sanitize_utf8): Zero-terminate string.
2004-07-07 00:10:03 +00:00
wcstr = g_utf8_to_utf16 (text, text_length, NULL, &wlen, NULL);
_gdk_wchar_text_handle (font, wcstr, wlen, gdk_draw_text_handler, &arg);
g_free (wcstr);
Large changes to the Win32 backend, partially made necessary by the 2000-05-02 Tor Lillqvist <tml@iki.fi> Large changes to the Win32 backend, partially made necessary by the changes to the backend-independent internal structures. Attempts to implement similar backing store stuff as on X11. The current (CVS) version of the Win32 backend is *not* as stable as it was before the no-flicker branch was merged. A zipfile with that version is available from http://www.gimp.org/win32/. That should be use by "production" code until this CVS version is usable. (But note, the Win32 backend has never been claimed to be "production quality".) * README.win32: Add the above comment about versions. * gdk/gdkwindow.c: Don't use backing store for now on Win32. * gdk/gdk.def: Update. * gdk/gdkfont.h: Declare temporary Win32-only functions. Will presumably be replaced by some more better mechanism as 1.4 gets closer to release shape. * gdk/makefile.{cygwin,msc}: Update. * gdk/win32/*.c: Correct inclusions of the backend-specific and internal headers. Change code according to changes in these. Use gdk_drawable_*, not gdk_window_* where necessary. * gdk/win32/gdkdnd-win32.c: Use MISC selector for GDK_NOTE, not our old DND. * gdk/win32/gdkdrawable-win32.c (gdk_win32_draw_text): Don't try to interpret single characters as UTF-8. Thanks to Hans Breuer. Use correct function name in warning messages. * gdk/win32/gdkevents-win32.c: Use correct parameter lists for the GSourceFuncs gdk_event_prepare and gdk_event_check. (gdk_event_get_graphics_expose): Do implement, use PeekMessage. Thanks to Hans Breuer. (event_mask_string): Debugging function to print an GdkEventMask. (gdk_pointer_grab): Use it. * gdk/win32/gdkfont-win32.c: The Unicode subrange that the (old) book I used claimed was Hangul actually is CJK Unified Ideographs Extension A. Also, Hangul Syllables were missing. Improve logging. * gdk/win32/gdkgc-win32.c: Largish changes. * gdk/win32/gdkim-win32.c (gdk_set_locale): Use g_win32_getlocale() from GLib, and not setlocale() to get current locale name. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkwin32.h: Move stuff from gdkprivate-win32.h to gdkwin32.h, similarily as in the X11 backend. * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Bugfix, assignment was used instead of equals in if test. Thanks to Hans Breuer. * gdk/win32/makefile.{cygwin,msc} * gtk/makefile.{cygwin,msc}: Updates. Better kludge to get the path to the Win32 headers that works also with the mingw compiler. * gtk/gtkstyle.c: Include <string.h>.
2000-05-01 22:06:49 +00:00
}
gdk_win32_hdc_release (drawable, gc, mask);
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
const GdkGCValuesMask mask = GDK_GC_FOREGROUND|GDK_GC_FONT;
gint i;
wchar_t *wcstr;
gdk_draw_text_arg arg;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
arg.x = x;
arg.y = y;
arg.hdc = gdk_win32_hdc_get (drawable, gc, mask);
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_text_wc: %s (%d,%d) len: %d\n",
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
_gdk_win32_drawable_description (drawable),
x, y, text_length));
if (sizeof (wchar_t) != sizeof (GdkWChar))
{
wcstr = g_new (wchar_t, text_length);
for (i = 0; i < text_length; i++)
wcstr[i] = text[i];
}
else
wcstr = (wchar_t *) text;
_gdk_wchar_text_handle (font, wcstr, text_length,
gdk_draw_text_handler, &arg);
if (sizeof (wchar_t) != sizeof (GdkWChar))
g_free (wcstr);
gdk_win32_hdc_release (drawable, gc, mask);
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_drawable (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
GdkGC *gc,
GdkPixmap *src,
GdkDrawable *original_src,
2009-02-16 18:26:35 +00:00
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
_gdk_win32_blit (FALSE, (GdkDrawableImplWin32 *) drawable,
2009-02-16 18:26:35 +00:00
gc, src, xsrc, ysrc,
xdest, ydest, width, height);
}
1999-11-17 00:45:37 +00:00
static void
gdk_win32_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
HDC hdc;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
HGDIOBJ old_pen;
int i;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
hdc = gdk_win32_hdc_get (drawable, gc, GDK_GC_FOREGROUND);
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_points: %s %d points\n",
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
_gdk_win32_drawable_description (drawable),
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
npoints));
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
/* The X11 version uses XDrawPoint(), which doesn't use the fill
* mode, so don't use generic_draw. But we should use the current
* function, so we can't use SetPixel(). Draw single-pixel
* rectangles (sigh).
*/
old_pen = SelectObject (hdc, GetStockObject (NULL_PEN));
for (i = 0; i < npoints; i++)
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
Rectangle (hdc, points[i].x, points[i].y,
points[i].x + 2, points[i].y + 2);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
SelectObject (hdc, old_pen);
gdk_win32_hdc_release (drawable, gc, GDK_GC_FOREGROUND);
}
1999-11-17 00:45:37 +00:00
static void
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_segments (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GdkSegment *segs;
gint nsegs;
gint i;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
segs = va_arg (args, GdkSegment *);
nsegs = va_arg (args, gint);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
if (x_offset != 0 || y_offset != 0)
{
/* must not modify in place, but could splice in the offset all below */
segs = g_memdup (segs, nsegs * sizeof (GdkSegment));
for (i = 0; i < nsegs; i++)
{
segs[i].x1 -= x_offset;
segs[i].y1 -= y_offset;
segs[i].x2 -= x_offset;
segs[i].y2 -= y_offset;
}
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (MUST_RENDER_DASHES_MANUALLY (gcwin32))
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
for (i = 0; i < nsegs; i++)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
if (segs[i].x1 == segs[i].x2)
{
int y1, y2;
if (segs[i].y1 <= segs[i].y2)
y1 = segs[i].y1, y2 = segs[i].y2;
else
y1 = segs[i].y2, y2 = segs[i].y1;
render_line_vertical (gcwin32, segs[i].x1, y1, y2);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
}
else if (segs[i].y1 == segs[i].y2)
{
int x1, x2;
if (segs[i].x1 <= segs[i].x2)
x1 = segs[i].x1, x2 = segs[i].x2;
else
x1 = segs[i].x2, x2 = segs[i].x1;
render_line_horizontal (gcwin32, x1, x2, segs[i].y1);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
}
else
GDI_CALL (MoveToEx, (hdc, segs[i].x1, segs[i].y1, NULL)) &&
GDI_CALL (LineTo, (hdc, segs[i].x2, segs[i].y2));
}
}
else
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
for (i = 0; i < nsegs; i++)
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
{
const GdkSegment *ps = &segs[i];
const int x1 = ps->x1, y1 = ps->y1;
int x2 = ps->x2, y2 = ps->y2;
GDK_NOTE (DRAW, g_print (" +%d+%d..+%d+%d", x1, y1, x2, y2));
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
GDI_CALL (MoveToEx, (hdc, x1, y1, NULL)) &&
GDI_CALL (LineTo, (hdc, x2, y2));
}
GDK_NOTE (DRAW, g_print ("\n"));
}
if (x_offset != 0 || y_offset != 0)
g_free (segs);
}
1999-11-17 00:45:37 +00:00
static void
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gdk_win32_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GdkRectangle bounds;
GdkRegion *region;
gint i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_segments: %s %d segs\n",
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
_gdk_win32_drawable_description (drawable),
nsegs));
bounds.x = G_MAXINT;
bounds.y = G_MAXINT;
bounds.width = 0;
bounds.height = 0;
for (i = 0; i < nsegs; i++)
{
bounds.x = MIN (bounds.x, segs[i].x1);
bounds.x = MIN (bounds.x, segs[i].x2);
bounds.y = MIN (bounds.y, segs[i].y1);
bounds.y = MIN (bounds.y, segs[i].y2);
}
for (i = 0; i < nsegs; i++)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
bounds.width = MAX (bounds.width, segs[i].x1 - bounds.x);
bounds.width = MAX (bounds.width, segs[i].x2 - bounds.x);
bounds.height = MAX (bounds.height, segs[i].y1 - bounds.y);
bounds.height = MAX (bounds.height, segs[i].y2 - bounds.y);
}
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
generic_draw (drawable, gc, GDK_GC_FOREGROUND | LINE_ATTRIBUTES,
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_segments, region, segs, nsegs);
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
gdk_region_destroy (region);
}
static void
draw_lines (GdkGCWin32 *gcwin32,
HDC hdc,
gint x_offset,
gint y_offset,
va_list args)
{
POINT *pts;
gint npoints;
gint i;
pts = va_arg (args, POINT *);
npoints = va_arg (args, gint);
if (x_offset != 0 || y_offset != 0)
for (i = 0; i < npoints; i++)
{
pts[i].x -= x_offset;
pts[i].y -= y_offset;
}
Improve and simplify line segment rendering on Win32, especially the 2005-06-23 Tor Lillqvist <tml@novell.com> Improve and simplify line segment rendering on Win32, especially the implementation of GDK_CAP_NOT_LAST, and dashed lines. Fixes bug #306396. * gdk/win32/gdkprivate-win32.h (GdkGCWin32): Save the GdkGC's line_style, cap_style and join_style as such in the GdkGCWin32. Don't need to keep the pen_double_dash flag, we can check the line_style. * gdk/win32/gdkgc-win32.c (fixup_pen): New internal function. Sets up the GDI pen type, style, end cap and join attributes to use based on the pen width, GDK line style, end cap style, and join style. For a narrow (zero-width) GDK pen with the GDK_CAP_NOT_LAST end cap style, which typically are used for XOR drawing where it is essential that the last pixel is not drawn, use a GDI cosmetic pen. Only for a cosmetic pen does GDI not draw the last pixel. I deduced this by experimetation, the documentation is rather vague. For other GDK pens use a geometric GDI pen. If the width is 0 or 1 and the GDK end cap style is GDK_CAP_BUTT, and the line style is GDK_LINE_SOLID, use PS_ENDCAP_ROUND. This ensures that also single-pixel length lines are drawn. (For sngle-pixel width lines roundness as such is of course irrelevant.) For dashed lines, use PS_ENDCAP_FLAT. For wide lines use PS_ENDCAP_FLAT, _ROUND or _SQUARE, respectively, for GDK_CAP_BUTT, GDK_CAP_ROUND and GDK_CAP_PROJECTING. For one pixel on-off dashed lines, use PS_ALTERNATE, it seems to work better than PS_USERSTYLE. For other dashed lines, use PS_USERSTYLE and the dashes as set by the user (or the default four-pixel on-off style). (gdk_win32_gc_values_to_win32values, gdk_win32_gc_set_dashes): Call fixup_pen() to do the pen settings after modifying some of the GDK GC attributes that affect pens. * gdk/win32/gdkdrawable-win32.c (render_line_horizontal, render_line_vertical, draw_segments): Check GdkGCWin32::line_style instead of the the removed pen_double_dash member. Don't use PATCOPY unconditionally in the PatBlt() call, use a raster ope code that depends on the GC function in use. (draw_rectangle, draw_segments, draw_lines): Be more careful in deciding when to do the manual dash rendering. (draw_segments): Don't do any manual "last point" drawing at all. The above changes takes care of narrow line segments being drawn correctly in most cases, at least on NT-based Windows.
2005-06-24 13:00:05 +00:00
if (MUST_RENDER_DASHES_MANUALLY (gcwin32))
{
for (i = 0; i < npoints - 1; i++)
{
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
if (pts[i].x == pts[i+1].x)
{
int y1, y2;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
if (pts[i].y > pts[i+1].y)
y1 = pts[i+1].y, y2 = pts[i].y;
else
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
y1 = pts[i].y, y2 = pts[i+1].y;
render_line_vertical (gcwin32, pts[i].x, y1, y2);
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
else if (pts[i].y == pts[i+1].y)
{
int x1, x2;
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
if (pts[i].x > pts[i+1].x)
x1 = pts[i+1].x, x2 = pts[i].x;
else
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
x1 = pts[i].x, x2 = pts[i+1].x;
render_line_horizontal (gcwin32, x1, x2, pts[i].y);
}
else
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GDI_CALL (MoveToEx, (hdc, pts[i].x, pts[i].y, NULL)) &&
GDI_CALL (LineTo, (hdc, pts[i+1].x, pts[i+1].y));
}
}
else
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
GDI_CALL (Polyline, (hdc, pts, npoints));
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
static void
gdk_win32_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkRectangle bounds;
GdkRegion *region;
POINT *pts;
int i;
GDK_NOTE (DRAW, g_print ("gdk_win32_draw_lines: %s %d points\n",
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
_gdk_win32_drawable_description (drawable),
npoints));
if (npoints < 2)
return;
bounds.x = G_MAXINT;
bounds.y = G_MAXINT;
bounds.width = 0;
bounds.height = 0;
pts = g_new (POINT, npoints);
for (i = 0; i < npoints; i++)
{
bounds.x = MIN (bounds.x, points[i].x);
bounds.y = MIN (bounds.y, points[i].y);
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
for (i = 0; i < npoints; i++)
{
bounds.width = MAX (bounds.width, points[i].x - bounds.x);
bounds.height = MAX (bounds.height, points[i].y - bounds.y);
}
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
generic_draw (drawable, gc, GDK_GC_FOREGROUND | GDK_GC_BACKGROUND |
LINE_ATTRIBUTES,
Merge from stable: 2002-11-24 Tor Lillqvist <tml@iki.fi> Merge from stable: Implement tiles and stipples for all drawing methids (except the deprecated draw_text() and draw_text_wc()). * gdk/win32/gdkdrawable-win32.c: Remove the already ifdeffed-out code that didn't use generic_draw(). (generic_draw): When drawing into the mask (for tiled/stippled fill styles), copy the line attributes from the actual GC. Also ask for text drawing setup if needed. Use differently set up HDCs in the normal and tiled/stippled cases. (draw_lines, gdk_win32_draw_lines, draw_polygon, gdk_win32_draw_polygon, draw_segments, gdk_win32_draw_segments, draw_arc, gdk_win32_draw_arc): Use generic_draw(), thus implementing tiled and stippled fill styles for lines, polygons, segments, and args. (gdk_win32_draw_points): Use Rectangle() instead of SetPixel(). Rectangle() uses the function (raster op) set for the HDC, SetPixel() doesn't. (widen_bounds): New function, refactoring. * gdk/win32/gdkgc-win32.c: Remove ifdeffed-out code. (predraw_set_foreground, gdk_win32_hdc_get): Some code moved around. Call SetROP2() only if necessary. Call SetTextColor() only if GDK_GC_FOREGROUND flag present. Don't handle GDK_OPAQUE_STIPPLED here, has been superseded by the code in generic_draw(). Always create a solid brush. Remove background color handling from here. The background color of a GdkGC is supposed to affect only GDK_OPAQUE_STIPPLED fill style, which it is already handled in generic_draw(), and GDK_LINE_DOUBLE_DASH lines, which aren't implemented properly anyway. Calling SetBkColor() is unnecessary as we always use TRANSPARENT text output. (gdk_win32_hdc_get, gdk_win32_hdc_release): Add doc comments, as these are public functions. * gdk/win32/gdkevents-win32.c (synthesize_expose_events): Don't synthesize expose events for GDK_INPUT_ONLY windows. (gdk_event_translate): On WM_SIZE, call gdk_synthesize_window_state() if window was iconified, restored or maximized. (#98983, Arnaud Charlet) * gtk+/gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents): Fix typo in setting y. (#98983, Arnaud Charlet)
2002-11-24 23:54:01 +00:00
draw_lines, region, pts, npoints);
gdk_region_destroy (region);
g_free (pts);
}
static void
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
blit_from_pixmap (gboolean use_fg_bg,
GdkDrawableImplWin32 *dest,
HDC hdc,
GdkPixmapImplWin32 *src,
GdkGC *gc,
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkGCWin32 *gcwin32 = GDK_GC_WIN32 (gc);
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
HDC srcdc;
HBITMAP holdbitmap;
RGBQUAD oldtable[256], newtable[256];
COLORREF bg, fg;
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
gint newtable_size = 0, oldtable_size = 0;
gboolean ok = TRUE;
GDK_NOTE (DRAW, g_print ("blit_from_pixmap\n"));
srcdc = _gdk_win32_drawable_acquire_dc (GDK_DRAWABLE (src));
if (!srcdc)
return;
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (!(holdbitmap = SelectObject (srcdc, ((GdkDrawableImplWin32 *) src)->handle)))
WIN32_GDI_FAILED ("SelectObject");
else
{
if (GDK_PIXMAP_OBJECT (src->parent_instance.wrapper)->depth <= 8)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
/* Blitting from a 1, 4 or 8-bit pixmap */
if ((oldtable_size = GetDIBColorTable (srcdc, 0, 256, oldtable)) == 0)
WIN32_GDI_FAILED ("GetDIBColorTable");
else if (GDK_PIXMAP_OBJECT (src->parent_instance.wrapper)->depth == 1)
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
{
/* Blitting from an 1-bit pixmap */
gint bgix, fgix;
if (use_fg_bg)
{
Add a draw-border style property to allow themes to draw outside the 2005-04-28 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c: Add a draw-border style property to allow themes to draw outside the widget's allocation. * gdk/gdkwindow.c gtk/gtkstyle.c: Remove some save/restore pairs that were working around the clip-leakage bug in Cairo. * gtk/gtkstyle.c: Use cairo_fill_preserve() rathe than save/fill/restore. * gdk/gdkgc.c gdk/gdkinternals.h: Add _gdk_gc_update_context() That updates a Cairo context to match a GC. * gdk/gdkdraw.c: Use _gdk_gc_update_context() to add support for tiles/stipples/clipping to gdk_draw_glyphs(), gdk_draw_trapezoids(). * gdk/gdkpango.c: Use _gdk_gc_update_context() instead of internal implementation of stipples. Use one cairo_t across the entire drawing operation. Replace cairo_matrix_create() with stack-allocated matrices. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c: Save various aspects of the GC state (fill, tile, stipple, foreground, background, clip region) in instance-private-data for future use. Add getters. Get rid of _gdk_windowing_gc_get_foreground() function implemented by the backends. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Add _gdk_gc_init() to do initial setup of the GC from values; fixes some problems from drawable redirection. * gdk/gdkgc.c gdk/gdkinternals.h gdk/x11/gdkgc-x11.c gdk/win32/gdkgc-win32.c gdk/linux-fb/gdkgc-fb.c: Move gdk_gc_copy() and gdk_gc_set_clip_{region,rectangle}() into the generic code, add _gdk_windowing_gc_copy(), _gdk_windowing_gc_set_clip_region() to do backend specific stuff. * gdk/x11/{gdkprivate-x11.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/win32/{gdkprivate-win32.h,gdkgc-x11.c.c,gdkdrawable-x11.c} gdk/linux-fb/{gdkprivate-fb.h,gdkgc-fb.c.c,gdkdrawable-fb.c}: Don't duplicate state that now is stored by the generic code. * gdk/gdk.symbols Update
2005-05-02 23:29:24 +00:00
bgix = _gdk_gc_get_bg_pixel (gc);
fgix = _gdk_gc_get_fg_pixel (gc);
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
else
{
bgix = 0;
fgix = 1;
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (GDK_IS_PIXMAP_IMPL_WIN32 (dest) &&
GDK_PIXMAP_OBJECT (dest->wrapper)->depth <= 8)
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
{
/* Destination is also pixmap, get fg and bg from
* its palette. Either use the foreground and
* background pixel values in the GC (only in the
* case of gdk_image_put(), cf. XPutImage()), or 0
* and 1 to index the palette.
*/
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
if (!GDI_CALL (GetDIBColorTable, (hdc, bgix, 1, newtable)) ||
!GDI_CALL (GetDIBColorTable, (hdc, fgix, 1, newtable+1)))
ok = FALSE;
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
else
{
/* Destination is a window, get fg and bg from its
* colormap
*/
bg = _gdk_win32_colormap_color (dest->colormap, bgix);
fg = _gdk_win32_colormap_color (dest->colormap, fgix);
newtable[0].rgbBlue = GetBValue (bg);
newtable[0].rgbGreen = GetGValue (bg);
newtable[0].rgbRed = GetRValue (bg);
newtable[0].rgbReserved = 0;
newtable[1].rgbBlue = GetBValue (fg);
newtable[1].rgbGreen = GetGValue (fg);
newtable[1].rgbRed = GetRValue (fg);
newtable[1].rgbReserved = 0;
}
if (ok)
GDK_NOTE (DRAW, g_print ("bg: %02x %02x %02x "
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
"fg: %02x %02x %02x\n",
newtable[0].rgbRed,
newtable[0].rgbGreen,
newtable[0].rgbBlue,
newtable[1].rgbRed,
newtable[1].rgbGreen,
newtable[1].rgbBlue));
newtable_size = 2;
}
else if (GDK_IS_PIXMAP_IMPL_WIN32 (dest))
{
/* Destination is pixmap, get its color table */
if ((newtable_size = GetDIBColorTable (hdc, 0, 256, newtable)) == 0)
WIN32_GDI_FAILED ("GetDIBColorTable"), ok = FALSE;
}
/* If blitting between pixmaps, set source's color table */
if (ok && newtable_size > 0)
{
GDK_NOTE (MISC_OR_COLORMAP,
g_print ("blit_from_pixmap: set color table"
" hdc=%p count=%d\n",
srcdc, newtable_size));
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
if (!GDI_CALL (SetDIBColorTable, (srcdc, 0, newtable_size, newtable)))
ok = FALSE;
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
if (ok)
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)) &&
GetLastError () != ERROR_INVALID_HANDLE)
WIN32_GDI_FAILED ("BitBlt");
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
/* Restore source's color table if necessary */
if (ok && newtable_size > 0 && oldtable_size > 0)
{
GDK_NOTE (MISC_OR_COLORMAP,
g_print ("blit_from_pixmap: reset color table"
" hdc=%p count=%d\n",
srcdc, oldtable_size));
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (SetDIBColorTable, (srcdc, 0, oldtable_size, oldtable));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (SelectObject, (srcdc, holdbitmap));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
_gdk_win32_drawable_release_dc (GDK_DRAWABLE (src));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
static void
blit_inside_drawable (HDC hdc,
GdkGCWin32 *gcwin32,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
{
GDK_NOTE (DRAW, g_print ("blit_inside_drawable\n"));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
hdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
static void
blit_from_window (HDC hdc,
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GdkGCWin32 *gcwin32,
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
GdkDrawableImplWin32 *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
HDC srcdc;
HPALETTE holdpal = NULL;
GdkColormap *cmap = gdk_colormap_get_system ();
GDK_NOTE (DRAW, g_print ("blit_from_window\n"));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if ((srcdc = GetDC (src->handle)) == NULL)
{
WIN32_GDI_FAILED ("GetDC");
return;
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR ||
cmap->visual->type == GDK_VISUAL_STATIC_COLOR)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
gint k;
if (!(holdpal = SelectPalette (srcdc, GDK_WIN32_COLORMAP_DATA (cmap)->hpal, FALSE)))
WIN32_GDI_FAILED ("SelectPalette");
else if ((k = RealizePalette (srcdc)) == GDI_ERROR)
WIN32_GDI_FAILED ("RealizePalette");
else if (k > 0)
GDK_NOTE (MISC_OR_COLORMAP,
g_print ("blit_from_window: realized %d\n", k));
}
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (BitBlt, (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, rop2_to_rop3 (gcwin32->rop2)));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (holdpal != NULL)
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (SelectPalette, (srcdc, holdpal, FALSE));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (ReleaseDC, (src->handle, srcdc));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
void
_gdk_win32_blit (gboolean use_fg_bg,
GdkDrawableImplWin32 *draw_impl,
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
GdkGC *gc,
GdkDrawable *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
HDC hdc;
HRGN src_rgn, draw_rgn, outside_rgn;
RECT r;
GdkDrawableImplWin32 *src_impl = NULL;
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
gint src_width, src_height;
GDK_NOTE (DRAW, g_print ("_gdk_win32_blit: src:%s %dx%d@%+d%+d\n"
" dst:%s @%+d%+d use_fg_bg=%d\n",
gdk/win32/gdkprivate-win32.h Rename all global variables and functions to 2002-11-12 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkprivate-win32.h * gdk/win32/*.c: Rename all global variables and functions to start with underscore. Merge from stable: More work on the Win32 backend. The cause of some scrolling problems was that SetWindowPos() and ScrollWindowEx() don't blit those parts of the window they think are invalid. As we didn't keep Windows's update region in synch with GDK's, Windows thought those areas that in fact had been updated were invalid. Calling ValidateRgn() in _gdk_windowing_window_queue_antiexpose() seems to be an elegant and efficient solution, removing from Windows's update region those areas we are about to repaint proactively. In some cases garbage leftover values were used for the clip origin in GdkGCWin32. This showed up as odd blank areas around the pixmaps included in the Text Widget in gtk-demo. Having the clip region either as a GdkRegion or a HRGN in GdkGCWin32 was unnecessary, it's better to just use a HRGN. The translation and antiexpose queue handling in gdkgeometry-win32.c seems unnecessary (and not implementable in the same way as on X11 anyway, no serial numbers) on Windows, ifdeffed out. Don't (try to) do guffaw scrolling as there is no static window gravity on Windows. Guffaw scrolling would be unnecessary anyway, as there is the ScrollWindow() API. This improves the behaviour of the Text Widget demo in gtk-demo a lot. But I have no idea how the lack of static win gravity should be handled in other places where the X11 code uses it. Especially _gdk_window_move_resize_child(). There is still some problem in expose handling. By moving an obscuring window back and forth over testgtk's main window, for instance, every now and then you typically get narrow vertical or horizontal strips of pixels that haven't been properly redrawn after being exposed. A fencepost error somewhere? Otherwise, all of testgtk and gtk-demo except "big windows" now seem to work pretty well. Bug #79720 should be fixed now. * gdk/win32/gdkcolor-win32.c (gdk_win32_color_to_string, gdk_win32_print_paletteentries, gdk_win32_print_system_palette, gdk_win32_print_hpalette) * gdk/win32/gdkdrawable-win32.c (gdk_win32_drawable_description) * gdk/win32/gdkevents-win32.c (gdk_win32_message_name): Move all debugging helper functions to gdkmain-win32.c. * gdk/win32/gdkdrawable-win32.c (_gdk_win32_draw_tiles): Rewrite. Make static. Must take tile origin parameters, too. (gdk_win32_draw_rectangle): Pass the tile/stipple origin to _gdk_win32_draw_tiles(). Remove #if 0 code. (blit_inside_window): Don't call ScrollDC(), that didn't work at all like I thought. A simple call to BitBlt() is enough. * gdk/win32/gdkevents-win32.c (gdk_event_translate) Remove unused latin_locale_loaded variable. (_gdk_win32_get_next_tick): New function. Used to make sure timestamps of events are always increasing, both in events generated from the window procedure and in events gotten via PeekMessage(). Not sure whether this is actually useful, but it seemed as a good idea. (real_window_procedure): Don't use a local GdkEventPrivate variable. Don't attempt any compression of configure or expose events here, handled elsewhere. (erase_background): Accumulate window offsets when traversing up the parent chain for GDK_PARENT_RELATIVE_BG, in order to get correct alignment of background pixmaps. Don't fill with BLACK_BRUSH if GDK_NO_BG. (gdk_event_get_graphics_expose): A bit more verbose debugging output. (gdk_event_translate): Use _gdk_win32_get_next_tick(). In the WM_PAINT handler, don't check for empty update rect. When we get a WM_PAINT, the update region isn't empty. And if it for some strange reason is, that will be handled later anyway. Call GetUpdateRgn() before calling BeginPaint() and EndPaint() (which empty the update region). * gdk/win32/gdkdnd-win32.c * gdk/win32/gdkinput-win32.c: Use _gdk_win32_get_next_tick(). * gdk/win32/gdkfont-win32.c: Use %p to print HFONTs. (gdk_text_size): Remove, unused. * gdk/win32/gdkgc-win32.c: Set clip origins to zero when appropriate. (gdk_gc_copy): Increase refcount on colormap if present. (gdk_win32_hdc_get): Handle just hcliprgn. If we have a stipple, combine it with clip region after selecting into the DC. (_gdk_win32_bitmap_to_hrgn): Rename from _gdk_win32_bitmap_to_region. (_gdk_win3_gdkregion_to_hrgn): New function, code snippet extracted from gdk_win32_hdc_get(). * gdk/win32/gdkgeometry-win32.c: Ifdef out the translate_queue handling. (gdk_window_copy_area_scroll): Increase clipRect to avoid ScrollWindowEx() not scrolling pixels it thinks are invalid. Scroll also children with the ScrollWindowEx() call. No need to call gdk_window_move() on the children. (gdk_window_scroll): Don't do guffaw scrolling. (gdk_window_compute_position): Fix typo, used win32_y where x was intended. (gdk_window_premove, gdk_window_postmove, gdk_window_clip_changed): Add debugging output. (_gdk_windowing_window_queue_antiexpose): Just call ValidateRgn() on the region. (_gdk_window_process_expose): No use for the serial number parameter now. Instead of a rectangle, take a region parameter, as Windows gives us one in WM_PAINT. * gdk/win32/gdkmain-win32.c (_gdk_win32_lbstyle_to_string, _gdk_win32_pstype_to_string, _gdk_win32_psstyle_to_string, _gdk_win32_psendcap_to_string, _gdk_win32_psjoin_to_string, _gdk_win32_rect_to_string, _gdk_win32_gdkrectangle_to_string, _gdk_win32_gdkregion_to_string): New debugging functions. (static_printf): Helper function for the above. sprintfs into a static circular buffer, return value should be used "soon". * gdk/win32/gdkwindow-win32.c (gdk_propagate_shapes): Plug memory leak, free list after use. (gdk_window_gravity_works): Remove, we know that there is no such thing on Windows. (gdk_window_set_static_bit_gravity, gdk_window_set_static_win_gravity): Ditto, remove, they didn't do anything anyway. (_gdk_windowing_window_init, gdk_window_foreign_new): Call _gdk_window_init_position() like in the X11 backend. (gdk_window_reparent): Don't call the now nonexistent gdk_window_set_static_win_gravity(). No idea what should be done instead. (gdk_window_get_geometry): The returned x and y should be relative to parent. Used to be always zero.. (gdk_window_set_static_gravities): Return FALSE if trying to set static gravity. * gdk/win32/gdkprivate-win32.h: Drop the clip_region field from GdkGCWin32. Only use the HRGN hcliprgn. Declare new functions. * gdk/win32/*.c: Use new debugging functions. * gdk/win32/rc/gdk.rc.in: Update copyright year.
2002-11-12 22:17:48 +00:00
_gdk_win32_drawable_description (src),
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
width, height, xsrc, ysrc,
_gdk_win32_drawable_description (&draw_impl->parent_instance),
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
xdest, ydest,
use_fg_bg));
/* If blitting from the root window, take the multi-monitor offset
* into account.
*/
if (src == ((GdkWindowObject *)_gdk_root)->impl)
{
GDK_NOTE (DRAW, g_print ("... offsetting src coords\n"));
xsrc -= _gdk_offset_x;
ysrc -= _gdk_offset_y;
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (GDK_IS_DRAWABLE_IMPL_WIN32 (src))
src_impl = (GdkDrawableImplWin32 *) src;
else if (GDK_IS_WINDOW (src))
src_impl = (GdkDrawableImplWin32 *) GDK_WINDOW_OBJECT (src)->impl;
else if (GDK_IS_PIXMAP (src))
src_impl = (GdkDrawableImplWin32 *) GDK_PIXMAP_OBJECT (src)->impl;
else
g_assert_not_reached ();
2009-03-01 13:55:50 +00:00
if (GDK_IS_WINDOW_IMPL_WIN32 (draw_impl) &&
GDK_IS_PIXMAP_IMPL_WIN32 (src_impl))
{
GdkPixmapImplWin32 *src_pixmap = GDK_PIXMAP_IMPL_WIN32 (src_impl);
if (xsrc < 0)
{
width += xsrc;
xdest -= xsrc;
xsrc = 0;
}
if (ysrc < 0)
{
height += ysrc;
ydest -= ysrc;
ysrc = 0;
}
if (xsrc + width > src_pixmap->width)
width = src_pixmap->width - xsrc;
if (ysrc + height > src_pixmap->height)
height = src_pixmap->height - ysrc;
}
hdc = gdk_win32_hdc_get (&draw_impl->parent_instance, gc, GDK_GC_FOREGROUND);
gdk_drawable_get_size (src_impl->wrapper, &src_width, &src_height);
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if ((src_rgn = CreateRectRgn (0, 0, src_width + 1, src_height + 1)) == NULL)
2009-02-24 15:52:32 +00:00
{
WIN32_GDI_FAILED ("CreateRectRgn");
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
else if ((draw_rgn = CreateRectRgn (xsrc, ysrc,
xsrc + width + 1,
ysrc + height + 1)) == NULL)
2009-02-16 18:26:35 +00:00
{
WIN32_GDI_FAILED ("CreateRectRgn");
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
else
{
if (GDK_IS_WINDOW_IMPL_WIN32 (draw_impl))
{
int comb;
/* If we are drawing on a window, calculate the region that is
* outside the source pixmap, and invalidate that, causing it to
* be cleared. Not completely sure whether this is always needed. XXX
*/
SetRectEmpty (&r);
outside_rgn = CreateRectRgnIndirect (&r);
if ((comb = CombineRgn (outside_rgn,
draw_rgn, src_rgn,
RGN_DIFF)) == ERROR)
WIN32_GDI_FAILED ("CombineRgn");
else if (comb != NULLREGION)
{
OffsetRgn (outside_rgn, xdest, ydest);
GDK_NOTE (DRAW, (GetRgnBox (outside_rgn, &r),
g_print ("... InvalidateRgn "
"bbox: %ldx%ld@%+ld%+ld\n",
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
r.right - r.left - 1, r.bottom - r.top - 1,
r.left, r.top)));
InvalidateRgn (draw_impl->handle, outside_rgn, TRUE);
}
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (DeleteObject, (outside_rgn));
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
#if 1 /* Don't know if this is necessary XXX */
if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
g_warning ("gdk_win32_blit: CombineRgn returned a COMPLEXREGION");
GetRgnBox (draw_rgn, &r);
if (r.left != xsrc || r.top != ysrc ||
r.right != xsrc + width + 1 || r.bottom != ysrc + height + 1)
{
xdest += r.left - xsrc;
xsrc = r.left;
ydest += r.top - ysrc;
ysrc = r.top;
width = r.right - xsrc - 1;
height = r.bottom - ysrc - 1;
GDK_NOTE (DRAW, g_print ("... restricted to src: %dx%d@%+d%+d, "
"dest: @%+d%+d\n",
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
width, height, xsrc, ysrc,
xdest, ydest));
}
#endif
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
GDI_CALL (DeleteObject, (src_rgn));
GDI_CALL (DeleteObject, (draw_rgn));
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
if (draw_impl->handle == src_impl->handle)
blit_inside_drawable (hdc, GDK_GC_WIN32 (gc), xsrc, ysrc, xdest, ydest, width, height);
else if (GDK_IS_PIXMAP_IMPL_WIN32 (src_impl))
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
blit_from_pixmap (use_fg_bg, draw_impl, hdc,
(GdkPixmapImplWin32 *) src_impl, gc,
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
xsrc, ysrc, xdest, ydest, width, height);
else
Reflect recent renamings and removals of functions. 2002-11-15 Tor Lillqvist <tml@iki.fi> * gdk/gdk.def: Reflect recent renamings and removals of functions. Merge from stable: Start implementing all fill styles (i.e. tiled, stippled, and opaque stippled in addition to the plain solid style) in the Win32 backend in an elegant and generic way. For now only did the draw_rectangle() and draw_glyphs() methods. The rest will follow. Previously some of the drawing methods implemented opaque stippling, but not tiles or non-opaque stippling. Seems to work fine, now the check marks show up in check buttons, the stippled background and stippled text in gtk-demo's Text Widget look as they should, and GtkText's line wrap arrow shows correctly instead of an ugly rectangle. [This refers to the stable branch, haven't actually checked HEAD.] The implementation does do a lot of pixmap handling and blitting back and forth, especially on Win9x. But performance is hopefully not an issue. I don't think many applications do a lot of tiled or stippled drawing. * gdk/win32/gdkprivate-win32.h: Define a new macro, GDI_CALL, that calls a GDI function and prints a warning if it failed. Also API_CALL for non-GDI calls. Cleans all the the if (!BlaBla()) WIN32_GDI_FAILED ("BlaBla") snippets, these can now be written GDI_CALL (BlaBla, ()). Declare new functions. * gdk/win32/gdkdrawable-win32.c: Use GDI_CALL macro in lots of places. (generic_draw): New function that handles all the blitting necessary to implement tiles and stipples. A function that actually draws stuff is passed as a parameter to generic_draw(). If the fill style is solid, it is called directly, to draw on the destination drawable. Otherwise it is called to draw on a temporary mask bitmap, which then is used in blitting operations. The tiles and/or stipples are rendered into another temporary pixmap. If MaskBlt() is available (on NT/2k/XP), it is used, otherwise a sequence of BitBlt() is used to do the final composition onto the destination drawable. (draw_tiles_lowlevel, draw_tiles): Some renaming and code reorg. Use BitBlt() to blit each tile, not gdk_draw_drawable(). (rop2_to_rop3): New function, does binary->ternary rop mapping. (blit_from_pixmap, blit_inside_window, blit_from_window): Use rop2_to_rop3(). Previously used SRCCOPY always... (draw_rectangle, gdk_win32_draw_rectangle, draw_glyphs, gdk_win32_draw_glyphs): Split functionality into two functions, with generic_draw() doing its magic inbetween. * gdk/win32/gdkevents-win32.c: Remove the TrackMouseEvent code, it was ifdeffed out and wouldn't have done anything even if enabled. Remove the GDK_EVENT_FUNC_FROM_WINDOW_PROC code, didn't have any effect any more anyway after all the changes GTK+ has gone through in the last years. Remove some #if 0 code. * gdk/win32/gdkgc-win32.c (gdk_gc_copy): Set the copy's hdc field to NULL in case a GC is copied while it has a Windows DC active. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: Remove gdk_event_func_from_window_proc. * gdk/win32/gdkmain-win32.c: Remove -event-func-from-window-proc option. If there is a PRETEND_WIN9X envvar, set windows_version as if on Win9x. * gdk/win32/gdkpixmap-win32.c (_gdk_win32_pixmap_new, gdk_pixmap_new): Combine these two, _gdk_win32_pixmap_new() wasn't used or exported. Make a bit more like the X11 version. Hopefully I didn't break the fragile palettized display ("pseudocolor") code. * gdk/win32/gdkgc-win32.c: Various debugging output improvements. (predraw_set_foreground): Check whether tile/stipple origins are valid when calling SetBrushOrgEx(). (gdk_win32_hdc_get): Ifdef out code that tries to handle the stipple by converting it into a region, and combining the clip region with that. A stipple shouldn't work like that, it should replicate in x and y directions. Stipples are now handled by generic_draw() in gdkdrawable-win32.c. * gdk/win32/gdkmain-win32.c: (gdk_win32_gcvalues_mask_to_string, gdk_win32_rop2_to_string): New debugging functions. (gdk_win32_print_dc): Print also DC's rop2 and text color.
2002-11-16 01:12:10 +00:00
blit_from_window (hdc, GDK_GC_WIN32 (gc), src_impl, xsrc, ysrc, xdest, ydest, width, height);
2009-02-24 15:52:32 +00:00
gdk_win32_hdc_release (&draw_impl->parent_instance, gc, GDK_GC_FOREGROUND);
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
}
static void
gdk_win32_draw_image (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
g_assert (GDK_IS_DRAWABLE_IMPL_WIN32 (drawable));
_gdk_win32_blit (TRUE, (GdkDrawableImplWin32 *) drawable,
gc, (GdkPixmap *) image->windowing_data,
xsrc, ysrc, xdest, ydest, width, height);
}
/**
* _gdk_win32_drawable_acquire_dc
* @drawable: a Win32 #GdkDrawable implementation
*
* Gets a DC with the given drawable selected into
* it.
*
* Return value: The DC, on success. Otherwise
* %NULL. If this function succeeded
* _gdk_win32_drawable_release_dc() must be called
* release the DC when you are done using it.
**/
HDC
_gdk_win32_drawable_acquire_dc (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
if (GDK_IS_WINDOW_IMPL_WIN32 (drawable) &&
GDK_WINDOW_DESTROYED (impl->wrapper))
return NULL;
if (!impl->hdc)
{
if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
{
impl->hdc = CreateCompatibleDC (NULL);
if (!impl->hdc)
WIN32_GDI_FAILED ("CreateCompatibleDC");
if (impl->hdc)
{
impl->saved_dc_bitmap = SelectObject (impl->hdc,
impl->handle);
if (!impl->saved_dc_bitmap)
{
WIN32_GDI_FAILED ("CreateCompatibleDC");
DeleteDC (impl->hdc);
impl->hdc = NULL;
}
}
}
else
{
impl->hdc = GetDC (impl->handle);
if (!impl->hdc)
WIN32_GDI_FAILED ("GetDC");
}
}
if (impl->hdc)
{
impl->hdc_count++;
return impl->hdc;
}
else
2009-03-01 13:55:50 +00:00
{
return NULL;
}
}
/**
* _gdk_win32_drawable_release_dc
* @drawable: a Win32 #GdkDrawable implementation
*
* Releases the reference count for the DC
* from _gdk_win32_drawable_acquire_dc()
**/
void
_gdk_win32_drawable_release_dc (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
g_return_if_fail (impl->hdc_count > 0);
impl->hdc_count--;
if (impl->hdc_count == 0)
{
if (impl->saved_dc_bitmap)
{
GDI_CALL (SelectObject, (impl->hdc, impl->saved_dc_bitmap));
impl->saved_dc_bitmap = NULL;
}
if (impl->hdc)
{
if (GDK_IS_PIXMAP_IMPL_WIN32 (impl))
GDI_CALL (DeleteDC, (impl->hdc));
else
GDI_CALL (ReleaseDC, (impl->handle, impl->hdc));
impl->hdc = NULL;
}
}
}
cairo_surface_t *
_gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
2009-02-16 18:26:35 +00:00
gint width,
gint height)
{
2009-03-01 13:55:50 +00:00
HDC hdc = _gdk_win32_drawable_acquire_dc (drawable);
if (!hdc)
2009-07-01 10:06:57 +00:00
return NULL;
2009-03-01 13:55:50 +00:00
return cairo_win32_surface_create (hdc);
}
static void
gdk_win32_cairo_surface_destroy (void *data)
{
GdkDrawableImplWin32 *impl = data;
_gdk_win32_drawable_release_dc (GDK_DRAWABLE (impl));
impl->cairo_surface = NULL;
}
static cairo_surface_t *
gdk_win32_ref_cairo_surface (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
if (GDK_IS_WINDOW_IMPL_WIN32 (drawable) &&
GDK_WINDOW_DESTROYED (impl->wrapper))
return NULL;
if (!impl->cairo_surface)
{
2009-02-16 18:26:35 +00:00
// On Win32 cairo surface, width and height are determined from the DC
impl->cairo_surface = _gdk_windowing_create_cairo_surface (drawable, 0, 0);
cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key,
2009-02-16 18:26:35 +00:00
drawable, gdk_win32_cairo_surface_destroy);
}
else
2009-03-01 13:55:50 +00:00
{
cairo_surface_reference (impl->cairo_surface);
}
return impl->cairo_surface;
}
void
_gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
2009-02-16 18:26:35 +00:00
gint width,
gint height)
{
2009-02-16 18:26:35 +00:00
// Do nothing. The surface size is determined by the DC
}
static gint
gdk_win32_get_depth (GdkDrawable *drawable)
{
/* This is a bit bogus but I'm not sure the other way is better */
return gdk_drawable_get_depth (GDK_DRAWABLE_IMPL_WIN32 (drawable)->wrapper);
}
Changes multihead reorganizing code for win32 support, mostly from a patch Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com> Changes multihead reorganizing code for win32 support, mostly from a patch by Hans Breuer. * gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c gdk/gdkscreen.c gdk/x11/gdkmain-x11.c gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c gdk/x11/gdkpango-x11.c gdk/gdkselection.c gdk/x11/gdkselection-x11.c gdk/gdkwindow.c gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c: Move port-independent singlehead wrapper functions into port-independent part of GDK. (#80009) * gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c: Turn singlehead functions into "multihead" functions that ignore their GdkDisplay or GdkScreen arguments. * gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h: Misc multihead-compatibility changes. * gtk/gtk.def gdk/gdk.def: Update for multihead functions. * gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c gdk/x11/gdkvisual-x11.c: Remove the screen fields from the public parts of the colormap/visual structures, add accessors instead. * gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen for colormaps, visuals; move the fields into the private structures for the x11 backend. * gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c: Remove virtualization of screen and display functions. (#79990, patch from Erwann Chenede) * gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}: New files containing stub implementations of Display, Screen functions. * gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkx.h: Clean up function exports and what headers they are in. (#79954) * gdk/x11/gdkx.h: Fix macro that was referring to a non-existant screen->screen_num. (In the patch for #79972, Erwann Chenede) * gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer() to use window hooks. (#79972, patch partly from Erwann Chenede) * gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix some warnings.
2002-06-06 00:26:42 +00:00
static GdkScreen*
gdk_win32_get_screen (GdkDrawable *drawable)
{
return gdk_screen_get_default ();
Changes multihead reorganizing code for win32 support, mostly from a patch Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com> Changes multihead reorganizing code for win32 support, mostly from a patch by Hans Breuer. * gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c gdk/gdkscreen.c gdk/x11/gdkmain-x11.c gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c gdk/x11/gdkpango-x11.c gdk/gdkselection.c gdk/x11/gdkselection-x11.c gdk/gdkwindow.c gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c: Move port-independent singlehead wrapper functions into port-independent part of GDK. (#80009) * gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c: Turn singlehead functions into "multihead" functions that ignore their GdkDisplay or GdkScreen arguments. * gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h: Misc multihead-compatibility changes. * gtk/gtk.def gdk/gdk.def: Update for multihead functions. * gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c gdk/x11/gdkvisual-x11.c: Remove the screen fields from the public parts of the colormap/visual structures, add accessors instead. * gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen for colormaps, visuals; move the fields into the private structures for the x11 backend. * gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c: Remove virtualization of screen and display functions. (#79990, patch from Erwann Chenede) * gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}: New files containing stub implementations of Display, Screen functions. * gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch] gdk/x11/gdkx.h: Clean up function exports and what headers they are in. (#79954) * gdk/x11/gdkx.h: Fix macro that was referring to a non-existant screen->screen_num. (In the patch for #79972, Erwann Chenede) * gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer() to use window hooks. (#79972, patch partly from Erwann Chenede) * gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix some warnings.
2002-06-06 00:26:42 +00:00
}
static GdkVisual*
gdk_win32_get_visual (GdkDrawable *drawable)
{
return gdk_drawable_get_visual (GDK_DRAWABLE_IMPL_WIN32 (drawable)->wrapper);
}
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
HGDIOBJ
gdk_win32_drawable_get_handle (GdkDrawable *drawable)
{
Massive changes. Too many to list here, but I'll try a summary: 2002-02-17 Tor Lillqvist <tml@iki.fi> * gdk/win32/*.c: Massive changes. Too many to list here, but I'll try a summary: 1) Unify GdkPixmap and GdkImage implementation: For each GdkPixmap, allocate a GdkImage, and vice versa. GdkPixmapImplWin32Data has a pointer to the GdkImage. GdkImage::windowing_data is a pointer to the GdkPixmap. This simplifies many pixmap and image related functions a lot, and reduces duplicated code snippets. For instance, there is only one place in gdk/win32 where CreateDIBSection() is called, in the function _gdk_win32_new_pixmap(). Converting a bitmap (GdkPixmap) to a Windows region is almost trivial, with the bitmap bits being readily accessible in the associated GdkImage. All blitting between GdkPixmaps, GdkWindows and GdkImages goes through handled the _gdk_win32_blit() function, which calls different functions to handle the cases of blitting from pixmaps, inside windows (scrolling), or from windows, which all require somewhat different handling. 2) Support 256-color mode. This has long been very broken, now it works more or less OK. Keep the logical palette for each colormap as small as possible while allocating and freeing colors. Select and realize the logical palette associated with a GdkColormap into a DC before drawing or blitting. When the display is in 256-color mode, make it possible for the user to override the size of the palette(s) used with either the GDK_WIN32_MAX_COLORS environment variable, or a -max-colors command line option. It is possible to reduce the palette size all the way down to using just the 16 static colors (which causes the system visual to be of type GDK_VISUAL_STATIC_COLOR. This could possibly be useful if one desperately wants to avoid color flashing. (Note that in order for this to work properly, an as of yet not commited fix to gdkrgb.c is needed.) Handle the palette messages. On WM_PALETTECHANGED, call UpdateColors() for the given window hierarchy. Do this only if a window in some other top-level window hierarchy caused the palette change (realized a palette). Do this max five times in a row (an arbitrarily chosen limit), though, otherwise redraw by generating expose events. On WM_QUERYNEWPALETTE, cause a redraw of the whole window hierarchy by generating GDK_EXPOSE events. 3) Code cleanup in general. For instance, remove the "emulated" X11 structs ColormapStruct, Visual and XStandardColormap. Use the new GDK_DEBUG_* flags for debugging output in the relevant source files. Remove the unused colormap hash table in gdkcolor-win32.c 4) Plug some resource leaks. 2002-02-14 Tor Lillqvist <tml@iki.fi> * gdk/win32/gdkdnd-win32.c (gdk_dropfiles_filter): Use g_filename_to_uri() to actually create legal URIs in the text/uri-list data.
2002-02-17 00:25:05 +00:00
return GDK_DRAWABLE_HANDLE (drawable);
}
/**
* _gdk_win32_drawable_finish
* @drawable: a Win32 #GdkDrawable implementation
*
* Releases any resources allocated internally for the drawable.
* This is called when the drawable becomes unusable
* (gdk_window_destroy() for a window, or the refcount going to
* zero for a pixmap.)
**/
void
_gdk_win32_drawable_finish (GdkDrawable *drawable)
{
GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (drawable);
if (impl->cairo_surface)
{
cairo_surface_finish (impl->cairo_surface);
2009-03-01 13:55:50 +00:00
cairo_surface_set_user_data (impl->cairo_surface, &gdk_win32_cairo_key, NULL, NULL);
}
2009-03-01 13:55:50 +00:00
2009-07-01 11:33:45 +00:00
//TODO_CSW: g_assert (impl->hdc_count == 0);
}