5 // Created by Killery on 2013/11/07.
6 // Copyright (c) 2013年 Killery. All rights reserved.
11 @implementation StandView
13 - (id)initWithFrame:(NSRect)frame
15 self = [super initWithFrame:frame];
18 scheduledTimerWithTimeInterval:0.05f
20 selector:@selector(EventLoopSV:)
25 testImage = [self LoadImage:@"ucb1"];
31 -(void)EventLoopSV:(NSTimer*)time{
33 [self setNeedsDisplay:YES];
41 -(NSImage*)LoadImage:(NSString*)name{
42 NSImage *image = [NSImage imageNamed:name];
43 if(image == nil) return nil;
48 -(void)DrawImage:(NSImage*)image x:(float)x y:(float)y{
50 frRect.size.height = image.size.height;
51 frRect.size.width = image.size.width;
59 drRect.size.height = image.size.height;
60 drRect.size.width = image.size.width;
62 [image drawInRect:drRect fromRect:frRect operation:NSCompositeSourceOver fraction:1.0f respectFlipped:YES hints:nil];
66 -(void)mouseDown:(NSEvent *)theEvent{
69 for(int i = 0;i < Irow;i++){
77 for (int i = 0; i < TVCrow1; i++) {
81 for (int i = 0; i < TVCrow2; i++) {
90 if(TV2sglFlag && b->L->visible){
100 startPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
102 startPoint.x = startPoint.x - imgGx;
103 startPoint.y = startPoint.y - imgGy;
107 -(void)mouseDragged:(NSEvent *)theEvent{
109 endPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
111 imgGx = endPoint.x - startPoint.x;
112 imgGy = endPoint.y - startPoint.y;
117 for (int i = 0;i < Irow;i++) {
123 for (int i = 0;i < IBrow;i++) {
146 for (int i = 0;i < Irow;i++) {
153 for (int i = 0;i < IBrow;i++) {
160 for (int i = 0;i < IBLrow;i++) {
161 I->B->L = I->B->L->next;
177 endPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
179 imgGx = endPoint.x - startPoint.x;
180 imgGy = endPoint.y - startPoint.y;
183 for(int i = 0;i < Irow;i++){
191 for (int i = 0; i < TVCrow1; i++) {
195 for (int i = 0; i < TVCrow2; i++) {
203 if(TV2sglFlag && b->L->visible){
208 //NSLog(@"%d,%d", b->L->x, b->L->y);
215 [self setNeedsDisplay:YES];
219 -(void)mouseUp:(NSEvent *)theEvent{
223 - (void)drawRect:(NSRect)dirtyRect
232 while(layerIndex <= 999){
234 for (int i = 0;i < Irow;i++) {
240 for (int i = 0;i < IBrow;i++) {
245 if(I->B->z == layerIndex)
246 [self DrawImage:I->B->img x:I->B->x y:I->B->y];
252 if(I->B->L && I->B->L->visible && I->B->L->z == layerIndex){
253 [self DrawImage:I->B->L->img x:I->B->L->x y:I->B->L->y];
255 I->B->L = I->B->L->next;
271 for(int i = 0;i < Irow;i++){
279 while(layerIndex <= 999){
281 for (int i = 0;b && i <= TVCrow1; i++) {
285 if(layerIndex == b->z && b->img) [self DrawImage:b->img x:b->x y:b->y];
293 if(layerIndex == l->z && l->img)
294 [self DrawImage:l->img x:l->x y:l->y];