/* Queue a redraw of the dnd highlight rect */ static void dnd_highlight_queue_redraw (GtkWidget *widget) { NemoIconDndInfo *dnd_info; int width, height; GtkAllocation allocation; dnd_info = NEMO_ICON_CONTAINER (widget)->details->dnd_info; if (!dnd_info->highlighted) { return; } gtk_widget_get_allocation (widget, &allocation); width = allocation.width; height = allocation.height; /* we don't know how wide the shadow is exactly, * so we expose a 10-pixel wide border */ gtk_widget_queue_draw_area (widget, 0, 0, width, 10); gtk_widget_queue_draw_area (widget, 0, 0, 10, height); gtk_widget_queue_draw_area (widget, 0, height - 10, width, 10); gtk_widget_queue_draw_area (widget, width - 10, 0, 10, height); }
/** * gtk_image_tool_selector_set_selection: * @selector: a #GtkImageToolSelector * @rect: Selection rectangle in image space coordinates. * * Sets the selection rectangle for the tool. Setting this attribute * will cause the widget to immediately repaint itself if its view is * realized. * * This method does nothing under the following circumstances: * * <itemizedlist> * <listitem>If the views pixbuf is %NULL.</listitem> * <listitem>If @rect is wider or taller than the size of the * pixbuf</listitem> * <listitem>If @rect equals the current selection * rectangle.</listitem> * </itemizedlist> * * If the selection falls outside the pixbufs area, its position is * moved so that it is within the pixbuf. * * Calling this method causes the ::selection-changed signal to be * emitted. * * The default selection is (0,0) - [0,0]. **/ void gtk_image_tool_selector_set_selection (GtkImageToolSelector *selector, GdkRectangle *rect) { GtkImageView *view = selector->view; GdkPixbuf *pixbuf = gtk_image_view_get_pixbuf (view); if (!pixbuf) return; int width = gdk_pixbuf_get_width (pixbuf); int height = gdk_pixbuf_get_height (pixbuf); if (rect->width > width || rect->height > height) return; rect->x = CLAMP (rect->x, 0, width - rect->width); rect->y = CLAMP (rect->y, 0, height - rect->height); if (gdk_rectangle_eq (*rect, selector->sel_rect)) return; GdkRectangle wid_old = {0}, wid_new = {0}; gtk_image_view_image_to_widget_rect (view, &selector->sel_rect, &wid_old); gtk_image_view_image_to_widget_rect (view, rect, &wid_new); selector->sel_rect = *rect; gtk_widget_queue_draw_area (GTK_WIDGET (view), wid_old.x, wid_old.y, wid_old.width, wid_old.height); gtk_widget_queue_draw_area (GTK_WIDGET (view), wid_new.x, wid_new.y, wid_new.width, wid_new.height); g_signal_emit (G_OBJECT (selector), gtk_image_tool_selector_signals[0], 0); }
static void gimp_ruler_queue_pos_redraw (GimpRuler *ruler) { GimpRulerPrivate *priv = GIMP_RULER_GET_PRIVATE (ruler); const GdkRectangle rect = gimp_ruler_get_pos_rect (ruler, priv->position); gtk_widget_queue_draw_area (GTK_WIDGET(ruler), rect.x, rect.y, rect.width, rect.height); if (priv->last_pos_rect.width != 0 || priv->last_pos_rect.height != 0) { gtk_widget_queue_draw_area (GTK_WIDGET(ruler), priv->last_pos_rect.x, priv->last_pos_rect.y, priv->last_pos_rect.width, priv->last_pos_rect.height); priv->last_pos_rect.x = 0; priv->last_pos_rect.y = 0; priv->last_pos_rect.width = 0; priv->last_pos_rect.height = 0; } }
void Widget::invalidateRect(const IntRect& rect) { if (data->suppressInvalidation) return; if (!parent()) { gtk_widget_queue_draw_area(GTK_WIDGET(containingWindow()), rect.x(), rect.y(), rect.width(), rect.height()); if (isFrameView()) static_cast<FrameView*>(this)->addToDirtyRegion(rect); return; } // Get the root widget. ScrollView* outermostView = parent(); while (outermostView && outermostView->parent()) outermostView = outermostView->parent(); if (!outermostView) return; IntRect windowRect = convertToContainingWindow(rect); gtk_widget_queue_draw_area(GTK_WIDGET(containingWindow()), windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height()); outermostView->addToDirtyRegion(windowRect); }
void move_item(struct gropes_state *gs, struct map_state *ms, struct item_on_screen *item, const struct gps_coord *pos, struct gps_speed *speed) { GdkRectangle *area; area = &item->area; if (pos == NULL) { /* If the position was already invalid, we don't have to * do anything */ item->pos_valid = item->on_screen = 0; if (item->update_info) item->update_info(ms, item); } else { GdkRectangle old_area; int was_valid; /* If the coordinates didn't change, we don't have to * do anything */ if (pos->la == item->pos.la && pos->lo == item->pos.lo && speed->speed == item->speed.speed && speed->track == item->speed.track && item->pos_valid) return; was_valid = item->pos_valid; item->pos_valid = 1; item->pos = *pos; item->speed = *speed; old_area = *area; if (item->update_info) item->update_info(ms, item); pthread_mutex_lock(&ms->mutex); calc_item_pos(gs, ms, item); item_save_track(item); pthread_mutex_unlock(&ms->mutex); /* Change map center if item is not on screen */ if (gs->opt_follow_gps) change_map_center(gs, ms, &item->mpos, ms->scale); /* Now area contains the new item area */ if (area->x == old_area.x && area->y == old_area.y && area->height == old_area.height && area->width == old_area.width) return; if (was_valid) { /* Invalidate old area */ gtk_widget_queue_draw_area(ms->darea, old_area.x, old_area.y, old_area.width, old_area.height); } } gtk_widget_queue_draw_area(ms->darea, area->x, area->y, area->width, area->height); }
static void screen_saver_update_state (ScreenSaver *screen_saver, gdouble time) { GList *tmp; tmp = screen_saver->floaters; while (tmp != NULL) { ScreenSaverFloater *floater; floater = (ScreenSaverFloater *) tmp->data; screen_saver_floater_update_state (screen_saver, floater, time); if (GTK_WIDGET_REALIZED (screen_saver->drawing_area) && (floater->bounds.width > 0) && (floater->bounds.height > 0)) { gint size; size = CLAMP ((int) (FLOATER_MAX_SIZE * floater->scale), FLOATER_MIN_SIZE, FLOATER_MAX_SIZE); gtk_widget_queue_draw_area (screen_saver->drawing_area, floater->bounds.x, floater->bounds.y, floater->bounds.width, floater->bounds.height); /* the edges could concievably be spread across two * pixels so we add +2 to invalidated region */ if (screen_saver->should_do_rotations) gtk_widget_queue_draw_area (screen_saver->drawing_area, (int) (floater->position.x - .5 * G_SQRT2 * size), (int) (floater->position.y - .5 * G_SQRT2 * size), G_SQRT2 * size + 2, G_SQRT2 * size + 2); else gtk_widget_queue_draw_area (screen_saver->drawing_area, (int) (floater->position.x - .5 * size), (int) (floater->position.y - .5 * size), size + 2, size + 2); if (screen_saver->should_show_paths) gtk_widget_queue_draw (screen_saver->drawing_area); } tmp = tmp->next; } }
/* drawCar * Draws a car * * @return void */ void drawCar (int colorCarro, gint xant, gint yant, gint x, gint y, gint width, gint height) { GdkRectangle car; GdkColor color; switch(colorCarro){ case 1: gdk_color_parse("#FF0000", &color); break; case 2: gdk_color_parse("#0000FF", &color); break; case 3: gdk_color_parse("#00FF00", &color); break; case 4: gdk_color_parse("#000000", &color); break; case 5: gdk_color_parse("#FFFFFF", &color); break; case 6: gdk_color_parse("#FFFF00", &color); break; case 7: gdk_color_parse("#FF6600", &color); break; case 8: gdk_color_parse("#FF33CC", &color); break; case 9: gdk_color_parse("#6699FF", &color); break; case 10: gdk_color_parse("#777777", &color); break; } GdkGC* gcont; gcont = gdk_gc_new(this.pixMap); gdk_gc_set_rgb_fg_color (gcont, &color); gtk_widget_queue_draw_area(this.drawingArea, xant, yant, width, height); car.x = x; car.y = y; car.width = width; car.height = height; gdk_draw_rectangle(this.pixMap, gcont, TRUE, car.x, car.y, car.width, car.height); if (colorCarro==4) gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-50-*-*-*-*-iso8859-1"), this.drawingArea->style->white_gc, (car.x+2), (car.y+10), "A1/5"); else gdk_draw_string(this.pixMap, gdk_font_load("-*-*-bold-r-normal--*-50-*-*-*-*-iso8859-1"), this.drawingArea->style->black_gc, (car.x+2), (car.y+10), "A1/5"); gtk_widget_queue_draw_area(this.drawingArea, car.x, car.y, car.width, car.height); }
static void nsgtk_tree_redraw_request(int x, int y, int width, int height, void *data) { struct nsgtk_treeview *tw = data; gtk_widget_queue_draw_area(GTK_WIDGET(tw->drawing_area), x, y, width, height); }
void gtk_xournal_repaint_area(GtkWidget* widget, int x1, int y1, int x2, int y2) { g_return_if_fail(widget != NULL); g_return_if_fail(GTK_IS_XOURNAL(widget)); GtkXournal* xournal = GTK_XOURNAL(widget); x1 -= xournal->x; x2 -= xournal->x; y1 -= xournal->y; y2 -= xournal->y; if (x2 < 0 || y2 < 0) { return; // outside visible area } GtkAllocation alloc = { 0 }; gtk_widget_get_allocation(widget, &alloc); if (x1 > alloc.width || y1 > alloc.height) { return; // outside visible area } gtk_widget_queue_draw_area(widget, x1, y1, x2 - x1, y2 - y1); }
static void tile_fetched(const char *url, const char *filename, gpointer data) { char *nfname=g_strdup(filename); char *dot; GList *l=g_list_find_custom(tile_fetch_queue,url,mystrequal); struct mapwin *mw=(struct mapwin *)data; dot=strrchr(nfname,'.'); if (dot) { dot[0]=0; } free_image_cache(nfname); g_free(nfname); if (mw) { gtk_widget_queue_draw_area(mw->map,0,0, mw->page_width, mw->page_height); mapwin_draw(mw,mw->map->style->fg_gc[mw->map->state],globalmap.first, mw->page_x,mw->page_y,0,0,mw->page_width,mw->page_height); } if (l) { free(l->data); tile_fetch_queue=g_list_remove_link(tile_fetch_queue,l); g_list_free(l); } }
/** * goc_canvas_invalidate: * @canvas: #GocCanvas * @x0: minimum x coordinate of the invalidated region in canvas coordinates * @y0: minimum y coordinate of the invalidated region in canvas coordinates * @x1: maximum x coordinate of the invalidated region in canvas coordinates * @y1: maximum y coordinate of the invalidated region in canvas coordinates * * Invalidates a region of the canvas. The canvas will be redrawn only if * the invalidated region intersects the visible area. **/ void goc_canvas_invalidate (GocCanvas *canvas, double x0, double y0, double x1, double y1) { if (!goc_canvas_get_realized (canvas)) return; #ifdef GOFFICE_WITH_GTK x0 = (x0 - canvas->scroll_x1) * canvas->pixels_per_unit; y0 = (y0 - canvas->scroll_y1) * canvas->pixels_per_unit; x1 = (x1 - canvas->scroll_x1) * canvas->pixels_per_unit; y1 = (y1 - canvas->scroll_y1) * canvas->pixels_per_unit; if (x0 < 0.) x0 = 0; if (y0 < 0) y0 = 0; if (x1 > canvas->width) x1 = canvas->width; if (y1 > canvas->height) y1 = canvas->height; if (canvas->direction == GOC_DIRECTION_RTL) { double tmp = x0; x0 = canvas->width - x1; x1 = canvas->width - tmp; } if (x1 > x0 && y1 > y0) /* invalidate with an extra one pixel wide margin */ gtk_widget_queue_draw_area (GTK_WIDGET (canvas), (int) floor (x0) - 1, (int) floor (y0) - 1, (int) ceil (x1) - (int) floor (x0) + 2, (int) ceil (y1) - (int) floor (y0) + 2); #endif }
/* Draw a rectangle on the screen */ static void draw_brush( GtkWidget *widget, gdouble x, gdouble y) { if( clear == 1 ) { a=breadth;b=height;p.x=0;p.y=0; gtk_widget_queue_draw_area(widget,0,0,breadth,height); } else { p.x=x;a=rec1;b=rec2; p.y=y; gtk_widget_queue_draw_area(widget,x,y,rec1,rec2); } }
static void inf_text_gtk_viewport_user_invalidate_user_area(InfTextGtkViewportUser* user) { InfTextGtkViewportPrivate* priv; GtkWidget* scrollbar; priv = INF_TEXT_GTK_VIEWPORT_PRIVATE(user->viewport); if(priv->show_user_markers && user->rectangle.width > 0 && user->rectangle.height > 0) { scrollbar = gtk_scrolled_window_get_vscrollbar(priv->scroll); /* During destruction of the widget it can happen that there is no * vertical scrollbar anymore, so check for it here. */ if(scrollbar != NULL) { gtk_widget_queue_draw_area( scrollbar, user->rectangle.x, user->rectangle.y, user->rectangle.width, user->rectangle.height ); } } }
static gboolean qtcTreeViewLeave(GtkWidget *widget, GdkEventMotion *event, void *data) { QTC_UNUSED(event); QTC_UNUSED(data); if (GTK_IS_TREE_VIEW(widget)) { QtCTreeView *tv = qtcTreeViewLookupHash(widget, false); if (tv) { GtkTreeView *treeView = GTK_TREE_VIEW(widget); QtcRect rect = {0, 0, -1, -1 }; QtcRect alloc = qtcWidgetGetAllocation(widget); if (tv->path && tv->column) { gtk_tree_view_get_background_area( treeView, tv->path, tv->column, (GdkRectangle*)&rect); } if (tv->fullWidth) { rect.x = 0; rect.width = alloc.width; } if (tv->path) { gtk_tree_path_free(tv->path); } tv->path = NULL; tv->column = NULL; gtk_tree_view_convert_bin_window_to_widget_coords( treeView, rect.x, rect.y, &rect.x, &rect.y); gtk_widget_queue_draw_area( widget, rect.x, rect.y, rect.width, rect.height); } } return false; }
static void init_rs_cb(GtkWidget *widget, gpointer data) { InitializeGame(); int x = 0; int y = 0; NodeType t; for (int i = 0; i <= 2; ++i) { t = (i == 1) ? Black : White; x = (BoardSize - 9) / 2 + rand() % 9; y = (BoardSize - 9) / 2 + rand() % 9; if (game.board[x][y] == Empty) { game.board[x][y] = t; DrawPiece(x, y, t); } } if (game.blackAI.id != 10) { Point p; p = game.blackAI.func(game.board, Black); game.Move(p); DrawPiece(p.x, p.y, Black); } GtkWidget* draw_area = (GtkWidget*) data; gtk_widget_queue_draw_area(draw_area, 0, 0, CanvasWidth, CanvasWidth); }
static VALUE rg_queue_draw_area(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height) { gtk_widget_queue_draw_area(_SELF(self), NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); return self; }
static void gui_theme_changed(void) { g_assert(legend_page != NULL); gtk_widget_queue_draw(legend_page); gtk_widget_queue_draw_area(gmap->area, 0, 0, gmap->width, gmap->height); }
gboolean timer_anime ( gpointer user_data ) { static gboolean first_execution = TRUE; GtkWidget * widget = (GtkWidget * ) user_data; //use a safe function to get the value of currently_drawing so //we don't run into the usual multithreading issues int drawing_status = g_atomic_int_get(¤tly_drawing); //if we are not currently drawing anything, launch a thread to //update our pixmap if(drawing_status == 0){ static pthread_t thread_info; int iret; if(first_execution != TRUE){ pthread_join(thread_info, NULL); } iret = pthread_create( &thread_info, NULL, do_draw, user_data); } //tell our window it is time to draw our animation. int width, height; gdk_drawable_get_size(pixmap, &width, &height); gtk_widget_queue_draw_area(widget, 0, 0, width, height); first_execution = FALSE; return TRUE; }
static gboolean on_motion_notify_event (GtkWidget *window, GdkEventMotion *ev, gpointer user_data) { AbiTable* table = static_cast<AbiTable*>(user_data); gboolean changed = FALSE; guint selected_cols; guint selected_rows; if (ev->x < 0 || ev->y < 0) return TRUE; pixels_to_cells(static_cast<guint>(ev->x), static_cast<guint>(ev->y), &selected_cols, &selected_rows); if ((selected_cols != table->selected_cols) || (selected_rows != table->selected_rows)) { /* grow or shrink the table widget as necessary */ table->selected_cols = selected_cols; table->selected_rows = selected_rows; if (table->selected_rows <= 0 || table->selected_cols <= 0) table->selected_rows = table->selected_cols = 0; table->total_rows = my_max(table->selected_rows + 1, 3); table->total_cols = my_max(table->selected_cols + 1, 3); abi_table_resize(table); gtk_widget_queue_draw_area (window, 0, 0, window->allocation.width, window->allocation.height); changed = TRUE; } return TRUE; }
gboolean timer_exe(GtkWidget * window){ static int first_time = 1; //use a safe function to get the value of currently_drawing so //we don't run into the usual multithreading issues int drawing_status = g_atomic_int_get(¤tly_drawing); //if this is the first time, create the drawing thread static pthread_t thread_info; if(first_time == 1){ int iret; iret = pthread_create( &thread_info, NULL, do_draw, NULL); } //if we are not currently drawing anything, send a SIGALRM signal //to our thread and tell it to update our pixmap if(drawing_status == 0){ pthread_kill(thread_info, SIGALRM); } //tell our window it is time to draw our animation. int width, height; gdk_drawable_get_size(pixmap, &width, &height); gtk_widget_queue_draw_area(window, 0, 0, width, height); first_time = 0; return TRUE; }
void splash_update (const gchar *text1, const gchar *text2, gdouble percentage) { GdkRectangle expose = { 0, 0, 0, 0 }; g_return_if_fail (percentage >= 0.0 && percentage <= 1.0); if (! splash) return; #ifdef STARTUP_TIMER splash_timer_elapsed (text1, text2, percentage); #endif splash_position_layouts (splash, text1, text2, &expose); if (expose.width > 0 && expose.height > 0) gtk_widget_queue_draw_area (splash->area, expose.x, expose.y, expose.width, expose.height); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (splash->progress), percentage); if (gtk_events_pending ()) gtk_main_iteration (); }
static void PutPiece(GtkWidget *widget, GdkEventMotion *event, gpointer data) { if (game.winner == Empty && game.isBlackPlaying == (game.blackAI.id == 10)) { Point p(GetRowColFromPixel(event->x), GetRowColFromPixel(event->y)); if (game.Move(p) == true) { DrawPiece(GetRowColFromPixel(event->x), GetRowColFromPixel(event->y), game.isBlackPlaying ? White : Black); gtk_widget_queue_draw_area(widget, 0, 0, CanvasWidth, CanvasWidth); if (game.CheckVictory() != Empty) { return; } else { if (game.isBlackPlaying) { p = game.blackAI.func(game.board, Black); game.Move(p); DrawPiece(p.x, p.y, Black); } else { p = game.whiteAI.func(game.board, White); game.Move(p); DrawPiece(p.x, p.y, White); } if (game.CheckVictory() != Empty) return; } } } }
/* Pøidání textového popisu události do seznamu zachycených událostí we * widgetu */ static void gtk_ev_push_text(GtkEv *ev, const gchar* text) { g_return_if_fail(ev); if(text) { gchar** event; event = g_strsplit(text, "\n", 10); ev->list = g_list_prepend(ev->list, event); ev->list_len ++; if(ev->list_end == NULL) ev->list_end = ev->list; if(ev->list_len > 100) { GList* prev = ev->list_end->prev; prev->next = NULL; g_strfreev(ev->list_end->data); g_list_free_1(ev->list_end); ev->list_end = prev; ev->list_len--; } } if(GTK_WIDGET_DRAWABLE(ev)) gtk_widget_queue_draw_area(GTK_WIDGET(ev), ev->list_rect.x, ev->list_rect.y, ev->list_rect.width, ev->list_rect.height); }
static void draw_brush(GtkWidget *widget, gdouble x, gdouble y) { cairo_t *cr = cairo_create(surface); cairo_rectangle(cr, x - 3, y - 3, 6, 6); cairo_fill(cr); cairo_destroy(cr); gtk_widget_queue_draw_area(widget, x - 3, y - 3, 6, 6); }
static void pidgin_whiteboard_draw_brush_point(PurpleWhiteboard *wb, int x, int y, int color, int size) { PidginWhiteboard *gtkwb = wb->ui_data; GtkWidget *widget = gtkwb->drawing_area; GdkPixmap *pixmap = gtkwb->pixmap; cairo_t *gfx_con = g_object_get_data(G_OBJECT(pixmap), "cairo-context"); GdkColor col; /* Interpret and convert color */ pidgin_whiteboard_rgb24_to_rgb48(color, &col); gdk_cairo_set_source_color(gfx_con, &col); /* Draw a circle */ cairo_arc(gfx_con, x, y, size / 2.0, 0.0, 2.0 * M_PI); cairo_fill(gfx_con); gtk_widget_queue_draw_area(widget, x - size / 2, y - size / 2, size, size); }
static void remmina_rdp_call_feature(RemminaProtocolWidget* gp, const RemminaProtocolFeature* feature) { RemminaFile* remminafile; rfContext* rfi; rfi = GET_DATA(gp); remminafile = remmina_plugin_service->protocol_plugin_get_file(gp); switch (feature->id) { case REMMINA_RDP_FEATURE_UNFOCUS: remmina_rdp_event_unfocus(gp); break; case REMMINA_RDP_FEATURE_SCALE: rfi->scale = remmina_plugin_service->file_get_int(remminafile, "scale", FALSE); remmina_rdp_event_update_scale(gp); break; case REMMINA_RDP_FEATURE_TOOL_REFRESH: gtk_widget_queue_draw_area(rfi->drawing_area, 0, 0, remmina_plugin_service->protocol_plugin_get_width(gp), remmina_plugin_service->protocol_plugin_get_height(gp)); break; default: break; } }
void draw_area (view_struct *vs) { if (vs->calc_buf) (*vs->calc_buf) (vs->external_data, vs->buf8, vs->width, vs->height); // This calls an expose_event for vs->area: gtk_widget_queue_draw_area ( vs->area, 0, 0, vs->width, vs->height); }
/* Draw a rectangle on the screen, size depending on pressure, and color on the type of device */ static void draw_brush (GtkWidget *widget, GdkInputSource source, gdouble x, gdouble y, gdouble pressure) { GdkGC *gc; GdkRectangle update_rect; switch (source) { case GDK_SOURCE_MOUSE: gc = widget->style->dark_gc[gtk_widget_get_state (widget)]; break; case GDK_SOURCE_PEN: gc = widget->style->black_gc; break; case GDK_SOURCE_ERASER: gc = widget->style->white_gc; break; default: gc = widget->style->light_gc[gtk_widget_get_state (widget)]; } update_rect.x = x - 10 * pressure; update_rect.y = y - 10 * pressure; update_rect.width = 20 * pressure; update_rect.height = 20 * pressure; gdk_draw_rectangle (pixmap, gc, TRUE, update_rect.x, update_rect.y, update_rect.width, update_rect.height); gtk_widget_queue_draw_area (widget, update_rect.x, update_rect.y, update_rect.width, update_rect.height); }
void gtku_gl_drawing_area_invalidate (GtkuGLDrawingArea * self) { GtkWidget * widget = GTK_WIDGET (self); gtk_widget_queue_draw_area (widget, 0, 0, widget->allocation.width, widget->allocation.height); }
virtual bool queue_draw_area(gint x,gint y, gint width,gint height) { widget_attached_t detached = 0; if ((detached = this->attached_to())) { gtk_widget_queue_draw_area(detached, x,y, width,height); return true; } return false; }