Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OODebugInspector Class Reference

#include <OODebugInspector.h>

+ Inheritance diagram for OODebugInspector:
+ Collaboration diagram for OODebugInspector:

Instance Methods

(void) - bringToFront
 
(id< OOWeakReferenceSupport >) - object
 
(void) - dealloc [implementation]
 
(id) - initWithObject: [implementation]
 
(void) - placeModules [implementation]
 
(void) - update [implementation]
 
(void) - updateTick: [implementation]
 
(void) - windowWillClose: [implementation]
 
(void) - cleanSelfUp [implementation]
 

Class Methods

(id) + inspectorForObject:
 
(void) + cleanUpInspectors
 

Private Attributes

OOWeakReference_object
 
IBOutlet NSPanel * _panel
 
NSTimer * _timer
 
NSValue * _key
 
NSArray * _modules
 

Detailed Description

Definition at line 34 of file OODebugInspector.h.

Method Documentation

◆ bringToFront

- (void) bringToFront

Definition at line 35 of file OODebugInspector.m.

115{
116 if (![_panel isVisible]) [self update];
117 [_panel orderFront:nil];
118}
IBOutlet NSPanel * _panel

References nil.

◆ cleanSelfUp

- (void) cleanSelfUp
implementation

Definition at line 35 of file OODebugInspector.m.

219{
220 if ([self object] == nil) [_panel close];
221}
return nil

◆ cleanUpInspectors

+ (void) cleanUpInspectors

Definition at line 35 of file OODebugInspector.m.

122{
123 [[sActiveInspectors allValues] makeObjectsPerformSelector:@selector(cleanSelfUp)];
124}

◆ dealloc

- (void) dealloc
implementation

Definition at line 35 of file OODebugInspector.m.

79{
80 [_timer invalidate];
81 _timer = nil;
82 _panel = nil;
83 [_object release];
84 _object = nil;
85 if (_key != nil) [sActiveInspectors removeObjectForKey:_key];
86 [_key release];
87 _key = nil;
88 [_modules release];
89 [_panel close];
90
91 [super dealloc];
92}
OOWeakReference * _object

◆ initWithObject:

- (id) initWithObject: (id <OOWeakReferenceSupport>) object
implementation

Definition at line 35 of file OODebugInspector.m.

127 :(id <OOWeakReferenceSupport>)object
128{
129 if ((self = [super init]))
130 {
131 _key = [[NSValue valueWithNonretainedObject:object] retain];
132 _object = [object weakRetain];
133
134 [NSBundle loadNibNamed:@"OODebugInspector" owner:self];
135 [self update];
136 _timer = [NSTimer scheduledTimerWithTimeInterval:0.1
137 target:self
138 selector:@selector(updateTick:)
139 userInfo:nil
140 repeats:YES];
141
142 _modules = [[(id)object debugInspectorModules] retain];
143 [self placeModules];
144
145 if (sActiveInspectors == nil) sActiveInspectors = [[NSMutableDictionary alloc] init];
146 [sActiveInspectors setObject:self forKey:_key];
147 }
148
149 return self;
150}
static NSMutableDictionary * sActiveInspectors

◆ inspectorForObject:

+ (id) inspectorForObject: (id <OOWeakReferenceSupport>) object

Definition at line 35 of file OODebugInspector.m.

51 :(id <OOWeakReferenceSupport>)object
52{
53 OODebugInspector *inspector = nil;
54 NSValue *key = nil;
55
56 if (object == nil) return nil;
57
58 // Look for existing inspector
59 key = [NSValue valueWithNonretainedObject:object];
60 inspector = [sActiveInspectors objectForKey:key];
61 if (inspector != nil)
62 {
63 if ([inspector object] == object) return inspector;
64 else
65 {
66 // Existing inspector is for an old object that used to be at the same address.
67 [sActiveInspectors removeObjectForKey:key];
68 }
69 }
70
71 // No existing inspector; create one.
72 inspector = [[[self alloc] initWithObject:object] autorelease];
73
74 return inspector;
75}

◆ object

- (id< OOWeakReferenceSupport >) object

Definition at line 35 of file OODebugInspector.m.

96{
97 if (_object != nil)
98 {
99 id result = [_object weakRefUnderlyingObject];
100 if (result == nil)
101 {
102 [_object release];
103 _object = nil;
104 }
105 return result;
106 }
107 else
108 {
109 return nil;
110 }
111}

◆ placeModules

- (void) placeModules
implementation

Definition at line 35 of file OODebugInspector.m.

154{
155 // Lay out modules vertically in panel.
156 CGFloat totalHeight = 4; // Margin at bottom
157 NSRect frame;
158 NSView *contentView = nil, *moduleView = nil;
159 NSSize size;
160
161 // Sum heights of modules.
162 for (OODebugInspectorModule *module in _modules)
163 {
164 totalHeight += [[module rootView] frame].size.height;
165 }
166
167 // Resize panel appropriately.
168 frame = [_panel contentRectForFrameRect:[_panel frame]];
169 frame.size.height = totalHeight + 4; // Margin at top
170 [_panel setFrame:[_panel frameRectForContentRect:frame] display:NO];
171
172 size = [_panel contentMinSize];
173 size.height = frame.size.height;
174 [_panel setContentMinSize:size];
175
176 size = [_panel contentMaxSize];
177 size.height = frame.size.height;
178 [_panel setContentMaxSize:size];
179
180 // Position each module.
181 contentView = [_panel contentView];
182 for (OODebugInspectorModule *module in _modules)
183 {
184 moduleView = [module rootView];
185 frame = [moduleView frame];
186 totalHeight -= frame.size.height;
187 frame.origin.y = totalHeight;
188 [moduleView setFrame:frame];
189 [contentView addSubview:moduleView];
190 }
191
192 [self update];
193}
voidpf void uLong size
Definition ioapi.h:134

◆ update

- (void) update
implementation

Definition at line 35 of file OODebugInspector.m.

197{
198 [_modules makeObjectsPerformSelector:@selector(update)];
199}

◆ updateTick:

- (void) updateTick: (NSTimer *) timer
implementation

Definition at line 35 of file OODebugInspector.m.

202 :(NSTimer *)timer
203{
204 if ([_panel isVisible]) [self update];
205}

◆ windowWillClose:

- (void) windowWillClose: (NSNotification *) notification
implementation

Definition at line 35 of file OODebugInspector.m.

208 :(NSNotification *)notification
209{
210 _panel = nil;
211 NSValue *key = _key;
212 _key = nil;
213 if (key != nil) [sActiveInspectors removeObjectForKey:key];
214 [key release];
215}

Member Data Documentation

◆ _key

- (NSValue*) _key
private

Definition at line 40 of file OODebugInspector.h.

◆ _modules

- (NSArray*) _modules
private

Definition at line 42 of file OODebugInspector.h.

◆ _object

- (OOWeakReference*) _object
private

Definition at line 37 of file OODebugInspector.h.

◆ _panel

- (IBOutlet NSPanel*) _panel
private

Definition at line 38 of file OODebugInspector.h.

◆ _timer

- (NSTimer*) _timer
private

Definition at line 39 of file OODebugInspector.h.


The documentation for this class was generated from the following files: