table packing problems




Hi Folks,

sorry if I'm bothering you with dumb questions, but I'm fighting the Table
packer. 

I'd like to get an interface window for a Audio & MIDI sequencing
application that looks something like:

//   0                             1 2 3 4
// 0 +-----------------------------+-+-+-+
//   | timeline + markers              | |
// 1 +---------------------------------+-+  vscroll
//   |                                 |^| /
//   | track canvas                    | |/
//   |                                 | |
//   |                                 |v|
// 2 +                                 +-+
//   |                                 |-|
// 3 +                                 +-+
//   |                                 |+|
// 4 +-----------------------------+-+-+-+
//   |<                           >|-|+| |
// 5 +-----------------------------+-+-+-+
//                       \
//                        hscroll

(People that are familiar with Cubase will recognise it!)

This window consists of a (scalable) canvas where I'll paint my tracks. On
top of it is a timeline. This very much like a scrolled window except for
the [+] and [-] buttons next to the scrollbars.... These are intended for
the zoom in and out (horizontal or vertical). 

Point is: I can't get proper sized buttons for zooming in and out. I tried
to pack a pair of buttons, but these are always too big, and not square. I'd
like to have a [+] and [-] button that has the same size as the arrow in the
scrollbar.

Any Ideas?

Frank.


Btw, I'm using gtk+-971109 on a Linux machine.


Example code that doesn't give the result Frank is looking for:

==============

//
// Test for sequencer user interface 
//
// Some parts inspired by the Gimp. 
//



#include <gtk/gtk.h>




#define CANVAS_EVENT_MASK  GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | \
                           GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | \
                           GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK | \
                           GDK_ENTER_NOTIFY_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK



//
// create the arrangement window...
//
//   0                             1 2 3 4
// 0 +-----------------------------+-+-+-+
//   | timeline + markers              | |
// 1 +---------------------------------+-+  vscroll
//   |                                 |^| /
//   | track canvas                    | |/
//   |                                 |v|
// 2 +                                 +-+
//   |                                 |-|
// 3 +                                 +-+
//   |                                 |+|
// 4 +-----------------------------+-+-+-+
//   |<                           >|-|+| |
// 5 +-----------------------------+-+-+-+
//                       \
//                        hscroll

void new_win(void)
{

      	GtkWidget *shell;
	GtkWidget *table;

	GtkWidget *f1;
	GtkWidget *f2;

	GtkWidget *hsb;
	GtkWidget *vsb;

	GtkWidget *canvas;

	GtkWidget *timeline;

	GtkWidget *hzi;	// horizontal zoom in
	GtkWidget *hzo;	// horizontal zoom out

	GtkWidget *vzi;	// vertical zoom in
	GtkWidget *vzo;	// vertical zoom out

 	GtkAdjustment *hsbdata;   
	GtkAdjustment *vsbdata;   

  	hsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 500, 1, 1, 500));
  	vsbdata = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 500, 1, 1, 500));



	  /*  The toplevel shell */
  shell = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (shell), "Arrangement");
  gtk_window_set_policy (GTK_WINDOW (shell), TRUE, TRUE, TRUE);
  gtk_widget_set_events (shell, GDK_POINTER_MOTION_MASK |
	GDK_POINTER_MOTION_HINT_MASK);


  /*  the table containing all widgets  */
  table = gtk_table_new (5, 4, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1);
  gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2);
  gtk_container_border_width (GTK_CONTAINER (table), 2);
  gtk_container_add (GTK_CONTAINER (shell), table);


 
  f1 = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (f1), GTK_SHADOW_OUT);

  f2 = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (f2), GTK_SHADOW_OUT);


  hsb = gtk_hscrollbar_new (hsbdata);
  vsb = gtk_vscrollbar_new (vsbdata);

  canvas = gtk_drawing_area_new ();
  gtk_drawing_area_size (GTK_DRAWING_AREA (canvas), 256, 128);
  gtk_widget_set_events (canvas, CANVAS_EVENT_MASK);
  GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS);


  hzi = gtk_button_new_with_label ("+");
  hzo = gtk_button_new_with_label ("-");
  vzi = gtk_button_new_with_label ("+");
  vzo = gtk_button_new_with_label ("-");

  
  //gtk_widget_set_usize(hzi,20,20);
  //gtk_widget_set_usize(hzo,20,20);
  //gtk_widget_set_usize(vzi,20,20);
  //gtk_widget_set_usize(vzo,20,20);



  timeline = gtk_hruler_new ();
  gtk_ruler_set_metric (GTK_RULER (timeline), GTK_CENTIMETERS);
  {
	GtkRuler *r = GTK_RULER(timeline);

	r->lower=0;
	r->upper=150;
	r->max_size=20;
  }
 

  /*  pack all the widgets  */
  gtk_table_attach (GTK_TABLE (table), timeline, 0, 3, 0, 1,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);

				// should be   0  3  1  4  
  gtk_table_attach (GTK_TABLE (table), canvas, 0, 3, 1, 4,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);


  gtk_table_attach (GTK_TABLE (table), f1, 3, 4, 0, 1,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), f2, 3, 4, 4, 5,
                    GTK_FILL, GTK_FILL, 0, 0);


  gtk_table_attach (GTK_TABLE (table), hsb, 0, 1, 4, 5,
                    GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), vsb, 3, 4, 1, 2,
                    GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);

  gtk_table_attach (GTK_TABLE (table), vzi, 3, 4, 2, 3,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), vzo, 3, 4, 3, 4,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), hzi, 1, 2, 4, 5,
                    GTK_FILL, GTK_FILL, 0, 0);
  gtk_table_attach (GTK_TABLE (table), hzo, 2, 3, 4, 5,
                    GTK_FILL, GTK_FILL, 0, 0);



  gtk_widget_show (hsb);
  gtk_widget_show (vsb);
  gtk_widget_show (f1);
  gtk_widget_show (f2);
  gtk_widget_show (timeline);
  gtk_widget_show (canvas);
  gtk_widget_show (hzi);
  gtk_widget_show (hzo);
  gtk_widget_show (vzi);
  gtk_widget_show (vzo);
  gtk_widget_show (table);
  gtk_widget_show (shell);

  /*  set the focus to the canvas area  */
  gtk_widget_grab_focus (canvas);

}




int main (int argc, char *argv[])
{
	gtk_init(&argc, &argv);


	new_win();


      /* all GTK applications must have a gtk_main().     Control ends here
       * and waits for an event to occur (like a key press or mouse event). */
      gtk_main ();
      return 0;
}


==============




========================---------------->
#define NAME    "Frank van de Pol"     
#define ADDRESS "mgr. Nelislaan 10"  
#define CITY    "4741 AB Hoeven"    
#define COUNTRY "The Netherlands"  
#define EMAIL   "F.K.W.van.de.Pol@inter.NL.net

Linux - Why use Windows, since there is a door?



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