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.15 2000/02/03 19:54:01 wellhard Exp $"; + constant cvs_version = "$Id: gbutton.pike,v 1.16 2000/02/07 03:57:39 per Exp $";   constant thread_safe = 1;      #include <module.h>   inherit "module";   inherit "roxenlib";         roxen.ImageCache button_cache; - Image.Image button_border; - Image.Image button_mask; +          // Distance between icon image and text   #define IMAGE_SPC 5         array register_module()   {    return( ({ MODULE_PARSER,    "GButton",
Roxen.git/server/modules/graphics/gbutton.pike:111:    return ([ "gbutton" : tag_button, "gbutton-url" : tag_button ]);   }         object(Image.Image)|mapping draw_button(mapping args, string text, object id)   {    Image.Image text_img, b, tmp, button;    int req_width, b_width, b_height, t_width, i_width, icn_x, txt_x;    mapping icon;    object button_font = resolve_font( args->font ); +  Image.Image button_border; +  Image.Image button_mask;    -  // Load images +  if( args->border_image ) +  { +  mapping q = roxen.low_load_image(args->border_image, id); +  if( q ) +  { +  button_border = q->img; +  if(!q->alpha) +  button_mask = Image.Image( q->img->xsize(),q->img->ysize(), +  255,255,255 ); +  else +  button_mask = q->alpha; +  } +  } +  // otherwise load default images    if (!button_border)    { -  button_border = roxen.load_image("roxen-images/gbutton_border.gif", id); -  button_mask = roxen.load_image("roxen-images/gbutton_mask.gif", id); +  mapping q = Image._load("roxen-images/gbutton_border.xcf"); +  button_border = q->img; +  button_mask = q->alpha;    }       // Colorize borders    if (!args->dim)    { -  b = button_border->clone()->grey()-> +  b = button_border->grey()->    modify_by_intensity(1, 1, 1, args->bo, args->bob );    }    else    {    array dim_bg;    array dim_bo;       array hsv = Image.Color( @args->bg )->hsv( );    hsv[-1] = min( hsv[-1]+70, 255 );   
Roxen.git/server/modules/graphics/gbutton.pike:222:    icn_x = b_width / 2;    txt_x = req_width - b_width / 2 - t_width;    break;    case "right":    icn_x = req_width - b_width / 2 - i_width + IMAGE_SPC;    txt_x = icn_x - IMAGE_SPC - t_width;    break;    }    break;    } +     button = Image.Image(req_width, b_height, args->bg);       // Paste left and right edge of border    tmp = b->copy(0, 0, b_width / 2 - 1, b_height - 1);    button->paste_mask(tmp, button_mask->copy(0, 0,    b_width / 2 - 1, b_height - 1));    tmp = b->copy(b_width / 2, 0, b_width - 1, b_height - 1); -  +     button->paste_mask(tmp, button_mask->copy(b_width / 2, 0,    b_width - 1, b_height - 1),    req_width - b_width / 2, 0);    -  +  tmp = button_mask->copy(0, 0, b_width / 2 - 1, b_height - 1) +  ->invert()->threshold(250); +  button->paste_alpha_color(tmp, args->pagebg); +  tmp = button_mask->copy(b_width / 2, 0, b_width - 1, b_height - 1) +  ->invert()->threshold(250); +  button->paste_alpha_color(tmp, args->pagebg, +  button->xsize()-tmp->xsize(), 0); +  +  +     // Stretch top/bottom borders    tmp = button->copy(b_width / 2 - 1, 0, b_width / 2 - 1, b_height - 1);    for (int offset = b_width / 2; offset <= req_width - b_width / 2; offset++)    button->paste(tmp, offset, 0);       // Draw icon    if (icon) {    int icn_y = (b_height - icon->img->ysize()) / 2;       if (!icon->alpha)
Roxen.git/server/modules/graphics/gbutton.pike:268:         mapping find_internal(string f, RequestID id)   {    return button_cache->http_file_answer(f, id);   }         string tag_button(string tag, mapping args, string contents, RequestID id)   { +  string fi = (args["frame-image"]||id->misc->defines["gbutton-frame-image"]); +  if( fi ) +  fi = fix_relative( fi, id );    mapping new_args = ([ -  "bg" : parse_color(args->bgcolor || id->misc->defines->theme_bgcolor || -  id->misc->defines->bgcolor || "#eeeeee"), // Background color +  "pagebg" :parse_color(id->misc->defines->theme_bgcolor || +  id->misc->defines->bgcolor || +  args->bgcolor || +  "#eeeeee"), // _page_ background color +  "bg" : parse_color(args->bgcolor || +  id->misc->defines->theme_bgcolor || +  id->misc->defines->bgcolor || +  "#eeeeee"), // Background color    "txt" : parse_color(args->textcolor || id->misc->defines->theme_bgcolor ||    id->misc->defines->fgcolor || "#000000"), // Text color    "cnd" : args->condensed || // Condensed text    (lower_case(args->textstyle || "") == "condensed"),    "wi" : (int) args->width, // Min button width    "al" : args->align || "left", // Text alignment    "dim" : args->dim || // Button dimming    (< "dim", "disabled" >)[lower_case(args->state || "")],    "icn" : args->icon_src && fix_relative(args->icon_src, id), // Icon URL    "icd" : args->icon_data, // Inline icon data    "ica" : args->align_icon || "left", // Icon alignment -  "font": (args->font||id->misc->defines->font||roxen->query("default_font")), +  "font": (args->font||id->misc->defines->font|| +  roxen->query("default_font")), +  "border_image":fi,    ]);       array hsv = Image.Color( @new_args->bg )->hsv( );    hsv[-1] = min( hsv[-1]+70, 255 );    hsv[1] = max( hsv[1]-20, 0 );    new_args->bob = (array)Image.Color.hsv( @hsv );    hsv[-1] = max( hsv[-1]-140, 0 );    new_args->bo = (array)Image.Color.hsv( @hsv );       if(args->bordercolor)