1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa Heidari
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;
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.
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., 51 Franklin Street, Fifth Floor, Boston,
29 #include "histobuttonwidget.h"
30 #include "histodrawing.h"
31 #include "histodrawitem.h"
33 extern void histogram_show(HistoControlFlowData
*histocontrol_flow_data
,
34 guint draw_begin
, guint draw_end
);
37 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
40 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
43 /* Preallocated Size of the index_to_pixmap array */
44 #define ALLOCATE_PROCESSES 1000
46 /*****************************************************************************
48 *****************************************************************************/
49 static gboolean
gplus( GtkWidget
*widget
,gpointer user_data
)
51 HistoControlFlowData
*histo_cfd
= (HistoControlFlowData
*)user_data
;
52 //histo_cfd->vertical_ratio =histo_cfd->vertical_ratio * (1.0/2.0);
53 if(histo_cfd
->max_height
>1)
55 histo_cfd
->max_height
/= 2;
56 //just redraw.horizontal scale is not changed so Array's data are valid.
57 histogram_show(histo_cfd
,0,histo_cfd
->number_of_process
->len
);
60 g_warning("Zoom more than 1 event is impossible");
62 histo_drawing_update_vertical_ruler(histo_cfd
->drawing
);//, TimeWindow *time_window);
66 static gboolean
gMinus( GtkWidget
*widget
,
69 HistoControlFlowData
*histo_cfd
= (HistoControlFlowData
*)user_data
;
70 histo_cfd
->max_height
*= 2;
72 //just redraw.horizontal scale is not changed so Array's data are valid.
73 histogram_show(histo_cfd
,0,histo_cfd
->number_of_process
->len
);
74 histo_drawing_update_vertical_ruler(histo_cfd
->drawing
);//, TimeWindow *time_window);
78 static gboolean
gFit( GtkWidget
*widget
,
81 /*find the maximum value and put max_height equal with this maximum*/
82 HistoControlFlowData
*histo_cfd
= (HistoControlFlowData
*)user_data
;
85 maximum
=g_array_index(histo_cfd
->number_of_process
,guint
,i
);
86 for (i
=1; i
< histo_cfd
->number_of_process
-> len
;i
++)
88 x
=g_array_index(histo_cfd
->number_of_process
,guint
,i
);
89 maximum
=MAX(x
,maximum
);
93 histo_cfd
->max_height
=maximum
;
94 histogram_show (histo_cfd
,0,histo_cfd
->number_of_process
->len
);
96 histo_drawing_update_vertical_ruler(histo_cfd
->drawing
);
101 static GtkWidget
* new_button_with_icon(const gchar
*icon_name
) {
103 GtkWidget
*button
= gtk_button_new();
105 gtk_button_set_image((GtkButton
*)button
,
106 gtk_image_new_from_icon_name(icon_name
,
107 GTK_ICON_SIZE_BUTTON
));
111 ButtonWidget
*histo_buttonwidget_construct(HistoControlFlowData
*histocontrol_flow_data
)
113 ButtonWidget
*buttonwidget
= g_new(ButtonWidget
,1);
114 buttonwidget
->histo_control_flow_data
= histocontrol_flow_data
;
115 /* Put + and - on the vbox and assign related functions to each button */
116 buttonwidget
-> vbox1
= gtk_vbox_new (FALSE
, 0);
118 buttonwidget
->buttonP
= new_button_with_icon (GTK_STOCK_ZOOM_IN
);
119 buttonwidget
->buttonM
= new_button_with_icon (GTK_STOCK_ZOOM_OUT
);
120 buttonwidget
->buttonFit
= new_button_with_icon (GTK_STOCK_ZOOM_FIT
);
122 /* Pack and show all widgets */
124 gtk_box_pack_start (GTK_BOX (buttonwidget
->vbox1
),buttonwidget
->buttonP
, TRUE
, FALSE
, 0);
125 gtk_box_pack_start (GTK_BOX (buttonwidget
->vbox1
),buttonwidget
->buttonM
, TRUE
, FALSE
, 0);
126 gtk_box_pack_end (GTK_BOX (buttonwidget
->vbox1
),buttonwidget
->buttonFit
, TRUE
, FALSE
, 0);
128 /* When the button receives the "clicked" signal, it will call the
129 * function gplus() passing it NULL as its argument. The gplus()
130 * function is defined above . */
132 g_signal_connect (G_OBJECT (buttonwidget
->buttonP
), "clicked",
133 G_CALLBACK (gplus
), (gpointer
)histocontrol_flow_data
);
134 g_signal_connect (G_OBJECT ( buttonwidget
->buttonM
), "clicked",
135 G_CALLBACK (gMinus
), (gpointer
)histocontrol_flow_data
);
136 g_signal_connect (G_OBJECT ( buttonwidget
->buttonFit
), "clicked",
137 G_CALLBACK (gFit
), (gpointer
)histocontrol_flow_data
);
139 gtk_widget_show (buttonwidget
-> vbox1
);
140 gtk_widget_show (buttonwidget
->buttonP
);
141 gtk_widget_show (buttonwidget
->buttonM
);
142 gtk_widget_show (buttonwidget
->buttonFit
);
147 void histo_buttonwidget_destroy(ButtonWidget
*buttonwidget
)
149 g_debug("buttonwidget_destroy %p", buttonwidget
);
151 g_free(buttonwidget
);
152 g_debug("buttonwidget_destroy end");
155 GtkWidget
*histo_buttonwidget_get_widget(ButtonWidget
*button_widget
)
157 return button_widget
->vbox1
;
162 void histo_rectangle_pixmap (GdkGC
*gc
,
163 gboolean filled
, gint x
, gint y
, gint width
, gint height
,
164 histoDrawing_t
*value
)
167 height
= value
->drawing_area
->allocation
.height
;
169 height
= value
->drawing_area
->allocation
.width
;
170 gdk_draw_rectangle (value
->pixmap
,
177 //This could be usefull if a vertical scroll bar is added to viewer:
178 void histo_copy_pixmap_region(histoDrawing_t
*drawing
,GdkDrawable
*dest
,
179 GdkGC
*gc
, GdkDrawable
*src
,
180 gint xsrc
, gint ysrc
,
181 gint xdest
, gint ydest
, gint width
, gint height
)
185 dest
= drawing
->pixmap
;
187 src
= drawing
->pixmap
;
189 gdk_draw_drawable (dest
,gc
,src
,xsrc
, ysrc
,
190 xdest
, ydest
,width
, height
);
193 void histo_update_pixmap_size(histoDrawing_t
*value
,
196 GdkPixmap
*old_pixmap
= value
->pixmap
;
199 gdk_pixmap_new(old_pixmap
,
204 gdk_pixmap_unref(old_pixmap
);
This page took 0.113187 seconds and 5 git commands to generate.