github.com/secoba/wails/v2@v2.6.4/internal/frontend/desktop/windows/winc/imagelist.go (about)

     1  //go:build windows
     2  
     3  /*
     4   * Copyright (C) 2019 The Winc Authors. All Rights Reserved.
     5   * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.
     6   */
     7  
     8  package winc
     9  
    10  import (
    11  	"fmt"
    12  
    13  	"github.com/secoba/wails/v2/internal/frontend/desktop/windows/winc/w32"
    14  )
    15  
    16  type ImageList struct {
    17  	handle w32.HIMAGELIST
    18  }
    19  
    20  func NewImageList(cx, cy int) *ImageList {
    21  	return newImageList(cx, cy, w32.ILC_COLOR32, 0, 0)
    22  }
    23  
    24  func newImageList(cx, cy int, flags uint, cInitial, cGrow int) *ImageList {
    25  	imgl := new(ImageList)
    26  	imgl.handle = w32.ImageList_Create(cx, cy, flags, cInitial, cGrow)
    27  	return imgl
    28  }
    29  
    30  func (im *ImageList) Handle() w32.HIMAGELIST {
    31  	return im.handle
    32  }
    33  
    34  func (im *ImageList) Destroy() bool {
    35  	return w32.ImageList_Destroy(im.handle)
    36  }
    37  
    38  func (im *ImageList) SetImageCount(uNewCount uint) bool {
    39  	return w32.ImageList_SetImageCount(im.handle, uNewCount)
    40  }
    41  
    42  func (im *ImageList) ImageCount() int {
    43  	return w32.ImageList_GetImageCount(im.handle)
    44  }
    45  
    46  func (im *ImageList) AddIcon(icon *Icon) int {
    47  	return w32.ImageList_AddIcon(im.handle, icon.Handle())
    48  }
    49  
    50  func (im *ImageList) AddResIcon(iconID uint16) {
    51  	if ico, err := NewIconFromResource(GetAppInstance(), iconID); err == nil {
    52  		im.AddIcon(ico)
    53  		return
    54  	}
    55  	panic(fmt.Sprintf("missing icon with icon ID: %d", iconID))
    56  }
    57  
    58  func (im *ImageList) RemoveAll() bool {
    59  	return w32.ImageList_RemoveAll(im.handle)
    60  }
    61  
    62  func (im *ImageList) Remove(i int) bool {
    63  	return w32.ImageList_Remove(im.handle, i)
    64  }