specify which child widget to be on top in GtkFixed?!

2010-02-09 Thread ferar achkar
greetings,
I'm having trouble with GtkFixed and their children, how can I specify
which child widget to be on top. In the code snippet below no matter
were I create the TextEntry it always get drawn on top of the other
widgets! how can specify which child widget to be on top of the others
at run time / or at  compile time.
regards,
ferar

/***
*   Copyright (C) 2009 by ferar   *
*   fe...@druid   *
* *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or *
*   (at your option) any later version.   *
* *
*   This program is distributed in the hope that it will be useful,   *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of*
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *
*   GNU General Public License for more details.  *
* *
*   You should have received a copy of the GNU General Public License *
*   along with this program; if not, write to the *
*   Free Software Foundation, Inc.,   *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
***/

#include gtk/gtk.h
#include string
using namespace std;
GtkWidget* fixedviewo = NULL;
GtkWidget* FocusEntry = NULL;
GtkWidget* next_cache_page = NULL;
GtkWidget* prev_cache_page = NULL;
gint x=5;
gint y=5;
gint x2=5;

gboolean OnLabelButtonPress ( GtkWidget   *widget, 
GdkEventButton  *event, gpointer user_data )
{

// GList *children = gtk_container_get_children ( GTK_CONTAINER (
fixedviewo ) );
//
// while ( children )
// {
// string typeo (g_type_name( GTK_WIDGET_TYPE( children-data ) ));
// if(typeo == GtkButton)
// {
// gint xx, yy;
// gdk_window_get_origin(((GtkWidget*)( children-data
))-window,xx,yy);
// const gchar* labelo = gtk_button_get_label ((GtkButton*)(
children-data )) ;
// printf(Type: %s, Label is: %s\n,typeo.c_str(), labelo);
// }
//
// children = g_list_next ( children );
// }
x+=4;
x2+=6;
gtk_fixed_move ( GTK_FIXED ( fixedviewo ), next_cache_page, x++, y++ );
gtk_fixed_move ( GTK_FIXED ( fixedviewo ), prev_cache_page, x2, y );
return FALSE;
}

int
main ( intargc,
   char **argv )
{
/* Initialization */
gtk_init ( argc, argv );

GtkWidget* splash_widget = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
gtk_window_set_position ( GTK_WINDOW ( splash_widget ),
GTK_WIN_POS_CENTER_ALWAYS );
gtk_window_set_gravity ( GTK_WINDOW ( splash_widget ),
GDK_GRAVITY_CENTER );
g_signal_connect ( G_OBJECT ( splash_widget ), destroy, G_CALLBACK
( gtk_main_quit ), NULL );
GtkWidget* vbox = gtk_vbox_new ( FALSE, 0 );
gtk_container_add ( ( GtkContainer* ) splash_widget, vbox );
GtkWidget* progress_spitout = gtk_button_new_with_label ( move the
buttons up );
g_signal_connect ( ( gpointer ) progress_spitout, pressed,
   G_CALLBACK ( OnLabelButtonPress ),
   NULL );
fixedviewo = gtk_fixed_new ();
gtk_widget_show ( fixedviewo );
gtk_container_add ( GTK_CONTAINER ( vbox ), fixedviewo );

FocusEntry = gtk_entry_new ();
gtk_fixed_put ( GTK_FIXED ( fixedviewo ), FocusEntry, 10, 0 );

prev_cache_page = gtk_button_new_with_label ( GTK_STOCK_GO_BACK );
gtk_fixed_put ( GTK_FIXED ( fixedviewo ), prev_cache_page, 30, 0 );
// gtk_widget_set_size_request ( prev_cache_page, 60, 26 );
gtk_widget_show ( prev_cache_page );

next_cache_page = gtk_button_new_from_stock ( GTK_STOCK_GO_FORWARD );
gtk_fixed_put ( GTK_FIXED ( fixedviewo ), next_cache_page, 100, 0 );
// gtk_widget_set_size_request ( next_cache_page, 60, 26 );
gtk_widget_show ( next_cache_page );




gtk_container_add ( GTK_CONTAINER ( vbox ), progress_spitout );

gtk_widget_show_all ( splash_widget );

gtk_main();

return ( 0 );
}

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: specify which child widget to be on top in GtkFixed?!

2010-02-09 Thread Tristan Van Berkom
Widgets dont overlap in GTK+, instead one widget is packed into another
widget and sits along side other widgets inside its container - who packs
them in a way that they will not overlap.

FYI, GtkFixed is a special case widget you dont want to be using if your
application has any resize capabilities at all (yes, GtkFixed places widgets
on top of eachother when you forgot to place them with enough space between
them, because GtkFixed assumes you are using all the width/height available;
but there is no conceptual Z coordinate).

If you need to have widgets that overlap, you might consider using a canvas
api (like goocanvas for instance), or maybe use clutter.

Cheers,
  -Tristan

On Tue, Feb 9, 2010 at 9:21 AM, ferar achkar fachkar.dataw...@gmail.com wrote:
 greetings,
 I'm having trouble with GtkFixed and their children, how can I specify
 which child widget to be on top. In the code snippet below no matter
 were I create the TextEntry it always get drawn on top of the other
 widgets! how can specify which child widget to be on top of the others
 at run time / or at  compile time.
 regards,
 ferar

 /***
 *   Copyright (C) 2009 by ferar   *
 *   fe...@druid   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***/

 #include gtk/gtk.h
 #include string
 using namespace std;
 GtkWidget* fixedviewo = NULL;
 GtkWidget* FocusEntry = NULL;
 GtkWidget* next_cache_page = NULL;
 GtkWidget* prev_cache_page = NULL;
 gint x=5;
 gint y=5;
 gint x2=5;

 gboolean OnLabelButtonPress ( GtkWidget       *widget,
 GdkEventButton  *event,     gpointer         user_data )
 {

 //     GList *children = gtk_container_get_children ( GTK_CONTAINER (
 fixedviewo ) );
 //
 //     while ( children )
 //     {
 //         string typeo (g_type_name( GTK_WIDGET_TYPE( children-data ) ));
 //         if(typeo == GtkButton)
 //         {
 //             gint xx, yy;
 //             gdk_window_get_origin(((GtkWidget*)( children-data
 ))-window,xx,yy);
 //             const gchar* labelo = gtk_button_get_label ((GtkButton*)(
 children-data )) ;
 //             printf(Type: %s, Label is: %s\n,typeo.c_str(), labelo);
 //         }
 //
 //         children = g_list_next ( children );
 //     }
    x+=4;
    x2+=6;
    gtk_fixed_move ( GTK_FIXED ( fixedviewo ), next_cache_page, x++, y++ );
    gtk_fixed_move ( GTK_FIXED ( fixedviewo ), prev_cache_page, x2, y );
    return FALSE;
 }

 int
 main ( int    argc,
       char **argv )
 {
    /* Initialization */
    gtk_init ( argc, argv );

    GtkWidget* splash_widget = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
    gtk_window_set_position ( GTK_WINDOW ( splash_widget ),
 GTK_WIN_POS_CENTER_ALWAYS );
    gtk_window_set_gravity ( GTK_WINDOW ( splash_widget ),
 GDK_GRAVITY_CENTER );
    g_signal_connect ( G_OBJECT ( splash_widget ), destroy, G_CALLBACK
 ( gtk_main_quit ), NULL );
    GtkWidget* vbox = gtk_vbox_new ( FALSE, 0 );
    gtk_container_add ( ( GtkContainer* ) splash_widget, vbox );
    GtkWidget* progress_spitout = gtk_button_new_with_label ( move the
 buttons up );
    g_signal_connect ( ( gpointer ) progress_spitout, pressed,
                       G_CALLBACK ( OnLabelButtonPress ),
                       NULL );
    fixedviewo = gtk_fixed_new ();
    gtk_widget_show ( fixedviewo );
    gtk_container_add ( GTK_CONTAINER ( vbox ), fixedviewo );

    FocusEntry = gtk_entry_new ();
    gtk_fixed_put ( GTK_FIXED ( fixedviewo ), FocusEntry, 10, 0 );

    prev_cache_page = gtk_button_new_with_label ( GTK_STOCK_GO_BACK );
    gtk_fixed_put ( GTK_FIXED ( fixedviewo ), prev_cache_page, 30, 0 );
 //     gtk_widget_set_size_request ( prev_cache_page, 60, 26 );
    gtk_widget_show ( prev_cache_page );

    next_cache_page = gtk_button_new_from_stock (