gtk2/gtk/gtktextchild.c
Havoc Pennington 9ae724bf4d Remove all references to offscreen flag which was no longer used.
Thu Jun  1 23:05:13 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c: Remove all references to
	offscreen flag which was no longer used.

	* gtk/gtkprivate.h (enum): Remove unused flags and compress.

	* gtk/gtkframe.c (gtk_frame_set_label_widget): Check
	for non-null label_widget->parent.

	* gtk/gtkentry.c: Get rid of code to deal with PangoAttribute
	which no longer was used.

	* gdk/gdkpango.c (gdk_pango_context_get_info): make static.

	* gdk/gdkpango.c (gdk_draw_layout[_line]): Add checks
	for null arguments.

	* gdk/x11/gdkgeometry-x11.c (gdk_window_scroll): add
	check for destroyed windows.

Thu Jun  1 13:48:45 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimmulticontext.c: Add a finalize method and unref
	the slave context there.

	* gtk/gtkinvisible.[ch]: Make reference counting behavior
	identical to GtkWindow.

Thu Jun  1 01:54:11 2000  Owen Taylor  <otaylor@redhat.com>

	* Makefile.am gdk/gdkpango.c: Copy the layout render function from
	pangox to here, so we can write them independent of rendering
	system, using GDK primitives.

	* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c
	gdk/x11/gdkdrawable-x11.c: Remove draw_layout() from the vtable,
	since we have a rendering-system independent implementation in
	terms of draw_glyphs().

	* gdk/gdkpango.c gdkdrawable.h (gdk_draw_layout_line): New
	function to render a single line.

	* gdk/x11/gdkpango.c: Move the guts of this file mostly
	into ../gdkpango.c, which simplifies things, since we
	don't have to deal with raw X gc's.

Fri May 19 04:28:16 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.[ch]: Add get_log_attrs() function to
	get the logical attributes for a given GtkTextLine.

Tue May 30 16:05:39 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Track
	g_locale_get_codeset() to g_get_codeset() change.

Tue May 30 15:03:19 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/testcalendar.c (calendar_font_selection_ok): Use font
	descriptions.

	* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
	the entry.

	* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
	redoing (vastly simplifying) for Pango. Still needs quite
	a bit of work. (Size selection is currently poor. List of
	predefined sizes is not a good idea, since all of these
	sizes won't necessarily be distinct.)

Tue May 30 13:50:19 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/x11/gdkfont-x11.c (gdk_font_charset_for_locale): Handle
	CODESET results for LANG=C.

Mon May 29 15:49:10 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkrc.[ch]: Add a 'font_name' declaration to RC
	which takes a stringized pango font description;
	ignore the older 'font' and 'fontset' declarations.

	* gtk/gtkstyle.c gtk/gtkrc.c: Fill in the style->font
	field with a GdkFont derived via gdk_font_from_description(),
	for compatibility. (Should we just remove it entirely?
	Probably too much compatibility breakage, but people
	should be migrating to the new Pango stuff as quickly
	as possible.)

Mon May 29 15:47:41 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c gtk/gtkclist.c: s/pango_font_unref/g_object_unref/.

Mon May 29 15:44:46 2000  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkcalender.c: Roughly pango-ized. Really needs
	redoing; there are some bugs in size allocation right
	now, the semi-existant distinction between header / day
	fonts was removed, but, with Pango, could actually
	be made functional in a nice way.

	* gtk/testcalender: Move calender from examples into this
	directory as a test program. (We really need to restrcture
	testgtk into a whole directory full of tests for every
	widget or functionality group, separated into multiple .c
	files.)

Mon May 29 15:19:56 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/testgtk.c (file_exists): Fix stupid typo that
	was keeping RC file from being loaded.

	* gtk/testgtkrc gtk/testgtkrc2: Test new pango-ized
	RC file font code.

Mon May 29 14:31:27 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkfont.h gdk/x11/gdkfont-x11.c (gdk_font_from_description):
	Add function to load a GdkFont from a PangoFontDescription.

Fri May 26 17:16:40 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/frame.[ch] gtkaspectframe.c: Make frame widgets able
	to have any widget for the label, use a GtkLabel widget
	to display the text. (Based partially on a patch from
	Anders Carlson.)

	(Quite a bit of code reorganization - strip 90% of the
	guts out of gtkaspectframe and add a single virtual
	func to GtkFrameClass - compute_child_allocation.)

Fri May 26 12:00:02 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkctree.c gtk/gtkclist.[ch]: Pangoized.
	(Removed clist->row_center_offset field because caching
	it wasn't saving time or code, added private function
	_gtk_clist_create_cell_layout()).

Wed May 24 15:59:37 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkaccellabel.c: Pangoized.

	* gtk/[hv]ruler.c: Pangoized

Mon May 22 19:23:59 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkfilesel.c (gtk_file_selection_init):
	Use gtk_clist_set_column_auto_resize() to remove need
	need for manual column width computations.

Mon May 22 18:50:26 2000  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktooltips.[ch]: Replace custom drawing with a GtkLabel,
	ensuring Pango correctness, and considerably simplifying the
	code.

	* gtk/gtklabel.c gtk[hv]scale.c: 1000 => PANGO_SCALE.

	* gtk/gtklabel.c (gtk_label_size_request): Fixed incorrect
	getting of numbers of lines.

	* gtk/gtklabel.c (gtk_label_size_request): Set the requisition
	to the actual requested width of the lable, not to the wrap
	width we set.

	* gtk/gtktextchild.h: Remove extraneous include of gtk/gtk.h.

	* gtk/gtktextbtree.c gtk/gtktextbuffer.c gtk/gtktextlayout.c
	  gtk/gtktextview.c gtk/gtktextview.[ch]: Fix up includes.

	* gtk/gtktextview.c: Fix structure inheritance.

	* gtk/gtkprogressbar.c: Pangoize.

Mon May 22 15:47:30 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextview.c (gtk_text_view_get_first_para_iter): Encapsulate
	in a function.

	* gtk/gtktextlayout.c (find_display_line_above): Fixed
	bug with computing line tops.

	* gtk/gtktextview.c (changed_handler): Fix < , <= confusion.

Thu May 18 18:53:31 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextdisplay.c (gtk_text_layout_draw): Fix up the x_offset
	and y_offset coordinates to do what we need now. (The offset between
	buffer and layout coordinates has been reintroduced, but is a
	bit different than before.)

	* gtk/gtktextview.[ch]: No longer inherit from GtkLayout; instead
	handle the adjustments ourselves, and scroll as necessary using
	the new gdk_window_scroll().

	The advantage of this is that when we are incrementally revalidating,
	we are essentially rearranging things around the visible portion
	of the screen. With the old setup, the visible portion of the
	screen was moved around in the layout, so scrolling and redrawing
	to track that caused jumping of the display. Since we now
	control the scrolling ourselves, we can suppress this and
	only redraw when things actually change.

Thu May 18 18:47:25 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextbtree.c (redisplay_mark): We need to invalidate
	the region not just redisplay it after-all, since we store the
	cursors in the LineDisplay. (Ugly interactions here between
	GtkLayout and GtkTextBTree here.)

	* gtk/gtktextbtree.c (redisplay_region): Fixed reversed comparison.

Thu May 18 18:43:21 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkwindow.h gdk/x11/gdkgeometry-x11.c (gdk_window_scroll):
	Added function to scroll contents of a window while keeping the
	window constant. Works by XCopyArea or guffaw-scrolling depending
	on the details of how the window is set up. (guffaw-scrolling
	still needs to be filled in.)

Wed May 17 22:36:53 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextiter.c gtk/gtkmain.c: Add a debug key for the text widget,
	move the debugging that was tied to a global variable
	to that.

	* gtk/gtkmarshal.list: Add NONE:INT,INT,INT

	* gtk/gtktextbtree.[ch] gtk/gtktextlayout.c: Keep a separate
	validated flag, in line data instead of setting height/width to
	-1. This allows us to perform operations with partially invalid
	buffer (using the old size for invalid lines) and thus to do
	incremental vaidation. Keep height/width aggregates up to date
	when deleting text and rebalancing the tree.

	* gtk/gtktextbtree.[ch]: Add functions validate a line
	(gtk_text_btree_validate_line), and to validate up
	to a number of pixels (gtk_text_btree_validate).

	* gtk/gtktextlayout.[ch]: Add an ::invalidated signal
	that indicates that something is changed and a revalidation
	pass is needed. Change ::need_repaint to ::changed, and
	make it take old and new yranges instead of a rectangle.

	* gtk/gtktextbtree.[ch] gtk/gtktextlayout.[ch]: Move
	the line_data_destroy() function from
	gtk_text_btree_add_view() to a virtual function in
	GtkTextLayout

	* gtk/gtktextbtree.[ch]: Remove gtk_text_btree_get_damage_range(),
	since we are handling partial repaints in a different fashion
	now.

	* gtk/gtktextbtree.[ch]: Only repaint the changed portion
	of the selection instead of queueing a repaint on the
	entire widget.

	* gtk/gtktextbuffer.[ch] gtk/gtktextbtree.[ch]: Move
	get_selection_bounds() down to btree, make the function
	in buffer a wrapper around the btree function.

	* gtk/gtktextlayout.[ch]: Add functions to check if the
	layout is valid and to recompute either a range of pixels
	aroudn a line or a certain total number of pixels.

	* gtk/gtktextlayout.[ch]: Cache a single line display;
	now that we only redraw the needed portions, the hit rate
	for this cache is quite high.

	* gtk/gtktextview.[ch]: Keep track of the first paragraph
	on the screen so that when re-laying-out the buffer, we can
	keep the same place. This requires connecting to ::value_changed
	on the adjustments

	* gtk/gtktextview.[ch]: Add idle functions to revalidate
	the buffer after we receive an ::invalidated signal.

Wed May 17 22:10:47 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtklayout.c (gtk_layout_size_allocate): Set upper
	to max of allocation and layout size, not just to the
	layout size.

	* gtk/gtk[hv]scrollbar.c (gtk_[hv]scrollbar_calc_slider_size):
	Invalidate window so it gets redrawn properly.

	* gdk/gdkwindow.c (gdk_window_invalidate_rect): Allow rect == NULL
	to mean the entire window.

	* gdk/gdkevents.h: Move definition for GDK_PRIORITY_REDRAW
	into public header.

Mon May 15 14:51:31 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextmark.c (gtk_text_mark_get_name): Add function
	to get the name of a mark.

	* gtk/gtktextlayout.c (gtk_text_layout_get_line_at_y): Add a function
	to find the paragraph from a y position.

Thu May 11 12:57:20 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextbtree.c (gtk_text_btree_node_invalidate_upward): Valid
	nodes have width/height >= 0, not > 0.

Tue May  9 21:29:06 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c (gtk_text_layout_get_line_display):
	Add a size_only flag, so when we only need the size, we don't create
	useless appearance attributes.

	* gtk/gtktextview.c (gtk_text_view_ensure_layout): Remove
	duplicate setting of font description.

	* gtk/gtkscale.c: Use PANGO_SCALE instead of 1000

Wed Apr 26 01:53:23 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/Makefile.am (EXTRA_DIST): Add OLD_STAMP into
	EXTRA_DIST. It does not work well when the file that
	everything depends on is not in the tarball.

Wed Apr 26 00:56:14 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/testgtk.c: Some hacks and fixes so that it basically
	works when not sitting in the GTK+ build tree.

2000-05-03  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextbtree.c (gtk_text_line_next_could_contain_tag):
	Properly determine the ordering of the tag root and the current
	line within the tree. Previous algorithm only worked if the tag
	root's immediate parent was the common root of both the current
	line and the tag root.

Wed Apr 26 00:43:00 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.c (set_para_values): Fix some bugs in
	alignment.

	* gtk/gtktextview.c (gtk_text_view_ensure_layout): Track
	the widget text directional dynamically.

	* gtk/gtktextview.[ch]: Added functions to get and set default
	wrap mode.

Tue Apr 25 23:47:38 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.c (gtk_text_layout_get_iter_location): Fix bug
	in cursor location computation.

Tue Apr 25 23:22:59 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtklayout.c (gtk_layout_set_size): Clamp hadjustment/
	vadjusment values properly when layout gets smaller.

	* gtk/gtktextview.c (need_repaint_handler): Areas being
	passed in are far completely inaccurate, and sometimes
	too small, so, for now, just queue a redraw on the
	whole visible region.

2000-04-25  Havoc Pennington  <hp@redhat.com>

	* gtk/gtktextbtree.c (summary_destroy): new function to
	destroy tag summary nodes
	(gtk_text_line_next_could_contain_tag): this function was
	totally broken if the line passed in wasn't below the tag
	root. Fix it.
	(gtk_text_btree_first_could_contain_tag): In the tag == NULL
	"wildcard" case, we have to do a linear scan. Blah.
	(gtk_text_btree_last_could_contain_tag): In tag == NULL case,
	we have to do the linear scan
	(tag_removed_cb): When a tag is removed from the tag table,
	remove the GtkTextTagInfo node from the btree.
	(gtk_text_btree_spew): Implement the spew function, for
	our debugging pleasure.

Tue Apr 25 19:40:18 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.c (gtk_text_layout_set_buffer): Fix
	a problem with referring to the wrong buffer.

	* gtk/gtkentry.c: Fix focus-in/focus-out confusion.

	* gtk/gtkrc.c gtk/gtkstyle.c: Moving setting default
	font description to gtk_style_new() - otherwise things
	don't work without a .gtkrc file.

	* gtk/gtktextbuffer.c (gtk_text_buffer_new): Sink the
	tags table if we create it ourself, too.

	* gdk/gdktypes.h (enum): Move GDK_RELEASE_MASK, since
	it was conflicting with XKB modifiers.

	* gtk/gtktextview.[ch]: Add simple support for
	GtkIMContext.

Mon Apr 24 19:34:18 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c (gtk_entry_move_cursor_visually): Fix problem
	with deletion from last commit.

Mon Apr 24 19:29:40 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_create_pango_context): Set the language
	in the context from the current locale.

	* gtk/gtkentry.c (gtk_entry_size_request): Use language from the
	context, not hardcoded value.

	* gtk/gtkentry.c (gtk_entry_move_cursor): Make character movement visual,
	not logical.

Sun Apr 23 23:39:18 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c gtk/gtktextdisplay.c: Don't handle selections as
	attributes - that doesn't handle partial-glyph selection
	properly. Instead use new pango_layout_line_get_x_ranges()
	functionality to draw the selection.

	* gtk/gtkentry.c: Simplify code since pango_layout_line_index_to_x()
	now properly handles out-of-range coordinates.

	* gtk/gtktextbuffer.c: Emit "mark_set" when the cursor is moved.

	* gtk/gtktextiter.h gtk/gtktextiterprivate.h: Make gtk_text_iter_get_line_byte()
	public.

	* gtk/gtktextlayout.[ch]: Properly set the direction in the PangoContext
	for paragraphs opposite to the base direction of the widget.

	* gtk/gtktextlayout.[ch] gtk/gtktextdisplay.c: Fixes for alignment.

	* gtk/gtktextlayout.c: Don't split segments on marks, since that
	causes Arabic words to reshape as you cursor through.

	* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Implement virtual
	cursor position when moving vertically with the arrow keys and
	scrolling with page-up/page-down. (Arrow keys save only the X,
	scrolling saves both X and Y.)

	This means you can line-up / line-down or page-up / page-down
	without losing your place, and also that moving vertically
	with the cursor keys keeps the same X position, not the same
	character count:

	* gtk/gtktextlayout.[ch] gtk/gtktextview.[ch]: Make vertical
	arrow keys move by display lines, not paragraphs.

Tue Apr 18 14:16:50 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtklayout.c: Make sure that the bin window is at least
	as big as the allocation. (Should we also make sure that the
	bin window is big enough to completely cover widget->window?)

	* gtk/gtktextview.c (gtk_text_view_get_visible_rect): Add
	function to get the onscreen rectangle.

	* gdk/x11/gdkwindow-x11.c (gdk_window_get_pointer): Correctly account
	for offsets in window coordinates.

Sun Apr 16 16:13:27 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c (gtk_entry_get_cursor_locations): Fix index/offset
	confusion.

	* gtk/gtktextview.c (gtk_text_view_ensure_layout): Set the default direction
	from the widget direction.

	* gtk/gtktexttag.c gtk/gtktexttagprivate.h (gtk_text_tag_set_arg):
	Add a "direction" attribute.

	* gtk/gtktextview.c: global s/tkxt/text_view/.

	* gtk/testtext.c: Added long block of text in Arabic, to test out
	the direction attributes. (Some problems with the shaping system
	for arabic become obvious - like the fact the cursor splits words
	into unjoined pieces.)

Fri Apr 14 12:54:34 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextdisplay.c (render_layout): Add overstrike handling.

	* gtk/gtktextlayout.c: Fix up alignment.

	* gtk/testtext.c: Add some tests for centering, wrapping.

Fri Apr 14 09:26:22 2000  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdkdrawable.h gdk/gdkdraw.c gdk/gdkwindow.c gdk/x11/gdkdrawable-x11.c:
	Add a draw_glyphs() operation to the drawable vtable and gdk_draw_glyphs().
	If we wrote GTK+-specific layout-render function this could just replace
	the draw_layout() operation in the vtable.

	* gtk/gtkentry.c: Move guts of gtk_entry_get_cursor_locations to
	pango_layout_get_cursor_pos() and use that function.

	* gtk/gtktextchild.[ch]: add gtk_ onto pixmap_segment_new(), since it
	is a non-static symbol.

	* gtk/gtktextbtree.[ch]: Replace gtk_text_btree_find_line_data_by_y()
	with gtk_text_btree_find_line_by_y()

	* gtk/gtktextdisplay.c: Rewrote for Pango - uses a custom layout
	renderer that handles GtkTextAppearance attributes.

	* gtk/gtktexttag.[ch] gtk/gtktexttagprivate.h:

	  - Move the values in the style that don't affect geometry into a
	    GtkTextAppearance structure.
	  - Change underline to take a PangoUnderline and "font" a string
	    representation of a font description
	  - Add a "font_desc" attribute which takes a FontDescription structure.

	* gtk/gtktextlayout.[ch]:

	  - Get rid of the display-line list per each line. Instead, we
	    generate, on demand, a GtkTextLineDisplay structure which]
	    contains a PangoLayout * and other necesary information
	    (offsets, cursor locations) for displaying a paragraph.
	  - Get rid of the code to wrap lines, create display chunks,
	    etc. Instead, we just go through a paragraph and convert
	    it into the necessary inputs to a PangoLayout.
	  - Implement a new attribute type, GtkTextAttrAppearance. This
	    holds a GtkTextAppearance, and is used to pass colors,
	    stipple, etc, through from the layout to the display without
	    having to use lots and lots of individual attributes.
	  - Reimplement gtk_layout_get_iter_at_pixel() gtk_layout_get_iter_pos()
	    in terms of PangoLayout functions.

	* gtk/gtktextview.c:

	  - Handle passing the necessary PangoContext to the layout
	  - Some fixups in painting to deal with the automatic backing store
	    and offsetting of GTK+-1.4
	  - Add a style_set handler so that the default style reacts
	    properly to theme changes.

	* gtk/gtktext?*.[ch]: Random code-style fixes.

	* gtk/testtext.c: Substitute in languages that Pango handles now for Thai

Mon Apr 10 10:33:45 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktext?*.[ch]: Check in Havoc's port of the Tk text widget,
	in original form preparatory to Pango-ization and gdkimcontext-ization.

Thu Apr  6 19:25:39 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimcontext.c: Move default implementations to real_* vfuncs,
	so that we can derive from gtkimcontext in language bindings properly.

Thu Apr  6 16:02:52 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimcontextsimple.[ch]: Use gdk_keyval_to_unicode to gdk_unicode_to_keyval.
	Add a compose table including (almost) all the compose combinations
	from X. This is 6k of static, shared data as opposed to 50k or so of dynamic
	data in the XIM implementation.

	* gdk/gdk.h gdk/gdkkeyuni.c gdk/win32/gdkevents-win32.c (gdk_keyval_to_unicode, gdk_unicode_to_keyval):
	Moved functions to convert keyvalues from and to unicode here from
	the win32 port and made them public.

Wed Apr  5 16:37:29 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkeditable.c (gtk_editable_insert_text): Allow new_text_length == -1.

Wed Apr  5 16:27:45 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimcontext.[ch]: Base class for new input context system

	* gtk/gtkimmulticontext.[ch]: Proxy input context that allows
	the real input context implementation to be loaded from modules
	and switched on the fly.

	* gtk/gtkcontextsimple.[ch]: Simple implementation of an input
	context that just does direct keysymbol => unicode translation.

	* gtk/gtkentry.[ch]: Start switching editing over to using
	GtkInputContext. (No handling of preedit yet.)

Wed Apr  5 15:48:41 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktypeutils.h (GTK_CHECK_GET_CLASS): Fix problem with one too
	many substitutions. (klass should not be subsituted.)

Wed Apr  5 00:18:14 2000  Owen Taylor  <otaylor@redhat.com>

	* configure.in: Add checks for Pango

	* configure.in docs/Makefile.am: Add test for sgml2html
	and allow 'make dist' without building html, but print out
	warnings in that case. (For making snapshots)

	* gdk/Makefile.am gdk/x11/Makefile.am gtk/Makefile.am:
	Add Pango libraries and C flags

	* gdk/gdkdraw.c gdk/gdkdrawable.h gdkwindow.c gdk/x11/gdkdrawable-x11.c:
	Add function (gdk_draw_layout) to draw a pango layout.

	* gdk/gdkpango.h gdk/x11/gdkpango-x11.c: New file with functions
	for getting Pango contexts for GDK.

	* gtk/gtkeditable.c: Get rid of dead code gtk_editable_parent_set()

	* gtk/gtkentry.[ch]: Complete rewrite to use Pango, add bidirectional
	editing.

	* gtk/gtkentry.c: Hack in simple Hebrew input with direct
	keysym => unicode translations. More languages can be added
	here, but real input-method support is needed.

	* docs/Changes-1.4.txt: Added note about entry behavior.

	* gtk/gtkenums.h gtk/gtkwidget.[ch] testgtk.c gtkprivate.h: Add functions
	to set the reading direction for a widget and the global direction.
	Add test which allows toggling the global direction. Two private
	flags are used to store the direction. (GTK_DIRECTION_SET + GTK_DIRECTION_LTR)

	* gtk/gtkcheckbutton.c gtk/gtkframe.c gtk/gtkhbbox.c gtk/gtkhbox.c
	  gtk/gtkradiobutton.c gtk/gtkspinbutton.c gtk/gtktable.c

	* gtk/gtk[hv]scale.c gtk/gtkscale.[ch]: Draw numbers using Pango

	* gtk/gtklabel.[ch]: Moved to Pango and considerably rewritten. Line breaking,
	underlining now handled by Pango.

	* gtk/gtkstyle.[ch] gtk/gtkrc.[ch]: Add a PangoFontDescription
	to RCStyle and Style. (Having both this and the old font name and GdkFont
	is temporary.)

	* gtk/gtkwidget.[ch] (gtk_widget_create_pango_{context,layout}): Added
	convenience functions for creating contexts and layouts for widgets.

	* gtk/testgtk.c: Enhance label tests with multilingual labels.
2000-06-02 03:14:07 +00:00

1305 lines
40 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* gtktextchild.c - child pixmaps and widgets
*
*
* Copyright (c) 1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 2000 Red Hat, Inc.
* Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
*
* This software is copyrighted by the Regents of the University of
* California, Sun Microsystems, Inc., and other parties. The
* following terms apply to all files associated with the software
* unless explicitly disclaimed in individual files.
*
* The authors hereby grant permission to use, copy, modify,
* distribute, and license this software and its documentation for any
* purpose, provided that existing copyright notices are retained in
* all copies and that this notice is included verbatim in any
* distributions. No written agreement, license, or royalty fee is
* required for any of the authorized uses. Modifications to this
* software may be copyrighted by their authors and need not follow
* the licensing terms described here, provided that the new terms are
* clearly indicated on the first page of each file where they apply.
*
* IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
* PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
* DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
* OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
* NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
* AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* GOVERNMENT USE: If you are acquiring this software on behalf of the
* U.S. government, the Government shall have only "Restricted Rights"
* in the software and related documentation as defined in the Federal
* Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
* are acquiring the software on behalf of the Department of Defense,
* the software shall be classified as "Commercial Computer Software"
* and the Government shall have only "Restricted Rights" as defined
* in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
* foregoing, the authors grant the U.S. Government and others acting
* in its behalf permission to use and distribute the software in
* accordance with the terms specified in this license.
*
*/
#include "gtktextchild.h"
#include "gtktextbtree.h"
static GtkTextLineSegment *
pixmap_segment_cleanup_func(GtkTextLineSegment *seg,
GtkTextLine *line)
{
/* nothing */
return seg;
}
static int
pixmap_segment_delete_func(GtkTextLineSegment *seg,
GtkTextLine *line,
gboolean tree_gone)
{
if (seg->body.pixmap.pixmap)
gdk_pixmap_unref(seg->body.pixmap.pixmap);
if (seg->body.pixmap.mask)
gdk_bitmap_unref(seg->body.pixmap.mask);
g_free(seg);
return 0;
}
static void
pixmap_segment_check_func(GtkTextLineSegment *seg,
GtkTextLine *line)
{
if (seg->next == NULL)
g_error("pixmap segment is the last segment in a line");
if (seg->byte_count != 3)
g_error("pixmap segment has byte count of %d", seg->byte_count);
if (seg->char_count != 1)
g_error("pixmap segment has char count of %d", seg->char_count);
}
GtkTextLineSegmentClass gtk_text_pixmap_type = {
"pixmap", /* name */
0, /* leftGravity */
NULL, /* splitFunc */
pixmap_segment_delete_func, /* deleteFunc */
pixmap_segment_cleanup_func, /* cleanupFunc */
NULL, /* lineChangeFunc */
pixmap_segment_check_func /* checkFunc */
};
#if 0
GtkTextLineSegmentClass gtk_text_view_child_type = {
"child-widget", /* name */
0, /* leftGravity */
child_segment_split_func, /* splitFunc */
child_segment_delete_func, /* deleteFunc */
child_segment_cleanup_func, /* cleanupFunc */
NULL, /* lineChangeFunc */
child_segment_check_func /* checkFunc */
};
#endif
#define PIXMAP_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET(GtkTextLineSegment, body) \
+ sizeof(GtkTextPixmap)))
GtkTextLineSegment *
gtk_text_pixmap_segment_new(GdkPixmap *pixmap, GdkBitmap *mask)
{
GtkTextLineSegment *seg;
seg = g_malloc(PIXMAP_SEG_SIZE);
seg->type = &gtk_text_pixmap_type;
seg->next = NULL;
seg->byte_count = 3; /* We convert to the 0xFFFD "unknown character",
a 3-byte sequence in UTF-8 */
seg->char_count = 1;
seg->body.pixmap.pixmap = pixmap;
seg->body.pixmap.mask = mask;
if (pixmap)
gdk_pixmap_ref(pixmap);
if (mask)
gdk_bitmap_ref(mask);
return seg;
}
#if 0
/*
* The following structure is the official type record for the
* embedded window geometry manager:
*/
static void EmbWinRequestFunc _ANSI_ARGS_((gpointer clientData,
Tk_Window tkwin));
static void EmbWinLostSlaveFunc _ANSI_ARGS_((gpointer clientData,
Tk_Window tkwin));
static Tk_GeomMgr textGeomType = {
"text", /* name */
EmbWinRequestFunc, /* requestFunc */
EmbWinLostSlaveFunc, /* lostSlaveFunc */
};
/*
* Definitions for alignment values:
*/
#define ALIGN_BOTTOM 0
#define ALIGN_CENTER 1
#define ALIGN_TOP 2
#define ALIGN_BASELINE 3
/*
* Macro that determines the size of an embedded window segment:
*/
#define EW_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET(GtkTextLineSegment, body) \
+ sizeof(GtkTextEmbWindow)))
/*
* Prototypes for procedures defined in this file:
*/
static int AlignParseFunc _ANSI_ARGS_((gpointer clientData,
Tcl_Interp *interp, Tk_Window tkwin, char *value,
char *widgRec, int offset));
static char * AlignPrintFunc _ANSI_ARGS_((gpointer clientData,
Tk_Window tkwin, char *widgRec, int offset,
Tcl_FreeFunc **freeFuncPtr));
static GtkTextLineSegment * EmbWinCleanupFunc _ANSI_ARGS_((GtkTextLineSegment *segPtr,
GtkTextLine *line));
static void EmbWinCheckFunc _ANSI_ARGS_((GtkTextLineSegment *segPtr,
GtkTextLine *line));
static void EmbWinBboxFunc _ANSI_ARGS_((GtkTextDisplayChunk *chunkPtr,
int index, int y, int lineHeight, int baseline,
int *xPtr, int *yPtr, int *widthPtr,
int *heightPtr));
static int EmbWinConfigure _ANSI_ARGS_((GtkTextView *tkxt,
GtkTextLineSegment *ewPtr, int argc, char **argv));
static void EmbWinDelayedUnmap _ANSI_ARGS_((
gpointer clientData));
static int EmbWinDeleteFunc _ANSI_ARGS_((GtkTextLineSegment *segPtr,
GtkTextLine *line, int treeGone));
static void EmbWinDisplayFunc _ANSI_ARGS_((
GtkTextDisplayChunk *chunkPtr, int x, int y,
int lineHeight, int baseline, Display *display,
Drawable dst, int screenY));
static int EmbWinLayoutFunc _ANSI_ARGS_((GtkTextView *tkxt,
GtkTextIndex *indexPtr, GtkTextLineSegment *segPtr,
int offset, int maxX, int maxChars,
int noCharsYet, GtkWrapMode wrapMode,
GtkTextDisplayChunk *chunkPtr));
static void EmbWinStructureFunc _ANSI_ARGS_((gpointer clientData,
XEvent *eventPtr));
static void EmbWinUndisplayFunc _ANSI_ARGS_((GtkTextView *tkxt,
GtkTextDisplayChunk *chunkPtr));
/*
* The following structure declares the "embedded window" segment type.
*/
static GtkTextLineSegmentClass tkTextEmbWindowType = {
"window", /* name */
0, /* leftGravity */
(GtkTextLineSegmentSplitFunc *) NULL, /* splitFunc */
EmbWinDeleteFunc, /* deleteFunc */
EmbWinCleanupFunc, /* cleanupFunc */
(GtkTextLineSegmentLineChangeFunc *) NULL, /* lineChangeFunc */
EmbWinLayoutFunc, /* layoutFunc */
EmbWinCheckFunc /* checkFunc */
};
/*
* Information used for parsing window configuration options:
*/
static Tk_CustomOption alignOption = {AlignParseFunc, AlignPrintFunc,
(gpointer) NULL};
static Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-align", (char *) NULL, (char *) NULL,
"center", 0, TK_CONFIG_DONT_SET_DEFAULT, &alignOption},
{TK_CONFIG_STRING, "-create", (char *) NULL, (char *) NULL,
(char *) NULL, G_STRUCT_OFFSET(GtkTextEmbWindow, create),
TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK},
{TK_CONFIG_INT, "-padx", (char *) NULL, (char *) NULL,
"0", G_STRUCT_OFFSET(GtkTextEmbWindow, padX),
TK_CONFIG_DONT_SET_DEFAULT},
{TK_CONFIG_INT, "-pady", (char *) NULL, (char *) NULL,
"0", G_STRUCT_OFFSET(GtkTextEmbWindow, padY),
TK_CONFIG_DONT_SET_DEFAULT},
{TK_CONFIG_BOOLEAN, "-stretch", (char *) NULL, (char *) NULL,
"0", G_STRUCT_OFFSET(GtkTextEmbWindow, stretch),
TK_CONFIG_DONT_SET_DEFAULT},
{TK_CONFIG_WINDOW, "-window", (char *) NULL, (char *) NULL,
(char *) NULL, G_STRUCT_OFFSET(GtkTextEmbWindow, tkwin),
TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK},
{TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
(char *) NULL, 0, 0}
};
/*
*--------------------------------------------------------------
*
* GtkTextViewWindowCmd --
*
* This procedure implements the "window" widget command
* for text widgets. See the user documentation for details
* on what it does.
*
* Results:
* A standard Tcl result or error.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
int
GtkTextViewWindowCmd(tkxt, interp, argc, argv)
GtkTextView *tkxt; /* Information about text widget. */
Tcl_Interp *interp; /* Current interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. Someone else has already
* parsed this command enough to know that
* argv[1] is "window". */
{
size_t length;
GtkTextLineSegment *ewPtr;
if (argc < 3) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " window option ?arg arg ...?\"", (char *) NULL);
return TCL_ERROR;
}
length = strlen(argv[2]);
if ((strncmp(argv[2], "cget", length) == 0) && (length >= 2)) {
GtkTextIndex index;
GtkTextLineSegment *ewPtr;
if (argc != 5) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " window cget index option\"",
(char *) NULL);
return TCL_ERROR;
}
if (gtk_text_btree_index_from_string(interp, tkxt, argv[3], &index) != TCL_OK) {
return TCL_ERROR;
}
ewPtr = gtk_text_view_index_to_seg(&index, (int *) NULL);
if (ewPtr->type != &tkTextEmbWindowType) {
Tcl_AppendResult(interp, "no embedded window at index \"",
argv[3], "\"", (char *) NULL);
return TCL_ERROR;
}
return Tk_ConfigureValue(interp, tkxt->tkwin, configSpecs,
(char *) &ewPtr->body.ew, argv[4], 0);
} else if ((strncmp(argv[2], "configure", length) == 0) && (length >= 2)) {
GtkTextIndex index;
GtkTextLineSegment *ewPtr;
if (argc < 4) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " window configure index ?option value ...?\"",
(char *) NULL);
return TCL_ERROR;
}
if (gtk_text_btree_index_from_string(interp, tkxt, argv[3], &index) != TCL_OK) {
return TCL_ERROR;
}
ewPtr = gtk_text_view_index_to_seg(&index, (int *) NULL);
if (ewPtr->type != &tkTextEmbWindowType) {
Tcl_AppendResult(interp, "no embedded window at index \"",
argv[3], "\"", (char *) NULL);
return TCL_ERROR;
}
if (argc == 4) {
return Tk_ConfigureInfo(interp, tkxt->tkwin, configSpecs,
(char *) &ewPtr->body.ew, (char *) NULL, 0);
} else if (argc == 5) {
return Tk_ConfigureInfo(interp, tkxt->tkwin, configSpecs,
(char *) &ewPtr->body.ew, argv[4], 0);
} else {
gtk_text_buffer_need_redisplay(tree->buffer, &index, &index);
return EmbWinConfigure(tkxt, ewPtr, argc-4, argv+4);
}
} else if ((strncmp(argv[2], "create", length) == 0) && (length >= 2)) {
GtkTextIndex index;
int lineIndex;
/*
* Add a new window. Find where to put the new window, and
* mark that position for redisplay.
*/
if (argc < 4) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " window create index ?option value ...?\"",
(char *) NULL);
return TCL_ERROR;
}
if (gtk_text_btree_index_from_string(interp, tkxt, argv[3], &index) != TCL_OK) {
return TCL_ERROR;
}
/*
* Don't allow insertions on the last (dummy) line of the text.
*/
lineIndex = gtk_text_btree_line_number(index.line);
if (lineIndex == gtk_text_btree_num_lines(tkxt->tree)) {
lineIndex--;
gtk_text_btree_get_line_byte_index(tkxt->tree, lineIndex, G_MAXINT, &index);
}
/*
* Create the new window segment and initialize it.
*/
ewPtr = (GtkTextLineSegment *) g_malloc(EW_SEG_SIZE);
ewPtr->type = &tkTextEmbWindowType;
ewPtr->size = 1;
ewPtr->body.ew.tkxt = tkxt;
ewPtr->body.ew.line = NULL;
ewPtr->body.ew.tkwin = NULL;
ewPtr->body.ew.create = NULL;
ewPtr->body.ew.align = ALIGN_CENTER;
ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0;
ewPtr->body.ew.stretch = 0;
ewPtr->body.ew.chunkCount = 0;
ewPtr->body.ew.displayed = 0;
/*
* Link the segment into the text widget, then configure it (delete
* it again if the configuration fails).
*/
gtk_text_buffer_need_redisplay(tkxt, &index, &index);
gtk_text_btree_link_segment(ewPtr, &index);
if (EmbWinConfigure(tkxt, ewPtr, argc-4, argv+4) != TCL_OK) {
GtkTextIndex index2;
gtk_text_view_index_forw_chars(&index, 1, &index2);
gtk_text_btree_delete_chars(&index, &index2);
return TCL_ERROR;
}
} else if (strncmp(argv[2], "names", length) == 0) {
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
argv[0], " window names\"", (char *) NULL);
return TCL_ERROR;
}
for (hPtr = Tcl_FirstHashEntry(&tkxt->windowTable, &search);
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_AppendElement(interp,
Tcl_GetHashKey(&tkxt->markTable, hPtr));
}
} else {
Tcl_AppendResult(interp, "bad window option \"", argv[2],
"\": must be cget, configure, create, or names",
(char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* EmbWinConfigure --
*
* This procedure is called to handle configuration options
* for an embedded window, using an argc/argv list.
*
* Results:
* The return value is a standard Tcl result. If TCL_ERROR is
* returned, then the interp's result contains an error message..
*
* Side effects:
* Configuration information for the embedded window changes,
* such as alignment, stretching, or name of the embedded
* window.
*
*--------------------------------------------------------------
*/
static int
EmbWinConfigure(tkxt, ewPtr, argc, argv)
GtkTextView *tkxt; /* Information about text widget that
* contains embedded window. */
GtkTextLineSegment *ewPtr; /* Embedded window to be configured. */
int argc; /* Number of strings in argv. */
char **argv; /* Array of strings describing configuration
* options. */
{
Tk_Window oldWindow;
Tcl_HashEntry *hPtr;
int new;
oldWindow = ewPtr->body.ew.tkwin;
if (Tk_ConfigureWidget(tkxt->interp, tkxt->tkwin, configSpecs,
argc, argv, (char *) &ewPtr->body.ew, TK_CONFIG_ARGV_ONLY)
!= TCL_OK) {
return TCL_ERROR;
}
if (oldWindow != ewPtr->body.ew.tkwin) {
if (oldWindow != NULL) {
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&tkxt->windowTable,
Tk_PathName(oldWindow)));
Tk_DeleteEventHandler(oldWindow, StructureNotifyMask,
EmbWinStructureFunc, (gpointer) ewPtr);
Tk_ManageGeometry(oldWindow, (Tk_GeomMgr *) NULL,
(gpointer) NULL);
if (tkxt->tkwin != Tk_Parent(oldWindow)) {
Tk_UnmaintainGeometry(oldWindow, tkxt->tkwin);
} else {
Tk_UnmapWindow(oldWindow);
}
}
if (ewPtr->body.ew.tkwin != NULL) {
Tk_Window ancestor, parent;
/*
* Make sure that the text is either the parent of the
* embedded window or a descendant of that parent. Also,
* don't allow a top-level window to be managed inside
* a text.
*/
parent = Tk_Parent(ewPtr->body.ew.tkwin);
for (ancestor = tkxt->tkwin; ;
ancestor = Tk_Parent(ancestor)) {
if (ancestor == parent) {
break;
}
if (Tk_IsTopLevel(ancestor)) {
badMaster:
Tcl_AppendResult(tkxt->interp, "can't embed ",
Tk_PathName(ewPtr->body.ew.tkwin), " in ",
Tk_PathName(tkxt->tkwin), (char *) NULL);
ewPtr->body.ew.tkwin = NULL;
return TCL_ERROR;
}
}
if (Tk_IsTopLevel(ewPtr->body.ew.tkwin)
|| (ewPtr->body.ew.tkwin == tkxt->tkwin)) {
goto badMaster;
}
/*
* Take over geometry management for the window, plus create
* an event handler to find out when it is deleted.
*/
Tk_ManageGeometry(ewPtr->body.ew.tkwin, &textGeomType,
(gpointer) ewPtr);
Tk_CreateEventHandler(ewPtr->body.ew.tkwin, StructureNotifyMask,
EmbWinStructureFunc, (gpointer) ewPtr);
/*
* Special trick! Must enter into the hash table *after*
* calling Tk_ManageGeometry: if the window was already managed
* elsewhere in this text, the Tk_ManageGeometry call will cause
* the entry to be removed, which could potentially lose the new
* entry.
*/
hPtr = Tcl_CreateHashEntry(&tkxt->windowTable,
Tk_PathName(ewPtr->body.ew.tkwin), &new);
Tcl_SetHashValue(hPtr, ewPtr);
}
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* AlignParseFunc --
*
* This procedure is invoked by Tk_ConfigureWidget during
* option processing to handle "-align" options for embedded
* windows.
*
* Results:
* A standard Tcl return value.
*
* Side effects:
* The alignment for the embedded window may change.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
AlignParseFunc(clientData, interp, tkwin, value, widgRec, offset)
gpointer clientData; /* Not used.*/
Tcl_Interp *interp; /* Used for reporting errors. */
Tk_Window tkwin; /* Window for text widget. */
char *value; /* Value of option. */
char *widgRec; /* Pointer to GtkTextEmbWindow
* structure. */
int offset; /* Offset into item (ignored). */
{
GtkTextEmbWindow *embPtr = (GtkTextEmbWindow *) widgRec;
if (strcmp(value, "baseline") == 0) {
embPtr->align = ALIGN_BASELINE;
} else if (strcmp(value, "bottom") == 0) {
embPtr->align = ALIGN_BOTTOM;
} else if (strcmp(value, "center") == 0) {
embPtr->align = ALIGN_CENTER;
} else if (strcmp(value, "top") == 0) {
embPtr->align = ALIGN_TOP;
} else {
Tcl_AppendResult(interp, "bad alignment \"", value,
"\": must be baseline, bottom, center, or top",
(char *) NULL);
return TCL_ERROR;
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* AlignPrintFunc --
*
* This procedure is invoked by the Tk configuration code
* to produce a printable string for the "-align" configuration
* option for embedded windows.
*
* Results:
* The return value is a string describing the embedded
* window's current alignment.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static char *
AlignPrintFunc(clientData, tkwin, widgRec, offset, freeFuncPtr)
gpointer clientData; /* Ignored. */
Tk_Window tkwin; /* Window for text widget. */
char *widgRec; /* Pointer to GtkTextEmbWindow
* structure. */
int offset; /* Ignored. */
Tcl_FreeFunc **freeFuncPtr; /* Pointer to variable to fill in with
* information about how to reclaim
* storage for return string. */
{
switch (((GtkTextEmbWindow *) widgRec)->align) {
case ALIGN_BASELINE:
return "baseline";
case ALIGN_BOTTOM:
return "bottom";
case ALIGN_CENTER:
return "center";
case ALIGN_TOP:
return "top";
default:
return "??";
}
}
/*
*--------------------------------------------------------------
*
* EmbWinStructureFunc --
*
* This procedure is invoked by the Tk event loop whenever
* StructureNotify events occur for a window that's embedded
* in a text widget. This procedure's only purpose is to
* clean up when windows are deleted.
*
* Results:
* None.
*
* Side effects:
* The window is disassociated from the window segment, and
* the portion of the text is redisplayed.
*
*--------------------------------------------------------------
*/
static void
EmbWinStructureFunc(clientData, eventPtr)
gpointer clientData; /* Pointer to record describing window item. */
XEvent *eventPtr; /* Describes what just happened. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) clientData;
GtkTextIndex index;
if (eventPtr->type != DestroyNotify) {
return;
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&ewPtr->body.ew.tkxt->windowTable,
Tk_PathName(ewPtr->body.ew.tkwin)));
ewPtr->body.ew.tkwin = NULL;
index.tree = ewPtr->body.ew.tkxt->tree;
index.line = ewPtr->body.ew.line;
index.byteIndex = gtk_text_line_segment_get_offset(ewPtr, ewPtr->body.ew.line);
gtk_text_buffer_need_redisplay(ewPtr->body.ew.tkxt, &index, &index);
}
/*
*--------------------------------------------------------------
*
* EmbWinRequestFunc --
*
* This procedure is invoked whenever a window that's associated
* with a window canvas item changes its requested dimensions.
*
* Results:
* None.
*
* Side effects:
* The size and location on the screen of the window may change,
* depending on the options specified for the window item.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static void
EmbWinRequestFunc(clientData, tkwin)
gpointer clientData; /* Pointer to record for window item. */
Tk_Window tkwin; /* Window that changed its desired
* size. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) clientData;
GtkTextIndex index;
index.tree = ewPtr->body.ew.tkxt->tree;
index.line = ewPtr->body.ew.line;
index.byteIndex = gtk_text_line_segment_get_offset(ewPtr, ewPtr->body.ew.line);
gtk_text_buffer_need_redisplay(ewPtr->body.ew.tkxt, &index, &index);
}
/*
*--------------------------------------------------------------
*
* EmbWinLostSlaveFunc --
*
* This procedure is invoked by the Tk geometry manager when
* a slave window managed by a text widget is claimed away
* by another geometry manager.
*
* Results:
* None.
*
* Side effects:
* The window is disassociated from the window segment, and
* the portion of the text is redisplayed.
*
*--------------------------------------------------------------
*/
static void
EmbWinLostSlaveFunc(clientData, tkwin)
gpointer clientData; /* Pointer to record describing window item. */
Tk_Window tkwin; /* Window that was claimed away by another
* geometry manager. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) clientData;
GtkTextIndex index;
Tk_DeleteEventHandler(ewPtr->body.ew.tkwin, StructureNotifyMask,
EmbWinStructureFunc, (gpointer) ewPtr);
Tcl_CancelIdleCall(EmbWinDelayedUnmap, (gpointer) ewPtr);
if (ewPtr->body.ew.tkxt->tkwin != Tk_Parent(tkwin)) {
Tk_UnmaintainGeometry(tkwin, ewPtr->body.ew.tkxt->tkwin);
} else {
Tk_UnmapWindow(tkwin);
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&ewPtr->body.ew.tkxt->windowTable,
Tk_PathName(ewPtr->body.ew.tkwin)));
ewPtr->body.ew.tkwin = NULL;
index.tree = ewPtr->body.ew.tkxt->tree;
index.line = ewPtr->body.ew.line;
index.byteIndex = gtk_text_line_segment_get_offset(ewPtr, ewPtr->body.ew.line);
gtk_text_buffer_need_redisplay(ewPtr->body.ew.tkxt, &index, &index);
}
/*
*--------------------------------------------------------------
*
* EmbWinDeleteFunc --
*
* This procedure is invoked by the text B-tree code whenever
* an embedded window lies in a range of characters being deleted.
*
* Results:
* Returns 0 to indicate that the deletion has been accepted.
*
* Side effects:
* The embedded window is deleted, if it exists, and any resources
* associated with it are released.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static int
EmbWinDeleteFunc(ewPtr, line, treeGone)
GtkTextLineSegment *ewPtr; /* Segment being deleted. */
GtkTextLine *line; /* Line containing segment. */
int treeGone; /* Non-zero means the entire tree is
* being deleted, so everything must
* get cleaned up. */
{
Tcl_HashEntry *hPtr;
if (ewPtr->body.ew.tkwin != NULL) {
hPtr = Tcl_FindHashEntry(&ewPtr->body.ew.tkxt->windowTable,
Tk_PathName(ewPtr->body.ew.tkwin));
if (hPtr != NULL) {
/*
* (It's possible for there to be no hash table entry for this
* window, if an error occurred while creating the window segment
* but before the window got added to the table)
*/
Tcl_DeleteHashEntry(hPtr);
}
/*
* Delete the event handler for the window before destroying
* the window, so that EmbWinStructureFunc doesn't get called
* (we'll already do everything that it would have done, and
* it will just get confused).
*/
Tk_DeleteEventHandler(ewPtr->body.ew.tkwin, StructureNotifyMask,
EmbWinStructureFunc, (gpointer) ewPtr);
Tk_DestroyWindow(ewPtr->body.ew.tkwin);
}
Tcl_CancelIdleCall(EmbWinDelayedUnmap, (gpointer) ewPtr);
Tk_FreeOptions(configSpecs, (char *) &ewPtr->body.ew,
ewPtr->body.ew.tkxt->display, 0);
g_free((char *) ewPtr);
return 0;
}
/*
*--------------------------------------------------------------
*
* EmbWinCleanupFunc --
*
* This procedure is invoked by the B-tree code whenever a
* segment containing an embedded window is moved from one
* line to another.
*
* Results:
* None.
*
* Side effects:
* The line field of the segment gets updated.
*
*--------------------------------------------------------------
*/
static GtkTextLineSegment *
EmbWinCleanupFunc(ewPtr, line)
GtkTextLineSegment *ewPtr; /* Mark segment that's being moved. */
GtkTextLine *line; /* Line that now contains segment. */
{
ewPtr->body.ew.line = line;
return ewPtr;
}
/*
*--------------------------------------------------------------
*
* EmbWinLayoutFunc --
*
* This procedure is the "layoutFunc" for embedded window
* segments.
*
* Results:
* 1 is returned to indicate that the segment should be
* displayed. The chunkPtr structure is filled in.
*
* Side effects:
* None, except for filling in chunkPtr.
*
*--------------------------------------------------------------
*/
/*ARGSUSED*/
static int
EmbWinLayoutFunc(tkxt, indexPtr, ewPtr, offset, maxX, maxChars,
noCharsYet, wrapMode, chunkPtr)
GtkTextView *tkxt; /* Text widget being layed out. */
GtkTextIndex *indexPtr; /* Identifies first character in chunk. */
GtkTextLineSegment *ewPtr; /* Segment corresponding to indexPtr. */
int offset; /* Offset within segPtr corresponding to
* indexPtr (always 0). */
int maxX; /* Chunk must not occupy pixels at this
* position or higher. */
int maxChars; /* Chunk must not include more than this
* many characters. */
int noCharsYet; /* Non-zero means no characters have been
* assigned to this line yet. */
GtkWrapMode wrapMode; /* Wrap mode to use for line: GTK_WRAPMODE_CHAR,
* GTK_WRAPMODE_NONE, or GTK_WRAPMODE_WORD. */
GtkTextDisplayChunk *chunkPtr;
/* Structure to fill in with information
* about this chunk. The x field has already
* been set by the caller. */
{
int width, height;
if (offset != 0) {
panic("Non-zero offset in EmbWinLayoutFunc");
}
if ((ewPtr->body.ew.tkwin == NULL) && (ewPtr->body.ew.create != NULL)) {
int code, new;
Tcl_DString name;
Tk_Window ancestor;
Tcl_HashEntry *hPtr;
/*
* The window doesn't currently exist. Create it by evaluating
* the creation script. The script must return the window's
* path name: look up that name to get back to the window
* token. Then ourselves as the geometry manager for
* the window.
*/
code = Tcl_GlobalEval(tkxt->interp, ewPtr->body.ew.create);
if (code != TCL_OK) {
createError:
Tcl_BackgroundError(tkxt->interp);
goto gotWindow;
}
Tcl_DStringInit(&name);
Tcl_DStringAppend(&name, Tcl_GetStringResult(tkxt->interp), -1);
Tcl_ResetResult(tkxt->interp);
ewPtr->body.ew.tkwin = Tk_NameToWindow(tkxt->interp,
Tcl_DStringValue(&name), tkxt->tkwin);
if (ewPtr->body.ew.tkwin == NULL) {
goto createError;
}
for (ancestor = tkxt->tkwin; ;
ancestor = Tk_Parent(ancestor)) {
if (ancestor == Tk_Parent(ewPtr->body.ew.tkwin)) {
break;
}
if (Tk_IsTopLevel(ancestor)) {
badMaster:
Tcl_AppendResult(tkxt->interp, "can't embed ",
Tk_PathName(ewPtr->body.ew.tkwin), " relative to ",
Tk_PathName(tkxt->tkwin), (char *) NULL);
Tcl_BackgroundError(tkxt->interp);
ewPtr->body.ew.tkwin = NULL;
goto gotWindow;
}
}
if (Tk_IsTopLevel(ewPtr->body.ew.tkwin)
|| (tkxt->tkwin == ewPtr->body.ew.tkwin)) {
goto badMaster;
}
Tk_ManageGeometry(ewPtr->body.ew.tkwin, &textGeomType,
(gpointer) ewPtr);
Tk_CreateEventHandler(ewPtr->body.ew.tkwin, StructureNotifyMask,
EmbWinStructureFunc, (gpointer) ewPtr);
/*
* Special trick! Must enter into the hash table *after*
* calling Tk_ManageGeometry: if the window was already managed
* elsewhere in this text, the Tk_ManageGeometry call will cause
* the entry to be removed, which could potentially lose the new
* entry.
*/
hPtr = Tcl_CreateHashEntry(&tkxt->windowTable,
Tk_PathName(ewPtr->body.ew.tkwin), &new);
Tcl_SetHashValue(hPtr, ewPtr);
}
/*
* See if there's room for this window on this line.
*/
gotWindow:
if (ewPtr->body.ew.tkwin == NULL) {
width = 0;
height = 0;
} else {
width = Tk_ReqWidth(ewPtr->body.ew.tkwin) + 2*ewPtr->body.ew.padX;
height = Tk_ReqHeight(ewPtr->body.ew.tkwin) + 2*ewPtr->body.ew.padY;
}
if ((width > (maxX - chunkPtr->x))
&& !noCharsYet && (tkxt->wrapMode != GTK_WRAPMODE_NONE)) {
return 0;
}
/*
* Fill in the chunk structure.
*/
chunkPtr->displayFunc = EmbWinDisplayFunc;
chunkPtr->undisplayFunc = EmbWinUndisplayFunc;
chunkPtr->measureFunc = (GtkTextViewChunkMeasureFunc *) NULL;
chunkPtr->bboxFunc = EmbWinBboxFunc;
chunkPtr->numBytes = 1;
if (ewPtr->body.ew.align == ALIGN_BASELINE) {
chunkPtr->minAscent = height - ewPtr->body.ew.padY;
chunkPtr->minDescent = ewPtr->body.ew.padY;
chunkPtr->minHeight = 0;
} else {
chunkPtr->minAscent = 0;
chunkPtr->minDescent = 0;
chunkPtr->minHeight = height;
}
chunkPtr->width = width;
chunkPtr->breakIndex = -1;
chunkPtr->breakIndex = 1;
chunkPtr->clientData = (gpointer) ewPtr;
ewPtr->body.ew.chunkCount += 1;
return 1;
}
/*
*--------------------------------------------------------------
*
* EmbWinCheckFunc --
*
* This procedure is invoked by the B-tree code to perform
* consistency checks on embedded windows.
*
* Results:
* None.
*
* Side effects:
* The procedure panics if it detects anything wrong with
* the embedded window.
*
*--------------------------------------------------------------
*/
static void
EmbWinCheckFunc(ewPtr, line)
GtkTextLineSegment *ewPtr; /* Segment to check. */
GtkTextLine *line; /* Line containing segment. */
{
if (ewPtr->next == NULL) {
panic("EmbWinCheckFunc: embedded window is last segment in line");
}
if (ewPtr->size != 1) {
panic("EmbWinCheckFunc: embedded window has size %d", ewPtr->size);
}
}
/*
*--------------------------------------------------------------
*
* EmbWinDisplayFunc --
*
* This procedure is invoked by the text displaying code
* when it is time to actually draw an embedded window
* chunk on the screen.
*
* Results:
* None.
*
* Side effects:
* The embedded window gets moved to the correct location
* and mapped onto the screen.
*
*--------------------------------------------------------------
*/
static void
EmbWinDisplayFunc(chunkPtr, x, y, lineHeight, baseline, display, dst, screenY)
GtkTextDisplayChunk *chunkPtr; /* Chunk that is to be drawn. */
int x; /* X-position in dst at which to
* draw this chunk (differs from
* the x-position in the chunk because
* of scrolling). */
int y; /* Top of rectangular bounding box
* for line: tells where to draw this
* chunk in dst (x-position is in
* the chunk itself). */
int lineHeight; /* Total height of line. */
int baseline; /* Offset of baseline from y. */
Display *display; /* Display to use for drawing. */
Drawable dst; /* Pixmap or window in which to draw */
int screenY; /* Y-coordinate in text window that
* corresponds to y. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) chunkPtr->clientData;
int lineX, windowX, windowY, width, height;
Tk_Window tkwin;
tkwin = ewPtr->body.ew.tkwin;
if (tkwin == NULL) {
return;
}
if ((x + chunkPtr->width) <= 0) {
/*
* The window is off-screen; just unmap it.
*/
if (ewPtr->body.ew.tkxt->tkwin != Tk_Parent(tkwin)) {
Tk_UnmaintainGeometry(tkwin, ewPtr->body.ew.tkxt->tkwin);
} else {
Tk_UnmapWindow(tkwin);
}
return;
}
/*
* Compute the window's location and size in the text widget, taking
* into account the align and stretch values for the window.
*/
EmbWinBboxFunc(chunkPtr, 0, screenY, lineHeight, baseline, &lineX,
&windowY, &width, &height);
windowX = lineX - chunkPtr->x + x;
if (ewPtr->body.ew.tkxt->tkwin == Tk_Parent(tkwin)) {
if ((windowX != Tk_X(tkwin)) || (windowY != Tk_Y(tkwin))
|| (Tk_ReqWidth(tkwin) != Tk_Width(tkwin))
|| (height != Tk_Height(tkwin))) {
Tk_MoveResizeWindow(tkwin, windowX, windowY, width, height);
}
Tk_MapWindow(tkwin);
} else {
Tk_MaintainGeometry(tkwin, ewPtr->body.ew.tkxt->tkwin,
windowX, windowY, width, height);
}
/*
* Mark the window as displayed so that it won't get unmapped.
*/
ewPtr->body.ew.displayed = 1;
}
/*
*--------------------------------------------------------------
*
* EmbWinUndisplayFunc --
*
* This procedure is called when the chunk for an embedded
* window is no longer going to be displayed. It arranges
* for the window associated with the chunk to be unmapped.
*
* Results:
* None.
*
* Side effects:
* The window is scheduled for unmapping.
*
*--------------------------------------------------------------
*/
static void
EmbWinUndisplayFunc(tkxt, chunkPtr)
GtkTextView *tkxt; /* Overall information about text
* widget. */
GtkTextDisplayChunk *chunkPtr; /* Chunk that is about to be freed. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) chunkPtr->clientData;
ewPtr->body.ew.chunkCount--;
if (ewPtr->body.ew.chunkCount == 0) {
/*
* Don't unmap the window immediately, since there's a good chance
* that it will immediately be redisplayed, perhaps even in the
* same place. Instead, schedule the window to be unmapped later;
* the call to EmbWinDelayedUnmap will be cancelled in the likely
* event that the unmap becomes unnecessary.
*/
ewPtr->body.ew.displayed = 0;
Tcl_DoWhenIdle(EmbWinDelayedUnmap, (gpointer) ewPtr);
}
}
/*
*--------------------------------------------------------------
*
* EmbWinBboxFunc --
*
* This procedure is called to compute the bounding box of
* the area occupied by an embedded window.
*
* Results:
* There is no return value. *xPtr and *yPtr are filled in
* with the coordinates of the upper left corner of the
* window, and *widthPtr and *heightPtr are filled in with
* the dimensions of the window in pixels. Note: not all
* of the returned bbox is necessarily visible on the screen
* (the rightmost part might be off-screen to the right,
* and the bottommost part might be off-screen to the bottom).
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static void
EmbWinBboxFunc(chunkPtr, index, y, lineHeight, baseline, xPtr, yPtr,
widthPtr, heightPtr)
GtkTextDisplayChunk *chunkPtr; /* Chunk containing desired char. */
int index; /* Index of desired character within
* the chunk. */
int y; /* Topmost pixel in area allocated
* for this line. */
int lineHeight; /* Total height of line. */
int baseline; /* Location of line's baseline, in
* pixels measured down from y. */
int *xPtr, *yPtr; /* Gets filled in with coords of
* character's upper-left pixel. */
int *widthPtr; /* Gets filled in with width of
* character, in pixels. */
int *heightPtr; /* Gets filled in with height of
* character, in pixels. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) chunkPtr->clientData;
Tk_Window tkwin;
tkwin = ewPtr->body.ew.tkwin;
if (tkwin != NULL) {
*widthPtr = Tk_ReqWidth(tkwin);
*heightPtr = Tk_ReqHeight(tkwin);
} else {
*widthPtr = 0;
*heightPtr = 0;
}
*xPtr = chunkPtr->x + ewPtr->body.ew.padX;
if (ewPtr->body.ew.stretch) {
if (ewPtr->body.ew.align == ALIGN_BASELINE) {
*heightPtr = baseline - ewPtr->body.ew.padY;
} else {
*heightPtr = lineHeight - 2*ewPtr->body.ew.padY;
}
}
switch (ewPtr->body.ew.align) {
case ALIGN_BOTTOM:
*yPtr = y + (lineHeight - *heightPtr - ewPtr->body.ew.padY);
break;
case ALIGN_CENTER:
*yPtr = y + (lineHeight - *heightPtr)/2;
break;
case ALIGN_TOP:
*yPtr = y + ewPtr->body.ew.padY;
break;
case ALIGN_BASELINE:
*yPtr = y + (baseline - *heightPtr);
break;
}
}
/*
*--------------------------------------------------------------
*
* EmbWinDelayedUnmap --
*
* This procedure is an idle handler that does the actual
* work of unmapping an embedded window. See the comment
* in EmbWinUndisplayFunc for details.
*
* Results:
* None.
*
* Side effects:
* The window gets unmapped, unless its chunk reference count
* has become non-zero again.
*
*--------------------------------------------------------------
*/
static void
EmbWinDelayedUnmap(clientData)
gpointer clientData; /* Token for the window to
* be unmapped. */
{
GtkTextLineSegment *ewPtr = (GtkTextLineSegment *) clientData;
if (!ewPtr->body.ew.displayed && (ewPtr->body.ew.tkwin != NULL)) {
if (ewPtr->body.ew.tkxt->tkwin != Tk_Parent(ewPtr->body.ew.tkwin)) {
Tk_UnmaintainGeometry(ewPtr->body.ew.tkwin,
ewPtr->body.ew.tkxt->tkwin);
} else {
Tk_UnmapWindow(ewPtr->body.ew.tkwin);
}
}
}
/*
*--------------------------------------------------------------
*
* GtkTextViewWindowIndex --
*
* Given the name of an embedded window within a text widget,
* returns an index corresponding to the window's position
* in the text.
*
* Results:
* The return value is 1 if there is an embedded window by
* the given name in the text widget, 0 otherwise. If the
* window exists, *indexPtr is filled in with its index.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
int
GtkTextViewWindowIndex(tkxt, name, indexPtr)
GtkTextView *tkxt; /* Text widget containing window. */
char *name; /* Name of window. */
GtkTextIndex *indexPtr; /* Index information gets stored here. */
{
Tcl_HashEntry *hPtr;
GtkTextLineSegment *ewPtr;
hPtr = Tcl_FindHashEntry(&tkxt->windowTable, name);
if (hPtr == NULL) {
return 0;
}
ewPtr = (GtkTextLineSegment *) Tcl_GetHashValue(hPtr);
indexPtr->tree = tkxt->tree;
indexPtr->line = ewPtr->body.ew.line;
indexPtr->byteIndex = gtk_text_line_segment_get_offset(ewPtr, indexPtr->line);
return 1;
}
#endif