xigo

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2023 License: BSD-2-Clause-Views Imports: 13 Imported by: 0

README

This directory contains the xigo package which is an implementation
of the sketch interface on top of the XI X-11 interface. 

Documentation

Index

Constants

View Source
const (
	FILL_NONE int = iota
	FILL_SOLID
	FILL_OP_0 //  for X these aren't implemented (coudl we do an alpha channel thing?)
	FILL_OP_1
	FILL_OP_2
	FILL_OP_3
	FILL_OP_4
	FILL_OP_5
	FILL_OP_6
	FILL_HORIZ
	FILL_VERT
)

CAUTION: there is no way to reference these from the 'parent' without managing this directory

at the same level as sketch. So, these are defined in all places, and user will reference
them as sketch.FILL_*. These must match the constants in sketch.
View Source
const (
	EV_PRESS int = iota // event types
	EV_RELEASE
	EV_MOUSE_PRESS
	EV_MOUSE_REL
)
View Source
const (
	BT_RADIO  int = C.XI_RADIO_BUTTON // button types
	BT_STICKY int = C.XI_TOGGLE_BUTTON
	BT_SPRING int = C.XI_SPRING_BUTTON
	BT_ENTRY  int = C.XI_ENTRY_BUTTON
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Xigo_gc

type Xigo_gc struct {
	// contains filtered or unexported fields
}

func Mk_xigo_gc

func Mk_xigo_gc(output string) (gc *Xigo_gc, err error)

Mk_xigo_gc will create the sketch api compatable graphic context for darawing to the x environment using the XI C "package". The output parameter specifies the display and root window size and the title as comma separated items. This is of the format:

hostname:display.screen,height,width,title

The hostname informtation may be omitted (e.g. ,height,width) and if so the contents of the DISPLAY environment variable will be used. If either height or width is omitted the value of 640 is used.

func (*Xigo_gc) Add_button

func (xgc *Xigo_gc) Add_button(bid int, x int, y int, height int, width int, label string, colour string, txt_colour string, kind int, pushed bool)

Adds a button to the active window described by the gc. Because the C code cannot call one of our go functions as a callback, we pass nil values for the press/release callbacks. We will set a generic callback function for each type (press/release) when a listener is added and that will drive the Go function that will stuff an event onto the proper channel.

Sketch does NOT implement a button class concept as the class is set to the window number allowing us to paint all buttons in a window by class. If radio buttons are desired, then the user programme must create a subpage, and draw radio buttons there as they will be properly 'classed' from a push one and the currently depressed button pops up.

The pushed parm allows a sticky or radio button to start out as depressed. It is ignored for spring buttons.

func (*Xigo_gc) Add_listener

func (xgc *Xigo_gc) Add_listener(lchan chan *sktools.Interaction)

Adds the callback listener channel that a goroutine is listening on for callback's related to this gc. This function will also register the callback functions with XI.

Because pointer data cannot be passed to C functions, there is only one listener that will sent events for any gc.

func (*Xigo_gc) Clear

func (xgc *Xigo_gc) Clear()

func (*Xigo_gc) Clear_subpage

func (xgc *Xigo_gc) Clear_subpage(ccolour string)

Clear_subpage clears the active page.

func (*Xigo_gc) Close

func (xgc *Xigo_gc) Close()

Close overall root window and clean up everything.

func (*Xigo_gc) Close_image

func (xgc *Xigo_gc) Close_image(iimage interface{})

Close_image will do any cleanup that is needed. In the case of XI we need it to release the pixmap allocated by this code, and the allocated image in the XI world to prevent leaks.

func (*Xigo_gc) Delete_subpage

func (xgc *Xigo_gc) Delete_subpage(pname string)

Delete_subpage deletes the named subpage. It attempts to find the named page as a subpage to the active page, and if that fails it looks for a subpage to the root page.

func (*Xigo_gc) Draw_arc

func (xgc *Xigo_gc) Draw_arc(xo float64, yo float64, radius float64, alpha1 float64, alpha2 float64)

Draw_arc causes an arc to be drawn with the center at xo,yo starting at alpha1 degrees to alpha2 degrees with the given radius. Degrees are measured anticlockwise with 0 being the X-axis of the carteisan plane (3 o'clock).

func (*Xigo_gc) Draw_circle

func (xgc *Xigo_gc) Draw_circle(xo float64, yo float64, radius float64, outline bool)

func (*Xigo_gc) Draw_image

func (xgc *Xigo_gc) Draw_image(xo float64, yo float64, iimage interface{})

Draw_image accepts an Xigo_image pointer and draws it into the xi environment using the associated gc. It is positions such that the top left corner (ulc) is positioned at xo,yo.

func (*Xigo_gc) Draw_line

func (xgc *Xigo_gc) Draw_line(x1 float64, y1 float64, x2 float64, y2 float64)

Draw_line will draw a line from x1,y1 to x2,2 using the currently set colour.

func (*Xigo_gc) Draw_pie

func (xgc *Xigo_gc) Draw_pie(xo float64, yo float64, radius float64, alpha1 float64, alpha2 float64, outline bool)

Draw_pie will draw a 'filled' arc which is the shape of a pie. The pie is drawn with a center (point) at xo,yo and radius. The start and end angles are defined by alpha1 and alpha2; angles are from the X-axis of the cartesian plane (3 o'clock) and increase anticlockwise.

NOTE: X windows second angle is RELATIVE to the first, an thus is the number of degrees to

sweep and NOT the angle from 0.  The angle2 we accept for these functions IS the angle
from 0 so we must compute the sweep.

func (*Xigo_gc) Draw_poly

func (xgc *Xigo_gc) Draw_poly(points []*sktools.Point, outline bool)

Given a set of points, draw a polygon optionally filling it.

func (*Xigo_gc) Draw_rect

func (xgc *Xigo_gc) Draw_rect(xo float64, yo float64, height float64, width float64, outline bool)

Draw_rect will draw a rectangle with its lower left corner at xo,yo.

func (*Xigo_gc) Draw_text

func (xgc *Xigo_gc) Draw_text(xo float64, yo float64, text string)

Draw_text will cause the given string to be drawn at xo,yo in the active page/subpage.

func (*Xigo_gc) Drive

func (xgc *Xigo_gc) Drive()

func (*Xigo_gc) Engague

func (xgc *Xigo_gc) Engague()

func (*Xigo_gc) Lock

func (xgc *Xigo_gc) Lock()

Block until we have the draw lock for the gc.

func (*Xigo_gc) Mk_bounded_image

func (xgc *Xigo_gc) Mk_bounded_image(fname string, max_height int, max_width int) (image interface{}, e error)

Load an image and scale it based on a bounding box. The image will be scaled such that the largest dimension will utialise the entire bounding box in that direction.

func (*Xigo_gc) Mk_locked_subpage

func (xgc *Xigo_gc) Mk_locked_subpage(pname string, xo float64, yo float64, height float64, width float64)

Mk_locked_subpage creates a subpage which is immune to scale changes, and the initial size and placement is NOT affected by the current scale.

func (*Xigo_gc) Mk_page

func (gc *Xigo_gc) Mk_page(pname string, height int, width int, title string) error

Mk_page creates a main page which in the X world is a root window. The title is of the form <internal-name>:<window-title> where the internal name is used to make the page active and the title is displayed on the window border.

func (*Xigo_gc) Mk_scaled_image

func (xgc *Xigo_gc) Mk_scaled_image(fname string, scale float64) (image interface{}, e error)

Load an image and scale it.

func (*Xigo_gc) Mk_stacked_image

func (xgc *Xigo_gc) Mk_stacked_image(fnames []string, max_height int, max_width int) (image interface{}, e error)

Mk_stacked_image will load numtiple images from different files stacking them into to same pix map.

func (*Xigo_gc) Mk_subpage

func (xgc *Xigo_gc) Mk_subpage(pname string, ulx float64, uly float64, height float64, width float64)

Mk_subpage creates a subpage (a child window in X terms) at the given ulx, uly position with the requested height and width.

func (*Xigo_gc) Pop_state

func (xgc *Xigo_gc) Pop_state()

Pop_state pops updates various things in the context from the last pushed state.

func (*Xigo_gc) Press_button

func (xgc *Xigo_gc) Press_button(wname string, bid int)

Press causes a radio/sticky button to be 'pressed in.'

func (*Xigo_gc) Push_state

func (xgc *Xigo_gc) Push_state()

Push_state saves various things from the current state.

func (*Xigo_gc) Release_button

func (xgc *Xigo_gc) Release_button(wname string, bid int)

Release_button causes a radio/sticky button to be 'popped out.'

func (*Xigo_gc) Rotate

func (xgc *Xigo_gc) Rotate(degrees float64) bool

Rotate will logically rotate the page by the specified degrees. Currently not supported for XI, so we return false to indicate that rotation 'failed'.

func (*Xigo_gc) Select_page

func (xgc *Xigo_gc) Select_page(pname string)

Select_page makes the named page the active page which becomes the target for all subsequent drawing operations. Unlike the select_subpage, this function always looks at the top level window (page) and ignores the currently active page.

func (*Xigo_gc) Select_subpage

func (xgc *Xigo_gc) Select_subpage(pname string) (found bool)

Select_subpage selects the named subpage for subsequent drawing actions. The active page is searched first, and if the named page isn't there, then the default page is searched. The special names "root" or "default" may be used to select the root window.

If the named page was found we return true.

func (*Xigo_gc) Set_colour

func (xgc *Xigo_gc) Set_colour(cname string)

Set_colour accepts a colour value string (e.g. #rrggbb) or recognised name (e.g. "white") and makes that the active colour for subsequent drawing options.

func (*Xigo_gc) Set_dimensions

func (xgc *Xigo_gc) Set_dimensions(height float64, width float64)

Set diminsions is ignored. A window should be sizable by the user.

func (*Xigo_gc) Set_fill_attrs

func (xgc *Xigo_gc) Set_fill_attrs(cname string, fill_style int)

Set_fill_sttrs allows the caller to control the fill attribute (fill/unfilled) for the shape drawing funcitons.

func (*Xigo_gc) Set_font

func (xgc *Xigo_gc) Set_font(fontname string, points int, weight int, ital bool)

Set_font finds and loads the indicated font. Weights < 2 are considered 'normal'; >=2 are 'bold'.

func (*Xigo_gc) Set_iscale

func (xgc *Xigo_gc) Set_iscale(increment float64)

Set_iscale increments the scale by the value passed in, the increment is applied to both x and y scales. For the most part, only xscale is applied since the underlying XI lib doesn't support independent scale values as postscript does, but we must accept same parms as the postscript functions.

func (*Xigo_gc) Set_line_style

func (xgc *Xigo_gc) Set_line_style(pattern []int)

Set_line_style configures the rendering for lines until changed.

This is fashioned after the postscript line style mechanism that takes an on off set of integers (e.g. 3 on, 2 off, or 3 on 2 off, 4 on 2 off, etc.). To set a solid line in postscript, a nil pointer is passed. X doesn't support such a rich notaion of line styles so the interpretation here is:

nil -- solid line
!nil - dashed line

func (*Xigo_gc) Set_line_width

func (xgc *Xigo_gc) Set_line_width(width int)

Set the line wdith to desired size. setting to 0 causes the smallest possible (fastest) line to be drawn.

func (*Xigo_gc) Set_page_colour

func (xgc *Xigo_gc) Set_page_colour(cname string)

func (*Xigo_gc) Set_scale

func (xgc *Xigo_gc) Set_scale(xscale float64, yscale float64)

Set_scale captures the new desired scale for things drawn in the pages known to this graphics context. For the most part, only xscale is applied since the underlying XI lib doesn't support independent scale values as postscript does, but we must accept same parms as the postscript functions.

func (*Xigo_gc) Set_visibility

func (xgc *Xigo_gc) Set_visibility(pname string, hidden bool)

Set the visibility for a subpage.

func (*Xigo_gc) Show

func (xgc *Xigo_gc) Show()

Show causes all pages to be updated (shown). This is done by drawing each page which in turn draws each subpage.

func (*Xigo_gc) Translate

func (xgc *Xigo_gc) Translate(x float64, y float64)

Translate applies the hard x,y value as the coordinates of the page's origin for the active page. Current setting are saved so that push/pop can restore the setting.

func (*Xigo_gc) Translate_delta

func (xgc *Xigo_gc) Translate_delta(xdelta float64, ydelta float64)

Translate_delta shifts the page origin by deltax,deltay for the active page.

func (*Xigo_gc) Unlock

func (xgc *Xigo_gc) Unlock()

Release the lock.

type Xigo_image

type Xigo_image struct {
	// contains filtered or unexported fields
}

type Xigo_page

type Xigo_page struct {
	// contains filtered or unexported fields
}

Used to manage both a root page (window) and a subpage (window in its own right, but within a window).

func (*Xigo_page) Add_listener

func (p *Xigo_page) Add_listener(gc *Xigo_gc)

Ensure that the callback funciton will be driven for this subpage window and that the window will map to the given gc.

func (*Xigo_page) Add_subpage

func (p *Xigo_page) Add_subpage(pname string, x int, y int, height int, width int) (sp *Xigo_page)

Add_subpage creates a new subpage and places it into the drawing order at the "top" (last drawn).

func (*Xigo_page) Clear

func (p *Xigo_page) Clear(xgc *Xigo_gc, clear_all bool)

Clears the page by filling with the current colour, and calls clear for all subpages.

func (*Xigo_page) Close

func (p *Xigo_page) Close()

Close does whatever is needed to close the page including closing any open subpages.

func (*Xigo_page) Get_colour

func (p *Xigo_page) Get_colour() C.int

func (*Xigo_page) Get_page_colour

func (p *Xigo_page) Get_page_colour() C.int

func (*Xigo_page) Get_subpage

func (p *Xigo_page) Get_subpage(pname string) (sp *Xigo_page)

Finds the named subpage and returns it to the caller.

func (*Xigo_page) Get_win

func (p *Xigo_page) Get_win() C.int

Get_win returns the page's window for drawing operations.

func (*Xigo_page) Lock

func (p *Xigo_page) Lock()

Lock causes the page's size and scale to become fixed (locked) and will not be affected by scale and move requests.

func (*Xigo_page) Move

func (p *Xigo_page) Move(delta_x int, delta_y int, scale float64)

Move will change the x,y location of the subpage by the delta x,y passed in applying the scale factor after adjusting the point. If only adjusting the scale, then a delta of 0,0 should be passed.

func (*Xigo_page) Move_subpages

func (p *Xigo_page) Move_subpages(dx int, dy int, scale float64, recursive bool)

Move_subpages causes all subpages to be moved relative to their original x,y location.

func (*Xigo_page) Scale

func (p *Xigo_page) Scale(scale float64)

Scale causes the window size to be changed by scaling the defined window height/width using the factor passed in.

func (*Xigo_page) Scale_subpages

func (p *Xigo_page) Scale_subpages(scale float64, recursive bool)

Scale_subpages causes all subpages to this page to be scaled. If recursive is true, then for each subpage, we scale their subpages too.

func (*Xigo_page) Set_colour

func (p *Xigo_page) Set_colour(colour C.int)

Set_colour sets the currently active colour for drawing.

func (*Xigo_page) Set_invisible

func (p *Xigo_page) Set_invisible()

Sets the visibility of the page/subpage to false.

func (*Xigo_page) Set_page_colour

func (p *Xigo_page) Set_page_colour(colour C.int)

Set_page_colour sets the page colour used when clearing the page.

func (*Xigo_page) Set_visible

func (p *Xigo_page) Set_visible()

Sets the visibility of the page/subpage to true.

func (*Xigo_page) Show

func (p *Xigo_page) Show()

Show will cause the drawing buffer for this page to be swapped (making it visible), and if there are any sub pages, will invoke their show function to do the same. Sub pages are rendered in reverse creation order.

func (*Xigo_page) Unlock added in v1.2.0

func (p *Xigo_page) Unlock()

Unock causes the page's size and scale to become variable (unlocked) and will be affected by scale and move requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL