Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/gtkbase/request_initial_size.cxx

Go to the documentation of this file.
00001 // Filename: request_initial_size.cxx
00002 // Created by:  drose (15Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "request_initial_size.h"
00020 
00021 static int
00022 restore_usize(Gtk::Widget *widget) {
00023   widget->set_usize(0, 0);
00024   return false;
00025 }
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: request_initial_size
00029 //  Description: Gtk-- hack to request an initial size for a widget,
00030 //               while still allowing the user to resize it smaller.
00031 ////////////////////////////////////////////////////////////////////
00032 void
00033 request_initial_size(Gtk::Widget &widget, int xsize, int ysize) {
00034   if (xsize != 0 || ysize != 0) {
00035     // I can't find a way to request an initial size for a general
00036     // widget.  The best I can do is specify its minimum size.
00037     widget.set_usize(xsize, ysize);
00038 
00039     // However, I don't want the minimum size to be enforced forever;
00040     // the user should be able to resize the window smaller if he wants
00041     // to.  Thus, this ugly hack: at the first idle signal, we return
00042     // the usize to 0.
00043     Gtk::Main::idle.connect(bind(slot(&restore_usize), &widget));
00044   }
00045 }
00046 

Generated on Fri May 2 03:20:05 2003 for Panda-Tool by doxygen1.3