|
|
1.1 ! root 1: ! 2: #import "CornerView.h" ! 3: #import "Thinker.h" ! 4: ! 5: @implementation CornerView ! 6: ! 7: - initFrame:(const NXRect *)frameRect ! 8: { ! 9: [super initFrame:frameRect]; ! 10: image = [NXImage findImageNamed:"corner"]; ! 11: check = [NXImage findImageNamed:"x"]; ! 12: return self; ! 13: } ! 14: ! 15: static NXPoint z[] = {{5,9},{32,9},{32,30},{5,30}}; ! 16: ! 17: - drawSelf:(const NXRect *)rects :(int)rectCount ! 18: { ! 19: NXPoint zero = {0,0}; ! 20: [image composite:NX_SOVER toPoint:&zero]; ! 21: if (state) [check composite:NX_SOVER toPoint:&z[state-1]]; ! 22: return self; ! 23: } ! 24: ! 25: - setState:(int)val ! 26: { ! 27: state = val; ! 28: [self display]; ! 29: return self; ! 30: } ! 31: ! 32: - mouseDown:(NXEvent *)theEvent ! 33: { ! 34: int i, tstate = 0; ! 35: NXPoint p; ! 36: NXRect r = {{0,0},{11,11}}; ! 37: int inCorner = 0; ! 38: ! 39: p = theEvent->location; ! 40: [self convertPoint:&p fromView:nil]; ! 41: ! 42: for (i=0; i<4; i++) ! 43: { ! 44: r.origin = z[i]; ! 45: if (NXPointInRect(&p,&r)) ! 46: { ! 47: tstate = i+1; ! 48: inCorner = 1; ! 49: break; ! 50: } ! 51: } ! 52: if (tstate == state) state = 0; ! 53: else if (inCorner) state = tstate; ! 54: ! 55: [self display]; ! 56: [BSThinker() setSleepCorner:state]; ! 57: ! 58: if (inCorner) ! 59: { ! 60: [self perform:@selector(saveState:) ! 61: with:self ! 62: afterDelay:5000 ! 63: cancelPrevious:YES]; ! 64: } ! 65: ! 66: return self; ! 67: } ! 68: ! 69: - saveState:sender ! 70: { ! 71: char str[10]; ! 72: sprintf(str,"%1d", state); ! 73: NXWriteDefault([NXApp appName], "hotCorner", str); ! 74: return self; ! 75: } ! 76: ! 77: @end ! 78: ! 79: ! 80: ! 81: ! 82: ! 83: ! 84: ! 85: ! 86: ! 87: ! 88: ! 89: ! 90: ! 91: ! 92:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.