gtk2/gtk/gtktextlayout.h
Owen Taylor dfba226908 Make parent_class static.
Sun Nov  5 04:24:53 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkcellrenderertextpixbuf.c: Make parent_class
	static.

Tue Sep 19 10:54:22 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimcontext*.[ch] gtk/gtkimmulticontext.[ch]
	gtk/gtktextlayout.[ch] gtk/gtktextview.c gtk/gtkentry.c:
	Add support for positioning the cursor within the preedit string.

Mon Sep 18 23:56:32 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextview.c: Check for bindings after passing
	events to im context filter.

Mon Sep 18 11:50:51 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.c (add_preedit_attrs): Handle
	empty attribute lists properly.

Sun Sep 17 10:08:16 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/queryimmodules.c (main): Return non-zero exit
	status if errors were encountered querying any
	modules.

Sat Sep 16 14:01:52 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtk.h: include gtkmodule.h gtkoldeditable.h,
	don't include gtkthemes.h.

	* gtk/testgtk.c gtk/testtext.c: Set environment variables
	to point

	* gtk/Makefile.am: Add new .c and .h files, build
	gtk-query-immodules and use it to create a gtk.immodules
	file for use of test programs.

	* gtk/gtkpreview.c: remove extra blank line.

Sat Sep 16 13:21:04 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimcontextsimple.c (gtk_im_context_simple_add_table):
	Add the ability to add extra tables beyond the default
	one, and also the ability to have compose sequences
	that are prefixes of other compose sequences.

	* gtk/gtkimcontextsimple.c: Export a preedit string which
	consists of possible candidates for keystrokes that have
	been entered but not yet committed.

	* gtk/gtkimcontext.[ch] gtk/immulticontext.[ch]
	gtk/gtkimcontextsimple.[ch]: add gtk_im_context_reset()

	* gtk/gtkmulticontext.[ch] (gtk_im_multicontext_append_menuitems):
	Add a function to add input-method switching menu items
	to a menu.

	* gtk/gtkimmulticontext.[ch]: Properly handly set_client_window
	when switching input methods.

	* gtk/gtkimcontextsimple.[ch]: Change the format of
	the compose table to allow compose tables of different
	lengths / sequence.

Sat Sep 16 13:05:48 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkimmodule.[ch]: Support routines for loading
	GtkIMContext implementations dynamically at runtime.

	* gtk/queryimmodules.c: Program to query the available
	input modules and write the results into a file.

	* gtk/gtkrc.[ch] (gtk_rc_get_im_module_file): Add
	extra config options "im_module_file" (cache file for
	input method modules), and "im_module_path" - path
	to look for modules when generating cache file.

	This doesn't scale.

Sat Sep 16 13:09:06 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkthemes.[ch] gtk/gtkmodule.[ch]: Move most of the
	generic	code from gtkthemes into a new abstraction
	GtkModule which has the logic for implementing
	a loadable module which implements a number of
	GObject types.

Sat Sep 16 13:07:13 2000  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkeditable.[ch]: Convert GtkEditable from
	a class into an interface

	* gtk/gtkoldeditable.[ch]: Move the old editable
	implementation into here, so legacy widgets can
	still rely on the implemenation. GtkOldEditable
	exports GtkEditable. Make selection handling
	code use new text conversion functions (and
	handle UTF-8 as a side-effect). Use GtkClipboard
	for CLIPBOARD.

	* gtk/gtktext.[ch] gtk/gtkcombo.c gtk/gtkspinbutton.c:
	Adopt to match above changes.

	* gtk/gtkentry.[ch]: Implement GtkEditable directly,
	avoid GtkOldEditable implementation. Restructure
        to reduce number of places that modify state directly.
	Move to GtkBindingSet. Display the preedit string.
	Queue recomputation of PangoLayout and scroll position
	to improve effiency of doing complex changes naively.
	Add a menu with cut/copy/paste and input method selection.

Thu Sep 14 22:11:05 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtktextlayout.[ch]: Add gtk_text_layout_set_preedit_string()
	to set preedit string and attributes; display preedit string by
	inserting string and attributes at cursor when creating the
	GtkTextLineDisplay.

	* gtk/gtktextlayout.c: Move all conversions between byte
	positions in PangoLayout and GtkTextIter into new functions
	line_display_iter_to_index/index_to_iter that properly
	handle the preedit string.

	* gtk/gtktextmark.[ch]: Restore gtk_text_mark_get_name, modify
	it to return const char * (eventually will end up
	as GCONST char *, most likely.)

	* gtk/gtktextview.[ch]: Handle the preedit string, call
	gtk_im_context_reset() as necessary, add a menu to switch
	input methods.

	* gtk/gtktextlayout.[ch]: Remove useless
	gtk_text_layout_get_log_attrs() function.
2000-11-12 03:43:24 +00:00

375 lines
16 KiB
C

/* GTK - The GIMP Toolkit
* gtktextlayout.h
*
* Copyright (c) 1992-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
* Pango support by Owen Taylor
*
* This file can be used under your choice of two licenses, the LGPL
* and the original Tk license.
*
* LGPL:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Original Tk license:
*
* 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.
*
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef GTK_TEXT_LAYOUT_H
#define GTK_TEXT_LAYOUT_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* This is a "semi-private" header; it is intended for
* use by the text widget, and the text canvas item,
* but that's all. We may have to install it so the
* canvas item can use it, but users are not supposed
* to use it.
*/
#include <gtk/gtktextbuffer.h>
#include <gtk/gtktextiter.h>
/* forward declarations that have to be here to avoid including
* gtktextbtree.h
*/
typedef struct _GtkTextLine GtkTextLine;
typedef struct _GtkTextLineData GtkTextLineData;
#define GTK_TYPE_TEXT_LAYOUT (gtk_text_layout_get_type ())
#define GTK_TEXT_LAYOUT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayout))
#define GTK_TEXT_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
#define GTK_IS_TEXT_LAYOUT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_LAYOUT))
#define GTK_IS_TEXT_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_LAYOUT))
#define GTK_TEXT_LAYOUT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass))
typedef struct _GtkTextLayout GtkTextLayout;
typedef struct _GtkTextLayoutClass GtkTextLayoutClass;
typedef struct _GtkTextLineDisplay GtkTextLineDisplay;
typedef struct _GtkTextCursorDisplay GtkTextCursorDisplay;
typedef struct _GtkTextAttrAppearance GtkTextAttrAppearance;
struct _GtkTextLayout
{
GtkObject parent_instance;
/* width of the display area on-screen,
* i.e. pixels we should wrap to fit inside. */
gint screen_width;
/* width/height of the total logical area being layed out */
gint width;
gint height;
/* Pixel offsets from the left and from the top to be used when we
* draw; these allow us to create left/top margins. We don't need
* anything special for bottom/right margins, because those don't
* affect drawing.
*/
/* gint left_edge; */
/* gint top_edge; */
GtkTextBuffer *buffer;
/* Default style used if no tags override it */
GtkTextAttributes *default_style;
/* Pango contexts used for creating layouts */
PangoContext *ltr_context;
PangoContext *rtl_context;
/* A cache of one style; this is used to ensure
* we don't constantly regenerate the style
* over long runs with the same style. */
GtkTextAttributes *one_style_cache;
/* A cache of one line display. Getting the same line
* many times in a row is the most common case.
*/
GtkTextLineDisplay *one_display_cache;
/* Whether we are allowed to wrap right now */
gint wrap_loop_count;
/* Whether to show the insertion cursor */
guint cursor_visible : 1;
/* The preedit string and attributes, if any */
gchar *preedit_string;
PangoAttrList *preedit_attrs;
gint preedit_len;
gint preedit_cursor;
};
struct _GtkTextLayoutClass
{
GtkObjectClass parent_class;
/* Some portion of the layout was invalidated
*/
void (*invalidated) (GtkTextLayout *layout);
/* A range of the layout changed appearance and possibly height
*/
void (*changed) (GtkTextLayout *layout,
gint y,
gint old_height,
gint new_height);
GtkTextLineData* (*wrap) (GtkTextLayout *layout,
GtkTextLine *line,
GtkTextLineData *line_data); /* may be NULL */
void (*get_log_attrs) (GtkTextLayout *layout,
GtkTextLine *line,
PangoLogAttr **attrs,
gint *n_attrs);
void (*invalidate) (GtkTextLayout *layout,
const GtkTextIter *start,
const GtkTextIter *end);
void (*free_line_data) (GtkTextLayout *layout,
GtkTextLine *line,
GtkTextLineData *line_data);
void (*allocate_child) (GtkTextLayout *layout,
GtkWidget *child,
gint x,
gint y);
};
struct _GtkTextAttrAppearance
{
PangoAttribute attr;
GtkTextAppearance appearance;
};
struct _GtkTextCursorDisplay
{
gint x;
gint y;
gint height;
guint is_strong : 1;
guint is_weak : 1;
};
struct _GtkTextLineDisplay
{
PangoLayout *layout;
GSList *cursors;
GSList *shaped_objects;
GtkTextDirection direction;
gint width; /* Width of layout */
gint total_width; /* width - margins, if no width set on layout, if width set on layout, -1 */
gint height;
gint x_offset; /* Amount layout is shifted from left edge */
gint left_margin;
gint right_margin;
gint top_margin;
gint bottom_margin;
gint insert_index; /* Byte index of insert cursor within para or -1 */
gboolean size_only;
GtkTextLine *line;
};
extern PangoAttrType gtk_text_attr_appearance_type;
GtkType gtk_text_layout_get_type (void) G_GNUC_CONST;
GtkTextLayout* gtk_text_layout_new (void);
void gtk_text_layout_set_buffer (GtkTextLayout *layout,
GtkTextBuffer *buffer);
void gtk_text_layout_set_default_style (GtkTextLayout *layout,
GtkTextAttributes *values);
void gtk_text_layout_set_contexts (GtkTextLayout *layout,
PangoContext *ltr_context,
PangoContext *rtl_context);
void gtk_text_layout_default_style_changed (GtkTextLayout *layout);
void gtk_text_layout_set_screen_width (GtkTextLayout *layout,
gint width);
void gtk_text_layout_set_preedit_string (GtkTextLayout *layout,
const gchar *preedit_string,
PangoAttrList *preedit_attrs,
gint cursor_pos);
void gtk_text_layout_set_cursor_visible (GtkTextLayout *layout,
gboolean cursor_visible);
gboolean gtk_text_layout_get_cursor_visible (GtkTextLayout *layout);
/* Getting the size or the lines potentially results in a call to
* recompute, which is pretty massively expensive. Thus it should
* basically only be done in an idle handler.
*
* Long-term, we would really like to be able to do these without
* a full recompute so they may get cheaper over time.
*/
void gtk_text_layout_get_size (GtkTextLayout *layout,
gint *width,
gint *height);
GSList* gtk_text_layout_get_lines (GtkTextLayout *layout,
/* [top_y, bottom_y) */
gint top_y,
gint bottom_y,
gint *first_line_y);
void gtk_text_layout_wrap_loop_start (GtkTextLayout *layout);
void gtk_text_layout_wrap_loop_end (GtkTextLayout *layout);
GtkTextLineDisplay* gtk_text_layout_get_line_display (GtkTextLayout *layout,
GtkTextLine *line,
gboolean size_only);
void gtk_text_layout_free_line_display (GtkTextLayout *layout,
GtkTextLineDisplay *display);
void gtk_text_layout_get_line_at_y (GtkTextLayout *layout,
GtkTextIter *target_iter,
gint y,
gint *line_top);
void gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
GtkTextIter *iter,
gint x,
gint y);
void gtk_text_layout_invalidate (GtkTextLayout *layout,
const GtkTextIter *start,
const GtkTextIter *end);
void gtk_text_layout_free_line_data (GtkTextLayout *layout,
GtkTextLine *line,
GtkTextLineData *line_data);
gboolean gtk_text_layout_is_valid (GtkTextLayout *layout);
void gtk_text_layout_validate_yrange (GtkTextLayout *layout,
GtkTextIter *anchor_line,
gint y0,
gint y1);
void gtk_text_layout_validate (GtkTextLayout *layout,
gint max_pixels);
/* This function should return the passed-in line data,
* OR remove the existing line data from the line, and
* return a NEW line data after adding it to the line.
* That is, invariant after calling the callback is that
* there should be exactly one line data for this view
* stored on the btree line.
*/
GtkTextLineData* gtk_text_layout_wrap (GtkTextLayout *layout,
GtkTextLine *line,
GtkTextLineData *line_data); /* may be NULL */
void gtk_text_layout_changed (GtkTextLayout *layout,
gint y,
gint old_height,
gint new_height);
void gtk_text_layout_get_iter_location (GtkTextLayout *layout,
const GtkTextIter *iter,
GdkRectangle *rect);
void gtk_text_layout_get_line_yrange (GtkTextLayout *layout,
const GtkTextIter *iter,
gint *y,
gint *height);
void gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
GtkTextIter *iter,
GdkRectangle *strong_pos,
GdkRectangle *weak_pos);
gboolean gtk_text_layout_clamp_iter_to_vrange (GtkTextLayout *layout,
GtkTextIter *iter,
gint top,
gint bottom);
void gtk_text_layout_move_iter_to_line_end (GtkTextLayout *layout,
GtkTextIter *iter,
gint direction);
void gtk_text_layout_move_iter_to_previous_line (GtkTextLayout *layout,
GtkTextIter *iter);
void gtk_text_layout_move_iter_to_next_line (GtkTextLayout *layout,
GtkTextIter *iter);
void gtk_text_layout_move_iter_to_x (GtkTextLayout *layout,
GtkTextIter *iter,
gint x);
void gtk_text_layout_move_iter_visually (GtkTextLayout *layout,
GtkTextIter *iter,
gint count);
/* Don't use these. Use gtk_text_view_add_child_at_anchor().
* These functions are defined in gtktextchild.c, but here
* since they are semi-public and require GtkTextLayout to
* be declared.
*/
void gtk_text_child_anchor_register_child (GtkTextChildAnchor *anchor,
GtkWidget *child,
GtkTextLayout *layout);
void gtk_text_child_anchor_unregister_child (GtkTextChildAnchor *anchor,
GtkWidget *child);
void gtk_text_child_anchor_queue_resize (GtkTextChildAnchor *anchor,
GtkTextLayout *layout);
void gtk_text_layout_spew (GtkTextLayout *layout);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* GTK_TEXT_LAYOUT_H */