Roxen.git / server / modules / graphics / gbutton.pike

version» Context lines:

Roxen.git/server/modules/graphics/gbutton.pike:18:   // icon_src -- icon reference   // icon_data -- inline icon data   // align -- left|center|right text alignment   // align_icon -- left|center_before|center_after|right icon alignment   // >Button text</gbutton>   //   // Alignment restriction: when text alignment is either left or right, icons   // must also be aligned left or right.       - constant cvs_version = "$Id: gbutton.pike,v 1.19 2000/02/08 03:35:57 per Exp $"; + constant cvs_version = "$Id: gbutton.pike,v 1.20 2000/02/08 17:35:44 jonasw Exp $";   constant thread_safe = 1;      #include <module.h>   inherit "module";   inherit "roxenlib";         roxen.ImageCache button_cache;      
Roxen.git/server/modules/graphics/gbutton.pike:113:    ]) );   }      Image.Layer stretch_layer( Image.Layer o, int x1, int x2, int w )   {    Image.Layer l, m, r;    int leftovers = w - (x1 + (o->xsize()-x2) );    object oo = o;       l = layer_slice( o, 0, x1 ); -  m = layer_slice( o, x1+1, x2+1 ); +  m = layer_slice( o, x1+1, x2-1 );    r = layer_slice( o, x2, o->xsize() );       m->set_image( m->image()->scale( leftovers, l->ysize() ),    m->alpha()->scale( leftovers, l->ysize() ));       l->set_offset( 0,0 );    m->set_offset( x1,0 );    r->set_offset( w-r->xsize(),0 );    o = Image.lay( ({ l, m, r }) );    return o;
Roxen.git/server/modules/graphics/gbutton.pike:199:       int text_height = bottom - top;       // Get icon    if (args->icn)    icon = roxen.low_load_image(args->icn, id);    else if (args->icd)    icon = roxen.low_decode_image(args->icd);       int i_width = icon && icon->img->xsize(); +  int i_spc = i_width ? 5 : 0;       // Generate text    if (sizeof(text))    {    text_img = button_font->write(text)->scale(0, text_height );    if (args->cnd)    text_img = text_img->scale((int) round(text_img->xsize() * 0.8),    text_img->ysize());    }       int t_width = text_img && text_img->xsize();       // Compute text and icon placement -  req_width = text_img->xsize() + left + right + (i_width?i_width + 5:0); +  req_width = text_img->xsize() + left + right + i_width + i_spc;       if (args->wi && (req_width < args->wi))    req_width = args->wi;       int icn_x, txt_x;       switch (lower_case(args->al))    {    case "left":    // Allow icon alignment: left, right    switch (lower_case(args->ica))    {    case "left":    icn_x = left; -  txt_x = icn_x + i_width + 5; +  txt_x = icn_x + i_width + i_spc;    break;    default:    case "right":    txt_x = left;    icn_x = req_width - right - i_width;    break;    }    break;       default:    case "center":    case "middle":    // Allow icon alignment: left, center, center_before, center_after, right    switch (lower_case(args->ica))    {    case "left":    icn_x = left; -  txt_x = icn_x + i_width + -  (req_width - icn_x - i_width - 5) -  - t_width / 2; +  txt_x = (req_width - right - left - i_width - i_spc - t_width) / 2; +  txt_x += icn_x + i_width + i_spc;    break;    default:    case "center":    case "center_before": -  icn_x = (req_width - i_width - t_width) / 2; -  txt_x = icn_x + i_width; +  icn_x = (req_width - i_width - i_spc - t_width) / 2; +  txt_x = icn_x + i_width + i_spc;    break;    case "center_after": -  txt_x = (req_width - i_width - t_width) / 2; -  icn_x = txt_x + t_width + left; +  txt_x = (req_width - i_width - i_spc - t_width) / 2; +  icn_x = txt_x + t_width + i_spc;    break;    case "right":    icn_x = req_width - right - i_width; -  txt_x = left + (icn_x - 5 - t_width) / 2; +  txt_x = left + (icn_x - i_spc - t_width) / 2;    break;    }    break;       case "right":    // Allow icon alignment: left, right    switch (lower_case(args->ica))    {    default:    case "left":    icn_x = left;    txt_x = req_width - right - t_width;    break;    case "right":    icn_x = req_width - right - i_width; -  txt_x = icn_x - 5 - t_width; +  txt_x = icn_x - i_spc - t_width;    break;    }    break;    }    -  +     right = frame->xsize()-right; -  +     frame = stretch_layer( frame, left, right, req_width ); -  +  if (mask != frame) +  mask = stretch_layer( mask, left, right, req_width );       if( background )    {    if( !background->alpha() )    background->set_image( background->image(),    Image.Image( background->xsize(),    background->ysize(),    ({255,255,255}) ) );    if( args->dim )    background->set_image(background->image(),