Re: RV: How to update the current position of a widget...



The gdk_window_get_geometry didn't work. It returned nonsense values
such as xpos: 4 -- ypos: 24
But the window was created using
"gtk_widget_set_uposition(GTK_WIDGET(_pwindow),200,100);", so it should
have returned xpos: 200 -- ypos: 100.

I fixed it setting the new values by my own this way:

void ParamWindow::SetPosition(gint x, gint y)
{
  _pwindow->allocation.x = x;
  _pwindow->allocation.y = y;
  gtk_widget_set_uposition(GTK_WIDGET(_pwindow), x, y);
}

I don't think this is the best solution, but at least it works x)

Another newbie question hehehe. 
I've got a callback for a button's clicked event that creates a child
window. Of course, i only want to create ONE window, but when the window
is created.. if I continue clicking the button it creates everytime a
new window.How can I restrict this?

Ignacio Nodal


Ignacio Nodal wrote:
> 
> ----- Original Message -----
> From: Maher Awamy <muhri muhri net>
> To: Ignacio Nodal <inodal teleline es>; <gtk-list gnome org>
> Sent: Wednesday, February 21, 2001 10:12 PM
> Subject: Re: How to update the current position of a widget...
> 
> > you want to use gdk_window_get_geometry() function on your GetPosition
> > function like so
> >
> > gint x, y, w, h;
> > gdk_window_get_geometry(_pwindow->window, &x, &y, &w, &h);
> > then your x adn y should be correct :)
> >
> > Maher
> >
> > --
> > http://muhri.net - muhri muhri net
> > ----- Original Message -----
> > From: Ignacio Nodal <inodal teleline es>
> > To: <gtk-list gnome org>
> > Sent: Wednesday, February 21, 2001 9:38 PM
> > Subject: 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
> >




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