Re: error: invalid uninstantiatable type `<invalid>' in cast to ...
- From: Димитров Вячеслав <bordimida mail ru>
- To: "gtk-list gnome org" <gtk-list gnome org>
- Subject: Re: error: invalid uninstantiatable type `<invalid>' in cast to ...
- Date: Mon, 27 Oct 2008 00:34:19 +0300
On Sun, 26 Oct 2008 21:01:29 +0300, Carlos Pereira <carlao2005 gmail com>
wrote:
Is there any difference in the way c++ treats matrices, from how c
treats them??
I try to define drops_regras with calloc and code work correctly, but may
be i don't understand you right:
GtkWidget ***drops_regras = NULL;
int j;
drops_regras = (GtkWidget ***)calloc(MAIN_nregras,
sizeof(GtkWidget**));
for(j=0; j < MAIN_nregras; j++)
{
drops_regras[j] = (GtkWidget **)calloc(MAIN_narq_ent + 1,
sizeof(GtkWidget*));
}
=======================================
Full my example:
void processa_sistema(GtkWidget *widget, gpointer pacote[])
{
GtkWidget ***drops_regras = (GtkWidget ***)pacote[0];
printf( "%d\n", gtk_combo_box_get_active(
GTK_COMBO_BOX(drops_regras[0][0] ) ) );
}
int main (int argc, char* argv[])
{
int MAIN_nregras = 6;
int MAIN_narq_ent = 3;
gtk_init (&argc, &argv);
GtkWidget *main_table = gtk_table_new(MAIN_nregras, MAIN_narq_ent,
true);
GtkWidget ***drops_regras = NULL;
int j;
drops_regras = (GtkWidget ***)calloc(MAIN_nregras,
sizeof(GtkWidget**));
for(j=0; j < MAIN_nregras; j++)
{
drops_regras[j] = (GtkWidget **)calloc(MAIN_narq_ent + 1,
sizeof(GtkWidget*));
}
GtkAttachOptions gtk_attach_options_x;
GtkAttachOptions gtk_attach_options_y;
int coluna, linha;
for(coluna=0; coluna < MAIN_narq_ent + 1; coluna++)
{
for(linha=0; linha < MAIN_nregras; linha++)
{
drops_regras[linha][coluna] = gtk_combo_box_new();
gtk_table_attach(GTK_TABLE(main_table),
GTK_WIDGET(drops_regras[linha][coluna]),
coluna + 1,
coluna + 2,
linha + 1,
linha + 2,
gtk_attach_options_x,
gtk_attach_options_y,
1, 5);
}
}
gpointer pacote2[1];
pacote2[0] = drops_regras;
GtkWidget *button = gtk_button_new_with_label ("Press");
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(processa_sistema), pacote2);
GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *main_window = create_window ();
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (main_table), TRUE,
TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button), TRUE,
TRUE, 0);
gtk_container_add (GTK_CONTAINER (main_window), vbox);
gtk_widget_show_all (main_window);
gtk_main ();
}
--
Dimitrov V.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]