swatches.cpp revision ef9d155a8149d4793471047b3836db719b9e0292
/*
* A simple panel for color swatches
*
* Authors:
* Jon A. Cruz
*
* Copyright (C) 2005 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include "inkscape.h"
#include "document.h"
#include "desktop-handles.h"
#include "inkscape.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "path-prefix.h"
#include "swatches.h"
#include "sp-item.h"
#include "prefs-utils.h"
#include "eek-preview.h"
namespace Inkscape {
namespace UI {
namespace Dialogs {
_isLive(false),
_linkIsTone(false),
_linkPercent(0),
_linkGray(0),
_linkSrc(0)
{
}
{
}
{
if ( this != &other ) {
*this = other;
}
}
{
if ( this != &other ) {
// TODO - correct linkage
g_message("Erk!");
}
return *this;
}
class JustForNow
{
public:
JustForNow() : _prefWidth(0) {}
int _prefWidth;
};
typedef enum {
APP_X_INKY_COLOR_ID = 0,
APP_X_INKY_COLOR = 0,
static const GtkTargetEntry sourceColorEntries[] = {
// {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID},
{"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
{"application/x-color", 0, APP_X_COLOR},
};
{
gchar* tmp = g_strdup_printf("#%02x%02x%02x", item->def.getR(), item->def.getG(), item->def.getB() );
8, // format
tmp = 0;
} else if ( info == APP_X_INKY_COLOR ) {
// Find where this thing came from
bool found = false;
int index = 0;
for ( std::vector<JustForNow*>::iterator it = possible.begin(); it != possible.end() && !found; ++it ) {
index = 0;
for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) {
found = true;
break;
} else {
index++;
}
}
}
// if ( found ) {
// g_message("Found the color at entry %d in palette '%s'", index, paletteName.c_str() );
// } else {
// g_message("Unable to find the color");
// }
for ( unsigned int i = 0; i < paletteName.length(); i++ ) {
}
16, // format
itemCount * 2);
delete[] tmp;
} else {
16, // format
(3+1) * 2);
}
}
{
if ( item )
{
}
}
//"drag-drop"
// gboolean dragDropColorData( GtkWidget *widget,
// GdkDragContext *drag_context,
// gint x,
// gint y,
// guint time,
// gpointer user_data)
// {
// // TODO finish
// return TRUE;
// }
if ( item ) {
item->buttonClicked(false);
}
}
if ( item ) {
item->buttonClicked(true);
}
}
{
}
static const GtkTargetEntry destColorTargets[] = {
// {"application/x-inkscape-color-id", GTK_TARGET_SAME_APP, APP_X_INKY_COLOR_ID},
{"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
#endif // ENABLE_MAGIC_COLORS
{"application/x-color", 0, APP_X_COLOR},
};
#include "color.h" // for SP_RGBA32_U_COMPOSE
{
// g_message(" droppy droppy %d", info);
switch (info) {
case APP_X_INKY_COLOR:
{
// Careful about endian issues.
if ( user_data ) {
// Shove on in the new value
item->def.setRGB( 0x0ff & (dataVals[0] >> 8), 0x0ff & (dataVals[1] >> 8), 0x0ff & (dataVals[2] >> 8) );
}
}
}
break;
}
case APP_X_COLOR:
{
// Careful about endian issues.
// {
// gchar c[64] = {0};
// sp_svg_write_color( c, 64,
// SP_RGBA32_U_COMPOSE(
// 0x0ff & (dataVals[0] >> 8),
// 0x0ff & (dataVals[1] >> 8),
// 0x0ff & (dataVals[2] >> 8),
// 0xff // can't have transparency in the color itself
// //0x0ff & (data->data[3] >> 8),
// ));
// }
if ( user_data ) {
// Shove on in the new value
item->def.setRGB( 0x0ff & (dataVals[0] >> 8), 0x0ff & (dataVals[1] >> 8), 0x0ff & (dataVals[2] >> 8) );
}
}
}
break;
}
default:
g_message("unknown drop type");
}
}
static bool bruteForce( SPDocument* document, Inkscape::XML::Node* node, Glib::ustring const& match, int r, int g, int b )
{
bool changed = false;
if ( node ) {
gchar c[64] = {0};
changed = true;
}
gchar c[64] = {0};
changed = true;
}
}
return changed;
}
{
if ( item ) {
for ( std::vector<Gtk::Widget*>::iterator it = item->_previews.begin(); it != item->_previews.end(); ++it ) {
widget->queue_draw();
}
}
for ( std::vector<ColorItem*>::iterator it = item->_listeners.begin(); it != item->_listeners.end(); ++it ) {
if ( (*it)->_linkIsTone ) {
} else {
}
}
// Look for objects using this color
{
if ( desktop ) {
if ( rroot ) {
// Find where this thing came from
bool found = false;
int index = 0;
for ( std::vector<JustForNow*>::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) {
index = 0;
for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) {
found = true;
break;
} else {
index++;
}
}
}
if ( !paletteName.empty() ) {
str = 0;
if ( bruteForce( document, rroot, paletteName, item->def.getR(), item->def.getG(), item->def.getB() ) ) {
_("Change color definition"));
}
}
}
}
}
}
}
{
if ( style == PREVIEW_STYLE_BLURB ) {
} else {
blank = " ";
}
eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB());
| (_isLive ? PREVIEW_LINK_OTHER:0)) );
/*
Gtk::Button *btn = new Gtk::Button(blank);
Gdk::Color color;
color.set_rgb((_r << 8)|_r, (_g << 8)|_g, (_b << 8)|_b);
btn->modify_bg(Gtk::STATE_NORMAL, color);
btn->modify_bg(Gtk::STATE_ACTIVE, color);
btn->modify_bg(Gtk::STATE_PRELIGHT, color);
btn->modify_bg(Gtk::STATE_SELECTED, color);
Gtk::Widget* newBlot = btn;
*/
/*
newBlot->signal_clicked().connect( sigc::mem_fun(*this, &ColorItem::buttonClicked) );
sigc::signal<void> type_signal_something;
*/
"clicked",
this);
"alt-clicked",
this);
"drag-data-get",
this);
"drag-begin",
this );
// g_signal_connect( G_OBJECT(newBlot->gobj()),
// "drag-drop",
// G_CALLBACK(dragDropColorData),
// this);
if ( def.isEditable() )
{
"drag-data-received",
this );
}
"destroy",
this);
}
return widget;
}
{
if (desktop) {
gchar c[64];
}
}
str++;
}
while ( *str ) {
str++;
}
str--;
*str-- = 0;
}
return ret;
}
void skipWhitespace( char*& str ) {
str++;
}
}
val = 0;
str++;
}
return retval;
}
{
bool good = false;
{
good = true;
}
}
}
return good;
}
{
bool good = false;
}
// overflow
// failed conversion
} else {
good = true;
}
}
return good;
}
void ColorItem::_wireMagicColors( void* p )
{
if ( onceMore )
{
for ( std::vector<ColorItem*>::iterator it = onceMore->_colors.begin(); it != onceMore->_colors.end(); ++it )
{
{
{
//g_message("FOUND MAGIC at '%s'", (*it)->def.descr.c_str());
//g_message(" '%s'", subby.c_str());
{
}
{
}
// Tint. index + 1 more val.
guint64 colorIndex = 0;
}
}
}
guint64 colorIndex = 0;
grayLevel = 0;
}
}
}
}
}
}
}
}
}
{
if ( !_linkSrc )
{
_linkIsTone = false;
if ( _linkPercent > 100 )
_linkPercent = 100;
if ( _linkPercent < 0 )
_linkPercent = 0;
_linkGray = 0;
}
}
{
if ( !_linkSrc )
{
_linkIsTone = true;
if ( _linkPercent > 100 )
_linkPercent = 100;
if ( _linkPercent < 0 )
_linkPercent = 0;
}
}
{
char block[1024];
if ( f ) {
if ( result ) {
bool inHeader = true;
bool hasErr = false;
do {
if ( result ) {
if ( block[0] == '#' ) {
// ignore comment
} else {
// very simple check for header versus entry
ptr++;
}
if ( *ptr == 0 ) {
// blank line. skip it.
// should be an entry link
inHeader = false;
int r = 0;
int g = 0;
int b = 0;
if ( *ptr ) {
if ( !hasErr ) {
}
if ( !hasErr ) {
}
if (n != NULL) {
name = n;
}
}
if ( !hasErr ) {
// Add the entry now
}
} else {
hasErr = true;
}
} else {
if ( !inHeader ) {
// Hmmm... probably bad. Not quite the format we want?
hasErr = true;
} else {
if ( sep ) {
*sep = 0;
if ( *name ) {
{
}
{
// overflow
// failed conversion
} else {
}
}
} else {
// error
hasErr = true;
}
} else {
// error
hasErr = true;
}
}
}
}
}
if ( !hasErr ) {
#endif // ENABLE_MAGIC_COLORS
} else {
delete onceMore;
}
}
}
fclose(f);
}
}
static void loadEmUp()
{
static bool beenHere = false;
if ( !beenHere ) {
beenHere = true;
// Use this loop to iterate through a list of possible document locations.
if (!directory) {
} else {
// if ( g_str_has_suffix(lower, ".gpl") ) {
}
// }
}
}
}
// toss the dirname
}
}
}
{
if ( !instance ) {
instance = new SwatchesPanel();
}
return *instance;
}
/**
* Constructor
*/
_holder(0)
{
_holder = new PreviewHolder();
loadEmUp();
JustForNow* first = 0;
gchar const* targetName = 0;
if ( _prefs_path ) {
if ( targetName ) {
for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
break;
}
}
}
}
if ( !first ) {
}
if ( first->_prefWidth > 0 ) {
}
_holder->freezeUpdates();
for ( std::vector<ColorItem*>::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) {
}
_holder->thawUpdates();
int i = 0;
}
i++;
}
}
if ( hotItem ) {
hotItem->set_active();
}
}
{
}
{
// Must call the parent class or bad things might happen
if ( _holder )
{
}
}
{
switch( setId ) {
case 3:
{
if ( _prefs_path ) {
}
if ( curr->_prefWidth > 0 ) {
}
_holder->freezeUpdates();
for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) {
}
_holder->thawUpdates();
}
}
break;
}
}
} //namespace Dialogs
} //namespace UI
} //namespace Inkscape
/*
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 :