git-svn-id: http://ltt.polymtl.ca/svn@462 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git] / ltt / branches / poly / lttv / modules / gui / controlflow / drawing.c
CommitLineData
ce0214a6 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
fa2c4dbe 18
76a67e8a 19#include <gtk/gtk.h>
20#include <gdk/gdk.h>
f0d936c0 21
831a876d 22#include <lttv/processTrace.h>
cef97e7c 23#include <lttv/gtktraceset.h>
f66eba62 24#include <lttv/hook.h>
831a876d 25
d66666fe 26#include "drawing.h"
27#include "cfv.h"
28#include "cfv-private.h"
29#include "eventhooks.h"
6d5ed1c3 30
31#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
32#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
33
f0d936c0 34/*****************************************************************************
501d5405 35 * drawing functions *
f0d936c0 36 *****************************************************************************/
37
831a876d 38//FIXME Colors will need to be dynamic. Graphic context part not done so far.
f0d936c0 39typedef enum
40{
a56a1ba4 41 RED,
42 GREEN,
43 BLUE,
44 WHITE,
45 BLACK
f0d936c0 46
47} ControlFlowColors;
48
49/* Vector of unallocated colors */
50static GdkColor CF_Colors [] =
51{
a56a1ba4 52 { 0, 0xffff, 0x0000, 0x0000 }, // RED
53 { 0, 0x0000, 0xffff, 0x0000 }, // GREEN
54 { 0, 0x0000, 0x0000, 0xffff }, // BLUE
55 { 0, 0xffff, 0xffff, 0xffff }, // WHITE
56 { 0, 0x0000, 0x0000, 0x0000 } // BLACK
f0d936c0 57};
58
59
831a876d 60/* Function responsible for updating the exposed area.
61 * It must call processTrace() to ask for this update.
432a7065 62 * Note : this function cannot clear the background, because it may
63 * erase drawing already present (SAFETY).
831a876d 64 */
501d5405 65void drawing_data_request(Drawing_t *drawing,
b6db18f8 66 GdkPixmap **pixmap,
a56a1ba4 67 gint x, gint y,
68 gint width,
69 gint height)
847b479d 70{
d9b7ca88 71 if(width < 0) return ;
72 if(height < 0) return ;
a56a1ba4 73 ControlFlowData *control_flow_data =
74 (ControlFlowData*)g_object_get_data(
75 G_OBJECT(
501d5405 76 drawing->drawing_area),
68997a22 77 "control_flow_data");
a56a1ba4 78
79 LttTime start, end;
ba90bc77 80 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
81 control_flow_data->time_window.start_time);
a56a1ba4 82
83 g_critical("req : window_end : %u, %u", window_end.tv_sec,
84 window_end.tv_nsec);
85
ba90bc77 86 g_critical("req : time width : %u, %u", control_flow_data->time_window.time_width.tv_sec,
87 control_flow_data->time_window.time_width.tv_nsec);
a56a1ba4 88
89 g_critical("x is : %i, x+width is : %i", x, x+width);
90
501d5405 91 convert_pixels_to_time(drawing->drawing_area->allocation.width, x,
ba90bc77 92 &control_flow_data->time_window.start_time,
a56a1ba4 93 &window_end,
94 &start);
95
501d5405 96 convert_pixels_to_time(drawing->drawing_area->allocation.width, x + width,
ba90bc77 97 &control_flow_data->time_window.start_time,
a56a1ba4 98 &window_end,
99 &end);
100
101 LttvTracesetContext * tsc =
ba90bc77 102 get_traceset_context(control_flow_data->mw);
a56a1ba4 103
432a7065 104 //send_test_process(
501d5405 105 //guicontrolflow_get_process_list(drawing->control_flow_data),
106 //drawing);
f66eba62 107 //send_test_drawing(
501d5405 108 //guicontrolflow_get_process_list(drawing->control_flow_data),
109 //drawing, *pixmap, x, y, width, height);
a56a1ba4 110
111 // Let's call processTrace() !!
112 EventRequest event_request; // Variable freed at the end of the function.
68997a22 113 event_request.control_flow_data = control_flow_data;
a56a1ba4 114 event_request.time_begin = start;
115 event_request.time_end = end;
116 event_request.x_begin = x;
117 event_request.x_end = x+width;
118
119 g_critical("req : start : %u, %u", event_request.time_begin.tv_sec,
120 event_request.time_begin.tv_nsec);
121
122 g_critical("req : end : %u, %u", event_request.time_end.tv_sec,
123 event_request.time_end.tv_nsec);
124
125 LttvHooks *event = lttv_hooks_new();
126 LttvHooks *after_event = lttv_hooks_new();
127 LttvHooks *after_traceset = lttv_hooks_new();
128 lttv_hooks_add(after_traceset, after_data_request, &event_request);
129 lttv_hooks_add(event, draw_event_hook, &event_request);
130 //Modified by xiangxiu: state update hooks are added by the main window
ba90bc77 131 //state_add_event_hooks_api(control_flow_data->mw);
a56a1ba4 132 lttv_hooks_add(after_event, draw_after_hook, &event_request);
133
134 lttv_process_traceset_seek_time(tsc, start);
135 // FIXME : would like to place the after_traceset hook after the traceset,
136 // but the traceset context state is not valid anymore.
137 lttv_traceset_context_add_hooks(tsc,
138 // NULL, after_traceset, NULL, NULL, NULL, NULL,
139 NULL, NULL, NULL, NULL, NULL, NULL,
140 NULL, after_traceset, NULL, event, after_event);
141 lttv_process_traceset(tsc, end, G_MAXULONG);
142 //after_data_request((void*)&event_request,(void*)tsc);
143 lttv_traceset_context_remove_hooks(tsc,
144 //NULL, after_traceset, NULL, NULL, NULL, NULL,
145 NULL, NULL, NULL, NULL, NULL, NULL,
146 NULL, after_traceset, NULL, event, after_event);
147 //Modified by xiangxiu: state update hooks are removed by the main window
ba90bc77 148 //state_remove_event_hooks_api(control_flow_data->mw);
a56a1ba4 149
150 lttv_hooks_destroy(after_traceset);
151 lttv_hooks_destroy(event);
152 lttv_hooks_destroy(after_event);
153
154
847b479d 155}
a56a1ba4 156
847b479d 157/* Callbacks */
158
159
160/* Create a new backing pixmap of the appropriate size */
bd24a9af 161/* As the scaling will always change, it's of no use to copy old
162 * pixmap.
163 */
847b479d 164static gboolean
165configure_event( GtkWidget *widget, GdkEventConfigure *event,
a56a1ba4 166 gpointer user_data)
f0d936c0 167{
501d5405 168 Drawing_t *drawing = (Drawing_t*)user_data;
f0d936c0 169
86c520a7 170
a56a1ba4 171 /* First, get the new time interval of the main window */
172 /* we assume (see documentation) that the main window
173 * has updated the time interval before this configure gets
174 * executed.
175 */
501d5405 176 get_time_window(drawing->control_flow_data->mw,
177 &drawing->control_flow_data->time_window);
a56a1ba4 178
b6db18f8 179 /* New pixmap, size of the configure event */
180 //GdkPixmap *pixmap = gdk_pixmap_new(widget->window,
a56a1ba4 181 // widget->allocation.width + SAFETY,
182 // widget->allocation.height + SAFETY,
183 // -1);
184
f7afe191 185 g_critical("drawing configure event");
a56a1ba4 186 g_critical("New draw size : %i by %i",widget->allocation.width, widget->allocation.height);
187
188
501d5405 189 if (drawing->pixmap)
190 gdk_pixmap_unref(drawing->pixmap);
a56a1ba4 191
b6db18f8 192 /* If no old pixmap present */
501d5405 193 //if(drawing->pixmap == NULL)
847b479d 194 {
501d5405 195 drawing->pixmap = gdk_pixmap_new(
a56a1ba4 196 widget->window,
197 widget->allocation.width + SAFETY,
198 widget->allocation.height + SAFETY,
199 //ProcessList_get_height
501d5405 200 // (GuiControlFlow_get_process_list(drawing->control_flow_data)),
a56a1ba4 201 -1);
501d5405 202 drawing->width = widget->allocation.width;
203 drawing->height = widget->allocation.height;
a56a1ba4 204
205
206 // Clear the image
501d5405 207 gdk_draw_rectangle (drawing->pixmap,
cfe526b1 208 widget->style->black_gc,
a56a1ba4 209 TRUE,
210 0, 0,
211 widget->allocation.width+SAFETY,
212 widget->allocation.height+SAFETY);
213
214 //g_info("init data request");
215
216
217 /* Initial data request */
218 // Do not need to ask for data of 1 pixel : not synchronized with
219 // main window time at this moment.
501d5405 220 drawing_data_request(drawing, &drawing->pixmap, 0, 0,
a56a1ba4 221 widget->allocation.width,
222 widget->allocation.height);
223
501d5405 224 drawing->width = widget->allocation.width;
225 drawing->height = widget->allocation.height;
a56a1ba4 226
227 return TRUE;
bd24a9af 228
229
847b479d 230
231 }
bd24a9af 232#ifdef NOTUSE
847b479d 233// /* Draw empty background */
b6db18f8 234// gdk_draw_rectangle (pixmap,
a56a1ba4 235// widget->style->black_gc,
236// TRUE,
237// 0, 0,
238// widget->allocation.width,
239// widget->allocation.height);
240
241 /* Copy old data to new pixmap */
b6db18f8 242 gdk_draw_drawable (pixmap,
cfe526b1 243 widget->style->black_gc,
501d5405 244 drawing->pixmap,
a56a1ba4 245 0, 0,
246 0, 0,
247 -1, -1);
248
501d5405 249 if (drawing->pixmap)
250 gdk_pixmap_unref(drawing->pixmap);
80a52ff8 251
501d5405 252 drawing->pixmap = pixmap;
a56a1ba4 253
254 // Clear the bottom part of the image (SAFETY)
b6db18f8 255 gdk_draw_rectangle (pixmap,
cfe526b1 256 widget->style->black_gc,
a56a1ba4 257 TRUE,
501d5405 258 0, drawing->height+SAFETY,
259 drawing->width+SAFETY, // do not overlap
260 (widget->allocation.height) - drawing->height);
bd24a9af 261
a56a1ba4 262 // Clear the right part of the image (SAFETY)
b6db18f8 263 gdk_draw_rectangle (pixmap,
cfe526b1 264 widget->style->black_gc,
a56a1ba4 265 TRUE,
501d5405 266 drawing->width+SAFETY, 0,
267 (widget->allocation.width) - drawing->width, // do not overlap
268 drawing->height+SAFETY);
a56a1ba4 269
270 /* Clear the backgound for data request, but not SAFETY */
b6db18f8 271 gdk_draw_rectangle (pixmap,
cfe526b1 272 drawing->drawing_area->style->black_gc,
a56a1ba4 273 TRUE,
501d5405 274 drawing->width + SAFETY, 0,
275 widget->allocation.width - drawing->width, // do not overlap
a56a1ba4 276 widget->allocation.height+SAFETY);
bd24a9af 277
432a7065 278 /* Request data for missing space */
a56a1ba4 279 g_info("missing data request");
501d5405 280 drawing_data_request(drawing, &pixmap, drawing->width, 0,
281 widget->allocation.width - drawing->width,
a56a1ba4 282 widget->allocation.height);
283
501d5405 284 drawing->width = widget->allocation.width;
285 drawing->height = widget->allocation.height;
847b479d 286
287 return TRUE;
bd24a9af 288#endif //NOTUSE
847b479d 289}
290
291
292/* Redraw the screen from the backing pixmap */
293static gboolean
294expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
295{
501d5405 296 Drawing_t *drawing = (Drawing_t*)user_data;
a56a1ba4 297 ControlFlowData *control_flow_data =
298 (ControlFlowData*)g_object_get_data(
299 G_OBJECT(widget),
68997a22 300 "control_flow_data");
8b90e648 301
847b479d 302 g_critical("drawing expose event");
a56a1ba4 303
304 guint x=0;
ba90bc77 305 LttTime* current_time =
a56a1ba4 306 guicontrolflow_get_current_time(control_flow_data);
307
ba90bc77 308 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
309 control_flow_data->time_window.start_time);
a56a1ba4 310
311 convert_time_to_pixels(
ba90bc77 312 control_flow_data->time_window.start_time,
a56a1ba4 313 window_end,
ba90bc77 314 *current_time,
a56a1ba4 315 widget->allocation.width,
316 &x);
317
847b479d 318 gdk_draw_pixmap(widget->window,
a56a1ba4 319 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
501d5405 320 drawing->pixmap,
a56a1ba4 321 event->area.x, event->area.y,
322 event->area.x, event->area.y,
323 event->area.width, event->area.height);
324
325 if(x >= event->area.x && x <= event->area.x+event->area.width)
326 {
853dbdb8 327 gint8 dash_list[] = { 1, 2 };
501d5405 328 GdkGC *gc = gdk_gc_new(control_flow_data->drawing->pixmap);
0e492a24 329 gdk_gc_copy(gc, widget->style->white_gc);
330 gdk_gc_set_line_attributes(gc,
331 1,
332 GDK_LINE_ON_OFF_DASH,
333 GDK_CAP_BUTT,
334 GDK_JOIN_MITER);
853dbdb8 335 gdk_gc_set_dashes(gc,
336 0,
337 dash_list,
338 2);
a56a1ba4 339 drawing_draw_line(NULL, widget->window,
340 x, event->area.y,
341 x, event->area.y+event->area.height,
342 gc);
343 gdk_gc_unref(gc);
344 }
847b479d 345 return FALSE;
346}
347
8b90e648 348/* mouse click */
349static gboolean
350button_press_event( GtkWidget *widget, GdkEventButton *event, gpointer user_data )
351{
a56a1ba4 352 ControlFlowData *control_flow_data =
353 (ControlFlowData*)g_object_get_data(
354 G_OBJECT(widget),
68997a22 355 "control_flow_data");
501d5405 356 Drawing_t *drawing = control_flow_data->drawing;
8b90e648 357
358
a56a1ba4 359 g_critical("click");
360 if(event->button == 1)
361 {
362 LttTime time;
8b90e648 363
ba90bc77 364 LttTime window_end = ltt_time_add(control_flow_data->time_window.time_width,
365 control_flow_data->time_window.start_time);
8b90e648 366
367
a56a1ba4 368 /* left mouse button click */
369 g_critical("x click is : %f", event->x);
8b90e648 370
a56a1ba4 371 convert_pixels_to_time(widget->allocation.width, (guint)event->x,
ba90bc77 372 &control_flow_data->time_window.start_time,
a56a1ba4 373 &window_end,
374 &time);
8b90e648 375
ba90bc77 376 set_current_time(control_flow_data->mw, &time);
8b90e648 377
a56a1ba4 378 }
379
380 return FALSE;
8b90e648 381}
382
383
384
385
68997a22 386Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
847b479d 387{
501d5405 388 Drawing_t *drawing = g_new(Drawing_t, 1);
a56a1ba4 389
501d5405 390 drawing->drawing_area = gtk_drawing_area_new ();
391 drawing->control_flow_data = control_flow_data;
a56a1ba4 392
501d5405 393 drawing->pango_layout =
394 gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
a56a1ba4 395
501d5405 396 //gtk_widget_set_size_request(drawing->drawing_area->window, 50, 50);
a56a1ba4 397 g_object_set_data_full(
501d5405 398 G_OBJECT(drawing->drawing_area),
399 "Link_drawing_Data",
400 drawing,
a56a1ba4 401 (GDestroyNotify)drawing_destroy);
402
501d5405 403 //gtk_widget_modify_bg( drawing->drawing_area,
a56a1ba4 404 // GTK_STATE_NORMAL,
405 // &CF_Colors[BLACK]);
406
501d5405 407 //gdk_window_get_geometry(drawing->drawing_area->window,
a56a1ba4 408 // NULL, NULL,
501d5405 409 // &(drawing->width),
410 // &(drawing->height),
a56a1ba4 411 // -1);
412
501d5405 413 //drawing->pixmap = gdk_pixmap_new(
414 // drawing->drawing_area->window,
415 // drawing->width,
416 // drawing->height,
417 // drawing->depth);
a56a1ba4 418
501d5405 419 drawing->pixmap = NULL;
a56a1ba4 420
501d5405 421// drawing->pixmap = gdk_pixmap_new(drawing->drawing_area->window,
422// drawing->drawing_area->allocation.width,
423// drawing->drawing_area->allocation.height,
a56a1ba4 424// -1);
425
501d5405 426 gtk_widget_add_events(drawing->drawing_area, GDK_BUTTON_PRESS_MASK);
a56a1ba4 427
501d5405 428 g_signal_connect (G_OBJECT(drawing->drawing_area),
a56a1ba4 429 "configure_event",
430 G_CALLBACK (configure_event),
501d5405 431 (gpointer)drawing);
a56a1ba4 432
501d5405 433 g_signal_connect (G_OBJECT(drawing->drawing_area),
a56a1ba4 434 "expose_event",
435 G_CALLBACK (expose_event),
501d5405 436 (gpointer)drawing);
a56a1ba4 437
501d5405 438 g_signal_connect (G_OBJECT(drawing->drawing_area),
a56a1ba4 439 "button-press-event",
440 G_CALLBACK (button_press_event),
501d5405 441 (gpointer)drawing);
a56a1ba4 442
443
501d5405 444 return drawing;
f0d936c0 445}
446
501d5405 447void drawing_destroy(Drawing_t *drawing)
f0d936c0 448{
449
a56a1ba4 450 // Do not unref here, Drawing_t destroyed by it's widget.
501d5405 451 //g_object_unref( G_OBJECT(drawing->drawing_area));
a56a1ba4 452
501d5405 453 g_free(drawing->pango_layout);
454 g_free(drawing);
f0d936c0 455}
456
501d5405 457GtkWidget *drawing_get_widget(Drawing_t *drawing)
76a67e8a 458{
501d5405 459 return drawing->drawing_area;
76a67e8a 460}
461
f66eba62 462/* convert_pixels_to_time
f0d936c0 463 *
f66eba62 464 * Convert from window pixel and time interval to an absolute time.
f0d936c0 465 */
fa2c4dbe 466void convert_pixels_to_time(
a56a1ba4 467 gint width,
468 guint x,
469 LttTime *window_time_begin,
470 LttTime *window_time_end,
471 LttTime *time)
f0d936c0 472{
a56a1ba4 473 LttTime window_time_interval;
474
475 window_time_interval = ltt_time_sub(*window_time_end,
308711e5 476 *window_time_begin);
a56a1ba4 477 *time = ltt_time_mul(window_time_interval, (x/(float)width));
478 *time = ltt_time_add(*window_time_begin, *time);
fa2c4dbe 479}
480
481
482
483void convert_time_to_pixels(
a56a1ba4 484 LttTime window_time_begin,
485 LttTime window_time_end,
486 LttTime time,
487 int width,
488 guint *x)
fa2c4dbe 489{
a56a1ba4 490 LttTime window_time_interval;
491 float interval_float, time_float;
492
493 window_time_interval = ltt_time_sub(window_time_end,window_time_begin);
494
495 time = ltt_time_sub(time, window_time_begin);
496
497 interval_float = ltt_time_to_double(window_time_interval);
498 time_float = ltt_time_to_double(time);
499
500 *x = (guint)(time_float/interval_float * width);
501
f0d936c0 502}
503
501d5405 504void drawing_refresh ( Drawing_t *drawing,
a56a1ba4 505 guint x, guint y,
506 guint width, guint height)
847b479d 507{
a56a1ba4 508 g_info("Drawing.c : drawing_refresh %u, %u, %u, %u", x, y, width, height);
509 GdkRectangle update_rect;
510
511 gdk_draw_drawable(
501d5405 512 drawing->drawing_area->window,
513 drawing->drawing_area->
514 style->fg_gc[GTK_WIDGET_STATE (drawing->drawing_area)],
515 GDK_DRAWABLE(drawing->pixmap),
a56a1ba4 516 x, y,
517 x, y,
518 width, height);
519
520 update_rect.x = 0 ;
521 update_rect.y = 0 ;
501d5405 522 update_rect.width = drawing->width;
523 update_rect.height = drawing->height ;
524 gtk_widget_draw( drawing->drawing_area, &update_rect);
f7afe191 525
847b479d 526}
527
528
501d5405 529void drawing_draw_line( Drawing_t *drawing,
b6db18f8 530 GdkPixmap *pixmap,
a56a1ba4 531 guint x1, guint y1,
532 guint x2, guint y2,
533 GdkGC *GC)
847b479d 534{
b6db18f8 535 gdk_draw_line (pixmap,
a56a1ba4 536 GC,
537 x1, y1, x2, y2);
847b479d 538}
539
540
fa2c4dbe 541
542
501d5405 543void drawing_resize(Drawing_t *drawing, guint h, guint w)
f0d936c0 544{
501d5405 545 drawing->height = h ;
546 drawing->width = w ;
a56a1ba4 547
501d5405 548 gtk_widget_set_size_request ( drawing->drawing_area,
549 drawing->width,
550 drawing->height);
a56a1ba4 551
552
f0d936c0 553}
847b479d 554
555
5f16133f 556/* Insert a square corresponding to a new process in the list */
501d5405 557/* Applies to whole drawing->width */
558void drawing_insert_square(Drawing_t *drawing,
a56a1ba4 559 guint y,
560 guint height)
5f16133f 561{
a56a1ba4 562 //GdkRectangle update_rect;
5f16133f 563
a56a1ba4 564 /* Allocate a new pixmap with new height */
501d5405 565 GdkPixmap *pixmap = gdk_pixmap_new(drawing->drawing_area->window,
566 drawing->width + SAFETY,
567 drawing->height + height + SAFETY,
a56a1ba4 568 -1);
569
570 /* Copy the high region */
b6db18f8 571 gdk_draw_drawable (pixmap,
501d5405 572 drawing->drawing_area->style->black_gc,
573 drawing->pixmap,
a56a1ba4 574 0, 0,
575 0, 0,
501d5405 576 drawing->width + SAFETY, y);
5f16133f 577
578
579
5f16133f 580
a56a1ba4 581 /* add an empty square */
b6db18f8 582 gdk_draw_rectangle (pixmap,
cfe526b1 583 drawing->drawing_area->style->black_gc,
a56a1ba4 584 TRUE,
585 0, y,
501d5405 586 drawing->width + SAFETY, // do not overlap
a56a1ba4 587 height);
5f16133f 588
589
5f16133f 590
a56a1ba4 591 /* copy the bottom of the region */
b6db18f8 592 gdk_draw_drawable (pixmap,
501d5405 593 drawing->drawing_area->style->black_gc,
594 drawing->pixmap,
a56a1ba4 595 0, y,
596 0, y + height,
501d5405 597 drawing->width+SAFETY, drawing->height - y + SAFETY);
5f16133f 598
599
600
5f16133f 601
501d5405 602 if (drawing->pixmap)
603 gdk_pixmap_unref(drawing->pixmap);
5f16133f 604
501d5405 605 drawing->pixmap = pixmap;
a56a1ba4 606
501d5405 607 drawing->height+=height;
a56a1ba4 608
501d5405 609 /* Rectangle to update, from new drawing dimensions */
a56a1ba4 610 //update_rect.x = 0 ;
611 //update_rect.y = y ;
501d5405 612 //update_rect.width = drawing->width;
613 //update_rect.height = drawing->height - y ;
614 //gtk_widget_draw( drawing->drawing_area, &update_rect);
5f16133f 615}
616
617
618/* Remove a square corresponding to a removed process in the list */
501d5405 619void drawing_remove_square(Drawing_t *drawing,
a56a1ba4 620 guint y,
621 guint height)
5f16133f 622{
a56a1ba4 623 //GdkRectangle update_rect;
624
625 /* Allocate a new pixmap with new height */
b6db18f8 626 GdkPixmap *pixmap = gdk_pixmap_new(
501d5405 627 drawing->drawing_area->window,
628 drawing->width + SAFETY,
629 drawing->height - height + SAFETY,
a56a1ba4 630 -1);
631
632 /* Copy the high region */
b6db18f8 633 gdk_draw_drawable (pixmap,
501d5405 634 drawing->drawing_area->style->black_gc,
635 drawing->pixmap,
a56a1ba4 636 0, 0,
637 0, 0,
501d5405 638 drawing->width + SAFETY, y);
a56a1ba4 639
640
641
642 /* Copy up the bottom of the region */
b6db18f8 643 gdk_draw_drawable (pixmap,
501d5405 644 drawing->drawing_area->style->black_gc,
645 drawing->pixmap,
a56a1ba4 646 0, y + height,
647 0, y,
501d5405 648 drawing->width, drawing->height - y - height + SAFETY);
a56a1ba4 649
650
501d5405 651 if (drawing->pixmap)
652 gdk_pixmap_unref(drawing->pixmap);
a56a1ba4 653
501d5405 654 drawing->pixmap = pixmap;
a56a1ba4 655
501d5405 656 drawing->height-=height;
a56a1ba4 657
501d5405 658 /* Rectangle to update, from new drawing dimensions */
a56a1ba4 659 //update_rect.x = 0 ;
660 //update_rect.y = y ;
501d5405 661 //update_rect.width = drawing->width;
662 //update_rect.height = drawing->height - y ;
663 //gtk_widget_draw( drawing->drawing_area, &update_rect);
5f16133f 664}
189a5d08 665
666
This page took 0.059016 seconds and 4 git commands to generate.