dash-selector.cpp revision 05940874c84c05601c854dc95a5463af40be2652
#define __SP_DASH_SELECTOR_C__
/*
* Optionmenu for selecting dash patterns
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#define DASH_PREVIEW_WIDTH 2
#define DASH_PREVIEW_LENGTH 80
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cstring>
#include <string>
#include <libnr/nr-macros.h>
#include "../style.h"
#include "../dialogs/dialog-events.h"
#include "dash-selector.h"
enum {CHANGED, LAST_SIGNAL};
struct SPDashSelector {
};
struct SPDashSelectorClass {
};
double dash_0[] = {-1.0};
static GtkHBoxClass *parent_class;
sp_dash_selector_get_type (void)
{
if (!type) {
GtkTypeInfo info = {
"SPDashSelector",
sizeof (SPDashSelector),
sizeof (SPDashSelectorClass),
};
}
return type;
}
static void
{
GTK_TYPE_NONE, 0);
}
static void
{
GtkWidget *m = gtk_menu_new ();
gtk_widget_show (m);
for (int i = 0; dashes[i]; i++) {
}
gtk_signal_connect (dsel->offset, "value_changed", GTK_SIGNAL_FUNC (sp_dash_selector_offset_value_changed), dsel);
}
{
if (!dashes) {
int ndashes = 0;
if (drepr) {
ndashes += 1;
}
}
if (ndashes > 0) {
int pos = 0;
int i = 0;
}
d[i] = -1;
} else {
}
pos += 1;
}
}
} else {
}
}
return dsel;
}
void
{
int pos = 0;
if (ndash > 0) {
double delta = 0.0;
for (int i = 0; i < ndash; i++)
delta /= 1000.0;
for (int i = 0; dashes[i]; i++) {
int np = 0;
np += 1;
int j;
for (j = 0; j < ndash; j++) {
break;
}
if (j == ndash) {
pos = i;
break;
}
}
}
}
}
void
{
int nd = 0;
nd += 1;
if (nd > 0) {
if (ndash)
if (dash) {
}
if (offset)
} else {
if (ndash)
*ndash = 0;
if (dash)
if (offset)
*offset = 0.0;
}
}
bool
all_even_are_zero (double *pattern, int n)
{
for (int i = 0; i < n; i += 2) {
if (pattern[i] != 0)
return false;
}
return true;
}
bool
all_odd_are_zero (double *pattern, int n)
{
for (int i = 1; i < n; i += 2) {
if (pattern[i] != 0)
return false;
}
return true;
}
static GtkWidget *
{
gtk_signal_connect (GTK_OBJECT (mi), "activate", G_CALLBACK (sp_dash_selector_dash_activate), dsel);
g_signal_connect_after(G_OBJECT(px), "realize", G_CALLBACK(sp_dash_selector_menu_item_image_realize), pattern);
return mi;
}
// FIXME: all of the below twibblering is due to the limitations of gdk_gc_set_dashes (only integers, no zeroes).
// Perhaps would make sense to rework this with manually drawn dashes.
// Fill in the integer array of pixel-lengths, for display
int n_source_dashes = 0;
int n_pixel_dashes = 0;
}
// calculate the pixel length corresponding to the current dash
if (pixels > 0.0)
else {
if (i_p >= 1) {
// dash is zero, skip this element in the array, and set pointer backwards so the next dash is added to the previous
i_p -= 2;
} else {
// the first dash is zero; bad luck, gdk cannot start pattern with non-stroke, so we put a 1-pixel stub here
// (it may turn out not shown, though, see special cases below)
}
}
}
// after summation, convert double dash lengths to ints
// zero-length dashes are already eliminated, so the <1 dash is short but not zero;
// we approximate it with a one-pixel mark
}
}
// fake "shortening" of one-pixel marks by painting them lighter-than-black
} else {
}
if (n_source_dashes > 0) {
// special cases:
; // do not draw anything, only gaps are non-zero
// draw solid line, only dashes are non-zero
} else {
// regular pattern with both gaps and dashes non-zero
}
} else {
// no pattern, draw solid line
}
gdk_gc_unref (gc);
}
static void
{
}
static void
{
}