Roxen.git
/
server
/
modules
/
graphics
/
gbutton.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/modules/graphics/gbutton.pike:1:
// Button module. Generates graphical buttons for use in Roxen config // interface, Roxen SiteBuilder and other places. //
-
// Copyright © 1999 Idonex AB. Author: Jonas Walldén, <jonasw@idonex.se>
+
// Copyright © 1999
-2000
Idonex AB. Author: Jonas Walldén, <jonasw@idonex.se>
// Usage: // // <gbutton // bgcolor -- background color inside/outside button // bordercolor -- button border color // textcolor -- button text color // href -- button URL // alt -- alternative button alt text
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.
8
1999
/
12
/
09
09
:
58
:
57
nilsson Exp $";
+
constant cvs_version = "$Id: gbutton.pike,v 1.
9
2000
/
01
/
10
11
:
49
:
12
nilsson Exp $";
constant thread_safe = 1; #include <module.h> inherit "module"; inherit "roxenlib"; roxen.ImageCache button_cache; Image.Font button_font; Image.Image button_border;
Roxen.git/server/modules/graphics/gbutton.pike:113:
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;
+
// Load 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);
+
}
+
// Colorize borders if (!args->dim) b = button_border->clone()->grey()->
-
modify_by_intensity(1, 1, 1, args->bo,
({
255, 255, 255 }
)
)
;
+
modify_by_intensity(1, 1, 1, args->bo,
args->bob
);
else { array dim_bg = ({ 255, 255, 255 }); array dim_bo = ({ 0, 0, 0 }); for (int i = 0; i < 3; i++) { dim_bo[i] = (args->bo[i] + args->bg[i]) / 2; dim_bg[i] = (args->bg[i] + dim_bg[i]) / 2; } b = button_border->clone()->grey()->
Roxen.git/server/modules/graphics/gbutton.pike:247:
for (int i = 0; i < 3; i++) args->txt[i] = (args->txt[i] + args->bg[i]) / 2; button->paste_alpha_color(text_img, args->txt, txt_x, 2); return button; } mapping find_internal(string f, RequestID id) {
-
// Load 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);
-
}
-
+
return button_cache->http_file_answer(f, id); } string tag_button(string tag, mapping args, string contents, RequestID id) { mapping new_args = ([
-
"
bo
" : parse_color(args->
bordercolor
||
"#333333"),
//
Border
color
-
"bg"
:
parse_color(args
->bgcolor || "#eeeeee"), // Background color
-
"txt" : parse_color(args->textcolor || "#000000"), // Text 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 ]);
-
+
if(args->bordercolor)
+
new_args->bo=parse_color(args->bordercolor); // Border color
+
else
+
new_args->bo=Array.map(new_args->bg, lambda(int c){ return c/5; });
+
+
if(args->borderbottom)
+
new_args->bob=parse_color(args->borderbottom);
+
else
+
new_args->bob=Array.map(new_args->bg, lambda(int c){ c=c*2+64; return c>255?255:c; });
+
new_args->quant = args->quant || 128; foreach(glob("*-*", indices(args)), string n) new_args[n] = args[n]; string img_src = query_internal_location() + button_cache->store( ({ new_args, contents }), id); if( tag == "gbutton-url" ) return img_src;