freebsd-ports/japanese/gnumeric/files/patch-ac
2002-03-03 11:48:26 +00:00

66 lines
1.8 KiB
Plaintext

--- src/item-edit.c.orig Thu Dec 27 07:10:52 2001
+++ src/item-edit.c Fri Mar 1 21:58:00 2002
@@ -42,6 +42,41 @@
ARG_SHEET_CONTROL_GUI, /* The SheetControlGUI * argument */
};
+/* Update XIM position */
+static void
+item_edit_update_im_position(ItemEdit* item_edit, int x, int y)
+{
+ /* Need widget pointer that has GdkIC */
+ GnumericCanvas* gcanvas =
+ GNUMERIC_CANVAS(GNOME_CANVAS_ITEM(item_edit)->canvas);
+ int cx, cy;
+
+ if (GTK_WIDGET_HAS_FOCUS(gcanvas) && gdk_im_ready() &&
+ gcanvas->ic && (gdk_ic_get_style (gcanvas->ic)
+ & GDK_IM_PREEDIT_POSITION)){
+
+ int width, height;
+
+ /* position should be inside the widget */
+ if ( x <= 0 || y <=0 )
+ return;
+
+ gnome_canvas_get_scroll_offsets(GNOME_CANVAS(gcanvas), &cx, &cy);
+
+ gcanvas->ic_attr->spot_location.x =
+ (int)GNOME_CANVAS_ITEM(item_edit)->x1 + x - cx;
+ gcanvas->ic_attr->spot_location.y =
+ (int)GNOME_CANVAS_ITEM(item_edit)->y1 + y - 2 - cy;
+
+ gdk_window_get_size (GTK_WIDGET(gcanvas)->window, &width, &height);
+ gcanvas->ic_attr->preedit_area.width = width;
+ gcanvas->ic_attr->preedit_area.height = height;
+
+ gdk_ic_set_attr (gcanvas->ic, gcanvas->ic_attr,
+ GDK_IC_SPOT_LOCATION | GDK_IC_PREEDIT_AREA);
+ }
+}
+
static void
scan_at (const char *text, int *scan)
{
@@ -169,6 +204,8 @@
gdk_draw_line (drawable, style->black_gc,
x, y-font->ascent,
x, y+font->descent);
+
+ item_edit_update_im_position(item_edit, x, y+font->descent);
}
static void
@@ -239,6 +276,11 @@
if (item_edit->font == NULL)
return;
top_pos += item_edit->font->ascent;
+
+ /* Handle multibyte */
+ if( cursor_pos != -1 )
+ cursor_pos = strlen(gtk_editable_get_chars(GTK_EDITABLE(item_edit->entry),
+ 0, cursor_pos));
/* Draw the background (recall that gdk_draw_rectangle excludes far coords) */
gdk_draw_rectangle (