// drawingParser provides a function to parse drawingXML. In order to solve
// the problem that the label structure is changed after serialization and
// deserialization, two different structures: decodeWsDr and encodeWsDr are
// defined.
764367
func (f *File) drawingParser(path string) (*xlsxWsDr, int) {
	cNvPrID := 1
	if f.Drawings[path] == nil {
		content := xlsxWsDr{}
		content.A = NameSpaceDrawingML
		content.Xdr = NameSpaceDrawingMLSpreadSheet
		_, ok := f.XLSX[path]
		if ok { // Append Model
			decodeWsDr := decodeWsDr{}
			_ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML(path)), &decodeWsDr)
			content.R = decodeWsDr.R
			cNvPrID = len(decodeWsDr.OneCellAnchor) + len(decodeWsDr.TwoCellAnchor) + 1
			for _, v := range decodeWsDr.OneCellAnchor {
				content.OneCellAnchor = append(content.OneCellAnchor, &xdrCellAnchor{
					EditAs:       v.EditAs,
					GraphicFrame: v.Content,
				})
			}
			for _, v := range decodeWsDr.TwoCellAnchor {
				content.TwoCellAnchor = append(content.TwoCellAnchor, &xdrCellAnchor{
					EditAs:       v.EditAs,
					GraphicFrame: v.Content,
				})
			}
		}
		f.Drawings[path] = &content
	}
	return f.Drawings[path], cNvPrID
}
1244954
func GIFDrawer(drawer draw.Drawer) EncodeOption {
	return func(c *encodeConfig) {
		c.gifDrawer = drawer
	}
}
1230939
func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
	return &cPlotArea{
		Pie3DChart: &cCharts{
			VaryColors: &attrValBool{
				Val: true,
			},
			Ser: f.drawChartSeries(formatSet),
		},
	}
}
44746
func CreateXMLDecoder(input io.Reader, strict bool) *xml.Decoder {
	// drop any chars that will blow up the xml decoder and replace with a space
	input = filter.NewReader(input, filter.XML10Filter(filter.SpaceChar))
	decoder := xml.NewDecoder(input)
	decoder.Strict = strict
	// this only gets used when a proper xml header is used
	decoder.CharsetReader = charset.NewReaderLabel
	return decoder
}
139356
func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs {
	min := &attrValFloat{Val: formatSet.XAxis.Minimum}
	max := &attrValFloat{Val: formatSet.XAxis.Maximum}
	if formatSet.XAxis.Minimum == 0 {
		min = nil
	}
	if formatSet.XAxis.Maximum == 0 {
		max = nil
	}
	return []*cAxs{
		{
			AxID: &attrValInt{Val: 754001152},
			Scaling: &cScaling{
				Orientation: &attrValString{Val: orientation[formatSet.XAxis.ReverseOrder]},
				Max:         max,
				Min:         min,
			},
			Delete: &attrValBool{Val: false},
			AxPos:  &attrValString{Val: catAxPos[formatSet.XAxis.ReverseOrder]},
			NumFmt: &cNumFmt{
				FormatCode:   "General",
				SourceLinked: true,
			},
			MajorTickMark: &attrValString{Val: "none"},
			MinorTickMark: &attrValString{Val: "none"},
			TickLblPos:    &attrValString{Val: "nextTo"},
			SpPr:          f.drawPlotAreaSpPr(),
			TxPr:          f.drawPlotAreaTxPr(),
			CrossAx:       &attrValInt{Val: 753999904},
			Crosses:       &attrValString{Val: "autoZero"},
			Auto:          &attrValBool{Val: true},
			LblAlgn:       &attrValString{Val: "ctr"},
			LblOffset:     &attrValInt{Val: 100},
			NoMultiLvlLbl: &attrValBool{Val: false},
		},
	}
}
1238110
func DrawButton(x, y int, text string, active bool) {
	color := BUTTONTEXT
	if active {
		color = BUTTONFOCUS
	}
	Write(x, y, "<  ", color, BG)
	Write(x+3, y, text, color, BG)
	Write(x+3+len(text), y, "  >", color, BG)
}
239659
func (n *Network) GetXMLDesc(flags NetworkXMLFlags) (string, error) {
	var err C.virError
	result := C.virNetworkGetXMLDescWrapper(n.ptr, C.uint(flags), &err)
	if result == nil {
		return "", makeError(&err)
	}
	xml := C.GoString(result)
	C.free(unsafe.Pointer(result))
	return xml, nil
}
1212794
func (v *Drawable) DrawString(font *Font, gc *GC, x int, y int, str string) {
	ptr := C.CString(str)
	defer cfree(ptr)
	C.gdk_draw_string(v.GDrawable, font.GFont, gc.GGC, gint(x), gint(y), gstring(ptr))
}
1314674
func (p *parser) parseHelperNameOrSexpr() ast.Node {
	if p.isSexpr() {
		// sexpr
		return p.parseSexpr()
	}

	// helperName
	return p.parseHelperName()
}
1090713
func (renderer *Renderer) DrawLine(x1, y1, x2, y2 int32) error {
	return errorFromInt(int(
		C.SDL_RenderDrawLine(
			renderer.cptr(),
			C.int(x1),
			C.int(y1),
			C.int(x2),
			C.int(y2))))
}
765904
func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
	gd = genHelperDecoder{d: d}
	dd = genHelperDecDriver{decDriver: d.d}
	return
}
732159
func (s Style) WriteDrawingOptionsToRenderer(r Renderer) {
	r.SetClassName(s.GetClassName())
	r.SetStrokeColor(s.GetStrokeColor())
	r.SetStrokeWidth(s.GetStrokeWidth())
	r.SetStrokeDashArray(s.GetStrokeDashArray())
	r.SetFillColor(s.GetFillColor())
}
634653
func (f *NWFilter) GetXMLDesc(flags uint32) (string, error) {
	var err C.virError
	result := C.virNWFilterGetXMLDescWrapper(f.ptr, C.uint(flags), &err)
	if result == nil {
		return "", makeError(&err)
	}
	xml := C.GoString(result)
	C.free(unsafe.Pointer(result))
	return xml, nil
}
342947
func drawSlider(win *Window, state nstyle.WidgetStates, style *nstyle.Slider, bounds, virtual_cursor rect.Rect, minval, value, maxval float64) {
	out := &win.cmds
	if style.DrawBegin != nil {
		style.DrawBegin(out)
	}
	if style.DrawEnd != nil {
		defer style.DrawEnd(out)
	}
	if style.Draw != nil {
		style.Draw(out, state, style, bounds.Rectangle(), virtual_cursor.Rectangle(), minval, value, maxval)
		return
	}

	var fill rect.Rect
	var bar rect.Rect
	var scursor rect.Rect
	var background *nstyle.Item
	var bar_color color.RGBA
	var cursor *nstyle.Item

	/* select correct slider images/colors */
	if state&nstyle.WidgetStateActive != 0 {
		background = &style.Active
		bar_color = style.BarActive
		cursor = &style.CursorActive
	} else if state&nstyle.WidgetStateHovered != 0 {
		background = &style.Hover
		bar_color = style.BarHover
		cursor = &style.CursorHover
	} else {
		background = &style.Normal
		bar_color = style.BarNormal
		cursor = &style.CursorNormal
	}

	/* calculate slider background bar */
	bar.X = bounds.X
	bar.Y = (bounds.Y + virtual_cursor.H/2) - virtual_cursor.H/8
	bar.W = bounds.W
	bar.H = bounds.H / 6

	/* resize virtual cursor to given size */
	scursor.H = style.CursorSize.Y
	scursor.W = style.CursorSize.X
	scursor.Y = (bar.Y + bar.H/2.0) - scursor.H/2.0
	scursor.X = virtual_cursor.X - (virtual_cursor.W / 2)

	/* filled background bar style */
	fill.W = (scursor.X + (scursor.W / 2.0)) - bar.X

	fill.X = bar.X
	fill.Y = bar.Y
	fill.H = bar.H

	/* draw background */
	if background.Type == nstyle.ItemImage {
		out.DrawImage(bounds, background.Data.Image)
	} else {
		out.FillRect(bounds, style.Rounding, style.BorderColor)
		out.FillRect(shrinkRect(bounds, style.Border), style.Rounding, background.Data.Color)
	}

	/* draw slider bar */
	out.FillRect(bar, style.Rounding, bar_color)

	out.FillRect(fill, style.Rounding, style.BarFilled)

	/* draw cursor */
	if cursor.Type == nstyle.ItemImage {
		out.DrawImage(scursor, cursor.Data.Image)
	} else {
		out.FillCircle(scursor, cursor.Data.Color)
	}
	return
}
1139648
func NewParser(rd io.Reader) *Parser {
	p := Parser{}
	p.rd = rd
	p.lastByte = bufSize
	p.buf = make([]byte, bufSize)
	p.ev = &SimpleEventHandler{}
	p.r = -1
	p.fill()
	return &p
}
1281073
func (img *Image) DrawString(font *truetype.Font, c color.Color, str string, fontsize float64) {
	ctx := freetype.NewContext()
	// default 72dpi
	ctx.SetDst(img)
	ctx.SetClip(img.Bounds())
	ctx.SetSrc(image.NewUniform(c))
	ctx.SetFontSize(fontsize)
	ctx.SetFont(font)
	// 写入文字的位置
	pt := freetype.Pt(0, int(-fontsize/6)+ctx.PointToFixed(fontsize).Ceil())
	ctx.DrawString(str, pt)
}
1041008
func xStreamSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
	ret := make([]XStream, 0, n)
	for i := int64(0); i < n; i++ {
		_, err := rd.ReadArrayReply(func(rd *proto.Reader, n int64) (interface{}, error) {
			if n != 2 {
				return nil, fmt.Errorf("got %d, wanted 2", n)
			}

			stream, err := rd.ReadString()
			if err != nil {
				return nil, err
			}

			v, err := rd.ReadArrayReply(xMessageSliceParser)
			if err != nil {
				return nil, err
			}

			ret = append(ret, XStream{
				Stream:   stream,
				Messages: v.([]XMessage),
			})
			return nil, nil
		})
		if err != nil {
			return nil, err
		}
	}
	return ret, nil
}