static gboolean hippo_window_gtk_expose_event(GtkWidget *widget, GdkEventExpose *event) { /* We don't want to redraw between requesting a new position/size * from the window manager and getting allocated that size because * we won't yet have made all the reallocations for the new size, * but may already have the new coordinates after the resize. We * count here on a) the resize not being denied by the window manager * b) on the complete redraw we currently do at each new size. */ if (GTK_WINDOW(widget)->configure_request_count > 0) return FALSE; /* Ignoring the expose event while we are waiting for the window manager * to resize us would cause problems if we were normally double-buffered * because when we ignored the expose event, a blank double-buffer would * get drawn. So what we do is turn off double-buffering at the widget * level and do it ourselves here. */ gdk_window_begin_paint_region(widget->window, event->region); GTK_WIDGET_CLASS(hippo_window_gtk_parent_class)->expose_event(widget, event); gdk_window_end_paint(widget->window); return FALSE; }
/* draw frequency spectrum as a bunch of bars */ static void draw_spectrum (gfloat * data) { gint i; GdkRectangle rect = { 0, 0, spect_bands, spect_height }; cairo_t *cr; if (!drawingarea) return; gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect); cr = gdk_cairo_create (gtk_widget_get_window (drawingarea)); cairo_set_source_rgb (cr, 0, 0, 0); cairo_rectangle (cr, 0, 0, spect_bands, spect_height); cairo_fill (cr); cairo_set_source_rgb (cr, 1, 1, 1); for (i = 0; i < spect_bands; i++) { cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]); cairo_fill (cr); } cairo_destroy (cr); gdk_window_end_paint (gtk_widget_get_window (drawingarea)); }
JNIEXPORT void JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1end_1paint ( JNIEnv* env, jclass cls, jlong _self ) { GdkWindow* self; // convert parameter self self = (GdkWindow*) _self; // call function gdk_window_end_paint(self); // cleanup parameter self }
/* draw frequency spectrum as a bunch of bars */ static void draw_spectrum (gfloat * data) { gint i; GdkRectangle rect = { 0, 0, spect_bands, spect_height }; if (!drawingarea) return; gdk_window_begin_paint_rect (drawingarea->window, &rect); gdk_draw_rectangle (drawingarea->window, drawingarea->style->black_gc, TRUE, 0, 0, spect_bands, spect_height); for (i = 0; i < spect_bands; i++) { gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc, TRUE, i, -data[i], 1, spect_height + data[i]); } gdk_window_end_paint (drawingarea->window); }
/** * draw_area: * * Draw the game area with its players and their cards */ void draw_area(void) { gint i; cairo_t *cr; player *player; GdkRectangle rect = { 0, 0, gskat.area->allocation.width, gskat.area->allocation.height }; gdk_window_begin_paint_rect(gskat.area->window, &rect); cr = gdk_cairo_create(gskat.area->window); draw_table(gskat.area, cr); if (gskat.skat) draw_cards(gskat.skat, cr); if (gskat.table) draw_cards(gskat.table, cr); if (gskat.players) { for (i=0; i<3; ++i) { player = gskat.players[i]; draw_cards(player->cards, cr); draw_player(player, cr); } } /* draw bid values during provoke phase only */ if (gskat.state >= PROVOKE1 && gskat.state <= PROVOKE4 && get_prop_bool("provoke_values")) draw_provoke_value(cr); cairo_destroy(cr); gdk_window_end_paint(gskat.area->window); }
gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GdkWindow *window = widget->window; GtkStyle *style = gtk_widget_get_style(widget); gint width, height; gdk_drawable_get_size(window, & width, & height); GdkRectangle rect = {0, 0, width, height}; gdk_window_begin_paint_rect(window, & rect); cairo_t *ctx = gdk_cairo_create(window); cairo_set_antialias(ctx, CAIRO_ANTIALIAS_NONE); cairo_set_line_width(ctx, 1); // Fill background. cairo_rectangle(ctx, 0, 0, width, height); cairo_set_source_rgb(ctx, style->mid[0].red/255./255., style->mid[0].green/255./255., style->mid[0].blue/255./255.); cairo_fill(ctx); // Line. cairo_move_to(ctx, 0, height/(gfloat)2); cairo_line_to(ctx, width, height/(gfloat)2); cairo_set_source_rgb(ctx, style->dark[0].red/255./255., style->dark[0].green/255./255., style->dark[0].blue/255./255.); cairo_stroke(ctx); gdk_window_end_paint(window); cairo_destroy(ctx); return FALSE; }
/** * draw_tricks_area: * @area: #GtkDrawingArea widget the cards are drawn on * @sv: trick (three cards) to draw * * Draw the tricks in the show last tricks dialog window */ void draw_tricks_area(GtkWidget *area, stich_view *sv) { gint i, x, y, winner; gchar *caption = NULL; cairo_t *cr; trick *stich = sv->stich; card **cards = stich->cards; GdkRectangle rect = { 0, 0, area->allocation.width, area->allocation.height }; /* begin drawing process * used for double buffering */ gdk_window_begin_paint_rect(area->window, &rect); cr = gdk_cairo_create(area->window); /* draw table background */ draw_table(area, cr); /* draw current stich */ caption = g_strdup_printf(_("Trick %d"), sv->cur + 1); cairo_set_source_rgb(cr, 0.1, 0.1, 0.1); cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 12); cairo_move_to(cr, area->allocation.width / 2 - 25, 25); cairo_show_text(cr, caption); /* draw cards of the given stich */ x = 5; y = 40; winner = get_trick_winner(cards); for (i=0; i<3; ++i) { if (cards[i]) { /* draw card image */ cairo_set_source_surface(cr, cards[i]->img, x, y); cairo_paint(cr); /* darken the non-winning cards */ if (cards[i]->owner != winner) { cairo_set_source_rgba(cr, 0.1, 0.1, 0.1, 0.2); cairo_rectangle(cr, x, y, cards[i]->dim.w, cards[i]->dim.h); cairo_fill(cr); } /* draw card owner's name */ cairo_set_source_rgb(cr, 0.1, 0.1, 0.1); cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 12); cairo_move_to(cr, x, y + cards[i]->dim.h + 15); cairo_show_text(cr, gskat.players[cards[i]->owner]->name); x += cards[i]->dim.w + 5; } } cairo_destroy(cr); g_free(caption); /* end drawing process * used for double buffering */ gdk_window_end_paint(area->window); }
static VALUE gdkwin_end_paint(VALUE self) { gdk_window_end_paint(_SELF(self)); return self; }
void refresh_display(void) { int n; scope_disp_t *disp; scope_vert_t *vert; scope_horiz_t *horiz; int depth; double pixels_per_div, pixels_per_sec, overall_record_length; double screen_center_time, screen_start_time, screen_end_time; /* cancel any pending refresh request */ ctrl_usr->display_refresh_timer = 0; /* set pointers */ disp = &(ctrl_usr->disp); vert = &(ctrl_usr->vert); horiz = &(ctrl_usr->horiz); /* get window pointer */ disp->win = disp->drawing->window; if (disp->win == NULL) { /* window isn't visible yet, do nothing */ printf("refresh_display(): win = NULL, bailing!\n"); return; } /* create drawing context if needed */ if (disp->context == NULL) { disp->context = gdk_gc_new(disp->win); } /* get window dimensions */ gdk_window_get_geometry(disp->win, NULL, NULL, &(disp->width), &(disp->height), &depth); /* calculate horizontal params that depend on width */ pixels_per_div = disp->width * 0.1; pixels_per_sec = pixels_per_div / horiz->disp_scale; disp->pixels_per_sample = pixels_per_sec * horiz->sample_period; overall_record_length = horiz->sample_period * ctrl_shm->rec_len; screen_center_time = overall_record_length * horiz->pos_setting; screen_start_time = screen_center_time - (5.0 * horiz->disp_scale); disp->horiz_offset = screen_start_time * pixels_per_sec; disp->start_sample = screen_start_time / horiz->sample_period; if (disp->start_sample < 0) { disp->start_sample = 0; } screen_end_time = screen_center_time + (5.0 * horiz->disp_scale); disp->end_sample = (screen_end_time / horiz->sample_period) + 1; if (disp->end_sample > ctrl_shm->rec_len - 1) { disp->end_sample = ctrl_shm->rec_len - 1; } { GdkRectangle rect = {0, 0, disp->width, disp->height}; GdkRegion *region = gdk_region_rectangle(&rect); gdk_window_begin_paint_region(disp->drawing->window, region); gdk_region_destroy(region); } DRAWING = 1; clear_display_window(); draw_grid(); /* calculate offsets for AC-offset channels */ for (n = 0; n < 16; n++) { if (vert->chan_enabled[n]) calculate_offset(n); } /* draw baselines first */ for (n = 0; n < 16; n++) { if ((vert->chan_enabled[n]) && (n + 1 != vert->selected)) { draw_baseline(n + 1, FALSE); } } if (vert->chan_enabled[vert->selected - 1]) { draw_baseline(vert->selected, TRUE); } /* Draw trigger line */ if (vert->chan_enabled[ctrl_shm->trig_chan - 1]) { draw_triggerline(ctrl_shm->trig_chan, ctrl_shm->trig_chan == vert->selected); } conflict_reset(disp->height); /* draw non-highlighted waveforms next */ for (n = 0; n < 16; n++) { if ((vert->chan_enabled[n]) && (vert->data_offset[n] >= 0) && (n + 1 != vert->selected)) { draw_waveform(n + 1, FALSE); } } /* draw highlighted waveform last */ if ((vert->chan_enabled[vert->selected - 1]) && (vert->data_offset[vert->selected - 1] >= 0)) { draw_waveform(vert->selected, TRUE); } update_readout(); gdk_window_end_paint(disp->drawing->window); }
void FrameGdk::handleGdkEvent(GdkEvent* event) { switch (event->type) { case GDK_EXPOSE: { GdkRectangle clip; gdk_region_get_clipbox(event->expose.region, &clip); gdk_window_begin_paint_region (event->any.window, event->expose.region); cairo_t* cr = gdk_cairo_create (event->any.window); GraphicsContext* ctx = new GraphicsContext(cr); paint(ctx, IntRect(clip.x, clip.y, clip.width, clip.height)); delete ctx; gdk_window_end_paint (event->any.window); break; } case GDK_SCROLL: { PlatformWheelEvent wheelEvent(event); view()->handleWheelEvent(wheelEvent); if (wheelEvent.isAccepted()) { return; } RenderObject::NodeInfo nodeInfo(true, true); renderer()->layer()->hitTest(nodeInfo, wheelEvent.pos()); Node* node = nodeInfo.innerNode(); if (!node) return; //Default to scrolling the page //not sure why its null //broke anyway when its not null doScroll(renderer(), wheelEvent.isHorizontal(), wheelEvent.delta()); break; } case GDK_DRAG_ENTER: case GDK_DRAG_LEAVE: case GDK_DRAG_MOTION: case GDK_DRAG_STATUS: case GDK_DROP_START: case GDK_DROP_FINISHED: { //bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*); //void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*); //bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*); break; } case GDK_MOTION_NOTIFY: view()->handleMouseMoveEvent(event); break; case GDK_BUTTON_PRESS: case GDK_2BUTTON_PRESS: case GDK_3BUTTON_PRESS: view()->handleMousePressEvent(event); break; case GDK_BUTTON_RELEASE: view()->handleMouseReleaseEvent(event); break; case GDK_KEY_PRESS: case GDK_KEY_RELEASE: { PlatformKeyboardEvent kevent(event); bool handled = false; if (!kevent.isKeyUp()) { Node* start = selection().start().node(); if (start && start->isContentEditable()) { switch(kevent.WindowsKeyCode()) { case VK_BACK: TypingCommand::deleteKeyPressed(document()); break; case VK_DELETE: TypingCommand::forwardDeleteKeyPressed(document()); break; case VK_LEFT: selection().modify(SelectionController::MOVE, SelectionController::LEFT, CharacterGranularity); break; case VK_RIGHT: selection().modify(SelectionController::MOVE, SelectionController::RIGHT, CharacterGranularity); break; case VK_UP: selection().modify(SelectionController::MOVE, SelectionController::BACKWARD, ParagraphGranularity); break; case VK_DOWN: selection().modify(SelectionController::MOVE, SelectionController::FORWARD, ParagraphGranularity); break; default: TypingCommand::insertText(document(), kevent.text(), false); } handled = true; } if (!handled) { switch (kevent.WindowsKeyCode()) { case VK_LEFT: doScroll(renderer(), true, -120); break; case VK_RIGHT: doScroll(renderer(), true, 120); break; case VK_UP: doScroll(renderer(), false, -120); break; case VK_PRIOR: //return SB_PAGEUP; break; case VK_NEXT: //return SB_PAGEDOWN; break; case VK_DOWN: doScroll(renderer(), false, 120); break; case VK_HOME: renderer()->layer()->scrollToOffset(0, 0, true, true); doScroll(renderer(), false, 120); break; case VK_END: renderer()->layer()->scrollToOffset(0, renderer()->height(), true, true); break; case VK_SPACE: if (kevent.shiftKey()) doScroll(renderer(), false, -120); else doScroll(renderer(), false, 120); break; } } } } default: break; } }