KeypairView.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #import "qedefs.h"
  2. id keypairview_i;
  3. @implementation KeypairView
  4. /*
  5. ==================
  6. initFrame:
  7. ==================
  8. */
  9. - initFrame:(const NXRect *)frameRect
  10. {
  11. [super initFrame:frameRect];
  12. keypairview_i = self;
  13. return self;
  14. }
  15. - calcViewSize
  16. {
  17. NXCoord w;
  18. NXCoord h;
  19. NXRect b;
  20. NXPoint pt;
  21. int count;
  22. id ent;
  23. ent = [map_i currentEntity];
  24. count = [ent numPairs];
  25. [superview setFlipped: YES];
  26. [superview getBounds:&b];
  27. w = b.size.width;
  28. h = LINEHEIGHT*count + SPACING;
  29. [self sizeTo:w :h];
  30. pt.x = pt.y = 0;
  31. [self scrollPoint: &pt];
  32. return self;
  33. }
  34. - drawSelf:(const NXRect *)rects :(int)rectCount
  35. {
  36. epair_t *pair;
  37. int y;
  38. PSsetgray(NXGrayComponent(NX_COLORLTGRAY));
  39. PSrectfill(0,0,bounds.size.width,bounds.size.height);
  40. PSselectfont("Helvetica-Bold",FONTSIZE);
  41. PSrotate(0);
  42. PSsetgray(0);
  43. pair = [[map_i currentEntity] epairs];
  44. y = bounds.size.height - LINEHEIGHT;
  45. for ( ; pair ; pair=pair->next)
  46. {
  47. PSmoveto(SPACING, y);
  48. PSshow(pair->key);
  49. PSmoveto(100, y);
  50. PSshow(pair->value);
  51. y -= LINEHEIGHT;
  52. }
  53. PSstroke();
  54. return self;
  55. }
  56. - mouseDown:(NXEvent *)theEvent
  57. {
  58. NXPoint loc;
  59. int i;
  60. epair_t *p;
  61. loc = theEvent->location;
  62. [self convertPoint:&loc fromView:NULL];
  63. i = (bounds.size.height - loc.y - 4) / LINEHEIGHT;
  64. p = [[map_i currentEntity] epairs];
  65. while ( i )
  66. {
  67. p=p->next;
  68. if (!p)
  69. return self;
  70. i--;
  71. }
  72. if (p)
  73. [things_i setSelectedKey: p];
  74. return self;
  75. }
  76. @end