Re: Getting the visible portion of a scrolled window

I figured out what I needed, but it was bizarrely difficult. I first had to use gtk_bin_get_child on the scrolled window to get the viewport; then I had to use gdk_window_get_position() on viewport->bin_window to get the (negative) x and y coordinates of the visible region, then gdk_window_get_size() on viewport->view_window to get the width and height of the visible region.

There *must* be a better way do get this information, but damned if I can find it.....this just seems too useful to make it so obscure to locate.

----- Original Message -----
From: Lindley M French <lfrench1 gmu edu>
Date: Wednesday, May 21, 2008 10:14 am
Subject: Getting the visible portion of a scrolled window

> I've got a scrolled window containing an OpenGL-enabled drawing 
> area, and I'm trying to implement drag-selection of OpenGL-
> rendered items.
> This works just fine so long at the entire area I'm selecting is 
> within the drawing area. However, if it isn't, the program crashes 
> because I can't control what's drawn there.
> Since the selection only includes a draw to the GL_BACK buffer and 
> no visible render, I'm not sure why the program can't draw there 
> just because that part of the window is "hidden" (scrolled away), 
> but let's not worry about that for now.
> What I'd like to do is limit the size of my drag-box to the 
> currently visible area. This works fine if my scrolled window has 
> no scroll bars and is completely visible; I can easily limit 
> myself to the bounds of the most recent configure event on the 
> drawing area.
> But how can I get the visible area of a scrolled window when it's 
> only partially visible, and scroll bars exist? There must be a way 
> to do it; *something* knows which part of the child to draw.
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org

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