sodipodi-ctrl.cpp revision 23a3802b72e33acd30f7868da3600c8e488f60fd
#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
{
}
static void
{
// This way we make sure that the first sp_ctrl_update() call finishes properly;
// in subsequent calls it will not update anything it the control hasn't moved
// Consider for example the case in which a snap indicator is drawn at (0, 0);
// If moveto() is called then it will not set _moved to true because we're initially already at (0, 0)
ctrl->_moved = true; // Is this flag ever going to be set back to false? I can't find where that is supposed to happen
}
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.left(), ctrl->box.top(), ctrl->box.right() + 1, ctrl->box.bottom() + 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;
}
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 (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
cairo_rectangle(buf->ct, ctrl->box.left() - buf->rect.left(), ctrl->box.top() - buf->rect.top(), w, h);
} 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 :