dash-selector.cpp revision 08989785f2cdc3a4191b1d32914ee0a6e33af9d7
#define __SP_DASH_SELECTOR_NEW_C__
/** @file
* @brief Option menu for selecting dash patterns - implementation
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <maximilian.albert@gmail.com>
*
* 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 "preferences.h"
#include <gtkmm/optionmenu.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
#include "dash-selector.h"
static double dash_0[] = {-1.0};
// TODO: find something more sensible here!!
init_dashes();
this->pack_start(*dash, false, false, 0);
m->show();
for (int i = 0; dashes[i]; i++) {
}
this->pack_start(*sb, false, false, 0);
offset->signal_value_changed().connect(sigc::mem_fun(*this, &SPDashSelector::offset_value_changed));
}
SPDashSelector::~SPDashSelector() {
// FIXME: for some reason this doesn't get called; does the call to manage() in
// sp_stroke_style_line_widget_new() not processed correctly?
delete dash;
delete offset;
}
void
if (!dashes) {
if (!dash_prefs.empty()) {
int pos = 0;
int i = 0;
}
d[i] = -1;
} else {
}
pos += 1;
}
} else {
}
}
}
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 (off)
} else {
if (ndash)
*ndash = 0;
if (dash)
if (off)
*off = 0.0;
}
}
{
mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SPDashSelector::dash_activate), mi));
px->signal_realize().connect(sigc::bind(sigc::ptr_fun(&sp_dash_selector_menu_item_image_realize), px, pattern));
return mi;
}
static 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;
}
static 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;
}
Glib::RefPtr<Gdk::Pixmap> pixmap = Gdk::Pixmap::create(px->get_window(), DASH_PREVIEW_LENGTH + 4, 16, -1);
// 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
Gdk::JOIN_MITER);
} else {
// regular pattern with both gaps and dashes non-zero
}
} else {
// no pattern, draw solid line
}
}
void
{
}
void
{
}
/*
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 :