Commit 9bec105a authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

Draw the focus, and leave space to do so.

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

	* gtk/gtktextview.c: Draw the focus, and leave space to do so.

	* gtk/gtktexttypes.c: Remove Latin1 conversion stuff

	* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
	Fix a bug when removing node data, we didn't properly
	re-splice the linked list after removing the data.

	* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
	GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget

	* gtk/gtktextbuffer.c (selection_received): fix g_convert usage

	* gtk/gtktextlayout.c (set_para_values): Set tab array
	for the layout from the GtkTextTag.

	* gtk/gtktexttypes.h: delete tab and search cruft,
	remove g_convert() in favor of GLib version

	* gtk/gtktexttypes.c: remove tab implementation from here,
	move to Pango

	* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
	tab stuff using new PangoTabArray from Pango

	* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
	unused border_width stuff
parent f235c3cb
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
2000-09-25 Havoc Pennington <hp@redhat.com>
* gtk/gtktextview.c: Draw the focus, and leave space to do so.
* gtk/gtktexttypes.c: Remove Latin1 conversion stuff
* gtk/gtktextbtree.c (gtk_text_btree_node_remove_data):
Fix a bug when removing node data, we didn't properly
re-splice the linked list after removing the data.
* gtk/gtktextview.c (gtk_text_view_key_press_event): Pass through
GDK_Tab as literal tab, Ctrl-Tab to tab to focus widget
* gtk/gtktextbuffer.c (selection_received): fix g_convert usage
* gtk/gtktextlayout.c (set_para_values): Set tab array
for the layout from the GtkTextTag.
* gtk/gtktexttypes.h: delete tab and search cruft,
remove g_convert() in favor of GLib version
* gtk/gtktexttypes.c: remove tab implementation from here,
move to Pango
* gtk/gtktexttag.h, gtk/gtktexttag.c: Implement
tab stuff using new PangoTabArray from Pango
* gtk/gtktexttag.c (gtk_text_attributes_fill_from_tags): Remove
unused border_width stuff
Thu Sep 14 12:21:12 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtktexttypes.[ch]: Remove g_convert (moved to
......
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
Drawables to Pixbufs
<!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
<para>
A function of this type can be used to override the default
......@@ -15,10 +19,6 @@
@pixbuf: The pixbuf that is losing its last reference.
@data: User closure data.
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
Drawables to Pixbufs
<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
<para>
......
......@@ -4724,6 +4724,7 @@ gtk_text_btree_node_remove_data(GtkTextBTreeNode *node, gpointer view_id)
if (nd->view_id == view_id)
break;
prev = nd;
nd = nd->next;
}
......
......@@ -1414,7 +1414,6 @@ clipboard_received (GtkClipboard *clipboard,
}
#endif
if (request_data->interactive)
gtk_text_buffer_insert_interactive (buffer, &insert_point,
str, -1, request_data->default_editable);
......
......@@ -1039,6 +1039,9 @@ set_para_values (GtkTextLayout *layout,
pango_layout_set_alignment (display->layout, pango_align);
pango_layout_set_spacing (display->layout, style->pixels_inside_wrap * PANGO_SCALE);
if (style->tabs)
pango_layout_set_tabs (display->layout, style->tabs);
display->top_margin = style->pixels_above_lines;
display->height = style->pixels_above_lines + style->pixels_below_lines;
display->bottom_margin = style->pixels_below_lines;
......
......@@ -46,6 +46,14 @@ struct _GtkTextLayout
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 */
......
......@@ -55,6 +55,7 @@
#include "gtkmain.h"
#include <stdlib.h>
#include <string.h>
enum {
EVENT,
......@@ -90,6 +91,7 @@ enum {
ARG_OFFSET,
ARG_BG_FULL_HEIGHT,
ARG_LANGUAGE,
ARG_TABS,
/* Whether-a-style-arg-is-set args */
ARG_BACKGROUND_SET,
......@@ -113,6 +115,7 @@ enum {
ARG_OFFSET_SET,
ARG_BG_FULL_HEIGHT_SET,
ARG_LANGUAGE_SET,
ARG_TABS_SET,
LAST_ARG
};
......@@ -218,6 +221,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_UNDERLINE);
gtk_object_add_arg_type ("GtkTextTag::wrap_mode", GTK_TYPE_ENUM,
GTK_ARG_READWRITE, ARG_WRAP_MODE);
gtk_object_add_arg_type ("GtkTextTag::tabs", GTK_TYPE_POINTER,
GTK_ARG_READWRITE, ARG_TABS);
/* Style args are set or not */
gtk_object_add_arg_type ("GtkTextTag::background_set", GTK_TYPE_BOOL,
......@@ -262,6 +267,9 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_UNDERLINE_SET);
gtk_object_add_arg_type ("GtkTextTag::wrap_mode_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_WRAP_MODE_SET);
gtk_object_add_arg_type ("GtkTextTag::tabs_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_TABS_SET);
signals[EVENT] =
gtk_signal_new ("event",
......@@ -581,6 +589,18 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
tkxt_tag->values->language = g_strdup (GTK_VALUE_STRING(*arg));
break;
case ARG_TABS:
tkxt_tag->tabs_set = TRUE;
if (tkxt_tag->values->tabs)
pango_tab_array_free (tkxt_tag->values->tabs);
tkxt_tag->values->tabs =
pango_tab_array_copy (GTK_VALUE_POINTER (*arg));
size_changed = TRUE;
break;
/* Whether the value should be used... */
case ARG_BACKGROUND_SET:
......@@ -672,6 +692,11 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
size_changed = TRUE;
break;
case ARG_TABS_SET:
tkxt_tag->tabs_set = GTK_VALUE_BOOL (*arg);
size_changed = TRUE;
break;
default:
g_assert_not_reached();
break;
......@@ -801,6 +826,11 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_STRING(*arg) = g_strdup (tag->values->language);
break;
case ARG_TABS:
GTK_VALUE_POINTER (*arg) = tag->values->tabs ?
pango_tab_array_copy (tag->values->tabs) : NULL;
break;
case ARG_BACKGROUND_SET:
case ARG_BACKGROUND_GDK_SET:
GTK_VALUE_BOOL(*arg) = tag->bg_color_set;
......@@ -879,6 +909,10 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL(*arg) = tag->language_set;
break;
case ARG_TABS_SET:
GTK_VALUE_BOOL (*arg) = tag->tabs_set;
break;
case ARG_BACKGROUND:
case ARG_FOREGROUND:
default:
......@@ -1067,9 +1101,6 @@ gtk_text_attributes_copy(GtkTextAttributes *src,
if (src->appearance.fg_stipple)
gdk_bitmap_ref(src->appearance.fg_stipple);
if (src->tab_array)
gtk_text_view_tab_array_ref(src->tab_array);
/* Remove refs */
if (dest->appearance.bg_stipple)
......@@ -1078,15 +1109,16 @@ gtk_text_attributes_copy(GtkTextAttributes *src,
if (dest->appearance.fg_stipple)
gdk_bitmap_unref(dest->appearance.fg_stipple);
if (dest->tab_array)
gtk_text_view_tab_array_unref(dest->tab_array);
/* Copy */
orig_refcount = dest->refcount;
*dest = *src;
dest->font_desc = pango_font_description_copy (src->font_desc);
if (src->tabs)
dest->tabs = pango_tab_array_copy (src->tabs);
dest->language = g_strdup (src->language);
dest->refcount = orig_refcount;
......@@ -1122,8 +1154,8 @@ gtk_text_attributes_unref(GtkTextAttributes *values)
if (values->appearance.fg_stipple)
gdk_bitmap_unref(values->appearance.fg_stipple);
if (values->tab_array)
gtk_text_view_tab_array_unref(values->tab_array);
if (values->tabs)
pango_tab_array_free (values->tabs);
if (values->language)
g_free (values->language);
......@@ -1199,9 +1231,6 @@ gtk_text_attributes_fill_from_tags(GtkTextAttributes *dest,
dest->appearance.draw_bg = TRUE;
}
if (tag->border_width_set)
dest->border_width = vals->border_width;
if (tag->relief_set)
dest->relief = vals->relief;
......@@ -1260,12 +1289,11 @@ gtk_text_attributes_fill_from_tags(GtkTextAttributes *dest,
if (tag->pixels_inside_wrap_set)
dest->pixels_inside_wrap = vals->pixels_inside_wrap;
if (tag->tab_array_set)
if (tag->tabs_set)
{
gtk_text_view_tab_array_ref(vals->tab_array);
if (dest->tab_array)
gtk_text_view_tab_array_unref(dest->tab_array);
dest->tab_array = vals->tab_array;
if (dest->tabs)
pango_tab_array_free (dest->tabs);
dest->tabs = pango_tab_array_copy (vals->tabs);
}
if (tag->wrap_mode_set)
......
......@@ -11,9 +11,9 @@ extern "C" {
typedef struct _GtkTextIter GtkTextIter;
typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
typedef struct _GtkTextTagTable GtkTextTagTable;
typedef struct _GtkTextTabArray GtkTextTabArray;
typedef enum {
typedef enum
{
GTK_WRAPMODE_NONE,
GTK_WRAPMODE_CHAR,
GTK_WRAPMODE_WORD
......@@ -54,11 +54,10 @@ struct _GtkTextTag {
GtkTextAttributes *values;
/*
Flags for whether a given value is set; if a value is unset, then
this tag does not affect it. */
/* Flags for whether a given value is set; if a value is unset, then
* this tag does not affect it.
*/
guint bg_color_set : 1;
guint border_width_set : 1;
guint relief_set : 1;
guint bg_stipple_set : 1;
guint fg_color_set : 1;
......@@ -73,7 +72,7 @@ struct _GtkTextTag {
guint pixels_above_lines_set : 1;
guint pixels_below_lines_set : 1;
guint pixels_inside_wrap_set : 1;
guint tab_array_set : 1;
guint tabs_set : 1;
guint underline_set : 1;
guint wrap_mode_set : 1;
guint bg_full_height_set : 1;
......@@ -123,7 +122,8 @@ struct _GtkTextAppearance
/* Whether to use background-related values; this is irrelevant for
* the values struct when in a tag, but is used for the composite
* values struct; it's true if any of the tags being composited
* had background stuff set. */
* had background stuff set.
*/
guint draw_bg : 1;
/* This is only used when we are actually laying out and rendering
......@@ -139,7 +139,6 @@ struct _GtkTextAttributes
GtkTextAppearance appearance;
gint border_width;
GtkShadowType relief;
GtkJustification justify;
GtkTextDirection direction;
......@@ -163,7 +162,7 @@ struct _GtkTextAttributes
gint pixels_inside_wrap;
GtkTextTabArray *tab_array;
PangoTabArray *tabs;
GtkWrapMode wrap_mode; /* How to handle wrap-around for this tag.
* Must be GTK_WRAPMODE_CHAR,
......@@ -176,7 +175,8 @@ struct _GtkTextAttributes
guint invisible : 1;
/* Background is fit to full line height rather than
* baseline +/- ascent/descent (font height) */
* baseline +/- ascent/descent (font height)
*/
guint bg_full_height : 1;
/* can edit this text */
......@@ -197,7 +197,6 @@ void gtk_text_attributes_copy (GtkTextAttributes *src,
void gtk_text_attributes_unref (GtkTextAttributes *values);
void gtk_text_attributes_ref (GtkTextAttributes *values);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
#include "gtktexttypes.h"
/*
* Tab array
*/
GtkTextTabArray*
gtk_text_view_tab_array_new(guint size)
{
GtkTextTabArray *array;
array = g_new0(GtkTextTabArray, 1);
array->refcount = 1;
array->numTabs = size;
array->tabs = g_new0(GtkTextTab, size);
return array;
}
void
gtk_text_view_tab_array_ref(GtkTextTabArray *tab_array)
{
g_return_if_fail(tab_array != NULL);
tab_array->refcount += 1;
}
void
gtk_text_view_tab_array_unref(GtkTextTabArray *tab_array)
{
g_return_if_fail(tab_array != NULL);
g_return_if_fail(tab_array->refcount > 0);
tab_array->refcount -= 1;
if (tab_array->refcount == 0)
{
g_free(tab_array->tabs);
g_free(tab_array);
}
}
/* These are used to represent embedded non-character objects
* if you return a string representation of a text buffer
*/
......@@ -59,4 +17,3 @@ gtk_text_byte_begins_utf8_char(const gchar *byte)
{
return inline_byte_begins_utf8_char(byte);
}
......@@ -15,83 +15,8 @@ typedef struct _GtkTextCounter GtkTextCounter;
typedef struct _GtkTextLineSegment GtkTextLineSegment;
typedef struct _GtkTextLineSegmentClass GtkTextLineSegmentClass;
typedef struct _GtkTextToggleBody GtkTextToggleBody;
typedef struct _GtkTextViewSearch GtkTextViewSearch;
typedef struct _GtkTextTab GtkTextTab;
typedef struct _GtkTextViewStyle GtkTextViewStyle;
typedef struct _GtkTextMarkBody GtkTextMarkBody;
/*
* Search
*/
/*
* The data structure below is used for searching a B-tree for transitions
* on a single tag (or for all tag transitions). No code outside of
* tkTextBTree.c should ever modify any of the fields in these structures,
* but it's OK to use them for read-only information.
*/
struct _GtkTextViewSearch {
GtkTextBTree *tree;
GtkTextIter curIndex; /* Position of last tag transition
* returned by gtk_text_btree_next_tag, or
* index of start of segment
* containing starting position for
* search if gtk_text_btree_next_tag hasn't
* been called yet, or same as
* stopIndex if search is over. */
GtkTextLineSegment *segPtr; /* Actual tag segment returned
by last call to
gtk_text_btree_next_tag,
or NULL if
gtk_text_btree_next_tag
hasn't returned anything
yet. */
GtkTextLineSegment *lastPtr; /* Stop search before just before
* considering this segment. */
GtkTextTag *tag; /* Tag to search for (or tag found, if
* allTags is non-zero). */
int linesLeft; /* Lines left to search (including
* curIndex and stopIndex). When
* this becomes <= 0 the search is
* over. */
int allTags; /* Non-zero means ignore tag check:
* search for transitions on all
* tags. */
};
/*
* The following data structure describes a single tab stop.
*/
typedef enum {
GTK_TEXT_TAB_LEFT,
GTK_TEXT_TAB_RIGHT,
GTK_TEXT_TAB_CENTER,
GTK_TEXT_TAB_NUMERIC
} GtkTextTabAlign;
struct _GtkTextTab {
int location; /* Offset in pixels of this tab stop
* from the left margin (lmargin2) of
* the text. */
GtkTextTabAlign alignment; /* Where the tab stop appears relative
* to the text. */
};
struct _GtkTextTabArray {
guint refcount;
int numTabs; /* Number of tab stops. */
GtkTextTab *tabs;
};
GtkTextTabArray *gtk_text_view_tab_array_new (guint size);
void gtk_text_view_tab_array_ref (GtkTextTabArray *tab_array);
void gtk_text_view_tab_array_unref (GtkTextTabArray *tab_array);
/*
* Declarations for variables shared among the text-related files:
*/
......
......@@ -62,6 +62,15 @@
#include "gtktexttypes.h"
#include <string.h>
#define FOCUS_RECT_WIDTH 10
#if 0
#define SCREEN_WIDTH(widget) (MAX (GTK_WIDGET(widget)->allocation.width - FOCUS_RECT_WIDTH*2, 0))
#define SCREEN_HEIGHT(widget) (MAX (GTK_WIDGET(widget)->allocation.height - FOCUS_RECT_WIDTH*2, 0))
#else
#define SCREEN_WIDTH(widget) GTK_WIDGET(widget)->allocation.width
#define SCREEN_HEIGHT(widget) GTK_WIDGET(widget)->allocation.height
#endif
enum {
MOVE,
SET_ANCHOR,
......@@ -127,6 +136,7 @@ static void gtk_text_view_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_text_view_expose_event (GtkWidget *widget,
GdkEventExpose *expose);
static void gtk_text_view_draw_focus (GtkWidget *widget);
/* Source side drag signals */
......@@ -189,7 +199,7 @@ static void gtk_text_view_validate_onscreen (GtkTextView *text_vi
static void gtk_text_view_get_first_para_iter (GtkTextView *text_view,
GtkTextIter *iter);
static void gtk_text_view_scroll_calc_now (GtkTextView *text_view);
static void gtk_text_view_set_values_from_style (GtkTextView *text_view,
static void gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
GtkTextAttributes *values,
GtkStyle *style);
static void gtk_text_view_ensure_layout (GtkTextView *text_view);
......@@ -571,6 +581,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->motion_notify_event = gtk_text_view_motion_event;
widget_class->expose_event = gtk_text_view_expose_event;
widget_class->draw = gtk_text_view_draw;
widget_class->draw_focus = gtk_text_view_draw_focus;
widget_class->drag_begin = gtk_text_view_drag_begin;
widget_class->drag_end = gtk_text_view_drag_end;
......@@ -783,8 +794,8 @@ gtk_text_view_scroll_to_mark_adjusted (GtkTextView *text_view,
screen.x = current_x_scroll;
screen.y = current_y_scroll;
screen.width = widget->allocation.width;
screen.height = widget->allocation.height;
screen.width = SCREEN_WIDTH (widget);
screen.height = SCREEN_HEIGHT (widget);
{
/* Clamp margin so it's not too large. */
......@@ -921,8 +932,8 @@ gtk_text_view_get_visible_rect (GtkTextView *text_view,
{
visible_rect->x = text_view->xoffset;
visible_rect->y = text_view->yoffset;
visible_rect->width = widget->allocation.width;
visible_rect->height = widget->allocation.height;
visible_rect->width = SCREEN_WIDTH (widget);
visible_rect->height = SCREEN_HEIGHT (widget);
}
}
......@@ -1174,13 +1185,13 @@ gtk_text_view_size_allocate (GtkWidget *widget,
gtk_text_view_ensure_layout (text_view);
gtk_text_layout_set_screen_width (text_view->layout,
GTK_WIDGET (text_view)->allocation.width);
SCREEN_WIDTH (text_view));
gtk_text_view_validate_onscreen (text_view);
gtk_text_view_scroll_calc_now (text_view);
/* Now adjust the value of the adjustment to keep the cursor at the same place in
* the buffer
/* Now adjust the value of the adjustment to keep the cursor at the
* same place in the buffer
*/
gtk_text_view_get_first_para_iter (text_view, &first_para);
gtk_text_layout_get_line_yrange (text_view->layout, &first_para, &y, NULL);
......@@ -1201,16 +1212,18 @@ gtk_text_view_size_allocate (GtkWidget *widget,
yoffset_changed = TRUE;
}
text_view->hadjustment->page_size = allocation->width;
text_view->hadjustment->page_increment = allocation->width / 2;
text_view->hadjustment->page_size = SCREEN_WIDTH (text_view);
text_view->hadjustment->page_increment = SCREEN_WIDTH (text_view) / 2;
text_view->hadjustment->lower = 0;
text_view->hadjustment->upper = MAX (allocation->width, text_view->width);
text_view->hadjustment->upper = MAX (SCREEN_WIDTH (text_view),
text_view->width);
gtk_signal_emit_by_name (GTK_OBJECT (text_view->hadjustment), "changed");
text_view->vadjustment->page_size = allocation<