comparison pkg-src/tree-nx/TreeButton.m @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents
children
comparison
equal deleted inserted replaced
162:4de2936b4e77 163:0132846995bd
1 //
2 // TreeButton.m -- a class to attach to tree data structures
3 // This class requires the String class, also by Don Yacktman.
4 // Written by Don Yacktman (c) 1993 by Don Yacktman.
5 // All rights reserved.
6 //
7 // I doubt this will be useful for much beyond what it does in the demo
8 // program supplied in this directory.
9 //
10 // You may use and copy this class freely as long as you
11 // comply with the following terms:
12 // (1) If you use this class in an application which you
13 // intend to sell commercially, as shareware, or otherwise,
14 // you may only do so with express written permission
15 // of the author. Use in applications which will
16 // be distributed free of charge is encouraged.
17 // (2) You must include the source code to this object and
18 // all accompanying documentation with your application,
19 // or provide it to users if requested, free of charge.
20 // (3) Do not remove the author's name or any of the
21 // copyright notices
22 //
23
24 #import "TreeButton.h"
25 #import "TreeButtonCell.h"
26 #import "NamedTree.h"
27
28 @implementation TreeButton
29
30 static id treeButtonCell;
31
32 + initialize
33 {
34 if (self == [TreeButton class]) {
35 treeButtonCell = [TreeButtonCell class]; // default cell class
36 }
37 return self;
38 }
39
40 + setCellClass:classId
41 {
42 treeButtonCell = classId;
43 return self;
44 }
45
46 - initFrame:(const NXRect *)frameRect
47 {
48 id oldCell;
49
50 [super initFrame:frameRect];
51 oldCell = [self setCell:[[[treeButtonCell alloc] init] setParent:self]];
52 [oldCell free];
53
54 return self;
55 }
56
57 - wasSelected:sender
58 { // message is sent here by the Cell if the user clicked the button
59 if ([myTreeNode respondsTo:@selector(activateNode:)])
60 [myTreeNode activateNode:self];
61 return self;
62 }
63
64 - treeNode { return myTreeNode; }
65 - setTreeNode:node { myTreeNode = node; return self; }
66
67 @end