bool TColorStyle::operator==(const TColorStyle &cs) const {
  if (getTagId() != cs.getTagId()) return false;

  if (getMainColor() != cs.getMainColor()) return false;

  int paramCount = getParamCount();
  if (paramCount != cs.getParamCount()) return false;

  int colorParamCount = getColorParamCount();
  if (colorParamCount != cs.getColorParamCount()) return false;

  if (m_name != cs.getName()) return false;
  if (m_originalName != cs.getOriginalName()) return false;
  if (m_globalName != cs.getGlobalName()) return false;
  if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false;
  if (m_pickedPosition != cs.getPickedPosition()) return false;
  if (m_flags != cs.getFlags()) return false;

  for (int p = 0; p < colorParamCount; ++p)
    if (getColorParamValue(p) != cs.getColorParamValue(p)) return false;

  for (int p = 0; p < paramCount; ++p) {
    switch (getParamType(p)) {
    case BOOL:
      if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p))
        return false;
      break;
    case INT:
    case ENUM:
      if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p))
        return false;
      break;
    case DOUBLE:
      if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p))
        return false;
      break;
    case FILEPATH:
      if (getParamValue(TFilePath_tag(), p) !=
          cs.getParamValue(TFilePath_tag(), p))
        return false;
      break;
    default:
      assert(false);
    }
  }

  return true;
}
void TStyleSelection::toggleLink()
{
	if (!m_palette || m_pageIndex < 0)
		return;
	int n = m_styleIndicesInPage.size();
	if (n <= 0)
		return;

	bool somethingHasBeenLinked = false;

	bool currentStyleIsInSelection = false;
	TApp *app = TApp::instance();
	TPaletteHandle *ph = app->getCurrentPalette();

	TPalette::Page *page = m_palette->getPage(m_pageIndex);
	assert(page);

	for (std::set<int>::iterator it = m_styleIndicesInPage.begin();
		 it != m_styleIndicesInPage.end(); ++it) {
		TColorStyle *cs = page->getStyle(*it);
		assert(cs);
		wstring name = cs->getGlobalName();
		if (name != L"" && (name[0] == L'-' || name[0] == L'+')) {
			name[0] = name[0] == L'-' ? L'+' : L'-';
			cs->setGlobalName(name);
			if (name[0] == L'+')
				somethingHasBeenLinked = true;
		}

		if (*it == m_palette->getPage(m_pageIndex)->search(ph->getStyleIndex()))
			currentStyleIsInSelection = true;
	}
	if (somethingHasBeenLinked)
		StudioPalette::instance()->updateLinkedColors(m_palette.getPointer());

	ph->notifyPaletteChanged();

	if (currentStyleIsInSelection)
		ph->notifyColorStyleSwitched();

	// DA FARE: e' giusto mettere la nofica del dirty flag a current scene
	// o e' meglio farlo al livello corrente!?
	app->getCurrentScene()->setDirtyFlag(true);
	//  extern void setPaletteDirtyFlag();
	//  setPaletteDirtyFlag();
}