Bonjour,

Je n'arrive pas à utiliser un widget GtkScrolledWindow de façon à ce que les srollbars n'englobe qu'un seul widget
qui est positionné sur un table, mais je ne suis pas sûr que ce soit possible.

Voici mon code (j'ai simplifié pour l'exemple).
L'application consiste en une fenêtre dont une partie (à gauche) comporte des boutons , et l'autre
partie (à droite) est l'espace de dessin, c'est donc cette partie qui doit être scrollable.
Tous ces widgets sont positionnés sur la fenêtre via un table.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
#include <stdlib.h>
#include <gtk/gtk.h>
#define WIDTH 500
#define HEIGHT 300
 
GdkPixmap *pPixmap = NULL;
 
typedef struct APPLICATION
{
  GtkWidget *pWin;
  GtkWidget *pDrawArea;
  GtkWidget *pTable;
  GtkWidget *pQuitBtn;
  GtkWidget *pPaddBtn;
 
}APPLICATION;
 
 
void draw_cb(GtkWidget *drawArea, GdkEventExpose *event, gpointer userData)
{
   static int wScrn, hScrn = 0;
   if (pPixmap == NULL || wScrn != drawArea->allocation.width || hScrn != drawArea->allocation.height)
   {
    wScrn = drawArea->allocation.width;
    hScrn = drawArea->allocation.height;
    pPixmap = gdk_pixmap_new(drawArea->window, wScrn, hScrn, -1);//
    gdk_draw_rectangle(pPixmap, drawArea->style->white_gc, TRUE, 0, 0, wScrn, hScrn);
   }
 
   gdk_draw_drawable(drawArea->window, drawArea->style->fg_gc[GTK_WIDGET_STATE (drawArea)],
                                        pPixmap, event->area.x, event->area.y,
                                        event->area.x, event->area.y,
                                        event->area.width, event->area.height);
}
 
int main (int argc, char *argv[])
{
  APPLICATION myApp;
  gtk_init(&argc, &argv);
 
  myApp.pWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(myApp.pWin), WIDTH, HEIGHT);
  gtk_window_set_title(GTK_WINDOW(myApp.pWin), "GTK-Win");
  g_signal_connect(G_OBJECT(myApp.pWin), "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
 
  myApp.pDrawArea = gtk_drawing_area_new ();
  g_signal_connect(G_OBJECT(myApp.pDrawArea),"expose_event",G_CALLBACK(draw_cb), &myApp);
 
 
  myApp.pTable = gtk_table_new(2, 2, FALSE);
  gtk_container_add (GTK_CONTAINER(myApp.pWin), myApp.pTable);
  //création des boutons
  myApp.pQuitBtn = gtk_button_new_with_label("Quitter");
  myApp.pPaddBtn = gtk_button_new();
  //connexion des bouton à une fonction de callback
  g_signal_connect(G_OBJECT(myApp.pQuitBtn),"clicked",G_CALLBACK(gtk_main_quit), NULL);
  //définit la taille des boutons
  gtk_widget_set_size_request(myApp.pQuitBtn, 100, 30);
  gtk_widget_set_size_request(myApp.pPaddBtn, 1, 1);
  //attache les widgets sur la table
  gtk_table_attach(GTK_TABLE(myApp.pTable), myApp.pQuitBtn, 0, 1, 0, 1, GTK_FILL, GTK_SHRINK, 5, 5);
  gtk_table_attach(GTK_TABLE(myApp.pTable), myApp.pPaddBtn, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND, 0, 0);
  gtk_table_attach_defaults(GTK_TABLE(myApp.pTable), myApp.pDrawArea, 1, 2, 0, 2);
  gtk_widget_set_child_visible(myApp.pPaddBtn, FALSE);
 
  gtk_widget_show_all(myApp.pWin);
  gtk_main ();
  return 0;
}
J'ai essayé un tas de combinaisons, (mettre le draw area dans une vbox et attacher la vbox à la table etc.....) mais rien ne marche

Quelqu'un pourrait-il m'aider ?

D'avance merci