static TApItem *dialog_get (int err, const char *prop) { TApItem *ap; char *buf = malloc (strlen (prop) + 8); // +8: d i a l o g . \0 if (err) strcpy (buf, "error."); else strcpy (buf, "dialog."); strcat (buf, prop); ap = ttk_ap_get (buf); free (buf); return ap; }
void podwrite_widget_draw(TWidget * wid, ttk_surface srf) { int h = wid->h - (((TiBuffer *)wid->data)->idata[2]) - 1; ttk_ap_fillrect(srf, ti_ap_getx(0), wid->x, wid->y, wid->x+wid->w, wid->y+wid->h); ti_multiline_text(srf, ttk_textfont, wid->x+5, wid->y+5, wid->w-15, wid->h-10-(((TiBuffer *)wid->data)->idata[2]), ti_ap_get(1), ((TiBuffer *)wid->data)->text, ((TiBuffer *)wid->data)->cpos, ((podwrite_linecount > podwrite_screenlines)?podwrite_scroll:0), &podwrite_linecount, &podwrite_screenlines, &podwrite_cursor_out_of_bounds); if (podwrite_linecount > podwrite_screenlines) { ttk_ap_fillrect (srf, ttk_ap_get ("scroll.bg"), wid->x + wid->w - 10, wid->y + ttk_ap_getx ("header.line") -> spacing, wid->x + wid->w, wid->y + h); ttk_ap_rect (srf, ttk_ap_get ("scroll.box"), wid->x + wid->w - 10, wid->y + ttk_ap_getx ("header.line") -> spacing, wid->x + wid->w, wid->y + h); ttk_ap_fillrect (srf, ttk_ap_get ("scroll.bar"), wid->x + wid->w - 10, wid->y + ttk_ap_getx ("header.line") -> spacing + ((podwrite_scroll) * (h-2) / podwrite_linecount), wid->x + wid->w, wid->y - ttk_ap_getx ("header.line") -> spacing + ((podwrite_scroll + podwrite_screenlines) * (h-2) / podwrite_linecount) ); } }
/* progress bar borrowed from courtc's mpdc module */ static void fill_copied_percent(PzWidget *wid, ttk_surface srf, int per, int y){ int num = per > 100 ? 100 : per; int w = wid->w - (wid->w / 6); int x = (wid->w - w) / 2; //int y = wid->h - 30; int pw = (w * num) / 100; const int h = 9; if (ttk_ap_get("music.bar.bg")) ttk_ap_fillrect(srf, ttk_ap_get("music.bar.bg"), x,y,x+w+1,y+h); ttk_ap_fillrect(srf, ttk_ap_get("music.bar"), x, y, x + pw + 1, y + h); ttk_ap_hline(srf, ttk_ap_get("window.fg"), x, x + w, y - 1); ttk_ap_hline(srf, ttk_ap_get("window.fg"), x, x + w, y + h); ttk_ap_vline(srf, ttk_ap_get("window.fg"), x - 1, y, y +(h - 1)); ttk_ap_vline(srf, ttk_ap_get("window.fg"), x+w+1, y, y +(h - 1)); }
TApItem * ti_ap_getx(int i) { TApItem * tai; switch (i) { case 0: tai = ttk_ap_get("input.bg"); if (!tai) { tai = ttk_ap_getx("window.bg"); } return tai; break; case 1: tai = ttk_ap_get("input.fg"); if (!tai) { tai = ttk_ap_getx("window.fg"); } return tai; break; case 2: tai = ttk_ap_get("input.selbg"); if (!tai) { tai = ttk_ap_getx("menu.selbg"); } return tai; break; case 3: tai = ttk_ap_get("input.selfg"); if (!tai) { tai = ttk_ap_getx("menu.selfg"); } return tai; break; case 4: tai = ttk_ap_get("input.border"); if (!tai) { tai = ttk_ap_getx("window.border"); } return tai; break; case 5: tai = ttk_ap_get("input.cursor"); if (!tai) { tai = ttk_ap_getx("window.border"); } return tai; break; } return 0; }
/* this basically just calls the current clock face routine */ void draw_truchet( PzWidget *widget, ttk_surface srf ) { int x,y; int modulo=1; unsigned short slash1[] = { 0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004, 0x0002, 0x0001, 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100, }; unsigned short slash2[] = { 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, }; unsigned short curve1[] = { 0x0180, 0x0180, 0x01c0, 0x01c0, 0x00e0, 0x00f0, 0x007c, 0xf03f, 0xfc0f, 0x3e00, 0x0f00, 0x0700, 0x0380, 0x0380, 0x0180, 0x0180, }; unsigned short curve2[] = { 0x0180, 0x0180, 0x0380, 0x0380, 0x0700, 0x0f00, 0x3e00, 0xfc0f, 0xf03f, 0x003c, 0x00f0, 0x00e0, 0x01c0, 0x01c0, 0x0180, 0x0180, }; unsigned short sl1[] = { 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff, }; unsigned short sl2[] = { 0xffff, 0x7fff, 0x3fff, 0x1fff, 0x0fff, 0x07ff, 0x03ff, 0x01ff, 0x00ff, 0x007f, 0x003f, 0x001f, 0x000f, 0x0007, 0x0003, 0x0001, }; unsigned short sl3[] = { 0xffff, 0xfffe, 0xfffc, 0xfff8, 0xfff0, 0xffe0, 0xffc0, 0xff80, 0xff00, 0xfe00, 0xfc00, 0xf800, 0xf000, 0xe000, 0xc000, 0x8000, }; unsigned short sl4[] = { 0x8000, 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80, 0xffc0, 0xffe0, 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff, }; unsigned short *tile1 = curve1; unsigned short *tile2 = curve2; unsigned short *tile3 = curve1; unsigned short *tile4 = curve2; ttk_gc gc = ttk_new_gc(); TWindow *pixmap = malloc (sizeof(TWindow)); pixmap->srf = srf; /* deal with user input */ if( tglob.clicks > 5 ) tglob.clicks = 0; if( tglob.clicks & 1 ) { tglob.bg = ttk_ap_get( "window.bg" )->color; tglob.fg = ttk_ap_get( "window.fg" )->color; } else { tglob.bg = ttk_ap_get( "window.fg" )->color; tglob.fg = ttk_ap_get( "window.bg" )->color; } tglob.border = ttk_ap_get( "window.border" )->color; /* clicks & 1 => color */ /* clicks >> 1 => style */ switch( (tglob.clicks >> 1) & 3 ){ case( 0 ): tile1 = curve1; tile2 = curve2; break; case( 1 ): tile1 = slash1; tile2 = slash2; break; case( 2 ): tile1 = sl1; tile2 = sl2; tile3 = sl3; tile4 = sl4; modulo = 3; break; } ttk_fillrect( srf, 0, 0, tglob.w, tglob.h, tglob.bg ); ttk_gc_set_foreground( gc, tglob.fg ); for( x=0 ; x<tglob.bw ; x++ ) for( y=0 ; y<tglob.bh ; y++ ) { unsigned short * tile = NULL; switch( tglob.buf[x][y] & modulo ) { case( 0 ): tile = tile1; break; case( 1 ): tile = tile2; break; case( 2 ): tile = tile3; break; case( 3 ): tile = tile4; break; default: tile = tile1; break; } t_GrBitmap( pixmap, gc, x*16, y*16, 16, 16, tile ); } ttk_free_gc (gc); free (pixmap); }