Roxen.git
/
server
/
modules
/
graphics
/
gbutton.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/modules/graphics/gbutton.pike:18:
// icon-data -- inline icon data // align -- left|center|right text alignment // align-icon -- left|center-before|center-after|right icon alignment // valign-icon -- above|middle|below icon vertical 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.
69
2000/12/11
05
:
14
:
56
nilsson
Exp $";
+
constant cvs_version = "$Id: gbutton.pike,v 1.
70
2000/12/11
10
:
44
:
43
per
Exp $";
constant thread_safe = 1; #include <module.h> inherit "module"; roxen.ImageCache button_cache; constant module_type = MODULE_TAG; constant module_name = "GButton"; constant module_doc =
Roxen.git/server/modules/graphics/gbutton.pike:382:
else if (args->icd) icon = roxen.low_decode_image(args->icd); int i_width = icon && icon->img->xsize(); int i_height = icon && icon->img->ysize(); int i_spc = i_width && sizeof(text) && 5; // Generate text if (sizeof(text)) {
-
Font button_font = resolve_font( args->font+" "
+text_height
);
+
int os, dir;
+
Font button_font
;
+
int th
=
text_height;
+
do
+
{
+
button_font =
resolve_font( args->font+" "
+th
);
text_img = button_font->write(text);
-
if(
abs
(text_img->ysize() -text_height) > 2 )
+
os = text_img->ysize();
+
if(
!dir )
+
{
+
if
(
os <
text_
height ) { dir = 1; th++; }
+
if( os > text_height ) { dir =-1; th--; }
+
} else {
+
if( dir > 0 && os > text_height )
+
break;
+
if( dir < 0 && os < text_height )
+
break;
+
if( os == text_height )
+
break;
+
th += dir;
+
}
+
} while( (text_
img->ysize() -
text_height)
>1
+
&& (th
>
0
&& th<text_height*
2
));
+
+
// fonts that can not be scaled.
+
if( abs(text_img->ysize(
)
- text_height)>1 )
text_img = text_img->scale(0, text_height );
-
+
else
+
{
+
int o = text_img->ysize() - text_height;
+
top -= o;
+
middle -= o/2;
+
}
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. Only incorporate icon width/spacing if // it's placed inline with the text. req_width = t_width + left + right;