什么是在画布上显示图形图像的正确方法? 我有对象aImage从:visualworks smalltalk在画布上显示图形图像
(...)superclass: #{UI.ApplicationModel}(...)
和方法初始化:
initialize
|img gc|
img:=(ImageReader fromFile: 'clockface.jpg') image.
img convertForGraphicsDevice: Screen default.
gc := ScreenGraphicsContext new.
img displayOn: gc.
gc displayOn: self.
但我
(ImageReader fromFile: 'clockface.jpg') image.
我经由GUIBuilder(新canvas->安装)新类称为ClockWindow制成出现错误: messageNotUnderstatood:representImage:anImage forMedium:medium 符合:“img displayOn:gc。”
所以。我们升级吧。我想在图形上下文中绘制一些形状和图像。如何将此上下文显示为画布的一部分(GuiPainter)? – borovsky
为此您需要自定义视图。创建视图的子类并覆盖displayOn:在图形上下文中绘制图形。要将其添加到UIPainter窗口中,请添加一个viewHolder,并为View:字段输入返回该自定义视图的类中的方法名称。您可能希望在创建实例变量时将其缓存在实例变量中。 –