Естественно, интересуют только варианты с сохранением исходных пропорций. Типа такого :
phpBB [media]
Список разделов › foobar2000 › Секреты foobar2000
function RGB(r, g, b) {
return (0xff000000 | (r << 16) | (g << 8) | (b));
}
function RGBA(r, g, b, a) {
return ((a << 24) | (r << 16) | (g << 8) | (b));
}
var WshShell = new ActiveXObject("WScript.Shell");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var images_path = fb.ProfilePath + "themes\\" + "buttons\\"
DT_TOP = 0x00000000;
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_RIGHT = 0x00000002;
DT_VCENTER = 0x00000004;
DT_WORDBREAK = 0x00000010;
DT_CALCRECT = 0x00000400;
DT_NOPREFIX = 0x00000800;
DT_END_ELLIPSIS = 0x00008000;
MF_GRAYED = 0x00000001;
MF_STRING = 0x00000000;
IDC_ARROW = 32512;
IDC_HAND = 32649;
var font;
var ww=800;
var wh=600;
var bw=50;
var bh=40;
var kx=8;
var ky=3;
var cur_btn;
var g_down = false;
var font_n;
on_size;
text = " ''резиновые'' шрифты и кнопки в WSH";
colour = RGB(15,150,250);
ButtonStates = {
normal: 0,
hover: 1,
down: 2,
hide: 3
}
var g_theme = window.CreateThemeManager("Button");
function on_size() {
ww = window.Width;
wh = window.Height;
font_n = Math.ceil(ww/20);
font = gdi.Font("Segoe UI", font_n);
buttons = {
b1: new SimpleButton(0, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\VU2_off.png", function () { fb.Stop(); }),
b2: new SimpleButton(0+ww/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\Explorer_off.png", function () { fb.Pause(); }),
b3: new SimpleButton(0+ww*2/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\Play_pause_off.png", function () { fb.Play(); }),
b4: new SimpleButton(0+ww*3/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\Previous_off.png", function () { fb.Prev(); }),
b5: new SimpleButton(0+ww*4/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\Next_off.png", function () { fb.Next(); }),
b6: new SimpleButton(0+ww*5/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\Clock_off.png", function () { fb.ShowPreferences(); }),
b7: new SimpleButton(0+ww*6/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\DClock_off.png", function () { fb.RunMainMenuCommand("Library/Search"); }),
b8: new SimpleButton(0+ww*7/kx, wh-ww/1.5/kx-5, ww/kx, ww/1.5/kx, images_path + "\\PS_off.png", function() { WshShell.Run("http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Title_Formatting_Reference"); }),
}
}
function on_paint(gr) {
gr.FillGradRect(0, 0, ww, wh, 90, RGBA(0, 100, 150, 255), RGBA(19, 33, 45, 255));
gr.SetSmoothingMode(2);
gr.DrawString(text, font, colour, 0, 0, ww, wh, DT_LEFT | DT_TOP);
line_length = gr.MeasureString(text, font, 0, 0, ww, wh, 0).Width;
drawAllButtons(gr);
}
function SimpleButton(x, y, w, h, img, fonClick, state) {
this.state = state ? state : ButtonStates.normal;
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.img = img ? gdi.image(img) : null;
this.fonClick = fonClick;
this.containXY = function (x, y) {
return (this.x <= x) && (x <= this.x + this.w) && (this.y <= y) && (y <= this.y + this.h);
}
this.changeState = function (state) {
var old = this.state;
this.state = state;
return old;
}
this.draw = function (gr) {
if (this.state == ButtonStates.hide) return;
switch (this.state) {
case ButtonStates.normal:
g_theme.SetPartAndStateId(6, 1);
break;
case ButtonStates.hover:
g_theme.SetPartAndStateId(6, 2);
break;
case ButtonStates.down:
g_theme.SetPartAndStateId(6, 3);
break;
case ButtonStates.hide:
return;
}
g_theme.DrawThemeBackground(gr, this.x, this.y, this.w, this.h);
this.img && gr.DrawImage(this.img, this.x , this.y, ww/kx, ww/1.5/kx, 0, 0, this.img.Width, this.img.Height);
}
this.onClick = function () {
this.fonClick && this.fonClick();
}
}
function drawAllButtons(gr) {
for (var i in buttons) {
buttons[i].draw(gr);
}
}
function chooseButton(x, y) {
for (var i in buttons) {
if (buttons[i].containXY(x, y) && buttons[i].state != ButtonStates.hide) return buttons[i];
}
return null;
}
function on_mouse_leave() {
g_down = false;
if (cur_btn) {
cur_btn.changeState(ButtonStates.normal);
window.Repaint();
}
}
function on_mouse_move(x, y) {
var old = cur_btn;
cur_btn = chooseButton(x, y);
if (old == cur_btn) {
if (g_down) return;
} else if (g_down && cur_btn && cur_btn.state != ButtonStates.down) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
return;
}
old && old.changeState(ButtonStates.normal);
cur_btn && cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}
function on_mouse_lbtn_down(x, y) {
g_down = true;
if (cur_btn) {
cur_btn.changeState(ButtonStates.down);
window.Repaint();
}
}
function on_mouse_lbtn_up(x, y) {
g_down = false;
if (cur_btn) {
cur_btn.onClick();
cur_btn.changeState(ButtonStates.hover);
window.Repaint();
}
}
function on_mouse_rbtn_up(x, y) {
var _menu = window.CreatePopupMenu();
if (utils.IsKeyPressed(0x10)) _menu.AppendMenuItem(MF_STRING, 1, "Properties");
_menu.AppendMenuItem(MF_STRING, 2, "Configure...");
idx = _menu.TrackPopupMenu(x, y);
if (idx == 1) window.ShowProperties();
if (idx == 2) window.ShowConfigure();
_menu.Dispose();
return true;
}
Вернуться в Секреты foobar2000