Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 06c8b6c89a
Fetching contributors…

Cannot retrieve contributors at this time

53 lines (37 sloc) 1.011 kB
// 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
type ImageView struct {
image Image
func NewImageView(parent Container) (*ImageView, error) {
iv := &ImageView{}
cw, err := NewCustomWidget(parent, 0, func(canvas *Canvas, updateBounds Rectangle) error {
return iv.drawImage(canvas, updateBounds)
if err != nil {
return nil, err
iv.CustomWidget = cw
iv.widget = iv
return iv, nil
func (iv *ImageView) Image() Image {
return iv.image
func (iv *ImageView) SetImage(value Image) error {
iv.image = value
_, isMetafile := value.(*Metafile)
return iv.Invalidate()
func (iv *ImageView) drawImage(canvas *Canvas, updateBounds Rectangle) error {
if iv.image == nil {
return nil
bounds := iv.ClientBounds()
return canvas.DrawImageStretched(iv.image, bounds)
Jump to Line
Something went wrong with that request. Please try again.