diff options
author | Alexander Neumann <an2048@googlemail.com> | 2012-02-20 14:53:54 +0100 |
---|---|---|
committer | Alexander Neumann <an2048@googlemail.com> | 2012-02-20 14:53:54 +0100 |
commit | 05d8da640fe57702e9ea0c3e325f3b5a01b7dc13 (patch) | |
tree | d70da2a4be44e607a86e729917ba9bde7874f01b /imagelist.go | |
parent | TextEdit: Improve handling of escape and tab keys. (diff) | |
download | wireguard-windows-05d8da640fe57702e9ea0c3e325f3b5a01b7dc13.tar.xz wireguard-windows-05d8da640fe57702e9ea0c3e325f3b5a01b7dc13.zip |
Revert directory layout to what we had initially
Diffstat (limited to 'imagelist.go')
-rw-r--r-- | imagelist.go | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/imagelist.go b/imagelist.go new file mode 100644 index 00000000..cb649d3a --- /dev/null +++ b/imagelist.go @@ -0,0 +1,75 @@ +// Copyright 2010 The Walk Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package walk + +import ( + "os" +) + +import . "walk/winapi" + +type ImageList struct { + hIml HIMAGELIST + maskColor Color +} + +func NewImageList(imageSize Size, maskColor Color) (*ImageList, os.Error) { + hIml := ImageList_Create( + int32(imageSize.Width), + int32(imageSize.Height), + ILC_MASK|ILC_COLOR24, + 8, + 8) + if hIml == 0 { + return nil, newError("ImageList_Create failed") + } + + return &ImageList{hIml: hIml, maskColor: maskColor}, nil +} + +func (il *ImageList) Add(bitmap, maskBitmap *Bitmap) (int, os.Error) { + if bitmap == nil { + return 0, newError("bitmap cannot be nil") + } + + var maskHandle HBITMAP + if maskBitmap != nil { + maskHandle = maskBitmap.handle() + } + + index := int(ImageList_Add(il.hIml, bitmap.handle(), maskHandle)) + if index == -1 { + return 0, newError("ImageList_Add failed") + } + + return index, nil +} + +func (il *ImageList) AddMasked(bitmap *Bitmap) (int32, os.Error) { + if bitmap == nil { + return 0, newError("bitmap cannot be nil") + } + + index := ImageList_AddMasked( + il.hIml, + bitmap.handle(), + COLORREF(il.maskColor)) + if index == -1 { + return 0, newError("ImageList_AddMasked failed") + } + + return index, nil +} + +func (il *ImageList) Dispose() { + if il.hIml != 0 { + ImageList_Destroy(il.hIml) + il.hIml = 0 + } +} + +func (il *ImageList) MaskColor() Color { + return il.maskColor +} |