void wxPizza::scroll(int dx, int dy) { GtkWidget* widget = GTK_WIDGET(this); if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL) dx = -dx; m_scroll_x -= dx; m_scroll_y -= dy; if (widget->window) { gdk_window_scroll(widget->window, dx, dy); // Adjust child allocations. Doing a queue_resize on the children is not // enough, sometimes they redraw in the wrong place during fast scrolling. AdjustData data = { widget->window, dx, dy }; gtk_container_forall(GTK_CONTAINER(widget), scroll_adjust, &data); } }
static void scroll_window_clicked (GtkWidget *button, gpointer data) { GdkWindow *window; GtkDirectionType direction; GList *selected, *l; gint dx, dy; direction = GPOINTER_TO_INT (data); selected = get_selected_windows (); dx = 0; dy = 0; switch (direction) { case GTK_DIR_UP: dy = 10; break; case GTK_DIR_DOWN: dy = -10; break; case GTK_DIR_LEFT: dx = 10; break; case GTK_DIR_RIGHT: dx = -10; break; default: break; } for (l = selected; l != NULL; l = l->next) { window = l->data; gdk_window_scroll (window, dx, dy); } g_list_free (selected); }
/* Scroll a rectangular region up or down by a fixed number of lines. */ static void vga_scroll_region(VGAText *vga, long row, long count, long delta) { GtkWidget *widget; gboolean repaint = TRUE; if ((delta == 0) || (count == 0)) return; /* We only do this if we're scrolling the entire window. */ if (row == 0 && count == vga->rows) { widget = GTK_WIDGET(vga); gdk_window_scroll(widget->window, 0, delta * vga->pvt->font->height); repaint = FALSE; } if (repaint) { /* We have to repaint the entire area. */ vga_invalidate_cells(vga, 0, vga->cols, row, count); } }
static VALUE gdkwin_scroll(VALUE self, VALUE dx, VALUE dy) { gdk_window_scroll(_SELF(self), NUM2INT(dx), NUM2INT(dy)); return self; }
void moz_drawingarea_scroll (MozDrawingarea *drawingarea, gint x, gint y) { gdk_window_scroll(drawingarea->inner_window, x, y); }
void help(char *file) { char fullspec[1024], *temp, *pt; if ( browser[0]=='\0' ) findbrowser(); #ifndef __CygWin if ( browser[0]=='\0' ) { gwwv_post_error(_("No Browser"),_("Could not find a browser. Set the BROWSER environment variable to point to one")); return; } #endif if ( strstr(file,"http://")==NULL ) { fullspec[0] = 0; if ( *file!='/' ) { if ( helpdir==NULL || *helpdir=='\0' ) { #ifdef DOCDIR strcpy(fullspec,DOCDIR "/"); #elif defined(SHAREDIR) strcpy(fullspec,SHAREDIR "/doc/fontforge/"); #else strcpy(fullspec,"/usr/local/share/doc/fontforge/"); #endif } else strcpy(fullspec,helpdir); } strcat(fullspec,file); if (( pt = strrchr(fullspec,'#') )!=NULL ) *pt ='\0'; if ( !GFileReadable( fullspec )) { if ( *file!='/' ) { strcpy(fullspec,"/usr/share/doc/fontforge/"); strcat(fullspec,file); if (( pt = strrchr(fullspec,'#') )!=NULL ) *pt ='\0'; } } if ( !GFileReadable( fullspec )) { strcpy(fullspec,"http://fontforge.sf.net/"); AppendSupportedLocale(fullspec); strcat(fullspec,file); } else if ( pt!=NULL ) *pt = '#'; } else strcpy(fullspec,file); #if __CygWin if ( (strstrmatch(browser,"/cygdrive")!=NULL || browser[0]=='\0') && strstr(fullspec,":/")==NULL ) { /* It looks as though the browser is a windows application, so we */ /* should give it a windows file name */ char *pt, *tpt; temp = galloc(1024); cygwin_conv_to_full_win32_path(fullspec,temp); for ( pt = fullspec, tpt = temp; *tpt && pt<fullspec+sizeof(fullspec)-3; *pt++ = *tpt++ ) if ( *tpt=='\\' ) *pt++ = '\\'; *pt = '\0'; free(temp); } #endif #if __Mac if ( strcmp(browser,"open")==0 ) /* open doesn't want "file:" prepended */; else #endif if ( strstr(fullspec,":/")==NULL ) { char *t1 = galloc(strlen(fullspec)+strlen("file:")+20); #if __CygWin sprintf( t1, "file:\\\\\\%s", fullspec ); #else sprintf( t1, "file:%s", fullspec); #endif strcpy(fullspec,t1); free(t1); } #if 0 && __Mac /* Starting a Mac application is weird... system() can't do it */ /* Thanks to Edward H. Trager giving me an example... */ if ( strstr(browser,".app")!=NULL ) { *strstr(browser,".app") = '\0'; pt = strrchr(browser,'/'); if ( pt==NULL ) pt = browser-1; ++pt; temp = galloc(strlen(pt)+strlen(fullspec) + strlen( "osascript -l AppleScript -e \"Tell application \"\" to getURL \"\"\"" )+ 20); /* this doesn't work on Max OS X.0 (osascript does not support -e) */ sprintf( temp, "osascript -l AppleScript -e \"Tell application \"%s\" to getURL \"%s\"\"", pt, fullspec); system(temp); ff_post_notice(_("Leave X"),_("A browser is probably running in the native Mac windowing system. You must leave the X environment to view it. Try Cmd-Opt-A")); } else { #elif __Mac /* This seems a bit easier... Thanks to riggle */ if ( strcmp(browser,"open")==0 ) { temp = galloc(strlen(browser) + strlen(fullspec) + 20); sprintf( temp, "open \"%s\" &", fullspec ); system(temp); ff_post_notice(_("Leave X"),_("A browser is probably running in the native Mac windowing system. You must leave the X environment to view it. Try Cmd-Opt-A")); } else { #elif __CygWin if ( browser[0]=='\0' ) { do_windows_browser(fullspec); temp = NULL; } else { #else { #endif temp = galloc(strlen(browser) + strlen(fullspec) + 20); sprintf( temp, strcmp(browser,"kfmclient openURL")==0 ? "%s \"%s\" &" : "\"%s\" \"%s\" &", browser, fullspec ); system(temp); } free(temp); } #define MAX_ERR_LINES 200 static struct errordata { char *errlines[MAX_ERR_LINES]; int fh, as; GtkWidget *vsb; GtkWidget *gw, *v; PangoLayout *layout; int cnt, linecnt; int offtop; int showing; } errdata; static void Warning_Hide(void) { gdk_window_hide(errdata.gw->window); errdata.showing = false; } static void Warning_VScroll(GtkRange *vsb, gpointer user_data) { GtkAdjustment *sb; sb = gtk_range_get_adjustment(GTK_RANGE(vsb)); if ( sb->value!=errdata.offtop) { int diff = sb->value-errdata.offtop; errdata.offtop = sb->value; gdk_window_scroll(GDK_WINDOW(errdata.v->window),0,diff*errdata.fh); } } static gboolean Warning_Resize(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { GtkAdjustment *sb; errdata.linecnt = widget->allocation.width/errdata.fh; sb = gtk_range_get_adjustment(GTK_RANGE(errdata.vsb)); sb->lower = 0; sb->upper = errdata.cnt; sb->page_size = errdata.linecnt; sb->step_increment = 1; sb->page_increment = errdata.linecnt; if ( errdata.offtop>=errdata.cnt-errdata.linecnt ) errdata.offtop = errdata.cnt-errdata.linecnt; if ( errdata.offtop<0 ) errdata.offtop =0; sb->value = errdata.offtop; gtk_range_set_adjustment(GTK_RANGE(errdata.vsb),sb); return 0; }
/* Scrolls the view to the specified offsets. */ static void scroll_to (ImageView *view, int x, int y, gboolean change_adjustments) { ImageViewPrivate *priv; int xofs, yofs; GdkWindow *window; int width, height; int src_x, src_y; int dest_x, dest_y; int twidth, theight; priv = view->priv; /* Check bounds */ x = CLAMP (x, 0, priv->hadj->upper - priv->hadj->page_size); y = CLAMP (y, 0, priv->vadj->upper - priv->vadj->page_size); /* Compute offsets */ xofs = x - priv->xofs; yofs = y - priv->yofs; if (xofs == 0 && yofs == 0) return; priv->xofs = x; priv->yofs = y; if (!GTK_WIDGET_DRAWABLE (view)) goto out; width = GTK_WIDGET (view)->allocation.width; height = GTK_WIDGET (view)->allocation.height; if (abs (xofs) >= width || abs (yofs) >= height) { GdkRectangle area; area.x = 0; area.y = 0; area.width = width; area.height = height; request_paint_area (view, &area); goto out; } window = GTK_WIDGET (view)->window; /* Ensure that the uta has the full size */ twidth = (width + ART_UTILE_SIZE - 1) >> ART_UTILE_SHIFT; theight = (height + ART_UTILE_SIZE - 1) >> ART_UTILE_SHIFT; if (priv->uta) g_assert (priv->idle_id != 0); else priv->idle_id = g_idle_add (paint_iteration_idle, view); priv->uta = uta_ensure_size (priv->uta, 0, 0, twidth, theight); /* Copy the uta area. Our synchronous handling of expose events, below, * will queue the new scrolled-in areas. */ src_x = xofs < 0 ? 0 : xofs; src_y = yofs < 0 ? 0 : yofs; dest_x = xofs < 0 ? -xofs : 0; dest_y = yofs < 0 ? -yofs : 0; uta_copy_area (priv->uta, src_x, src_y, dest_x, dest_y, width - abs (xofs), height - abs (yofs)); /* Scroll the window area and process exposure synchronously. */ gdk_window_scroll (window, -xofs, -yofs); gdk_window_process_updates (window, TRUE); out: if (!change_adjustments) return; g_signal_handlers_block_matched ( priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); g_signal_handlers_block_matched ( priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); priv->hadj->value = x; priv->vadj->value = y; g_signal_emit_by_name (priv->hadj, "value_changed"); g_signal_emit_by_name (priv->vadj, "value_changed"); g_signal_handlers_unblock_matched ( priv->hadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); g_signal_handlers_unblock_matched ( priv->vadj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, view); }