/*
* SPCtrl
*
* (non-aa) images
*
*/
#include "sp-canvas-util.h"
#include "sodipodi-ctrl.h"
#include "display/cairo-utils.h"
#include "display/sp-canvas.h"
enum {
};
static void sp_ctrl_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void sp_ctrl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void
{
ARG_SHAPE, g_param_spec_int ("shape", "shape", "Shape", 0, G_MAXINT, SP_CTRL_SHAPE_SQUARE, (GParamFlags) G_PARAM_READWRITE));
ARG_MODE, g_param_spec_int ("mode", "mode", "Mode", 0, G_MAXINT, SP_CTRL_MODE_COLOR, (GParamFlags) G_PARAM_READWRITE));
ARG_ANCHOR, g_param_spec_int ("anchor", "anchor", "Anchor", 0, G_MAXINT, SP_ANCHOR_CENTER, (GParamFlags) G_PARAM_READWRITE));
ARG_SIZE, g_param_spec_double ("size", "size", "Size", 0.0, G_MAXDOUBLE, 8.0, (GParamFlags) G_PARAM_READWRITE));
ARG_FILLED, g_param_spec_boolean ("filled", "filled", "Filled", TRUE, (GParamFlags) G_PARAM_READWRITE));
ARG_FILL_COLOR, g_param_spec_int ("fill_color", "fill_color", "Fill Color", G_MININT, G_MAXINT, 0x000000ff, (GParamFlags) G_PARAM_READWRITE));
ARG_STROKED, g_param_spec_boolean ("stroked", "stroked", "Stroked", FALSE, (GParamFlags) G_PARAM_READWRITE));
ARG_STROKE_COLOR, g_param_spec_int ("stroke_color", "stroke_color", "Stroke Color", G_MININT, G_MAXINT, 0x000000ff, (GParamFlags) G_PARAM_READWRITE));
}
static void
{
switch (prop_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:
// A pixbuf defines it's own size, don't mess about with size.
if (gdk_pixbuf_get_has_alpha(pixbuf)) {
} else {
}
break;
default:
return; // Do not do an update
}
}
static void
{
switch (prop_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:
break;
default:
break;
}
}
static void
{
}
{
}
}
static void
{
gint x, y;
item->canvas->requestRedraw(ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
}
if (!ctrl->defined) return;
case SP_ANCHOR_N:
case SP_ANCHOR_CENTER:
case SP_ANCHOR_S:
break;
case SP_ANCHOR_NW:
case SP_ANCHOR_W:
case SP_ANCHOR_SW:
break;
case SP_ANCHOR_NE:
case SP_ANCHOR_E:
case SP_ANCHOR_SE:
break;
}
case SP_ANCHOR_W:
case SP_ANCHOR_CENTER:
case SP_ANCHOR_E:
break;
case SP_ANCHOR_NW:
case SP_ANCHOR_N:
case SP_ANCHOR_NE:
break;
case SP_ANCHOR_SW:
case SP_ANCHOR_S:
case SP_ANCHOR_SE:
break;
}
sp_canvas_update_bbox (item, ctrl->box.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 1);
}
static double
{
*actual_item = item;
return 1e18;
}
static void
{
guint32 *p, *q;
} else {
}
} else {
fill_color = 0;
}
} else {
}
} else {
}
if (width < 2) return;
case SP_CTRL_SHAPE_SQUARE:
// top edge
for (x=0; x < width; x++) {
*p++ = stroke_color;
}
// middle
for (y = 2; y < height; y++) {
*p++ = stroke_color; // stroke at first and last pixel
for (x=2; x < width; x++) {
*p++ = fill_color; // fill in the middle
}
*p++ = stroke_color;
}
// bottom edge
for (x=0; x < width; x++) {
*p++ = stroke_color;
}
break;
case SP_CTRL_SHAPE_DIAMOND:
for (y = 0; y < height; y++) {
z = abs (c - y);
for (x = 0; x < z; x++) {
*p++ = 0;
}
*p++ = stroke_color; x++;
for (; x < width - z -1; x++) {
*p++ = fill_color;
}
if (z != c) {
*p++ = stroke_color; x++;
}
for (; x < width; 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 < width) {
*p++ = 0;
*q-- = 0;
x++;
}
s = z;
}
break;
case SP_CTRL_SHAPE_CROSS:
for (y = 0; y < height; 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 < width; x++) {
*p++ = 0;
}
}
break;
case SP_CTRL_SHAPE_BITMAP:
unsigned char *px;
unsigned int rs;
for (y = 0; y < height; y++){
guint32 *d;
unsigned char *s;
for (x = 0; x < width; 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 < height; y++){
for (x = 0; x < width; 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
}
// 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
cairo_rectangle(buf->ct, ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top(), w, h);
} else {
}
}
if (p != _point) {
}
_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 :