#include "xo-file.h"
#include "xo-paint.h"
#include "xo-shapes.h"
+#include "xo-image.h"
// some global constants
return pg;
}
+// change the current page if necessary for pointer at pt
+void set_current_page(gdouble *pt)
+{
+ gboolean page_change;
+ struct Page *tmppage;
+
+ page_change = FALSE;
+ tmppage = ui.cur_page;
+ while (ui.view_continuous && (pt[1] < - VIEW_CONTINUOUS_SKIP)) {
+ if (ui.pageno == 0) break;
+ page_change = TRUE;
+ ui.pageno--;
+ tmppage = g_list_nth_data(journal.pages, ui.pageno);
+ pt[1] += tmppage->height + VIEW_CONTINUOUS_SKIP;
+ }
+ while (ui.view_continuous && (pt[1] > tmppage->height + VIEW_CONTINUOUS_SKIP)) {
+ if (ui.pageno == journal.npages-1) break;
+ pt[1] -= tmppage->height + VIEW_CONTINUOUS_SKIP;
+ page_change = TRUE;
+ ui.pageno++;
+ tmppage = g_list_nth_data(journal.pages, ui.pageno);
+ }
+ if (page_change) do_switch_page(ui.pageno, FALSE, FALSE);
+}
+
void realloc_cur_path(int n)
{
if (n <= ui.cur_path_storage_alloc) return;
g_free(redo->item->font_name);
g_free(redo->item);
}
+ else if (redo->type == ITEM_IMAGE) {
+ g_object_unref(redo->item->image);
+ g_free(redo->item->image_png);
+ g_free(redo->item);
+ }
else if (redo->type == ITEM_ERASURE || redo->type == ITEM_RECOGNIZER) {
for (list = redo->erasurelist; list!=NULL; list=list->next) {
erasure = (struct UndoErasureData *)list->data;
}
if (erasure->item->type == ITEM_TEXT)
{ g_free(erasure->item->text); g_free(erasure->item->font_name); }
+ if (erasure->item->type == ITEM_IMAGE) {
+ g_object_unref(erasure->item->image);
+ g_free(erasure->item->image_png);
+ }
g_free(erasure->item);
g_list_free(erasure->replacement_items);
g_free(erasure);
if (item->type == ITEM_TEXT) {
g_free(item->font_name); g_free(item->text);
}
+ if (item->type == ITEM_IMAGE) {
+ g_object_unref(item->image);
+ g_free(item->image_png);
+ }
// don't need to delete the canvas_item, as it's part of the group destroyed below
g_free(item);
l->items = g_list_delete_link(l->items, l->items);
ret[1] -= ui.cur_page->voffset;
}
+void get_current_pointer_coords(gdouble *ret)
+{
+ gint wx, wy, sx, sy;
+
+ gtk_widget_get_pointer((GtkWidget *)canvas, &wx, &wy);
+ gnome_canvas_get_scroll_offsets(canvas, &sx, &sy);
+ gnome_canvas_window_to_world(canvas, (double)(wx + sx), (double)(wy + sy), ret, ret+1);
+ ret[0] -= ui.cur_page->hoffset;
+ ret[1] -= ui.cur_page->voffset;
+}
+
void fix_xinput_coords(GdkEvent *event)
{
double *axes, *px, *py, axis_width;
"text", item->text, NULL);
update_item_bbox(item);
}
+ if (item->type == ITEM_IMAGE) {
+ item->canvas_item = gnome_canvas_item_new(group,
+ gnome_canvas_pixbuf_get_type(),
+ "pixbuf", item->image,
+ "x", item->bbox.left, "y", item->bbox.top,
+ "width", item->bbox.right - item->bbox.left,
+ "height", item->bbox.bottom - item->bbox.top,
+ "width-set", TRUE, "height-set", TRUE,
+ NULL);
+ }
}
void make_canvas_items(void)
gtk_toggle_tool_button_set_active(
GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonText")), TRUE);
break;
+ case TOOL_IMAGE:
+ gtk_toggle_tool_button_set_active(
+ GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonImage")), TRUE);
+ break;
case TOOL_SELECTREGION:
gtk_toggle_tool_button_set_active(
GTK_TOGGLE_TOOL_BUTTON(GET_COMPONENT("buttonSelectRegion")), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsText")), TRUE);
break;
+ case TOOL_IMAGE:
+ gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsImage")), TRUE);
+ break;
case TOOL_SELECTREGION:
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("toolsSelectRegion")), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("button2Text")), TRUE);
break;
+ case TOOL_IMAGE:
+ gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(GET_COMPONENT("button2Image")), TRUE);
+ break;
case TOOL_SELECTREGION:
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("button2SelectRegion")), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("button3Text")), TRUE);
break;
+ case TOOL_IMAGE:
+ gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(GET_COMPONENT("button3Image")), TRUE);
+ break;
case TOOL_SELECTREGION:
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("button3SelectRegion")), TRUE);
if (item->type == ITEM_STROKE)
for (pt=item->path->coords, i=0; i<item->path->num_points; i++, pt+=2)
{ pt[0] += dx; pt[1] += dy; }
- if (item->type == ITEM_STROKE || item->type == ITEM_TEXT || item->type == ITEM_TEMP_TEXT) {
+ if (item->type == ITEM_STROKE || item->type == ITEM_TEXT ||
+ item->type == ITEM_TEMP_TEXT || item->type == ITEM_IMAGE) {
item->bbox.left += dx;
item->bbox.right += dx;
item->bbox.top += dy;
item->bbox.left = item->bbox.left*scaling_x + offset_x;
item->bbox.top = item->bbox.top*scaling_y + offset_y;
}
+ if (item->type == ITEM_IMAGE) {
+ item->bbox.left = item->bbox.left*scaling_x + offset_x;
+ item->bbox.right = item->bbox.right*scaling_x + offset_x;
+ item->bbox.top = item->bbox.top*scaling_y + offset_y;
+ item->bbox.bottom = item->bbox.bottom*scaling_y + offset_y;
+ if (item->bbox.left > item->bbox.right) {
+ temp = item->bbox.left;
+ item->bbox.left = item->bbox.right;
+ item->bbox.right = temp;
+ }
+ if (item->bbox.top > item->bbox.bottom) {
+ temp = item->bbox.top;
+ item->bbox.top = item->bbox.bottom;
+ item->bbox.bottom = temp;
+ }
+ }
// redraw the item
if (item->canvas_item!=NULL) {
group = (GnomeCanvasGroup *) item->canvas_item->parent;