color-slider.cpp revision 1ec0e7318a4bf659c7f5703dccb1cef17c5adabd
/**
* @file
* A slider with colored background - implementation.
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
*
* This code is in public domain
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "color-slider.h"
#include <gtkmm/adjustment.h>
#if GTK_CHECK_VERSION(3,0,0)
#include <gtkmm/stylecontext.h>
#else
#endif
#include "widgets/sp-color-scales.h"
#include "preferences.h"
namespace Inkscape {
namespace UI {
namespace Widget {
#if GTK_CHECK_VERSION(3,0,0)
: _dragging(false)
#else
: _dragging(false)
, _adjustment(NULL)
#endif
, _value(0.0)
, _oldvalue(0.0)
, _mapsize(0)
{
_c0[0] = 0x00;
_cm[0] = 0xff;
_c0[0] = 0xff;
_b0 = 0x5f;
_b1 = 0xa0;
_bmask = 0x08;
}
ColorSlider::~ColorSlider() {
if (_adjustment) {
#if GTK_CHECK_VERSION(3,0,0)
_adjustment.reset();
#else
_adjustment = NULL;
#endif
}
}
void ColorSlider::on_realize() {
set_realized();
if(!_gdk_window)
{
#if !GTK_CHECK_VERSION(3,0,0)
#endif
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
#if !GTK_CHECK_VERSION(3,0,0)
style_attach();
#endif
}
}
void ColorSlider::on_unrealize() {
_gdk_window.reset();
}
if (get_realized()) {
}
}
#if GTK_CHECK_VERSION(3,0,0)
{
}
void ColorSlider::get_preferred_width_for_height_vfunc(int /*height*/, int& minimum_width, int& natural_width) const
{
}
{
}
void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int& minimum_height, int& natural_height) const
{
}
#else
}
bool result = false;
if (get_is_drawable()) {
}
return result;
}
#endif
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
_dragging = true;
#if GTK_CHECK_VERSION(3,0,0)
_gdk_window->gobj(),
NULL,
#else
#endif
}
return false;
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
_dragging = false;
}
}
return false;
}
if (_dragging) {
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
return false;
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
if (!adjustment) {
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
} else {
}
if (_adjustment != adjustment) {
if (_adjustment) {
#if !GTK_CHECK_VERSION(3,0,0)
#endif
}
}
}
void ColorSlider::_onAdjustmentChanged() {
queue_draw();
}
void ColorSlider::_onAdjustmentValueChanged() {
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
} else {
}
}
}
// Remove any map, if set
_map = 0;
queue_draw();
}
queue_draw();
}
queue_draw();
}
gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false);
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// Draw shadow
if (colorsOnTop) {
#if GTK_CHECK_VERSION(3,0,0)
#else
0, 0,
#endif
}
/* Paintable part of color gradient area */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
if (_map) {
/* Render map pixelstore */
gint s = 0;
_map, s, d,
}
} else {
/* Render gradient */
// part 1: from c0 to cm
for (gint i = 0; i < 4; i++) {
c[i] = _c0[i] << 16;
}
/* Draw pixelstore 1 */
}
}
// part 2: from cm to c1
for (gint i = 0; i < 4; i++) {
c[i] = _cm[i] << 16;
}
c, dc,
/* Draw pixelstore 2 */
}
}
}
/* Draw shadow */
if (!colorsOnTop) {
#if GTK_CHECK_VERSION(3,0,0)
#else
0, 0,
#endif
}
/* Draw arrow */
// Define top arrow
// Define bottom arrow
// Render both arrows
cr->stroke_preserve();
return false;
}
}//namespace Widget
}//namespace UI
}//namespace Inkscape
/* Colors are << 16 */
static const guchar *
{
gint x, y;
guint r, g, b, a;
}
if (!buf) {
}
r = c[0];
g = c[1];
b = c[2];
a = c[3];
guchar *d;
cr = r >> 16;
cg = g >> 16;
cb = b >> 16;
ca = a >> 16;
d = dp;
/* Background value */
d += 3 * width;
}
r += dc[0];
g += dc[1];
b += dc[2];
a += dc[3];
dp += 3;
}
return buf;
}
/* Positions are << 16 */
static const guchar *
{
gint x, y;
}
if (!buf) {
}
/* Background value */
d += 3 * width;
}
dp += 3;
}
return buf;
}