Documentation
¶
Overview ¶
Package style is part of the go-fastreport library, a pure Go port of FastReport .NET.
Index ¶
- Variables
- func FontEqual(a, b Font) bool
- func FontToStr(f Font) string
- type Border
- func (b *Border) Bottom() *BorderLine
- func (b *Border) Clone() *Border
- func (b *Border) Color() color.RGBA
- func (b *Border) Equals(other *Border) bool
- func (b *Border) Left() *BorderLine
- func (b *Border) LineStyle() LineStyle
- func (b *Border) Right() *BorderLine
- func (b *Border) SetColor(c color.RGBA)
- func (b *Border) SetLineStyle(s LineStyle)
- func (b *Border) SetWidth(w float32)
- func (b *Border) Top() *BorderLine
- func (b *Border) Width() float32
- type BorderLine
- type BorderLines
- type BorderSide
- type Fill
- type FillType
- type Font
- type FontStyle
- type GlassFill
- type HatchFill
- type HatchStyle
- type HighlightCondition
- type LineStyle
- type LinearGradientFill
- type NoneFill
- type PathGradientFill
- type PathGradientStyle
- type SolidFill
- type StyleEntry
- type StyleSheet
- type Styleable
- type TextOutline
- type TextureFill
- type WrapMode
Constants ¶
This section is empty.
Variables ¶
var ( // ColorWhite is opaque white. ColorWhite = color.RGBA{R: 255, G: 255, B: 255, A: 255} // ColorBlack is opaque black. ColorBlack = color.RGBA{R: 0, G: 0, B: 0, A: 255} // ColorTransparent is fully transparent. ColorTransparent = color.RGBA{R: 0, G: 0, B: 0, A: 0} )
Common colours used as defaults throughout go-fastreport.
Functions ¶
Types ¶
type Border ¶
type Border struct {
// Lines holds the four BorderLine values indexed by BorderSide.
// Use Left(), Top(), Right(), Bottom() for named access.
Lines [4]*BorderLine
// VisibleLines controls which sides are actually drawn.
VisibleLines BorderLines
// Shadow enables a drop shadow on the bottom-right of the object.
Shadow bool
// ShadowColor is the colour of the drop shadow. Defaults to opaque black.
ShadowColor color.RGBA
// ShadowWidth is the width of the shadow in pixels. Defaults to 4.
ShadowWidth float32
}
Border holds the four sides of a report object's border plus an optional drop shadow. It is the Go equivalent of FastReport.Border.
func NewBorder ¶
func NewBorder() *Border
NewBorder returns a Border initialised with FastReport defaults: four black, solid, 1 px wide border lines; no shadow (shadow width 4, shadow colour black, matching the .NET constructor).
func (*Border) Bottom ¶
func (b *Border) Bottom() *BorderLine
Bottom returns the bottom BorderLine (index 3).
func (*Border) Color ¶
Color returns the colour of the left line (representative of all lines when they share the same settings, matching the .NET Border.Color getter).
func (*Border) Left ¶
func (b *Border) Left() *BorderLine
Left returns the left BorderLine (index 0).
func (*Border) Right ¶
func (b *Border) Right() *BorderLine
Right returns the right BorderLine (index 2).
func (*Border) SetLineStyle ¶
SetLineStyle sets the same line style on all four border lines.
type BorderLine ¶
type BorderLine struct {
// Color is the line colour. Defaults to opaque black.
Color color.RGBA
// Style is the dash/dot pattern. Defaults to LineStyleSolid.
Style LineStyle
// Width is the line width in pixels. Defaults to 1.
Width float32
}
BorderLine represents a single side of a border. It is the Go equivalent of FastReport.BorderLine.
func NewBorderLine ¶
func NewBorderLine() *BorderLine
NewBorderLine returns a BorderLine with the FastReport defaults (black, solid, 1 px wide).
func (*BorderLine) Clone ¶
func (l *BorderLine) Clone() *BorderLine
Clone returns a deep copy of the BorderLine.
func (*BorderLine) Equals ¶
func (l *BorderLine) Equals(other *BorderLine) bool
Equals reports whether l and other have the same Color, Style and Width.
type BorderLines ¶
type BorderLines int
BorderLines is a flag set that controls which sides of a Border are visible. It mirrors the FastReport.BorderLines flags enum.
const ( // BorderLinesNone hides all sides. BorderLinesNone BorderLines = 0 // BorderLinesLeft shows the left side. BorderLinesLeft BorderLines = 1 // BorderLinesRight shows the right side. BorderLinesRight BorderLines = 2 // BorderLinesTop shows the top side. BorderLinesTop BorderLines = 4 // BorderLinesBottom shows the bottom side. BorderLinesBottom BorderLines = 8 // BorderLinesAll shows all four sides. BorderLinesAll BorderLines = 15 )
type BorderSide ¶
type BorderSide int
BorderSide identifies one of the four sides of a Border.
const ( // BorderLeft is the left side (index 0). BorderLeft BorderSide = iota // BorderTop is the top side (index 1). BorderTop // BorderRight is the right side (index 2). BorderRight // BorderBottom is the bottom side (index 3). BorderBottom )
type Fill ¶
type Fill interface {
// FillType returns the concrete fill variant.
FillType() FillType
// Clone returns a deep copy of the fill.
Clone() Fill
// IsTransparent reports whether the fill produces no visible colour.
IsTransparent() bool
}
Fill is the base interface for all fill types. It is the Go equivalent of FastReport.FillBase.
type FillType ¶
type FillType string
FillType identifies which concrete fill implementation is in use.
const ( // FillTypeSolid is a plain single-colour fill. FillTypeSolid FillType = "Solid" // FillTypeLinear is a linear gradient fill. FillTypeLinear FillType = "Linear" // FillTypeGlass is a glass-effect fill. FillTypeGlass FillType = "Glass" // FillTypeHatch is a hatch-pattern fill. FillTypeHatch FillType = "Hatch" // FillTypePathGradient is a radial/path gradient fill. FillTypePathGradient FillType = "PathGradient" // FillTypeTexture is an image-tiled texture fill. FillTypeTexture FillType = "Texture" // FillTypeNone represents no fill (fully transparent). FillTypeNone FillType = "None" )
type Font ¶
type Font struct {
// Name is the font family name (e.g. "Arial").
Name string
// Size is the font size in points.
Size float32
// Style is the combination of FontStyle flags.
Style FontStyle
}
Font holds the font properties used by TextObject. It is the Go equivalent of System.Drawing.Font.
func DefaultFont ¶
func DefaultFont() Font
DefaultFont returns the default report font (Arial 10pt Regular).
func FontFromStr ¶
FontFromStr parses a font string into a Font value.
Two formats are accepted:
Go round-trip format produced by FontToStr: "Name, Size, StyleInt" e.g. "Arial, 10, 0"
FRX format produced by FastReport .NET: "Name, Sizept, style=StyleName" e.g. "Arial, 11pt" or "Tahoma, 14pt, style=Bold"
Returns DefaultFont() on any parse error.
type FontStyle ¶
type FontStyle int
FontStyle holds font decoration flags (mirrors System.Drawing.FontStyle).
type GlassFill ¶
type GlassFill struct {
// Color is the base fill colour.
Color color.RGBA
// Blend controls the white highlight strength (0..1). Default 0.2.
Blend float32
// Hatch enables a diagonal hatch overlay. Default true.
Hatch bool
}
GlassFill produces a glass-like sheen effect over a base colour. It is the Go equivalent of FastReport.GlassFill.
func NewGlassFill ¶
NewGlassFill returns a GlassFill with FastReport defaults (blend 0.2, hatch enabled).
func (*GlassFill) IsTransparent ¶
IsTransparent implements Fill.
type HatchFill ¶
type HatchFill struct {
// ForeColor is the foreground (line) colour.
ForeColor color.RGBA
// BackColor is the background colour between the lines.
BackColor color.RGBA
// Style selects the hatch pattern.
Style HatchStyle
}
HatchFill fills a region with a repeating hatch pattern. It is the Go equivalent of FastReport.HatchFill.
func NewHatchFill ¶
func NewHatchFill(fore, back color.RGBA, style HatchStyle) *HatchFill
NewHatchFill returns a HatchFill with the given colours and pattern.
func (*HatchFill) IsTransparent ¶
IsTransparent implements Fill; transparent when both colours have alpha == 0.
type HatchStyle ¶
type HatchStyle int
HatchStyle enumerates the available hatch patterns. The values mirror the most common System.Drawing.Drawing2D.HatchStyle entries used by FastReport.
const ( // HatchHorizontal draws horizontal lines. HatchHorizontal HatchStyle = iota // HatchVertical draws vertical lines. HatchVertical // HatchDiagonal1 draws forward-diagonal lines (/). HatchDiagonal1 // HatchDiagonal2 draws backward-diagonal lines (\). HatchDiagonal2 // HatchCross draws a cross (horizontal + vertical) pattern. HatchCross // HatchDiagonalCross draws a diagonal cross (X) pattern. HatchDiagonalCross )
type HighlightCondition ¶
type HighlightCondition struct {
// Expression is the boolean expression that enables this condition
// (e.g. "[Row#] % 2 == 0"). Evaluated via Report.Calc().
Expression string
// Visible controls object visibility when the condition is true.
// Default true (matching FastReport.HighlightCondition defaults).
Visible bool
// Apply flags mirror FastReport StyleBase.Apply* properties.
ApplyBorder bool
ApplyFill bool
ApplyFont bool
ApplyTextFill bool
// Visual overrides — applied only when the corresponding Apply flag is true.
// Fill holds the full fill object (SolidFill, GlassFill, etc.) for the
// background override. Mirrors C# StyleBase.Fill (StyleBase.cs).
Fill Fill // background fill override (may be GlassFill, SolidFill, etc.)
TextFillColor color.RGBA // text (foreground) colour override
Font Font // font override
// Border is the border override applied when ApplyBorder is true.
// Mirrors C# StyleBase.Border (StyleBase.cs) used by HighlightCondition.
Border Border
}
HighlightCondition holds one conditional-formatting rule for a TextObject. When the Expression evaluates to true, the associated visual overrides are applied to the rendered object. Only properties flagged with Apply* are used.
It is the Go equivalent of FastReport.HighlightCondition / FastReport.StyleBase.
func NewHighlightCondition ¶
func NewHighlightCondition() HighlightCondition
NewHighlightCondition returns a HighlightCondition with the same defaults as FastReport.HighlightCondition: Visible=true, ApplyTextFill=true, text fill colour = red.
func (*HighlightCondition) Assign ¶
func (h *HighlightCondition) Assign(src HighlightCondition)
Assign copies all fields from src into this HighlightCondition. Mirrors C# HighlightCondition.Assign (HighlightCondition.cs).
func (HighlightCondition) Clone ¶
func (h HighlightCondition) Clone() HighlightCondition
Clone returns a copy of this HighlightCondition. Mirrors C# HighlightCondition.Clone (HighlightCondition.cs line 75-80).
func (HighlightCondition) Equals ¶
func (h HighlightCondition) Equals(other HighlightCondition) bool
Equals reports whether h and other have identical field values. Mirrors C# HighlightCondition.Equals (HighlightCondition.cs line 83-90).
type LineStyle ¶
type LineStyle int
LineStyle specifies the style of a border line. It is the Go equivalent of FastReport.LineStyle.
const ( // LineStyleSolid is a solid line. LineStyleSolid LineStyle = iota // LineStyleDash is a dashed line. LineStyleDash // LineStyleDot is a dotted line. LineStyleDot // LineStyleDashDot is a dash-dot repeating pattern. LineStyleDashDot // LineStyleDashDotDot is a dash-dot-dot repeating pattern. LineStyleDashDotDot // LineStyleDouble is a double line. LineStyleDouble )
type LinearGradientFill ¶
type LinearGradientFill struct {
// StartColor is the gradient's start colour.
StartColor color.RGBA
// EndColor is the gradient's end colour.
EndColor color.RGBA
// Angle is the gradient direction in degrees (0 = left to right).
Angle int
// Focus is the normalised position of the gradient centre (0..1).
Focus float32
// Contrast controls how sharply the gradient transitions (0..1).
Contrast float32
}
LinearGradientFill fills a region with a linear colour gradient. It is the Go equivalent of FastReport.LinearGradientFill.
func NewLinearGradientFill ¶
func NewLinearGradientFill(start, end color.RGBA) *LinearGradientFill
NewLinearGradientFill returns a LinearGradientFill from start to end colour with all other settings at their FastReport defaults (angle 0, focus 0, contrast 100 mapped to 1.0 here since we use a 0..1 scale).
func (*LinearGradientFill) FillType ¶
func (f *LinearGradientFill) FillType() FillType
FillType implements Fill.
func (*LinearGradientFill) IsTransparent ¶
func (f *LinearGradientFill) IsTransparent() bool
IsTransparent implements Fill; transparent only when both colours have alpha == 0, matching FastReport.LinearGradientFill.IsTransparent.
type NoneFill ¶
type NoneFill struct{}
NoneFill represents the absence of any fill (fully transparent). It is the Go equivalent of using no fill in FastReport.
func (*NoneFill) IsTransparent ¶
IsTransparent implements Fill; always true.
type PathGradientFill ¶
type PathGradientFill struct {
// CenterColor is the colour at the centre of the gradient.
CenterColor color.RGBA
// EdgeColor is the colour at the edges of the gradient.
EdgeColor color.RGBA
// Style selects the gradient shape (Elliptic or Rectangular).
Style PathGradientStyle
}
PathGradientFill fills a region with a radial (path) gradient that blends from a center colour outward to an edge colour. It is the Go equivalent of FastReport.PathGradientFill. Draw() is handled by exporters — only serialization data is stored here.
func NewPathGradientFill ¶
func NewPathGradientFill(center, edge color.RGBA, style PathGradientStyle) *PathGradientFill
NewPathGradientFill returns a PathGradientFill with the given colours and style, matching FastReport.PathGradientFill(CenterColor, EdgeColor, Style).
func (*PathGradientFill) FillType ¶
func (f *PathGradientFill) FillType() FillType
FillType implements Fill.
func (*PathGradientFill) IsTransparent ¶
func (f *PathGradientFill) IsTransparent() bool
IsTransparent implements Fill; transparent only when both colours have alpha == 0, matching FastReport.PathGradientFill.IsTransparent.
type PathGradientStyle ¶
type PathGradientStyle int
PathGradientStyle selects the shape of the path gradient. It mirrors FastReport.PathGradientStyle.
const ( // PathGradientElliptic uses an ellipse centred on the bounding box. PathGradientElliptic PathGradientStyle = iota // PathGradientRectangular uses the bounding rectangle directly. PathGradientRectangular )
type SolidFill ¶
SolidFill fills a region with a single, uniform colour. It is the Go equivalent of FastReport.SolidFill.
func NewSolidFill ¶
NewSolidFill returns a SolidFill with the given colour.
func (*SolidFill) IsTransparent ¶
IsTransparent implements Fill; a SolidFill is transparent when alpha == 0.
type StyleEntry ¶
type StyleEntry struct {
// Name is the style's unique identifier.
Name string
// ApplyBorder controls whether the Border is applied to the object.
// Defaults to true.
ApplyBorder bool
// Border holds the border overrides to apply when ApplyBorder is true.
Border Border
// ApplyFill controls whether the Fill is applied to the object.
// Defaults to true.
ApplyFill bool
// Fill is the fill override when ApplyFill is true.
// When non-nil it takes precedence over the legacy FillColor field.
// It is the Go equivalent of FastReport.StyleBase.Fill (FillBase interface).
Fill Fill
// FillColor is the solid fill colour override when ApplyFill is true and
// Fill is nil. Kept for backward compatibility with existing serialisation code.
FillColor color.RGBA
// ApplyTextFill controls whether the text fill is applied to the object.
// Defaults to true.
ApplyTextFill bool
// TextFill is the text fill override when ApplyTextFill is true.
// When non-nil it takes precedence over the legacy TextColor field.
// It is the Go equivalent of FastReport.StyleBase.TextFill (FillBase interface).
TextFill Fill
// TextColor is the text fill colour override when ApplyTextFill is true and
// TextFill is nil. Kept for backward compatibility with existing serialisation code.
TextColor color.RGBA
// ApplyFont controls whether the Font is applied to the object.
// Defaults to true.
ApplyFont bool
// Font overrides the component font when ApplyFont is true.
Font Font
// Legacy "Changed" fields kept for backward compatibility with existing code.
// They map to the corresponding Apply* flags.
FontChanged bool
TextColorChanged bool
FillColorChanged bool
BorderColorChanged bool
// BorderColor overrides all border-line colours (legacy; prefer Border).
BorderColor color.RGBA
}
StyleEntry holds the complete visual properties that a named style can override on a report object. It is the Go equivalent of FastReport.StyleBase / FastReport.Style.
func (*StyleEntry) Assign ¶
func (e *StyleEntry) Assign(src *StyleEntry)
Assign copies all fields from src into e, performing deep copies of Border, Fill, and TextFill. It is the Go equivalent of FastReport.StyleBase.Assign(StyleBase source).
func (*StyleEntry) Clone ¶
func (e *StyleEntry) Clone() *StyleEntry
Clone returns a deep copy of e. It is the Go equivalent of FastReport.Style.Clone().
func (*StyleEntry) EffectiveFill ¶
func (e *StyleEntry) EffectiveFill() Fill
EffectiveFill returns the fill to use when applying this style entry. If the Fill interface field is set it is returned; otherwise a SolidFill wrapping FillColor is returned. Returns nil when ApplyFill is false. This is a helper for ReportComponentBase.ApplyStyle.
func (*StyleEntry) EffectiveTextFill ¶
func (e *StyleEntry) EffectiveTextFill() Fill
EffectiveTextFill returns the text fill to use when applying this style entry. If the TextFill interface field is set it is returned; otherwise a SolidFill wrapping TextColor is returned. Returns nil when ApplyTextFill is false.
type StyleSheet ¶
type StyleSheet struct {
// contains filtered or unexported fields
}
StyleSheet is a named-style registry. It maps style names to StyleEntry definitions and applies them to objects that implement Styleable. It is the Go equivalent of FastReport's StyleCollection (Report.Styles).
Name lookups are case-insensitive to match C# StyleCollection.IndexOf(string) which uses String.Compare(s.Name, value, ignoreCase: true).
func (*StyleSheet) Add ¶
func (ss *StyleSheet) Add(e *StyleEntry)
Add registers a StyleEntry. If a style with the same name (case-insensitive) already exists it is replaced in-place, preserving insertion order.
func (*StyleSheet) All ¶
func (ss *StyleSheet) All() []*StyleEntry
All returns all registered StyleEntries in registration order.
func (*StyleSheet) ApplyToObject ¶
func (ss *StyleSheet) ApplyToObject(obj Styleable)
ApplyToObject looks up obj.StyleName() in the stylesheet and, if found, calls obj.ApplyStyle with the matching entry. It is a no-op when the component has no style name set or the style is not registered.
func (*StyleSheet) Find ¶
func (ss *StyleSheet) Find(name string) *StyleEntry
Find returns the StyleEntry with the given name, or nil if not registered. The lookup is case-insensitive, matching C# StyleCollection.IndexOf(string) behaviour (String.Compare with ignoreCase=true).
func (*StyleSheet) Len ¶
func (ss *StyleSheet) Len() int
Len returns the number of registered styles.
type Styleable ¶
type Styleable interface {
// StyleName returns the name of the style applied to the component.
StyleName() string
// ApplyStyle applies the given StyleEntry's overrides to the component.
ApplyStyle(entry *StyleEntry)
}
Styleable is the interface that report components must implement to receive style overrides from a StyleSheet. ReportComponentBase in the report package satisfies this interface.
type TextOutline ¶
type TextOutline struct {
// Enabled controls whether the outline is drawn.
Enabled bool
// Color is the stroke color.
Color color.RGBA
// Width is the stroke width in pixels.
Width float32
// DashStyle is the line style (0=Solid, 1=Dash, 2=Dot, 3=DashDot, 4=DashDotDot).
DashStyle int
// DrawBehind controls whether the outline is drawn behind the text (true)
// or on top of it (false, default).
// Mirrors C# TextOutline.DrawBehind (TextOutline.cs line 44-47).
DrawBehind bool
}
TextOutline defines a stroke drawn around each character in a text object. It is the Go equivalent of FastReport.TextOutline.
func DefaultTextOutline ¶
func DefaultTextOutline() TextOutline
DefaultTextOutline returns a TextOutline with default values (disabled).
func (*TextOutline) Assign ¶
func (o *TextOutline) Assign(src TextOutline)
Assign copies all fields from src into this TextOutline. Mirrors C# TextOutline.Assign (TextOutline.cs line 123-129).
func (TextOutline) Clone ¶
func (o TextOutline) Clone() TextOutline
Clone returns a copy of this TextOutline. Mirrors C# TextOutline.Clone (TextOutline.cs line 136-138).
type TextureFill ¶
type TextureFill struct {
// ImageData holds the raw image bytes (PNG/JPEG etc.) as decoded from
// the FRX Fill.ImageData base-64 attribute.
ImageData []byte
// ImageWidth is the display width in pixels (0 = natural width).
ImageWidth int
// ImageHeight is the display height in pixels (0 = natural height).
ImageHeight int
// PreserveAspectRatio keeps the aspect ratio when one dimension is set.
PreserveAspectRatio bool
// WrapMode controls tiling behaviour. Default is WrapModeTile.
WrapMode WrapMode
// ImageOffsetX is the horizontal offset of the tile origin in pixels.
ImageOffsetX int
// ImageOffsetY is the vertical offset of the tile origin in pixels.
ImageOffsetY int
// ImageIndex is the BlobStore index used when the FRX is stored with a
// BlobStore (designer/preview format). -1 means "not set" (inline path).
// Mirrors C# TextureFill.ImageIndex (Fills.cs).
ImageIndex int
}
TextureFill fills a region by tiling an embedded image. It is the Go equivalent of FastReport.TextureFill. Draw() is handled by exporters — only the serialization fields are stored. The image data is stored as a raw base-64-decoded byte slice matching the FRX Fill.ImageData attribute.
func NewTextureFill ¶
func NewTextureFill() *TextureFill
NewTextureFill returns a TextureFill with ImageIndex set to -1 (not set), matching the C# TextureFill constructor which calls ResetImageIndex().
func (*TextureFill) IsTransparent ¶
func (f *TextureFill) IsTransparent() bool
IsTransparent implements Fill; always false (matches FastReport.TextureFill.IsTransparent).
type WrapMode ¶
type WrapMode int
WrapMode controls how a TextureFill tiles its image. It mirrors System.Drawing.Drawing2D.WrapMode.
const ( // WrapModeTile tiles the image. WrapModeTile WrapMode = iota // WrapModeTileFlipX tiles the image, flipping horizontally on alternate columns. WrapModeTileFlipX // WrapModeTileFlipY tiles the image, flipping vertically on alternate rows. WrapModeTileFlipY // WrapModeTileFlipXY tiles the image, flipping both axes. WrapModeTileFlipXY // WrapModeClamp clamps the image without tiling. WrapModeClamp )