Exemple #1
0
func NewImgButton(parent gform.Controller, resNormal, resMouseOver, resClick ResBmpInfo) *ImgButton {
	b := new(ImgButton)
	b.Init(parent)

	b.resNormal = resNormal
	b.resMouseOver = resMouseOver
	b.resClick = resClick

	b.state = IBSNormal

	//Load normal state bitmap to set initial size
	temp := newResBitmap(&b.resNormal)
	defer temp.Dispose()
	b.SetSize(temp.Size())

	gform.RegMsgHandler(b)

	b.OnPaint().Attach(imgButton_OnPaint)
	b.OnMouseHover().Attach(imgButton_OnMouseHover)
	b.OnMouseLeave().Attach(imgButton_OnMouseLeave)
	b.OnLBDown().Attach(imgButton_OnLBDown)
	b.OnLBUp().Attach(imgButton_OnLBUp)

	return b
}
Exemple #2
0
func NewMainform(parent gform.Controller) *Mainform {
	mf := Mainform{*gform.NewForm(parent)}

	mf.EnableDragMove(true)
	mf.SetSize(200, 200)
	mf.EnableSizable(false)
	mf.EnableDragAcceptFiles(true)
	gform.ToggleStyle(mf.Handle(), false, w32.WS_CAPTION)
	gform.ToggleExStyle(mf.Handle(), false, w32.WS_EX_CLIENTEDGE)

	gform.RegMsgHandler(&mf)

	mf.OnPaint().Attach(mainform_OnPaint)

	btnClose := NewImgButton(&mf, gResCloseNormal, gResCloseMouseOver, gResCloseClick)
	btnClose.SetPos(mf.Width()-btnClose.Width()-3, 3)
	btnClose.OnLBUp().Attach(btnClose_OnLBUp)

	x, y := btnClose.Pos()
	btnPin := NewStateButton(&mf, gResPinNormal, gResPinChecked)
	btnPin.SetPos(x-btnPin.Width()-3, y)
	btnPin.OnStateChange().Attach(btnPin_OnStateChange)

	btnLoad := NewImgButton(&mf, gResLoadNormal, gResLoadMouseOver, gResLoadClick)
	btnLoad.SetPos(mf.Width()-btnLoad.Width()-3, 130)

	x, y = btnLoad.Pos()
	btnSave := NewImgButton(&mf, gResSaveNormal, gResSaveMouseOver, gResSaveClick)
	btnSave.SetPos(x-btnSave.Width()-3, y)

	return &mf
}
Exemple #3
0
func NewProgressButton(parent gform.Controller, bgColor, foreColor gform.Color) *ProgressButton {
	pb := new(ProgressButton)
	pb.Init(parent)
	pb.bgColor, pb.foreColor, pb.highlightColor = bgColor, foreColor, gform.RGB(150, 150, 150)
	pb.tempColor = pb.bgColor

	gform.RegMsgHandler(pb)

	pb.OnPaint().Attach(progressButton_OnPaint)
	pb.OnMouseHover().Attach(progressButton_OnMouseHover)
	pb.OnMouseLeave().Attach(progressButton_OnMouseLeave)

	return pb
}
Exemple #4
0
func NewStateButton(parent gform.Controller, resNormal, resChecked ResBmpInfo) *StateButton {
	b := new(StateButton)
	b.Init(parent)

	b.resNormal = resNormal
	b.resChecked = resChecked

	b.isChecked = false

	//Load normal state bitmap to set initial size
	temp := newResBitmap(&b.resNormal)
	defer temp.Dispose()
	b.SetSize(temp.Size())

	gform.RegMsgHandler(b)

	b.OnPaint().Attach(stateButton_OnPaint)
	b.OnLBUp().Attach(stateButton_OnLBUp)

	return b
}