Fwd: Re: resizing a drawingarea

On 04/10/2011 08:03 PM, Robert Pearce wrote:
 Hi Kees,

 On Sun, 10 Apr 2011 15:54:06 +0200 you wrote:
   In this method I call ste_allocation(allocation) and I check on
 several places in my code what the geometry of the widget is and these
 are correct, but my drawingArea keeps its orginal  size.
 Just to clarify, please:

 When you say "these are correct" above, what do you mean? Do you mean
 you've formally proved that code, or that you've put in debug printfs
 and shown that the geometry found in those places follows the re-sizing
 that your drawing area doesn't?

 Either way, I think we probably need to see your code. In particular,
 how is the drawing area packed? Is it directly in the window? Or is it
 nested in something that could be allocating the extra space elsewhere?

 gtkmm-list mailing list
 gtkmm-list gnome org

Hi Rob,


I wrote a small test widget in which you can see the behaviour of the
drawingarea. I packed it in a mainwindow by adding it. I also tried to
do this with a frame around it and the frame is resizing, but not the
drawing area. You can see in the small blue area that the line is
changing, so expose works

Here my code:



#ifndef testArea_H_
#define testArea_H_


using namespace std;

class testArea : public Gtk::DrawingArea {

    virtual ~testArea();
private :
    void status();

    virtual void on_size_request(Gtk::Requisition* requisition);
    virtual void on_size_allocate(Gtk::Allocation&  allocation);
    virtual void on_map();
    virtual void on_unmap();
    virtual void on_realize();
    virtual void on_unrealize();
    virtual bool on_expose_event(GdkEventExpose* event);
    virtual bool on_configure_event(GdkEventConfigure* event);


#endif /* testArea_H_ */



#include "testArea.h" testArea::testArea() { cout<<"ctor"<<endl; status(); signal_configure_event().connect(sigc::mem_fun(*this, &testArea::on_configure_event)); cout<<"end ctor"<<endl; } testArea::~testArea() { cout<<"dtor"<<endl; } void testArea::status() { cout<<" "<<get_width()<<" widget_size "<<get_height()<<endl; } void testArea::on_size_request(Gtk::Requisition* requisition) { cout<<"on_size_requiest"; *requisition = Gtk::Requisition(); requisition->height = 50; requisition->width = 50; status(); } void testArea::on_size_allocate(Gtk::Allocation& allocation){ set_allocation(allocation); cout<<"on_size_allocate"; status(); } void testArea::on_map(){ Gtk::Widget::on_map(); cout<<"on_map"; status(); } void testArea::on_unmap(){ Gtk::Widget::on_unmap(); cout<<"on_unmap"; status(); } void testArea::on_realize(){ Gtk::Widget::on_realize(); cout<<"on_realize"; status(); } void testArea::on_unrealize(){ Gtk::Widget::on_unrealize(); cout<<"on_unrealize"; status(); } bool testArea::on_configure_event(GdkEventConfigure* event) { cout<<"configure"<<endl; status(); return false; } bool testArea::on_expose_event(GdkEventExpose* event){ cout<<"on_expose"; status(); Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context(); Gtk::Allocation alloc = get_allocation(); double w = alloc.get_width(); double h = alloc.get_height(); // paint background context->set_source_rgb(0.62, 0.78, 0.76); context->paint(); context->set_source_rgb(0.0, 0.0, 0.5); context->move_to(10,10); context->line_to(w-30, h-50); context->stroke(); return false; }




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