Re: how to shrink a window



See https://developer.gnome.org/gtkmm/stable/classGtk_1_1Widget.html#a5e95431f630a226b0b7297e4815ee945 under set_size_request:

"In most cases, Gtk::Window::set_default_size() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, Gtk::Window::set_geometry_hints() can be a useful function as well."

Perhaps the reference to users is overly restrictive, since not allowing shrinkage applies to code as well.

On 2015/02/17 10:46, Klaus Rudolph wrote:
I have a very simply problem: I want to shrink a window but I can't get it run.
The call to set_size_request seems to resize the window ONLY if it should be bigger as before. The simple 
question is: How can I shrink a window?

Minimized Example Code:

#include <iostream>
#include <gtkmm.h>
#include <goocanvasmm.h>

Goocanvas::Canvas* canvas;
Gtk::ScrolledWindow* sw;
Gtk::Window* winptr;

bool Do( const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* ev)
{
     std::cout << "Do" << std::endl;
     //sw->set_size_request( 400,400); // make the window bigger works
     sw->set_size_request( 100,100); // shrink the window fails! why? Whats to do?

     return true;
}

int main(int argc, char *argv[])
{
     Gtk::Main kit(argc, argv);
     Goocanvas::init("Simu", "0.1", argc, argv);

     canvas=new Goocanvas::Canvas;

     canvas->set_size_request(300, 300);
     canvas->set_bounds(0, 0, 300, 300);



     Glib::RefPtr<Goocanvas::Item> root = canvas->get_root_item();

     Glib::RefPtr<Goocanvas::Ellipse> outer = Goocanvas::Ellipse::create( 100,100,20,20);
     outer->property_line_width() = 5;
     outer->property_stroke_color() = "red";
     outer->property_fill_color()="blue";
     root->add_child( outer );

     sigc::connection conn2= outer->signal_button_press_event().connect( sigc::ptr_fun(&Do));

     sw = Gtk::manage(new Gtk::ScrolledWindow());
     sw->add(*canvas);

     Gtk::VBox hbox;
     hbox.add(*sw);

     Gtk::Window win;
     winptr=&win;
     win.add(hbox);
     win.show_all_children();

     sw->set_size_request( 200,200);

     Gtk::Main::run(win);
     delete canvas;
}

Regards
  Klaus
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

--
We're not giving up. We're waiting for a better opportunity to win.
    -- Lois McMaster Bujold


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