Just renamed the Win32 backend files to *-win32.

This commit is contained in:
Tor Lillqvist 1999-11-10 00:04:17 +00:00
parent 78141c328f
commit 84477de7fc
47 changed files with 30 additions and 48432 deletions

View File

@ -1,336 +0,0 @@
EXPORTS
gdk_atom_intern
gdk_atom_name
gdk_beep
gdk_bitmap_create_from_data
gdk_bitmap_ref
gdk_bitmap_unref
gdk_char_height
gdk_char_measure
gdk_char_width
gdk_char_width_wc
gdk_color_alloc
gdk_color_black
gdk_color_change
gdk_color_context_add_palette
gdk_color_context_free
gdk_color_context_free_dither
gdk_color_context_get_index_from_palette
gdk_color_context_get_pixel
gdk_color_context_get_pixel_from_palette
gdk_color_context_get_pixels
gdk_color_context_get_pixels_incremental
gdk_color_context_init_dither
gdk_color_context_new
gdk_color_context_new_mono
gdk_color_context_query_color
gdk_color_context_query_colors
gdk_color_copy
gdk_color_equal
gdk_color_free
gdk_color_hash
gdk_color_parse
gdk_color_white
gdk_colormap_alloc_color
gdk_colormap_alloc_colors
gdk_colormap_change
gdk_colormap_free_colors
gdk_colormap_get_system
gdk_colormap_get_system_size
gdk_colormap_get_visual
gdk_colormap_new
gdk_colormap_ref
gdk_colormap_unref
gdk_colors_alloc
gdk_colors_free
gdk_colors_store
gdk_cursor_destroy
gdk_cursor_new
gdk_cursor_new_from_pixmap
gdk_debug_flags
gdk_dnd_init
gdk_drag_abort
gdk_drag_begin
gdk_drag_context_new
gdk_drag_context_ref
gdk_drag_context_unref
gdk_drag_drop
gdk_drag_find_window
gdk_drag_get_protocol
gdk_drag_get_selection
gdk_drag_motion
gdk_drag_status
gdk_drop_finish
gdk_drop_reply
gdk_draw_arc
gdk_draw_gray_image
gdk_draw_image
gdk_draw_indexed_image
gdk_draw_line
gdk_draw_lines
gdk_draw_pixmap
gdk_draw_point
gdk_draw_points
gdk_draw_polygon
gdk_draw_rectangle
gdk_draw_rgb_32_image
gdk_draw_rgb_image
gdk_draw_rgb_image_dithalign
gdk_draw_segments
gdk_draw_string
gdk_draw_text
gdk_draw_text_wc
gdk_drawable_get_colormap
gdk_drawable_get_size
gdk_drawable_get_type
gdk_drawable_get_visual
gdk_drawable_set_colormap
gdk_drawable_set_data
gdk_error_code
gdk_error_trap_pop
gdk_error_trap_push
gdk_error_warnings
gdk_event_copy
gdk_event_free
gdk_event_get
gdk_event_get_graphics_expose
gdk_event_get_time
gdk_event_handler_set
gdk_event_peek
gdk_event_put
gdk_event_send_client_message
gdk_event_send_clientmessage_toall
gdk_events_pending
gdk_exit
gdk_flush
gdk_font_equal
gdk_font_id
gdk_font_list_free
gdk_font_list_new
gdk_font_load
gdk_font_ref
gdk_font_unref
gdk_font_xlfd_create
gdk_font_xlfd_free
gdk_fontset_load
gdk_free_compound_text
gdk_free_text_list
gdk_gc_copy
gdk_gc_destroy
gdk_gc_get_values
gdk_gc_new
gdk_gc_new_with_values
gdk_gc_ref
gdk_gc_set_background
gdk_gc_set_clip_mask
gdk_gc_set_clip_origin
gdk_gc_set_clip_rectangle
gdk_gc_set_clip_region
gdk_gc_set_dashes
gdk_gc_set_exposures
gdk_gc_set_fill
gdk_gc_set_font
gdk_gc_set_foreground
gdk_gc_set_function
gdk_gc_set_line_attributes
gdk_gc_set_stipple
gdk_gc_set_subwindow
gdk_gc_set_tile
gdk_gc_set_ts_origin
gdk_gc_unref
gdk_get_display
gdk_get_show_events
gdk_get_use_xshm
gdk_ic_destroy
gdk_ic_get_attr
gdk_ic_get_events
gdk_ic_get_style
gdk_ic_get_values
gdk_ic_new
gdk_ic_set_attr
gdk_ic_set_values
gdk_im_begin
gdk_im_decide_style
gdk_im_end
gdk_im_ready
gdk_im_set_best_style
gdk_image_bitmap_new
gdk_image_destroy
gdk_image_get
gdk_image_get_pixel
gdk_image_new
gdk_image_new_bitmap
gdk_image_put_pixel
gdk_init
gdk_init_check
gdk_input_add
gdk_input_add_full
gdk_input_exit
gdk_input_init
gdk_input_list_devices
gdk_input_motion_events
gdk_input_remove
gdk_input_set_axes
gdk_input_set_extension_events
gdk_input_set_key
gdk_input_set_mode
gdk_input_set_source
gdk_input_window_get_pointer
gdk_key_repeat_disable
gdk_key_repeat_restore
gdk_keyboard_grab
gdk_keyboard_ungrab
gdk_keyval_from_name
gdk_keyval_is_lower
gdk_keyval_is_upper
gdk_keyval_name
gdk_keyval_to_lower
gdk_keyval_to_upper
gdk_list_visuals
gdk_mbstowcs
gdk_null_window_warnings
gdk_pixmap_colormap_create_from_xpm
gdk_pixmap_colormap_create_from_xpm_d
gdk_pixmap_create_from_data
gdk_pixmap_create_from_xpm
gdk_pixmap_create_from_xpm_d
gdk_pixmap_create_on_shared_image
gdk_pixmap_foreign_new
gdk_pixmap_new
gdk_pixmap_ref
gdk_pixmap_unref
gdk_pointer_grab
gdk_pointer_is_grabbed
gdk_pointer_ungrab
gdk_progclass
gdk_property_change
gdk_property_delete
gdk_property_get
gdk_query_depths
gdk_query_visual_types
gdk_rectangle_intersect
gdk_rectangle_union
gdk_region_destroy
gdk_region_empty
gdk_region_equal
gdk_region_get_clipbox
gdk_region_new
gdk_region_offset
gdk_region_point_in
gdk_region_polygon
gdk_region_rect_in
gdk_region_shrink
gdk_region_union_with_rect
gdk_regions_intersect
gdk_regions_subtract
gdk_regions_union
gdk_regions_xor
gdk_rgb_cmap_free
gdk_rgb_cmap_new
gdk_rgb_ditherable
gdk_rgb_gc_set_background
gdk_rgb_gc_set_foreground
gdk_rgb_get_cmap
gdk_rgb_get_visual
gdk_rgb_init
gdk_rgb_set_install
gdk_rgb_set_min_colors
gdk_rgb_set_verbose
gdk_rgb_xpixel_from_rgb
gdk_root_parent
gdk_screen_height
gdk_screen_height_mm
gdk_screen_width
gdk_screen_width_mm
gdk_selection_convert
gdk_selection_owner_get
gdk_selection_owner_set
gdk_selection_property
gdk_selection_property_get
gdk_selection_send_notify
gdk_set_locale
gdk_set_show_events
gdk_set_use_xshm
gdk_string_extents
gdk_string_height
gdk_string_measure
gdk_string_to_compound_text
gdk_string_width
gdk_text_extents
gdk_text_extents_wc
gdk_text_height
gdk_text_measure
gdk_text_property_to_text_list
gdk_text_width
gdk_text_width_wc
gdk_threads_enter
gdk_threads_leave
gdk_threads_mutex
gdk_visual_get_best
gdk_visual_get_best_depth
gdk_visual_get_best_type
gdk_visual_get_best_with_both
gdk_visual_get_best_with_depth
gdk_visual_get_best_with_type
gdk_visual_get_system
gdk_visual_ref
gdk_visual_unref
gdk_wcstombs
gdk_window_add_filter
gdk_window_at_pointer
gdk_window_clear
gdk_window_clear_area
gdk_window_clear_area_e
gdk_window_destroy
gdk_window_foreign_new
gdk_window_get_deskrelative_origin
gdk_window_get_children
gdk_window_get_events
gdk_window_get_geometry
gdk_window_get_origin
gdk_window_get_parent
gdk_window_get_pointer
gdk_window_get_position
gdk_window_get_root_origin
gdk_window_get_toplevel
gdk_window_get_toplevels
gdk_window_get_user_data
gdk_window_hide
gdk_window_is_visible
gdk_window_is_viewable
gdk_window_lower
gdk_window_merge_child_shapes
gdk_window_move
gdk_window_move_resize
gdk_window_new
gdk_window_raise
gdk_window_ref
gdk_window_register_dnd
gdk_window_remove_filter
gdk_window_reparent
gdk_window_resize
gdk_window_set_back_pixmap
gdk_window_set_background
gdk_window_set_child_shapes
gdk_window_set_cursor
gdk_window_set_decorations
gdk_window_set_events
gdk_window_set_functions
gdk_window_set_geometry_hints
gdk_window_set_group
gdk_window_set_hints
gdk_window_set_icon
gdk_window_set_icon_name
gdk_window_set_override_redirect
gdk_window_set_role
gdk_window_set_static_gravities
gdk_window_set_title
gdk_window_set_transient_for
gdk_window_set_user_data
gdk_window_shape_combine_mask
gdk_window_show
gdk_window_unref
gdk_window_withdraw
gdk_xid_table_insert
gdk_xid_table_lookup
gdk_xid_table_remove

File diff suppressed because it is too large Load Diff

View File

@ -1,336 +0,0 @@
EXPORTS
gdk_atom_intern
gdk_atom_name
gdk_beep
gdk_bitmap_create_from_data
gdk_bitmap_ref
gdk_bitmap_unref
gdk_char_height
gdk_char_measure
gdk_char_width
gdk_char_width_wc
gdk_color_alloc
gdk_color_black
gdk_color_change
gdk_color_context_add_palette
gdk_color_context_free
gdk_color_context_free_dither
gdk_color_context_get_index_from_palette
gdk_color_context_get_pixel
gdk_color_context_get_pixel_from_palette
gdk_color_context_get_pixels
gdk_color_context_get_pixels_incremental
gdk_color_context_init_dither
gdk_color_context_new
gdk_color_context_new_mono
gdk_color_context_query_color
gdk_color_context_query_colors
gdk_color_copy
gdk_color_equal
gdk_color_free
gdk_color_hash
gdk_color_parse
gdk_color_white
gdk_colormap_alloc_color
gdk_colormap_alloc_colors
gdk_colormap_change
gdk_colormap_free_colors
gdk_colormap_get_system
gdk_colormap_get_system_size
gdk_colormap_get_visual
gdk_colormap_new
gdk_colormap_ref
gdk_colormap_unref
gdk_colors_alloc
gdk_colors_free
gdk_colors_store
gdk_cursor_destroy
gdk_cursor_new
gdk_cursor_new_from_pixmap
gdk_debug_flags
gdk_dnd_init
gdk_drag_abort
gdk_drag_begin
gdk_drag_context_new
gdk_drag_context_ref
gdk_drag_context_unref
gdk_drag_drop
gdk_drag_find_window
gdk_drag_get_protocol
gdk_drag_get_selection
gdk_drag_motion
gdk_drag_status
gdk_drop_finish
gdk_drop_reply
gdk_draw_arc
gdk_draw_gray_image
gdk_draw_image
gdk_draw_indexed_image
gdk_draw_line
gdk_draw_lines
gdk_draw_pixmap
gdk_draw_point
gdk_draw_points
gdk_draw_polygon
gdk_draw_rectangle
gdk_draw_rgb_32_image
gdk_draw_rgb_image
gdk_draw_rgb_image_dithalign
gdk_draw_segments
gdk_draw_string
gdk_draw_text
gdk_draw_text_wc
gdk_drawable_get_colormap
gdk_drawable_get_size
gdk_drawable_get_type
gdk_drawable_get_visual
gdk_drawable_set_colormap
gdk_drawable_set_data
gdk_error_code
gdk_error_trap_pop
gdk_error_trap_push
gdk_error_warnings
gdk_event_copy
gdk_event_free
gdk_event_get
gdk_event_get_graphics_expose
gdk_event_get_time
gdk_event_handler_set
gdk_event_peek
gdk_event_put
gdk_event_send_client_message
gdk_event_send_clientmessage_toall
gdk_events_pending
gdk_exit
gdk_flush
gdk_font_equal
gdk_font_id
gdk_font_list_free
gdk_font_list_new
gdk_font_load
gdk_font_ref
gdk_font_unref
gdk_font_xlfd_create
gdk_font_xlfd_free
gdk_fontset_load
gdk_free_compound_text
gdk_free_text_list
gdk_gc_copy
gdk_gc_destroy
gdk_gc_get_values
gdk_gc_new
gdk_gc_new_with_values
gdk_gc_ref
gdk_gc_set_background
gdk_gc_set_clip_mask
gdk_gc_set_clip_origin
gdk_gc_set_clip_rectangle
gdk_gc_set_clip_region
gdk_gc_set_dashes
gdk_gc_set_exposures
gdk_gc_set_fill
gdk_gc_set_font
gdk_gc_set_foreground
gdk_gc_set_function
gdk_gc_set_line_attributes
gdk_gc_set_stipple
gdk_gc_set_subwindow
gdk_gc_set_tile
gdk_gc_set_ts_origin
gdk_gc_unref
gdk_get_display
gdk_get_show_events
gdk_get_use_xshm
gdk_ic_destroy
gdk_ic_get_attr
gdk_ic_get_events
gdk_ic_get_style
gdk_ic_get_values
gdk_ic_new
gdk_ic_set_attr
gdk_ic_set_values
gdk_im_begin
gdk_im_decide_style
gdk_im_end
gdk_im_ready
gdk_im_set_best_style
gdk_image_bitmap_new
gdk_image_destroy
gdk_image_get
gdk_image_get_pixel
gdk_image_new
gdk_image_new_bitmap
gdk_image_put_pixel
gdk_init
gdk_init_check
gdk_input_add
gdk_input_add_full
gdk_input_exit
gdk_input_init
gdk_input_list_devices
gdk_input_motion_events
gdk_input_remove
gdk_input_set_axes
gdk_input_set_extension_events
gdk_input_set_key
gdk_input_set_mode
gdk_input_set_source
gdk_input_window_get_pointer
gdk_key_repeat_disable
gdk_key_repeat_restore
gdk_keyboard_grab
gdk_keyboard_ungrab
gdk_keyval_from_name
gdk_keyval_is_lower
gdk_keyval_is_upper
gdk_keyval_name
gdk_keyval_to_lower
gdk_keyval_to_upper
gdk_list_visuals
gdk_mbstowcs
gdk_null_window_warnings
gdk_pixmap_colormap_create_from_xpm
gdk_pixmap_colormap_create_from_xpm_d
gdk_pixmap_create_from_data
gdk_pixmap_create_from_xpm
gdk_pixmap_create_from_xpm_d
gdk_pixmap_create_on_shared_image
gdk_pixmap_foreign_new
gdk_pixmap_new
gdk_pixmap_ref
gdk_pixmap_unref
gdk_pointer_grab
gdk_pointer_is_grabbed
gdk_pointer_ungrab
gdk_progclass
gdk_property_change
gdk_property_delete
gdk_property_get
gdk_query_depths
gdk_query_visual_types
gdk_rectangle_intersect
gdk_rectangle_union
gdk_region_destroy
gdk_region_empty
gdk_region_equal
gdk_region_get_clipbox
gdk_region_new
gdk_region_offset
gdk_region_point_in
gdk_region_polygon
gdk_region_rect_in
gdk_region_shrink
gdk_region_union_with_rect
gdk_regions_intersect
gdk_regions_subtract
gdk_regions_union
gdk_regions_xor
gdk_rgb_cmap_free
gdk_rgb_cmap_new
gdk_rgb_ditherable
gdk_rgb_gc_set_background
gdk_rgb_gc_set_foreground
gdk_rgb_get_cmap
gdk_rgb_get_visual
gdk_rgb_init
gdk_rgb_set_install
gdk_rgb_set_min_colors
gdk_rgb_set_verbose
gdk_rgb_xpixel_from_rgb
gdk_root_parent
gdk_screen_height
gdk_screen_height_mm
gdk_screen_width
gdk_screen_width_mm
gdk_selection_convert
gdk_selection_owner_get
gdk_selection_owner_set
gdk_selection_property
gdk_selection_property_get
gdk_selection_send_notify
gdk_set_locale
gdk_set_show_events
gdk_set_use_xshm
gdk_string_extents
gdk_string_height
gdk_string_measure
gdk_string_to_compound_text
gdk_string_width
gdk_text_extents
gdk_text_extents_wc
gdk_text_height
gdk_text_measure
gdk_text_property_to_text_list
gdk_text_width
gdk_text_width_wc
gdk_threads_enter
gdk_threads_leave
gdk_threads_mutex
gdk_visual_get_best
gdk_visual_get_best_depth
gdk_visual_get_best_type
gdk_visual_get_best_with_both
gdk_visual_get_best_with_depth
gdk_visual_get_best_with_type
gdk_visual_get_system
gdk_visual_ref
gdk_visual_unref
gdk_wcstombs
gdk_window_add_filter
gdk_window_at_pointer
gdk_window_clear
gdk_window_clear_area
gdk_window_clear_area_e
gdk_window_destroy
gdk_window_foreign_new
gdk_window_get_deskrelative_origin
gdk_window_get_children
gdk_window_get_events
gdk_window_get_geometry
gdk_window_get_origin
gdk_window_get_parent
gdk_window_get_pointer
gdk_window_get_position
gdk_window_get_root_origin
gdk_window_get_toplevel
gdk_window_get_toplevels
gdk_window_get_user_data
gdk_window_hide
gdk_window_is_visible
gdk_window_is_viewable
gdk_window_lower
gdk_window_merge_child_shapes
gdk_window_move
gdk_window_move_resize
gdk_window_new
gdk_window_raise
gdk_window_ref
gdk_window_register_dnd
gdk_window_remove_filter
gdk_window_reparent
gdk_window_resize
gdk_window_set_back_pixmap
gdk_window_set_background
gdk_window_set_child_shapes
gdk_window_set_cursor
gdk_window_set_decorations
gdk_window_set_events
gdk_window_set_functions
gdk_window_set_geometry_hints
gdk_window_set_group
gdk_window_set_hints
gdk_window_set_icon
gdk_window_set_icon_name
gdk_window_set_override_redirect
gdk_window_set_role
gdk_window_set_static_gravities
gdk_window_set_title
gdk_window_set_transient_for
gdk_window_set_user_data
gdk_window_shape_combine_mask
gdk_window_show
gdk_window_unref
gdk_window_withdraw
gdk_xid_table_insert
gdk_xid_table_lookup
gdk_xid_table_remove

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
static const struct { const char *name; int type; } cursors[] = {
{ "x_cursor", 0 },
{ "arrow", 2 },
{ "based_arrow_down", 4 },
{ "based_arrow_up", 6 },
{ "boat", 8 },
{ "bogosity", 10 },
{ "bottom_left_corner", 12 },
{ "bottom_right_corner", 14 },
{ "bottom_side", 16 },
{ "bottom_tee", 18 },
{ "box_spiral", 20 },
{ "center_ptr", 22 },
{ "circle", 24 },
{ "clock", 26 },
{ "coffee_mug", 28 },
{ "cross", 30 },
{ "cross_reverse", 32 },
{ "crosshair", 34 },
{ "diamond_cross", 36 },
{ "dot", 38 },
{ "dotbox", 40 },
{ "double_arrow", 42 },
{ "draft_large", 44 },
{ "draft_small", 46 },
{ "draped_box", 48 },
{ "exchange", 50 },
{ "fleur", 52 },
{ "gobbler", 54 },
{ "gumby", 56 },
{ "hand1", 58 },
{ "hand2", 60 },
{ "heart", 62 },
{ "icon", 64 },
{ "iron_cross", 66 },
{ "left_ptr", 68 },
{ "left_side", 70 },
{ "left_tee", 72 },
{ "leftbutton", 74 },
{ "ll_angle", 76 },
{ "lr_angle", 78 },
{ "man", 80 },
{ "middlebutton", 82 },
{ "mouse", 84 },
{ "pencil", 86 },
{ "pirate", 88 },
{ "plus", 90 },
{ "question_arrow", 92 },
{ "right_ptr", 94 },
{ "right_side", 96 },
{ "right_tee", 98 },
{ "rightbutton", 100 },
{ "rtl_logo", 102 },
{ "sailboat", 104 },
{ "sb_down_arrow", 106 },
{ "sb_h_double_arrow", 108 },
{ "sb_left_arrow", 110 },
{ "sb_right_arrow", 112 },
{ "sb_up_arrow", 114 },
{ "sb_v_double_arrow", 116 },
{ "shuttle", 118 },
{ "sizing", 120 },
{ "spider", 122 },
{ "spraycan", 124 },
{ "star", 126 },
{ "target", 128 },
{ "tcross", 130 },
{ "top_left_arrow", 132 },
{ "top_left_corner", 134 },
{ "top_right_corner", 136 },
{ "top_side", 138 },
{ "top_tee", 140 },
{ "trek", 142 },
{ "ul_angle", 144 },
{ "umbrella", 146 },
{ "ur_angle", 148 },
{ "watch", 150 },
{ "xterm", 152 },
{ NULL, 0 }
};
GdkCursor*
gdk_cursor_new (GdkCursorType cursor_type)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
HCURSOR xcursor;
int i;
for (i = 0; cursors[i].name != NULL && cursors[i].type != cursor_type; i++)
;
if (cursors[i].name != NULL)
{
xcursor = LoadCursor (gdk_DLLInstance, cursors[i].name);
if (xcursor == NULL)
g_warning ("gdk_cursor_new: LoadCursor failed");
GDK_NOTE (MISC, g_print ("gdk_cursor_new: %#x %d\n",
xcursor, cursor_type));
}
else
{
g_warning ("gdk_cursor_new: no cursor %d found",
cursor_type);
xcursor = NULL;
}
private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = cursor_type;
return cursor;
}
GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
GdkColor *fg,
GdkColor *bg,
gint x,
gint y)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
GdkDrawablePrivate *source_private, *mask_private;
GdkImage *source_image, *mask_image;
HCURSOR xcursor;
guchar *p, *q, *XORmask, *ANDmask;
gint width, height, cursor_width, cursor_height;
guchar residue;
gint ix, iy;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (mask != NULL, NULL);
source_private = (GdkDrawablePrivate *) source;
mask_private = (GdkDrawablePrivate *) mask;
g_return_val_if_fail (source_private->width == mask_private->width
&& source_private->height == mask_private->height,
NULL);
width = source_private->width;
height = source_private->height;
cursor_width = GetSystemMetrics (SM_CXCURSOR);
cursor_height = GetSystemMetrics (SM_CYCURSOR);
g_return_val_if_fail (width <= cursor_width
&& height <= cursor_height, NULL);
residue = (1 << ((8-(width%8))%8)) - 1;
source_image = gdk_image_get (source, 0, 0, width, height);
mask_image = gdk_image_get (mask, 0, 0, width, height);
if (source_image->depth != 1 || mask_image->depth != 1)
{
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
NULL);
}
/* Such complex bit manipulation for this simple task, sigh.
* The X cursor and Windows cursor concepts are quite different.
* We assume here that we are always called with fg == black and
* bg == white.
*/
/* First set masked-out source bits, as all source bits matter on Windoze.
* As we invert them below, they will be clear in the final XORmask.
*/
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
q = (guchar *) mask_image->mem + iy*mask_image->bpl;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*p++ |= ~(*q++);
}
/* XOR mask is initialized to zero */
XORmask = g_malloc0 (cursor_width/8 * cursor_height);
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
q = XORmask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] &= ~residue; /* Clear left-over bits */
}
/* AND mask is initialized to ones */
ANDmask = g_malloc (cursor_width/8 * cursor_height);
memset (ANDmask, 0xFF, cursor_width/8 * cursor_height);
for (iy = 0; iy < height; iy++)
{
p = (guchar *) mask_image->mem + iy*mask_image->bpl;
q = ANDmask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] |= residue; /* Set left-over bits */
}
xcursor = CreateCursor (gdk_ProgInstance, x, y, cursor_width, cursor_height,
ANDmask, XORmask);
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
source_private->width, source_private->height,
mask_private->xwindow,
mask_private->width, mask_private->height,
xcursor, cursor_width, cursor_height));
g_free (XORmask);
g_free (ANDmask);
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = GDK_CURSOR_IS_PIXMAP;
return cursor;
}
void
gdk_cursor_destroy (GdkCursor *cursor)
{
GdkCursorPrivate *private;
g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor;
GDK_NOTE (MISC, g_print ("gdk_cursor_destroy: %#x\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->xcursor : 0));
if (cursor->type == GDK_CURSOR_IS_PIXMAP)
if (!DestroyIcon (private->xcursor))
g_warning ("gdk_cursor_destroy: DestroyIcon failed");
g_free (private);
}

View File

@ -1,274 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkcursor.h"
#include "gdkprivate.h"
static const struct { const char *name; int type; } cursors[] = {
{ "x_cursor", 0 },
{ "arrow", 2 },
{ "based_arrow_down", 4 },
{ "based_arrow_up", 6 },
{ "boat", 8 },
{ "bogosity", 10 },
{ "bottom_left_corner", 12 },
{ "bottom_right_corner", 14 },
{ "bottom_side", 16 },
{ "bottom_tee", 18 },
{ "box_spiral", 20 },
{ "center_ptr", 22 },
{ "circle", 24 },
{ "clock", 26 },
{ "coffee_mug", 28 },
{ "cross", 30 },
{ "cross_reverse", 32 },
{ "crosshair", 34 },
{ "diamond_cross", 36 },
{ "dot", 38 },
{ "dotbox", 40 },
{ "double_arrow", 42 },
{ "draft_large", 44 },
{ "draft_small", 46 },
{ "draped_box", 48 },
{ "exchange", 50 },
{ "fleur", 52 },
{ "gobbler", 54 },
{ "gumby", 56 },
{ "hand1", 58 },
{ "hand2", 60 },
{ "heart", 62 },
{ "icon", 64 },
{ "iron_cross", 66 },
{ "left_ptr", 68 },
{ "left_side", 70 },
{ "left_tee", 72 },
{ "leftbutton", 74 },
{ "ll_angle", 76 },
{ "lr_angle", 78 },
{ "man", 80 },
{ "middlebutton", 82 },
{ "mouse", 84 },
{ "pencil", 86 },
{ "pirate", 88 },
{ "plus", 90 },
{ "question_arrow", 92 },
{ "right_ptr", 94 },
{ "right_side", 96 },
{ "right_tee", 98 },
{ "rightbutton", 100 },
{ "rtl_logo", 102 },
{ "sailboat", 104 },
{ "sb_down_arrow", 106 },
{ "sb_h_double_arrow", 108 },
{ "sb_left_arrow", 110 },
{ "sb_right_arrow", 112 },
{ "sb_up_arrow", 114 },
{ "sb_v_double_arrow", 116 },
{ "shuttle", 118 },
{ "sizing", 120 },
{ "spider", 122 },
{ "spraycan", 124 },
{ "star", 126 },
{ "target", 128 },
{ "tcross", 130 },
{ "top_left_arrow", 132 },
{ "top_left_corner", 134 },
{ "top_right_corner", 136 },
{ "top_side", 138 },
{ "top_tee", 140 },
{ "trek", 142 },
{ "ul_angle", 144 },
{ "umbrella", 146 },
{ "ur_angle", 148 },
{ "watch", 150 },
{ "xterm", 152 },
{ NULL, 0 }
};
GdkCursor*
gdk_cursor_new (GdkCursorType cursor_type)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
HCURSOR xcursor;
int i;
for (i = 0; cursors[i].name != NULL && cursors[i].type != cursor_type; i++)
;
if (cursors[i].name != NULL)
{
xcursor = LoadCursor (gdk_DLLInstance, cursors[i].name);
if (xcursor == NULL)
g_warning ("gdk_cursor_new: LoadCursor failed");
GDK_NOTE (MISC, g_print ("gdk_cursor_new: %#x %d\n",
xcursor, cursor_type));
}
else
{
g_warning ("gdk_cursor_new: no cursor %d found",
cursor_type);
xcursor = NULL;
}
private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = cursor_type;
return cursor;
}
GdkCursor*
gdk_cursor_new_from_pixmap (GdkPixmap *source,
GdkPixmap *mask,
GdkColor *fg,
GdkColor *bg,
gint x,
gint y)
{
GdkCursorPrivate *private;
GdkCursor *cursor;
GdkDrawablePrivate *source_private, *mask_private;
GdkImage *source_image, *mask_image;
HCURSOR xcursor;
guchar *p, *q, *XORmask, *ANDmask;
gint width, height, cursor_width, cursor_height;
guchar residue;
gint ix, iy;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (mask != NULL, NULL);
source_private = (GdkDrawablePrivate *) source;
mask_private = (GdkDrawablePrivate *) mask;
g_return_val_if_fail (source_private->width == mask_private->width
&& source_private->height == mask_private->height,
NULL);
width = source_private->width;
height = source_private->height;
cursor_width = GetSystemMetrics (SM_CXCURSOR);
cursor_height = GetSystemMetrics (SM_CYCURSOR);
g_return_val_if_fail (width <= cursor_width
&& height <= cursor_height, NULL);
residue = (1 << ((8-(width%8))%8)) - 1;
source_image = gdk_image_get (source, 0, 0, width, height);
mask_image = gdk_image_get (mask, 0, 0, width, height);
if (source_image->depth != 1 || mask_image->depth != 1)
{
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
g_return_val_if_fail (source_image->depth == 1 && mask_image->depth == 1,
NULL);
}
/* Such complex bit manipulation for this simple task, sigh.
* The X cursor and Windows cursor concepts are quite different.
* We assume here that we are always called with fg == black and
* bg == white.
*/
/* First set masked-out source bits, as all source bits matter on Windoze.
* As we invert them below, they will be clear in the final XORmask.
*/
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
q = (guchar *) mask_image->mem + iy*mask_image->bpl;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*p++ |= ~(*q++);
}
/* XOR mask is initialized to zero */
XORmask = g_malloc0 (cursor_width/8 * cursor_height);
for (iy = 0; iy < height; iy++)
{
p = (guchar *) source_image->mem + iy*source_image->bpl;
q = XORmask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] &= ~residue; /* Clear left-over bits */
}
/* AND mask is initialized to ones */
ANDmask = g_malloc (cursor_width/8 * cursor_height);
memset (ANDmask, 0xFF, cursor_width/8 * cursor_height);
for (iy = 0; iy < height; iy++)
{
p = (guchar *) mask_image->mem + iy*mask_image->bpl;
q = ANDmask + iy*cursor_width/8;
for (ix = 0; ix < ((width-1)/8+1); ix++)
*q++ = ~(*p++);
q[-1] |= residue; /* Set left-over bits */
}
xcursor = CreateCursor (gdk_ProgInstance, x, y, cursor_width, cursor_height,
ANDmask, XORmask);
GDK_NOTE (MISC, g_print ("gdk_cursor_new_from_pixmap: "
"%#x (%dx%d) %#x (%dx%d) = %#x (%dx%d)\n",
source_private->xwindow,
source_private->width, source_private->height,
mask_private->xwindow,
mask_private->width, mask_private->height,
xcursor, cursor_width, cursor_height));
g_free (XORmask);
g_free (ANDmask);
gdk_image_destroy (source_image);
gdk_image_destroy (mask_image);
private = g_new (GdkCursorPrivate, 1);
private->xcursor = xcursor;
cursor = (GdkCursor*) private;
cursor->type = GDK_CURSOR_IS_PIXMAP;
return cursor;
}
void
gdk_cursor_destroy (GdkCursor *cursor)
{
GdkCursorPrivate *private;
g_return_if_fail (cursor != NULL);
private = (GdkCursorPrivate *) cursor;
GDK_NOTE (MISC, g_print ("gdk_cursor_destroy: %#x\n",
(cursor->type == GDK_CURSOR_IS_PIXMAP) ? private->xcursor : 0));
if (cursor->type == GDK_CURSOR_IS_PIXMAP)
if (!DestroyIcon (private->xcursor))
g_warning ("gdk_cursor_destroy: DestroyIcon failed");
g_free (private);
}

View File

@ -1,973 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 1998-1999 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
/* #define OLE2_DND */
#define INITGUID
#include "gdkdnd.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include "gdkx.h"
#ifdef OLE2_DND
#include <ole2.h>
#else
#include <objbase.h>
#endif
#ifdef _MSC_VER /* These aren't in mingw32 */
#include <shlobj.h>
#include <shlguid.h>
#endif
#ifndef _MSC_VER
static IID IID_IUnknown = {
0x00000000, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
static IID IID_IDropSource = {
0x00000121, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
static IID IID_IDropTarget = {
0x00000122, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
#endif
#include <gdk/gdk.h>
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
typedef enum {
GDK_DRAG_STATUS_DRAG,
GDK_DRAG_STATUS_MOTION_WAIT,
GDK_DRAG_STATUS_ACTION_WAIT,
GDK_DRAG_STATUS_DROP
} GtkDragStatus;
typedef enum {
GDK_DRAG_SOURCE,
GDK_DRAG_TARGET
} GdkDragKind;
#ifdef OLE2_DND
#define PRINT_GUID(guid) \
g_print ("guid = %.08x-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x", \
((gulong *) guid)[0], \
((gushort *) guid)[2], \
((gushort *) guid)[3], \
((guchar *) guid)[8], \
((guchar *) guid)[9], \
((guchar *) guid)[10], \
((guchar *) guid)[11], \
((guchar *) guid)[12], \
((guchar *) guid)[13], \
((guchar *) guid)[14], \
((guchar *) guid)[15]);
#endif /* OLE2_DND */
/* Structure that holds information about a drag in progress.
* this is used on both source and destination sides.
*/
struct _GdkDragContextPrivate {
GdkDragContext context;
guint ref_count;
guint16 last_x; /* Coordinates from last event */
guint16 last_y;
HWND dest_xid;
guint drag_status; /* Current status of drag */
};
GdkDragContext *current_dest_drag = NULL;
/* Drag Contexts */
static GList *contexts;
GdkDragContext *
gdk_drag_context_new (void)
{
GdkDragContextPrivate *result;
result = g_new0 (GdkDragContextPrivate, 1);
result->ref_count = 1;
contexts = g_list_prepend (contexts, result);
return (GdkDragContext *)result;
}
void
gdk_drag_context_ref (GdkDragContext *context)
{
g_return_if_fail (context != NULL);
((GdkDragContextPrivate *)context)->ref_count++;
}
void
gdk_drag_context_unref (GdkDragContext *context)
{
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
g_return_if_fail (context != NULL);
private->ref_count--;
GDK_NOTE (DND, g_print ("gdk_drag_context_unref: %d%s\n",
private->ref_count,
(private->ref_count == 0 ? " freeing" : "")));
if (private->ref_count == 0)
{
g_dataset_destroy (private);
g_list_free (context->targets);
if (context->source_window)
gdk_window_unref (context->source_window);
if (context->dest_window)
gdk_window_unref (context->dest_window);
contexts = g_list_remove (contexts, private);
g_free (private);
}
}
#if 0
static GdkDragContext *
gdk_drag_context_find (gboolean is_source,
HWND source_xid,
HWND dest_xid)
{
GList *tmp_list = contexts;
GdkDragContext *context;
while (tmp_list)
{
context = (GdkDragContext *)tmp_list->data;
if ((!context->is_source == !is_source) &&
((source_xid == None) || (context->source_window &&
(GDK_WINDOW_XWINDOW (context->source_window) == source_xid))) &&
((dest_xid == None) || (context->dest_window &&
(GDK_WINDOW_XWINDOW (context->dest_window) == dest_xid))))
return context;
tmp_list = tmp_list->next;
}
return NULL;
}
#endif
typedef struct {
#ifdef OLE2_DND
IDropTarget idt;
#endif
GdkDragContext *context;
} target_drag_context;
typedef struct {
#ifdef OLE2_DND
IDropSource ids;
#endif
GdkDragContext *context;
} source_drag_context;
#ifdef OLE2_DND
static ULONG STDMETHODCALLTYPE
m_add_ref_target (IDropTarget __RPC_FAR *This)
{
target_drag_context *ctx = (target_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_add_ref_target\n"));
gdk_drag_context_ref (ctx->context);
return private->ref_count;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_target (IDropTarget __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
GDK_NOTE (DND, g_print ("m_query_interface_target\n"));
*ppvObject = NULL;
PRINT_GUID (riid);
if (IsEqualGUID (riid, &IID_IUnknown))
{
g_print ("...IUnknown\n");
m_add_ref_target (This);
*ppvObject = This;
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropTarget))
{
g_print ("...IDropTarget\n");
m_add_ref_target (This);
*ppvObject = This;
return S_OK;
}
else
{
g_print ("...Huh?\n");
return E_NOINTERFACE;
}
}
static ULONG STDMETHODCALLTYPE
m_release_target (IDropTarget __RPC_FAR *This)
{
target_drag_context *ctx = (target_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_release_target\n"));
gdk_drag_context_unref (ctx->context);
if (private->ref_count == 1)
{
gdk_drag_context_unref (ctx->context);
return 0;
}
else
return private->ref_count - 1;
}
static HRESULT STDMETHODCALLTYPE
m_drag_enter (IDropTarget __RPC_FAR *This,
IDataObject __RPC_FAR *pDataObj,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drag_enter\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drag_over (IDropTarget __RPC_FAR *This,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drag_over\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drag_leave (IDropTarget __RPC_FAR *This)
{
GDK_NOTE (DND, g_print ("m_drag_leave\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drop (IDropTarget __RPC_FAR *This,
IDataObject __RPC_FAR *pDataObj,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drop\n"));
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_add_ref_source (IDropSource __RPC_FAR *This)
{
source_drag_context *ctx = (source_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_add_ref_source\n"));
gdk_drag_context_ref (ctx->context);
return private->ref_count;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_source (IDropSource __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
GDK_NOTE (DND, g_print ("m_query_interface_source\n"));
*ppvObject = NULL;
PRINT_GUID (riid);
if (IsEqualGUID (riid, &IID_IUnknown))
{
g_print ("...IUnknown\n");
m_add_ref_source (This);
*ppvObject = This;
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropSource))
{
g_print ("...IDropSource\n");
m_add_ref_source (This);
*ppvObject = This;
return S_OK;
}
else
{
g_print ("...Huh?\n");
return E_NOINTERFACE;
}
}
static ULONG STDMETHODCALLTYPE
m_release_source (IDropSource __RPC_FAR *This)
{
source_drag_context *ctx = (source_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_release_source\n"));
gdk_drag_context_unref (ctx->context);
if (private->ref_count == 1)
{
gdk_drag_context_unref (ctx->context);
return 0;
}
else
return private->ref_count - 1;
}
static HRESULT STDMETHODCALLTYPE
m_query_continue_drag (IDropSource __RPC_FAR *This,
BOOL fEscapePressed,
DWORD grfKeyState)
{
GDK_NOTE (DND, g_print ("m_query_continue_drag\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_give_feedback (IDropSource __RPC_FAR *This,
DWORD dwEffect)
{
GDK_NOTE (DND, g_print ("m_give_feedback\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_object (IDataObject __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_add_ref_object (IDataObject __RPC_FAR *This)
{
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_release_object (IDataObject __RPC_FAR *This)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_data_here (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_query_get_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_canonical_format_etc (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtcIn,
FORMATETC *pFormatEtcOut)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_set_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium,
BOOL fRelease)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_enum_format_etc (IDataObject __RPC_FAR *This,
DWORD dwDirection,
IEnumFORMATETC **ppEnumFormatEtc)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_d_advise (IDataObject __RPC_FAR *This,
FORMATETC *pFormatetc,
DWORD advf,
IAdviseSink *pAdvSink,
DWORD *pdwConnection)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_d_unadvise (IDataObject __RPC_FAR *This,
DWORD dwConnection)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_enum_d_advise (IDataObject __RPC_FAR *This,
IEnumSTATDATA **ppenumAdvise)
{
return E_UNEXPECTED;
}
static IDropTargetVtbl idt_vtbl = {
m_query_interface_target,
m_add_ref_target,
m_release_target,
m_drag_enter,
m_drag_over,
m_drag_leave,
m_drop
};
static IDropSourceVtbl ids_vtbl = {
m_query_interface_source,
m_add_ref_source,
m_release_source,
m_query_continue_drag,
m_give_feedback
};
static IDataObjectVtbl ido_vtbl = {
m_query_interface_object,
m_add_ref_object,
m_release_object,
m_get_data,
m_get_data_here,
m_query_get_data,
m_get_canonical_format_etc,
m_set_data,
m_enum_format_etc,
m_d_advise,
m_d_unadvise,
m_enum_d_advise
};
#endif /* OLE2_DND */
static target_drag_context *
target_context_new (void)
{
target_drag_context *result;
result = g_new0 (target_drag_context, 1);
#ifdef OLE2_DND
result->idt.lpVtbl = &idt_vtbl;
#endif
result->context = gdk_drag_context_new ();
return result;
}
static source_drag_context *
source_context_new (void)
{
source_drag_context *result;
result = g_new0 (source_drag_context, 1);
#ifdef OLE2_DND
result->ids.lpVtbl = &ids_vtbl;
#endif
result->context = gdk_drag_context_new ();
return result;
}
#ifdef _MSC_VER
/* From MS Knowledge Base article Q130698 */
/* resolve_link() fills the filename and path buffer
* with relevant information
* hWnd - calling app's window handle.
*
* lpszLinkName - name of the link file passed into the function.
*
* lpszPath - the buffer that will receive the file pathname.
*/
static HRESULT
resolve_link(HWND hWnd,
LPCTSTR lpszLinkName,
LPSTR lpszPath,
LPSTR lpszDescription)
{
HRESULT hres;
IShellLink *psl;
WIN32_FIND_DATA wfd;
/* Assume Failure to start with: */
*lpszPath = 0;
if (lpszDescription)
*lpszDescription = 0;
/* Call CoCreateInstance to obtain the IShellLink interface
* pointer. This call fails if CoInitialize is not called, so it is
* assumed that CoInitialize has been called.
*/
hres = CoCreateInstance (&CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IShellLink,
(LPVOID *)&psl);
if (SUCCEEDED (hres))
{
IPersistFile *ppf;
/* The IShellLink interface supports the IPersistFile
* interface. Get an interface pointer to it.
*/
hres = psl->lpVtbl->QueryInterface (psl,
&IID_IPersistFile,
(LPVOID *) &ppf);
if (SUCCEEDED (hres))
{
WORD wsz[MAX_PATH];
/* Convert the given link name string to wide character string. */
MultiByteToWideChar (CP_ACP, 0,
lpszLinkName,
-1, wsz, MAX_PATH);
/* Load the file. */
hres = ppf->lpVtbl->Load (ppf, wsz, STGM_READ);
if (SUCCEEDED (hres))
{
/* Resolve the link by calling the Resolve()
* interface function.
*/
hres = psl->lpVtbl->Resolve(psl, hWnd,
SLR_ANY_MATCH |
SLR_NO_UI);
if (SUCCEEDED (hres))
{
hres = psl->lpVtbl->GetPath (psl, lpszPath,
MAX_PATH,
(WIN32_FIND_DATA*)&wfd,
0);
if (SUCCEEDED (hres) && lpszDescription != NULL)
{
hres = psl->lpVtbl->GetDescription (psl,
lpszDescription,
MAX_PATH );
if (!SUCCEEDED (hres))
return FALSE;
}
}
}
ppf->lpVtbl->Release (ppf);
}
psl->lpVtbl->Release (psl);
}
return SUCCEEDED (hres);
}
#else
#define resolve_link(hWnd, lpszLinkName, lpszPath, lpszDescription) FALSE
#endif
static GdkFilterReturn
gdk_dropfiles_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
{
GdkDragContext *context;
GdkDragContextPrivate *private;
static GdkAtom text_uri_list_atom = GDK_NONE;
GString *result;
MSG *msg = (MSG *) xev;
HANDLE hdrop;
POINT pt;
gint nfiles, i, k;
guchar fileName[MAX_PATH], linkedFile[MAX_PATH];
if (text_uri_list_atom == GDK_NONE)
text_uri_list_atom = gdk_atom_intern ("text/uri-list", FALSE);
if (msg->message == WM_DROPFILES)
{
GDK_NOTE (DND, g_print ("WM_DROPFILES: %#x\n", msg->hwnd));
context = gdk_drag_context_new ();
private = (GdkDragContextPrivate *) context;
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
context->source_window = (GdkWindow *) gdk_root_parent;
context->dest_window = event->any.window;
gdk_window_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
context->targets =
g_list_append (NULL, GUINT_TO_POINTER (text_uri_list_atom));
current_dest_drag = context;
event->dnd.type = GDK_DROP_START;
event->dnd.context = current_dest_drag;
gdk_drag_context_ref (current_dest_drag);
hdrop = (HANDLE) msg->wParam;
DragQueryPoint (hdrop, &pt);
ClientToScreen (msg->hwnd, &pt);
event->dnd.x_root = pt.x;
event->dnd.y_root = pt.y;
event->dnd.time = msg->time;
nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
result = g_string_new (NULL);
for (i = 0; i < nfiles; i++)
{
g_string_append (result, "file:");
DragQueryFile (hdrop, i, fileName, MAX_PATH);
/* Resolve shortcuts */
if (resolve_link (msg->hwnd, fileName, linkedFile, NULL))
{
g_string_append (result, linkedFile);
GDK_NOTE (DND, g_print ("...%s link to %s\n",
fileName, linkedFile));
}
else
{
g_string_append (result, fileName);
GDK_NOTE (DND, g_print ("...%s\n", fileName));
}
g_string_append (result, "\015\012");
}
gdk_sel_prop_store ((GdkWindow *) gdk_root_parent,
text_uri_list_atom, 8, result->str, result->len + 1);
DragFinish (hdrop);
return GDK_FILTER_TRANSLATE;
}
else
return GDK_FILTER_CONTINUE;
}
/*************************************************************
************************** Public API ***********************
*************************************************************/
void
gdk_dnd_init (void)
{
HRESULT hres;
#ifdef OLE2_DND
hres = OleInitialize (NULL);
if (! SUCCEEDED (hres))
g_error ("OleInitialize failed");
#endif
}
void
gdk_dnd_exit (void)
{
#ifdef OLE2_DND
OleUninitialize ();
#endif
}
/* Source side */
static void
gdk_drag_do_leave (GdkDragContext *context, guint32 time)
{
if (context->dest_window)
{
GDK_NOTE (DND, g_print ("gdk_drag_do_leave\n"));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
}
GdkDragContext *
gdk_drag_begin (GdkWindow *window,
GList *targets)
{
GList *tmp_list;
source_drag_context *ctx;
g_return_val_if_fail (window != NULL, NULL);
GDK_NOTE (DND, g_print ("gdk_drag_begin\n"));
ctx = source_context_new ();
ctx->context->is_source = TRUE;
ctx->context->source_window = window;
gdk_window_ref (window);
tmp_list = g_list_last (targets);
ctx->context->targets = NULL;
while (tmp_list)
{
ctx->context->targets = g_list_prepend (ctx->context->targets,
tmp_list->data);
tmp_list = tmp_list->prev;
}
ctx->context->actions = 0;
#if 0
DoDragDrop (...);
#endif
return ctx->context;
}
guint32
gdk_drag_get_protocol (guint32 xid,
GdkDragProtocol *protocol)
{
/* This isn't used */
return 0;
}
void
gdk_drag_find_window (GdkDragContext *context,
GdkWindow *drag_window,
gint x_root,
gint y_root,
GdkWindow **dest_window,
GdkDragProtocol *protocol)
{
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
GdkDrawablePrivate *drag_window_private = (GdkDrawablePrivate*) drag_window;
HWND recipient;
POINT pt;
GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n",
(drag_window ? drag_window_private->xwindow : 0),
x_root, y_root));
pt.x = x_root;
pt.y = y_root;
recipient = WindowFromPoint (pt);
if (recipient == NULL)
*dest_window = NULL;
else
{
*dest_window = gdk_window_lookup (recipient);
if (*dest_window)
gdk_window_ref (*dest_window);
*protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
}
}
gboolean
gdk_drag_motion (GdkDragContext *context,
GdkWindow *dest_window,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
GdkDragAction suggested_action,
GdkDragAction possible_actions,
guint32 time)
{
return FALSE;
}
void
gdk_drag_drop (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
g_warning ("gdk_drag_drop: not implemented\n");
}
void
gdk_drag_abort (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
gdk_drag_do_leave (context, time);
}
/* Destination side */
void
gdk_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time)
{
GDK_NOTE (DND, g_print ("gdk_drag_status\n"));
}
void
gdk_drop_reply (GdkDragContext *context,
gboolean ok,
guint32 time)
{
}
void
gdk_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
}
static GdkFilterReturn
gdk_destroy_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
{
#ifdef OLE2_DND
MSG *msg = (MSG *) xev;
if (msg->message == WM_DESTROY)
{
IDropTarget *idtp = (IDropTarget *) data;
GDK_NOTE (DND, g_print ("gdk_destroy_filter: WM_DESTROY: %#x\n", msg->hwnd));
RevokeDragDrop (msg->hwnd);
CoLockObjectExternal (idtp, FALSE, TRUE);
}
#endif
return GDK_FILTER_CONTINUE;
}
void
gdk_window_register_dnd (GdkWindow *window)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *) window;
#ifdef OLE2_DND
target_drag_context *context;
HRESULT hres;
#endif
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", private->xwindow));
/* We always claim to accept dropped files, but in fact we might not,
* of course. This function is called in such a way that it cannot know
* whether the window (widget) in question actually accepts files
* (in gtk, data of type text/uri-list) or not.
*/
gdk_window_add_filter (window, gdk_dropfiles_filter, NULL);
DragAcceptFiles (private->xwindow, TRUE);
#ifdef OLE2_DND
/* Register for OLE2 d&d */
context = target_context_new ();
hres = CoLockObjectExternal ((IUnknown *) &context->idt, TRUE, FALSE);
if (!SUCCEEDED (hres))
g_warning ("gdk_window_register_dnd: CoLockObjectExternal failed");
else
{
hres = RegisterDragDrop (private->xwindow, &context->idt);
if (hres == DRAGDROP_E_ALREADYREGISTERED)
{
g_print ("DRAGDROP_E_ALREADYREGISTERED\n");
CoLockObjectExternal ((IUnknown *) &context->idt, FALSE, FALSE);
}
else if (!SUCCEEDED (hres))
g_warning ("gdk_window_register_dnd: RegisterDragDrop failed");
else
{
gdk_window_add_filter (window, gdk_destroy_filter, &context->idt);
}
}
#endif
}
/*************************************************************
* gdk_drag_get_selection:
* Returns the selection atom for the current source window
* arguments:
*
* results:
*************************************************************/
GdkAtom
gdk_drag_get_selection (GdkDragContext *context)
{
if (context->protocol == GDK_DRAG_PROTO_WIN32_DROPFILES)
return gdk_win32_dropfiles_atom;
else if (context->protocol == GDK_DRAG_PROTO_OLE2)
return gdk_ole2_dnd_atom;
else
return GDK_NONE;
}

View File

@ -1,973 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
* Copyright (C) 1998-1999 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
/* #define OLE2_DND */
#define INITGUID
#include "gdkdnd.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include "gdkx.h"
#ifdef OLE2_DND
#include <ole2.h>
#else
#include <objbase.h>
#endif
#ifdef _MSC_VER /* These aren't in mingw32 */
#include <shlobj.h>
#include <shlguid.h>
#endif
#ifndef _MSC_VER
static IID IID_IUnknown = {
0x00000000, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
static IID IID_IDropSource = {
0x00000121, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
static IID IID_IDropTarget = {
0x00000122, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } };
#endif
#include <gdk/gdk.h>
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
typedef enum {
GDK_DRAG_STATUS_DRAG,
GDK_DRAG_STATUS_MOTION_WAIT,
GDK_DRAG_STATUS_ACTION_WAIT,
GDK_DRAG_STATUS_DROP
} GtkDragStatus;
typedef enum {
GDK_DRAG_SOURCE,
GDK_DRAG_TARGET
} GdkDragKind;
#ifdef OLE2_DND
#define PRINT_GUID(guid) \
g_print ("guid = %.08x-%.04x-%.04x-%.02x%.02x-%.02x%.02x%.02x%.02x%.02x%.02x", \
((gulong *) guid)[0], \
((gushort *) guid)[2], \
((gushort *) guid)[3], \
((guchar *) guid)[8], \
((guchar *) guid)[9], \
((guchar *) guid)[10], \
((guchar *) guid)[11], \
((guchar *) guid)[12], \
((guchar *) guid)[13], \
((guchar *) guid)[14], \
((guchar *) guid)[15]);
#endif /* OLE2_DND */
/* Structure that holds information about a drag in progress.
* this is used on both source and destination sides.
*/
struct _GdkDragContextPrivate {
GdkDragContext context;
guint ref_count;
guint16 last_x; /* Coordinates from last event */
guint16 last_y;
HWND dest_xid;
guint drag_status; /* Current status of drag */
};
GdkDragContext *current_dest_drag = NULL;
/* Drag Contexts */
static GList *contexts;
GdkDragContext *
gdk_drag_context_new (void)
{
GdkDragContextPrivate *result;
result = g_new0 (GdkDragContextPrivate, 1);
result->ref_count = 1;
contexts = g_list_prepend (contexts, result);
return (GdkDragContext *)result;
}
void
gdk_drag_context_ref (GdkDragContext *context)
{
g_return_if_fail (context != NULL);
((GdkDragContextPrivate *)context)->ref_count++;
}
void
gdk_drag_context_unref (GdkDragContext *context)
{
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
g_return_if_fail (context != NULL);
private->ref_count--;
GDK_NOTE (DND, g_print ("gdk_drag_context_unref: %d%s\n",
private->ref_count,
(private->ref_count == 0 ? " freeing" : "")));
if (private->ref_count == 0)
{
g_dataset_destroy (private);
g_list_free (context->targets);
if (context->source_window)
gdk_window_unref (context->source_window);
if (context->dest_window)
gdk_window_unref (context->dest_window);
contexts = g_list_remove (contexts, private);
g_free (private);
}
}
#if 0
static GdkDragContext *
gdk_drag_context_find (gboolean is_source,
HWND source_xid,
HWND dest_xid)
{
GList *tmp_list = contexts;
GdkDragContext *context;
while (tmp_list)
{
context = (GdkDragContext *)tmp_list->data;
if ((!context->is_source == !is_source) &&
((source_xid == None) || (context->source_window &&
(GDK_WINDOW_XWINDOW (context->source_window) == source_xid))) &&
((dest_xid == None) || (context->dest_window &&
(GDK_WINDOW_XWINDOW (context->dest_window) == dest_xid))))
return context;
tmp_list = tmp_list->next;
}
return NULL;
}
#endif
typedef struct {
#ifdef OLE2_DND
IDropTarget idt;
#endif
GdkDragContext *context;
} target_drag_context;
typedef struct {
#ifdef OLE2_DND
IDropSource ids;
#endif
GdkDragContext *context;
} source_drag_context;
#ifdef OLE2_DND
static ULONG STDMETHODCALLTYPE
m_add_ref_target (IDropTarget __RPC_FAR *This)
{
target_drag_context *ctx = (target_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_add_ref_target\n"));
gdk_drag_context_ref (ctx->context);
return private->ref_count;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_target (IDropTarget __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
GDK_NOTE (DND, g_print ("m_query_interface_target\n"));
*ppvObject = NULL;
PRINT_GUID (riid);
if (IsEqualGUID (riid, &IID_IUnknown))
{
g_print ("...IUnknown\n");
m_add_ref_target (This);
*ppvObject = This;
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropTarget))
{
g_print ("...IDropTarget\n");
m_add_ref_target (This);
*ppvObject = This;
return S_OK;
}
else
{
g_print ("...Huh?\n");
return E_NOINTERFACE;
}
}
static ULONG STDMETHODCALLTYPE
m_release_target (IDropTarget __RPC_FAR *This)
{
target_drag_context *ctx = (target_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_release_target\n"));
gdk_drag_context_unref (ctx->context);
if (private->ref_count == 1)
{
gdk_drag_context_unref (ctx->context);
return 0;
}
else
return private->ref_count - 1;
}
static HRESULT STDMETHODCALLTYPE
m_drag_enter (IDropTarget __RPC_FAR *This,
IDataObject __RPC_FAR *pDataObj,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drag_enter\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drag_over (IDropTarget __RPC_FAR *This,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drag_over\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drag_leave (IDropTarget __RPC_FAR *This)
{
GDK_NOTE (DND, g_print ("m_drag_leave\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_drop (IDropTarget __RPC_FAR *This,
IDataObject __RPC_FAR *pDataObj,
DWORD grfKeyState,
POINTL pt,
DWORD __RPC_FAR *pdwEffect)
{
GDK_NOTE (DND, g_print ("m_drop\n"));
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_add_ref_source (IDropSource __RPC_FAR *This)
{
source_drag_context *ctx = (source_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_add_ref_source\n"));
gdk_drag_context_ref (ctx->context);
return private->ref_count;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_source (IDropSource __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
GDK_NOTE (DND, g_print ("m_query_interface_source\n"));
*ppvObject = NULL;
PRINT_GUID (riid);
if (IsEqualGUID (riid, &IID_IUnknown))
{
g_print ("...IUnknown\n");
m_add_ref_source (This);
*ppvObject = This;
return S_OK;
}
else if (IsEqualGUID (riid, &IID_IDropSource))
{
g_print ("...IDropSource\n");
m_add_ref_source (This);
*ppvObject = This;
return S_OK;
}
else
{
g_print ("...Huh?\n");
return E_NOINTERFACE;
}
}
static ULONG STDMETHODCALLTYPE
m_release_source (IDropSource __RPC_FAR *This)
{
source_drag_context *ctx = (source_drag_context *) This;
GdkDragContextPrivate *private = (GdkDragContextPrivate *) ctx->context;
GDK_NOTE (DND, g_print ("m_release_source\n"));
gdk_drag_context_unref (ctx->context);
if (private->ref_count == 1)
{
gdk_drag_context_unref (ctx->context);
return 0;
}
else
return private->ref_count - 1;
}
static HRESULT STDMETHODCALLTYPE
m_query_continue_drag (IDropSource __RPC_FAR *This,
BOOL fEscapePressed,
DWORD grfKeyState)
{
GDK_NOTE (DND, g_print ("m_query_continue_drag\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_give_feedback (IDropSource __RPC_FAR *This,
DWORD dwEffect)
{
GDK_NOTE (DND, g_print ("m_give_feedback\n"));
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_query_interface_object (IDataObject __RPC_FAR *This,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_add_ref_object (IDataObject __RPC_FAR *This)
{
return E_UNEXPECTED;
}
static ULONG STDMETHODCALLTYPE
m_release_object (IDataObject __RPC_FAR *This)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_data_here (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_query_get_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_get_canonical_format_etc (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtcIn,
FORMATETC *pFormatEtcOut)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_set_data (IDataObject __RPC_FAR *This,
FORMATETC *pFormatEtc,
STGMEDIUM *pMedium,
BOOL fRelease)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_enum_format_etc (IDataObject __RPC_FAR *This,
DWORD dwDirection,
IEnumFORMATETC **ppEnumFormatEtc)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_d_advise (IDataObject __RPC_FAR *This,
FORMATETC *pFormatetc,
DWORD advf,
IAdviseSink *pAdvSink,
DWORD *pdwConnection)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_d_unadvise (IDataObject __RPC_FAR *This,
DWORD dwConnection)
{
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
m_enum_d_advise (IDataObject __RPC_FAR *This,
IEnumSTATDATA **ppenumAdvise)
{
return E_UNEXPECTED;
}
static IDropTargetVtbl idt_vtbl = {
m_query_interface_target,
m_add_ref_target,
m_release_target,
m_drag_enter,
m_drag_over,
m_drag_leave,
m_drop
};
static IDropSourceVtbl ids_vtbl = {
m_query_interface_source,
m_add_ref_source,
m_release_source,
m_query_continue_drag,
m_give_feedback
};
static IDataObjectVtbl ido_vtbl = {
m_query_interface_object,
m_add_ref_object,
m_release_object,
m_get_data,
m_get_data_here,
m_query_get_data,
m_get_canonical_format_etc,
m_set_data,
m_enum_format_etc,
m_d_advise,
m_d_unadvise,
m_enum_d_advise
};
#endif /* OLE2_DND */
static target_drag_context *
target_context_new (void)
{
target_drag_context *result;
result = g_new0 (target_drag_context, 1);
#ifdef OLE2_DND
result->idt.lpVtbl = &idt_vtbl;
#endif
result->context = gdk_drag_context_new ();
return result;
}
static source_drag_context *
source_context_new (void)
{
source_drag_context *result;
result = g_new0 (source_drag_context, 1);
#ifdef OLE2_DND
result->ids.lpVtbl = &ids_vtbl;
#endif
result->context = gdk_drag_context_new ();
return result;
}
#ifdef _MSC_VER
/* From MS Knowledge Base article Q130698 */
/* resolve_link() fills the filename and path buffer
* with relevant information
* hWnd - calling app's window handle.
*
* lpszLinkName - name of the link file passed into the function.
*
* lpszPath - the buffer that will receive the file pathname.
*/
static HRESULT
resolve_link(HWND hWnd,
LPCTSTR lpszLinkName,
LPSTR lpszPath,
LPSTR lpszDescription)
{
HRESULT hres;
IShellLink *psl;
WIN32_FIND_DATA wfd;
/* Assume Failure to start with: */
*lpszPath = 0;
if (lpszDescription)
*lpszDescription = 0;
/* Call CoCreateInstance to obtain the IShellLink interface
* pointer. This call fails if CoInitialize is not called, so it is
* assumed that CoInitialize has been called.
*/
hres = CoCreateInstance (&CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IShellLink,
(LPVOID *)&psl);
if (SUCCEEDED (hres))
{
IPersistFile *ppf;
/* The IShellLink interface supports the IPersistFile
* interface. Get an interface pointer to it.
*/
hres = psl->lpVtbl->QueryInterface (psl,
&IID_IPersistFile,
(LPVOID *) &ppf);
if (SUCCEEDED (hres))
{
WORD wsz[MAX_PATH];
/* Convert the given link name string to wide character string. */
MultiByteToWideChar (CP_ACP, 0,
lpszLinkName,
-1, wsz, MAX_PATH);
/* Load the file. */
hres = ppf->lpVtbl->Load (ppf, wsz, STGM_READ);
if (SUCCEEDED (hres))
{
/* Resolve the link by calling the Resolve()
* interface function.
*/
hres = psl->lpVtbl->Resolve(psl, hWnd,
SLR_ANY_MATCH |
SLR_NO_UI);
if (SUCCEEDED (hres))
{
hres = psl->lpVtbl->GetPath (psl, lpszPath,
MAX_PATH,
(WIN32_FIND_DATA*)&wfd,
0);
if (SUCCEEDED (hres) && lpszDescription != NULL)
{
hres = psl->lpVtbl->GetDescription (psl,
lpszDescription,
MAX_PATH );
if (!SUCCEEDED (hres))
return FALSE;
}
}
}
ppf->lpVtbl->Release (ppf);
}
psl->lpVtbl->Release (psl);
}
return SUCCEEDED (hres);
}
#else
#define resolve_link(hWnd, lpszLinkName, lpszPath, lpszDescription) FALSE
#endif
static GdkFilterReturn
gdk_dropfiles_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
{
GdkDragContext *context;
GdkDragContextPrivate *private;
static GdkAtom text_uri_list_atom = GDK_NONE;
GString *result;
MSG *msg = (MSG *) xev;
HANDLE hdrop;
POINT pt;
gint nfiles, i, k;
guchar fileName[MAX_PATH], linkedFile[MAX_PATH];
if (text_uri_list_atom == GDK_NONE)
text_uri_list_atom = gdk_atom_intern ("text/uri-list", FALSE);
if (msg->message == WM_DROPFILES)
{
GDK_NOTE (DND, g_print ("WM_DROPFILES: %#x\n", msg->hwnd));
context = gdk_drag_context_new ();
private = (GdkDragContextPrivate *) context;
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
context->source_window = (GdkWindow *) gdk_root_parent;
context->dest_window = event->any.window;
gdk_window_ref (context->dest_window);
/* WM_DROPFILES drops are always file names */
context->targets =
g_list_append (NULL, GUINT_TO_POINTER (text_uri_list_atom));
current_dest_drag = context;
event->dnd.type = GDK_DROP_START;
event->dnd.context = current_dest_drag;
gdk_drag_context_ref (current_dest_drag);
hdrop = (HANDLE) msg->wParam;
DragQueryPoint (hdrop, &pt);
ClientToScreen (msg->hwnd, &pt);
event->dnd.x_root = pt.x;
event->dnd.y_root = pt.y;
event->dnd.time = msg->time;
nfiles = DragQueryFile (hdrop, 0xFFFFFFFF, NULL, 0);
result = g_string_new (NULL);
for (i = 0; i < nfiles; i++)
{
g_string_append (result, "file:");
DragQueryFile (hdrop, i, fileName, MAX_PATH);
/* Resolve shortcuts */
if (resolve_link (msg->hwnd, fileName, linkedFile, NULL))
{
g_string_append (result, linkedFile);
GDK_NOTE (DND, g_print ("...%s link to %s\n",
fileName, linkedFile));
}
else
{
g_string_append (result, fileName);
GDK_NOTE (DND, g_print ("...%s\n", fileName));
}
g_string_append (result, "\015\012");
}
gdk_sel_prop_store ((GdkWindow *) gdk_root_parent,
text_uri_list_atom, 8, result->str, result->len + 1);
DragFinish (hdrop);
return GDK_FILTER_TRANSLATE;
}
else
return GDK_FILTER_CONTINUE;
}
/*************************************************************
************************** Public API ***********************
*************************************************************/
void
gdk_dnd_init (void)
{
HRESULT hres;
#ifdef OLE2_DND
hres = OleInitialize (NULL);
if (! SUCCEEDED (hres))
g_error ("OleInitialize failed");
#endif
}
void
gdk_dnd_exit (void)
{
#ifdef OLE2_DND
OleUninitialize ();
#endif
}
/* Source side */
static void
gdk_drag_do_leave (GdkDragContext *context, guint32 time)
{
if (context->dest_window)
{
GDK_NOTE (DND, g_print ("gdk_drag_do_leave\n"));
gdk_window_unref (context->dest_window);
context->dest_window = NULL;
}
}
GdkDragContext *
gdk_drag_begin (GdkWindow *window,
GList *targets)
{
GList *tmp_list;
source_drag_context *ctx;
g_return_val_if_fail (window != NULL, NULL);
GDK_NOTE (DND, g_print ("gdk_drag_begin\n"));
ctx = source_context_new ();
ctx->context->is_source = TRUE;
ctx->context->source_window = window;
gdk_window_ref (window);
tmp_list = g_list_last (targets);
ctx->context->targets = NULL;
while (tmp_list)
{
ctx->context->targets = g_list_prepend (ctx->context->targets,
tmp_list->data);
tmp_list = tmp_list->prev;
}
ctx->context->actions = 0;
#if 0
DoDragDrop (...);
#endif
return ctx->context;
}
guint32
gdk_drag_get_protocol (guint32 xid,
GdkDragProtocol *protocol)
{
/* This isn't used */
return 0;
}
void
gdk_drag_find_window (GdkDragContext *context,
GdkWindow *drag_window,
gint x_root,
gint y_root,
GdkWindow **dest_window,
GdkDragProtocol *protocol)
{
GdkDragContextPrivate *private = (GdkDragContextPrivate *)context;
GdkDrawablePrivate *drag_window_private = (GdkDrawablePrivate*) drag_window;
HWND recipient;
POINT pt;
GDK_NOTE (DND, g_print ("gdk_drag_find_window: %#x +%d+%d\n",
(drag_window ? drag_window_private->xwindow : 0),
x_root, y_root));
pt.x = x_root;
pt.y = y_root;
recipient = WindowFromPoint (pt);
if (recipient == NULL)
*dest_window = NULL;
else
{
*dest_window = gdk_window_lookup (recipient);
if (*dest_window)
gdk_window_ref (*dest_window);
*protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
}
}
gboolean
gdk_drag_motion (GdkDragContext *context,
GdkWindow *dest_window,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
GdkDragAction suggested_action,
GdkDragAction possible_actions,
guint32 time)
{
return FALSE;
}
void
gdk_drag_drop (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
g_warning ("gdk_drag_drop: not implemented\n");
}
void
gdk_drag_abort (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
gdk_drag_do_leave (context, time);
}
/* Destination side */
void
gdk_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time)
{
GDK_NOTE (DND, g_print ("gdk_drag_status\n"));
}
void
gdk_drop_reply (GdkDragContext *context,
gboolean ok,
guint32 time)
{
}
void
gdk_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
}
static GdkFilterReturn
gdk_destroy_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
{
#ifdef OLE2_DND
MSG *msg = (MSG *) xev;
if (msg->message == WM_DESTROY)
{
IDropTarget *idtp = (IDropTarget *) data;
GDK_NOTE (DND, g_print ("gdk_destroy_filter: WM_DESTROY: %#x\n", msg->hwnd));
RevokeDragDrop (msg->hwnd);
CoLockObjectExternal (idtp, FALSE, TRUE);
}
#endif
return GDK_FILTER_CONTINUE;
}
void
gdk_window_register_dnd (GdkWindow *window)
{
GdkDrawablePrivate *private = (GdkDrawablePrivate *) window;
#ifdef OLE2_DND
target_drag_context *context;
HRESULT hres;
#endif
g_return_if_fail (window != NULL);
GDK_NOTE (DND, g_print ("gdk_window_register_dnd: %#x\n", private->xwindow));
/* We always claim to accept dropped files, but in fact we might not,
* of course. This function is called in such a way that it cannot know
* whether the window (widget) in question actually accepts files
* (in gtk, data of type text/uri-list) or not.
*/
gdk_window_add_filter (window, gdk_dropfiles_filter, NULL);
DragAcceptFiles (private->xwindow, TRUE);
#ifdef OLE2_DND
/* Register for OLE2 d&d */
context = target_context_new ();
hres = CoLockObjectExternal ((IUnknown *) &context->idt, TRUE, FALSE);
if (!SUCCEEDED (hres))
g_warning ("gdk_window_register_dnd: CoLockObjectExternal failed");
else
{
hres = RegisterDragDrop (private->xwindow, &context->idt);
if (hres == DRAGDROP_E_ALREADYREGISTERED)
{
g_print ("DRAGDROP_E_ALREADYREGISTERED\n");
CoLockObjectExternal ((IUnknown *) &context->idt, FALSE, FALSE);
}
else if (!SUCCEEDED (hres))
g_warning ("gdk_window_register_dnd: RegisterDragDrop failed");
else
{
gdk_window_add_filter (window, gdk_destroy_filter, &context->idt);
}
}
#endif
}
/*************************************************************
* gdk_drag_get_selection:
* Returns the selection atom for the current source window
* arguments:
*
* results:
*************************************************************/
GdkAtom
gdk_drag_get_selection (GdkDragContext *context)
{
if (context->protocol == GDK_DRAG_PROTO_WIN32_DROPFILES)
return gdk_win32_dropfiles_atom;
else if (context->protocol == GDK_DRAG_PROTO_OLE2)
return gdk_ole2_dnd_atom;
else
return GDK_NONE;
}

View File

@ -1,909 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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>
#include "gdkdrawable.h"
#include "gdkprivate.h"
#include "gdkwindow.h"
#include "gdkx.h"
#ifndef G_PI
#define G_PI 3.14159265358979323846
#endif
/* Manipulation of drawables
*/
void
gdk_drawable_set_data (GdkDrawable *drawable,
const gchar *key,
gpointer data,
GDestroyNotify destroy_func)
{
g_dataset_set_data_full (drawable, key, data, destroy_func);
}
void
gdk_drawable_get_data (GdkDrawable *drawable,
const gchar *key)
{
g_dataset_get_data (drawable, key);
}
GdkDrawableType
gdk_drawable_get_type (GdkDrawable *drawable)
{
g_return_val_if_fail (drawable != NULL, (GdkDrawableType) -1);
return GDK_DRAWABLE_TYPE (drawable);
}
void
gdk_drawable_get_size (GdkDrawable *drawable,
gint *width,
gint *height)
{
GdkDrawablePrivate *drawable_private;
g_return_if_fail (drawable != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (width)
*width = drawable_private->width;
if (height)
*height = drawable_private->height;
}
void
gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
GdkColormapPrivate *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
colormap_private = (GdkColormapPrivate*) colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (GDK_IS_WINDOW (drawable))
{
g_return_if_fail (colormap_private->visual !=
((GdkColormapPrivate*)(drawable_private->colormap))->visual);
/* XXX ??? */
GDK_NOTE (MISC, g_print ("gdk_drawable_set_colormap: %#x %#x\n",
GDK_DRAWABLE_XID (drawable),
colormap_private->xcolormap));
}
if (drawable_private->colormap)
gdk_colormap_unref (drawable_private->colormap);
drawable_private->colormap = colormap;
gdk_colormap_ref (drawable_private->colormap);
if (GDK_IS_WINDOW (drawable) &&
drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
gdk_window_add_colormap_windows (drawable);
}
}
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL)
return gdk_colormap_get_system (); /* XXX ??? */
else
return drawable_private->colormap;
}
return NULL;
}
GdkVisual*
gdk_drawable_get_visual (GdkDrawable *drawable)
{
GdkColormap *colormap;
g_return_val_if_fail (drawable != NULL, NULL);
colormap = gdk_drawable_get_colormap (drawable);
return colormap ? gdk_colormap_get_visual (colormap) : NULL;
}
void
gdk_draw_point (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
/* We use LineTo because SetPixel wants the COLORREF directly,
* and doesn't use the current pen, which is what we want.
*/
if (!MoveToEx (hdc, x, y, NULL))
g_warning ("gdk_draw_point: MoveToEx failed");
if (!LineTo (hdc, x + 1, y))
g_warning ("gdk_draw_point: LineTo failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_line (GdkDrawable *drawable,
GdkGC *gc,
gint x1,
gint y1,
gint x2,
gint y2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_line: %#x (%d) +%d+%d..+%d+%d\n",
drawable_private->xwindow, gc_private,
x1, y1, x2, y2));
MoveToEx (hdc, x1, y1, NULL);
if (!LineTo (hdc, x2, y2))
g_warning ("gdk_draw_line: LineTo #1 failed");
/* LineTo doesn't draw the last point, so if we have a pen width of 1,
* we draw the end pixel separately... With wider pens we don't care.
* //HB: But the NT developers don't read their API documentation ...
*/
if (gc_private->pen_width == 1 && windows_version > 0x80000000)
if (!LineTo (hdc, x2 + 1, y2))
g_warning ("gdk_draw_line: LineTo #2 failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
HGDIOBJ oldpen, oldbrush;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n",
drawable_private->xwindow,
gc_private,
(filled ? "fill " : ""),
width, height, x, y));
#if 0
{
HBRUSH hbr = GetCurrentObject (hdc, OBJ_BRUSH);
HPEN hpen = GetCurrentObject (hdc, OBJ_PEN);
LOGBRUSH lbr;
LOGPEN lpen;
GetObject (hbr, sizeof (lbr), &lbr);
GetObject (hpen, sizeof (lpen), &lpen);
g_print ("current brush: style = %s, color = 0x%.08x\n",
(lbr.lbStyle == BS_SOLID ? "SOLID" : "???"),
lbr.lbColor);
g_print ("current pen: style = %s, width = %d, color = 0x%.08x\n",
(lpen.lopnStyle == PS_SOLID ? "SOLID" : "???"),
lpen.lopnWidth,
lpen.lopnColor);
}
#endif
if (filled)
oldpen = SelectObject (hdc, GetStockObject (NULL_PEN));
else
oldbrush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
if (!Rectangle (hdc, x, y, x+width+1, y+height+1))
g_warning ("gdk_draw_rectangle: Rectangle failed");
if (filled)
SelectObject (hdc, oldpen);
else
SelectObject (hdc, oldbrush);
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n",
drawable_private->xwindow,
x, y, width, height, angle1, angle2));
if (width != 0 && height != 0 && angle2 != 0)
{
hdc = gdk_gc_predraw (drawable_private, gc_private);
if (angle2 >= 360*64)
{
nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0;
}
else if (angle2 > 0)
{
/* The 100. is just an arbitrary value */
nXStartArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
nXEndArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
else
{
nXEndArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
nXStartArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
if (filled)
{
GDK_NOTE (MISC, g_print ("...Pie(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
x, y, x+width, y+height,
nXStartArc, nYStartArc,
nXEndArc, nYEndArc));
Pie (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc);
}
else
{
GDK_NOTE (MISC, g_print ("...Arc(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
x, y, x+width, y+height,
nXStartArc, nYStartArc,
nXEndArc, nYEndArc));
Arc (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc);
}
gdk_gc_postdraw (drawable_private, gc_private);
}
}
void
gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
GDK_NOTE (MISC, g_print ("gdk_draw_polygon: %#x (%d) %d\n",
drawable_private->xwindow, gc_private,
npoints));
if (npoints < 2)
return;
hdc = gdk_gc_predraw (drawable_private, gc_private);
pts = g_malloc ((npoints+1) * sizeof (POINT));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
if ((points[0].x != points[npoints-1].x) ||
(points[0].y != points[npoints-1].y))
{
pts[npoints].x = points[0].x;
pts[npoints].y = points[0].y;
npoints++;
}
if (filled)
{
if (!Polygon (hdc, pts, npoints))
g_warning ("gdk_draw_polygon: Polygon failed");
}
else
{
if (!Polyline (hdc, pts, npoints))
g_warning ("gdk_draw_polygon: Polyline failed");
}
g_free (pts);
gdk_gc_postdraw (drawable_private, gc_private);
}
typedef struct
{
gint x, y;
HDC hdc;
} gdk_draw_text_arg;
/* gdk_draw_string
*/
void
gdk_draw_string (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *string)
{
gdk_draw_text (drawable, font, gc, x, y, string, strlen (string));
}
static void
gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
const wchar_t *wcstr,
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->xfont)) == NULL)
{
g_warning ("gdk_draw_text_handler: SelectObject failed");
return;
}
if (!TextOutW (argp->hdc, argp->x, argp->y, wcstr, wclen))
g_warning ("gdk_draw_text_handler: TextOutW failed");
GetTextExtentPoint32W (argp->hdc, wcstr, wclen, &size);
argp->x += size.cx;
SelectObject (argp->hdc, oldfont);
}
/* gdk_draw_text
*
*/
void
gdk_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
wchar_t *wcstr;
gint wlen;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
drawable_private->xwindow,
x, y,
(text_length > 10 ? 10 : text_length),
text, text_length));
wcstr = g_new (wchar_t, text_length);
if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1)
g_warning ("gdk_draw_text: gdk_nmbstowchar_ts failed");
else
gdk_wchar_text_handle (font, wcstr, wlen,
gdk_draw_text_handler, &arg);
g_free (wcstr);
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
gint i, wlen;
wchar_t *wcstr;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
drawable_private->xwindow,
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_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkDrawablePrivate *src_private;
GdkGCPrivate *gc_private;
HDC hdc;
HDC srcdc;
HGDIOBJ hgdiobj;
HRGN src_rgn, draw_rgn, outside_rgn;
RECT r;
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
src_private = (GdkDrawablePrivate*) src;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = src_private->width; /* Or should we subtract xsrc? */
if (height == -1)
height = src_private->height; /* Ditto? */
GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x "
"src: %#x %dx%d@+%d+%d"
" dest: %#x @+%d+%d\n",
drawable_private->xwindow,
src_private->xwindow,
width, height, xsrc, ysrc,
drawable_private->xwindow, xdest, ydest));
hdc = gdk_gc_predraw (drawable_private, gc_private);
src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1);
draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
SetRectEmpty (&r);
outside_rgn = CreateRectRgnIndirect (&r);
if (drawable_private->window_type != GDK_DRAWABLE_PIXMAP)
{
/* If we are drawing on a window, calculate the region that is
* outside the source pixmap, and invalidate that, causing it to
* be cleared. XXX
*/
if (CombineRgn (outside_rgn, draw_rgn, src_rgn, RGN_DIFF) != NULLREGION)
{
OffsetRgn (outside_rgn, xdest, ydest);
GDK_NOTE (MISC, (GetRgnBox (outside_rgn, &r),
g_print ("...calling InvalidateRgn, "
"bbox: %dx%d@+%d+%d\n",
r.right - r.left - 1, r.bottom - r.top - 1,
r.left, r.top)));
InvalidateRgn (drawable_private->xwindow, outside_rgn, TRUE);
}
}
#if 1 /* Don't know if this is necessary */
if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
g_warning ("gdk_draw_pixmap: 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 (MISC, g_print ("... restricted to src: %dx%d@+%d+%d, "
"dest: @+%d+%d\n",
width, height, xsrc, ysrc,
xdest, ydest));
}
#endif
DeleteObject (src_rgn);
DeleteObject (draw_rgn);
DeleteObject (outside_rgn);
/* Strangely enough, this function is called also to bitblt
* from a window.
*/
if (src_private->window_type == GDK_DRAWABLE_PIXMAP)
{
if ((srcdc = CreateCompatibleDC (hdc)) == NULL)
g_warning ("gdk_draw_pixmap: CreateCompatibleDC failed");
if ((hgdiobj = SelectObject (srcdc, src_private->xwindow)) == NULL)
g_warning ("gdk_draw_pixmap: SelectObject #1 failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_draw_pixmap: BitBlt failed");
if ((SelectObject (srcdc, hgdiobj) == NULL))
g_warning ("gdk_draw_pixmap: SelectObject #2 failed");
if (!DeleteDC (srcdc))
g_warning ("gdk_draw_pixmap: DeleteDC failed");
}
else
{
if (drawable_private->xwindow == src_private->xwindow)
{
/* Blitting inside a window, use ScrollDC */
RECT scrollRect, clipRect, emptyRect;
HRGN updateRgn;
scrollRect.left = MIN (xsrc, xdest);
scrollRect.top = MIN (ysrc, ydest);
scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1);
scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1);
clipRect.left = xdest;
clipRect.top = ydest;
clipRect.right = xdest + width + 1;
clipRect.bottom = ydest + height + 1;
SetRectEmpty (&emptyRect);
updateRgn = CreateRectRgnIndirect (&emptyRect);
if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc,
&scrollRect, &clipRect,
updateRgn, NULL))
g_warning ("gdk_draw_pixmap: ScrollDC failed");
if (!InvalidateRgn (drawable_private->xwindow, updateRgn, FALSE))
g_warning ("gdk_draw_pixmap: InvalidateRgn failed");
if (!UpdateWindow (drawable_private->xwindow))
g_warning ("gdk_draw_pixmap: UpdateWindow failed");
}
else
{
if ((srcdc = GetDC (src_private->xwindow)) == NULL)
g_warning ("gdk_draw_pixmap: GetDC failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_draw_pixmap: BitBlt failed");
ReleaseDC (src_private->xwindow, srcdc);
}
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_image (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkImagePrivate *image_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
image_private = (GdkImagePrivate*) image;
g_return_if_fail (image_private->image_put != NULL);
if (width == -1)
width = image->width;
if (height == -1)
height = image->height;
(* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
xdest, ydest, width, height);
}
void
gdk_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail ((points != NULL) && (npoints > 0));
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x destdc: (%d) %#x "
"npoints: %d\n",
drawable_private->xwindow, gc_private, hdc,
npoints));
for (i = 0; i < npoints; i++)
{
if (!MoveToEx (hdc, points[i].x, points[i].y, NULL))
g_warning ("gdk_draw_points: MoveToEx failed");
if (!LineTo (hdc, points[i].x + 1, points[i].y))
g_warning ("gdk_draw_points: LineTo failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
if (nsegs <= 0)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (segs != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
for (i = 0; i < nsegs; i++)
{
if (!MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL))
g_warning ("gdk_draw_segments: MoveToEx failed");
if (!LineTo (hdc, segs[i].x2, segs[i].y2))
g_warning ("gdk_draw_segments: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2))
g_warning ("gdk_draw_segments: LineTo #2 failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
int i;
if (npoints < 2)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (points != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
#if 1
pts = g_malloc (npoints * sizeof (POINT));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
if (!Polyline (hdc, pts, npoints))
g_warning ("gdk_draw_lines: Polyline(,,%d) failed", npoints);
g_free (pts);
/* Draw end pixel */
if (gc_private->pen_width == 1)
{
MoveToEx (hdc, points[npoints-1].x, points[npoints-1].y, NULL);
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
g_warning ("gdk_draw_lines: LineTo failed");
}
#else
MoveToEx (hdc, points[0].x, points[0].y, NULL);
for (i = 1; i < npoints; i++)
if (!LineTo (hdc, points[i].x, points[i].y))
g_warning ("gdk_draw_lines: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
g_warning ("gdk_draw_lines: LineTo #2 failed");
#endif
gdk_gc_postdraw (drawable_private, gc_private);
}

View File

@ -1,909 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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>
#include "gdkdrawable.h"
#include "gdkprivate.h"
#include "gdkwindow.h"
#include "gdkx.h"
#ifndef G_PI
#define G_PI 3.14159265358979323846
#endif
/* Manipulation of drawables
*/
void
gdk_drawable_set_data (GdkDrawable *drawable,
const gchar *key,
gpointer data,
GDestroyNotify destroy_func)
{
g_dataset_set_data_full (drawable, key, data, destroy_func);
}
void
gdk_drawable_get_data (GdkDrawable *drawable,
const gchar *key)
{
g_dataset_get_data (drawable, key);
}
GdkDrawableType
gdk_drawable_get_type (GdkDrawable *drawable)
{
g_return_val_if_fail (drawable != NULL, (GdkDrawableType) -1);
return GDK_DRAWABLE_TYPE (drawable);
}
void
gdk_drawable_get_size (GdkDrawable *drawable,
gint *width,
gint *height)
{
GdkDrawablePrivate *drawable_private;
g_return_if_fail (drawable != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (width)
*width = drawable_private->width;
if (height)
*height = drawable_private->height;
}
void
gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
GdkColormapPrivate *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
colormap_private = (GdkColormapPrivate*) colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (GDK_IS_WINDOW (drawable))
{
g_return_if_fail (colormap_private->visual !=
((GdkColormapPrivate*)(drawable_private->colormap))->visual);
/* XXX ??? */
GDK_NOTE (MISC, g_print ("gdk_drawable_set_colormap: %#x %#x\n",
GDK_DRAWABLE_XID (drawable),
colormap_private->xcolormap));
}
if (drawable_private->colormap)
gdk_colormap_unref (drawable_private->colormap);
drawable_private->colormap = colormap;
gdk_colormap_ref (drawable_private->colormap);
if (GDK_IS_WINDOW (drawable) &&
drawable_private->window_type != GDK_WINDOW_TOPLEVEL)
gdk_window_add_colormap_windows (drawable);
}
}
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
GdkDrawablePrivate *drawable_private;
g_return_val_if_fail (drawable != NULL, NULL);
drawable_private = (GdkDrawablePrivate*) drawable;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (drawable_private->colormap == NULL)
return gdk_colormap_get_system (); /* XXX ??? */
else
return drawable_private->colormap;
}
return NULL;
}
GdkVisual*
gdk_drawable_get_visual (GdkDrawable *drawable)
{
GdkColormap *colormap;
g_return_val_if_fail (drawable != NULL, NULL);
colormap = gdk_drawable_get_colormap (drawable);
return colormap ? gdk_colormap_get_visual (colormap) : NULL;
}
void
gdk_draw_point (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
/* We use LineTo because SetPixel wants the COLORREF directly,
* and doesn't use the current pen, which is what we want.
*/
if (!MoveToEx (hdc, x, y, NULL))
g_warning ("gdk_draw_point: MoveToEx failed");
if (!LineTo (hdc, x + 1, y))
g_warning ("gdk_draw_point: LineTo failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_line (GdkDrawable *drawable,
GdkGC *gc,
gint x1,
gint y1,
gint x2,
gint y2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_line: %#x (%d) +%d+%d..+%d+%d\n",
drawable_private->xwindow, gc_private,
x1, y1, x2, y2));
MoveToEx (hdc, x1, y1, NULL);
if (!LineTo (hdc, x2, y2))
g_warning ("gdk_draw_line: LineTo #1 failed");
/* LineTo doesn't draw the last point, so if we have a pen width of 1,
* we draw the end pixel separately... With wider pens we don't care.
* //HB: But the NT developers don't read their API documentation ...
*/
if (gc_private->pen_width == 1 && windows_version > 0x80000000)
if (!LineTo (hdc, x2 + 1, y2))
g_warning ("gdk_draw_line: LineTo #2 failed");
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_rectangle (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
HGDIOBJ oldpen, oldbrush;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_rectangle: %#x (%d) %s%dx%d@+%d+%d\n",
drawable_private->xwindow,
gc_private,
(filled ? "fill " : ""),
width, height, x, y));
#if 0
{
HBRUSH hbr = GetCurrentObject (hdc, OBJ_BRUSH);
HPEN hpen = GetCurrentObject (hdc, OBJ_PEN);
LOGBRUSH lbr;
LOGPEN lpen;
GetObject (hbr, sizeof (lbr), &lbr);
GetObject (hpen, sizeof (lpen), &lpen);
g_print ("current brush: style = %s, color = 0x%.08x\n",
(lbr.lbStyle == BS_SOLID ? "SOLID" : "???"),
lbr.lbColor);
g_print ("current pen: style = %s, width = %d, color = 0x%.08x\n",
(lpen.lopnStyle == PS_SOLID ? "SOLID" : "???"),
lpen.lopnWidth,
lpen.lopnColor);
}
#endif
if (filled)
oldpen = SelectObject (hdc, GetStockObject (NULL_PEN));
else
oldbrush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
if (!Rectangle (hdc, x, y, x+width+1, y+height+1))
g_warning ("gdk_draw_rectangle: Rectangle failed");
if (filled)
SelectObject (hdc, oldpen);
else
SelectObject (hdc, oldbrush);
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_arc (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
gint x,
gint y,
gint width,
gint height,
gint angle1,
gint angle2)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int nXStartArc, nYStartArc, nXEndArc, nYEndArc;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = drawable_private->width;
if (height == -1)
height = drawable_private->height;
GDK_NOTE (MISC, g_print ("gdk_draw_arc: %#x %d,%d,%d,%d %d %d\n",
drawable_private->xwindow,
x, y, width, height, angle1, angle2));
if (width != 0 && height != 0 && angle2 != 0)
{
hdc = gdk_gc_predraw (drawable_private, gc_private);
if (angle2 >= 360*64)
{
nXStartArc = nYStartArc = nXEndArc = nYEndArc = 0;
}
else if (angle2 > 0)
{
/* The 100. is just an arbitrary value */
nXStartArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
nXEndArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
else
{
nXEndArc = x + width/2 + 100. * cos(angle1/64.*2.*G_PI/360.);
nYEndArc = y + height/2 + -100. * sin(angle1/64.*2.*G_PI/360.);
nXStartArc = x + width/2 + 100. * cos((angle1+angle2)/64.*2.*G_PI/360.);
nYStartArc = y + height/2 + -100. * sin((angle1+angle2)/64.*2.*G_PI/360.);
}
if (filled)
{
GDK_NOTE (MISC, g_print ("...Pie(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
x, y, x+width, y+height,
nXStartArc, nYStartArc,
nXEndArc, nYEndArc));
Pie (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc);
}
else
{
GDK_NOTE (MISC, g_print ("...Arc(hdc,%d,%d,%d,%d,%d,%d,%d,%d)\n",
x, y, x+width, y+height,
nXStartArc, nYStartArc,
nXEndArc, nYEndArc));
Arc (hdc, x, y, x+width, y+height,
nXStartArc, nYStartArc, nXEndArc, nYEndArc);
}
gdk_gc_postdraw (drawable_private, gc_private);
}
}
void
gdk_draw_polygon (GdkDrawable *drawable,
GdkGC *gc,
gint filled,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
GDK_NOTE (MISC, g_print ("gdk_draw_polygon: %#x (%d) %d\n",
drawable_private->xwindow, gc_private,
npoints));
if (npoints < 2)
return;
hdc = gdk_gc_predraw (drawable_private, gc_private);
pts = g_malloc ((npoints+1) * sizeof (POINT));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
if ((points[0].x != points[npoints-1].x) ||
(points[0].y != points[npoints-1].y))
{
pts[npoints].x = points[0].x;
pts[npoints].y = points[0].y;
npoints++;
}
if (filled)
{
if (!Polygon (hdc, pts, npoints))
g_warning ("gdk_draw_polygon: Polygon failed");
}
else
{
if (!Polyline (hdc, pts, npoints))
g_warning ("gdk_draw_polygon: Polyline failed");
}
g_free (pts);
gdk_gc_postdraw (drawable_private, gc_private);
}
typedef struct
{
gint x, y;
HDC hdc;
} gdk_draw_text_arg;
/* gdk_draw_string
*/
void
gdk_draw_string (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *string)
{
gdk_draw_text (drawable, font, gc, x, y, string, strlen (string));
}
static void
gdk_draw_text_handler (GdkWin32SingleFont *singlefont,
const wchar_t *wcstr,
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->xfont)) == NULL)
{
g_warning ("gdk_draw_text_handler: SelectObject failed");
return;
}
if (!TextOutW (argp->hdc, argp->x, argp->y, wcstr, wclen))
g_warning ("gdk_draw_text_handler: TextOutW failed");
GetTextExtentPoint32W (argp->hdc, wcstr, wclen, &size);
argp->x += size.cx;
SelectObject (argp->hdc, oldfont);
}
/* gdk_draw_text
*
*/
void
gdk_draw_text (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const gchar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
wchar_t *wcstr;
gint wlen;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text: %#x (%d,%d) \"%.*s\" (len %d)\n",
drawable_private->xwindow,
x, y,
(text_length > 10 ? 10 : text_length),
text, text_length));
wcstr = g_new (wchar_t, text_length);
if ((wlen = gdk_nmbstowchar_ts (wcstr, text, text_length, text_length)) == -1)
g_warning ("gdk_draw_text: gdk_nmbstowchar_ts failed");
else
gdk_wchar_text_handle (font, wcstr, wlen,
gdk_draw_text_handler, &arg);
g_free (wcstr);
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_text_wc (GdkDrawable *drawable,
GdkFont *font,
GdkGC *gc,
gint x,
gint y,
const GdkWChar *text,
gint text_length)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
gint i, wlen;
wchar_t *wcstr;
gdk_draw_text_arg arg;
g_return_if_fail (drawable != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (gc != NULL);
g_return_if_fail (text != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
if (text_length == 0)
return;
g_assert (font->type == GDK_FONT_FONT || font->type == GDK_FONT_FONTSET);
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
arg.x = x;
arg.y = y;
arg.hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_text_wc: %#x (%d,%d) len: %d\n",
drawable_private->xwindow,
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_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_pixmap (GdkDrawable *drawable,
GdkGC *gc,
GdkPixmap *src,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkDrawablePrivate *src_private;
GdkGCPrivate *gc_private;
HDC hdc;
HDC srcdc;
HGDIOBJ hgdiobj;
HRGN src_rgn, draw_rgn, outside_rgn;
RECT r;
g_return_if_fail (drawable != NULL);
g_return_if_fail (src != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable) || GDK_DRAWABLE_DESTROYED (src))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
src_private = (GdkDrawablePrivate*) src;
gc_private = (GdkGCPrivate*) gc;
if (width == -1)
width = src_private->width; /* Or should we subtract xsrc? */
if (height == -1)
height = src_private->height; /* Ditto? */
GDK_NOTE (MISC, g_print ("gdk_draw_pixmap: dest: %#x "
"src: %#x %dx%d@+%d+%d"
" dest: %#x @+%d+%d\n",
drawable_private->xwindow,
src_private->xwindow,
width, height, xsrc, ysrc,
drawable_private->xwindow, xdest, ydest));
hdc = gdk_gc_predraw (drawable_private, gc_private);
src_rgn = CreateRectRgn (0, 0, src_private->width + 1, src_private->height + 1);
draw_rgn = CreateRectRgn (xsrc, ysrc, xsrc + width + 1, ysrc + height + 1);
SetRectEmpty (&r);
outside_rgn = CreateRectRgnIndirect (&r);
if (drawable_private->window_type != GDK_DRAWABLE_PIXMAP)
{
/* If we are drawing on a window, calculate the region that is
* outside the source pixmap, and invalidate that, causing it to
* be cleared. XXX
*/
if (CombineRgn (outside_rgn, draw_rgn, src_rgn, RGN_DIFF) != NULLREGION)
{
OffsetRgn (outside_rgn, xdest, ydest);
GDK_NOTE (MISC, (GetRgnBox (outside_rgn, &r),
g_print ("...calling InvalidateRgn, "
"bbox: %dx%d@+%d+%d\n",
r.right - r.left - 1, r.bottom - r.top - 1,
r.left, r.top)));
InvalidateRgn (drawable_private->xwindow, outside_rgn, TRUE);
}
}
#if 1 /* Don't know if this is necessary */
if (CombineRgn (draw_rgn, draw_rgn, src_rgn, RGN_AND) == COMPLEXREGION)
g_warning ("gdk_draw_pixmap: 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 (MISC, g_print ("... restricted to src: %dx%d@+%d+%d, "
"dest: @+%d+%d\n",
width, height, xsrc, ysrc,
xdest, ydest));
}
#endif
DeleteObject (src_rgn);
DeleteObject (draw_rgn);
DeleteObject (outside_rgn);
/* Strangely enough, this function is called also to bitblt
* from a window.
*/
if (src_private->window_type == GDK_DRAWABLE_PIXMAP)
{
if ((srcdc = CreateCompatibleDC (hdc)) == NULL)
g_warning ("gdk_draw_pixmap: CreateCompatibleDC failed");
if ((hgdiobj = SelectObject (srcdc, src_private->xwindow)) == NULL)
g_warning ("gdk_draw_pixmap: SelectObject #1 failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_draw_pixmap: BitBlt failed");
if ((SelectObject (srcdc, hgdiobj) == NULL))
g_warning ("gdk_draw_pixmap: SelectObject #2 failed");
if (!DeleteDC (srcdc))
g_warning ("gdk_draw_pixmap: DeleteDC failed");
}
else
{
if (drawable_private->xwindow == src_private->xwindow)
{
/* Blitting inside a window, use ScrollDC */
RECT scrollRect, clipRect, emptyRect;
HRGN updateRgn;
scrollRect.left = MIN (xsrc, xdest);
scrollRect.top = MIN (ysrc, ydest);
scrollRect.right = MAX (xsrc + width + 1, xdest + width + 1);
scrollRect.bottom = MAX (ysrc + height + 1, ydest + height + 1);
clipRect.left = xdest;
clipRect.top = ydest;
clipRect.right = xdest + width + 1;
clipRect.bottom = ydest + height + 1;
SetRectEmpty (&emptyRect);
updateRgn = CreateRectRgnIndirect (&emptyRect);
if (!ScrollDC (hdc, xdest - xsrc, ydest - ysrc,
&scrollRect, &clipRect,
updateRgn, NULL))
g_warning ("gdk_draw_pixmap: ScrollDC failed");
if (!InvalidateRgn (drawable_private->xwindow, updateRgn, FALSE))
g_warning ("gdk_draw_pixmap: InvalidateRgn failed");
if (!UpdateWindow (drawable_private->xwindow))
g_warning ("gdk_draw_pixmap: UpdateWindow failed");
}
else
{
if ((srcdc = GetDC (src_private->xwindow)) == NULL)
g_warning ("gdk_draw_pixmap: GetDC failed");
if (!BitBlt (hdc, xdest, ydest, width, height,
srcdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_draw_pixmap: BitBlt failed");
ReleaseDC (src_private->xwindow, srcdc);
}
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_image (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkImagePrivate *image_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
image_private = (GdkImagePrivate*) image;
g_return_if_fail (image_private->image_put != NULL);
if (width == -1)
width = image->width;
if (height == -1)
height = image->height;
(* image_private->image_put) (drawable, gc, image, xsrc, ysrc,
xdest, ydest, width, height);
}
void
gdk_draw_points (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
g_return_if_fail (drawable != NULL);
g_return_if_fail ((points != NULL) && (npoints > 0));
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
GDK_NOTE (MISC, g_print ("gdk_draw_points: %#x destdc: (%d) %#x "
"npoints: %d\n",
drawable_private->xwindow, gc_private, hdc,
npoints));
for (i = 0; i < npoints; i++)
{
if (!MoveToEx (hdc, points[i].x, points[i].y, NULL))
g_warning ("gdk_draw_points: MoveToEx failed");
if (!LineTo (hdc, points[i].x + 1, points[i].y))
g_warning ("gdk_draw_points: LineTo failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_segments (GdkDrawable *drawable,
GdkGC *gc,
GdkSegment *segs,
gint nsegs)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
int i;
if (nsegs <= 0)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (segs != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
for (i = 0; i < nsegs; i++)
{
if (!MoveToEx (hdc, segs[i].x1, segs[i].y1, NULL))
g_warning ("gdk_draw_segments: MoveToEx failed");
if (!LineTo (hdc, segs[i].x2, segs[i].y2))
g_warning ("gdk_draw_segments: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (!LineTo (hdc, segs[i].x2 + 1, segs[i].y2))
g_warning ("gdk_draw_segments: LineTo #2 failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}
void
gdk_draw_lines (GdkDrawable *drawable,
GdkGC *gc,
GdkPoint *points,
gint npoints)
{
GdkDrawablePrivate *drawable_private;
GdkGCPrivate *gc_private;
HDC hdc;
POINT *pts;
int i;
if (npoints < 2)
return;
g_return_if_fail (drawable != NULL);
g_return_if_fail (points != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
hdc = gdk_gc_predraw (drawable_private, gc_private);
#if 1
pts = g_malloc (npoints * sizeof (POINT));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
if (!Polyline (hdc, pts, npoints))
g_warning ("gdk_draw_lines: Polyline(,,%d) failed", npoints);
g_free (pts);
/* Draw end pixel */
if (gc_private->pen_width == 1)
{
MoveToEx (hdc, points[npoints-1].x, points[npoints-1].y, NULL);
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
g_warning ("gdk_draw_lines: LineTo failed");
}
#else
MoveToEx (hdc, points[0].x, points[0].y, NULL);
for (i = 1; i < npoints; i++)
if (!LineTo (hdc, points[i].x, points[i].y))
g_warning ("gdk_draw_lines: LineTo #1 failed");
/* Draw end pixel */
if (gc_private->pen_width == 1)
if (!LineTo (hdc, points[npoints-1].x + 1, points[npoints-1].y))
g_warning ("gdk_draw_lines: LineTo #2 failed");
#endif
gdk_gc_postdraw (drawable_private, gc_private);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdktypes.h"
#include "gdkprivate.h"
guint gdk_debug_flags = 0;
HWND gdk_root_window = NULL;
HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent = NULL;
HDC gdk_DC;
HINSTANCE gdk_DLLInstance;
HINSTANCE gdk_ProgInstance;
UINT gdk_selection_notify_msg;
UINT gdk_selection_request_msg;
UINT gdk_selection_clear_msg;
GdkAtom gdk_clipboard_atom;
GdkAtom gdk_win32_dropfiles_atom;
GdkAtom gdk_ole2_dnd_atom;
Atom gdk_selection_property;
gchar *gdk_progclass = NULL;
gint gdk_error_code;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GMutex *gdk_threads_mutex = NULL;
DWORD windows_version = 0;

View File

@ -1,51 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdktypes.h"
#include "gdkprivate.h"
guint gdk_debug_flags = 0;
HWND gdk_root_window = NULL;
HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent = NULL;
HDC gdk_DC;
HINSTANCE gdk_DLLInstance;
HINSTANCE gdk_ProgInstance;
UINT gdk_selection_notify_msg;
UINT gdk_selection_request_msg;
UINT gdk_selection_clear_msg;
GdkAtom gdk_clipboard_atom;
GdkAtom gdk_win32_dropfiles_atom;
GdkAtom gdk_ole2_dnd_atom;
Atom gdk_selection_property;
gchar *gdk_progclass = NULL;
gint gdk_error_code;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GMutex *gdk_threads_mutex = NULL;
DWORD windows_version = 0;

View File

@ -1,394 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "gdkim.h"
#include "gdkpixmap.h"
#include "gdkprivate.h"
#include "gdki18n.h"
#include "gdkx.h"
/*
*--------------------------------------------------------------
* gdk_set_locale
*
* Arguments:
*
* Results:
*
* Side effects:
*
*--------------------------------------------------------------
*/
gchar*
gdk_set_locale (void)
{
gchar *current_locale;
if (!setlocale (LC_ALL,""))
g_warning ("locale not supported by C library");
current_locale = setlocale (LC_ALL, NULL);
return current_locale;
}
void
gdk_im_begin (GdkIC *ic, GdkWindow* window)
{
}
void
gdk_im_end (void)
{
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
gint
gdk_im_ready (void)
{
return FALSE;
}
GdkIC *
gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
{
return NULL;
}
void
gdk_ic_destroy (GdkIC *ic)
{
}
GdkIMStyle
gdk_ic_get_style (GdkIC *ic)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
void
gdk_ic_set_values (GdkIC *ic, ...)
{
}
void
gdk_ic_get_values (GdkIC *ic, ...)
{
}
GdkICAttributesType
gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
{
return 0;
}
GdkICAttributesType
gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
{
return 0;
}
GdkEventMask
gdk_ic_get_events (GdkIC *ic)
{
return 0;
}
/*
* gdk_wcstombs
*
* Returns a multi-byte string converted from the specified array
* of wide characters. The string is newly allocated. The array of
* wide characters must be null-terminated. If the conversion is
* failed, it returns NULL.
*
* On Win32, we always use UTF-8.
*/
gchar *
gdk_wcstombs (const GdkWChar *src)
{
gint len;
const GdkWChar *wcp;
guchar *mbstr, *bp;
wcp = src;
len = 0;
while (*wcp)
{
const GdkWChar c = *wcp++;
if (c < 0x80)
len += 1;
else if (c < 0x800)
len += 2;
else if (c < 0x10000)
len += 3;
else if (c < 0x200000)
len += 4;
else if (c < 0x4000000)
len += 5;
else
len += 6;
}
mbstr = g_malloc (len + 1);
wcp = src;
bp = mbstr;
while (*wcp)
{
int first;
int i;
GdkWChar c = *wcp++;
if (c < 0x80)
{
first = 0;
len = 1;
}
else if (c < 0x800)
{
first = 0xc0;
len = 2;
}
else if (c < 0x10000)
{
first = 0xe0;
len = 3;
}
else if (c < 0x200000)
{
first = 0xf0;
len = 4;
}
else if (c < 0x4000000)
{
first = 0xf8;
len = 5;
}
else
{
first = 0xfc;
len = 6;
}
/* Woo-hoo! */
switch (len)
{
case 6: bp[5] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 5: bp[4] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 4: bp[3] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 3: bp[2] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 2: bp[1] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 1: bp[0] = c | first;
}
bp += len;
}
*bp = 0;
return mbstr;
}
/*
* gdk_mbstowcs
*
* Converts the specified string into GDK wide characters, and,
* returns the number of wide characters written. The string 'src'
* must be null-terminated. If the conversion is failed, it returns
* -1.
*
* On Win32, thr string is assumed to be in UTF-8. Also note that
* GdkWChar is 32 bits, while wchar_t, and the wide characters the
* Windows API uses, are 16 bits!
*/
/* First a helper function for not zero-terminated strings */
gint
gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max)
{
guchar *cp, *end;
gint n;
cp = (guchar *) src;
end = cp + src_len;
n = 0;
while (cp != end && dest != dest + dest_max)
{
gint i, mask = 0, len;
guchar c = *cp;
if (c < 0x80)
{
len = 1;
mask = 0x7f;
}
else if ((c & 0xe0) == 0xc0)
{
len = 2;
mask = 0x1f;
}
else if ((c & 0xf0) == 0xe0)
{
len = 3;
mask = 0x0f;
}
else if ((c & 0xf8) == 0xf0)
{
len = 4;
mask = 0x07;
}
else if ((c & 0xfc) == 0xf8)
{
len = 5;
mask = 0x03;
}
else if ((c & 0xfc) == 0xfc)
{
len = 6;
mask = 0x01;
}
else
return -1;
if (cp + len > end)
return -1;
*dest = (cp[0] & mask);
for (i = 1; i < len; i++)
{
if ((cp[i] & 0xc0) != 0x80)
return -1;
*dest <<= 6;
*dest |= (cp[i] & 0x3f);
}
if (*dest == -1)
return -1;
cp += len;
dest++;
n++;
}
if (cp != end)
return -1;
return n;
}
gint
gdk_mbstowcs (GdkWChar *dest,
const gchar *src,
gint dest_max)
{
return gdk_nmbstowcs (dest, src, strlen (src), dest_max);
}
/* A version that converts to wchar_t wide chars */
gint
gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max)
{
wchar_t *wcp;
guchar *cp, *end;
gint n;
wcp = dest;
cp = (guchar *) src;
end = cp + src_len;
n = 0;
while (cp != end && wcp != dest + dest_max)
{
gint i, mask = 0, len;
guchar c = *cp;
if (c < 0x80)
{
len = 1;
mask = 0x7f;
}
else if ((c & 0xe0) == 0xc0)
{
len = 2;
mask = 0x1f;
}
else if ((c & 0xf0) == 0xe0)
{
len = 3;
mask = 0x0f;
}
else /* Other lengths are not possible with 16-bit wchar_t! */
return -1;
if (cp + len > end)
return -1;
*wcp = (cp[0] & mask);
for (i = 1; i < len; i++)
{
if ((cp[i] & 0xc0) != 0x80)
return -1;
*wcp <<= 6;
*wcp |= (cp[i] & 0x3f);
}
if (*wcp == 0xFFFF)
return -1;
cp += len;
wcp++;
n++;
}
if (cp != end)
return -1;
return n;
}

View File

@ -1,394 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "gdkim.h"
#include "gdkpixmap.h"
#include "gdkprivate.h"
#include "gdki18n.h"
#include "gdkx.h"
/*
*--------------------------------------------------------------
* gdk_set_locale
*
* Arguments:
*
* Results:
*
* Side effects:
*
*--------------------------------------------------------------
*/
gchar*
gdk_set_locale (void)
{
gchar *current_locale;
if (!setlocale (LC_ALL,""))
g_warning ("locale not supported by C library");
current_locale = setlocale (LC_ALL, NULL);
return current_locale;
}
void
gdk_im_begin (GdkIC *ic, GdkWindow* window)
{
}
void
gdk_im_end (void)
{
}
GdkIMStyle
gdk_im_decide_style (GdkIMStyle supported_style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
GdkIMStyle
gdk_im_set_best_style (GdkIMStyle style)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
gint
gdk_im_ready (void)
{
return FALSE;
}
GdkIC *
gdk_ic_new (GdkICAttr *attr, GdkICAttributesType mask)
{
return NULL;
}
void
gdk_ic_destroy (GdkIC *ic)
{
}
GdkIMStyle
gdk_ic_get_style (GdkIC *ic)
{
return GDK_IM_PREEDIT_NONE | GDK_IM_STATUS_NONE;
}
void
gdk_ic_set_values (GdkIC *ic, ...)
{
}
void
gdk_ic_get_values (GdkIC *ic, ...)
{
}
GdkICAttributesType
gdk_ic_set_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
{
return 0;
}
GdkICAttributesType
gdk_ic_get_attr (GdkIC *ic, GdkICAttr *attr, GdkICAttributesType mask)
{
return 0;
}
GdkEventMask
gdk_ic_get_events (GdkIC *ic)
{
return 0;
}
/*
* gdk_wcstombs
*
* Returns a multi-byte string converted from the specified array
* of wide characters. The string is newly allocated. The array of
* wide characters must be null-terminated. If the conversion is
* failed, it returns NULL.
*
* On Win32, we always use UTF-8.
*/
gchar *
gdk_wcstombs (const GdkWChar *src)
{
gint len;
const GdkWChar *wcp;
guchar *mbstr, *bp;
wcp = src;
len = 0;
while (*wcp)
{
const GdkWChar c = *wcp++;
if (c < 0x80)
len += 1;
else if (c < 0x800)
len += 2;
else if (c < 0x10000)
len += 3;
else if (c < 0x200000)
len += 4;
else if (c < 0x4000000)
len += 5;
else
len += 6;
}
mbstr = g_malloc (len + 1);
wcp = src;
bp = mbstr;
while (*wcp)
{
int first;
int i;
GdkWChar c = *wcp++;
if (c < 0x80)
{
first = 0;
len = 1;
}
else if (c < 0x800)
{
first = 0xc0;
len = 2;
}
else if (c < 0x10000)
{
first = 0xe0;
len = 3;
}
else if (c < 0x200000)
{
first = 0xf0;
len = 4;
}
else if (c < 0x4000000)
{
first = 0xf8;
len = 5;
}
else
{
first = 0xfc;
len = 6;
}
/* Woo-hoo! */
switch (len)
{
case 6: bp[5] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 5: bp[4] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 4: bp[3] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 3: bp[2] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 2: bp[1] = (c & 0x3f) | 0x80; c >>= 6; /* Fall through */
case 1: bp[0] = c | first;
}
bp += len;
}
*bp = 0;
return mbstr;
}
/*
* gdk_mbstowcs
*
* Converts the specified string into GDK wide characters, and,
* returns the number of wide characters written. The string 'src'
* must be null-terminated. If the conversion is failed, it returns
* -1.
*
* On Win32, thr string is assumed to be in UTF-8. Also note that
* GdkWChar is 32 bits, while wchar_t, and the wide characters the
* Windows API uses, are 16 bits!
*/
/* First a helper function for not zero-terminated strings */
gint
gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max)
{
guchar *cp, *end;
gint n;
cp = (guchar *) src;
end = cp + src_len;
n = 0;
while (cp != end && dest != dest + dest_max)
{
gint i, mask = 0, len;
guchar c = *cp;
if (c < 0x80)
{
len = 1;
mask = 0x7f;
}
else if ((c & 0xe0) == 0xc0)
{
len = 2;
mask = 0x1f;
}
else if ((c & 0xf0) == 0xe0)
{
len = 3;
mask = 0x0f;
}
else if ((c & 0xf8) == 0xf0)
{
len = 4;
mask = 0x07;
}
else if ((c & 0xfc) == 0xf8)
{
len = 5;
mask = 0x03;
}
else if ((c & 0xfc) == 0xfc)
{
len = 6;
mask = 0x01;
}
else
return -1;
if (cp + len > end)
return -1;
*dest = (cp[0] & mask);
for (i = 1; i < len; i++)
{
if ((cp[i] & 0xc0) != 0x80)
return -1;
*dest <<= 6;
*dest |= (cp[i] & 0x3f);
}
if (*dest == -1)
return -1;
cp += len;
dest++;
n++;
}
if (cp != end)
return -1;
return n;
}
gint
gdk_mbstowcs (GdkWChar *dest,
const gchar *src,
gint dest_max)
{
return gdk_nmbstowcs (dest, src, strlen (src), dest_max);
}
/* A version that converts to wchar_t wide chars */
gint
gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max)
{
wchar_t *wcp;
guchar *cp, *end;
gint n;
wcp = dest;
cp = (guchar *) src;
end = cp + src_len;
n = 0;
while (cp != end && wcp != dest + dest_max)
{
gint i, mask = 0, len;
guchar c = *cp;
if (c < 0x80)
{
len = 1;
mask = 0x7f;
}
else if ((c & 0xe0) == 0xc0)
{
len = 2;
mask = 0x1f;
}
else if ((c & 0xf0) == 0xe0)
{
len = 3;
mask = 0x0f;
}
else /* Other lengths are not possible with 16-bit wchar_t! */
return -1;
if (cp + len > end)
return -1;
*wcp = (cp[0] & mask);
for (i = 1; i < len; i++)
{
if ((cp[i] & 0xc0) != 0x80)
return -1;
*wcp <<= 6;
*wcp |= (cp[i] & 0x3f);
}
if (*wcp == 0xFFFF)
return -1;
cp += len;
wcp++;
n++;
}
if (cp != end)
return -1;
return n;
}

View File

@ -1,759 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */
#include "gdkimage.h"
#include "gdkprivate.h"
#include "gdkx.h"
static void gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static GList *image_list = NULL;
void
gdk_image_exit (void)
{
GdkImage *image;
while (image_list)
{
image = image_list->data;
gdk_image_destroy (image);
}
}
GdkImage *
gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h)
/*
* Desc: create a new bitmap image
*/
{
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[2];
RGBQUAD bmiColors[2];
} u;
} bmi;
char *bits;
int bpl = (w-1)/8 + 1;
int bpl32 = ((w-1)/32 + 1)*4;
private = g_new(GdkImagePrivate, 1);
image = (GdkImage *) private;
private->image_put = gdk_image_put_normal;
image->type = GDK_IMAGE_SHARED;
image->visual = visual;
image->width = w;
image->height = h;
image->depth = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
GDK_NOTE (MISC, g_print ("gdk_image_new_bitmap: %dx%d\n", w, h));
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = w;
bmi.bmiHeader.biHeight = -h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
bmi.u.bmiColors[0].rgbBlue =
bmi.u.bmiColors[0].rgbGreen =
bmi.u.bmiColors[0].rgbRed = 0x00;
bmi.u.bmiColors[0].rgbReserved = 0x00;
bmi.u.bmiColors[1].rgbBlue =
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
private->ximage = CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi,
DIB_RGB_COLORS, &bits, NULL, 0);
if (bpl != bpl32)
{
/* Win32 expects scanlines in DIBs to be 32 bit aligned */
int i;
for (i = 0; i < h; i++)
memmove (bits + i*bpl32, ((char *) data) + i*bpl, bpl);
}
else
memmove (bits, data, bpl*h);
image->mem = bits;
image->bpl = bpl32;
image->byte_order = GDK_MSB_FIRST;
image->bpp = 1;
return(image);
} /* gdk_image_new_bitmap() */
void
gdk_image_init (void)
{
}
static GdkImage*
gdk_image_new_with_depth (GdkImageType type,
GdkVisual *visual,
gint width,
gint height,
gint depth)
{
GdkImage *image;
GdkImagePrivate *private;
Visual *xvisual;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[256];
DWORD bmiMasks[3];
RGBQUAD bmiColors[256];
} u;
} bmi;
UINT iUsage;
int i;
if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
type = GDK_IMAGE_SHARED;
GDK_NOTE (MISC, g_print ("gdk_image_new_with_depth: %dx%dx%d %s\n",
width, height, depth,
(type == GDK_IMAGE_SHARED ? "shared" :
(type == GDK_IMAGE_SHARED_PIXMAP ? "shared_pixmap" :
"???"))));
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->image_put = NULL;
image->type = type;
image->visual = visual;
image->width = width;
image->height = height;
image->depth = depth;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
private->image_put = gdk_image_put_normal;
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
if (depth == 15)
bmi.bmiHeader.biBitCount = 16;
else
bmi.bmiHeader.biBitCount = depth;
#if 1
if (depth == 16)
bmi.bmiHeader.biCompression = BI_BITFIELDS;
else
#endif
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
{
if (depth == 1)
{
bmi.u.bmiColors[0].rgbBlue =
bmi.u.bmiColors[0].rgbGreen =
bmi.u.bmiColors[0].rgbRed = 0x00;
bmi.u.bmiColors[0].rgbReserved = 0x00;
bmi.u.bmiColors[1].rgbBlue =
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
}
#if 1
else if (depth == 16)
{
bmi.u.bmiMasks[0] = visual->red_mask;
bmi.u.bmiMasks[1] = visual->green_mask;
bmi.u.bmiMasks[2] = visual->blue_mask;
}
#endif
iUsage = DIB_RGB_COLORS;
}
private->ximage =
CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0);
if (private->ximage == NULL)
{
g_warning ("gdk_image_new_with_depth: CreateDIBSection failed");
g_free (image);
return NULL;
}
switch (depth)
{
case 1:
case 8:
image->bpp = 1;
break;
case 15:
case 16:
image->bpp = 2;
break;
case 24:
image->bpp = 3;
break;
case 32:
image->bpp = 4;
break;
default:
g_warning ("gdk_image_new_with_depth: depth = %d", depth);
g_assert_not_reached ();
}
image->byte_order = GDK_LSB_FIRST;
if (depth == 1)
image->bpl = ((width-1)/32 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
return image;
}
GdkImage*
gdk_image_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
GdkVisualPrivate *visual_private = (GdkVisualPrivate *) visual;
return gdk_image_new_with_depth (type, visual, width, height,
visual_private->xvisual->bitspixel);
}
GdkImage*
gdk_image_bitmap_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
return gdk_image_new_with_depth (type, visual, width, height, 1);
}
GdkImage*
gdk_image_get (GdkWindow *window,
gint x,
gint y,
gint width,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
HDC hdc, memdc;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[256];
DWORD bmiMasks[3];
RGBQUAD bmiColors[256];
} u;
} bmi;
HGDIOBJ oldbitmap1, oldbitmap2;
UINT iUsage;
BITMAP bm;
int i;
g_return_val_if_fail (window != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
GDK_NOTE (MISC, g_print ("gdk_image_get: %#x %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window), width, height, x, y));
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->image_put = gdk_image_put_normal;
image->type = GDK_IMAGE_SHARED;
image->visual = gdk_window_get_visual (window);
image->width = width;
image->height = height;
/* This function is called both to blit from a window and from
* a pixmap.
*/
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
if ((hdc = CreateCompatibleDC (NULL)) == NULL)
{
g_warning ("gdk_image_get: CreateCompatibleDC #1 failed");
g_free (image);
return NULL;
}
if ((oldbitmap1 = SelectObject (hdc, GDK_DRAWABLE_XID (window))) == NULL)
{
g_warning ("gdk_image_get: SelectObject #1 failed");
DeleteDC (hdc);
g_free (image);
return NULL;
}
GetObject (GDK_DRAWABLE_XID (window), sizeof (BITMAP), &bm);
GDK_NOTE (MISC,
g_print ("gdk_image_get: bmWidth = %d, bmHeight = %d, bmWidthBytes = %d, bmBitsPixel = %d\n",
bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, bm.bmBitsPixel));
image->depth = bm.bmBitsPixel;
if (image->depth <= 8)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
iUsage = DIB_RGB_COLORS;
}
else
{
if ((hdc = GetDC (GDK_DRAWABLE_XID (window))) == NULL)
{
g_warning ("gdk_image_get: GetDC failed");
g_free (image);
return NULL;
}
image->depth = gdk_visual_get_system ()->depth;
if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
iUsage = DIB_RGB_COLORS;
}
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
g_warning ("gdk_image_get: CreateCompatibleDC #2 failed");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = image->depth;
if (image->depth == 16)
{
bmi.bmiHeader.biCompression = BI_BITFIELDS;
if (image->visual == NULL)
{
/* XXX ??? Is it always this if depth==16 and a pixmap? Guess so. */
bmi.u.bmiMasks[0] = 0xf800;
bmi.u.bmiMasks[1] = 0x07e0;
bmi.u.bmiMasks[2] = 0x001f;
}
else
{
bmi.u.bmiMasks[0] = image->visual->red_mask;
bmi.u.bmiMasks[1] = image->visual->green_mask;
bmi.u.bmiMasks[2] = image->visual->blue_mask;
}
}
else
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
if ((private->ximage =
CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0)) == NULL)
{
g_warning ("gdk_image_get: CreateDIBSection failed");
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if ((oldbitmap2 = SelectObject (memdc, private->ximage)) == NULL)
{
g_warning ("gdk_image_get: SelectObject #2 failed");
DeleteObject (private->ximage);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if (!BitBlt (memdc, 0, 0, width, height, hdc, x, y, SRCCOPY))
{
g_warning ("gdk_image_get: BitBlt failed");
SelectObject (memdc, oldbitmap2);
DeleteObject (private->ximage);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if (SelectObject (memdc, oldbitmap2) == NULL)
g_warning ("gdk_image_get: SelectObject #3 failed");
if (!DeleteDC (memdc))
g_warning ("gdk_image_get: DeleteDC failed");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
switch (image->depth)
{
case 1:
case 8:
image->bpp = 1;
break;
case 15:
case 16:
image->bpp = 2;
break;
case 24:
image->bpp = 3;
break;
case 32:
image->bpp = 4;
break;
default:
g_warning ("gdk_image_get: image->depth = %d", image->depth);
g_assert_not_reached ();
}
image->byte_order = GDK_LSB_FIRST;
if (image->depth == 1)
image->bpl = ((width - 1)/32 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
return image;
}
guint32
gdk_image_get_pixel (GdkImage *image,
gint x,
gint y)
{
guint32 pixel;
GdkImagePrivate *private;
g_return_val_if_fail (image != NULL, 0);
private = (GdkImagePrivate *) image;
g_return_val_if_fail (x >= 0 && x < image->width
&& y >= 0 && y < image->height, 0);
if (image->depth == 1)
pixel = (((char *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
switch (image->bpp)
{
case 1:
pixel = *pixelp;
break;
/* Windows is always LSB, no need to check image->byte_order. */
case 2:
pixel = pixelp[0] | (pixelp[1] << 8);
break;
case 3:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
case 4:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
}
}
return pixel;
}
void
gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
guint32 pixel)
{
GdkImagePrivate *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate *) image;
g_return_if_fail (x >= 0 && x < image->width && y >= 0 && y < image->height);
if (image->depth == 1)
if (pixel & 1)
((guchar *) image->mem)[y * image->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
else
((guchar *) image->mem)[y * image->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
/* Windows is always LSB, no need to check image->byte_order. */
switch (image->bpp)
{
case 4:
pixelp[3] = 0;
case 3:
pixelp[2] = ((pixel >> 16) & 0xFF);
case 2:
pixelp[1] = ((pixel >> 8) & 0xFF);
case 1:
pixelp[0] = (pixel & 0xFF);
}
}
}
void
gdk_image_destroy (GdkImage *image)
{
GdkImagePrivate *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate*) image;
GDK_NOTE (MISC, g_print ("gdk_image_destroy: %#x%s\n",
private->ximage,
(image->type == GDK_IMAGE_SHARED_PIXMAP ?
" (shared pixmap)" : "")));
switch (image->type)
{
case GDK_IMAGE_SHARED_PIXMAP:
break; /* The Windows bitmap has already been
* (or will be) deleted when freeing
* the corresponding pixmap.
*/
case GDK_IMAGE_SHARED:
if (!DeleteObject (private->ximage))
g_warning ("gdk_image_destroy: DeleteObject failed");
break;
default:
g_assert_not_reached ();
}
g_free (image);
}
static void
gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
HDC hdc;
GdkColormapPrivate *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
/* The image can in fact be "shared", so don't test */
hdc = gdk_gc_predraw (drawable_private, gc_private);
colormap_private = (GdkColormapPrivate *) drawable_private->colormap;
if (colormap_private && colormap_private->xcolormap->rc_palette)
{
DIBSECTION ds;
static struct {
BITMAPINFOHEADER bmiHeader;
WORD bmiIndices[256];
} bmi;
static gboolean bmi_inited = FALSE;
int i;
if (!bmi_inited)
{
for (i = 0; i < 256; i++)
bmi.bmiIndices[i] = i;
bmi_inited = TRUE;
}
if (GetObject (image_private->ximage, sizeof (DIBSECTION),
&ds) != sizeof (DIBSECTION))
{
g_warning ("gdk_image_put_normal: GetObject failed");
}
#if 0
g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n",
xdest, ydest, xsrc, ysrc, width, height);
g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n",
ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits);
g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n",
ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed);
#endif
bmi.bmiHeader = ds.dsBmih;
/* I have spent hours on getting the parameters to
* SetDIBitsToDevice right. I wonder what drugs the guys in
* Redmond were on when they designed this API.
*/
if (SetDIBitsToDevice (hdc,
xdest, ydest,
width, height,
xsrc, (-ds.dsBmih.biHeight)-height-ysrc,
0, -ds.dsBmih.biHeight,
ds.dsBm.bmBits,
(CONST BITMAPINFO *) &bmi,
DIB_PAL_COLORS) == 0)
g_warning ("SetDIBitsToDevice failed");
}
else
{
HDC memdc;
HGDIOBJ oldbitmap;
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
g_warning ("gdk_image_put_normal: CreateCompatibleDC failed");
gdk_gc_postdraw (drawable_private, gc_private);
return;
}
if ((oldbitmap = SelectObject (memdc, image_private->ximage)) == NULL)
{
g_warning ("gdk_image_put_normal: SelectObject #1 failed");
gdk_gc_postdraw (drawable_private, gc_private);
return;
}
if (!BitBlt (hdc, xdest, ydest, width, height,
memdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_image_put_normal: BitBlt failed");
if (SelectObject (memdc, oldbitmap) == NULL)
g_warning ("gdk_image_put_normal: SelectObject #2 failed");
if (!DeleteDC (memdc))
g_warning ("gdk_image_put_normal: DeleteDC failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}

View File

@ -1,759 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdk.h" /* For gdk_error_trap_* / gdk_flush_* */
#include "gdkimage.h"
#include "gdkprivate.h"
#include "gdkx.h"
static void gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
static GList *image_list = NULL;
void
gdk_image_exit (void)
{
GdkImage *image;
while (image_list)
{
image = image_list->data;
gdk_image_destroy (image);
}
}
GdkImage *
gdk_image_new_bitmap (GdkVisual *visual, gpointer data, gint w, gint h)
/*
* Desc: create a new bitmap image
*/
{
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[2];
RGBQUAD bmiColors[2];
} u;
} bmi;
char *bits;
int bpl = (w-1)/8 + 1;
int bpl32 = ((w-1)/32 + 1)*4;
private = g_new(GdkImagePrivate, 1);
image = (GdkImage *) private;
private->image_put = gdk_image_put_normal;
image->type = GDK_IMAGE_SHARED;
image->visual = visual;
image->width = w;
image->height = h;
image->depth = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
GDK_NOTE (MISC, g_print ("gdk_image_new_bitmap: %dx%d\n", w, h));
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = w;
bmi.bmiHeader.biHeight = -h;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
bmi.u.bmiColors[0].rgbBlue =
bmi.u.bmiColors[0].rgbGreen =
bmi.u.bmiColors[0].rgbRed = 0x00;
bmi.u.bmiColors[0].rgbReserved = 0x00;
bmi.u.bmiColors[1].rgbBlue =
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
private->ximage = CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi,
DIB_RGB_COLORS, &bits, NULL, 0);
if (bpl != bpl32)
{
/* Win32 expects scanlines in DIBs to be 32 bit aligned */
int i;
for (i = 0; i < h; i++)
memmove (bits + i*bpl32, ((char *) data) + i*bpl, bpl);
}
else
memmove (bits, data, bpl*h);
image->mem = bits;
image->bpl = bpl32;
image->byte_order = GDK_MSB_FIRST;
image->bpp = 1;
return(image);
} /* gdk_image_new_bitmap() */
void
gdk_image_init (void)
{
}
static GdkImage*
gdk_image_new_with_depth (GdkImageType type,
GdkVisual *visual,
gint width,
gint height,
gint depth)
{
GdkImage *image;
GdkImagePrivate *private;
Visual *xvisual;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[256];
DWORD bmiMasks[3];
RGBQUAD bmiColors[256];
} u;
} bmi;
UINT iUsage;
int i;
if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
type = GDK_IMAGE_SHARED;
GDK_NOTE (MISC, g_print ("gdk_image_new_with_depth: %dx%dx%d %s\n",
width, height, depth,
(type == GDK_IMAGE_SHARED ? "shared" :
(type == GDK_IMAGE_SHARED_PIXMAP ? "shared_pixmap" :
"???"))));
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->image_put = NULL;
image->type = type;
image->visual = visual;
image->width = width;
image->height = height;
image->depth = depth;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
private->image_put = gdk_image_put_normal;
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
if (depth == 15)
bmi.bmiHeader.biBitCount = 16;
else
bmi.bmiHeader.biBitCount = depth;
#if 1
if (depth == 16)
bmi.bmiHeader.biCompression = BI_BITFIELDS;
else
#endif
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
{
if (depth == 1)
{
bmi.u.bmiColors[0].rgbBlue =
bmi.u.bmiColors[0].rgbGreen =
bmi.u.bmiColors[0].rgbRed = 0x00;
bmi.u.bmiColors[0].rgbReserved = 0x00;
bmi.u.bmiColors[1].rgbBlue =
bmi.u.bmiColors[1].rgbGreen =
bmi.u.bmiColors[1].rgbRed = 0xFF;
bmi.u.bmiColors[1].rgbReserved = 0x00;
}
#if 1
else if (depth == 16)
{
bmi.u.bmiMasks[0] = visual->red_mask;
bmi.u.bmiMasks[1] = visual->green_mask;
bmi.u.bmiMasks[2] = visual->blue_mask;
}
#endif
iUsage = DIB_RGB_COLORS;
}
private->ximage =
CreateDIBSection (gdk_DC, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0);
if (private->ximage == NULL)
{
g_warning ("gdk_image_new_with_depth: CreateDIBSection failed");
g_free (image);
return NULL;
}
switch (depth)
{
case 1:
case 8:
image->bpp = 1;
break;
case 15:
case 16:
image->bpp = 2;
break;
case 24:
image->bpp = 3;
break;
case 32:
image->bpp = 4;
break;
default:
g_warning ("gdk_image_new_with_depth: depth = %d", depth);
g_assert_not_reached ();
}
image->byte_order = GDK_LSB_FIRST;
if (depth == 1)
image->bpl = ((width-1)/32 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
return image;
}
GdkImage*
gdk_image_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
GdkVisualPrivate *visual_private = (GdkVisualPrivate *) visual;
return gdk_image_new_with_depth (type, visual, width, height,
visual_private->xvisual->bitspixel);
}
GdkImage*
gdk_image_bitmap_new (GdkImageType type,
GdkVisual *visual,
gint width,
gint height)
{
return gdk_image_new_with_depth (type, visual, width, height, 1);
}
GdkImage*
gdk_image_get (GdkWindow *window,
gint x,
gint y,
gint width,
gint height)
{
GdkImage *image;
GdkImagePrivate *private;
HDC hdc, memdc;
struct {
BITMAPINFOHEADER bmiHeader;
union {
WORD bmiIndices[256];
DWORD bmiMasks[3];
RGBQUAD bmiColors[256];
} u;
} bmi;
HGDIOBJ oldbitmap1, oldbitmap2;
UINT iUsage;
BITMAP bm;
int i;
g_return_val_if_fail (window != NULL, NULL);
if (GDK_DRAWABLE_DESTROYED (window))
return NULL;
GDK_NOTE (MISC, g_print ("gdk_image_get: %#x %dx%d@+%d+%d\n",
GDK_DRAWABLE_XID (window), width, height, x, y));
private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->image_put = gdk_image_put_normal;
image->type = GDK_IMAGE_SHARED;
image->visual = gdk_window_get_visual (window);
image->width = width;
image->height = height;
/* This function is called both to blit from a window and from
* a pixmap.
*/
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
if ((hdc = CreateCompatibleDC (NULL)) == NULL)
{
g_warning ("gdk_image_get: CreateCompatibleDC #1 failed");
g_free (image);
return NULL;
}
if ((oldbitmap1 = SelectObject (hdc, GDK_DRAWABLE_XID (window))) == NULL)
{
g_warning ("gdk_image_get: SelectObject #1 failed");
DeleteDC (hdc);
g_free (image);
return NULL;
}
GetObject (GDK_DRAWABLE_XID (window), sizeof (BITMAP), &bm);
GDK_NOTE (MISC,
g_print ("gdk_image_get: bmWidth = %d, bmHeight = %d, bmWidthBytes = %d, bmBitsPixel = %d\n",
bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, bm.bmBitsPixel));
image->depth = bm.bmBitsPixel;
if (image->depth <= 8)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
iUsage = DIB_RGB_COLORS;
}
else
{
if ((hdc = GetDC (GDK_DRAWABLE_XID (window))) == NULL)
{
g_warning ("gdk_image_get: GetDC failed");
g_free (image);
return NULL;
}
image->depth = gdk_visual_get_system ()->depth;
if (image->visual->type == GDK_VISUAL_PSEUDO_COLOR)
{
iUsage = DIB_PAL_COLORS;
for (i = 0; i < 256; i++)
bmi.u.bmiIndices[i] = i;
}
else
iUsage = DIB_RGB_COLORS;
}
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
g_warning ("gdk_image_get: CreateCompatibleDC #2 failed");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = image->depth;
if (image->depth == 16)
{
bmi.bmiHeader.biCompression = BI_BITFIELDS;
if (image->visual == NULL)
{
/* XXX ??? Is it always this if depth==16 and a pixmap? Guess so. */
bmi.u.bmiMasks[0] = 0xf800;
bmi.u.bmiMasks[1] = 0x07e0;
bmi.u.bmiMasks[2] = 0x001f;
}
else
{
bmi.u.bmiMasks[0] = image->visual->red_mask;
bmi.u.bmiMasks[1] = image->visual->green_mask;
bmi.u.bmiMasks[2] = image->visual->blue_mask;
}
}
else
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
bmi.bmiHeader.biXPelsPerMeter =
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
if ((private->ximage =
CreateDIBSection (hdc, (BITMAPINFO *) &bmi, iUsage,
&image->mem, NULL, 0)) == NULL)
{
g_warning ("gdk_image_get: CreateDIBSection failed");
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if ((oldbitmap2 = SelectObject (memdc, private->ximage)) == NULL)
{
g_warning ("gdk_image_get: SelectObject #2 failed");
DeleteObject (private->ximage);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if (!BitBlt (memdc, 0, 0, width, height, hdc, x, y, SRCCOPY))
{
g_warning ("gdk_image_get: BitBlt failed");
SelectObject (memdc, oldbitmap2);
DeleteObject (private->ximage);
DeleteDC (memdc);
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
g_free (image);
return NULL;
}
if (SelectObject (memdc, oldbitmap2) == NULL)
g_warning ("gdk_image_get: SelectObject #3 failed");
if (!DeleteDC (memdc))
g_warning ("gdk_image_get: DeleteDC failed");
if (GDK_DRAWABLE_TYPE (window) == GDK_DRAWABLE_PIXMAP)
{
SelectObject (hdc, oldbitmap1);
DeleteDC (hdc);
}
else
{
ReleaseDC (GDK_DRAWABLE_XID (window), hdc);
}
switch (image->depth)
{
case 1:
case 8:
image->bpp = 1;
break;
case 15:
case 16:
image->bpp = 2;
break;
case 24:
image->bpp = 3;
break;
case 32:
image->bpp = 4;
break;
default:
g_warning ("gdk_image_get: image->depth = %d", image->depth);
g_assert_not_reached ();
}
image->byte_order = GDK_LSB_FIRST;
if (image->depth == 1)
image->bpl = ((width - 1)/32 + 1)*4;
else
image->bpl = ((width*image->bpp - 1)/4 + 1)*4;
GDK_NOTE (MISC, g_print ("... = %#x mem = %#x, bpl = %d\n",
private->ximage, image->mem, image->bpl));
return image;
}
guint32
gdk_image_get_pixel (GdkImage *image,
gint x,
gint y)
{
guint32 pixel;
GdkImagePrivate *private;
g_return_val_if_fail (image != NULL, 0);
private = (GdkImagePrivate *) image;
g_return_val_if_fail (x >= 0 && x < image->width
&& y >= 0 && y < image->height, 0);
if (image->depth == 1)
pixel = (((char *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
switch (image->bpp)
{
case 1:
pixel = *pixelp;
break;
/* Windows is always LSB, no need to check image->byte_order. */
case 2:
pixel = pixelp[0] | (pixelp[1] << 8);
break;
case 3:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
case 4:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
}
}
return pixel;
}
void
gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
guint32 pixel)
{
GdkImagePrivate *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate *) image;
g_return_if_fail (x >= 0 && x < image->width && y >= 0 && y < image->height);
if (image->depth == 1)
if (pixel & 1)
((guchar *) image->mem)[y * image->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
else
((guchar *) image->mem)[y * image->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
/* Windows is always LSB, no need to check image->byte_order. */
switch (image->bpp)
{
case 4:
pixelp[3] = 0;
case 3:
pixelp[2] = ((pixel >> 16) & 0xFF);
case 2:
pixelp[1] = ((pixel >> 8) & 0xFF);
case 1:
pixelp[0] = (pixel & 0xFF);
}
}
}
void
gdk_image_destroy (GdkImage *image)
{
GdkImagePrivate *private;
g_return_if_fail (image != NULL);
private = (GdkImagePrivate*) image;
GDK_NOTE (MISC, g_print ("gdk_image_destroy: %#x%s\n",
private->ximage,
(image->type == GDK_IMAGE_SHARED_PIXMAP ?
" (shared pixmap)" : "")));
switch (image->type)
{
case GDK_IMAGE_SHARED_PIXMAP:
break; /* The Windows bitmap has already been
* (or will be) deleted when freeing
* the corresponding pixmap.
*/
case GDK_IMAGE_SHARED:
if (!DeleteObject (private->ximage))
g_warning ("gdk_image_destroy: DeleteObject failed");
break;
default:
g_assert_not_reached ();
}
g_free (image);
}
static void
gdk_image_put_normal (GdkDrawable *drawable,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height)
{
GdkDrawablePrivate *drawable_private;
GdkImagePrivate *image_private;
GdkGCPrivate *gc_private;
HDC hdc;
GdkColormapPrivate *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (image != NULL);
g_return_if_fail (gc != NULL);
if (GDK_DRAWABLE_DESTROYED (drawable))
return;
image_private = (GdkImagePrivate*) image;
drawable_private = (GdkDrawablePrivate*) drawable;
gc_private = (GdkGCPrivate*) gc;
/* The image can in fact be "shared", so don't test */
hdc = gdk_gc_predraw (drawable_private, gc_private);
colormap_private = (GdkColormapPrivate *) drawable_private->colormap;
if (colormap_private && colormap_private->xcolormap->rc_palette)
{
DIBSECTION ds;
static struct {
BITMAPINFOHEADER bmiHeader;
WORD bmiIndices[256];
} bmi;
static gboolean bmi_inited = FALSE;
int i;
if (!bmi_inited)
{
for (i = 0; i < 256; i++)
bmi.bmiIndices[i] = i;
bmi_inited = TRUE;
}
if (GetObject (image_private->ximage, sizeof (DIBSECTION),
&ds) != sizeof (DIBSECTION))
{
g_warning ("gdk_image_put_normal: GetObject failed");
}
#if 0
g_print("xdest = %d, ydest = %d, xsrc = %d, ysrc = %d, width = %d, height = %d\n",
xdest, ydest, xsrc, ysrc, width, height);
g_print("bmWidth = %d, bmHeight = %d, bmBitsPixel = %d, bmBits = %p\n",
ds.dsBm.bmWidth, ds.dsBm.bmHeight, ds.dsBm.bmBitsPixel, ds.dsBm.bmBits);
g_print("biWidth = %d, biHeight = %d, biBitCount = %d, biClrUsed = %d\n",
ds.dsBmih.biWidth, ds.dsBmih.biHeight, ds.dsBmih.biBitCount, ds.dsBmih.biClrUsed);
#endif
bmi.bmiHeader = ds.dsBmih;
/* I have spent hours on getting the parameters to
* SetDIBitsToDevice right. I wonder what drugs the guys in
* Redmond were on when they designed this API.
*/
if (SetDIBitsToDevice (hdc,
xdest, ydest,
width, height,
xsrc, (-ds.dsBmih.biHeight)-height-ysrc,
0, -ds.dsBmih.biHeight,
ds.dsBm.bmBits,
(CONST BITMAPINFO *) &bmi,
DIB_PAL_COLORS) == 0)
g_warning ("SetDIBitsToDevice failed");
}
else
{
HDC memdc;
HGDIOBJ oldbitmap;
if ((memdc = CreateCompatibleDC (hdc)) == NULL)
{
g_warning ("gdk_image_put_normal: CreateCompatibleDC failed");
gdk_gc_postdraw (drawable_private, gc_private);
return;
}
if ((oldbitmap = SelectObject (memdc, image_private->ximage)) == NULL)
{
g_warning ("gdk_image_put_normal: SelectObject #1 failed");
gdk_gc_postdraw (drawable_private, gc_private);
return;
}
if (!BitBlt (hdc, xdest, ydest, width, height,
memdc, xsrc, ysrc, SRCCOPY))
g_warning ("gdk_image_put_normal: BitBlt failed");
if (SelectObject (memdc, oldbitmap) == NULL)
g_warning ("gdk_image_put_normal: SelectObject #2 failed");
if (!DeleteDC (memdc))
g_warning ("gdk_image_put_normal: DeleteDC failed");
}
gdk_gc_postdraw (drawable_private, gc_private);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,459 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#ifndef __GDK_PRIVATE_H__
#define __GDK_PRIVATE_H__
#define STRICT /* We want strict type checks */
#include <windows.h>
#include <commctrl.h>
/* Make up for some minor mingw32 lossage */
/* PS_JOIN_MASK is missing from the mingw32 headers */
#ifndef PS_JOIN_MASK
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
/* CLR_INVALID is missing */
#ifndef CLR_INVALID
#define CLR_INVALID CLR_NONE
#endif
/* Some charsets are missing */
#ifndef JOHAB_CHARSET
#define JOHAB_CHARSET 130
#endif
#ifndef VIETNAMESE_CHARSET
#define VIETNAMESE_CHARSET 163
#endif
#ifndef VM_OEM_PLUS
#define VK_OEM_PLUS 0xBB
#endif
#include <time.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkevents.h>
#include <gdk/gdkfont.h>
#include <gdk/gdkgc.h>
#include <gdk/gdkim.h>
#include <gdk/gdkimage.h>
#include <gdk/gdkregion.h>
#include <gdk/gdkvisual.h>
#include <gdk/gdkwindow.h>
#define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
#define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
#define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
#define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Define corresponding Windows types for some X11 types, just for laziness.
*/
typedef HANDLE XID;
typedef PALETTEENTRY XColor;
typedef HDC GC;
typedef ATOM Atom;
typedef HCURSOR Cursor;
typedef guint VisualID;
typedef DWORD KeySym;
typedef int Status;
/* Define some of the X11 constants also here, again just for laziness */
/* Generic null resource */
#define None 0
/* Error codes */
#define Success 0
/* Grabbing status */
#define GrabSuccess 0
#define AlreadyGrabbed 2
/* For CreateColormap */
#define AllocNone 0
#define AllocAll 1
/* Some structs are somewhat useful to emulate internally, just to
keep the code less #ifdefed. */
typedef struct {
HPALETTE palette; /* Palette handle used when drawing. */
guint size; /* Number of entries in the palette. */
gboolean stale; /* 1 if palette needs to be realized,
* otherwise 0. */
gboolean *in_use;
gboolean rc_palette; /* If RC_PALETTE is on in the RASTERCAPS */
gulong sizepalette; /* SIZEPALETTE if rc_palette */
} ColormapStruct, *Colormap;
typedef struct {
gint map_entries;
guint visualid;
guint bitspixel;
} Visual;
typedef struct {
Colormap colormap;
unsigned long red_max;
unsigned long red_mult;
unsigned long green_max;
unsigned long green_mult;
unsigned long blue_max;
unsigned long blue_mult;
unsigned long base_pixel;
} XStandardColormap;
typedef struct _GdkDrawablePrivate GdkDrawablePrivate;
/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */
typedef struct _GdkWindowPrivate GdkWindowPrivate;
typedef struct _GdkImagePrivate GdkImagePrivate;
typedef struct _GdkGCPrivate GdkGCPrivate;
typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkColorInfo GdkColorInfo;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkClientFilter GdkClientFilter;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
struct _GdkDrawablePrivate
{
GdkDrawable drawable;
guint8 window_type;
guint ref_count;
guint16 width;
guint16 height;
HANDLE xwindow;
GdkColormap *colormap;
guint destroyed : 2;
};
struct _GdkWindowPrivate
{
GdkDrawablePrivate drawable;
GdkWindow *parent;
gint16 x;
gint16 y;
guint8 resize_count;
guint mapped : 1;
guint guffaw_gravity : 1;
/* We must keep the event mask here to filter them ourselves */
gint event_mask;
/* Values for bg_type */
#define GDK_WIN32_BG_NORMAL 0
#define GDK_WIN32_BG_PIXEL 1
#define GDK_WIN32_BG_PIXMAP 2
#define GDK_WIN32_BG_PARENT_RELATIVE 3
#define GDK_WIN32_BG_TRANSPARENT 4
/* We draw the background ourselves at WM_ERASEBKGND */
guchar bg_type;
GdkColor bg_pixel;
GdkPixmap *bg_pixmap;
HCURSOR xcursor;
/* Window size hints */
gint hint_flags;
gint hint_x, hint_y;
gint hint_min_width, hint_min_height;
gint hint_max_width, hint_max_height;
gint extension_events;
gboolean extension_events_selected;
GList *filters;
GList *children;
HKL input_locale;
CHARSETINFO charset_info;
};
struct _GdkImagePrivate
{
GdkImage image;
HBITMAP ximage;
gpointer x_shm_info;
void (*image_put) (GdkDrawable *window,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
};
struct _GdkGCPrivate
{
GdkGC gc;
GC xgc;
/* A Windows Device Context (DC) is not equivalent to an X11
* GC. We can use a DC only in the window for which it was
* allocated, or (in the case of a memory DC) with the bitmap that
* has been selected into it. Thus, we have to release and
* reallocate a DC each time the GdkGC is used to paint into a new
* window or pixmap. We thus keep all the necessary values in the
* GdkGCPrivate struct.
*/
GdkGCValuesMask values_mask;
GdkColor foreground;
GdkColor background;
GdkFont *font;
gint rop2;
GdkFill fill_style;
GdkPixmap *tile;
GdkPixmap *stipple;
HRGN clip_region;
GdkSubwindowMode subwindow_mode;
gint ts_x_origin;
gint ts_y_origin;
gint clip_x_origin;
gint clip_y_origin;
gint graphics_exposures;
gint pen_width;
DWORD pen_style;
HANDLE hwnd; /* If a DC is allocated, for which window
or what bitmap is selected into it */
int saved_dc;
guint ref_count;
};
typedef enum {
GDK_COLOR_WRITEABLE = 1 << 0
} GdkColorInfoFlags;
struct _GdkColorInfo
{
GdkColorInfoFlags flags;
guint ref_count;
};
struct _GdkColormapPrivate
{
GdkColormap colormap;
Colormap xcolormap;
GdkVisual *visual;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
guint ref_count;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
Visual *xvisual;
};
typedef struct
{
HFONT xfont;
DWORD charset;
UINT codepage;
CPINFO cpinfo;
FONTSIGNATURE fs;
} GdkWin32SingleFont;
struct _GdkFontPrivate
{
GdkFont font;
guint ref_count;
GSList *fonts;
GSList *names;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
Cursor xcursor;
};
struct _GdkEventFilter {
GdkFilterFunc function;
gpointer data;
};
struct _GdkClientFilter {
GdkAtom type;
GdkFilterFunc function;
gpointer data;
};
struct _GdkRegionPrivate
{
GdkRegion region;
HRGN xregion;
};
typedef enum {
GDK_DEBUG_MISC = 1 << 0,
GDK_DEBUG_EVENTS = 1 << 1,
GDK_DEBUG_DND = 1 << 2,
GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
GDK_DEBUG_XIM = 1 << 4,
GDK_DEBUG_SELECTION = 1 << 5
} GdkDebugFlag;
void gdk_events_init (void);
void gdk_window_init (void);
void gdk_visual_init (void);
void gdk_selection_init (void);
void gdk_dnd_init (void);
void gdk_dnd_exit (void);
void gdk_image_init (void);
void gdk_image_exit (void);
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
GdkVisual* gdk_visual_lookup (Visual *xvisual);
void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_xid_table_insert (XID *xid,
gpointer data);
void gdk_xid_table_remove (XID xid);
gpointer gdk_xid_table_lookup (XID xid);
/* Internal functions */
HDC gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
void gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
HRGN BitmapToRegion (HBITMAP hBmp);
void gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length);
void gdk_event_queue_append (GdkEvent *event);
gint gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max);
gint gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max);
void gdk_wchar_text_handle (GdkFont *font,
const wchar_t *wcstr,
int wclen,
void (*handler)(GdkWin32SingleFont *,
const wchar_t *,
int,
void *),
void *arg);
/* Please see gdkwindow.c for comments on how to use */
HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
extern gint gdk_debug_level;
extern gint gdk_show_events;
extern gint gdk_stack_trace;
extern HWND gdk_root_window;
extern HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent;
GDKVAR Atom gdk_selection_property;
GDKVAR gchar *gdk_progclass;
GDKVAR gint gdk_error_code;
GDKVAR gint gdk_error_warnings;
GDKVAR gint gdk_null_window_warnings;
extern gint gdk_event_func_from_window_proc;
extern HDC gdk_DC;
extern HINSTANCE gdk_DLLInstance;
extern HINSTANCE gdk_ProgInstance;
extern UINT gdk_selection_notify_msg;
extern UINT gdk_selection_request_msg;
extern UINT gdk_selection_clear_msg;
extern GdkAtom gdk_clipboard_atom;
extern GdkAtom gdk_win32_dropfiles_atom;
extern GdkAtom gdk_ole2_dnd_atom;
extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
extern DWORD windows_version;
/* Debugging support */
#ifdef G_ENABLE_DEBUG
#define GDK_NOTE(type,action) G_STMT_START { \
if (gdk_debug_flags & GDK_DEBUG_##type) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GDK_NOTE(type,action)
#endif /* G_ENABLE_DEBUG */
GDKVAR guint gdk_debug_flags;
/* Internal functions for debug output etc. */
char *gdk_color_to_string (GdkColor *);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_PRIVATE_H__ */

View File

@ -1,459 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#ifndef __GDK_PRIVATE_H__
#define __GDK_PRIVATE_H__
#define STRICT /* We want strict type checks */
#include <windows.h>
#include <commctrl.h>
/* Make up for some minor mingw32 lossage */
/* PS_JOIN_MASK is missing from the mingw32 headers */
#ifndef PS_JOIN_MASK
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
/* CLR_INVALID is missing */
#ifndef CLR_INVALID
#define CLR_INVALID CLR_NONE
#endif
/* Some charsets are missing */
#ifndef JOHAB_CHARSET
#define JOHAB_CHARSET 130
#endif
#ifndef VIETNAMESE_CHARSET
#define VIETNAMESE_CHARSET 163
#endif
#ifndef VM_OEM_PLUS
#define VK_OEM_PLUS 0xBB
#endif
#include <time.h>
#include <gdk/gdktypes.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkevents.h>
#include <gdk/gdkfont.h>
#include <gdk/gdkgc.h>
#include <gdk/gdkim.h>
#include <gdk/gdkimage.h>
#include <gdk/gdkregion.h>
#include <gdk/gdkvisual.h>
#include <gdk/gdkwindow.h>
#define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
#define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
#define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
#define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
#define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
#define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Define corresponding Windows types for some X11 types, just for laziness.
*/
typedef HANDLE XID;
typedef PALETTEENTRY XColor;
typedef HDC GC;
typedef ATOM Atom;
typedef HCURSOR Cursor;
typedef guint VisualID;
typedef DWORD KeySym;
typedef int Status;
/* Define some of the X11 constants also here, again just for laziness */
/* Generic null resource */
#define None 0
/* Error codes */
#define Success 0
/* Grabbing status */
#define GrabSuccess 0
#define AlreadyGrabbed 2
/* For CreateColormap */
#define AllocNone 0
#define AllocAll 1
/* Some structs are somewhat useful to emulate internally, just to
keep the code less #ifdefed. */
typedef struct {
HPALETTE palette; /* Palette handle used when drawing. */
guint size; /* Number of entries in the palette. */
gboolean stale; /* 1 if palette needs to be realized,
* otherwise 0. */
gboolean *in_use;
gboolean rc_palette; /* If RC_PALETTE is on in the RASTERCAPS */
gulong sizepalette; /* SIZEPALETTE if rc_palette */
} ColormapStruct, *Colormap;
typedef struct {
gint map_entries;
guint visualid;
guint bitspixel;
} Visual;
typedef struct {
Colormap colormap;
unsigned long red_max;
unsigned long red_mult;
unsigned long green_max;
unsigned long green_mult;
unsigned long blue_max;
unsigned long blue_mult;
unsigned long base_pixel;
} XStandardColormap;
typedef struct _GdkDrawablePrivate GdkDrawablePrivate;
/* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */
typedef struct _GdkWindowPrivate GdkWindowPrivate;
typedef struct _GdkImagePrivate GdkImagePrivate;
typedef struct _GdkGCPrivate GdkGCPrivate;
typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkColorInfo GdkColorInfo;
typedef struct _GdkVisualPrivate GdkVisualPrivate;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
typedef struct _GdkClientFilter GdkClientFilter;
typedef struct _GdkRegionPrivate GdkRegionPrivate;
struct _GdkDrawablePrivate
{
GdkDrawable drawable;
guint8 window_type;
guint ref_count;
guint16 width;
guint16 height;
HANDLE xwindow;
GdkColormap *colormap;
guint destroyed : 2;
};
struct _GdkWindowPrivate
{
GdkDrawablePrivate drawable;
GdkWindow *parent;
gint16 x;
gint16 y;
guint8 resize_count;
guint mapped : 1;
guint guffaw_gravity : 1;
/* We must keep the event mask here to filter them ourselves */
gint event_mask;
/* Values for bg_type */
#define GDK_WIN32_BG_NORMAL 0
#define GDK_WIN32_BG_PIXEL 1
#define GDK_WIN32_BG_PIXMAP 2
#define GDK_WIN32_BG_PARENT_RELATIVE 3
#define GDK_WIN32_BG_TRANSPARENT 4
/* We draw the background ourselves at WM_ERASEBKGND */
guchar bg_type;
GdkColor bg_pixel;
GdkPixmap *bg_pixmap;
HCURSOR xcursor;
/* Window size hints */
gint hint_flags;
gint hint_x, hint_y;
gint hint_min_width, hint_min_height;
gint hint_max_width, hint_max_height;
gint extension_events;
gboolean extension_events_selected;
GList *filters;
GList *children;
HKL input_locale;
CHARSETINFO charset_info;
};
struct _GdkImagePrivate
{
GdkImage image;
HBITMAP ximage;
gpointer x_shm_info;
void (*image_put) (GdkDrawable *window,
GdkGC *gc,
GdkImage *image,
gint xsrc,
gint ysrc,
gint xdest,
gint ydest,
gint width,
gint height);
};
struct _GdkGCPrivate
{
GdkGC gc;
GC xgc;
/* A Windows Device Context (DC) is not equivalent to an X11
* GC. We can use a DC only in the window for which it was
* allocated, or (in the case of a memory DC) with the bitmap that
* has been selected into it. Thus, we have to release and
* reallocate a DC each time the GdkGC is used to paint into a new
* window or pixmap. We thus keep all the necessary values in the
* GdkGCPrivate struct.
*/
GdkGCValuesMask values_mask;
GdkColor foreground;
GdkColor background;
GdkFont *font;
gint rop2;
GdkFill fill_style;
GdkPixmap *tile;
GdkPixmap *stipple;
HRGN clip_region;
GdkSubwindowMode subwindow_mode;
gint ts_x_origin;
gint ts_y_origin;
gint clip_x_origin;
gint clip_y_origin;
gint graphics_exposures;
gint pen_width;
DWORD pen_style;
HANDLE hwnd; /* If a DC is allocated, for which window
or what bitmap is selected into it */
int saved_dc;
guint ref_count;
};
typedef enum {
GDK_COLOR_WRITEABLE = 1 << 0
} GdkColorInfoFlags;
struct _GdkColorInfo
{
GdkColorInfoFlags flags;
guint ref_count;
};
struct _GdkColormapPrivate
{
GdkColormap colormap;
Colormap xcolormap;
GdkVisual *visual;
gint private_val;
GHashTable *hash;
GdkColorInfo *info;
time_t last_sync_time;
guint ref_count;
};
struct _GdkVisualPrivate
{
GdkVisual visual;
Visual *xvisual;
};
typedef struct
{
HFONT xfont;
DWORD charset;
UINT codepage;
CPINFO cpinfo;
FONTSIGNATURE fs;
} GdkWin32SingleFont;
struct _GdkFontPrivate
{
GdkFont font;
guint ref_count;
GSList *fonts;
GSList *names;
};
struct _GdkCursorPrivate
{
GdkCursor cursor;
Cursor xcursor;
};
struct _GdkEventFilter {
GdkFilterFunc function;
gpointer data;
};
struct _GdkClientFilter {
GdkAtom type;
GdkFilterFunc function;
gpointer data;
};
struct _GdkRegionPrivate
{
GdkRegion region;
HRGN xregion;
};
typedef enum {
GDK_DEBUG_MISC = 1 << 0,
GDK_DEBUG_EVENTS = 1 << 1,
GDK_DEBUG_DND = 1 << 2,
GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
GDK_DEBUG_XIM = 1 << 4,
GDK_DEBUG_SELECTION = 1 << 5
} GdkDebugFlag;
void gdk_events_init (void);
void gdk_window_init (void);
void gdk_visual_init (void);
void gdk_selection_init (void);
void gdk_dnd_init (void);
void gdk_dnd_exit (void);
void gdk_image_init (void);
void gdk_image_exit (void);
GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
GdkVisual* gdk_visual_lookup (Visual *xvisual);
void gdk_window_add_colormap_windows (GdkWindow *window);
void gdk_window_destroy_notify (GdkWindow *window);
void gdk_xid_table_insert (XID *xid,
gpointer data);
void gdk_xid_table_remove (XID xid);
gpointer gdk_xid_table_lookup (XID xid);
/* Internal functions */
HDC gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
void gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
GdkGCPrivate *gc_private);
HRGN BitmapToRegion (HBITMAP hBmp);
void gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length);
void gdk_event_queue_append (GdkEvent *event);
gint gdk_nmbstowcs (GdkWChar *dest,
const gchar *src,
gint src_len,
gint dest_max);
gint gdk_nmbstowchar_ts (wchar_t *dest,
const gchar *src,
gint src_len,
gint dest_max);
void gdk_wchar_text_handle (GdkFont *font,
const wchar_t *wcstr,
int wclen,
void (*handler)(GdkWin32SingleFont *,
const wchar_t *,
int,
void *),
void *arg);
/* Please see gdkwindow.c for comments on how to use */
HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
extern gint gdk_debug_level;
extern gint gdk_show_events;
extern gint gdk_stack_trace;
extern HWND gdk_root_window;
extern HWND gdk_leader_window;
GDKVAR GdkWindowPrivate *gdk_root_parent;
GDKVAR Atom gdk_selection_property;
GDKVAR gchar *gdk_progclass;
GDKVAR gint gdk_error_code;
GDKVAR gint gdk_error_warnings;
GDKVAR gint gdk_null_window_warnings;
extern gint gdk_event_func_from_window_proc;
extern HDC gdk_DC;
extern HINSTANCE gdk_DLLInstance;
extern HINSTANCE gdk_ProgInstance;
extern UINT gdk_selection_notify_msg;
extern UINT gdk_selection_request_msg;
extern UINT gdk_selection_clear_msg;
extern GdkAtom gdk_clipboard_atom;
extern GdkAtom gdk_win32_dropfiles_atom;
extern GdkAtom gdk_ole2_dnd_atom;
extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
extern DWORD windows_version;
/* Debugging support */
#ifdef G_ENABLE_DEBUG
#define GDK_NOTE(type,action) G_STMT_START { \
if (gdk_debug_flags & GDK_DEBUG_##type) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GDK_NOTE(type,action)
#endif /* G_ENABLE_DEBUG */
GDKVAR guint gdk_debug_flags;
/* Internal functions for debug output etc. */
char *gdk_color_to_string (GdkColor *);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_PRIVATE_H__ */

View File

@ -1,228 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
#include "gdkproperty.h"
#include "gdkselection.h"
#include "gdkprivate.h"
#include "gdkx.h"
GdkAtom
gdk_atom_intern (const gchar *atom_name,
gint only_if_exists)
{
GdkAtom retval;
static GHashTable *atom_hash = NULL;
if (!atom_hash)
atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
if (!retval)
{
if (strcmp (atom_name, "PRIMARY") == 0)
retval = GDK_SELECTION_PRIMARY;
else if (strcmp (atom_name, "SECONDARY") == 0)
retval = GDK_SELECTION_SECONDARY;
else if (strcmp (atom_name, "ATOM") == 0)
retval = GDK_SELECTION_TYPE_ATOM;
else if (strcmp (atom_name, "BITMAP") == 0)
retval = GDK_SELECTION_TYPE_BITMAP;
else if (strcmp (atom_name, "COLORMAP") == 0)
retval = GDK_SELECTION_TYPE_COLORMAP;
else if (strcmp (atom_name, "DRAWABLE") == 0)
retval = GDK_SELECTION_TYPE_DRAWABLE;
else if (strcmp (atom_name, "INTEGER") == 0)
retval = GDK_SELECTION_TYPE_INTEGER;
else if (strcmp (atom_name, "PIXMAP") == 0)
retval = GDK_SELECTION_TYPE_PIXMAP;
else if (strcmp (atom_name, "WINDOW") == 0)
retval = GDK_SELECTION_TYPE_WINDOW;
else if (strcmp (atom_name, "STRING") == 0)
retval = GDK_SELECTION_TYPE_STRING;
else
{
retval = GlobalFindAtom (atom_name);
if (only_if_exists && retval == 0)
retval = 0;
else
retval = GlobalAddAtom (atom_name);
}
g_hash_table_insert (atom_hash,
g_strdup (atom_name),
GUINT_TO_POINTER (retval));
}
return retval;
}
gchar *
gdk_atom_name (GdkAtom atom)
{
gchar name[256];
switch (atom)
{
case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY");
case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY");
case GDK_SELECTION_TYPE_ATOM: return g_strdup ("ATOM");
case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP");
case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP");
case GDK_SELECTION_TYPE_DRAWABLE: return g_strdup ("DRAWABLE");
case GDK_SELECTION_TYPE_INTEGER: return g_strdup ("INTEGER");
case GDK_SELECTION_TYPE_PIXMAP: return g_strdup ("PIXMAP");
case GDK_SELECTION_TYPE_WINDOW: return g_strdup ("WINDOW");
case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING");
}
if (atom < 0xC000)
return g_strdup_printf ("#%x", atom);
else if (GlobalGetAtomName (atom, name, sizeof (name)) == 0)
return NULL;
return g_strdup (name);
}
gint
gdk_property_get (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_property_type,
gint *actual_format_type,
gint *actual_length,
guchar **data)
{
g_warning ("gdk_property_get: Not implemented");
return FALSE;
}
void
gdk_property_change (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
guchar *data,
gint nelements)
{
HGLOBAL hdata;
gint i, length;
gchar *prop_name, *type_name;
guchar *ptr;
if (GDK_DRAWABLE_DESTROYED (window))
return;
GDK_NOTE (SELECTION,
(prop_name = gdk_atom_name (property),
type_name = gdk_atom_name (type),
g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n",
GDK_DRAWABLE_XID (window), property, prop_name,
type, type_name,
(mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
(mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
(mode == GDK_PROP_MODE_APPEND ? "APPEND" :
"???"))),
format, nelements, data),
g_free (prop_name),
g_free (type_name)));
if (property == gdk_selection_property
&& type == GDK_TARGET_STRING
&& format == 8
&& mode == GDK_PROP_MODE_REPLACE)
{
length = nelements;
ptr = data;
for (i = 0; i < nelements; i++)
if (*ptr++ == '\n')
length++;
#if 1
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (window)));
if (!OpenClipboard (GDK_DRAWABLE_XID (window)))
{
g_warning ("gdk_property_change: OpenClipboard failed");
return;
}
#endif
hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1);
ptr = GlobalLock (hdata);
GDK_NOTE (SELECTION, g_print ("...hdata=%#x, ptr=%#x\n", hdata, ptr));
for (i = 0; i < nelements; i++)
{
if (*data == '\n')
*ptr++ = '\r';
*ptr++ = *data++;
}
*ptr++ = '\0';
GlobalUnlock (hdata);
GDK_NOTE (SELECTION, g_print ("...SetClipboardData(CF_TEXT, %#x)\n",
hdata));
if (!SetClipboardData(CF_TEXT, hdata))
g_warning ("gdk_property_change: SetClipboardData failed: %d",
GetLastError ());
#if 1
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
if (!CloseClipboard ())
{
g_warning ("gdk_property_change: CloseClipboard failed");
return;
}
#endif
}
else
g_warning ("gdk_property_change: General case not implemented");
}
void
gdk_property_delete (GdkWindow *window,
GdkAtom property)
{
gchar *prop_name, *type_name;
extern void gdk_selection_property_delete (GdkWindow *);
if (GDK_DRAWABLE_DESTROYED (window))
return;
GDK_NOTE (SELECTION,
(prop_name = gdk_atom_name (property),
g_print ("gdk_property_delete: %#x %#x (%s)\n",
(window ? GDK_DRAWABLE_XID (window) : 0),
property, prop_name),
g_free (prop_name)));
if (property == gdk_selection_property)
gdk_selection_property_delete (window);
else
g_warning ("gdk_property_delete: General case not implemented");
}

View File

@ -1,228 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
#include "gdkproperty.h"
#include "gdkselection.h"
#include "gdkprivate.h"
#include "gdkx.h"
GdkAtom
gdk_atom_intern (const gchar *atom_name,
gint only_if_exists)
{
GdkAtom retval;
static GHashTable *atom_hash = NULL;
if (!atom_hash)
atom_hash = g_hash_table_new (g_str_hash, g_str_equal);
retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
if (!retval)
{
if (strcmp (atom_name, "PRIMARY") == 0)
retval = GDK_SELECTION_PRIMARY;
else if (strcmp (atom_name, "SECONDARY") == 0)
retval = GDK_SELECTION_SECONDARY;
else if (strcmp (atom_name, "ATOM") == 0)
retval = GDK_SELECTION_TYPE_ATOM;
else if (strcmp (atom_name, "BITMAP") == 0)
retval = GDK_SELECTION_TYPE_BITMAP;
else if (strcmp (atom_name, "COLORMAP") == 0)
retval = GDK_SELECTION_TYPE_COLORMAP;
else if (strcmp (atom_name, "DRAWABLE") == 0)
retval = GDK_SELECTION_TYPE_DRAWABLE;
else if (strcmp (atom_name, "INTEGER") == 0)
retval = GDK_SELECTION_TYPE_INTEGER;
else if (strcmp (atom_name, "PIXMAP") == 0)
retval = GDK_SELECTION_TYPE_PIXMAP;
else if (strcmp (atom_name, "WINDOW") == 0)
retval = GDK_SELECTION_TYPE_WINDOW;
else if (strcmp (atom_name, "STRING") == 0)
retval = GDK_SELECTION_TYPE_STRING;
else
{
retval = GlobalFindAtom (atom_name);
if (only_if_exists && retval == 0)
retval = 0;
else
retval = GlobalAddAtom (atom_name);
}
g_hash_table_insert (atom_hash,
g_strdup (atom_name),
GUINT_TO_POINTER (retval));
}
return retval;
}
gchar *
gdk_atom_name (GdkAtom atom)
{
gchar name[256];
switch (atom)
{
case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY");
case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY");
case GDK_SELECTION_TYPE_ATOM: return g_strdup ("ATOM");
case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP");
case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP");
case GDK_SELECTION_TYPE_DRAWABLE: return g_strdup ("DRAWABLE");
case GDK_SELECTION_TYPE_INTEGER: return g_strdup ("INTEGER");
case GDK_SELECTION_TYPE_PIXMAP: return g_strdup ("PIXMAP");
case GDK_SELECTION_TYPE_WINDOW: return g_strdup ("WINDOW");
case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING");
}
if (atom < 0xC000)
return g_strdup_printf ("#%x", atom);
else if (GlobalGetAtomName (atom, name, sizeof (name)) == 0)
return NULL;
return g_strdup (name);
}
gint
gdk_property_get (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_property_type,
gint *actual_format_type,
gint *actual_length,
guchar **data)
{
g_warning ("gdk_property_get: Not implemented");
return FALSE;
}
void
gdk_property_change (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
guchar *data,
gint nelements)
{
HGLOBAL hdata;
gint i, length;
gchar *prop_name, *type_name;
guchar *ptr;
if (GDK_DRAWABLE_DESTROYED (window))
return;
GDK_NOTE (SELECTION,
(prop_name = gdk_atom_name (property),
type_name = gdk_atom_name (type),
g_print ("gdk_property_change: %#x %#x (%s) %#x (%s) %s %d*%d bytes %.10s\n",
GDK_DRAWABLE_XID (window), property, prop_name,
type, type_name,
(mode == GDK_PROP_MODE_REPLACE ? "REPLACE" :
(mode == GDK_PROP_MODE_PREPEND ? "PREPEND" :
(mode == GDK_PROP_MODE_APPEND ? "APPEND" :
"???"))),
format, nelements, data),
g_free (prop_name),
g_free (type_name)));
if (property == gdk_selection_property
&& type == GDK_TARGET_STRING
&& format == 8
&& mode == GDK_PROP_MODE_REPLACE)
{
length = nelements;
ptr = data;
for (i = 0; i < nelements; i++)
if (*ptr++ == '\n')
length++;
#if 1
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (window)));
if (!OpenClipboard (GDK_DRAWABLE_XID (window)))
{
g_warning ("gdk_property_change: OpenClipboard failed");
return;
}
#endif
hdata = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, length + 1);
ptr = GlobalLock (hdata);
GDK_NOTE (SELECTION, g_print ("...hdata=%#x, ptr=%#x\n", hdata, ptr));
for (i = 0; i < nelements; i++)
{
if (*data == '\n')
*ptr++ = '\r';
*ptr++ = *data++;
}
*ptr++ = '\0';
GlobalUnlock (hdata);
GDK_NOTE (SELECTION, g_print ("...SetClipboardData(CF_TEXT, %#x)\n",
hdata));
if (!SetClipboardData(CF_TEXT, hdata))
g_warning ("gdk_property_change: SetClipboardData failed: %d",
GetLastError ());
#if 1
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
if (!CloseClipboard ())
{
g_warning ("gdk_property_change: CloseClipboard failed");
return;
}
#endif
}
else
g_warning ("gdk_property_change: General case not implemented");
}
void
gdk_property_delete (GdkWindow *window,
GdkAtom property)
{
gchar *prop_name, *type_name;
extern void gdk_selection_property_delete (GdkWindow *);
if (GDK_DRAWABLE_DESTROYED (window))
return;
GDK_NOTE (SELECTION,
(prop_name = gdk_atom_name (property),
g_print ("gdk_property_delete: %#x %#x (%s)\n",
(window ? GDK_DRAWABLE_XID (window) : 0),
property, prop_name),
g_free (prop_name)));
if (property == gdk_selection_property)
gdk_selection_property_delete (window);
else
g_warning ("gdk_property_delete: General case not implemented");
}

View File

@ -1,367 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdk.h"
#include "gdkprivate.h"
GdkRegion*
gdk_region_new (void)
{
GdkRegionPrivate *private;
GdkRegion *region;
HRGN xregion;
RECT emptyRect;
/* Create an empty region */
SetRectEmpty (&emptyRect);
xregion = CreateRectRgnIndirect (&emptyRect);
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion*) private;
region->user_data = NULL;
return region;
}
void
gdk_region_destroy (GdkRegion *region)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
DeleteObject (private->xregion);
g_free (private);
}
gboolean
gdk_region_empty (GdkRegion *region)
{
GdkRegionPrivate *private;
RECT rect;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return (GetRgnBox (private->xregion, &rect) == NULLREGION);
}
gboolean
gdk_region_equal (GdkRegion *region1,
GdkRegion *region2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
g_return_val_if_fail (region1 != NULL, 0);
g_return_val_if_fail (region2 != NULL, 0);
private1 = (GdkRegionPrivate *) region1;
private2 = (GdkRegionPrivate *) region2;
return EqualRgn (private1->xregion, private2->xregion);
}
void
gdk_region_get_clipbox(GdkRegion *region,
GdkRectangle *rectangle)
{
GdkRegionPrivate *rp;
RECT r;
g_return_if_fail(region != NULL);
g_return_if_fail(rectangle != NULL);
rp = (GdkRegionPrivate *)region;
GetRgnBox (rp->xregion, &r);
rectangle->x = r.left;
rectangle->y = r.top;
rectangle->width = r.right - r.left;
rectangle->height = r.bottom - r.top;
}
gboolean
gdk_region_point_in (GdkRegion *region,
gint x,
gint y)
{
GdkRegionPrivate *private;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return PtInRegion (private->xregion, x, y);
}
GdkOverlapType
gdk_region_rect_in (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
RECT r;
int res;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
r.left = rect->x;
r.top = rect->y;
r.right = rect->x + rect->width;
r.bottom = rect->y + rect->height;
if (RectInRegion (private->xregion, &r))
return GDK_OVERLAP_RECTANGLE_PART;
return GDK_OVERLAP_RECTANGLE_OUT; /*what else ? */
}
GdkRegion *
gdk_region_polygon (GdkPoint *points,
gint npoints,
GdkFillRule fill_rule)
{
GdkRegionPrivate *private;
GdkRegion *region;
HRGN xregion;
POINT *pts;
gint xfill_rule = ALTERNATE;
gint i;
g_return_val_if_fail (points != NULL, NULL);
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
switch (fill_rule)
{
case GDK_EVEN_ODD_RULE:
xfill_rule = ALTERNATE;
break;
case GDK_WINDING_RULE:
xfill_rule = WINDING;
break;
}
pts = g_malloc (npoints * sizeof (*pts));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
xregion = CreatePolygonRgn (pts, npoints, xfill_rule);
g_free (pts);
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion *) private;
region->user_data = NULL;
return region;
}
void
gdk_region_offset (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
OffsetRgn (private->xregion, dx, dy);
}
void
gdk_region_shrink (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
HRGN shrunken_bbox;
RECT r;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
if (dx > 0 || dy > 0)
{
/* We want to shrink it in one or both dimensions.
* Is it correct just to intersect it with a smaller bounding box?
* XXX
*/
GetRgnBox (private->xregion, &r);
if (dx > 0)
{
r.left += dx - dx/2;
r.right -= dx/2;
}
if (dy > 0)
{
r.top += dy - dy/2;
r.bottom -= dy/2;
}
shrunken_bbox = CreateRectRgnIndirect (&r);
CombineRgn (private->xregion, private->xregion,
shrunken_bbox, RGN_AND);
DeleteObject (shrunken_bbox);
}
else
{
/* Do nothing if the regions is expanded? XXX */
}
}
GdkRegion*
gdk_region_union_with_rect (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
GdkRegion *res;
GdkRegionPrivate *res_private;
RECT xrect;
HRGN rectangle;
g_return_val_if_fail (region != NULL, NULL);
private = (GdkRegionPrivate *) region;
xrect.left = rect->x;
xrect.top = rect->y;
xrect.right = rect->x + rect->width;
xrect.bottom = rect->y + rect->height;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
rectangle = CreateRectRgnIndirect (&xrect);
CombineRgn (res_private->xregion, private->xregion,
rectangle, RGN_OR);
DeleteObject (rectangle);
return res;
}
GdkRegion*
gdk_regions_intersect (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_AND);
return res;
}
GdkRegion*
gdk_regions_union (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_OR);
return res;
}
GdkRegion*
gdk_regions_subtract (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_DIFF);
return res;
}
GdkRegion*
gdk_regions_xor (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_XOR);
return res;
}

View File

@ -1,367 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdk.h"
#include "gdkprivate.h"
GdkRegion*
gdk_region_new (void)
{
GdkRegionPrivate *private;
GdkRegion *region;
HRGN xregion;
RECT emptyRect;
/* Create an empty region */
SetRectEmpty (&emptyRect);
xregion = CreateRectRgnIndirect (&emptyRect);
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion*) private;
region->user_data = NULL;
return region;
}
void
gdk_region_destroy (GdkRegion *region)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
DeleteObject (private->xregion);
g_free (private);
}
gboolean
gdk_region_empty (GdkRegion *region)
{
GdkRegionPrivate *private;
RECT rect;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return (GetRgnBox (private->xregion, &rect) == NULLREGION);
}
gboolean
gdk_region_equal (GdkRegion *region1,
GdkRegion *region2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
g_return_val_if_fail (region1 != NULL, 0);
g_return_val_if_fail (region2 != NULL, 0);
private1 = (GdkRegionPrivate *) region1;
private2 = (GdkRegionPrivate *) region2;
return EqualRgn (private1->xregion, private2->xregion);
}
void
gdk_region_get_clipbox(GdkRegion *region,
GdkRectangle *rectangle)
{
GdkRegionPrivate *rp;
RECT r;
g_return_if_fail(region != NULL);
g_return_if_fail(rectangle != NULL);
rp = (GdkRegionPrivate *)region;
GetRgnBox (rp->xregion, &r);
rectangle->x = r.left;
rectangle->y = r.top;
rectangle->width = r.right - r.left;
rectangle->height = r.bottom - r.top;
}
gboolean
gdk_region_point_in (GdkRegion *region,
gint x,
gint y)
{
GdkRegionPrivate *private;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
return PtInRegion (private->xregion, x, y);
}
GdkOverlapType
gdk_region_rect_in (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
RECT r;
int res;
g_return_val_if_fail (region != NULL, 0);
private = (GdkRegionPrivate *) region;
r.left = rect->x;
r.top = rect->y;
r.right = rect->x + rect->width;
r.bottom = rect->y + rect->height;
if (RectInRegion (private->xregion, &r))
return GDK_OVERLAP_RECTANGLE_PART;
return GDK_OVERLAP_RECTANGLE_OUT; /*what else ? */
}
GdkRegion *
gdk_region_polygon (GdkPoint *points,
gint npoints,
GdkFillRule fill_rule)
{
GdkRegionPrivate *private;
GdkRegion *region;
HRGN xregion;
POINT *pts;
gint xfill_rule = ALTERNATE;
gint i;
g_return_val_if_fail (points != NULL, NULL);
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
switch (fill_rule)
{
case GDK_EVEN_ODD_RULE:
xfill_rule = ALTERNATE;
break;
case GDK_WINDING_RULE:
xfill_rule = WINDING;
break;
}
pts = g_malloc (npoints * sizeof (*pts));
for (i = 0; i < npoints; i++)
{
pts[i].x = points[i].x;
pts[i].y = points[i].y;
}
xregion = CreatePolygonRgn (pts, npoints, xfill_rule);
g_free (pts);
private = g_new (GdkRegionPrivate, 1);
private->xregion = xregion;
region = (GdkRegion *) private;
region->user_data = NULL;
return region;
}
void
gdk_region_offset (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
OffsetRgn (private->xregion, dx, dy);
}
void
gdk_region_shrink (GdkRegion *region,
gint dx,
gint dy)
{
GdkRegionPrivate *private;
HRGN shrunken_bbox;
RECT r;
g_return_if_fail (region != NULL);
private = (GdkRegionPrivate *) region;
if (dx > 0 || dy > 0)
{
/* We want to shrink it in one or both dimensions.
* Is it correct just to intersect it with a smaller bounding box?
* XXX
*/
GetRgnBox (private->xregion, &r);
if (dx > 0)
{
r.left += dx - dx/2;
r.right -= dx/2;
}
if (dy > 0)
{
r.top += dy - dy/2;
r.bottom -= dy/2;
}
shrunken_bbox = CreateRectRgnIndirect (&r);
CombineRgn (private->xregion, private->xregion,
shrunken_bbox, RGN_AND);
DeleteObject (shrunken_bbox);
}
else
{
/* Do nothing if the regions is expanded? XXX */
}
}
GdkRegion*
gdk_region_union_with_rect (GdkRegion *region,
GdkRectangle *rect)
{
GdkRegionPrivate *private;
GdkRegion *res;
GdkRegionPrivate *res_private;
RECT xrect;
HRGN rectangle;
g_return_val_if_fail (region != NULL, NULL);
private = (GdkRegionPrivate *) region;
xrect.left = rect->x;
xrect.top = rect->y;
xrect.right = rect->x + rect->width;
xrect.bottom = rect->y + rect->height;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
rectangle = CreateRectRgnIndirect (&xrect);
CombineRgn (res_private->xregion, private->xregion,
rectangle, RGN_OR);
DeleteObject (rectangle);
return res;
}
GdkRegion*
gdk_regions_intersect (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_AND);
return res;
}
GdkRegion*
gdk_regions_union (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_OR);
return res;
}
GdkRegion*
gdk_regions_subtract (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_DIFF);
return res;
}
GdkRegion*
gdk_regions_xor (GdkRegion *source1,
GdkRegion *source2)
{
GdkRegionPrivate *private1;
GdkRegionPrivate *private2;
GdkRegion *res;
GdkRegionPrivate *res_private;
g_return_val_if_fail (source1 != NULL, NULL);
g_return_val_if_fail (source2 != NULL, NULL);
private1 = (GdkRegionPrivate *) source1;
private2 = (GdkRegionPrivate *) source2;
res = gdk_region_new ();
res_private = (GdkRegionPrivate *) res;
CombineRgn (res_private->xregion, private1->xregion, private2->xregion,
RGN_XOR);
return res;
}

View File

@ -1,403 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
#include <gdk/gdk.h>
#include "gdkx.h"
/* We emulate the GDK_SELECTION window properties by storing
* it's data in a per-window hashtable.
*/
typedef struct {
guchar *data;
gint length;
gint format;
GdkAtom type;
} GdkSelProp;
static GHashTable *sel_prop_table = NULL;
void
gdk_selection_init (void)
{
if (sel_prop_table == NULL)
sel_prop_table = g_hash_table_new (g_int_hash, g_int_equal);
}
void
gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length)
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (owner));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (owner));
}
prop = g_new (GdkSelProp, 1);
prop->data = data;
prop->length = length;
prop->format = format;
prop->type = type;
g_hash_table_insert (sel_prop_table, &GDK_DRAWABLE_XID (owner), prop);
}
gint
gdk_selection_owner_set (GdkWindow *owner,
GdkAtom selection,
guint32 time,
gint send_event)
{
gchar *sel_name;
HWND xwindow;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
g_print ("gdk_selection_owner_set: %#x %#x (%s)\n",
(owner ? GDK_DRAWABLE_XID (owner) : 0),
selection, sel_name),
g_free (sel_name)));
if (selection != gdk_clipboard_atom)
return FALSE;
if (owner != NULL)
xwindow = GDK_DRAWABLE_XID (owner);
else
xwindow = NULL;
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n", xwindow));
if (!OpenClipboard (xwindow))
{
g_warning ("gdk_selection_owner_set: OpenClipboard failed");
return FALSE;
}
GDK_NOTE (SELECTION, g_print ("...EmptyClipboard()\n"));
if (!EmptyClipboard ())
{
g_warning ("gdk_selection_owner_set: EmptyClipboard failed");
CloseClipboard ();
return FALSE;
}
#if 0
/* No delayed rendering */
if (xwindow != NULL)
SetClipboardData (CF_TEXT, NULL);
#endif
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
if (!CloseClipboard ())
{
g_warning ("gdk_selection_owner_set: CloseClipboard failed");
return FALSE;
}
if (owner != NULL)
{
/* Send ourselves an ersatz selection request message so that
* gdk_property_change will be called to store the clipboard data.
*/
SendMessage (xwindow, gdk_selection_request_msg,
selection, 0);
}
return TRUE;
}
GdkWindow*
gdk_selection_owner_get (GdkAtom selection)
{
GdkWindow *window;
gchar *sel_name;
#if 1
/* XXX Hmm, gtk selections seem to work best with this. This causes
* gtk to always get the clipboard contents from Windows, and not
* from the editable's own stashed-away copy.
*/
return NULL;
#else
if (selection != gdk_clipboard_atom)
window = NULL;
else
window = gdk_window_lookup (GetClipboardOwner ());
#endif
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
g_print ("gdk_selection_owner_get: %#x (%s) = %#x\n",
selection, sel_name,
(window ? GDK_DRAWABLE_XID (window) : 0)),
g_free (sel_name)));
return window;
}
void
gdk_selection_convert (GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
HGLOBAL hdata;
GdkSelProp *prop;
guchar *ptr, *data, *datap, *p;
guint i, length, slength;
gchar *sel_name, *tgt_name;
g_return_if_fail (requestor != NULL);
if (GDK_DRAWABLE_DESTROYED (requestor))
return;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
tgt_name = gdk_atom_name (target),
g_print ("gdk_selection_convert: %#x %#x (%s) %#x (%s)\n",
GDK_DRAWABLE_XID (requestor), selection, sel_name, target, tgt_name),
g_free (sel_name),
g_free (tgt_name)));
if (selection == gdk_clipboard_atom)
{
/* Converting the CLIPBOARD selection means he wants the
* contents of the clipboard. Get the clipboard data,
* and store it for later.
*/
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (requestor)));
if (!OpenClipboard (GDK_DRAWABLE_XID (requestor)))
{
g_warning ("gdk_selection_convert: OpenClipboard failed");
return;
}
GDK_NOTE (SELECTION, g_print ("...GetClipboardData(CF_TEXT)\n"));
if ((hdata = GetClipboardData (CF_TEXT)) != NULL)
{
if ((ptr = GlobalLock (hdata)) != NULL)
{
length = GlobalSize (hdata);
GDK_NOTE (SELECTION, g_print ("...got data: %d bytes: %.10s\n",
length, ptr));
slength = 0;
p = ptr;
for (i = 0; i < length; i++)
{
if (*p == '\0')
break;
else if (*p != '\r')
slength++;
p++;
}
data = datap = g_malloc (slength + 1);
p = ptr;
for (i = 0; i < length; i++)
{
if (*p == '\0')
break;
else if (*p != '\r')
*datap++ = *p;
p++;
}
*datap++ = '\0';
gdk_sel_prop_store (requestor, GDK_TARGET_STRING, 8,
data, strlen (data) + 1);
GlobalUnlock (hdata);
}
}
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
CloseClipboard ();
/* Send ourselves an ersatz selection notify message so that we actually
* fetch the data.
*/
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
}
else if (selection == gdk_win32_dropfiles_atom)
{
/* This means he wants the names of the dropped files.
* gdk_dropfiles_filter already has stored the text/uri-list
* data, tempoarily on gdk_root_parent's selection "property".
*/
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &gdk_root_parent->drawable.xwindow);
if (prop != NULL)
{
g_hash_table_remove (sel_prop_table, &gdk_root_parent->drawable.xwindow);
gdk_sel_prop_store (requestor, prop->type, prop->format,
prop->data, prop->length);
g_free (prop);
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
}
}
else
{
g_warning ("gdk_selection_convert: General case not implemented");
}
}
gint
gdk_selection_property_get (GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
GdkSelProp *prop;
g_return_val_if_fail (requestor != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
if (GDK_DRAWABLE_DESTROYED (requestor))
return 0;
GDK_NOTE (SELECTION, g_print ("gdk_selection_property_get: %#x\n",
GDK_DRAWABLE_XID (requestor)));
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (requestor));
if (prop == NULL)
{
*data = NULL;
return 0;
}
*data = g_malloc (prop->length);
if (prop->length > 0)
memmove (*data, prop->data, prop->length);
if (ret_type)
*ret_type = prop->type;
if (ret_format)
*ret_format = prop->format;
return prop->length;
}
void
gdk_selection_property_delete (GdkWindow *window)
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (window));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (window));
}
else
g_warning ("huh?");
}
void
gdk_selection_send_notify (guint32 requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
gchar *sel_name, *tgt_name, *prop_name;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
tgt_name = gdk_atom_name (target),
prop_name = gdk_atom_name (property),
g_print ("gdk_selection_send_notify: %#x %#x (%s) %#x (%s) %#x (%s)\n",
requestor,
selection, sel_name,
target, tgt_name,
property, prop_name),
g_free (sel_name),
g_free (tgt_name),
g_free (prop_name)));
/* Send ourselves a selection clear message so that gtk thinks we don't
* have the selection, and will claim it anew when needed, and
* we thus get a chance to store data in the Windows clipboard.
* Otherwise, if a gtkeditable does a copy to clipboard several times
* only the first one actually gets copied to the Windows clipboard,
* as only he first one causes a call to gdk_property_change.
*
* Hmm, there is something fishy with this. Cut and paste inside the
* same app didn't work, the gtkeditable immediately forgot the
* clipboard contents in gtk_editable_selection_clear as a result of
* this message. OTOH, when I changed gdk_selection_owner_get to
* always return NULL, it works. Sigh.
*/
SendMessage ((HWND) requestor, gdk_selection_clear_msg, selection, 0);
}
gint
gdk_text_property_to_text_list (GdkAtom encoding,
gint format,
guchar *text,
gint length,
gchar ***list)
{
GDK_NOTE (SELECTION,
g_print ("gdk_text_property_to_text_list not implemented\n"));
return 0;
}
void
gdk_free_text_list (gchar **list)
{
g_return_if_fail (list != NULL);
/* ??? */
}
gint
gdk_string_to_compound_text (gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
{
g_warning ("gdk_string_to_compound_text: Not implemented");
return 0;
}
void
gdk_free_compound_text (guchar *ctext)
{
g_warning ("gdk_free_compound_text: Not implemented");
}

View File

@ -1,403 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include <string.h>
#include <gdk/gdk.h>
#include "gdkx.h"
/* We emulate the GDK_SELECTION window properties by storing
* it's data in a per-window hashtable.
*/
typedef struct {
guchar *data;
gint length;
gint format;
GdkAtom type;
} GdkSelProp;
static GHashTable *sel_prop_table = NULL;
void
gdk_selection_init (void)
{
if (sel_prop_table == NULL)
sel_prop_table = g_hash_table_new (g_int_hash, g_int_equal);
}
void
gdk_sel_prop_store (GdkWindow *owner,
GdkAtom type,
gint format,
guchar *data,
gint length)
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (owner));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (owner));
}
prop = g_new (GdkSelProp, 1);
prop->data = data;
prop->length = length;
prop->format = format;
prop->type = type;
g_hash_table_insert (sel_prop_table, &GDK_DRAWABLE_XID (owner), prop);
}
gint
gdk_selection_owner_set (GdkWindow *owner,
GdkAtom selection,
guint32 time,
gint send_event)
{
gchar *sel_name;
HWND xwindow;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
g_print ("gdk_selection_owner_set: %#x %#x (%s)\n",
(owner ? GDK_DRAWABLE_XID (owner) : 0),
selection, sel_name),
g_free (sel_name)));
if (selection != gdk_clipboard_atom)
return FALSE;
if (owner != NULL)
xwindow = GDK_DRAWABLE_XID (owner);
else
xwindow = NULL;
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n", xwindow));
if (!OpenClipboard (xwindow))
{
g_warning ("gdk_selection_owner_set: OpenClipboard failed");
return FALSE;
}
GDK_NOTE (SELECTION, g_print ("...EmptyClipboard()\n"));
if (!EmptyClipboard ())
{
g_warning ("gdk_selection_owner_set: EmptyClipboard failed");
CloseClipboard ();
return FALSE;
}
#if 0
/* No delayed rendering */
if (xwindow != NULL)
SetClipboardData (CF_TEXT, NULL);
#endif
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
if (!CloseClipboard ())
{
g_warning ("gdk_selection_owner_set: CloseClipboard failed");
return FALSE;
}
if (owner != NULL)
{
/* Send ourselves an ersatz selection request message so that
* gdk_property_change will be called to store the clipboard data.
*/
SendMessage (xwindow, gdk_selection_request_msg,
selection, 0);
}
return TRUE;
}
GdkWindow*
gdk_selection_owner_get (GdkAtom selection)
{
GdkWindow *window;
gchar *sel_name;
#if 1
/* XXX Hmm, gtk selections seem to work best with this. This causes
* gtk to always get the clipboard contents from Windows, and not
* from the editable's own stashed-away copy.
*/
return NULL;
#else
if (selection != gdk_clipboard_atom)
window = NULL;
else
window = gdk_window_lookup (GetClipboardOwner ());
#endif
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
g_print ("gdk_selection_owner_get: %#x (%s) = %#x\n",
selection, sel_name,
(window ? GDK_DRAWABLE_XID (window) : 0)),
g_free (sel_name)));
return window;
}
void
gdk_selection_convert (GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
HGLOBAL hdata;
GdkSelProp *prop;
guchar *ptr, *data, *datap, *p;
guint i, length, slength;
gchar *sel_name, *tgt_name;
g_return_if_fail (requestor != NULL);
if (GDK_DRAWABLE_DESTROYED (requestor))
return;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
tgt_name = gdk_atom_name (target),
g_print ("gdk_selection_convert: %#x %#x (%s) %#x (%s)\n",
GDK_DRAWABLE_XID (requestor), selection, sel_name, target, tgt_name),
g_free (sel_name),
g_free (tgt_name)));
if (selection == gdk_clipboard_atom)
{
/* Converting the CLIPBOARD selection means he wants the
* contents of the clipboard. Get the clipboard data,
* and store it for later.
*/
GDK_NOTE (SELECTION, g_print ("...OpenClipboard(%#x)\n",
GDK_DRAWABLE_XID (requestor)));
if (!OpenClipboard (GDK_DRAWABLE_XID (requestor)))
{
g_warning ("gdk_selection_convert: OpenClipboard failed");
return;
}
GDK_NOTE (SELECTION, g_print ("...GetClipboardData(CF_TEXT)\n"));
if ((hdata = GetClipboardData (CF_TEXT)) != NULL)
{
if ((ptr = GlobalLock (hdata)) != NULL)
{
length = GlobalSize (hdata);
GDK_NOTE (SELECTION, g_print ("...got data: %d bytes: %.10s\n",
length, ptr));
slength = 0;
p = ptr;
for (i = 0; i < length; i++)
{
if (*p == '\0')
break;
else if (*p != '\r')
slength++;
p++;
}
data = datap = g_malloc (slength + 1);
p = ptr;
for (i = 0; i < length; i++)
{
if (*p == '\0')
break;
else if (*p != '\r')
*datap++ = *p;
p++;
}
*datap++ = '\0';
gdk_sel_prop_store (requestor, GDK_TARGET_STRING, 8,
data, strlen (data) + 1);
GlobalUnlock (hdata);
}
}
GDK_NOTE (SELECTION, g_print ("...CloseClipboard()\n"));
CloseClipboard ();
/* Send ourselves an ersatz selection notify message so that we actually
* fetch the data.
*/
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
}
else if (selection == gdk_win32_dropfiles_atom)
{
/* This means he wants the names of the dropped files.
* gdk_dropfiles_filter already has stored the text/uri-list
* data, tempoarily on gdk_root_parent's selection "property".
*/
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &gdk_root_parent->drawable.xwindow);
if (prop != NULL)
{
g_hash_table_remove (sel_prop_table, &gdk_root_parent->drawable.xwindow);
gdk_sel_prop_store (requestor, prop->type, prop->format,
prop->data, prop->length);
g_free (prop);
SendMessage (GDK_DRAWABLE_XID (requestor), gdk_selection_notify_msg, selection, target);
}
}
else
{
g_warning ("gdk_selection_convert: General case not implemented");
}
}
gint
gdk_selection_property_get (GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
GdkSelProp *prop;
g_return_val_if_fail (requestor != NULL, 0);
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
if (GDK_DRAWABLE_DESTROYED (requestor))
return 0;
GDK_NOTE (SELECTION, g_print ("gdk_selection_property_get: %#x\n",
GDK_DRAWABLE_XID (requestor)));
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (requestor));
if (prop == NULL)
{
*data = NULL;
return 0;
}
*data = g_malloc (prop->length);
if (prop->length > 0)
memmove (*data, prop->data, prop->length);
if (ret_type)
*ret_type = prop->type;
if (ret_format)
*ret_format = prop->format;
return prop->length;
}
void
gdk_selection_property_delete (GdkWindow *window)
{
GdkSelProp *prop;
prop = g_hash_table_lookup (sel_prop_table, &GDK_DRAWABLE_XID (window));
if (prop != NULL)
{
g_free (prop->data);
g_hash_table_remove (sel_prop_table, &GDK_DRAWABLE_XID (window));
}
else
g_warning ("huh?");
}
void
gdk_selection_send_notify (guint32 requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
gchar *sel_name, *tgt_name, *prop_name;
GDK_NOTE (SELECTION,
(sel_name = gdk_atom_name (selection),
tgt_name = gdk_atom_name (target),
prop_name = gdk_atom_name (property),
g_print ("gdk_selection_send_notify: %#x %#x (%s) %#x (%s) %#x (%s)\n",
requestor,
selection, sel_name,
target, tgt_name,
property, prop_name),
g_free (sel_name),
g_free (tgt_name),
g_free (prop_name)));
/* Send ourselves a selection clear message so that gtk thinks we don't
* have the selection, and will claim it anew when needed, and
* we thus get a chance to store data in the Windows clipboard.
* Otherwise, if a gtkeditable does a copy to clipboard several times
* only the first one actually gets copied to the Windows clipboard,
* as only he first one causes a call to gdk_property_change.
*
* Hmm, there is something fishy with this. Cut and paste inside the
* same app didn't work, the gtkeditable immediately forgot the
* clipboard contents in gtk_editable_selection_clear as a result of
* this message. OTOH, when I changed gdk_selection_owner_get to
* always return NULL, it works. Sigh.
*/
SendMessage ((HWND) requestor, gdk_selection_clear_msg, selection, 0);
}
gint
gdk_text_property_to_text_list (GdkAtom encoding,
gint format,
guchar *text,
gint length,
gchar ***list)
{
GDK_NOTE (SELECTION,
g_print ("gdk_text_property_to_text_list not implemented\n"));
return 0;
}
void
gdk_free_text_list (gchar **list)
{
g_return_if_fail (list != NULL);
/* ??? */
}
gint
gdk_string_to_compound_text (gchar *str,
GdkAtom *encoding,
gint *format,
guchar **ctext,
gint *length)
{
g_warning ("gdk_string_to_compound_text: Not implemented");
return 0;
}
void
gdk_free_compound_text (guchar *ctext)
{
g_warning ("gdk_free_compound_text: Not implemented");
}

View File

@ -1,346 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdkvisual.h"
#include "gdkprivate.h"
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
static GdkVisualPrivate *system_visual;
static gint available_depths[1];
static GdkVisualType available_types[1];
#ifdef G_ENABLE_DEBUG
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
"static color",
"pseudo color",
"true color",
"direct color",
};
#endif /* G_ENABLE_DEBUG */
void
gdk_visual_init (void)
{
struct
{
BITMAPINFOHEADER bi;
union
{
RGBQUAD colors[256];
DWORD fields[256];
} u;
} bmi;
HBITMAP hbm;
int rastercaps, numcolors, sizepalette, bitspixel;
system_visual = g_new (GdkVisualPrivate, 1);
bitspixel = GetDeviceCaps (gdk_DC, BITSPIXEL);
rastercaps = GetDeviceCaps (gdk_DC, RASTERCAPS);
system_visual->xvisual = g_new (Visual, 1);
system_visual->xvisual->visualid = 0;
system_visual->xvisual->bitspixel = bitspixel;
if (rastercaps & RC_PALETTE)
{
system_visual->visual.type = GDK_VISUAL_PSEUDO_COLOR;
numcolors = GetDeviceCaps (gdk_DC, NUMCOLORS);
sizepalette = GetDeviceCaps (gdk_DC, SIZEPALETTE);
system_visual->xvisual->map_entries = sizepalette;
}
else if (bitspixel == 1)
{
system_visual->visual.type = GDK_VISUAL_STATIC_GRAY;
system_visual->xvisual->map_entries = 2;
}
else if (bitspixel == 4)
{
system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
system_visual->xvisual->map_entries = 16;
}
else if (bitspixel == 8)
{
system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
system_visual->xvisual->map_entries = 256;
}
else if (bitspixel == 16)
{
system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
#if 1
/* This code by Mike Enright,
* see http://www.users.cts.com/sd/m/menright/display.html
*/
memset (&bmi, 0, sizeof (bmi));
bmi.bi.biSize = sizeof (bmi.bi);
hbm = CreateCompatibleBitmap (gdk_DC, 1, 1);
GetDIBits (gdk_DC, hbm, 0, 1, NULL,
(BITMAPINFO *) &bmi, DIB_RGB_COLORS);
GetDIBits (gdk_DC, hbm, 0, 1, NULL,
(BITMAPINFO *) &bmi, DIB_RGB_COLORS);
DeleteObject (hbm);
if (bmi.bi.biCompression != BI_BITFIELDS)
{
/* Either BI_RGB or BI_RLE_something
* .... or perhaps (!!) something else.
* Theoretically biCompression might be
* mmioFourCC('c','v','i','d') but I doubt it.
*/
if (bmi.bi.biCompression == BI_RGB)
{
/* It's 555 */
bitspixel = 15;
system_visual->visual.red_mask = 0x00007C00;
system_visual->visual.green_mask = 0x000003E0;
system_visual->visual.blue_mask = 0x0000001F;
}
else
{
g_assert_not_reached ();
}
}
else
{
DWORD allmasks =
bmi.u.fields[0] | bmi.u.fields[1] | bmi.u.fields[2];
int k = 0;
while (allmasks)
{
if (allmasks&1)
k++;
allmasks/=2;
}
bitspixel = k;
system_visual->visual.red_mask = bmi.u.fields[0];
system_visual->visual.green_mask = bmi.u.fields[1];
system_visual->visual.blue_mask = bmi.u.fields[2];
}
#else
/* Old, incorrect (but still working) code. */
#if 0
system_visual->visual.red_mask = 0x0000F800;
system_visual->visual.green_mask = 0x000007E0;
system_visual->visual.blue_mask = 0x0000001F;
#else
system_visual->visual.red_mask = 0x00007C00;
system_visual->visual.green_mask = 0x000003E0;
system_visual->visual.blue_mask = 0x0000001F;
#endif
#endif
}
else if (bitspixel == 24 || bitspixel == 32)
{
bitspixel = 24;
system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
system_visual->visual.red_mask = 0x00FF0000;
system_visual->visual.green_mask = 0x0000FF00;
system_visual->visual.blue_mask = 0x000000FF;
}
else
g_error ("gdk_visual_init: unsupported BITSPIXEL: %d\n", bitspixel);
system_visual->visual.depth = bitspixel;
system_visual->visual.byte_order = GDK_LSB_FIRST;
system_visual->visual.bits_per_rgb = 42; /* Not used? */
if ((system_visual->visual.type == GDK_VISUAL_TRUE_COLOR) ||
(system_visual->visual.type == GDK_VISUAL_DIRECT_COLOR))
{
gdk_visual_decompose_mask (system_visual->visual.red_mask,
&system_visual->visual.red_shift,
&system_visual->visual.red_prec);
gdk_visual_decompose_mask (system_visual->visual.green_mask,
&system_visual->visual.green_shift,
&system_visual->visual.green_prec);
gdk_visual_decompose_mask (system_visual->visual.blue_mask,
&system_visual->visual.blue_shift,
&system_visual->visual.blue_prec);
system_visual->xvisual->map_entries =
1 << (MAX (system_visual->visual.red_prec,
MAX (system_visual->visual.green_prec,
system_visual->visual.blue_prec)));
}
else
{
system_visual->visual.red_mask = 0;
system_visual->visual.red_shift = 0;
system_visual->visual.red_prec = 0;
system_visual->visual.green_mask = 0;
system_visual->visual.green_shift = 0;
system_visual->visual.green_prec = 0;
system_visual->visual.blue_mask = 0;
system_visual->visual.blue_shift = 0;
system_visual->visual.blue_prec = 0;
}
system_visual->visual.colormap_size = system_visual->xvisual->map_entries;
available_depths[0] = system_visual->visual.depth;
available_types[0] = system_visual->visual.type;
}
GdkVisual*
gdk_visual_ref (GdkVisual *visual)
{
return visual;
}
void
gdk_visual_unref (GdkVisual *visual)
{
return;
}
gint
gdk_visual_get_best_depth (void)
{
return available_depths[0];
}
GdkVisualType
gdk_visual_get_best_type (void)
{
return available_types[0];
}
GdkVisual*
gdk_visual_get_system (void)
{
return ((GdkVisual*) system_visual);
}
GdkVisual*
gdk_visual_get_best (void)
{
return ((GdkVisual*) system_visual);
}
GdkVisual*
gdk_visual_get_best_with_depth (gint depth)
{
if (depth == system_visual->visual.depth)
return (GdkVisual*) system_visual;
else
return NULL;
}
GdkVisual*
gdk_visual_get_best_with_type (GdkVisualType visual_type)
{
if (visual_type == system_visual->visual.type)
return (GdkVisual*) system_visual;
else
return NULL;
}
GdkVisual*
gdk_visual_get_best_with_both (gint depth,
GdkVisualType visual_type)
{
if ((depth == system_visual->visual.depth) &&
(visual_type == system_visual->visual.type))
return (GdkVisual*) system_visual;
else
return NULL;
}
void
gdk_query_depths (gint **depths,
gint *count)
{
*count = 1;
*depths = available_depths;
}
void
gdk_query_visual_types (GdkVisualType **visual_types,
gint *count)
{
*count = 1;
*visual_types = available_types;
}
GList*
gdk_list_visuals (void)
{
return g_list_append (NULL, (gpointer) system_visual);
}
GdkVisual*
gdk_visual_lookup (Visual *xvisual)
{
if (system_visual->xvisual == xvisual)
return (GdkVisual *) system_visual;
else
return NULL;
}
GdkVisual*
gdkx_visual_get (VisualID xvisualid)
{
if (xvisualid == system_visual->xvisual->visualid)
return (GdkVisual*) system_visual;
else
return NULL;
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

View File

@ -1,346 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 "gdkvisual.h"
#include "gdkprivate.h"
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
static GdkVisualPrivate *system_visual;
static gint available_depths[1];
static GdkVisualType available_types[1];
#ifdef G_ENABLE_DEBUG
static const gchar* visual_names[] =
{
"static gray",
"grayscale",
"static color",
"pseudo color",
"true color",
"direct color",
};
#endif /* G_ENABLE_DEBUG */
void
gdk_visual_init (void)
{
struct
{
BITMAPINFOHEADER bi;
union
{
RGBQUAD colors[256];
DWORD fields[256];
} u;
} bmi;
HBITMAP hbm;
int rastercaps, numcolors, sizepalette, bitspixel;
system_visual = g_new (GdkVisualPrivate, 1);
bitspixel = GetDeviceCaps (gdk_DC, BITSPIXEL);
rastercaps = GetDeviceCaps (gdk_DC, RASTERCAPS);
system_visual->xvisual = g_new (Visual, 1);
system_visual->xvisual->visualid = 0;
system_visual->xvisual->bitspixel = bitspixel;
if (rastercaps & RC_PALETTE)
{
system_visual->visual.type = GDK_VISUAL_PSEUDO_COLOR;
numcolors = GetDeviceCaps (gdk_DC, NUMCOLORS);
sizepalette = GetDeviceCaps (gdk_DC, SIZEPALETTE);
system_visual->xvisual->map_entries = sizepalette;
}
else if (bitspixel == 1)
{
system_visual->visual.type = GDK_VISUAL_STATIC_GRAY;
system_visual->xvisual->map_entries = 2;
}
else if (bitspixel == 4)
{
system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
system_visual->xvisual->map_entries = 16;
}
else if (bitspixel == 8)
{
system_visual->visual.type = GDK_VISUAL_STATIC_COLOR;
system_visual->xvisual->map_entries = 256;
}
else if (bitspixel == 16)
{
system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
#if 1
/* This code by Mike Enright,
* see http://www.users.cts.com/sd/m/menright/display.html
*/
memset (&bmi, 0, sizeof (bmi));
bmi.bi.biSize = sizeof (bmi.bi);
hbm = CreateCompatibleBitmap (gdk_DC, 1, 1);
GetDIBits (gdk_DC, hbm, 0, 1, NULL,
(BITMAPINFO *) &bmi, DIB_RGB_COLORS);
GetDIBits (gdk_DC, hbm, 0, 1, NULL,
(BITMAPINFO *) &bmi, DIB_RGB_COLORS);
DeleteObject (hbm);
if (bmi.bi.biCompression != BI_BITFIELDS)
{
/* Either BI_RGB or BI_RLE_something
* .... or perhaps (!!) something else.
* Theoretically biCompression might be
* mmioFourCC('c','v','i','d') but I doubt it.
*/
if (bmi.bi.biCompression == BI_RGB)
{
/* It's 555 */
bitspixel = 15;
system_visual->visual.red_mask = 0x00007C00;
system_visual->visual.green_mask = 0x000003E0;
system_visual->visual.blue_mask = 0x0000001F;
}
else
{
g_assert_not_reached ();
}
}
else
{
DWORD allmasks =
bmi.u.fields[0] | bmi.u.fields[1] | bmi.u.fields[2];
int k = 0;
while (allmasks)
{
if (allmasks&1)
k++;
allmasks/=2;
}
bitspixel = k;
system_visual->visual.red_mask = bmi.u.fields[0];
system_visual->visual.green_mask = bmi.u.fields[1];
system_visual->visual.blue_mask = bmi.u.fields[2];
}
#else
/* Old, incorrect (but still working) code. */
#if 0
system_visual->visual.red_mask = 0x0000F800;
system_visual->visual.green_mask = 0x000007E0;
system_visual->visual.blue_mask = 0x0000001F;
#else
system_visual->visual.red_mask = 0x00007C00;
system_visual->visual.green_mask = 0x000003E0;
system_visual->visual.blue_mask = 0x0000001F;
#endif
#endif
}
else if (bitspixel == 24 || bitspixel == 32)
{
bitspixel = 24;
system_visual->visual.type = GDK_VISUAL_TRUE_COLOR;
system_visual->visual.red_mask = 0x00FF0000;
system_visual->visual.green_mask = 0x0000FF00;
system_visual->visual.blue_mask = 0x000000FF;
}
else
g_error ("gdk_visual_init: unsupported BITSPIXEL: %d\n", bitspixel);
system_visual->visual.depth = bitspixel;
system_visual->visual.byte_order = GDK_LSB_FIRST;
system_visual->visual.bits_per_rgb = 42; /* Not used? */
if ((system_visual->visual.type == GDK_VISUAL_TRUE_COLOR) ||
(system_visual->visual.type == GDK_VISUAL_DIRECT_COLOR))
{
gdk_visual_decompose_mask (system_visual->visual.red_mask,
&system_visual->visual.red_shift,
&system_visual->visual.red_prec);
gdk_visual_decompose_mask (system_visual->visual.green_mask,
&system_visual->visual.green_shift,
&system_visual->visual.green_prec);
gdk_visual_decompose_mask (system_visual->visual.blue_mask,
&system_visual->visual.blue_shift,
&system_visual->visual.blue_prec);
system_visual->xvisual->map_entries =
1 << (MAX (system_visual->visual.red_prec,
MAX (system_visual->visual.green_prec,
system_visual->visual.blue_prec)));
}
else
{
system_visual->visual.red_mask = 0;
system_visual->visual.red_shift = 0;
system_visual->visual.red_prec = 0;
system_visual->visual.green_mask = 0;
system_visual->visual.green_shift = 0;
system_visual->visual.green_prec = 0;
system_visual->visual.blue_mask = 0;
system_visual->visual.blue_shift = 0;
system_visual->visual.blue_prec = 0;
}
system_visual->visual.colormap_size = system_visual->xvisual->map_entries;
available_depths[0] = system_visual->visual.depth;
available_types[0] = system_visual->visual.type;
}
GdkVisual*
gdk_visual_ref (GdkVisual *visual)
{
return visual;
}
void
gdk_visual_unref (GdkVisual *visual)
{
return;
}
gint
gdk_visual_get_best_depth (void)
{
return available_depths[0];
}
GdkVisualType
gdk_visual_get_best_type (void)
{
return available_types[0];
}
GdkVisual*
gdk_visual_get_system (void)
{
return ((GdkVisual*) system_visual);
}
GdkVisual*
gdk_visual_get_best (void)
{
return ((GdkVisual*) system_visual);
}
GdkVisual*
gdk_visual_get_best_with_depth (gint depth)
{
if (depth == system_visual->visual.depth)
return (GdkVisual*) system_visual;
else
return NULL;
}
GdkVisual*
gdk_visual_get_best_with_type (GdkVisualType visual_type)
{
if (visual_type == system_visual->visual.type)
return (GdkVisual*) system_visual;
else
return NULL;
}
GdkVisual*
gdk_visual_get_best_with_both (gint depth,
GdkVisualType visual_type)
{
if ((depth == system_visual->visual.depth) &&
(visual_type == system_visual->visual.type))
return (GdkVisual*) system_visual;
else
return NULL;
}
void
gdk_query_depths (gint **depths,
gint *count)
{
*count = 1;
*depths = available_depths;
}
void
gdk_query_visual_types (GdkVisualType **visual_types,
gint *count)
{
*count = 1;
*visual_types = available_types;
}
GList*
gdk_list_visuals (void)
{
return g_list_append (NULL, (gpointer) system_visual);
}
GdkVisual*
gdk_visual_lookup (Visual *xvisual)
{
if (system_visual->xvisual == xvisual)
return (GdkVisual *) system_visual;
else
return NULL;
}
GdkVisual*
gdkx_visual_get (VisualID xvisualid)
{
if (xvisualid == system_visual->xvisual->visualid)
return (GdkVisual*) system_visual;
else
return NULL;
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

View File

@ -1,60 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#ifndef __GDK_X_H__
#define __GDK_X_H__
#include <gdk/gdk.h>
#include <gdkprivate.h>
#include <time.h>
#include <locale.h>
#define GDK_ROOT_WINDOW() ((guint32) HWND_DESKTOP)
#define GDK_ROOT_PARENT() ((GdkWindow *) gdk_root_parent)
#define GDK_DISPLAY() NULL
#define GDK_DRAWABLE_XDISPLAY(win) NULL
#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_IMAGE_XDISPLAY(image) NULL
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) NULL
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
#define GDK_COLORMAP_XDISPLAY(cmap) NULL
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_FONT_XDISPLAY(font) NULL
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual. */
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
/* Functions to create GDK pixmaps and windows from their native equivalents */
GdkPixmap *gdk_pixmap_foreign_new (guint32 anid);
GdkWindow *gdk_window_foreign_new (guint32 anid);
#endif /* __GDK_X_H__ */

View File

@ -1,88 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 <stdio.h>
#include <gdk/gdk.h>
#include "gdkprivate.h"
static guint gdk_xid_hash (XID *xid);
static gint gdk_xid_compare (XID *a,
XID *b);
static GHashTable *xid_ht = NULL;
void
gdk_xid_table_insert (XID *xid,
gpointer data)
{
g_return_if_fail (xid != NULL);
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_insert (xid_ht, xid, data);
}
void
gdk_xid_table_remove (XID xid)
{
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_remove (xid_ht, &xid);
}
gpointer
gdk_xid_table_lookup (XID xid)
{
gpointer data = NULL;
if (xid_ht)
data = g_hash_table_lookup (xid_ht, &xid);
return data;
}
static guint
gdk_xid_hash (XID *xid)
{
return (guint) *xid;
}
static gint
gdk_xid_compare (XID *a,
XID *b)
{
return (*a == *b);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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/.
*/
#ifndef __GDK_X_H__
#define __GDK_X_H__
#include <gdk/gdk.h>
#include <gdkprivate.h>
#include <time.h>
#include <locale.h>
#define GDK_ROOT_WINDOW() ((guint32) HWND_DESKTOP)
#define GDK_ROOT_PARENT() ((GdkWindow *) gdk_root_parent)
#define GDK_DISPLAY() NULL
#define GDK_DRAWABLE_XDISPLAY(win) NULL
#define GDK_DRAWABLE_XID(win) (((GdkDrawablePrivate*) win)->xwindow)
#define GDK_WINDOW_XDISPLAY GDK_DRAWABLE_XDISPLAY
#define GDK_WINDOW_XWINDOW GDK_DRAWABLE_XID
#define GDK_IMAGE_XDISPLAY(image) NULL
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) NULL
#define GDK_GC_XGC(gc) (((GdkGCPrivate*) gc)->xgc)
#define GDK_COLORMAP_XDISPLAY(cmap) NULL
#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivate*) cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_FONT_XDISPLAY(font) NULL
GdkVisual* gdkx_visual_get (VisualID xvisualid);
/* XXX: Do not use this function until it is fixed. An X Colormap
* is useless unless we also have the visual. */
GdkColormap* gdkx_colormap_get (Colormap xcolormap);
/* Functions to create GDK pixmaps and windows from their native equivalents */
GdkPixmap *gdk_pixmap_foreign_new (guint32 anid);
GdkWindow *gdk_window_foreign_new (guint32 anid);
#endif /* __GDK_X_H__ */

View File

@ -1,88 +0,0 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-1999. 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 <stdio.h>
#include <gdk/gdk.h>
#include "gdkprivate.h"
static guint gdk_xid_hash (XID *xid);
static gint gdk_xid_compare (XID *a,
XID *b);
static GHashTable *xid_ht = NULL;
void
gdk_xid_table_insert (XID *xid,
gpointer data)
{
g_return_if_fail (xid != NULL);
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_insert (xid_ht, xid, data);
}
void
gdk_xid_table_remove (XID xid)
{
if (!xid_ht)
xid_ht = g_hash_table_new ((GHashFunc) gdk_xid_hash,
(GCompareFunc) gdk_xid_compare);
g_hash_table_remove (xid_ht, &xid);
}
gpointer
gdk_xid_table_lookup (XID xid)
{
gpointer data = NULL;
if (xid_ht)
data = g_hash_table_lookup (xid_ht, &xid);
return data;
}
static guint
gdk_xid_hash (XID *xid)
{
return (guint) *xid;
}
static gint
gdk_xid_compare (XID *a,
XID *b)
{
return (*a == *b);
}

View File

@ -3,7 +3,7 @@
# Change this to wherever you want to install the DLL. This directory
# should be in your PATH.
BIN = bin
BIN = /bin
# Location of the Wintab toolkit. Downloadable from http://www.pointing.com.
# We use the wntab32x.lib archive library directly (copy it as libwntab32x.a).
@ -28,66 +28,41 @@ GLIB = ../../../glib
CFLAGS = $(OPTIMIZE) -I . -I .. -I ../.. -I $(WTKIT)/include -I $(GLIB) -DG_ENABLE_DEBUG -DHAVE_CONFIG_H -DGDK_VERSION=\"$(GTK_VER)\"
all: \
gdk/gdkprivate.h \
gdk/gdkx.h \
../../config.h \
gdk-$(GTK_VER).dll
../../config.h \
gdk-win32-$(GTK_VER).dll
install : all
$(INSTALL) gdk-$(GTK_VER).dll $(BIN)
$(INSTALL) gdk-win32-$(GTK_VER).dll $(BIN)
gdk_OBJECTS = \
gdk.o \
gdkcc.o \
gdkcolor.o \
gdkcursor.o \
gdkdnd.o \
gdkdraw.o \
gdkevents.o \
gdkfont.o \
gdkgc.o \
gdkglobals.o \
gdkim.o \
gdkimage.o \
gdkinput.o \
gdkpixmap.o \
gdkproperty.o \
gdkrgb.o \
gdkrectangle.o \
gdkregion.o \
gdkselection.o \
gdkvisual.o \
gdkwindow.o \
gdkxid.o
# We must have copies of gdkx.h and gdkprivate.h in the gdk
# subdirectory, so that application sources which want to be
# compilable with both GTk+ 1.2 (where there are no separate backend
# gdk directories) and this 1.3 version (where the Win32 backend is in
# the directory of *this* file you are reading right now) can use
# #include <gdk/gdkprivate.h>.
# Applications that depend on GTk+ 1.3 or later should include
# gdkprivate.h and/or gdkx.h without the gdk/ prefix. The CFLAGS should
# include an -I switch pointing to the backend-specific directory
# (*this* directory in the Win32 case).
gdk/gdkprivate.h : gdkprivate.h
-mkdir gdk
cp gdkprivate.h gdk
gdk/gdkx.h : gdkx.h
-mkdir gdk
cp gdkx.h gdk
gdk_win32_OBJECTS = \
gdkcolor-win32.o \
gdkcursor-win32.o \
gdkdnd-win32.o \
gdkdrawable-win32.o \
gdkevents-win32.o \
gdkfont-win32.o \
gdkgc-win32.o \
gdkglobals-win32.o \
gdkim-win32.o \
gdkimage-win32.o \
gdkinput-win32.o \
gdkmain-win32.o \
gdkpixmap-win32.o \
gdkproperty-win32.o \
gdkregion-win32.o \
gdkselection-win32.o \
gdkvisual-win32.o \
gdkwin32id.o \
gdkwindow-win32.o
../../config.h : ../../config.h.win32
$(CP) ../../config.h.win32 ../../config.h
gdkres.o : rc/gdk.rc
windres --include-dir rc rc/gdk.rc gdkres.o
gdk-win32res.o : rc/gdk.rc
windres --include-dir rc rc/gdk.rc gdk-win32res.o
gdk-$(GTK_VER).dll : $(gdk_OBJECTS) gdk.def gdkres.o libwntab32x.a
$(GLIB)/build-dll gdk $(GTK_VER) gdk.def $(gdk_OBJECTS) -L $(GLIB) -lglib-$(GLIB_VER) -L . -lwntab32x -lgdi32 -luser32 -limm32 -lshell32 -lole32 -luuid $(LDFLAGS) gdkres.o
gdk-win32-$(GTK_VER).dll : $(gdk_win32_OBJECTS) gdk-win32.def gdk-win32res.o libwntab32x.a
$(GLIB)/build-dll gdk-win32 $(GTK_VER) gdk-win32.def $(gdk_win32_OBJECTS) -L $(GLIB) -lglib-$(GLIB_VER) -L . -lwntab32x -lgdi32 -luser32 -limm32 -lshell32 -lole32 -luuid $(LDFLAGS) gdk-win32res.o
libwntab32x.a : $(WTKIT)/lib/i386/wntab32x.lib
cp $(WTKIT)/lib/i386/wntab32x.lib libwntab32x.a
@ -100,11 +75,5 @@ libwntab32x.a : $(WTKIT)/lib/i386/wntab32x.lib
.c.i :
$(CC) $(CFLAGS) -E -DGDK_COMPILATION -DG_LOG_DOMAIN=\"Gdk\" $< >$@
gdkrgb.c : ../gdkrgb.c
$(CP) ../gdkrgb.c .
gdkrectangle.c : ../gdkrectangle.c
$(CP) ../gdkrectangle.c .
clean:
-rm *.exe *.o *.dll *.a *.exp *.base

View File

@ -2,13 +2,13 @@
#define __SURROGATE_DIMM_H__
/* The Win32api headers doesn't include <dimm.h>, thus we need
* this file, which coverr just the stuff we need from <dimm.h>.
* this file, which covers just the stuff we need from <dimm.h>.
*/
typedef struct IActiveIMMApp IActiveIMMApp;
typedef struct IActiveIMMMessagePumpOwner IActiveIMMMessagePumpOwner;
/* Dummy vtable structs that contain real names and prototypes for
/* Dummy vtable structs that contain real names and arg lists for
* only those methods we need.
*/
typedef struct {