sodipodi-ctrl.cpp revision 41956e81860e9b4971042dc68826605afa1129e1
#define INKSCAPE_CTRL_C
/*
* SPCtrl
*
* (non-aa) images
*
*/
#include "sp-canvas-util.h"
#include "sodipodi-ctrl.h"
#include "display/cairo-utils.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[Geom::X];
double const y = p[Geom::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
{
guint32 *p, *q;
} else {
}
} else {
fill_color = 0;
}
} else {
}
} else {
}
if (side < 2) return;
case SP_CTRL_SHAPE_SQUARE:
// top edge
for (x=0; x < side; x++) {
*p++ = stroke_color;
}
// middle
for (y = 2; y < side; y++) {
*p++ = stroke_color; // stroke at first and last pixel
for (x=2; x < side; x++) {
*p++ = fill_color; // fill in the middle
}
*p++ = stroke_color;
}
// bottom edge
for (x=0; x < side; x++) {
*p++ = stroke_color;
}
break;
case SP_CTRL_SHAPE_DIAMOND:
for (y = 0; y < side; y++) {
z = abs (c - y);
for (x = 0; x < z; x++) {
*p++ = 0;
}
*p++ = stroke_color; x++;
for (; x < side - z -1; x++) {
*p++ = fill_color;
}
if (z != c) {
*p++ = stroke_color; x++;
}
for (; x < side; x++) {
*p++ = 0;
}
}
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++ = 0;
*q-- = 0;
x++;
}
do {
*p++ = stroke_color;
*q-- = stroke_color;
x++;
} while (x < c-s);
while (x < MIN(c+s+1, c+z)) {
*p++ = fill_color;
*q-- = fill_color;
x++;
}
do {
*p++ = stroke_color;
*q-- = stroke_color;
x++;
} while (x <= c+z);
while (x < side) {
*p++ = 0;
*q-- = 0;
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++ = 0;
}
*p++ = stroke_color; x++;
for (; x < c + z; x++) {
*p++ = 0;
}
if (z != 0) {
*p++ = stroke_color; x++;
}
for (; x < side; x++) {
*p++ = 0;
}
}
break;
case SP_CTRL_SHAPE_BITMAP:
unsigned char *px;
unsigned int rs;
for (y = 0; y < side; y++){
guint32 *d;
unsigned char *s;
for (x = 0; x < side; x++) {
if (s[3] < 0x80) {
*d++ = 0;
} else if (s[0] < 0x80) {
*d++ = stroke_color;
} else {
*d++ = fill_color;
}
s += 4;
}
}
} else {
g_print ("control has no pixmap\n");
}
break;
case SP_CTRL_SHAPE_IMAGE:
for (y = 0; y < side; y++){
for (x = 0; x < side; x++) {
*p++ = *px++;
}
}
} else {
g_print ("control has no pixmap\n");
}
break;
default:
break;
}
}
{
return (c + 127) / 255;
}
static void
{
//gint y0, y1, y, x0,x1,x;
//guchar *p, *q, a;
if (!ctrl->defined) return;
// the control-image is rendered into ctrl->cache
}
int w, h;
// The code below works even when the target is not an image surface
// 1. Copy the affected part of output to a temporary surface
// 2. Composite the control on a temporary surface
for (int i=0; i<h; ++i) {
for (int j=0; j<w; ++j) {
} else {
}
}
}
// 3. Replace the affected part of output with contents of temporary surface
} else {
}
}
if (p != _point) {
_moved = true;
}
_point = p;
}
/*
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:fileencoding=utf-8:textwidth=99 :