Пример #1
0
package components

import (
	"github.com/skelterjohn/goui"
	"io"
	"template"
)

const LabelHTMLTemplateFormat = `
Label: {{.Text}}
`

var LabelHTMLTemplate = template.Must(goui.ParseExecTemplate(LabelHTMLTemplateFormat))

type LabelData struct {
	Text string
}

type Label struct {
	data  LabelData
	dirty bool
}

func NewLabel(text string) (me *Label) {
	me = new(Label)
	me.data.Text = text
	return
}

func (me *Label) SetData(data LabelData) {
	me.data = data
Пример #2
0
package components

import (
	"github.com/skelterjohn/goui"
	"github.com/skelterjohn/goui/messages"
	"io"
	"template"
)

const ButtonHTMLTemplateFormat = `
<a href=/m/{{.MName}}>{{.Label}}</a>
`

var ButtonHTMLTemplate = template.Must(goui.ParseExecTemplate(ButtonHTMLTemplateFormat))

type ButtonData struct {
	Label string
	MName string
}

type Button struct {
	data  ButtonData
	dirty bool

	Click <-chan []byte
}

func NewButton(label string) (me *Button) {
	me = new(Button)
	me.data.Label = label
	me.data.MName, me.Click = messages.GetMessenger()
Пример #3
0
import (
	"github.com/skelterjohn/goui"
	"github.com/skelterjohn/goui/components"
	"io"
	"template"
)

const DialogHTMLTemplateFormat = `
Dialog
<br>
{{ComponentWriter .Message}}
<br>
{{ComponentWriter .Button}}
`

var DialogHTMLTemplate = template.Must(goui.ParseExecTemplate(DialogHTMLTemplateFormat))

type DialogData struct {
	Message       goui.Component
	Button        *components.Button
	Width, Height int
}

type Dialog struct {
	data DialogData

	dirty bool
}

func NewDialog() (me *Dialog) {
	me = new(Dialog)