swatches.cpp revision 5e1a030f60fc5f5753e30882711db9af56f763f5
/** @file
* @brief Color swatches dialog
*/
/* Authors:
* Jon A. Cruz
* John Bintz
*
* Copyright (C) 2005 Jon A. Cruz
* Copyright (C) 2008 John Bintz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <errno.h>
#include <map>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkseparatormenuitem.h>
#include "color-item.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "document.h"
#include "document-private.h"
#include "inkscape.h"
#include "inkscape.h"
#include "io/resource.h"
#include "message-context.h"
#include "path-prefix.h"
#include "preferences.h"
#include "sp-item.h"
#include "sp-gradient-fns.h"
#include "sp-gradient.h"
#include "sp-gradient-vector.h"
#include "swatches.h"
#include "style.h"
#include "ui/previewholder.h"
#include "widgets/desktop-widget.h"
#include "widgets/gradient-vector.h"
#include "widgets/eek-preview.h"
#include "display/nr-plain-stuff.h"
#include "sp-gradient-reference.h"
namespace Inkscape {
namespace UI {
namespace Dialogs {
#define VBLOCK 16
#define PREVIEW_PIXBUF_WIDTH 128
class DocTrack;
class SwatchesPanelHook : public SwatchesPanel
{
public:
};
if ( item ) {
item->buttonClicked(false);
}
}
if ( item ) {
item->buttonClicked(true);
}
}
static GtkWidget *popupSubHolder = 0;
static ColorItem* bounceTarget = 0;
static SwatchesPanel* bouncePanel = 0;
{
if ( bounceTarget ) {
}
}
{
if ( bounceTarget ) {
}
}
{
if ( gr ) {
}
}
{
if ( bounceTarget ) {
if (doc) {
editGradientImpl( grad );
break;
}
}
}
}
}
{
if ( bounceTarget ) {
if (doc) {
editGradientImpl( gr );
}
}
}
{
if ( bounceTarget ) {
_("Add gradient stop"));
break;
}
}
}
}
}
{
SwatchesPanel *swp = 0;
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
}
}
}
return swp;
}
{
}
{
if ( !popupMenu ) {
popupMenu = gtk_menu_new();
//TRANSLATORS: An item in context menu on a colour in the swatches
"activate",
//TRANSLATORS: An item in context menu on a colour in the swatches
"activate",
"activate",
user_data );
//popupExtras.push_back(child);
"activate",
user_data );
//popupExtras.push_back(child);
//gtk_widget_set_sensitive( child, FALSE );
{
popupSub = gtk_menu_new();
}
}
if ( item ) {
}
bounceTarget = item;
bouncePanel = swp;
popupItems.clear();
if ( popupMenu ) {
bool processed = false;
if ( wdgt ) {
// Pick up all gradients with vectors
//gl = g_slist_prepend(gl, curr->data);
processed = true;
"activate",
GINT_TO_POINTER(index) );
index++;
}
}
}
}
}
}
}
return handled;
}
str++;
}
while ( *str ) {
str++;
}
str--;
*str-- = 0;
}
return ret;
}
void skipWhitespace( char*& str ) {
str++;
}
}
val = 0;
str++;
}
return retval;
}
{
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++;
}
// 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
}
}
}
{
return *new SwatchesPanel();
}
/**
* Constructor
*/
_holder(0),
_clear(0),
_remove(0),
_currentIndex(0),
_currentDesktop(0),
{
_holder = new PreviewHolder();
if (docPalettes.empty()) {
docPalettes[0] = docPalette;
}
loadEmUp();
SwatchPage* first = 0;
int index = 0;
if ( !_prefs_path.empty() ) {
if (!targetName.empty()) {
if (targetName == "Auto") {
first = docPalettes[0];
} else {
index++;
for ( std::vector<SwatchPage*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
break;
}
index++;
}
}
}
}
if ( !first ) {
first = docPalettes[0];
_currentIndex = 0;
} else {
}
_rebuild();
int i = 0;
}
i++;
}
}
if ( hotItem ) {
hotItem->set_active();
}
}
{
_trackDocument( this, 0 );
if ( _clear ) {
delete _clear;
}
if ( _remove ) {
delete _remove;
}
if ( _holder ) {
delete _holder;
}
}
{
// Must call the parent class or bad things might happen
if ( _holder )
{
}
}
{
if ( desktop != _currentDesktop ) {
if ( _currentDesktop ) {
}
if ( desktop ) {
sigc::bound_mem_functor1<void, Inkscape::UI::Dialogs::SwatchesPanel, SPDocument*> first = sigc::mem_fun(*this, &SwatchesPanel::_setDocument);
} else {
_setDocument(0);
}
}
}
class DocTrack
{
public:
DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) :
{
}
~DocTrack()
{
if (doc) {
}
}
private:
};
{
SPDocument *oldDoc = 0;
if (!oldDoc) {
}
}
if (oldDoc) {
docPerPanel[panel] = 0;
bool found = false;
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); (it != docPerPanel.end()) && !found; ++it) {
}
if (!found) {
delete *it;
break;
}
}
}
}
if (document) {
bool found = false;
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); (it != docPerPanel.end()) && !found; ++it) {
}
if (!found) {
sigc::connection conn1 = document->resources_changed_connect( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) );
sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) );
sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) );
}
}
}
}
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
}
}
{
if ( document != _currentDocument ) {
_trackDocument(this, document);
}
}
{
}
}
{
grad->ensureVector();
unsigned int r = SP_RGBA32_R_U(together);
unsigned int g = SP_RGBA32_G_U(together);
unsigned int b = SP_RGBA32_B_U(together);
}
}
}
{
SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0;
if (docPalette) {
}
for (std::map<ColorItem*, SPGradient*>::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) {
}
delete *it;
}
// Figure out which SwatchesPanel instances are affected and update them.
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
if (curr == docPalette) {
}
}
}
}
}
{
SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0;
if (docPalette) {
for (int i = 0; i < cap; i++) {
}
}
}
}
}
}
{
}
return tmp;
}
void SwatchesPanel::_updateFromSelection()
{
SwatchPage *docPalette = (docPalettes.find(_currentDocument) != docPalettes.end()) ? docPalettes[_currentDocument] : 0;
if ( docPalette ) {
switch (result) {
case QUERY_STYLE_SINGLE:
{
if ( SP_IS_GRADIENT(server) ) {
SPGradient* target = 0;
}
}
if ( target ) {
if ( id ) {
}
}
}
}
break;
}
}
switch (result) {
case QUERY_STYLE_SINGLE:
{
if ( SP_IS_GRADIENT(server) ) {
SPGradient* target = 0;
}
}
if ( target ) {
if ( id ) {
}
}
}
}
break;
}
}
for ( std::vector<ColorItem*>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) {
}
}
}
{
switch( setId ) {
case 3:
{
if ( !_prefs_path.empty() ) {
}
_rebuild();
}
}
break;
}
}
void SwatchesPanel::_rebuild()
{
if ( curr->_prefWidth > 0 ) {
}
_holder->freezeUpdates();
// TODO restore once 'clear' works _holder->addPreview(_clear);
for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) {
}
_holder->thawUpdates();
}
} //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 :