aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-text.c
diff options
context:
space:
mode:
authorChris Lahey <clahey@src.gnome.org>2000-01-14 06:01:23 +0800
committerChris Lahey <clahey@src.gnome.org>2000-01-14 06:01:23 +0800
commitf5347f59ff008ebc53f456cfcd4b8c58dead29c5 (patch)
tree1bfa9616fde11bbc40d7bf80557caf8f0429a84c /widgets/e-text.c
parent21c698ec023314751227247e4bef1d68a78a21ea (diff)
downloadgsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar.gz
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar.bz2
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar.lz
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar.xz
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.tar.zst
gsoc2013-evolution-f5347f59ff008ebc53f456cfcd4b8c58dead29c5.zip
e_canvas_item_move_absolute is just a helper function not supplied by the
* widgets/e-canvas-utils.c, widgets/e-canvas-utils.h: e_canvas_item_move_absolute is just a helper function not supplied by the gnome_canvas.[ch] I put it here so that multiple items can use it. * widgets/e-reflow.c, widgets/e-reflow.h: This item contains a number of other items and places them into multiple columns. The items contained must support a number of arguments and signals to allow the reflow to interact with them. * widgets/test-reflow.c: This is a test program for e-reflow. * widgets/e-text.c, widgets/e-text.h: Added properly drawn selected text. Added some preliminary code for X selection handling and cut & paste. * widgets/e-minicard.c, widgets/e-minicard.h: Added ARG_HAS_FOCUS handling. Made label display random for more interesting tests of multiple cards. Tweaked sizing information for better display. * widgets/e-minicard-label.c, widgets/e-minicard-label.h: Added ARG_HAS_FOCUS handling. * widgets/Makefile.am: Added the reflow test and reflow files. svn path=/trunk/; revision=1566
Diffstat (limited to 'widgets/e-text.c')
-rw-r--r--widgets/e-text.c113
1 files changed, 105 insertions, 8 deletions
diff --git a/widgets/e-text.c b/widgets/e-text.c
index 023ad2428d..99e35348b9 100644
--- a/widgets/e-text.c
+++ b/widgets/e-text.c
@@ -75,6 +75,12 @@ enum {
};
+enum {
+ TARGET_STRING,
+ TARGET_TEXT,
+ TARGET_COMPOUND_TEXT
+};
+
static void e_text_class_init (ETextClass *class);
static void e_text_init (EText *text);
static void e_text_destroy (GtkObject *object);
@@ -96,6 +102,8 @@ static gint e_text_event (GnomeCanvasItem *item, GdkEvent *event);
static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data);
+static guint32 e_text_get_event_time (EText *text);
+
static ETextSuckFont *e_suck_font (GdkFont *font);
static void e_suck_font_free (ETextSuckFont *suckfont);
@@ -1124,7 +1132,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
int x, int y, int width, int height)
{
EText *text;
- GdkRectangle rect;
+ GdkRectangle rect, *clip_rect;
struct line *lines;
int i;
int xpos, ypos;
@@ -1140,6 +1148,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
if (!text->text || !text->font)
return;
+ clip_rect = NULL;
if (text->clip) {
rect.x = text->clip_cx - x;
rect.y = text->clip_cy - y;
@@ -1148,6 +1157,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gdk_gc_set_clip_rectangle (text->gc, &rect);
gdk_gc_set_clip_rectangle (GTK_WIDGET(canvas)->style->fg_gc[GTK_STATE_SELECTED], &rect);
+ clip_rect = &rect;
}
lines = text->lines;
ypos = text->cy + text->font->ascent;
@@ -1182,13 +1192,17 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
lines->text + sel_start - start_char,
sel_end - sel_start);
sel_rect.height = text->font->ascent + text->font->descent;
- gdk_draw_rectangle (drawable,
- text->gc,
- TRUE,
- sel_rect.x,
- sel_rect.y,
- sel_rect.width,
- sel_rect.height);
+ gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style,
+ drawable,
+ GTK_STATE_SELECTED,
+ GTK_SHADOW_NONE,
+ clip_rect,
+ GTK_WIDGET(item->canvas),
+ "text",
+ sel_rect.x,
+ sel_rect.y,
+ sel_rect.width,
+ sel_rect.height);
gdk_draw_text (drawable,
text->font,
text->gc,
@@ -1897,6 +1911,89 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text));
}
+#if 0
+static void
+e_text_real_copy_clipboard (EText *text)
+{
+ guint32 time;
+ gint selection_start_pos;
+ gint selection_end_pos;
+
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (E_IS_TEXT (text));
+
+ time = gtk_text_get_event_time (text);
+ selection_start_pos = MIN (text->selection_start, text->selection_end);
+ selection_end_pos = MAX (text->selection_start, text->selection_end);
+
+ if (selection_start_pos != selection_end_pos)
+ {
+ if (gtk_selection_owner_set (GTK_WIDGET (text->canvas),
+ clipboard_atom,
+ time))
+ text->clipboard_text = "";
+ }
+}
+
+static void
+e_text_real_paste_clipboard (EText *text)
+{
+ guint32 time;
+
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (E_IS_TEXT (text));
+
+ time = e_text_get_event_time (text);
+ if (text->editable)
+ gtk_selection_convert (GTK_WIDGET(text->widget),
+ clipboard_atom,
+ gdk_atom_intern ("COMPOUND_TEXT", FALSE), time);
+}
+#endif
+
+/* Get the timestamp of the current event. Actually, the only thing
+ * we really care about below is the key event
+ */
+static guint32
+e_text_get_event_time (EText *text)
+{
+ GdkEvent *event;
+ guint32 tm = GDK_CURRENT_TIME;
+
+ event = gtk_get_current_event();
+
+ if (event)
+ switch (event->type)
+ {
+ case GDK_MOTION_NOTIFY:
+ tm = event->motion.time; break;
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ tm = event->button.time; break;
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ tm = event->key.time; break;
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ tm = event->crossing.time; break;
+ case GDK_PROPERTY_NOTIFY:
+ tm = event->property.time; break;
+ case GDK_SELECTION_CLEAR:
+ case GDK_SELECTION_REQUEST:
+ case GDK_SELECTION_NOTIFY:
+ tm = event->selection.time; break;
+ case GDK_PROXIMITY_IN:
+ case GDK_PROXIMITY_OUT:
+ tm = event->proximity.time; break;
+ default: /* use current time */
+ break;
+ }
+ gdk_event_free(event);
+
+ return tm;
+}