Addind 2 Widget in 1 Container....



Hi !

Firstly thank you for your help.

I 'm actually trying to add a GtkDrawingArea in a window that already
contains a GtkImage.
There's probably an easy solution for this but I didn't know it... :(
So I show my code and I wait for suggestions... :D


GtkWidget* draw_screen(GLOBAL_SKIN_INFOS *gsi)  {


    SKIN_INFOS *si;
    si=malloc(sizeof(SKIN_INFOS));
    gsi->si=(SKIN_INFOS*)si;
    skin_load(gsi->si,gsi->SkinFileName);


    /* Create the window */
    GtkWidget *pImage;
    GtkWidget *pWindow;

    GtkWidget *gtk_window_new(GtkWindowType type);
    pWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);                //
GTK_WINDOW_LEVEL : define how is the window
        gtk_window_set_title(GTK_WINDOW(pWindow),"tilem");
    // define title of the window
        gtk_window_set_position(GTK_WINDOW(pWindow),GTK_WIN_POS_CENTER); //
GTK_WIN_POS_CENTER : define how the window is displayed

gtk_window_set_default_size(GTK_WINDOW(pWindow),gsi->si->width,gsi->si->height);
// define size of the window


    pImage=gtk_image_new_from_pixbuf(gsi->si->image); //Load a pixbuf
    gsi->pImage=pImage;


    GtkWidget *pAf;
    int screenwidth=94;    // fixed for the test
    int screenheight=61;    // idem
    pAf = gtk_aspect_frame_new(NULL, 0.5, 0.5, 1.0, TRUE);        // et pAf
! ça fait des Chocapic !!
                         gtk_frame_set_shadow_type(GTK_FRAME(pAf),
                                                   GTK_SHADOW_NONE);
                         {
                                 gsi->emu.lcdwin = gtk_drawing_area_new();
                                 gtk_widget_set_name(gsi->emu.lcdwin,
"tilem-lcd");


gtk_widget_set_size_request(gsi->emu.lcdwin,
                                                             screenwidth *
2,
                                                             screenheight *
2);
                                 gtk_container_add(GTK_CONTAINER(pAf),
                                                   gsi->emu.lcdwin);
                               gtk_widget_show(gsi->emu.lcdwin);
                       }
     /* HERE IS MY PROBLEM ! */
    //gtk_container_add(GTK_CONTAINER(pImage),pAf);
    /* OR */
    //gtk_container_add(GTK_CONTAINER(pWindow),pAf);
    /* END */

    gtk_widget_show(pAf);
    gtk_container_add(GTK_CONTAINER(pWindow),pImage);




g_signal_connect(G_OBJECT(pWindow),"destroy",G_CALLBACK(OnDestroy),NULL);
    /* Connection signal keyboard key press */
    gtk_widget_add_events(pWindow, GDK_KEY_RELEASE_MASK); // Get the event
on the window (leftclick, rightclick)
    /*gtk_signal_connect(GTK_OBJECT(pWindow), "key_press_event",
GTK_SIGNAL_FUNC(keyboard_event), NULL); */
    gtk_signal_connect(GTK_OBJECT(pWindow), "key_press_event",
G_CALLBACK(keyboard_event), NULL);
    gtk_widget_add_events(pWindow, GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
    gtk_signal_connect(GTK_OBJECT(pWindow), "button_press_event",
G_CALLBACK(mouse_event),(gpointer)gsi);
    gtk_widget_show_all(pWindow);    // display the window and all that it
contains.


    return pWindow;
}

This code works but I can't add both widget...

So I "simply" search for a solution to contain a pixmap AND a drawarea .
Use GtkBox is  impossible because the pixmap must be in background and the
drawarea center ON it.


Thank you for all.

I hope my english is not too bad.

Best regards.

Thibault Duponchelle



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]