/usr/share/nickle/nichrome-border.5c is in cairo-5c 1.14.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /*
* Copyright © 2012 Keith Packard <keithp@keithp.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
autoload Nichrome;
extend namespace Nichrome {
public namespace Border {
import Cairo;
protected typedef widget_t + struct {
real left, right, top, bottom;
rgba_color_t color;
*widget_t child;
} border_t;
protected void natural (cairo_t cr, *border_t widget) {
save(cr);
translate(cr, widget->left, widget->top);
widget->child->natural(cr, widget->child);
restore(cr);
rect_t r = Cairo::fill_extents(cr);
new_path(cr);
rectangle (cr, r.x - widget->left, r.y -widget-> top,
r.width + widget->left + widget->right,
r.height + widget->top + widget->bottom);
}
protected void outline (cairo_t cr, *border_t widget) {
rectangle (cr, 0, 0, 0, 0);
}
protected void draw (cairo_t cr, *border_t widget) {
save(cr);
set_fill_rule(cr, fill_rule_t.EVEN_ODD);
set_source_rgba (cr, widget->color.red, widget->color.green,
widget->color.blue, widget->color.alpha);
rectangle (cr, 0, 0, widget->geometry.width, widget->geometry.height);
rectangle (cr,
widget->left,
widget->top,
widget->geometry.width - widget->right - widget->left,
widget->geometry.height - widget->bottom - widget->top);
fill (cr);
restore(cr);
}
protected void configure (*border_t widget, rect_t geometry) {
widget->geometry = geometry;
widget->child->configure (widget->child, (rect_t) {
.x = geometry.x + widget->left,
.y = geometry.y + widget->top,
.width = geometry.width - widget->left - widget->right,
.height = geometry.height - widget->top - widget->bottom
});
}
protected void remove (*border_t widget) {
widget->child->remove (widget->child);
Widget::remove(widget);
}
protected void print (*border_t widget, int indent) {
do_indent(indent);
printf ("border %d %d %d %d\n", widget->left, widget->right, widget->top, widget->bottom);
widget->child->print (widget->child, indent + 8);
}
protected void init (*border_t widget, *widget_t child, real args ...) {
Widget::init(&child->nichrome, widget);
widget->child = child;
switch (dim(args)) {
case 0:
widget->left = widget->top = widget->right = widget->bottom = 1;
break;
case 1:
widget->left = widget->top = widget->right = widget->bottom = args[0];
break;
case 2:
case 3:
widget->left = widget->right = args[0];
widget->top = widget->bottom = args[1];
break;
case 4:
widget->left = args[0];
widget->right = args[1];
widget->top = args[2];
widget->bottom = args[3];
break;
}
widget->draw = draw;
widget->outline = outline;
widget->natural = natural;
widget->configure = configure;
widget->remove = remove;
widget->print = print;
widget->color = (rgba_color_t) {
red = 0, green = 0, blue = 0, alpha = 1
};
}
protected *widget_t new (*widget_t child, real args...) {
*border_t widget = &(border_t) {};
init(widget, child, args...);
return widget;
}
}
}
|