/* Draw all the visible glyphs in the strip. */ static void draw_strip (ModeInfo *mi, strip *s) { matrix_configuration *mp = &mps[MI_SCREEN(mi)]; int i; for (i = 0; i < GRID_SIZE; i++) { int g = s->glyphs[i]; Bool below_p = (s->spinner_y >= i); if (s->erasing_p) below_p = !below_p; if (g && below_p) /* don't draw cells below the spinner */ { GLfloat brightness; if (!do_waves) brightness = 1.0; else { int j = WAVE_SIZE - ((i + (GRID_SIZE - s->wave_position)) % WAVE_SIZE); brightness = mp->brightness_ramp[j]; } draw_glyph (mi, g, s->highlight[i], s->x, s->y - i, s->z, brightness); } } if (!s->erasing_p) draw_glyph (mi, s->spinner_glyph, False, s->x, s->y - s->spinner_y, s->z, 1.0); }
inline static int draw_text(const uint8 *text, size_t length, int x, int y, T *p, int pitch, int clip_left, int clip_top, int clip_right, int clip_bottom, uint32 pixel, const sdl_font_info *font, uint16 style) { bool oblique = ((style & styleItalic) != 0); int total_width = 0; uint8 c; while (length--) { c = *text++; if (c < font->first_character || c > font->last_character) continue; int width; width = draw_glyph(c, x, y, p, pitch, clip_left, clip_top, clip_right, clip_bottom, pixel, font, oblique); if (style & styleBold) { draw_glyph(c, x + 1, y, p, pitch, clip_left, clip_top, clip_right, clip_bottom, pixel, font, oblique); width++; } if (style & styleUnderline) { for (int i=0; i<width; i++) p[y * pitch / sizeof(T) + x + i] = pixel; } total_width += width; x += width; } return total_width; }
void Fl_Scrollbar::draw() { if (damage()&FL_DAMAGE_ALL) draw_frame(); int X=0; int Y=0; int W=w(); int H=h(); box()->inset(X,Y,W,H); int ix = X; int iy = Y; int iw = W; int ih = H; char pushed_ = this==Fl::pushed() ? which_pushed : NOTHING; char highlight_ = this==Fl::belowmouse() ? which_highlight : NOTHING; // 1 = left/top 2 = right/bottom 5 = slider button Fl_Flags f1 = 0, f2 = 0, f5 = 0; if (!active_r()) { f1 = f2 = f5 = FL_INACTIVE; } else { if (pushed_ == UP_ARROW) f1 = FL_VALUE|FL_HIGHLIGHT; else if (highlight_ == UP_ARROW) f1 = FL_HIGHLIGHT; if (pushed_ == DOWN_ARROW) f2 = FL_VALUE|FL_HIGHLIGHT; else if (highlight_ == DOWN_ARROW) f2 = FL_HIGHLIGHT; if (pushed_ == SLIDER) f5 = FL_VALUE|FL_HIGHLIGHT; else if (highlight_ == SLIDER) f5 = FL_HIGHLIGHT; } if (vertical() && H >= 3*W) { if (damage()&FL_DAMAGE_ALL || last_ == UP_ARROW || highlight_ == UP_ARROW) draw_glyph(FL_GLYPH_UP_BUTTON, X, Y, W, W, f1); if (damage()&FL_DAMAGE_ALL || last_ ==DOWN_ARROW|| highlight_ ==DOWN_ARROW) draw_glyph(FL_GLYPH_DOWN_BUTTON, X, Y+H-W, W, W, f2); iy += W; ih -= 2*W; } // horizontal: else if (W >= 3*H) { if (damage()&FL_DAMAGE_ALL || last_ == UP_ARROW || highlight_ == UP_ARROW) draw_glyph(FL_GLYPH_LEFT_BUTTON, X, Y, H, H, f1); if (damage()&FL_DAMAGE_ALL || last_ ==DOWN_ARROW|| highlight_ ==DOWN_ARROW) draw_glyph(FL_GLYPH_RIGHT_BUTTON, X+W-H, Y, H, H, f2); ix += H; iw -= 2*H; } last_ = highlight_; if (Fl_Slider::draw(ix, iy, iw, ih, f5, false)) { fl_color(color()); fl_rectf(ix, iy, iw, ih); fl_pop_clip(); } }
static void fz_draw_stroke_text(fz_context *ctx, void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; unsigned char colorbv[FZ_MAX_COLORS + 1]; float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; if (dev->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_begin(ctx, dev); fz_convert_color(ctx, colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_stroked_glyph(ctx, dev->cache, text->font, gid, trm, ctm, stroke); if (glyph) { draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor); if (dev->shape) draw_glyph(colorbv, dev->shape, glyph, x, y, dev->scissor); fz_drop_pixmap(ctx, glyph); } } if (dev->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_end(ctx, dev); }
void Fl_Input_Browser::draw() { Fl_Flags f = flags(); if (!active_r()) f.set(FL_INACTIVE); //minw_ = w(); if (damage()&FL_DAMAGE_ALL) draw_frame(); int X = 0, Y = 0, W = w(), H = h(); box()->inset(X, Y, W, H); int W1 = H*4/5; if (damage()&(FL_DAMAGE_ALL|FL_DAMAGE_CHILD)) { input()->resize(X, Y, W-W1, H); input()->set_damage(FL_DAMAGE_ALL); input()->copy_style(style()); // force it to use this style input()->box(FL_FLAT_BOX); // fix for relative coordinates fl_push_matrix(); fl_translate(X,Y); input()->draw(); fl_pop_matrix(); input()->set_damage(0); } if(damage()&(FL_DAMAGE_ALL|FL_DAMAGE_VALUE|FL_DAMAGE_HIGHLIGHT)) { if(over_now) f.set(FL_HIGHLIGHT); X += W-W1; W = W1; button_box(FL_DIV_UP_BOX); // draw the little mark at the right: draw_glyph(FL_GLYPH_DOWN_BUTTON, X, Y, W, H, f); over_last = over_now; } }
static void menu(void) { draw_glyph(modes[mode_id].glyph_id); while(state == STATE_MENU) { if(keypresses & KEY_LEFT) { keypresses &= ~KEY_LEFT; if(mode_id > 0) { mode_id--; const uint8_t glyph_id = modes[mode_id].glyph_id; for(uint8_t i = 0; i < 8; i++) { shift_right(); display[0] = read_glyph_column(glyph_id, 7 - i); _delay_ms(50); } } } else if(keypresses & KEY_RIGHT) { keypresses &= ~KEY_RIGHT; if(modes[mode_id + 1].run != NULL) { mode_id++; const uint8_t glyph_id = modes[mode_id].glyph_id; for(uint8_t i = 0; i < 8; i++) { shift_left(); display[7] = read_glyph_column(glyph_id, i); _delay_ms(50); } } } else if(keypresses & KEY_ENTER) { keypresses &= ~KEY_ENTER; state = STATE_NORMAL; } } }
void draw_top_bar(uint8_t swap, CNTRLDISPLAY controls) { rectangle_filled(0, 0, 640, 30, 1); rectangle_filled(0, 30, 640, 480-30, 0); draw_glyph(3, 7, spclr_logo_width, spclr_logo_height, spclr_logo, 0, 0); draw_controls(controls); if (swap) swap_buffers(); }
void draw_checkbox_ui(CHECKBOX_UI* ui_element) { ui_element->update_layout(ui_element); if (ui_element->format.bg != NO_COLOR) rectangle_filled(ui_element->layout.layout_left, ui_element->layout.layout_top, ui_element->layout.width, ui_element->layout.height, ui_element->format.bg); SIZE size; align_content(&ui_element->layout, &size); draw_glyph(size.width, size.height, ui_element->layout.content_width, ui_element->layout.content_height, (ui_element->checked)?check_checked_data:check_unchecked_data, ui_element->format.fg, 1); }
void Fl_Tool_Bar::draw() { int n; if(opened()) { // make it not draw the inside label: int saved = flags(); align(FL_ALIGN_TOP); if(damage() & ~FL_DAMAGE_CHILD) { draw_frame(); fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh()); for (n = children(); n--;) draw_child(*child(n)); draw_box(); draw_inside_label(); fl_pop_clip(); if(m_menubut->visible()) { fl_push_clip(w()-box()->dw()-(m_menubut->visible()?20:0), box()->dy(), 30, h()-box()->dh()); draw_child(*m_menubut); draw_box(); fl_pop_clip(); } for (n = 0; n < children(); n++) draw_outside_label(*child(n)); } else { fl_push_clip(box()->dx(), box()->dy(), w()-box()->dw()-(m_menubut->visible()?20:0), h()-box()->dh()); for(n = 0; n < children(); n++) { Fl_Widget& w = *child(n); if (w.damage() & FL_DAMAGE_CHILD_LABEL) { draw_outside_label(w); w.set_damage(w.damage() & ~FL_DAMAGE_CHILD_LABEL); } update_child(w); } fl_pop_clip(); } flags(saved); if (damage() & (FL_DAMAGE_EXPOSE|FL_DAMAGE_HIGHLIGHT|FL_DAMAGE_ALL)) { Fl_Flags f = 0; if (pushed) f.set(FL_VALUE); if (highlighted) f.set(FL_HIGHLIGHT); draw_glyph(0, 0, 0, glyph_size(), h(), f); } } else Fl_Bar::draw(); }
void draw_controls(CNTRLDISPLAY controls) { uint32_t x_pos = WIDTH_W; if (controls.enter_select) { x_pos -= enter_select_width + 5; draw_glyph(x_pos, 5, enter_select_width, enter_select_height, enter_select_bitmap, 0, 1); } if (controls.arrow_nav) { x_pos -= arrow_nav_width + 5; draw_glyph(x_pos, 5, arrow_nav_width, arrow_nav_height, arrow_nav_bitmap, 0, 1); } if (controls.f5_refresh) { x_pos -= f5_refresh_width + 5; draw_glyph(x_pos, 5, f5_refresh_width, f5_refresh_height, f5_refresh_bitmap, 0, 1); } if (controls.esc_back) { x_pos -= esc_back_width + 5; draw_glyph(x_pos, 5, esc_back_width, esc_back_height, esc_back_bitmap, 0, 1); } if (controls.esc_menu) { x_pos -= esc_menu_width + 5; draw_glyph(x_pos, 5, esc_menu_width, esc_menu_height, esc_menu_bitmap, 0, 1); } }
void huddraw_help_text(const char *text) { int i, col=1, row=1; for(i=0; text[i]; i++) { if (text[i] == '\n') { col = 1; row += 6; } else { draw_glyph(col, row, text[i]); col += FONTS_W; } } }
/** * \brief Gets an iterator on the glyph_sheet containing the glyph of a given * character. If the character has never been drawn, draw_glyph() is * first. * \param character The character for which we want the sheet. */ bear::visual::true_type_font::glyph_sheet_iterator bear::visual::true_type_font::get_glyph_or_draw( charset::char_type character ) { glyph_sheet_iterator sheet; const character_to_glyph_sheet::const_iterator it = m_sheet_from_character.find(character); if ( it == m_sheet_from_character.end() ) sheet = draw_glyph( character ); else sheet = it->second; return sheet; } // true_type_font::get_glyph_or_draw()
static const char *drawchar(const char *str, float *xpos, float *ypos, int *should_flush) { float px, py; int code = dtx_utf8_char_code(str); str = dtx_utf8_next_char((char*)str); *should_flush = 0; /* the raster renderer never buffers output */ px = *xpos; py = *ypos; if((gmap = dtx_proc_char(code, xpos, ypos))) { int idx = code - gmap->cstart; draw_glyph(gmap->glyphs + idx, px, py); } return str; }
static void fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; unsigned char colorbv[FZ_MAX_COLORS + 1]; float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_glyph(dev->cache, text->font, gid, trm); if (glyph) { draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor); fz_drop_pixmap(glyph); } } }
static void fz_draw_fill_text(fz_context *ctx, void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; unsigned char colorbv[FZ_MAX_COLORS + 1]; unsigned char shapebv; float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; if (dev->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_begin(ctx, dev); fz_convert_color(ctx, colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; shapebv = 255; tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_glyph(ctx, dev->cache, text->font, gid, trm, model); if (glyph) { /* cf. http://code.google.com/p/sumatrapdf/issues/detail?id=1746 */ if (glyph->n > 1 && text->font->t3procs) { float light; fz_convert_color(ctx, colorspace, color, fz_device_gray, &light); if (light != 0) { fz_pixmap *gray = fz_new_pixmap_with_rect(ctx, fz_device_gray, fz_bound_pixmap(glyph)); fz_convert_pixmap(ctx, glyph, gray); fz_drop_pixmap(ctx, glyph); glyph = fz_alpha_from_gray(ctx, gray, 0); fz_drop_pixmap(ctx, gray); } } if (glyph->n == 1) { draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor); if (dev->shape) draw_glyph(&shapebv, dev->shape, glyph, x, y, dev->scissor); } else { fz_matrix ctm = {glyph->w, 0.0, 0.0, -glyph->h, x + glyph->x, y + glyph->y + glyph->h}; fz_paint_image(dev->dest, dev->scissor, dev->shape, glyph, ctm, alpha * 255); } fz_drop_pixmap(ctx, glyph); } } if (dev->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_end(ctx, dev); }
void draw() { draw_box(); int X=0, Y=0, W=w(), H=h(); box()->inset(X,Y,W,H); draw_glyph(FL_GLYPH_RIGHT_BUTTON, X,Y,W,H,flags()); }
static void fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate) { fz_draw_device *dev = devp->user; fz_context *ctx = dev->ctx; fz_bbox bbox; fz_pixmap *mask, *dest, *shape; fz_matrix tm, trm, trunc_trm; fz_pixmap *glyph; int i, x, y, gid; fz_draw_state *state; fz_colorspace *model; /* If accumulate == 0 then this text object is guaranteed complete */ /* If accumulate == 1 then this text object is the first (or only) in a sequence */ /* If accumulate == 2 then this text object is a continuation */ state = push_stack(dev); model = state->dest->colorspace; if (accumulate == 0) { /* make the mask the exact size needed */ bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm)); bbox = fz_intersect_bbox(bbox, state->scissor); } else { /* be conservative about the size of the mask needed */ bbox = state->scissor; } if (accumulate == 0 || accumulate == 1) { mask = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox); fz_clear_pixmap(dev->ctx, mask); dest = fz_new_pixmap_with_bbox(dev->ctx, model, bbox); fz_clear_pixmap(dev->ctx, dest); if (state->shape) { shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox); fz_clear_pixmap(dev->ctx, shape); } else shape = NULL; state[1].blendmode |= FZ_BLEND_ISOLATED; state[1].scissor = bbox; state[1].dest = dest; state[1].mask = mask; state[1].shape = shape; #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top-1, "Clip (text) begin\n"); #endif } else { mask = state->mask; dev->top--; } if (!fz_is_empty_rect(bbox) && mask) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trunc_trm = trm; trunc_trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trunc_trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_glyph(dev->ctx, text->font, gid, trunc_trm, model, bbox); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); if (state[1].shape) draw_glyph(NULL, state[1].shape, glyph, x, y, bbox); fz_drop_pixmap(dev->ctx, glyph); } else { fz_path *path = fz_outline_glyph(dev->ctx, text->font, gid, trm); if (path) { fz_pixmap *old_dest; float white = 1; state = &dev->stack[dev->top]; old_dest = state[0].dest; state[0].dest = state[0].mask; state[0].mask = NULL; fz_try(ctx) { fz_draw_fill_path(devp, path, 0, fz_identity, fz_device_gray, &white, 1); } fz_always(ctx) { state[0].mask = state[0].dest; state[0].dest = old_dest; fz_free_path(dev->ctx, path); } fz_catch(ctx) { fz_rethrow(ctx); } } else { fz_warn(dev->ctx, "cannot render glyph for clipping"); } } }
static void fz_draw_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { fz_draw_device *dev = devp->user; unsigned char colorbv[FZ_MAX_COLORS + 1]; float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm, trunc_trm; fz_pixmap *glyph; int i, x, y, gid; fz_draw_state *state = &dev->stack[dev->top]; fz_colorspace *model = state->dest->colorspace; fz_bbox scissor = state->scissor; if (state->blendmode & FZ_BLEND_KNOCKOUT) state = fz_knockout_begin(dev); fz_convert_color(dev->ctx, model, colorfv, colorspace, color); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trunc_trm = trm; trunc_trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trunc_trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); scissor.x0 -= x; scissor.x1 -= x; scissor.y0 -= y; scissor.y1 -= y; glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trunc_trm, ctm, stroke, scissor); if (glyph) { draw_glyph(colorbv, state->dest, glyph, x, y, state->scissor); if (state->shape) draw_glyph(colorbv, state->shape, glyph, x, y, state->scissor); fz_drop_pixmap(dev->ctx, glyph); } else { fz_path *path = fz_outline_glyph(dev->ctx, text->font, gid, trm); if (path) { fz_draw_stroke_path(devp, path, stroke, fz_identity, colorspace, color, alpha); fz_free_path(dev->ctx, path); } else { fz_warn(dev->ctx, "cannot render glyph"); } } } if (state->blendmode & FZ_BLEND_KNOCKOUT) fz_knockout_end(dev); }
static void fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { fz_draw_device *dev = devp->user; fz_bbox bbox; fz_pixmap *mask, *dest, *shape; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; fz_draw_state *state = push_stack(dev); fz_colorspace *model = state->dest->colorspace; /* make the mask the exact size needed */ bbox = fz_bbox_covering_rect(fz_bound_text(dev->ctx, text, ctm)); bbox = fz_intersect_bbox(bbox, state->scissor); mask = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox); fz_clear_pixmap(dev->ctx, mask); dest = fz_new_pixmap_with_bbox(dev->ctx, model, bbox); fz_clear_pixmap(dev->ctx, dest); if (state->shape) { shape = fz_new_pixmap_with_bbox(dev->ctx, NULL, bbox); fz_clear_pixmap(dev->ctx, shape); } else shape = state->shape; state[1].blendmode |= FZ_BLEND_ISOLATED; state[1].scissor = bbox; state[1].dest = dest; state[1].shape = shape; state[1].mask = mask; #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top-1, "Clip (stroke text) begin\n"); #endif if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_stroked_glyph(dev->ctx, text->font, gid, trm, ctm, stroke, bbox); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); if (shape) draw_glyph(NULL, shape, glyph, x, y, bbox); fz_drop_pixmap(dev->ctx, glyph); } else { fz_warn(dev->ctx, "cannot draw glyph for clipping (unimplemented case)"); // TODO: outline/non-cached case } } } }
void draw_text(int col, int row, char *s) { int i; for(i=0; s[i]; i++) draw_glyph(col+i*FONTS_W, row, s[i]); }
static void fz_draw_clip_text(fz_context *ctx, void *user, fz_text *text, fz_matrix ctm, int accumulate) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest, *shape; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; /* If accumulate == 0 then this text object is guaranteed complete */ /* If accumulate == 1 then this text object is the first (or only) in a sequence */ /* If accumulate == 2 then this text object is a continuation */ if (dev->top == dev->stack_max) fz_grow_stack(dev); if (accumulate == 0) { /* make the mask the exact size needed */ bbox = fz_round_rect(fz_bound_text(text, ctm)); bbox = fz_intersect_bbox(bbox, dev->scissor); } else { /* be conservative about the size of the mask needed */ bbox = dev->scissor; } if (accumulate == 0 || accumulate == 1) { mask = fz_new_pixmap_with_rect(ctx, NULL, bbox); fz_clear_pixmap(mask); dest = fz_new_pixmap_with_rect(ctx, model, bbox); /* FIXME: See note #1 */ fz_clear_pixmap(dest); if (dev->shape) { shape = fz_new_pixmap_with_rect(ctx, NULL, bbox); fz_clear_pixmap(shape); } else shape = NULL; dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; dev->stack[dev->top].dest = dev->dest; dev->stack[dev->top].shape = dev->shape; /* FIXME: See note #1 */ dev->stack[dev->top].blendmode = dev->blendmode | FZ_BLEND_ISOLATED; dev->scissor = bbox; dev->dest = dest; dev->shape = shape; #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top, "Clip (text) begin\n"); #endif dev->top++; } else { mask = dev->stack[dev->top-1].mask; } if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_glyph(ctx, dev->cache, text->font, gid, trm, model); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); if (dev->shape) draw_glyph(NULL, dev->shape, glyph, x, y, bbox); fz_drop_pixmap(ctx, glyph); } } } }
static void fz_draw_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } /* make the mask the exact size needed */ bbox = fz_round_rect(fz_bound_text(text, ctm)); bbox = fz_intersect_bbox(bbox, dev->scissor); mask = fz_new_pixmap_with_rect(NULL, bbox); dest = fz_new_pixmap_with_rect(model, bbox); fz_clear_pixmap(mask); fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; dev->stack[dev->top].dest = dev->dest; dev->scissor = bbox; dev->dest = dest; dev->top++; if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_stroked_glyph(dev->cache, text->font, gid, trm, ctm, stroke); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); fz_drop_pixmap(glyph); } } } }
static void fz_draw_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; /* If accumulate == 0 then this text object is guaranteed complete */ /* If accumulate == 1 then this text object is the first (or only) in a sequence */ /* If accumulate == 2 then this text object is a continuation */ if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } if (accumulate == 0) { /* make the mask the exact size needed */ bbox = fz_round_rect(fz_bound_text(text, ctm)); bbox = fz_intersect_bbox(bbox, dev->scissor); } else { /* be conservative about the size of the mask needed */ bbox = dev->scissor; } if (accumulate == 0 || accumulate == 1) { mask = fz_new_pixmap_with_rect(NULL, bbox); dest = fz_new_pixmap_with_rect(model, bbox); fz_clear_pixmap(mask); fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; dev->stack[dev->top].dest = dev->dest; dev->scissor = bbox; dev->dest = dest; dev->top++; } else { mask = dev->stack[dev->top-1].mask; } if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_glyph(dev->cache, text->font, gid, trm); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); fz_drop_pixmap(glyph); } } } }
static void fz_draw_clip_stroke_text(fz_context *ctx, void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest, *shape; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; if (dev->top == dev->stack_max) fz_grow_stack(dev); /* make the mask the exact size needed */ bbox = fz_round_rect(fz_bound_text(text, ctm)); bbox = fz_intersect_bbox(bbox, dev->scissor); mask = fz_new_pixmap_with_rect(ctx, NULL, bbox); fz_clear_pixmap(mask); dest = fz_new_pixmap_with_rect(ctx, model, bbox); /* FIXME: See note #1 */ fz_clear_pixmap(dest); if (dev->shape) { shape = fz_new_pixmap_with_rect(ctx, NULL, bbox); fz_clear_pixmap(shape); } else shape = dev->shape; dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; dev->stack[dev->top].dest = dev->dest; dev->stack[dev->top].shape = dev->shape; /* FIXME: See note #1 */ dev->stack[dev->top].blendmode = dev->blendmode | FZ_BLEND_ISOLATED; dev->scissor = bbox; dev->dest = dest; dev->shape = shape; #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top, "Clip (stroke text) begin\n"); #endif dev->top++; if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { gid = text->items[i].gid; if (gid < 0) continue; tm.e = text->items[i].x; tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); glyph = fz_render_stroked_glyph(ctx, dev->cache, text->font, gid, trm, ctm, stroke); if (glyph) { draw_glyph(NULL, mask, glyph, x, y, bbox); if (dev->shape) draw_glyph(NULL, dev->shape, glyph, x, y, bbox); fz_drop_pixmap(ctx, glyph); } } } }
bool Fl_Slider::draw(int ix, int iy, int iw, int ih, Fl_Flags flags, bool slot) { // for back compatability, use type flag to set slider size: if (type()&FILL) slider_size(0); // if user directly set selected_color we use it: if (style()->selection_color) flags.set(FL_SELECTED); // figure out where the slider should be: int sx = ix, sy = iy, sw = iw, sh = ih; int sp; if (horizontal()) { sx = sp = ix+slider_position(value(),iw); sw = slider_size_; if (!sw) // fill slider { sw = sx-ix; sx = ix; } } else { sy = sp = iy+slider_position(value(),ih); sh = slider_size_; if (!sh) sh = iy+ih-sy; // fill slider } if (damage()&FL_DAMAGE_ALL) { fl_push_clip(0, 0, w(), h()); // draw the slider draw_glyph(0, sx, sy, sw, sh, flags); // clip out the area of the slider fl_clip_out(sx, sy, sw, sh); } else if (sp != old_position) { // update a moving slider: // draw slider in new position draw_glyph(0, sx, sy, sw, sh, flags); // clip to the region the old slider was in: if (horizontal()) { if (slider_size_) fl_push_clip(old_position, sy, sw, sh); else fl_push_clip(ix, iy, old_position, ih); } else { if (slider_size_) fl_push_clip(sx, old_position, sw, sh); else fl_push_clip(ix, old_position, iw, iy+ih-old_position); } // don't erase new slider fl_clip_out(sx, sy, sw, sh); } else { // update for the highlight turning on/off if (damage() & FL_DAMAGE_HIGHLIGHT) draw_glyph(0, sx, sy, sw, sh, flags); // otherwise no changes return false; } old_position = sp; // we draw a slot if it seems the box has no border: if (slot) { const int slot_size_ = 6; int slx, sly, slw, slh; int dx = (slider_size_-slot_size_)/2; if (dx < 0) dx = 0; if (horizontal()) { slx = dx; slw = iw-2*dx; slx += ix; sly = iy+(ih-slot_size_+1)/2; slh = slot_size_; } else { sly = dx; slh = ih-2*dx; sly += iy; slx = ix+(iw-slot_size_+1)/2; slw = slot_size_; } button_box()->draw(slx, sly, slw, slh, FL_BLACK, flags&FL_INACTIVE|FL_VALUE); fl_clip_out(slx, sly, slw, slh); } return true; }