added set_default_size function

This commit is contained in:
maroy 2005-03-01 13:30:12 +00:00
parent 3a8cfa2bf1
commit 77d3d8a451
2 changed files with 44 additions and 3 deletions

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/include/LiveSupport/Widgets/WhiteWindow.h,v $
------------------------------------------------------------------------------*/
@ -69,11 +69,21 @@ using namespace LiveSupport::Core;
* A container holding exactly one child, habing a light blue border to it.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class WhiteWindow : public Gtk::Window
{
private:
/**
* The default width of the window, of -1, automatic.
*/
int defaultWidth;
/**
* The default height of the window, if -1, automatic
*/
int defaultHeight;
/**
* The rounded container for the window.
*/
@ -263,6 +273,16 @@ class WhiteWindow : public Gtk::Window
*/
Glib::ustring
get_title(void) const throw ();
/**
* Set the default size of the window.
*
* @param width the default width of the window.
* @param height the default height of the window.
*/
void
set_default_size(int width,
int height) throw ();
};

View File

@ -22,7 +22,7 @@
Author : $Author: maroy $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/widgets/src/WhiteWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -63,6 +63,8 @@ WhiteWindow :: WhiteWindow(Glib::ustring title,
: Gtk::Window(Gtk::WINDOW_TOPLEVEL)
{
set_decorated(false);
defaultWidth = -1;
defaultHeight = -1;
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
@ -137,6 +139,13 @@ void
WhiteWindow :: on_size_request(Gtk::Requisition* requisition) throw ()
{
Gtk::Window::on_size_request(requisition);
if (defaultWidth >= 0 && requisition->width < defaultWidth) {
requisition->width = defaultWidth;
}
if (defaultHeight >= 0 && requisition->height < defaultHeight) {
requisition->height = defaultHeight;
}
}
@ -300,3 +309,15 @@ WhiteWindow :: get_title(void) const throw ()
return title->get_label();
}
/*------------------------------------------------------------------------------
* Set the default window size.
*----------------------------------------------------------------------------*/
void
WhiteWindow :: set_default_size(int width,
int height) throw ()
{
defaultWidth = width;
defaultHeight = height;
}