Blame docs/tutorial/html/x1258.html

Packit 98cdb6
Packit 98cdb6
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>Fixed Container
Packit 98cdb6
>
Packit 98cdb6
NAME="GENERATOR"
Packit 98cdb6
CONTENT="Modular DocBook HTML Stylesheet Version 1.79">
Packit 98cdb6
REL="HOME"
Packit 98cdb6
TITLE="GTK+ 2.0 Tutorial"
Packit 98cdb6
HREF="book1.html">
Packit 98cdb6
REL="UP"
Packit 98cdb6
TITLE="Container Widgets"
Packit 98cdb6
HREF="c1226.html">
Packit 98cdb6
REL="PREVIOUS"
Packit 98cdb6
TITLE="The Alignment widget"
Packit 98cdb6
HREF="x1243.html">
Packit 98cdb6
REL="NEXT"
Packit 98cdb6
TITLE="Layout Container"
Packit 98cdb6
HREF="x1279.html">
Packit 98cdb6
>
Packit 98cdb6
CLASS="SECT1"
Packit 98cdb6
BGCOLOR="#FFFFFF"
Packit 98cdb6
TEXT="#000000"
Packit 98cdb6
LINK="#0000FF"
Packit 98cdb6
VLINK="#840084"
Packit 98cdb6
ALINK="#0000FF"
Packit 98cdb6
>
Packit 98cdb6
CLASS="NAVHEADER"
Packit 98cdb6
>
Packit 98cdb6
SUMMARY="Header navigation table"
Packit 98cdb6
WIDTH="100%"
Packit 98cdb6
BORDER="0"
Packit 98cdb6
CELLPADDING="0"
Packit 98cdb6
CELLSPACING="0"
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
COLSPAN="3"
Packit 98cdb6
ALIGN="center"
Packit 98cdb6
>GTK+ 2.0 Tutorial
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="10%"
Packit 98cdb6
ALIGN="left"
Packit 98cdb6
VALIGN="bottom"
Packit 98cdb6
>
Packit 98cdb6
HREF="x1243.html"
Packit 98cdb6
ACCESSKEY="P"
Packit 98cdb6
><<< Previous
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="80%"
Packit 98cdb6
ALIGN="center"
Packit 98cdb6
VALIGN="bottom"
Packit 98cdb6
>Container Widgets
Packit 98cdb6
>
Packit 98cdb6
WIDTH="10%"
Packit 98cdb6
ALIGN="right"
Packit 98cdb6
VALIGN="bottom"
Packit 98cdb6
>
Packit 98cdb6
HREF="x1279.html"
Packit 98cdb6
ACCESSKEY="N"
Packit 98cdb6
>Next >>>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
ALIGN="LEFT"
Packit 98cdb6
WIDTH="100%">
Packit 98cdb6
>
Packit 98cdb6
CLASS="SECT1"
Packit 98cdb6
>
Packit 98cdb6
CLASS="SECT1"
Packit 98cdb6
>
Packit 98cdb6
NAME="SEC-FIXEDCONTAINER"
Packit 98cdb6
>Fixed Container
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>The Fixed container allows you to place widgets at a fixed position
Packit 98cdb6
within it's window, relative to it's upper left hand corner. The
Packit 98cdb6
position of the widgets can be changed dynamically.
Packit 98cdb6
>
Packit 98cdb6
>There are only a few functions associated with the fixed widget:
Packit 98cdb6
>
Packit 98cdb6
BORDER="0"
Packit 98cdb6
BGCOLOR="#E0E0E0"
Packit 98cdb6
WIDTH="100%"
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
CLASS="PROGRAMLISTING"
Packit 98cdb6
>GtkWidget* gtk_fixed_new( void );
Packit 98cdb6
Packit 98cdb6
void gtk_fixed_put( GtkFixed  *fixed,
Packit 98cdb6
                    GtkWidget *widget,
Packit 98cdb6
                    gint       x,
Packit 98cdb6
                    gint       y );
Packit 98cdb6
Packit 98cdb6
void gtk_fixed_move( GtkFixed  *fixed,
Packit 98cdb6
                     GtkWidget *widget,
Packit 98cdb6
                     gint       x,
Packit 98cdb6
                     gint       y );
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>The function gtk_fixed_new() allows you to create a new Fixed
Packit 98cdb6
container.
Packit 98cdb6
>
Packit 98cdb6
>gtk_fixed_put() places 
Packit 98cdb6
CLASS="LITERAL"
Packit 98cdb6
>widget
Packit 98cdb6
> in the container 
Packit 98cdb6
CLASS="LITERAL"
Packit 98cdb6
>fixed
Packit 98cdb6
> at
Packit 98cdb6
the position specified by 
Packit 98cdb6
CLASS="LITERAL"
Packit 98cdb6
>x
Packit 98cdb6
> and 
Packit 98cdb6
CLASS="LITERAL"
Packit 98cdb6
>y
Packit 98cdb6
>.
Packit 98cdb6
>
Packit 98cdb6
>gtk_fixed_move() allows the specified widget to be moved to a new
Packit 98cdb6
position.
Packit 98cdb6
>
Packit 98cdb6
BORDER="0"
Packit 98cdb6
BGCOLOR="#E0E0E0"
Packit 98cdb6
WIDTH="100%"
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
CLASS="PROGRAMLISTING"
Packit 98cdb6
>void gtk_fixed_set_has_window( GtkFixed  *fixed,
Packit 98cdb6
                               gboolean   has_window );
Packit 98cdb6
Packit 98cdb6
gboolean gtk_fixed_get_has_window( GtkFixed *fixed );
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>Normally, Fixed widgets don't have their own X window. Since this is
Packit 98cdb6
different from the behaviour of Fixed widgets in earlier releases of GTK, 
Packit 98cdb6
the function gtk_fixed_set_has_window() allows the creation of Fixed widgets 
Packit 98cdb6
Packit 98cdb6
CLASS="EMPHASIS"
Packit 98cdb6
>with
Packit 98cdb6
> their own window. It has to be called before
Packit 98cdb6
realizing the widget.
Packit 98cdb6
>
Packit 98cdb6
>The following example illustrates how to use the Fixed Container.
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
CLASS="INLINEMEDIAOBJECT"
Packit 98cdb6
>
Packit 98cdb6
SRC="images/fixed.png">
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
BORDER="0"
Packit 98cdb6
BGCOLOR="#E0E0E0"
Packit 98cdb6
WIDTH="100%"
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
CLASS="PROGRAMLISTING"
Packit 98cdb6
>
#include <gtk/gtk.h>
Packit 98cdb6
Packit 98cdb6
/* I'm going to be lazy and use some global variables to
Packit 98cdb6
 * store the position of the widget within the fixed
Packit 98cdb6
 * container */
Packit 98cdb6
gint x = 50;
Packit 98cdb6
gint y = 50;
Packit 98cdb6
Packit 98cdb6
/* This callback function moves the button to a new position
Packit 98cdb6
 * in the Fixed container. */
Packit 98cdb6
static void move_button( GtkWidget *widget,
Packit 98cdb6
                         GtkWidget *fixed )
Packit 98cdb6
{
Packit 98cdb6
  x = (x + 30) % 300;
Packit 98cdb6
  y = (y + 50) % 300;
Packit 98cdb6
  gtk_fixed_move (GTK_FIXED (fixed), widget, x, y); 
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
int main( int   argc,
Packit 98cdb6
          char *argv[] )
Packit 98cdb6
{
Packit 98cdb6
  /* GtkWidget is the storage type for widgets */
Packit 98cdb6
  GtkWidget *window;
Packit 98cdb6
  GtkWidget *fixed;
Packit 98cdb6
  GtkWidget *button;
Packit 98cdb6
  gint i;
Packit 98cdb6
Packit 98cdb6
  /* Initialise GTK */
Packit 98cdb6
  gtk_init (&argc, &argv);
Packit 98cdb6
    
Packit 98cdb6
  /* Create a new window */
Packit 98cdb6
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
Packit 98cdb6
  gtk_window_set_title (GTK_WINDOW (window), "Fixed Container");
Packit 98cdb6
Packit 98cdb6
  /* Here we connect the "destroy" event to a signal handler */ 
Packit 98cdb6
  g_signal_connect (window, "destroy",
Packit 98cdb6
		    G_CALLBACK (gtk_main_quit), NULL);
Packit 98cdb6
 
Packit 98cdb6
  /* Sets the border width of the window. */
Packit 98cdb6
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
Packit 98cdb6
Packit 98cdb6
  /* Create a Fixed Container */
Packit 98cdb6
  fixed = gtk_fixed_new ();
Packit 98cdb6
  gtk_container_add (GTK_CONTAINER (window), fixed);
Packit 98cdb6
  gtk_widget_show (fixed);
Packit 98cdb6
  
Packit 98cdb6
  for (i = 1 ; i <= 3 ; i++) {
Packit 98cdb6
    /* Creates a new button with the label "Press me" */
Packit 98cdb6
    button = gtk_button_new_with_label ("Press me");
Packit 98cdb6
  
Packit 98cdb6
    /* When the button receives the "clicked" signal, it will call the
Packit 98cdb6
     * function move_button() passing it the Fixed Container as its
Packit 98cdb6
     * argument. */
Packit 98cdb6
    g_signal_connect (button, "clicked",
Packit 98cdb6
		      G_CALLBACK (move_button), (gpointer) fixed);
Packit 98cdb6
  
Packit 98cdb6
    /* This packs the button into the fixed containers window. */
Packit 98cdb6
    gtk_fixed_put (GTK_FIXED (fixed), button, i*50, i*50);
Packit 98cdb6
  
Packit 98cdb6
    /* The final step is to display this newly created widget. */
Packit 98cdb6
    gtk_widget_show (button);
Packit 98cdb6
  }
Packit 98cdb6
Packit 98cdb6
  /* Display the window */
Packit 98cdb6
  gtk_widget_show (window);
Packit 98cdb6
    
Packit 98cdb6
  /* Enter the event loop */
Packit 98cdb6
  gtk_main ();
Packit 98cdb6
    
Packit 98cdb6
  return 0;
Packit 98cdb6
}
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
CLASS="NAVFOOTER"
Packit 98cdb6
>
Packit 98cdb6
ALIGN="LEFT"
Packit 98cdb6
WIDTH="100%">
Packit 98cdb6
SUMMARY="Footer navigation table"
Packit 98cdb6
WIDTH="100%"
Packit 98cdb6
BORDER="0"
Packit 98cdb6
CELLPADDING="0"
Packit 98cdb6
CELLSPACING="0"
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="33%"
Packit 98cdb6
ALIGN="left"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>
Packit 98cdb6
HREF="x1243.html"
Packit 98cdb6
ACCESSKEY="P"
Packit 98cdb6
><<< Previous
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="34%"
Packit 98cdb6
ALIGN="center"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>
Packit 98cdb6
HREF="book1.html"
Packit 98cdb6
ACCESSKEY="H"
Packit 98cdb6
>Home
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="33%"
Packit 98cdb6
ALIGN="right"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>
Packit 98cdb6
HREF="x1279.html"
Packit 98cdb6
ACCESSKEY="N"
Packit 98cdb6
>Next >>>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="33%"
Packit 98cdb6
ALIGN="left"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>The Alignment widget
Packit 98cdb6
>
Packit 98cdb6
WIDTH="34%"
Packit 98cdb6
ALIGN="center"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>
Packit 98cdb6
HREF="c1226.html"
Packit 98cdb6
ACCESSKEY="U"
Packit 98cdb6
>Up
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
WIDTH="33%"
Packit 98cdb6
ALIGN="right"
Packit 98cdb6
VALIGN="top"
Packit 98cdb6
>Layout Container
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>
Packit 98cdb6
>