2014-08-16 13:02:00 -05:00
|
|
|
// 16 august 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "winapi_windows.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
type imagelist struct {
|
2014-10-02 09:05:53 -05:00
|
|
|
list []C.HBITMAP
|
|
|
|
width []int
|
|
|
|
height []int
|
2014-08-16 13:02:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func newImageList() ImageList {
|
|
|
|
return new(imagelist)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *imagelist) Append(img *image.RGBA) {
|
|
|
|
i.list = append(i.list, C.unscaledBitmap(unsafe.Pointer(img), C.intptr_t(img.Rect.Dx()), C.intptr_t(img.Rect.Dy())))
|
|
|
|
i.width = append(i.width, img.Rect.Dx())
|
|
|
|
i.height = append(i.height, img.Rect.Dy())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *imagelist) Len() ImageIndex {
|
|
|
|
return ImageIndex(len(i.list))
|
|
|
|
}
|
|
|
|
|
|
|
|
type imageListApply interface {
|
2014-08-25 15:53:47 -05:00
|
|
|
apply(C.HWND, C.UINT)
|
2014-08-16 13:02:00 -05:00
|
|
|
}
|
|
|
|
|
2014-08-25 15:53:47 -05:00
|
|
|
func (i *imagelist) apply(hwnd C.HWND, uMsg C.UINT) {
|
2014-08-16 13:02:00 -05:00
|
|
|
width := C.GetSystemMetrics(C.SM_CXSMICON)
|
|
|
|
height := C.GetSystemMetrics(C.SM_CYSMICON)
|
|
|
|
il := C.newImageList(width, height)
|
|
|
|
for index := range i.list {
|
2014-08-16 16:37:21 -05:00
|
|
|
C.addImage(il, hwnd, i.list[index], C.int(i.width[index]), C.int(i.height[index]), width, height)
|
2014-08-16 13:02:00 -05:00
|
|
|
}
|
2014-08-25 15:53:47 -05:00
|
|
|
C.SendMessageW(hwnd, uMsg, 0, C.LPARAM(uintptr(unsafe.Pointer(il))))
|
2014-08-16 13:02:00 -05:00
|
|
|
}
|