示例#1
0
文件: imgbutton.go 项目: pkf/dropdot
func imgButton_OnPaint(arg *gform.EventArg) {
	if data, ok := arg.Data().(*gform.PaintEventData); ok {
		var b *ImgButton
		if b, ok = arg.Sender().(*ImgButton); ok {
			var bmp *gform.Bitmap
			switch b.state {
			case IBSNormal:
				bmp = newResBitmap(&b.resNormal)
			case IBSMouseHover:
				bmp = newResBitmap(&b.resMouseOver)
			case IBSClick:
				bmp = newResBitmap(&b.resClick)
			}
			if bmp != nil {
				defer bmp.Dispose()

				if b.Height() != bmp.Height() || b.Width() != bmp.Width() {
					b.SetSize(bmp.Size())
				}

				data.Canvas.DrawBitmap(bmp, 0, 0)
			}
		}
	}
}
示例#2
0
func stateButton_OnPaint(arg *gform.EventArg) {
	if b, ok := arg.Sender().(*StateButton); ok {
		var data *gform.PaintEventData
		if data, ok = arg.Data().(*gform.PaintEventData); ok {
			var bmp *gform.Bitmap
			if b.isChecked {
				bmp = newResBitmap(&b.resChecked)
			} else {
				bmp = newResBitmap(&b.resNormal)
			}
			defer bmp.Dispose()

			data.Canvas.DrawBitmap(bmp, 0, 0)
		}
	}
}