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) ); } }
static void draw_digit( ttk_surface srf, clocks_globals *glob, int w, int v, int use_ap, ttk_color c_ol, ttk_color c_fill, ttk_color c_dark ) { /* 0 1 2 3 */ int array[9]; /* the bits - one for each light */ TApItem *boxOn = NULL, *boxOnB = NULL; TApItem *boxOff = NULL, *boxOffB = NULL; int x, z; /* misc */ int sx=0, sy=0; /* start x/ start y for the box */ int w2 = glob->w>>1; /* w/2 */ int h2 = glob->h>>1; /* h/2 */ int w6 = glob->w/6; /* w/6 */ int h6 = glob->h/6; /* h/6 */ /* the positions in the 3x3 grid for each of the 9 lights */ int xp[9] = { 0, w6, w6+w6, 0, w6, w6+w6, 0, w6, w6+w6 }; int yp[9] = { 0, 0, 0, h6, h6, h6, h6+h6, h6+h6, h6+h6 }; /* determine sx/sy */ if( w & 0x01 ) sx = w2; else sx = 0; if( w & 0x02 ) sy = h2; else sy = 0; /* use the apearance colorscheme */ if( use_ap ) { if( w == 0 || w == 3 ) { boxOff = ttk_ap_getx( "box.default.bg" ); boxOffB = ttk_ap_getx( "box.default.border" ); boxOn = ttk_ap_getx( "box.selected.bg" ); boxOnB = ttk_ap_getx( "box.selected.border" ); } else { boxOff = ttk_ap_getx( "box.default.bg" ); boxOffB = ttk_ap_getx( "box.default.border" ); boxOn = ttk_ap_getx( "box.special.bg" ); boxOnB = ttk_ap_getx( "box.special.border" ); } } /* generate the array */ for( x=0 ; x<9 ; x++ ) array[x] = 0; for( x=0 ; x<v ; ) { int idx = rand()%9; if( !array[idx]) { array[idx] = 1; x++; } } /* draw the number */ /* 0 1 2 3 4 5 6 7 8 */ for( z=0 ; z<9 ; z++ ) { int x1 = sx+xp[z]+INS; int y1 = sy+yp[z]+INS; int x2 = sx+xp[z]+w6-INS; int y2 = sy+yp[z]+h6-INS; if( use_ap ) { ttk_ap_fillrect( srf, (array[z])? boxOn : boxOff, x1, y1, x2, y2 ); ttk_ap_rect( srf, (array[z])? boxOnB : boxOffB, x1, y1, x2, y2 ); } else { if( array[z] ) { ttk_fillrect( srf, x1, y1, x2, y2, c_fill ); ttk_rect( srf, x1, y1, x2, y2, c_ol ); } else { ttk_fillrect( srf, x1, y1, x2, y2, c_dark ); } } } }