Пример #1
0
//---------------------------------------------------------------------------------------------------------------------
    boost::optional <Style> StyleSheet::select(std::string const& selector, bool cascade) const
    {
        std::multimap <long, std::pair <int, Style> > filtered;
        int counter = 0;
        for (auto const& i : styles_)
        {
            long specificity = i.getRule().selector.getHighestSpecificityFor(selector);
            if (specificity != -1)
                filtered.insert(std::pair <long, std::pair <int, Style>> (specificity, {counter, i}));
            ++counter;
        }

        if (filtered.empty())
            return boost::none;

        Style combined = filtered.rbegin()->second.second;
        Style* last = &combined;
        for (auto front = filtered.rbegin(), end = filtered.rend(), i = std::next(front); i != end; ++i)
        {
            last->derive(&i->second.second);
            last = &i->second.second;
        }

        return boost::optional <WretchedCss::Style> {combined.getCombined()};
    }
Пример #2
0
bool XARGenerator::OutputPathEntity(const Style& style, const Transformation& trans, PathDataVector& pathVector)
{
	bool ok = true;
	CXaraFileRecord Rec(0);

	if (style.IsFillColourDefined() || style.IsFillGradientDefined()) {
		if (style.IsStrokeColourDefined())
			Rec.Reinit(TAG_PATH_FILLED_STROKED, TAG_PATH_SIZE);
		else
			Rec.Reinit(TAG_PATH_FILLED, TAG_PATH_SIZE);
	} else // if (style.IsStrokeColourDefined())
		Rec.Reinit(TAG_PATH_STROKED, TAG_PATH_SIZE);

	Rec.WriteUINT32(pathVector.GetCount());
	for (unsigned int i = 0; i < pathVector.GetCount(); ++i)
		Rec.WriteBYTE(pathVector[i].m_verb);
	for (unsigned int i = 0; i < pathVector.GetCount(); ++i) {
		PointD p = pathVector[i].m_coord;
		Rec.WriteCoord(DocCoord((INT32)p.x, m_docSize.y - (INT32)p.y));
	}
	ok = m_pExporter->WriteRecord(&Rec);

	RectD boundings = GetMaximumBoundings(pathVector);
	/***/ ok = m_pExporter->WriteZeroSizedRecord(TAG_DOWN);
	OutputStyles(style, trans, boundings, STYLE_FILL_ALL|STYLE_STROKE_ALL|STYLE_OPACITY);
	/***/ ok = m_pExporter->WriteZeroSizedRecord(TAG_UP);

	return ok;
}
Пример #3
0
static void* scons(Object*) {
#if HAVE_IV
	SymChooser* sc = nil;
IFGUI
	const char* caption = "Choose a Variable Name or";
	if (ifarg(1)) {
		caption = gargstr(1);
	}
	Style* style = new Style(Session::instance()->style());
	style->attribute("caption", caption);
	if (ifarg(2)) {
		Symbol* sym = hoc_lookup(gargstr(2));
		int type = RANGEVAR;
		if (sym) {
			type = sym->type;
		}
		sc = new SymChooser(new SymDirectory(type), WidgetKit::instance(), style, nil, 1);
	}else{
		sc = new SymChooser(nil, WidgetKit::instance(), style);
	}
	Resource::ref(sc);
ENDGUI
	return (void*)sc;
#else
	return (void*)0;
#endif /* HAVE_IV */
}
Пример #4
0
bool XARGenerator::OutputPolygonEntity(const Style& style, const Transformation& trans, const PointDVector& coordVector)
{
	bool ok = true;
	CXaraFileRecord Rec(0);

	if (style.IsFillColourDefined() || style.IsFillGradientDefined()) {
		if (style.IsStrokeColourDefined())
			Rec.Reinit(TAG_PATH_FILLED_STROKED, TAG_PATH_SIZE);
		else
			Rec.Reinit(TAG_PATH_FILLED, TAG_PATH_SIZE);
	} else // if (style.IsStrokeColourDefined())
		Rec.Reinit(TAG_PATH_STROKED, TAG_PATH_SIZE);
	Rec.WriteUINT32(coordVector.GetCount());
	Rec.WriteBYTE(0x06); // moveto
	for (unsigned int i = 1; i < coordVector.GetCount() - 1; ++i)
		Rec.WriteBYTE(0x02); // lineto
	Rec.WriteBYTE(0x03); // lineto + closepath
	for (unsigned int i = 0; i < coordVector.GetCount(); ++i) {
		PointD p = coordVector[i];
		Rec.WriteCoord(DocCoord((INT32)p.x, m_docSize.y - (INT32)p.y));
	}
	ok = m_pExporter->WriteRecord(&Rec);

	RectD boundings = GetMaximumBoundings(coordVector);
	/***/ ok = m_pExporter->WriteZeroSizedRecord(TAG_DOWN);
	OutputStyles(style, trans, boundings, STYLE_FILL_ALL|STYLE_STROKE_ALL|STYLE_OPACITY);
	/***/ ok = m_pExporter->WriteZeroSizedRecord(TAG_UP);

	return ok;
}
Пример #5
0
TEST( KMLStyle , testSetId )
{
    Style s;
    s.id() = "Id";
    EXPECT_EQ( s.id() , "Id" );
    EXPECT_TRUE( bool( s ) );
}
Пример #6
0
boolean MonoKitImpl::match(const Style& s1, const Style& s2, const char* n) {
    String name(n);
    String v1, v2;
    boolean b1 = s1.find_attribute(n, v1);
    boolean b2 = s2.find_attribute(n, v2);
    return (!b1 && !b2) || (b1 && b2 && v1 == v2);
}
Пример #7
0
TEST( KMLStyle , testSetLabelStyle )
{
    Style s;
    s.labelStyle() = LabelStyle( White );
    EXPECT_TRUE( bool( s ) );
    EXPECT_EQ( s.labelStyle() , LabelStyle( White ) );
}
Пример #8
0
TEST( KMLStyle , testWriteEmpty )
{
    Style s;
    std::ostringstream str;
    s.write( str , 4 );
    EXPECT_EQ( str.str() , "" );
}   
Пример #9
0
TEST( KMLStyle , testSetLineStyle )
{
    Style s;
    s.lineStyle() = LineStyle( White );
    EXPECT_TRUE( bool( s ) );
    EXPECT_EQ( s.lineStyle() , LineStyle( White ) );
}
Пример #10
0
void asciimage::Shape::renderLine(QPainter* painter, int scale, const Style& style) const
{
    Q_ASSERT(type() == Type::LINE);
    Q_ASSERT(points().size() == 2);

    if (scale == 1)
    {
        if (!isStraightLine())
        {
            painter->setRenderHint(QPainter::Antialiasing, true);
        }
        painter->setPen(style.color());
        painter->drawLine(points()[0], points()[1]);
    }
    else
    {
        if (isStraightLine())
        {
            const QRect b = boundingRect();
            painter->setPen(style.color());
            painter->setBrush(style.color());
            painter->drawRect(scaledOuterRect(b, scale));
        }
        else
        {
            painter->setRenderHint(QPainter::Antialiasing, true);
            painter->setPen(QPen(style.color(), scale, Qt::SolidLine, Qt::SquareCap));
            painter->drawLine(p(points()[0], scale), p(points()[1], scale));
        }
    }
}
Пример #11
0
Style* PatternLoader::getStyle(QString name) {
  Style* pS;
  for(pS=styleList.first(); pS != 0; pS=styleList.next()) {
    if(name.compare(pS->getName())==0) { return pS; }
  }
  return NULL;
}
Пример #12
0
TEST( KMLStyle , testSetIconStyle )
{
    Style s;
    s.iconStyle() = IconStyle( White );
    EXPECT_TRUE( bool( s ) );
    EXPECT_EQ( s.iconStyle() , IconStyle( White ) );
}
Пример #13
0
void FieldEditorImpl::build(
    FieldEditor* e, const char* str, FieldEditorAction* a
) {
    WidgetKit& kit = *kit_;
    kit.begin_style("FieldEditor");
    Style* s  = kit.style();
    bs_ = new FieldButton(e, a);
    editor_ = new FieldStringEditor(bs_, str, kit_, s);
    Glyph* g = editor_;
    if (s->value_is_on("beveled")) {
	g = kit.inset_frame(
	    new Background(
		LayoutKit::instance()->h_margin(editor_, 2.0),
		kit.background()
	    )
	);
    }
    e->body(g);
    cursor_is_on_ = false;
    blink_handler_ = new IOCallback(FieldEditorImpl)(
	this, &FieldEditorImpl::blink_cursor
    );
    float sec = 0.5;
    s->find_attribute("cursorFlashRate", sec);
    flash_rate_ = long(sec * 1000000);
    kit.end_style();
}
void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<AnnotationSource>();
        source->baseImpl->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>(PointLayerID, SourceID);

        layer->setSourceLayer(PointLayerID);
        layer->setIconImage({"{sprite}"});
        layer->setIconAllowOverlap(true);

        layer->impl->spriteAtlas = &spriteAtlas;

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        if (style.getLayer(layer)) {
            style.removeLayer(layer);
        }
    }

    obsoleteShapeAnnotationLayers.clear();
}
Пример #15
0
Confirmer::Confirmer(const char* name, const char* prompt) {
    WidgetKit& kit = *WidgetKit::instance();
    const LayoutKit& layout = *LayoutKit::instance();
    Style* s = new Style(kit.style());
    s->attribute("name", name);
    Glyph* sep = layout.hspace(8);
    dialog_ = new Dialog(
	kit.outset_frame(
	    layout.margin(
		layout.vbox(
		    layout.hbox(kit.label(prompt), layout.hglue()),
		    layout.vglue(16, 20, 8),
		    layout.hbox(
			layout.hglue(30, fil, 0),
			kit.push_button(
			    "Cancel", new ConfirmerCallback(cancel)
			),
			sep,
			kit.push_button(
			    "No", new ConfirmerCallback(no)
			),
			sep,
			kit.push_button(
			    "Yes", new ConfirmerCallback(yes)
			)
		    )
		),
		12, 12
	    )
	),
	s
    );
    Resource::ref(dialog_);
}
Пример #16
0
Asker::Asker(const char* name, const char* prompt) {
    WidgetKit& kit = *WidgetKit::instance();
    const LayoutKit& layout = *LayoutKit::instance();
    Style* s = new Style(kit.style());
    s->attribute("name", name);
    editor_ = DialogKit::instance()->field_editor(
	"", s, new FieldEditorCallback(Asker)(
	    this, &Asker::accept_editor, &Asker::cancel_editor
	)
    );
    Glyph* sep = layout.vglue(11, fil, 11);
    dialog_ = new Dialog(
	kit.inset_frame(
	    layout.margin(
		layout.vbox(
		    layout.hbox(kit.label(prompt), layout.hglue()),
		    sep,
		    editor_,
		    sep,
		    layout.hbox(
			layout.hglue(100, fil, 100),
			kit.default_button("OK", new AskerCallback(accept)),
			layout.hglue(9, 0, 9),
			kit.push_button("Cancel", new AskerCallback(cancel))
		    )
		),
		12, 12
	    )
        ),
	s
    );
    dialog_->append_input_handler(editor_);
    dialog_->next_focus();
    Resource::ref(dialog_);
}
Пример #17
0
FieldEditor::FieldEditor(
    const String& sample,
    WidgetKit* kit,
    Style* s,
    FieldEditorAction* action)
    : InputHandler(nil, s)
{
    impl_ = new FieldEditorImpl;
    impl_->action_ = action;
    Resource::ref(impl_->action_);

    kit->begin_style("FieldEditor");
    Style* sty = kit->style();

    impl_->editor_ = new TextLine(sample, sample.length());
    Glyph* g = impl_->editor_;
    if (sty->value_is_on("beveled"))
    {
        g = kit->inset_frame(
                new Background(
                    LayoutKit::instance()->h_margin(impl_->editor_, 2.0),
                    kit->background()
                )
            );
    }
    body(g);

    kit->end_style();
}
Пример #18
0
CharacterMenu::CharacterMenu( Drawer & drawer )
{
	WidgetFactory& factory = WidgetFactory::getInstance();

	// MAIN CONTAINER
	Style * style = new Style();
	style->setBackgroundImage( factory.getMenuBackground() );

	rootContainer = new VerCenterContainer( style );

	// TITLE

	LabelWidget * lw = factory.getTitleLabel( Locale::get( "CHARACTER" ) );
	lw->prepare( drawer );

	rootContainer->addWidget( *lw );

	// FORRM
	playerNameForm = new Form( "setPlayerName" );

	// BUTTONS

	TextInputWidget* tiw = factory.getLargeTextInput( ".{1,15}", Config::playerName );
	interactiveWidgets.push_back( tiw );
	rootContainer->addWidget( *tiw );
	playerNameForm->addWidget( *tiw );

	ButtonWidget* bw = factory.getLargeSubmitButton( Locale::get( "BACK" ), "setmenu settings", *playerNameForm );

	this->interactiveWidgets.push_back( bw );
	rootContainer->addWidget( *bw );
}
void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<Source>();
        source->info.type = SourceType::Annotations;
        source->info.source_id = SourceID;
        source->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>();
        layer->id = PointLayerID;
        layer->type = StyleLayerType::Symbol;
        layer->styles.emplace(ClassID::Default, ClassProperties());

        layer->bucket = std::make_shared<StyleBucket>(layer->type);
        layer->bucket->name = layer->id;
        layer->bucket->source = SourceID;
        layer->bucket->source_layer = PointLayerID;
        layer->bucket->layout.set(PropertyKey::IconImage, ConstantFunction<std::string>("{sprite}"));
        layer->bucket->layout.set(PropertyKey::IconAllowOverlap, ConstantFunction<bool>(true));

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        style.removeLayer(layer);
    }

    obsoleteShapeAnnotationLayers.clear();
    style.getSource(SourceID)->invalidateTiles();
}
Пример #20
0
GraphicComp* ImportCmd::PostDialog () {
    bool imported = false;
    GraphicComp* comp = nil;
    Editor* ed = GetEditor();

    Style* style;
    bool reset_caption = false;
    if (chooser_ == nil) {
	style = new Style(Session::instance()->style());
	style->attribute("subcaption", "Import graphic from file:");
	style->attribute("open", "Import");
	chooser_ = DialogKit::instance()->file_chooser(".", style);
	Resource::ref(chooser_);
    } else {
	style = chooser_->style();
    }
    while (chooser_->post_for(ed->GetWindow())) {
	const String* str = chooser_->selected();
	if (str != nil) {
	    NullTerminatedString ns(*str);
	    comp = Import(ns.string());
	    if (comp != nil) {
		break;
	    }
	    style->attribute("caption", "Import failed!");
	    reset_caption = true;
	}
    }
    if (reset_caption) {
	style->attribute("caption", "");
    }
    return comp;
}
Пример #21
0
double AdjustColumnRowManipulator::adjustColumnHelper(const Cell& cell)
{
    double long_max = 0.0;
    const Style style = cell.effectiveStyle();
    const QSizeF size = textSize(cell.displayText(), style);
    if (size.width() > long_max) {
        double indent = 0.0;
        Style::HAlign alignment = style.halign();
        if (alignment == Style::HAlignUndefined) {
            if (cell.value().isNumber() || cell.isDate() || cell.isTime())
                alignment = Style::Right;
            else
                alignment = Style::Left;
        }
        if (alignment == Style::Left)
            indent = cell.style().indentation();
        long_max = indent + size.width()
                   + style.leftBorderPen().width() + style.rightBorderPen().width();
    }
    // add 4 because long_max is the length of the text
    // but column has borders
    if (long_max == 0.0)
        return -1.0;
    else
        return long_max + 4.0;
}
Пример #22
0
QString RecipeFormatter::getTextFormat()
{
   QString ret = "";
   QString tmp = "";
   if( rec == 0 )
      return "";
   
   Style* style = rec->style();
   
   ret += QString("%1 - %2 (%3%4)\n").arg( rec->name())
         .arg( style ? style->name() : tr("unknown style"))
         .arg( style ? style->categoryNumber() : tr("N/A"))
         .arg( style ? style->styleLetter() : "");
   ret += getTextSeparator();
   ret += buildStatTableTxt();
   if((tmp = buildFermentableTableTxt()) != "")
   {
      ret += "\n" + tr("Fermentables") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if((tmp = buildHopsTableTxt()) != "")
   {
      ret += "\n" + tr("Hops") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if((tmp = buildMiscTableTxt()) != "")
   {
      ret += "\n" + tr("Miscs") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if((tmp = buildYeastTableTxt()) != "")
   {
      ret += "\n" + tr("Yeasts") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if((tmp = buildMashTableTxt()) != "")
   {
      ret += "\n" + tr("Mash") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if( (tmp = rec->notes()) != "" )
   {
      ret += "\n" + tr("Notes") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   if((tmp = buildInstructionTableTxt()) != "")
   {
      ret += "\n" + tr("Instructions") + "\n";
      ret += getTextSeparator();
      ret += tmp;
   }
   
   return ret;
}
Пример #23
0
void TreeBuilder::visitWay(const utymap::entities::Way &way) {
  auto treeMesh = context_.meshPool.getSmall("");
  auto newMesh = context_.meshPool.getLarge(utymap::utils::getMeshName(WayMeshNamePrefix, way));

  Style style = context_.styleProvider.forElement(way, context_.quadKey.levelOfDetail);
  const auto center = context_.boundingBox.center();

  LSystemGenerator::generate(context_, style, treeMesh, center, 0);

  double treeStepInMeters = style.getValue(TreeStepKey);

  for (std::size_t i = 0; i < way.coordinates.size() - 1; ++i) {
    const auto &p0 = way.coordinates[i];
    const auto &p1 = way.coordinates[i + 1];
    utymap::utils::copyMeshAlong(context_.quadKey,
                                 center,
                                 p0,
                                 p1,
                                 treeMesh,
                                 newMesh,
                                 treeStepInMeters,
                                 context_.eleProvider);
  }

  context_.meshCallback(newMesh);
  context_.meshPool.release(std::move(treeMesh));
  context_.meshPool.release(std::move(newMesh));
}
Пример #24
0
void TreeBuilder::visitWay(const utymap::entities::Way& way)
{
    Mesh treeMesh("");
    Mesh newMesh(utymap::utils::getMeshName(WayMeshNamePrefix, way));
    Style style = context_.styleProvider.forElement(way, context_.quadKey.levelOfDetail);
    MeshContext meshContext(treeMesh, style);

    TreeBuilder::createGenerator(context_, meshContext)
        .setPosition(Vector3(0, 0, 0)) // NOTE we will override coordinates later
        .generate();

    double treeStepInMeters = style.getValue(TreeStepKey);

    for (std::size_t i = 0; i < way.coordinates.size() - 1; ++i) {
        const auto& p1 = way.coordinates[i];
        const auto& p2 = way.coordinates[i + 1];

        double distanceInMeters = GeoUtils::distance(p1, p2);
        int treeCount = static_cast<int>(distanceInMeters / treeStepInMeters);

        for (int j = 0; j < treeCount; ++j) {
            GeoCoordinate position = GeoUtils::newPoint(p1, p2, (double) j / treeCount);
            
            double elevation = context_.eleProvider.getElevation(position);
            utymap::utils::copyMesh(Vector3(position.longitude, elevation, position.latitude), treeMesh, newMesh);
        }
    }

    context_.meshCallback(newMesh);
}
Пример #25
0
TEST( KMLStyle , testSetPolyStyle )
{
    Style s;
    s.polyStyle() = PolyStyle( White );
    EXPECT_TRUE( bool( s ) );
    EXPECT_EQ( s.polyStyle() , PolyStyle( White ) );
}
Пример #26
0
void FileChooserImpl::init(
    FileChooser* chooser, Style* s, FileChooserAction* a
) {
    fchooser_ = chooser;
    fbrowser_ = nil;
    editor_ = nil;
    filter_ = nil;
    directory_filter_ = nil;
    filter_map_ = nil;
    dir_ = Directory::open(*name_);
    if (dir_ == nil) {
	dir_ = Directory::current();
	/* and what if we can't read the current directory? */
    }
    Resource::ref(a);
    action_ = a;
    style_ = new Style(s);
    Resource::ref(style_);
    style_->alias("FileChooser");
    style_->alias("Dialog");
    update_ = new ActionCallback(FileChooserImpl)(
	this, &FileChooserImpl::build
    );
    style_->add_trigger_any(update_);
    build();
}
Пример #27
0
void AnnotationManager::updateStyle(Style& style) {
    // Create annotation source, point layer, and point bucket
    if (!style.getSource(SourceID)) {
        std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations, SourceID, "", util::tileSize, std::make_unique<SourceInfo>(), nullptr);
        source->enabled = true;
        style.addSource(std::move(source));

        std::unique_ptr<SymbolLayer> layer = std::make_unique<SymbolLayer>();
        layer->id = PointLayerID;
        layer->source = SourceID;
        layer->sourceLayer = PointLayerID;
        layer->layout.icon.image = std::string("{sprite}");
        layer->layout.icon.allowOverlap = true;
        layer->spriteAtlas = &spriteAtlas;

        style.addLayer(std::move(layer));
    }

    for (const auto& shape : shapeAnnotations) {
        shape.second->updateStyle(style);
    }

    for (const auto& layer : obsoleteShapeAnnotationLayers) {
        if (style.getLayer(layer)) {
            style.removeLayer(layer);
        }
    }

    obsoleteShapeAnnotationLayers.clear();

    for (auto& monitor : monitors) {
        monitor->update(getTile(monitor->tileID));
    }
}
Пример #28
0
MonoKit::MonoKit() {
    impl_ = new MonoKitImpl(this);
    Style* s = Session::instance()->style();
    for (PropertyData* p = kit_props; p->path != nil; p++) {
        s->attribute(p->path, p->value, -5);
    }
}
Пример #29
0
Ref<Style> Style::clone() const {
	Ref<Style> to = new Style;
	Style* from = const_cast<Style*>(this);

	StyleCloner cloner(from, to.get());
	from->serialize(cloner);
	return to;
}
Пример #30
0
void PatternLoader::debugPrintStyles() {
  printf("--Styles[START] ---------------------\n");
  Style* st;
  for( st = styleList.first(); st != 0; st=styleList.next() ) {
    printf(st->debugPrint());
  }
  printf("--Styles[END] -----------------------\n");
}