第18章 Images and Mouse Events
2012-05-25 18:48
197 查看
第18章 Images and Mouse Events
本章主要介绍如何将一个image放到view中,以及使用鼠标的响应事件完成重新绘制图像的功能。
在上一章custom view的基础上,响应菜单栏的open事件,打开一个openPanel,完成选择图像文件,并将该图像存储到内部变量中。在自己创建的strechview绘制自己时,通过响应鼠标的事件,完成在选定位置,选定大小的矩形中绘制选择的图像文件。
在challenge中,又一次使用NSBezierPath,完成在任意位置绘制圆的功能。
文件名:imagefun_upload.zip
文件大小:4 KB
下载地址:http://1000eb.com/8upe
本章主要介绍如何将一个image放到view中,以及使用鼠标的响应事件完成重新绘制图像的功能。
在上一章custom view的基础上,响应菜单栏的open事件,打开一个openPanel,完成选择图像文件,并将该图像存储到内部变量中。在自己创建的strechview绘制自己时,通过响应鼠标的事件,完成在选定位置,选定大小的矩形中绘制选择的图像文件。
在challenge中,又一次使用NSBezierPath,完成在任意位置绘制圆的功能。
view绘制图像函数 - (void)drawRect: (NSRect)rect { // Drawing code here. NSRect bounds = [self bounds]; [[NSColor greenColor] set]; [NSBezierPath fillRect:bounds]; [[NSColor whiteColor] set]; [path stroke]; NSRect drawingOval = [self currentOvalRect]; ovalPath = [NSBezierPath bezierPathWithOvalInRect:drawingOval]; [ovalPath closePath]; [[NSColor redColor] set]; [ovalPath stroke]; if(image) { NSRect imageRect; imageRect.origin = NSZeroPoint; imageRect.size = [image size]; NSRect drawingRect = [self currentRect]; [image drawInRect:drawingRect fromRect:imageRect operation:NSCompositeSourceOver fraction: opacity]; }
}
文件名:imagefun_upload.zip
文件大小:4 KB
下载地址:http://1000eb.com/8upe
相关文章推荐
- Images and Mouse Events(Chapter 18 of Cocoa Programming for Mac OS X)
- Cocoa Programming for Mac OS X 第十八章(Images and Mouse Events)摘录
- Professional JS(13.4.3Mouse and Wheel/Keyboard and Text/composition/Mutation/HTML5 Events[part])
- 捕获按钮离开事件.Simulate MouseEnter and MouseLeave events
- Mouse wheel events, event filters, and QScrollArea
- System Events and Mouse Messages
- How to handle the MouseLeftButtonDown and MouseLeftButtonUp events of the Button control?
- What is the difference between the mouseover and mouseenter events?
- Page Events: Order and PostBack
- Virtualbox mouse move in and out and file share with windows
- [Yii Framework] How to embed the css and images in a module
- Model View Controller (MVC) Using C#, Delegates and Events in .NET
- Overloading,overriding,and extending functions and events 重载,重写和扩展函数和事件
- HDU-1078 FatMouse and Cheese ( 记忆化搜索 )
- HOWTO: Unpack, Edit, and Re-Pack Boot Images
- [HDOJ1078]FatMouse and Cheese(记忆化搜索)
- zoj 1107 FatMouse and Cheese(动态规划 记忆化搜索)
- Scrapy学习笔记九--Downloading and processing files and images
- .Net 's delegates and events
- Port Windows IPC apps to Linux, Part 2: Semaphores and events