sodipodi-ctrl.cpp revision 208e5a33acc4a8ad9d8c0488f047c260346f1258
#define INKSCAPE_CTRL_C
/*
* SPCtrl
*
* (non-aa) images
*
*/
#include "sp-canvas-util.h"
#include "display-forward.h"
#include "sodipodi-ctrl.h"
enum {
};
static SPCanvasItemClass *parent_class;
sp_ctrl_get_type (void)
{
if (!ctrl_type) {
sizeof (SPCtrlClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (SPCtrl),
0, /* n_preallocs */
};
}
return ctrl_type;
}
static void
{
gtk_object_add_arg_type ("SPCtrl::stroke_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STROKE_COLOR);
}
static void
{
}
static void
{
}
static void
{
switch (arg_id) {
case ARG_SHAPE:
break;
case ARG_MODE:
break;
case ARG_ANCHOR:
break;
case ARG_SIZE:
break;
case ARG_FILLED:
break;
case ARG_FILL_COLOR:
break;
case ARG_STROKED:
break;
case ARG_STROKE_COLOR:
break;
case ARG_PIXBUF:
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
} else {
}
break;
default:
break;
}
}
static void
{
gint x, y;
sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
}
if (!ctrl->defined) return;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
break;
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
break;
}
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
break;
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
break;
}
}
static double
{
*actual_item = item;
double const x = p[NR::X];
double const y = p[NR::Y];
if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
return 1e18;
}
static void
{
guchar * p, *q;
} else {
}
} else {
}
if (side < 2) return;
case SP_CTRL_SHAPE_SQUARE:
for (x=0; x < side; x++) {
}
for (y = 2; y < side; y++) {
for (x=2; x < side; x++) {
}
}
for (x=0; x < side; x++) {
}
break;
case SP_CTRL_SHAPE_DIAMOND:
for (y = 0; y < side; y++) {
z = abs (c - y);
for (x = 0; x < z; x++) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
}
for (; x < side - z -1; x++) {
}
if (z != c) {
}
for (; x < side; x++) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
}
}
break;
case SP_CTRL_SHAPE_CIRCLE:
q = p + size -1;
s = -1;
for (y = 0; y <= c ; y++) {
a = abs (c - y);
x = 0;
while (x < c-z) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
*q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
x++;
}
do {
x++;
} while (x < c-s);
while (x < MIN(c+s+1, c+z)) {
x++;
}
do {
x++;
} while (x <= c+z);
while (x < side) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
*q-- = 0x00; *q-- = 0x00; *q-- = 0x00; *q-- = 0x00;
x++;
}
s = z;
}
break;
case SP_CTRL_SHAPE_CROSS:
for (y = 0; y < side; y++) {
z = abs (c - y);
for (x = 0; x < c-z; x++) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
}
for (; x < c + z; x++) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
}
if (z != 0) {
}
for (; x < side; x++) {
*p++ = 0x00; *p++ = 0x00; *p++ = 0x00; *p++ = 0x00;
}
}
break;
case SP_CTRL_SHAPE_BITMAP:
unsigned char *px;
unsigned int rs;
for (y = 0; y < side; y++){
unsigned char *s, *d;
for (x = 0; x < side; x++) {
if (s[3] < 0x80) {
d[0] = 0x00;
d[1] = 0x00;
d[2] = 0x00;
d[3] = 0x00;
} else if (s[0] < 0x80) {
d[0] = sr;
d[1] = sg;
d[2] = sb;
d[3] = sa;
} else {
d[0] = fr;
d[1] = fg;
d[2] = fb;
d[3] = fa;
}
s += 4;
d += 4;
}
}
} else {
g_print ("control has no pixmap\n");
}
break;
case SP_CTRL_SHAPE_IMAGE:
for (y = 0; y < side; y++){
pix = q + (y * r);
for (x = 0; x < side; x++) {
*p++ = *pix++;
*p++ = *pix++;
*p++ = *pix++;
*p++ = *pix++;
}
}
} else {
g_print ("control has no pixmap\n");
}
break;
default:
break;
}
}
// composite background, foreground, alpha for xor mode
#define COMPOSE_X(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) / 0xff )
// composite background, foreground, alpha for color mode
#define COMPOSE_N(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) / 0xff )
static void
{
guchar *p, *q, a;
if (!ctrl->defined) return;
// the control-image is rendered into ctrl->cache
}
// then we render from ctrl->cache
bool colormode;
a = *(q + 3);
// 00000000 is the only way to get invisible; all other colors with alpha 00 are treated as mode_color with alpha ff
colormode = false;
if (a == 0x00 && !(q[0] == 0x00 && q[1] == 0x00 && q[2] == 0x00)) {
a = 0xff;
colormode = true;
}
p[0] = COMPOSE_N (p[0], q[0], a);
q += 4;
p += 3;
p[0] = COMPOSE_X (p[0], q[0], a);
q += 4;
p += 3;
}
}
}
}
_moved = true;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :