color-item.cpp revision 29a93177aea9e5b003f5600f188ab4280fac4a06
/** @file
* @brief Inkscape color swatch UI item.
*/
/* Authors:
* Jon A. Cruz
*
* Copyright (C) 2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <errno.h>
#include "color-item.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "display/nr-plain-stuff.h"
#include "document.h"
#include "inkscape.h" // for SP_ACTIVE_DESKTOP
#include "io/resource.h"
#include "message-context.h"
#include "sp-gradient.h"
#include "sp-item.h"
#include "svg/svg-color.h"
#include "color.h" // for SP_RGBA32_U_COMPOSE
namespace Inkscape {
namespace UI {
namespace Dialogs {
// TODO remove this soon:
#endif // ENABLE_MAGIC_COLORS
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;
}
#endif // ENABLE_MAGIC_COLORS
if ( item ) {
item->buttonClicked(false);
}
}
if ( item ) {
item->buttonClicked(true);
}
}
static gboolean handleEnterNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
if ( item ) {
if ( desktop ) {
gchar* msg = g_strdup_printf(_("Color: <b>%s</b>; <b>Click</b> to set fill, <b>Shift+click</b> to set stroke"),
}
}
return FALSE;
}
static gboolean handleLeaveNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
if ( item ) {
if ( desktop ) {
}
}
return FALSE;
}
{
}
{
bool good = false;
{
good = true;
}
}
}
return good;
}
{
bool good = false;
}
// overflow
// failed conversion
} else {
good = true;
}
}
return good;
}
// TODO resolve this more cleanly:
extern gboolean colorItemHandleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event, gpointer user_data);
{
if ( item )
{
int width = 32;
int height = 24;
gsize bytesWritten = 0;
-1,
&error);
} else {
if ( item->getGradient() ){
0, // add delete function
0 );
} else {
Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height );
}
}
}
}
//"drag-drop"
// gboolean dragDropColorData( GtkWidget *widget,
// GdkDragContext *drag_context,
// gint x,
// gint y,
// guint time,
// gpointer user_data)
// {
// // TODO finish
// return TRUE;
// }
SwatchPage::SwatchPage() :
_name(),
_prefWidth(0),
_colors()
{
}
SwatchPage::~SwatchPage()
{
}
Previewable(),
tips(),
_previews(),
_isFill(false),
_isStroke(false),
_isLive(false),
_linkIsTone(false),
_linkPercent(0),
_linkGray(0),
_linkSrc(0),
_grad(0),
_pixData(0),
_pixWidth(0),
_pixHeight(0),
{
}
Previewable(),
tips(),
_previews(),
_isFill(false),
_isStroke(false),
_isLive(false),
_linkIsTone(false),
_linkPercent(0),
_linkGray(0),
_linkSrc(0),
_grad(0),
_pixData(0),
_pixWidth(0),
_pixHeight(0),
{
}
{
}
{
if ( this != &other ) {
*this = other;
}
}
{
if ( this != &other ) {
// TODO - correct linkage
g_message("Erk!");
}
return *this;
}
{
if ( _isFill ) {
val |= PREVIEW_FILL;
}
if ( _isStroke ) {
val |= PREVIEW_STROKE;
}
}
}
}
}
{
// TODO regen and push to listeners
}
}
{
if (_pixData) {
}
_pixHeight = height;
}
}
GdkDragContext */*drag_context*/,
guint /*time*/,
{
} else {
}
char* tmp = 0;
int len = 0;
int format = 0;
if ( tmp ) {
delete[] tmp;
}
}
}
GdkDragContext */*drag_context*/,
GtkSelectionData */*data*/,
guint /*info*/,
guint /*event_time*/,
gpointer /*user_data*/)
{
}
{
if ( item ) {
item->_updatePreviews();
}
}
void ColorItem::_updatePreviews()
{
widget->queue_draw();
}
}
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<SwatchPage*>::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 ) {
if ( this == *zz ) {
found = true;
break;
} else {
index++;
}
}
}
if ( !paletteName.empty() ) {
str = 0;
_("Change color definition"));
}
}
}
}
}
#endif // ENABLE_MAGIC_COLORS
}
{
gsize bytesWritten = 0;
-1,
&error);
if (!pixbuf) {
}
}
else if ( !_pixData ){
} else {
0, // add delete function
0 );
}
| (_isLive ? PREVIEW_LINK_OTHER:0)) );
}
Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio)
{
if ( style == PREVIEW_STYLE_BLURB) {
} else {
// Glib::ustring blank(" ");
// if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
// blank = " ";
// }
eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
/*
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);
"button-press-event",
this);
{
// these next lines are order-dependent:
}
curr++;
}
for ( int i = 0; i < entryCount; i++ ) {
}
delete[] entries;
}
"drag-data-get",
this);
"drag-begin",
this );
"enter-notify-event",
this);
"leave-notify-event",
this);
// g_signal_connect( G_OBJECT(newBlot->gobj()),
// "drag-drop",
// G_CALLBACK(dragDropColorData),
// this);
if ( def.isEditable() )
{
// gtk_drag_dest_set( GTK_WIDGET(newBlot->gobj()),
// GTK_DEST_DEFAULT_ALL,
// destColorTargets,
// G_N_ELEMENTS(destColorTargets),
// GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
// g_signal_connect( G_OBJECT(newBlot->gobj()),
// "drag-data-received",
// G_CALLBACK(_dropDataIn),
// this );
}
"destroy",
this);
}
return widget;
}
{
if (desktop) {
// TODO actually make this clear
break;
}
break;
}
if ( _grad ){
colorspec = "url(#";
colorspec += ")";
} else {
gchar c[64];
sp_svg_write_color(c, sizeof(c), rgba);
colorspec = c;
}
break;
}
}
}
}
{
if ( colorSet )
{
for ( std::vector<ColorItem*>::iterator it = colorSet->_colors.begin(); it != colorSet->_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;
}
}
} // 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 :