Resizing window with Images.



Hi,

I have an application that reads picture from a file and shows it in a window. The problem is with resizing main window: image is not scaled and widgets are left as they showed up at first /Image is showed in Gtk::Image widget/. I found only this:

  1. connect to signal_check_size() of the Main Window.
  2. call resize_children() from function say on_signal_check_size()

But if I try to scale Image in on_signal_check_size() my application simply hangs up. Is there any way to connect to a sort of "resize" signal that is emitted only as Window's size is really changed and mouse button released /user finished playing with borders and window is let alone/?

One more thing. I have a button in my program that should maximize Window. I was surfing Internet + Google and found only one working idea of implementing it /simple resize does not give desired effect/:

  while( Gtk::Main::events_pending()){
    // Processing pending events
    Gtk::Main::iteration( false);
  }
  get_window()->resize( nWidth, nHeight);
  while(Gtk::Main::events_pending()){
    // Processing pending events
    Gtk::Main::iteration(false);
  }
  move( nXPos, nYPos);
  resize_children();

Now I have to resize image after maximization but simple line like /I add it right after resize_children() call/:

_oImage.set( _oPixBuf->scale_simple( _oFrame.get_width() - _nXPad * 2, _oFrame.get_height() - _nYPad * 2, Gdk::INTERP_NEAREST));

does not work correctly /Image is put into a Frame and Frame is in Window; _nXPad, _nYPad - padding's inside frame/. It looks like resize_children() does not affect widgets immediately so _oPixBuf is not scaled correctly because Frame didn't change it's size yet: the Image is scaled according to the last used Frame size. Suppose you have screen 1600x1200 and initial frame of 640x480. You press button and image is not scaled but window is maximized. You press button again /reverse action - get back into a last used geometry: 1600x1200 -> 640x480/ and image is scaled to 1600x1200 but frame now is 640x480 though resize_children() is called before scaling Image.

Any ideas? Help is really appreciated.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/



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