6
6
* Copyright (C) 1998-2005 Maurits Rijk m.rijk@chello.nl
8
* This program is free software; you can redistribute it and/or modify
8
* This program is free software: you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
10
* the Free Software Foundation; either version 3 of the License, or
11
11
* (at your option) any later version.
13
13
* This program is distributed in the hope that it will be useful,
16
16
* GNU General Public License for more details.
18
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
70
69
object_list_add_changed_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
73
72
return object_list_callback_add(&list->changed_cb, func, data);
77
76
object_list_add_update_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
80
79
return object_list_callback_add(&list->update_cb, func, data);
84
83
object_list_add_add_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
87
86
return object_list_callback_add(&list->add_cb, func, data);
91
90
object_list_add_remove_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
94
93
return object_list_callback_add(&list->remove_cb, func, data);
98
97
object_list_add_select_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
101
100
return object_list_callback_add(&list->select_cb, func, data);
105
104
object_list_add_move_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
108
107
return object_list_callback_add(&list->move_cb, func, data);
112
111
object_list_add_geometry_cb(ObjectList_t *list, ObjectListCallbackFunc_t func,
115
114
return object_list_callback_add(&list->geometry_cb, func, data);
252
object_draw(Object_t *obj, GdkWindow *window)
251
object_draw(Object_t *obj, cairo_t *cr)
254
253
PreferencesData_t *preferences = get_preferences();
255
GdkGC *gc = (obj->selected) ? preferences->selected_gc
256
: preferences->normal_gc;
257
obj->class->draw(obj, window, gc);
254
ColorSelData_t *colors = &preferences->colors;
258
if (obj->selected & 4) {
259
fg = &colors->interactive_fg;
260
bg = &colors->interactive_bg;
262
} else if (obj->selected) {
263
fg = &colors->selected_fg;
264
bg = &colors->selected_bg;
266
fg = &colors->normal_fg;
267
bg = &colors->normal_bg;
271
gdk_cairo_set_source_color (cr, bg);
272
obj->class->draw(obj, cr);
273
gdk_cairo_set_source_color (cr, fg);
274
cairo_set_dash (cr, &dash, 1, 0.);
275
obj->class->draw(obj, cr);
258
277
if (obj->selected && preferences->show_area_handle)
259
obj->class->draw_sashes(obj, window, gc);
278
obj->class->draw_sashes(obj, cr);
409
429
default_dialog_hide_cancel_button(dialog);
410
430
default_dialog_hide_apply_button(dialog);
411
431
default_dialog_set_label(
413
"\n You cannot delete the selected object \n"
414
"since it is currently being edited.\n");
433
"\n You cannot delete the selected object \n"
434
"since it is currently being edited.\n");
416
436
default_dialog_show(dialog);
426
446
button_motion(GtkWidget *widget, GdkEventMotion *event,
427
ObjectFactory_t *factory)
447
ObjectFactory_t *factory)
429
449
gint x = get_real_coord((gint) event->x);
430
450
gint y = get_real_coord((gint) event->y);
432
452
round_to_grid(&x, &y);
434
object_draw(factory->obj, widget->window);
435
454
factory->set_xy(factory->obj, event->state, x, y);
436
object_draw(factory->obj, widget->window);
455
475
if (event->button == 1) {
456
if (!factory->finish || factory->finish(obj, x, y)) {
457
g_signal_handlers_disconnect_by_func(widget,
476
if (!factory->finish || factory->finish(obj, x, y)) {
477
g_signal_handlers_disconnect_by_func(widget,
460
if (object_is_valid(obj)) {
461
Command_t *command = create_command_new(get_shapes(), obj);
462
command_execute(command);
463
if (preferences->prompt_for_area_info)
464
object_edit(obj, FALSE);
466
object_draw(obj, widget->window);
469
gdk_gc_set_function(preferences->normal_gc, GDK_COPY);
471
main_clear_dimension();
480
if (object_is_valid(obj)) {
481
Command_t *command = create_command_new(get_shapes(), obj);
482
command_execute(command);
483
if (preferences->prompt_for_area_info)
484
object_edit(obj, FALSE);
488
preview_unset_tmp_obj (obj);
491
main_clear_dimension();
473
493
} else if (event->button == 3) {
474
object_draw(obj, widget->window);
475
if (!factory->cancel || factory->cancel(event, obj)) {
476
g_signal_handlers_disconnect_by_func(widget,
494
if (!factory->cancel || factory->cancel(event, obj)) {
495
g_signal_handlers_disconnect_by_func(widget,
480
gdk_gc_set_function(preferences->normal_gc, GDK_COPY);
482
main_clear_dimension();
484
object_draw(obj, widget->window);
499
preview_unset_tmp_obj (obj);
502
main_clear_dimension();
488
507
if (event->button == 1) {
489
factory = ((ObjectFactory_t*(*)(guint)) data)(event->state);
490
obj = object_factory_create_object(factory, x, y);
492
gdk_gc_set_function(preferences->normal_gc, GDK_XOR);
494
g_signal_connect(widget, "motion-notify-event",
508
factory = ((ObjectFactory_t*(*)(guint)) data)(event->state);
509
obj = object_factory_create_object(factory, x, y);
510
preview_set_tmp_obj (obj);
512
g_signal_connect(widget, "motion-notify-event",
495
513
G_CALLBACK(button_motion), factory);
586
object_list_draw(ObjectList_t *list, GdkWindow *window)
604
object_list_draw(ObjectList_t *list, cairo_t *cr)
589
607
for (p = list->list; p; p = p->next)
590
object_draw((Object_t*) p->data, window);
608
object_draw((Object_t*) p->data, cr);
594
object_list_draw_selected(ObjectList_t *list, GdkWindow *window)
612
object_list_draw_selected(ObjectList_t *list, cairo_t *cr)
597
615
for (p = list->list; p; p = p->next) {
598
616
Object_t *obj = (Object_t*) p->data;
599
617
if (obj->selected)
600
object_draw(obj, window);
618
object_draw(obj, cr);
609
627
for (p = list->list; p; p = p->next) {
610
628
Object_t *obj = (Object_t*) p->data;
611
629
if (obj->class->point_is_on(obj, x, y))
618
636
object_list_near_sash(ObjectList_t *list, gint x, gint y,
619
MoveSashFunc_t *sash_func)
637
MoveSashFunc_t *sash_func)
621
639
Object_t *found = NULL;
623
641
for (p = list->list; p; p = p->next) {
624
642
Object_t *obj = (Object_t*) p->data;
625
643
if (obj->selected) {
626
MoveSashFunc_t func = obj->class->near_sash(obj, x, y);
644
MoveSashFunc_t func = obj->class->near_sash(obj, x, y);
673
691
Object_t *obj = (Object_t*) p->data;
675
693
if (obj->selected) {
677
do_object_locked_dialog();
679
object_list_append(_paste_buffer, obj);
680
object_list_remove_link(list, p);
695
do_object_locked_dialog();
697
object_list_append(_paste_buffer, obj);
698
object_list_remove_link(list, p);
685
703
object_list_set_changed(list, (count) ? TRUE : FALSE);
758
776
for (p = list->list; p; p = p->next) {
759
777
Object_t *obj = (Object_t*) p->data;
760
778
if (obj->selected) {
761
object_unselect(obj);
762
p = (p->next) ? p->next : list->list;
763
object_select((Object_t*) p->data);
764
for (p = p->next; p; p = p->next) {
765
obj = (Object_t*) p->data;
767
object_unselect(obj);
779
object_unselect(obj);
780
p = (p->next) ? p->next : list->list;
781
object_select((Object_t*) p->data);
782
for (p = p->next; p; p = p->next) {
783
obj = (Object_t*) p->data;
785
object_unselect(obj);
777
795
for (p = list->list; p; p = p->next) {
778
796
Object_t *obj = (Object_t*) p->data;
779
797
if (obj->selected) {
780
GList *q = (p->prev) ? p->prev : g_list_last(list->list);
781
for (; p; p = p->next) {
782
obj = (Object_t*) p->data;
784
object_unselect(obj);
786
object_select((Object_t*) q->data);
798
GList *q = (p->prev) ? p->prev : g_list_last(list->list);
799
for (; p; p = p->next) {
800
obj = (Object_t*) p->data;
802
object_unselect(obj);
804
object_select((Object_t*) q->data);
793
811
object_list_select_region(ObjectList_t *list, gint x, gint y, gint width,
926
944
Object_t *obj = (Object_t*) p->data;
928
946
if (obj->selected) {
929
object_list_remove_link(list, p);
930
object_list_append(list, obj);
947
object_list_remove_link(list, p);
948
object_list_append(list, obj);
942
960
Object_t *obj = (Object_t*) p->data;
944
962
if (obj->selected) {
945
object_list_remove_link(list, p);
946
object_list_prepend(list, obj);
963
object_list_remove_link(list, p);
964
object_list_prepend(list, obj);
955
973
for (p = list->list; p; p = p->next) {
956
974
Object_t *obj = (Object_t*) p->data;
957
975
if (obj->selected)
958
object_move_sash(obj, dx, dy);
976
object_move_sash(obj, dx, dy);
963
981
write_xml_attrib(const gchar *attrib, const gchar *value,
964
const gchar *default_text, gpointer param,
982
const gchar *default_text, gpointer param,
968
986
gchar *escaped_value = g_markup_escape_text(value, -1);
1013
1031
Object_t *obj = (Object_t*) p->data;
1015
1033
if (*obj->comment)
1016
output(param, "# %s\n", obj->comment);
1034
output(param, "# %s\n", obj->comment);
1017
1035
obj->class->write_ncsa(obj, param, output);
1018
1036
output(param, "\n");