Re: Gtk::Table problem



Hi,
 
  after searching a while, i saw that it's queue_draw() function which have no effect if it has not been display once. So, i think that queue_draw() is not called because there is no area to update.
 
   How can i force my widget to display on my computer screen into my own function?
 
 
I really need help on this,
 
Thanks a lot
 
Mick
 
2006/6/20, Mickael Drean <mickael drean gmail com>:

Hi there,

In my Gtk::Window i add a "Gtk::Table" which contain some Gtk::Frame. In fact i can switch visualisation of different Table. I use it to draw some curve and i would like to export all the Table to picture. When i try to export onei succeed to create my picture but if i try to export all by starting from the first, export , switching to next, export , etc... i have picture of 1px by 1px. I tried to slow it and i saw that my table don't appear. I suppose that it's an graphical allocation problem.

Any idea?
 
 

here is a sample of my code :

void MyApp::export_all()

{

for (int i = 0; i< GetNbEcran() ;++i)

{

move_to_screen(i);

Glib::Timer time;

time.start();

while (time.elapsed() < 1 )

{

}

time.stop();

Glib::ustring str2 = "./ecran ";

std::ostringstream converter;

converter << (i+1);

str2 += converter.str();

str2 += ".bmp";

get_root_window()->show();

get_root_window()->process_all_updates();

queue_draw();

(*m_IterEcran)->export_to_bmp(str2);

}

}

void CEcran::export_to_bmp(Glib::ustring filename)

{

int w = 0;

int h = 0;

show_all_children();

Gtk::Allocation allocation = get_allocation();

GdkWindowAttr attributes;

memset(&attributes, 0, sizeof(attributes));

//Set initial position and size of the Gdk::Window:

attributes.x = allocation.get_x();

attributes.y = allocation.get_y();

attributes.width = allocation.get_width();

attributes.height = allocation.get_height();

attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;

attributes.window_type = GDK_WINDOW_CHILD;

attributes.wclass = GDK_INPUT_OUTPUT;

Glib::RefPtr<Gdk::Window> refGdkWindow = Gdk::Window::create(get_window() /* parent */, &attributes, GDK_WA_X | GDK_WA_Y);

refGdkWindow->process_all_updates ();

get_root_window()->show();

get_root_window()->process_all_updates();

refGdkWindow->get_size(w,h);

Glib::RefPtr<Gdk::Colormap> colormap = get_colormap();

Glib::RefPtr<Gdk::Image> img = Gdk::Image::create(Gdk::IMAGE_NORMAL ,get_visual(), w,h);

img = refGdkWindow->get_image(0,0,w,h);

Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(img, colormap, 0,0,0,0,w,h);

pixbuf->save(filename,"bmp");

}




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