void textedit_draw_update ( struct widget *self ) { g_error e; struct cursor * c; if (!DATA->update_clean) { /* Translate to screen coordinates */ DATA->update_x1 += self->in->div->r.x; DATA->update_x2 += self->in->div->r.x; DATA->update_y1 += self->in->div->r.y; DATA->update_y2 += self->in->div->r.y; grop_render(self->in->div, NULL); VID(update) (self->dt->display, DATA->update_x1, DATA->update_y1, DATA->update_x2 - DATA->update_x1, DATA->update_y2 - DATA->update_y1); /* Make sure we show cursors affected by update */ for (c = cursor_get_default(); c; c = c->next) { if ((c->sprite) && (point_in_rect(c->sprite->x, c->sprite->y, DATA->update_x1, DATA->update_y1, DATA->update_x2, DATA->update_y2) || point_in_rect(c->sprite->x + c->sprite->w, c->sprite->y + c->sprite->h, DATA->update_x1, DATA->update_y1, DATA->update_x2, DATA->update_y2))) { VID(sprite_update) (c->sprite); } } DATA->update_clean= 1; } }
void textedit_build ( struct gropctxt *c, unsigned short state, struct widget *self ) { s16 w, h, tw; g_error e; w = self->in->div->r.w - theme_lookup(PGTH_O_SCROLL_V,PGTH_P_WIDTH); h = self->in->div->r.h; self->in->div->preferred.h = h; self->in->div->preferred.w = w; if (!DATA->fd){ /* FIXME: Theme lookup foreground, background colors, border */ e = textedit_set_font (self, theme_lookup (state, PGTH_P_FONT)); // errorcheck; } assert (DATA->fd); /* * The general rule is that once you create a handle you should never * delete the object it refers to, only delete the handle */ handle_free(self->owner,DATA->bit_h); e = VID(bitmap_new) (&(DATA->bit), w, h, vid->bpp); // errorcheck; /* the handle should be owned by the application not by pgserver itself */ e = mkhandle(&DATA->bit_h, PG_TYPE_BITMAP, self->owner, DATA->bit); // errorcheck; /* Size and add the bitmap itself */ e = addgropsz(c, PG_GROP_BITMAP, 0, 0, w, h); // errorcheck; c->current->param[0] = DATA->bit_h; /* Create cursor */ e = addgropsz(c,PG_GROP_RECT, 0, 0, 0, 0); // errorcheck; c->current->flags |= PG_GROPF_COLORED; DATA->cursor_grop = c->current; DATA->cursor_state = 1; DATA->cursor_grop->param[0] = VID(color_pgtohwr)(CURSORCOLOR_ON); /* Set cursor height to that of typical char */ textedit_str_size(self, NULL, 0, &tw, &DATA->cursor_grop->r.h); DATA->cursor_grop->r.x = DATA->border_h; DATA->cursor_grop->r.y = DATA->border_v; e = text_backend_build( DATA, w, h); // errorcheck; // return success; }
void BipartiteGraph<VT> :: addEdges(const LiBEVector<LiBEPair<POSITTYPE, POSITTYPE> >& es) { LiBEVector<LiBEPair<POSITTYPE, POSITTYPE> >::const_iterator it; for(it = es.begin(); it != es.end(); ++it){ EdgeType edge(VID(0, it->first), VID(1, it->second)); addEdge(edge); } }
/* Set up divnodes */ g_error textedit_install(struct widget *self) { g_error e; WIDGET_ALLOC_DATA(texteditdata); /* main split */ e = newdiv(&self->in, self); errorcheck; self->in->flags |= PG_S_ALL; /* Visible node */ e = newdiv(&self->in->div, self); errorcheck; self->in->div->build = &textedit_build; self->in->div->state = PGTH_O_TEXTEDIT; self->in->div->flags = DIVNODE_SPLIT_EXPAND | DIVNODE_SIZE_AUTOSPLIT | DIVNODE_SIZE_RECURSIVE | DIVNODE_HOTSPOT; self->trigger_mask = PG_TRIGGER_ACTIVATE | PG_TRIGGER_DEACTIVATE | PG_TRIGGER_DRAG | PG_TRIGGER_DOWN | PG_TRIGGER_RELEASE | PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_TIMER | PG_TRIGGER_NONTOOLBAR; self->out = &self->in->next; gropctxt_init(CTX,self->in->div); self->in->div->flags |= PG_S_RIGHT; self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT; DATA->fg = VID(color_pgtohwr) (TEXT_FG); DATA->bg = VID(color_pgtohwr) (TEXT_BG); DATA->highlight = VID(color_pgtohwr) (TEXT_HIGHLIGHT); DATA->bit = NULL; DATA->thumb_size = 0; DATA->thumb_top = 0; DATA->thumb_drag_start = 0; DATA->scroll_lock = 0; e = text_backend_init(DATA); errorcheck; self->in->div->flags |= PG_S_RIGHT; self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT; e = newdiv(&self->in->div->div,self); errorcheck; self->in->div->div->build = &textedit_build_scroll; self->in->div->div->state = PGTH_O_SCROLL; self->out = &self->in->div->next; DATA->self = self; return success; }
/* Get the window the cursor is in, falling back on the debug window */ static hwrbitmap magic_cursor_display(void) { struct cursor *c = cursor_get_default(); struct divtree *dt; if (!c) return VID(window_debug)(); if (iserror(rdhandle((void**)&dt, PG_TYPE_DIVTREE, -1, c->divtree))) return VID(window_debug)(); return dt->display; }
static void medsa_print_full(netdissect_options *ndo, const struct medsa_pkthdr *medsa, u_int caplen) { u_char tag = TAG(medsa); ND_PRINT((ndo, "%s", tok2str(tag_values, "Unknown (%u)", tag))); switch (tag) { case TAG_TO_CPU: ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un")); ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d", SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa))); ND_PRINT((ndo, ", %s", tok2str(code_values, "Unknown (%u)", CODE(medsa)))); if (CFI(medsa)) ND_PRINT((ndo, ", CFI")); ND_PRINT((ndo, ", pri %d: ", PRI(medsa))); break; case TAG_FROM_CPU: ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un")); ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d", SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa))); if (CFI(medsa)) ND_PRINT((ndo, ", CFI")); ND_PRINT((ndo, ", pri %d: ", PRI(medsa))); break; case TAG_FORWARD: ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un")); if (TRUNK(medsa)) ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d", SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa))); else ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d", SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa))); if (CFI(medsa)) ND_PRINT((ndo, ", CFI")); ND_PRINT((ndo, ", pri %d: ", PRI(medsa))); break; default: ND_DEFAULTPRINT((const u_char *)medsa, caplen); return; } }
g_error html_tag_font(struct html_parse *hp, struct html_tag_params *tag) { struct html_param p; pgcolor newcolor; int setcolor = 0; int size = 0; /* Process each tag parameter */ while (html_nextarg(tag,&p)) { if (p.name_len==5 && !strncasecmp(p.name,"color",p.name_len)) { setcolor = 1; newcolor = html_findcolor(p.value,p.value_len); if (*p.value=='#') { /* Was it a hex color? */ setcolor = 1; newcolor = strtoul(p.value+1,NULL,16); } } /* FIXME: more <font> parameters */ } /* Set the new font */ text_format_modifyfont(hp->c,0,0,size); if (setcolor) hp->c->f_top->color = VID(color_pgtohwr)(newcolor); return success; }
/* Called by x11input whenever a window's size changes, * even in response to x11_window_set_size */ void x11_acknowledge_resize(hwrbitmap window, int w, int h) { if (XB(window)->sb.w != w || XB(window)->sb.h != h) { XB(window)->sb.w = w; XB(window)->sb.h = h; /* Resize the backbuffer if we're using one */ if (XB(window)->frontbuffer) { /* FIXME: can't deal with errors here! */ x11_internal_bitmap_free(XB(window)); XB(window)->sb.w = XB(window)->frontbuffer->sb.w = w; XB(window)->sb.h = XB(window)->frontbuffer->sb.h = h; x11_new_bitmap_pixmap(XB(window)); } /* Resize the divtree */ if (XB(window)->dt) { XB(window)->dt->head->r.w = w; XB(window)->dt->head->r.h = h; XB(window)->dt->head->calc.w = w; XB(window)->dt->head->calc.h = h; XB(window)->dt->head->flags |= DIVNODE_NEED_RECALC | DIVNODE_FORCE_CHILD_RECALC | DIVNODE_NEED_REBUILD; XB(window)->dt->flags |= DIVTREE_NEED_RECALC | DIVTREE_ALL_REDRAW; } /* If this is monolithic mode, we need to set the video mode to match */ if ((!VID(is_rootless)()) && (vid->xres!=w || vid->yres!=h)) video_setmode(w, h, vid->bpp, PG_FM_ON,0); } }
void def_sprite_hide(struct sprite *spr) { static struct pgquad cr; struct divtree *dt; if (disable_output) return; if (iserror(rdhandle((void**)&dt, PG_TYPE_DIVTREE, -1, spr->dt))) return; if ( (!spr->onscreen) || (spr->ox == -1) ) return; cr.x1 = spr->x; cr.y1 = spr->y; cr.x2 = spr->x+spr->w-1; cr.y2 = spr->y+spr->h-1; /* Remove sprites above this one too */ def_sprite_hide_above(spr); /* Put back the old image */ VID(blit) (dt->display,spr->ox,spr->oy,spr->ow,spr->oh, spr->backbuffer,0,0,PG_LGOP_NONE); add_updarea(dt,spr->ox,spr->oy,spr->ow,spr->oh); spr->onscreen = 0; }
/* Rebuild function for paragraph divnodes, issued by textbox_new_par_div */ void textbox_build_par_div(struct gropctxt *c, u16 state, struct widget *self) { struct paragraph *par; struct gropnode *grops = *c->headpp; /* Retrieve the paragraph pointer from the existing gropnodes */ if (iserror(rdhandle((void**)&par,PG_TYPE_PARAGRAPH,-1,grops->next->param[0])) || !par) return; /* Text color, cursor color, cursor width */ grops->param[0] = VID(color_pgtohwr)(theme_lookup(state,PGTH_P_FGCOLOR)); par->cursor.color = grops->param[0]; par->cursor.width = theme_lookup(state,PGTH_P_CURSOR_WIDTH); /* If we're displaying to a different width, rewrap it */ if (par->width != c->r.w) { par->width = c->r.w; paragraph_wrap(par,1); } /* Set gropnode sizes */ grops->next->r.x = c->r.x; grops->next->r.y = c->r.y; grops->next->r.w = c->r.w; grops->next->r.h = c->r.h; grops->next->next->r = grops->next->r; DBG("Build, size: %d,%d,%d,%d preferred: %d,%d\n", c->r.x,c->r.y,c->r.w,c->r.h,c->owner->preferred.w,c->owner->preferred.h); }
hwrbitmap x11_window_fullscreen(void) { if (VID(is_rootless)()) { /* FIXME: Implement me */ return x11_window_debug(); } return x11_monolithic_window(); }
/* FIXME: Right now these look like links but aren't really links */ g_error html_tag_a(struct html_parse *hp, struct html_tag_params *tag) { g_error e; e = text_format_modifyfont(hp->c,PG_FSTYLE_UNDERLINE,0,0); errorcheck; hp->c->f_top->color = VID(color_pgtohwr)(LINK_COLOR); return success; }
void video_shutdown(void) { if (vid) { if (vid->display && vid->bitmap_getsize==def_bitmap_getsize && ((struct stdbitmap *)vid->display)->rend) g_free(((struct stdbitmap *)vid->display)->rend); VID(close) (); } }
/* Create a backbuffer for double-buffering the given surface */ g_error x11_new_backbuffer(struct x11bitmap **backbuffer, struct x11bitmap *frontbuffer) { g_error e; e = VID(bitmap_new)((hwrbitmap*)backbuffer, frontbuffer->sb.w, frontbuffer->sb.h, vid->bpp); errorcheck; (*backbuffer)->frontbuffer = frontbuffer; return success; }
void x11_window_set_position(hwrbitmap window, s16 x, s16 y) { struct x11bitmap *xb = XB(window)->frontbuffer ? XB(window)->frontbuffer : XB(window); XWindowChanges wc; if (VID(is_rootless)()) { wc.x = x; wc.y = y; XConfigureWindow(x11_display, xb->d, CWX | CWY, &wc); } }
void cursor_show(struct cursor *crsr) { if (crsr->sprite->visible) return; cursor_widgetunder(crsr); cursor_change_under(crsr,0); crsr->sprite->visible = 1; VID(sprite_show)(crsr->sprite); }
void BipartiteGraph<VT>::addVertexes(const Link<LiBEVector<VT> >& vs) { for(size_t d = 0; d < vs.size(); ++d){ for(size_t i = 0; i < vs[d].size(); ++i){ Vertex<VT> vertex; vertex.v = vs[d][i]; (*this)[VID(d, i)] = vertex; } } }
/* Trace the outlines of all divnodes onscreen */ void r_divnode_trace(struct divnode *div) { struct groprender r; struct gropnode n; s16 lxres,lyres; VID(bitmap_getsize)(magic_cursor_display(), &lxres, &lyres); if (!div) return; memset(&r,0,sizeof(r)); memset(&n,0,sizeof(n)); /* The scroll container must be visible */ if (div->divscroll && !(div->divscroll->calc.w && div->divscroll->calc.h)) return; /* Set up rendering... */ r.output = magic_cursor_display(); n.r = div->r; r.clip.x1 = 0; r.clip.y1 = 0; r.clip.x2 = lxres-1; r.clip.y2 = lyres-1; /* Green shading for leaf divnodes */ if (!div->div && !div->next) { r.color = VID(color_pgtohwr)(0xA0FFA0); r.lgop = PG_LGOP_MULTIPLY; n.type = PG_GROP_RECT; gropnode_clip(&r,&n); gropnode_draw(&r,&n); } /* yellow box around all divnodes */ r.color = VID(color_pgtohwr)(0xFFFF00); r.lgop = PG_LGOP_NONE; n.type = PG_GROP_FRAME; gropnode_clip(&r,&n); gropnode_draw(&r,&n); r_divnode_trace(div->div); r_divnode_trace(div->next); }
/* Hide/show the cursor, also keeping track of mouse entering and leaving */ void cursor_hide(struct cursor *crsr) { handle old_under = crsr->ctx.widget_under; if (!crsr->sprite || !crsr->sprite->visible) return; crsr->sprite->visible = 0; VID(sprite_hide)(crsr->sprite); memset(&crsr->ctx,0,sizeof(crsr->ctx)); cursor_change_under(crsr,old_under); }
void medsa_print(netdissect_options *ndo, const u_char *bp, u_int length, u_int caplen) { register const struct ether_header *ep; const struct medsa_pkthdr *medsa; u_short ether_type; medsa = (const struct medsa_pkthdr *)bp; ep = (const struct ether_header *)(bp - sizeof(*ep)); ND_TCHECK(*medsa); if (!ndo->ndo_eflag) ND_PRINT((ndo, "MEDSA %d.%d:%d: ", SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa))); else medsa_print_full(ndo, medsa, caplen); bp += 8; length -= 8; caplen -= 8; ether_type = EXTRACT_16BITS(&medsa->ether_type); if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(ndo, bp, length, caplen, ESRC(ep), EDST(ep)) < 0) { /* packet type not known, print raw packet */ if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(bp, caplen); } } else { if (ndo->ndo_eflag) ND_PRINT((ndo, "ethertype %s (0x%04x) ", tok2str(ethertype_values, "Unknown", ether_type), ether_type)); if (ethertype_print(ndo, ether_type, bp, length, caplen) == 0) { /* ether_type not known, print raw packet */ if (!ndo->ndo_eflag) ND_PRINT((ndo, "ethertype %s (0x%04x) ", tok2str(ethertype_values, "Unknown", ether_type), ether_type)); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(bp, caplen); } } return; trunc: ND_PRINT((ndo, "%s", tstr)); }
void panelbar_remove(struct widget *self) { if (DATA->s) { free_sprite(DATA->s); DATA->s = NULL; } if (DATA->sbit) { VID(bitmap_free) (DATA->sbit); DATA->sbit = NULL; } g_free(DATA); r_divnode_free(self->in); }
void free_sprite(struct sprite *s) { struct sprite *n; VID(sprite_hide) (s); /* Remove from the sprite list */ if (s==spritelist) spritelist = s->next; else { n = spritelist; while (n->next) { if (n->next == s) { n->next = s->next; break; } n = n->next; } } VID(bitmap_free) (s->backbuffer); g_free(s); }
/* Let the driver register itself, and initialize things */ g_error load_vidlib(g_error (*regfunc)(struct vidlib *v), s16 xres,s16 yres,s16 bpp,u32 flags) { g_error e; /* Unload */ if (vid) VID(close) (); /* Clear it */ vid = &vidlib_static; vidwrap = vid; /* No transforms */ memset(vid,0,sizeof(struct vidlib)); vid->close = &emulate_dos; vid->update = &def_update; vid->setmode = &def_setmode; /* Device registration */ e = (*regfunc)(vid); if (iserror(e)) { vid = NULL; return e; } inlib_main = NULL; /* By default use a static vid->display */ vid->display = (hwrbitmap) &static_display; /* Load new driver */ e = VID(init)(); if (iserror(e)) { vid = NULL; return e; } /* Set the initial mode */ return video_setmode(xres,yres,bpp,PG_FM_SET,flags); }
hwrbitmap x11_window_debug(void) { if (VID(is_rootless)()) { if (!x11_debug_window) { /* FIXME: There's nothing we can do with an error here */ x11_window_new(&x11_debug_window,NULL); XStoreName(x11_display, XB(x11_debug_window)->frontbuffer ? XB(x11_debug_window)->frontbuffer->d : XB(x11_debug_window)->d, "PicoGUI Debug Window"); x11_internal_window_resize(x11_debug_window,640,480); } return x11_debug_window; } return x11_monolithic_window(); }
g_error x11_window_new(hwrbitmap *hbmp, struct divtree *dt) { g_error e; /* In rootless mode, create a special window */ if (VID(is_rootless)()) { e = x11_create_window(hbmp); errorcheck; } /* In monolithic mode, everybody uses the same window */ else *hbmp = x11_monolithic_window(); XB(*hbmp)->dt = dt; return success; }
void x11_window_set_flags(hwrbitmap window, int flags) { struct x11bitmap *xb = XB(window)->frontbuffer ? XB(window)->frontbuffer : XB(window); XSetWindowAttributes attr; xb->window_flags = flags; /* If this is an unmanaged window or the background, * use OverrideRedirect to keep the window manager from messing with it. */ attr.override_redirect = (flags & (PG_WINDOW_UNMANAGED | PG_WINDOW_BACKGROUND)) != 0; XChangeWindowAttributes(x11_display, xb->d, CWOverrideRedirect, &attr); /* Background windows sit below everything else and take the whole screen */ if (flags & PG_WINDOW_BACKGROUND) { XLowerWindow(x11_display, xb->d); VID(window_set_size)(dts->top->display,vid->lxres,vid->lyres); } }
void x11_window_free(hwrbitmap window) { struct x11bitmap **b; if (VID(is_rootless)()) { if (XB(window)->frontbuffer) x11_bitmap_free((hwrbitmap) XB(window)->frontbuffer); /* Remove it from the window list */ for (b=&x11_window_list;*b;b=&(*b)->next_window) if (*b == XB(window)) { *b = (*b)->next_window; break; } x11_bitmap_free(window); } }
/* Sprite helper functions */ g_error new_sprite(struct sprite **ps,struct divtree *dt,s16 w,s16 h) { g_error e; e = g_malloc((void**)ps,sizeof(struct sprite)); errorcheck; memset(*ps,0,sizeof(struct sprite)); (*ps)->ox = -1; (*ps)->w = w; (*ps)->h = h; VID(bitmap_new) (&(*ps)->backbuffer,w,h,vid->bpp); (*ps)->next = spritelist; (*ps)->visible = 1; (*ps)->lgop = PG_LGOP_NONE; (*ps)->dt = hlookup(dt,NULL); spritelist = *ps; return success; }
/* Transcribe one scanline from the GIF to the picogui bitmap */ void transcribe_line(hwrbitmap b, GifFileType *f, int y, int transparent_flag, int transparent_color) { pgcolor c; u8 pixel; GifColorType *color; int x; for (x=0;x<f->Image.Width;x++) { DGifGetPixel(f, &pixel); color = f->SColorMap->Colors + (pixel % f->SColorMap->ColorCount); if (transparent_flag) { c = mkcolora(pixel==transparent_color ? 0 : 127,color->Red,color->Green,color->Blue); } else { c = mkcolor(color->Red,color->Green,color->Blue); } vid->pixel(b,x,y,VID(color_pgtohwr)(c),PG_LGOP_NONE); } }
static void textedit_draw_rect (struct widget *self, s16 x, s16 y, s16 w, s16 h, hwrcolor color) { assert (DATA->bit); if (x >= DATA->width) return; if (x + w >= DATA->width) w = DATA->width - x; if (y >= DATA->height) return; if (y + h >= DATA->height) h = DATA->height - y; VID(rect) (DATA->bit, x, y, w, h, color, PG_LGOP_NONE); add_update_region(self, x, y, w, h); }