How to update the current position of a widget...



How can i update the current position of a widget?

I'm programming using C++,but working with GTK+, not gtk--. Why??
Well,because that is what i've been asked for... :)

By the way i've got a class and this class has two fuctions like these
ones:


void ParamWindow::SetPosition(gint x, gint y)
{
  gtk_widget_set_uposition(GTK_WIDGET(_pwindow), x, y);
  g_print("_pwindow->allocation.x: %d -- _pwindow->allocation.y:
%d\n",x,y);
}

void ParamWindow::GetPosition(gint* x, gint* y)
{
  *x = _pwindow->allocation.x;
  *y = _pwindow->allocation.y;
}

To make some tests, i've just put a button with a callback which should
change the current position of my widget:

void button_callback(GtkWidget *widget, ParamWindow* pw)
{
  gint xpos,ypos;
  pw->GetPosition(&xpos,&ypos);
  g_print("xpos: %d -- ypos: %d\n",xpos,ypos);
  pw->SetPosition(xpos+50,ypos+25);
}

The first time it returns the correct position and the widget is moved
as expected.
But then... the GetPosition function returns always the same values for
xpos and ypos.
Why does "gtk_widget_set_uposition(GTK_WIDGET(_pwindow), x, y)" in my
SetPosition function move the window and print the correct updated
"allocation.x" and "allocation.y" when they seem not to be properly
updated?

Here's the output for several button's clicks...

xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125
(Here the window is correctily move from (200,100) to (250,125) but when
i try another click...)
xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125
xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125
xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125
xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125
xpos: 200 -- ypos: 100
_pwindow->allocation.x: 250 -- _pwindow->allocation.y: 125


Sorry for my bad, bad english...

Ignacio Nodal




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