2017-07-05 23:10:57 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions defined in
|
|
|
|
* file 'LICENSE.md', which is part of this source code package.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package creator
|
|
|
|
|
|
|
|
// All widgets that can be used to draw with the creator need to implement the Drawable interface.
|
|
|
|
type Drawable interface {
|
2017-07-06 16:26:22 +00:00
|
|
|
// Draw onto blocks representing Page contents. As the content can wrap over many pages, multiple
|
|
|
|
// templates are returned, one per Page. The function also takes a draw context containing information
|
|
|
|
// where to draw (if relative positioning) and the available height to draw on accounting for Margins etc.
|
|
|
|
GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
|
2017-07-05 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 20:41:10 +00:00
|
|
|
// A vector drawable is a Drawable with a specified width and height.
|
|
|
|
type VectorDrawable interface {
|
|
|
|
Drawable
|
|
|
|
Width() float64
|
|
|
|
Height() float64
|
|
|
|
}
|
|
|
|
|
2017-07-11 13:16:01 +00:00
|
|
|
// Drawing context. Continuously used when drawing the page contents. Keeps track of current X, Y position,
|
|
|
|
// available height as well as other page parameters such as margins and dimensions.
|
2017-07-06 16:26:22 +00:00
|
|
|
type DrawContext struct {
|
2017-07-11 13:16:01 +00:00
|
|
|
// Current page number.
|
2017-07-06 16:26:22 +00:00
|
|
|
Page int
|
|
|
|
|
2017-07-05 23:10:57 +00:00
|
|
|
// Current position. In a relative positioning mode, a drawable will be placed at these coordinates.
|
|
|
|
X, Y float64
|
2017-07-11 13:16:01 +00:00
|
|
|
|
2017-07-05 23:10:57 +00:00
|
|
|
// Context dimensions. Available width and height.
|
|
|
|
Width, Height float64
|
|
|
|
|
2017-07-11 13:16:01 +00:00
|
|
|
// Page Margins.
|
2017-07-06 16:26:22 +00:00
|
|
|
Margins margins
|
2017-07-05 23:10:57 +00:00
|
|
|
|
2017-07-06 16:26:22 +00:00
|
|
|
// Absolute Page size, widths and height.
|
|
|
|
PageWidth float64
|
|
|
|
PageHeight float64
|
2017-07-05 23:10:57 +00:00
|
|
|
}
|