The menu popup direction

View: New views
5 Messages — Rating Filter:   Alert me  

The menu popup direction

by XiuHua Wu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All:
       Can GTK+ control the menu popup direction ?? When I create a
popup menu and use the function gtk_menu_popup to show the menu, and the
menu alway pops from up to down. Is it possible to pop the menu from
down to up ?? I try to find solution for this from the Google search and
the GTK document, but with no luck. Any help is highly appreciated.

--
Sincerely,
Vanevan
xhwu@...

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: The menu popup direction

by Mike Massonnet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le Wed, 24 Sep 2008 16:16:20 +0800,
XiuHua Wu <xhwu@...> a écrit :

> Hi All:
>        Can GTK+ control the menu popup direction ?? When I create a
> popup menu and use the function gtk_menu_popup to show the menu, and
> the menu alway pops from up to down. Is it possible to pop the menu
> from down to up ?? I try to find solution for this from the Google
> search and the GTK document, but with no luck. Any help is highly
> appreciated.

When you call gtk_menu_popup you can pass a GtkMenuPositionFunc.
Define such a function, and that's where you will be able to define
the x and y position of your menu.

Mike
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: The menu popup direction

by XiuHua Wu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I know it can use this function to determine the position of the
menu. But if the menu is dynamic, I mean the length is not fixed and can
be changed during the program running, so the menu position must be
calculated every time. If the menu can be dropped from down to up, and
it only needs to determine the menu start position just like dropped
from up to down. So is there  any method to make the menu popup from up
to down ?? Or I must do this by myself using the GtkMenuPositionFunc
function ??

 
Mike Massonnet wrote:

> Le Wed, 24 Sep 2008 16:16:20 +0800,
> XiuHua Wu <xhwu@...> a 茅crit :
>
>  
>> Hi All:
>>        Can GTK+ control the menu popup direction ?? When I create a
>> popup menu and use the function gtk_menu_popup to show the menu, and
>> the menu alway pops from up to down. Is it possible to pop the menu
>> from down to up ?? I try to find solution for this from the Google
>> search and the GTK document, but with no luck. Any help is highly
>> appreciated.
>>    
>
> When you call gtk_menu_popup you can pass a GtkMenuPositionFunc.
> Define such a function, and that's where you will be able to define
> the x and y position of your menu.
>
> Mike
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@...
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


--
Sincerely,
Vanevan
xhwu@...

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: The menu popup direction

by Mike Massonnet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le Thu, 25 Sep 2008 09:00:21 +0800,
XiuHua Wu <xhwu@...> a écrit :

> Yes, I know it can use this function to determine the position of the
> menu. But if the menu is dynamic, I mean the length is not fixed and
> can be changed during the program running, so the menu position must
> be calculated every time. If the menu can be dropped from down to up,
> and it only needs to determine the menu start position just like
> dropped from up to down. So is there  any method to make the menu
> popup from up to down ?? Or I must do this by myself using the
> GtkMenuPositionFunc function ??

You still do this in the position func.  You must get the requisition
of your menu in this function with gtk_widget_size_request(), and to
get the bottom of menu at the cursor you would just have to substract
the req.height to y.

Hint:
GtkRequisition req;
gtk_widget_size_request (menu, &req);
*y -= req.height;

Mike
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: The menu popup direction

by XiuHua Wu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It works. Thanks very much!

Mike Massonnet wrote:

> Le Thu, 25 Sep 2008 09:00:21 +0800,
> XiuHua Wu <xhwu@...> a 茅crit :
>
>  
>> Yes, I know it can use this function to determine the position of the
>> menu. But if the menu is dynamic, I mean the length is not fixed and
>> can be changed during the program running, so the menu position must
>> be calculated every time. If the menu can be dropped from down to up,
>> and it only needs to determine the menu start position just like
>> dropped from up to down. So is there  any method to make the menu
>> popup from up to down ?? Or I must do this by myself using the
>> GtkMenuPositionFunc function ??
>>    
>
> You still do this in the position func.  You must get the requisition
> of your menu in this function with gtk_widget_size_request(), and to
> get the bottom of menu at the cursor you would just have to substract
> the req.height to y.
>
> Hint:
> GtkRequisition req;
> gtk_widget_size_request (menu, &req);
> *y -= req.height;
>
> Mike
>
>  


--
Sincerely,
Vanevan
xhwu@...

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
LightInTheBox - Buy quality products at wholesale price!