Jet Postado Janeiro 14, 2011 Denunciar Share Postado Janeiro 14, 2011 My program is always crashing and i can't figure way.. Can some one help my??CODE:#include <cairo.h>#include <gtk/gtk.h>#include <math.h>#include <time.h>#include <stdlib.h>static double dt = 1.;typedef struct{ gint D; gint Vi; gint N; gint Y1; gint Y2; gint *Px; gint *Py; gint *Vx; gint *Vy;} coordenadas;gbooleanpress_click (GtkWidget *widget ,GdkEventExpose *event , coordenadas *c ){ c->Vi = c->Vi + 1; if (c->Vi > 7) c->Vi = 1; return TRUE;}gboolean on_expose_event (GtkWidget*widget , GdkEventExpose*event , coordenadas *c){ cairo_t *cr ; gchar texto[128],caixas[128] ; gint width, height; static double pos1x = 15., pos1y = 200.; static int v,i,n; static int nv=0; static int numero[11]; gtk_window_get_size(GTK_WINDOW(widget), &width, &height); cr = gdk_cairo_create(widget->window); cairo_move_to (cr, 20, 20); cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, 18); sprintf (texto, "OOOOO MEU DEUSS QUE LIIINDO!! Velocidade: %d\n",(gint) dt); cairo_show_text (cr, texto); /* Cerca */ cairo_set_source_rgb (cr, 0, 0, 0.7); cairo_set_line_width (cr, 1); cairo_rectangle (cr, (gint) pos1x, (gint) pos1y, 770, 200); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_set_source_rgb (cr, 0, 0, 0.7); cairo_set_line_width (cr, 1); for (i=0; i<10;++i) { cairo_move_to (cr, (85+70*i), 200); cairo_line_to (cr, (85+70*i), c->Y1); cairo_move_to (cr, (85+70*i), 400); cairo_line_to (cr, (85+70*i), c->Y2); cairo_stroke (cr); } /*Gerador de Particulas */ for (i=0; i<c->N;++i) { cairo_set_source_rgb (cr, 1, 0., 0); cairo_set_line_width (cr, 1.0); cairo_arc (cr, c->Px, c->Py, 2, 0, 2. * M_PI); cairo_stroke_preserve (cr); cairo_set_source_rgb (cr, 0, 1, 1); cairo_fill (cr); } /*Detector de colisões em X*/ for (n=0;n<c->N;++n) { if ((c->Px[n] <= 15) || ((c->Px[n] + 15) >= width) || (c->Px[n]+c->Vx[n]*c->Vi <= 15) || ((c->Px[n]+c->Vx[n]*c->Vi + 15) >= width)) { v=0; c->Vx[n] = - c->Vx[n]; } else { for (i=1;i<11;++i) { if (((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i)) && ((c->Py[n]+c->Vy[n]<=c->Y1)||(c->Py[n]+c->Vy[n]>=c->Y2))|| ((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i)) && ((c->Py[n]+c->Vy[n]<=c->Y1)||(c->Py[n]+c->Vy[n]>=c->Y2))))) { v=i; c->Vx[n] = - c->Vx[n]; break; } else if ((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i))|| ((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i)))) v=100; } } /*Numero das caixas*/ if(nv==0) { numero[5]=c->N; nv=1; } for (i=1;i<11;++i) { if ((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i)) && (v==100)) { numero[i-1]=numero[i-1]-1; numero=numero+1; } else if ((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i)) && (v==100)) { numero[i-1]=numero[i-1]+1; numero=numero-1; } } /*Movimentador em X*/ c->Px[n] = c->Px[n] + c->Vx[n] * c->Vi; } for (n=0;n<c->N;++n) { /*Detector de Colisõe em Y*/ if ((c->Py[n] <= 200) || ((c->Py[n] + 200) >= height) || (c->Py[n]+c->Vy[n]*c->Vi <= 200) || ((c->Py[n]+c->Vy[n]*c->Vi + 200) >= height)) c->Vy[n] = - c->Vy[n]; /*Movimentador em Y*/ c->Py[n] = c->Py[n] + c->Vy[n] * c->Vi; } /*Escrita do numero de caixas*/ cairo_set_source_rgb (cr, 1., 0., 0.); for (i=0;i<11;++i) { cairo_move_to (cr, (50+70*i), 195); cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, 18); sprintf (caixas,"%d",(gint) numero); cairo_show_text (cr, caixas); } cairo_stroke(cr); cairo_destroy(cr); return FALSE;}static gbooleantime_handler (GtkWidget *widget){ if (widget->window == NULL) return FALSE; gtk_widget_queue_draw(widget); return TRUE;}static void Tela (coordenadas *c ){ double d, y1, y2,n,x; int *px,*py,*vx,*vy; int i; GtkWidget*window1=NULL; srand(time(NULL)); d=c->D; px = malloc(c->N * sizeof(int)); py = malloc(c->N * sizeof(int)); vx = malloc(c->N * sizeof(int)); vy = malloc(c->N * sizeof(int)); if( (px==NULL) || (py==NULL) || (vx==NULL) || (vy==NULL)) { printf("ERRO!!-> Sem memoria\n"); } for (i=0; i<n; ++i) { x=rand(); px=366+(x/RAND_MAX)*68; } for (i=0; i<n; ++i) { x=rand(); py=201+(x/RAND_MAX)*198; } for (i=0; i<n; ++i) { vx=1; } for (i=0; i<n; ++i) { vy=1; } y1=300-(d/2); y2=300+(d/2); c->Y1 = y1 ; c->Y2 = y2; c->Px = px; c->Py = py; c->Vx = vx; c->Vy = vy; window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_add_events (window1, GDK_BUTTON_PRESS_MASK); g_signal_connect (window1, "expose-event", G_CALLBACK(on_expose_event), c); g_signal_connect (window1, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect (G_OBJECT(window1), "button_press_event", G_CALLBACK(press_click),c); gtk_window_set_position (GTK_WINDOW(window1), GTK_WIN_POS_CENTER); gtk_window_set_title (GTK_WINDOW(window1), "Trabalho Final"); gtk_window_set_default_size (GTK_WINDOW(window1), 800, 600); gtk_widget_set_app_paintable (window1, TRUE); g_timeout_add (15, (GSourceFunc) time_handler, (gpointer) window1); gtk_widget_show_all(window1); gtk_main();}static void def_valor_D (GtkAdjustment*get, coordenadas *c){ c->D = get->value;}static void def_valor_Vi (GtkAdjustment*get, coordenadas *c){ c->Vi = get->value;}static void def_valor_N (GtkAdjustment*get, coordenadas *c){ c->N = get->value;}//Função atribuidora de caracterÃsticas das escalasstatic void scale_set_values(GtkScale *scale, int digits){ gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_CONTINUOUS); gtk_scale_set_digits (scale, digits); gtk_scale_set_value_pos (scale, GTK_POS_RIGHT); gtk_scale_set_draw_value (scale, TRUE);}//Função criadora da janela com as escalas de configuração de valoresstatic void create_range_controls( void ){ double N1, D1, Vi1; GtkWidget *window ; GtkWidget *box1, *box2, *box3 ; GtkWidget *velscale, *nscale, *dscale ; GtkWidget *label, *biniciar ; GtkObject *adj1, *adj2, *adj3 ; //Janela window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW(window), 400, 100); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_title (GTK_WINDOW (window), "Janela_1 - Configuração de Valores"); box2 = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_container_add (GTK_CONTAINER (window), box2); gtk_widget_show (box2); coordenadas *c = g_slice_new(coordenadas); c->N = 2; c->D = 50; c->Vi = 2; //Escala de configuração do módulo da velocidade das particulas box3 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10); gtk_widget_show (box3); label = gtk_label_new ("Velocidade inicial das Particulas"); gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0); gtk_widget_show (label); box3 = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0); gtk_widget_show (box3); adj1 = gtk_adjustment_new (1, 0, 7, 0.01, 0.01, 0); //g_signal_connect(GTK_OBJECT(adj1), "value_changed", G_CALLBACK (def_valor_Vi), c); velscale = gtk_hscale_new (GTK_ADJUSTMENT (adj1)); gtk_widget_set_size_request (GTK_WIDGET (velscale), 100, -1); scale_set_values (GTK_SCALE (velscale), 0); gtk_box_pack_start (GTK_BOX (box3), velscale, TRUE, TRUE, 0); gtk_widget_show (velscale); //Escala de configuração do número de partÃculas box3 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10); gtk_widget_show (box3); label = gtk_label_new ("Número de Particulas"); gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0); gtk_widget_show (label); box3 = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0); gtk_widget_show (box3); adj2 = gtk_adjustment_new (250.0, 0.0, 500.0, 1.0, 1.0, 0.0); //g_signal_connect(GTK_OBJECT(adj2), "value_changed", G_CALLBACK(def_valor_N), c); nscale = gtk_hscale_new (GTK_ADJUSTMENT (adj2)); gtk_widget_set_size_request (GTK_WIDGET (nscale), 100, -1); scale_set_values (GTK_SCALE (nscale), 0); gtk_box_pack_start (GTK_BOX (box3), nscale, TRUE, TRUE, 0); gtk_widget_show (nscale); //Escala de configuração da dimensão das aberturas (das caixas) box3 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10); gtk_widget_show (box3); label = gtk_label_new ("Dimensão das Aberturas"); gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0); gtk_widget_show (label); box3 = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 5); gtk_widget_show (box3); adj3 = gtk_adjustment_new (100.0, 0.0, 199.9, 0.1, 0.1, 0.0); //g_signal_connect(GTK_OBJECT (adj3), "value_changed", G_CALLBACK(def_valor_D), c); dscale = gtk_hscale_new (GTK_ADJUSTMENT (adj3)); gtk_widget_set_size_request (GTK_WIDGET (dscale), 100, -1); scale_set_values (GTK_SCALE (dscale), 0); gtk_box_pack_start (GTK_BOX (box3), dscale, TRUE, TRUE, 0); gtk_widget_show (dscale); //Botão de iniciação box3 = gtk_hbox_new (FALSE, 0); gtk_box_pack_end (GTK_BOX (box2), box3, FALSE, FALSE, 10); gtk_widget_show (box3); biniciar = gtk_button_new_with_label ("Iniciar"); gtk_widget_set_size_request (biniciar, 90, 40); g_signal_connect (biniciar, "clicked", G_CALLBACK (Tela), c); gtk_box_pack_end (GTK_BOX (box3), biniciar, FALSE, FALSE, 20); gtk_widget_show (biniciar); gtk_widget_show (window);}int main( int argc, char *argv[] ){ gtk_init (&argc, &argv); create_range_controls (); gtk_main (); return 0;} Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
Jet
My program is always crashing and i can't figure way.. Can some one help my??
CODE:
#include <cairo.h>
#include <gtk/gtk.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
static double dt = 1.;
typedef struct
{
gint D;
gint Vi;
gint N;
gint Y1;
gint Y2;
gint *Px;
gint *Py;
gint *Vx;
gint *Vy;
} coordenadas;
gboolean
press_click (GtkWidget *widget ,
GdkEventExpose *event , coordenadas *c )
{
c->Vi = c->Vi + 1;
if (c->Vi > 7)
c->Vi = 1;
return TRUE;
}
gboolean on_expose_event (GtkWidget*widget , GdkEventExpose*event , coordenadas *c)
{
cairo_t *cr ;
gchar texto[128],caixas[128] ;
gint width, height;
static double pos1x = 15., pos1y = 200.;
static int v,i,n;
static int nv=0;
static int numero[11];
gtk_window_get_size(GTK_WINDOW(widget), &width, &height);
cr = gdk_cairo_create(widget->window);
cairo_move_to (cr, 20, 20);
cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 18);
sprintf (texto, "OOOOO MEU DEUSS QUE LIIINDO!! Velocidade: %d\n",(gint) dt);
cairo_show_text (cr, texto);
/* Cerca */
cairo_set_source_rgb (cr, 0, 0, 0.7);
cairo_set_line_width (cr, 1);
cairo_rectangle (cr, (gint) pos1x, (gint) pos1y, 770, 200);
cairo_stroke_preserve (cr);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill (cr);
cairo_set_source_rgb (cr, 0, 0, 0.7);
cairo_set_line_width (cr, 1);
for (i=0; i<10;++i)
{
cairo_move_to (cr, (85+70*i), 200);
cairo_line_to (cr, (85+70*i), c->Y1);
cairo_move_to (cr, (85+70*i), 400);
cairo_line_to (cr, (85+70*i), c->Y2);
cairo_stroke (cr);
}
/*Gerador de Particulas */
for (i=0; i<c->N;++i)
{
cairo_set_source_rgb (cr, 1, 0., 0);
cairo_set_line_width (cr, 1.0);
cairo_arc (cr, c->Px, c->Py, 2, 0, 2. * M_PI);
cairo_stroke_preserve (cr);
cairo_set_source_rgb (cr, 0, 1, 1);
cairo_fill (cr);
}
/*Detector de colisões em X*/
for (n=0;n<c->N;++n)
{
if ((c->Px[n] <= 15) || ((c->Px[n] + 15) >= width) || (c->Px[n]+c->Vx[n]*c->Vi <= 15) || ((c->Px[n]+c->Vx[n]*c->Vi + 15) >= width))
{
v=0;
c->Vx[n] = - c->Vx[n];
}
else
{
for (i=1;i<11;++i)
{
if (((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i)) && ((c->Py[n]+c->Vy[n]<=c->Y1)||(c->Py[n]+c->Vy[n]>=c->Y2))||
((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i)) && ((c->Py[n]+c->Vy[n]<=c->Y1)||(c->Py[n]+c->Vy[n]>=c->Y2)))))
{
v=i;
c->Vx[n] = - c->Vx[n];
break;
}
else if ((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i))||
((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i))))
v=100;
}
}
/*Numero das caixas*/
if(nv==0)
{
numero[5]=c->N;
nv=1;
}
for (i=1;i<11;++i)
{
if ((c->Px[n]<=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)>15+(70*i)) && (v==100))
{
numero[i-1]=numero[i-1]-1;
numero=numero+1;
}
else if ((c->Px[n]>=15+(70*i)) && ((c->Px[n]+c->Vx[n]*c->Vi)<15+(70*i)) && (v==100))
{
numero[i-1]=numero[i-1]+1;
numero=numero-1;
}
}
/*Movimentador em X*/
c->Px[n] = c->Px[n] + c->Vx[n] * c->Vi;
}
for (n=0;n<c->N;++n)
{
/*Detector de Colisõe em Y*/
if ((c->Py[n] <= 200) || ((c->Py[n] + 200) >= height) || (c->Py[n]+c->Vy[n]*c->Vi <= 200) || ((c->Py[n]+c->Vy[n]*c->Vi + 200) >= height))
c->Vy[n] = - c->Vy[n];
/*Movimentador em Y*/
c->Py[n] = c->Py[n] + c->Vy[n] * c->Vi;
}
/*Escrita do numero de caixas*/
cairo_set_source_rgb (cr, 1., 0., 0.);
for (i=0;i<11;++i)
{
cairo_move_to (cr, (50+70*i), 195);
cairo_select_font_face(cr, "Courier", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 18);
sprintf (caixas,"%d",(gint) numero);
cairo_show_text (cr, caixas);
}
cairo_stroke(cr);
cairo_destroy(cr);
return FALSE;
}
static gboolean
time_handler (GtkWidget *widget)
{
if (widget->window == NULL)
return FALSE;
gtk_widget_queue_draw(widget);
return TRUE;
}
static void Tela (coordenadas *c )
{
double d, y1, y2,n,x;
int *px,*py,*vx,*vy;
int i;
GtkWidget*window1=NULL;
srand(time(NULL));
d=c->D;
px = malloc(c->N * sizeof(int));
py = malloc(c->N * sizeof(int));
vx = malloc(c->N * sizeof(int));
vy = malloc(c->N * sizeof(int));
if( (px==NULL) || (py==NULL) || (vx==NULL) || (vy==NULL))
{
printf("ERRO!!-> Sem memoria\n");
}
for (i=0; i<n; ++i)
{
x=rand();
px=366+(x/RAND_MAX)*68;
}
for (i=0; i<n; ++i)
{
x=rand();
py=201+(x/RAND_MAX)*198;
}
for (i=0; i<n; ++i)
{
vx=1;
}
for (i=0; i<n; ++i)
{
vy=1;
}
y1=300-(d/2);
y2=300+(d/2);
c->Y1 = y1 ;
c->Y2 = y2;
c->Px = px;
c->Py = py;
c->Vx = vx;
c->Vy = vy;
window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_add_events (window1, GDK_BUTTON_PRESS_MASK);
g_signal_connect (window1, "expose-event", G_CALLBACK(on_expose_event), c);
g_signal_connect (window1, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect (G_OBJECT(window1), "button_press_event", G_CALLBACK(press_click),c);
gtk_window_set_position (GTK_WINDOW(window1), GTK_WIN_POS_CENTER);
gtk_window_set_title (GTK_WINDOW(window1), "Trabalho Final");
gtk_window_set_default_size (GTK_WINDOW(window1), 800, 600);
gtk_widget_set_app_paintable (window1, TRUE);
g_timeout_add (15, (GSourceFunc) time_handler, (gpointer) window1);
gtk_widget_show_all(window1);
gtk_main();
}
static void def_valor_D (GtkAdjustment*get, coordenadas *c)
{
c->D = get->value;
}
static void def_valor_Vi (GtkAdjustment*get, coordenadas *c)
{
c->Vi = get->value;
}
static void def_valor_N (GtkAdjustment*get, coordenadas *c)
{
c->N = get->value;
}
//Função atribuidora de caracterÃsticas das escalas
static void scale_set_values(GtkScale *scale,
int digits)
{
gtk_range_set_update_policy (GTK_RANGE (scale),
GTK_UPDATE_CONTINUOUS);
gtk_scale_set_digits (scale, digits);
gtk_scale_set_value_pos (scale, GTK_POS_RIGHT);
gtk_scale_set_draw_value (scale, TRUE);
}
//Função criadora da janela com as escalas de configuração de valores
static void create_range_controls( void )
{
double N1, D1, Vi1;
GtkWidget *window ;
GtkWidget *box1, *box2, *box3 ;
GtkWidget *velscale, *nscale, *dscale ;
GtkWidget *label, *biniciar ;
GtkObject *adj1, *adj2, *adj3 ;
//Janela
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW(window), 400, 100);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
gtk_window_set_title (GTK_WINDOW (window), "Janela_1 - Configuração de Valores");
box2 = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
gtk_container_add (GTK_CONTAINER (window), box2);
gtk_widget_show (box2);
coordenadas *c = g_slice_new(coordenadas);
c->N = 2;
c->D = 50;
c->Vi = 2;
//Escala de configuração do módulo da velocidade das particulas
box3 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10);
gtk_widget_show (box3);
label = gtk_label_new ("Velocidade inicial das Particulas");
gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0);
gtk_widget_show (label);
box3 = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
gtk_widget_show (box3);
adj1 = gtk_adjustment_new (1, 0, 7, 0.01, 0.01, 0);
//g_signal_connect(GTK_OBJECT(adj1), "value_changed", G_CALLBACK (def_valor_Vi), c);
velscale = gtk_hscale_new (GTK_ADJUSTMENT (adj1));
gtk_widget_set_size_request (GTK_WIDGET (velscale), 100, -1);
scale_set_values (GTK_SCALE (velscale), 0);
gtk_box_pack_start (GTK_BOX (box3), velscale, TRUE, TRUE, 0);
gtk_widget_show (velscale);
//Escala de configuração do número de partÃculas
box3 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10);
gtk_widget_show (box3);
label = gtk_label_new ("Número de Particulas");
gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0);
gtk_widget_show (label);
box3 = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
gtk_widget_show (box3);
adj2 = gtk_adjustment_new (250.0, 0.0, 500.0, 1.0, 1.0, 0.0);
//g_signal_connect(GTK_OBJECT(adj2), "value_changed", G_CALLBACK(def_valor_N), c);
nscale = gtk_hscale_new (GTK_ADJUSTMENT (adj2));
gtk_widget_set_size_request (GTK_WIDGET (nscale), 100, -1);
scale_set_values (GTK_SCALE (nscale), 0);
gtk_box_pack_start (GTK_BOX (box3), nscale, TRUE, TRUE, 0);
gtk_widget_show (nscale);
//Escala de configuração da dimensão das aberturas (das caixas)
box3 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 10);
gtk_widget_show (box3);
label = gtk_label_new ("Dimensão das Aberturas");
gtk_box_pack_start (GTK_BOX (box3), label, FALSE, FALSE, 0);
gtk_widget_show (label);
box3 = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 5);
gtk_widget_show (box3);
adj3 = gtk_adjustment_new (100.0, 0.0, 199.9, 0.1, 0.1, 0.0);
//g_signal_connect(GTK_OBJECT (adj3), "value_changed", G_CALLBACK(def_valor_D), c);
dscale = gtk_hscale_new (GTK_ADJUSTMENT (adj3));
gtk_widget_set_size_request (GTK_WIDGET (dscale), 100, -1);
scale_set_values (GTK_SCALE (dscale), 0);
gtk_box_pack_start (GTK_BOX (box3), dscale, TRUE, TRUE, 0);
gtk_widget_show (dscale);
//Botão de iniciação
box3 = gtk_hbox_new (FALSE, 0);
gtk_box_pack_end (GTK_BOX (box2), box3, FALSE, FALSE, 10);
gtk_widget_show (box3);
biniciar = gtk_button_new_with_label ("Iniciar");
gtk_widget_set_size_request (biniciar, 90, 40);
g_signal_connect (biniciar, "clicked", G_CALLBACK (Tela), c);
gtk_box_pack_end (GTK_BOX (box3), biniciar, FALSE, FALSE, 20);
gtk_widget_show (biniciar);
gtk_widget_show (window);
}
int main( int argc,
char *argv[] )
{
gtk_init (&argc, &argv);
create_range_controls ();
gtk_main ();
return 0;
}
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.