//
// $Id: ipfw-default.c,v 1.3 2001/11/16 04:46:20 mavetju Exp $
//
//
// Some default graphical functions for ipfw-graph.
//
#include <gtk/gtk.h>
#include <stdio.h>
#include "ipfw-graph.h"
void bg_drawing(void) {
GdkGC *gc;
GdkRectangle update_rect;
//
// drawing part
//
if (drawtable[current_page].pixmap!=NULL &&
drawtable[current_page].area!=NULL) {
update_rect.x=0;
update_rect.y=0;
update_rect.width=drawtable[current_page].area->allocation.width;
update_rect.height=drawtable[current_page].area->allocation.height;
gc=drawtable[current_page].area->style->bg_gc[GTK_WIDGET_STATE(drawtable[current_page].area)];
gdk_draw_rectangle(drawtable[current_page].pixmap,gc,TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
}
}
void bg_bytes(void) {
GdkGC *gc;
GdkRectangle update_rect;
int y;
//
// bytes part
//
if (bytes_pixmap!=NULL && bytes_area!=NULL) {
update_rect.x=0;
update_rect.y=0;
update_rect.width=bytes_area->allocation.width;
update_rect.height=bytes_area->allocation.height;
gc = bytes_area->style->bg_gc[GTK_WIDGET_STATE (bytes_area)];
gdk_draw_rectangle(bytes_pixmap,gc,TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
gc=bytes_area->style->black_gc;
for (y=0;y<=10;y++) {
gdk_draw_line(bytes_pixmap,gc,
1 ,y*ysize_bytes/10,
xsize, y*ysize_bytes/10);
}
}
}
void default_stats(void) {
char c[100];
char m[100];
char s[100];
if (data_bytes.table[MAXSTORED-1]>9999999)
sprintf(c,"%1.3f Mbps",data_bytes.table[MAXSTORED-1]/1000000.0);
else if (data_bytes.table[MAXSTORED-1]>9999)
sprintf(c,"%1.3f kbps",data_bytes.table[MAXSTORED-1]/1000.0);
else
sprintf(c,"%ld bps",data_bytes.table[MAXSTORED-1]);
if (maxyvalue>9999999)
sprintf(m,"%1.3f Mbps",maxyvalue/1000000.0);
else if (maxyvalue>9999)
sprintf(m,"%1.3f kbps",maxyvalue/1000.0);
else
sprintf(m,"%ld bps",maxyvalue);
sprintf(s,"current %s max %s",c,m);
gtk_entry_set_text((GtkEntry *)text_area,s);
}
syntax highlighted by Code2HTML, v. 0.9.1