Skip to content

Commit 0fa9e74

Browse files
committed
Before moving ContentDataSource into Content.xib. Big Split of BkmxDocWinCon working pretty good.
1 parent d45ba44 commit 0fa9e74

14 files changed

+200
-148
lines changed

SSWebBrowsing.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ + (NSString*)defaultBrowserDisplayName {
6565
name = @"??" ;
6666
}
6767

68-
// Memory leak fixed in BookMacster 1.16.5. See LSGetApplicationForURL() doc.
68+
// Memory leak fixed in BookMacster 1.17. See LSGetApplicationForURL() doc.
6969
if (defaultBrowserURL) {
7070
CFRelease(defaultBrowserURL) ;
7171
}

SSYAboutPanelController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ + (SSYAboutPanelController *) sharedInstance
236236
{
237237
sharedInstance = [[self alloc] init];
238238
[NSBundle loadNibNamed: @"SSYAboutPanel.nib"
239-
owner: sharedInstance];
239+
owner: sharedInstance] ;
240240
}
241241

242242
return sharedInstance;

SSYCarbonSearcher.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void CStringToUnicode(
4545
struct SearchInfo {
4646
FSCatalogBulkParam searchPB ; // Needed so we can back out of it using offsetof()
4747
FSCatalogBulkParamPtr searchPB_p ; // Needed so we can dealloc it
48-
FSIterator iterator ; // Needed so we can close it. Added in BookMacster 1.16.5.
48+
FSIterator iterator ; // Needed so we can close it. Added in BookMacster 1.17.
4949
UInt32 maxFindsGrandTotal ;
5050
NSInteger maxIterations ;
5151
BOOL runAsync ;
@@ -62,7 +62,7 @@ void CStringToUnicode(
6262
typedef struct SearchInfo SearchInfo ;
6363

6464
void DisposeAndRelease(SearchInfo *searchInfo_p) {
65-
// Memory leak fixed in BookMacster 1.16.5. Without this, it definitely leaks…
65+
// Memory leak fixed in BookMacster 1.17. Without this, it definitely leaks…
6666
FSCloseIterator(searchInfo_p->iterator) ;
6767

6868

@@ -408,7 +408,7 @@ + (BOOL)catalogPathsForName:(NSString*)searchString
408408
// Note: NewIOCompletionUPP() is just a silly macro that typecasts to IOCompletionUPP
409409

410410
SearchInfo* searchInfo_p = (SearchInfo*) NewPtrClear( sizeof(SearchInfo) );
411-
searchInfo_p->iterator = iterator ; // Added in BookMacster 1.16.5
411+
searchInfo_p->iterator = iterator ; // Added in BookMacster 1.17
412412
searchInfo_p->paths = [[NSMutableArray alloc] init] ;
413413
searchParams_p->searchName = (UniChar*) NewPtrClear(MAX_SEARCH_BYTES) ;
414414
// I suppose that if we broke up CStringTo Unicode so that we could get a

SSYDocChildObject.m

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ - (id)initWithDocument:(BkmxDoc*)document_ {
3737
[self setDocument:document_] ;
3838
}
3939

40+
/*SSYDBL*/ NSLog(@"Initted %@", self) ;
4041
return self;
4142
}
4243

SSYDragDestinationTextView.m

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ - (void)awakeFromNib {
1212

1313
// Safely invoke super
1414
[self safelySendSuperSelector:_cmd
15+
prettyFunction:__PRETTY_FUNCTION__
1516
arguments:nil] ;
1617
}
1718

SSYHierarchicalTabViewItem.h

-20
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,4 @@ extern NSString* const constDiscontiguousTabViewHierarchyString ;
2525
*/
2626
- (NSTabViewItem*)selectedLeafmostTabViewItem ;
2727

28-
/*
29-
@brief Returns whether or not the receiver is selected, *and* all of its
30-
ancestor tab view items are selected, which means that the receiver should be
31-
actually visible.
32-
33-
@details Unfortunately, because there is no way for a given view, which
34-
happens to be the 'view' of a tab view item, to access its "parent' tab view
35-
item, we cannot walk the hierarchy upward as we would like. A tab view item
36-
can access its window, though, and a view can access its subviews. So we start
37-
at the receiver's window and walk down.
38-
39-
Because of this walking down, this method will fail if the receiver's greatest
40-
ancestor tab view is directly a subview of the the receiver's window, or if
41-
any of its intermediate ancestor tab views are not directly a subview of the
42-
view of the parent tab view items. If this condition occurs, this method will
43-
return NO and NSLog constDiscontiguousTabViewHierarchyString with the
44-
receiver's identifier appended.
45-
*/
46-
- (BOOL)isDeeplySelected ;
47-
#warning The 'unfortunately' above is not true because -superview returns the tab view (Not the item, but at least it's something)
4828
@end

SSYHierarchicalTabViewItem.m

+27-67
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,23 @@
22

33
NSString* const constDiscontiguousTabViewHierarchyString = @"Discontiguous tab view hierarchy" ;
44

5+
@interface NSView (SSYTabSubviews)
56

6-
@implementation SSYHierarchicalTabViewItem
7+
- (NSTabViewItem*)deeplySelectedTabViewItem ;
78

8-
- (NSTabViewItem*)selectedChild {
9+
@end
10+
11+
@implementation NSView (SSYTabSubviews)
12+
13+
- (NSTabViewItem*)deeplySelectedTabViewItem {
914
NSTabViewItem* selectedChild = nil ;
10-
for (NSTabView* subview in [[self view] subviews]) {
11-
if ([subview isKindOfClass:[NSTabView class]]) {
12-
selectedChild = [subview selectedTabViewItem] ;
13-
// Note that we consider only the *first* subview which is an
14-
// NSTabView. For this method to make sense, this must also be the
15-
// *only* subview which is an NSTabViewItem.
16-
break ;
17-
}
15+
if ([self respondsToSelector:@selector(selectedTabViewItem)]) {
16+
// self is a tab view
17+
selectedChild = [(NSTabView*)self selectedTabViewItem] ;
1818
}
19-
20-
// The following code seems to have been a good guess. That is,
21-
// it seems to work, but I haven't really thought it through.
22-
// The idea is that it can reach down to find a tab view through, I
23-
// think, one level of NSView subview. I need this for the topTabView
24-
// in BookMacster. This "feature" is not explained in the header doc.
25-
if (!selectedChild) {
26-
for (NSView* subview in [[self view] subviews]) {
27-
// NSLog(@"2 Considering subview %@", subview) ;
28-
if ([subview respondsToSelector:@selector(subviews)]) {
29-
for (NSTabView* innerSubview in [subview subviews]) {
30-
// NSLog(@"3 Considering innerSubview %@", innerSubview) ;
31-
if ([innerSubview isKindOfClass:[NSTabView class]]) {
32-
selectedChild = [innerSubview selectedTabViewItem] ;
33-
// Note that we consider only the *first* subview which is an
34-
// NSTabView. For this method to make sense, this must also be the
35-
// *only* subview which is an NSTabViewItem.
36-
break ;
37-
}
38-
}
39-
}
40-
19+
else {
20+
for (NSView* subview in [self subviews]) {
21+
selectedChild = [subview deeplySelectedTabViewItem] ;
4122
if (selectedChild) {
4223
break ;
4324
}
@@ -47,58 +28,37 @@ - (NSTabViewItem*)selectedChild {
4728
return selectedChild ;
4829
}
4930

31+
32+
@end
33+
34+
@implementation SSYHierarchicalTabViewItem
35+
36+
- (NSTabViewItem*)selectedChild {
37+
NSTabViewItem* selectedChild = [[self view] deeplySelectedTabViewItem] ;
38+
39+
return selectedChild ;
40+
}
41+
5042
- (NSTabViewItem*)selectedLeafmostTabViewItem {
5143
NSTabViewItem* leafItem = self ;
5244
NSTabViewItem* selectedChild = nil ;
53-
do {
45+
do {
5446
// This is in case the leaf item in a tree of SSYHierarchicalTabViewItem
5547
// objects is not itself a class descendant of
5648
// SSYHierarchicalTabViewItem. It is also for safety,
5749
// in case someone sends this message to a tab view item
5850
// which is not or does not inherit from this class.
5951
if (![leafItem respondsToSelector:@selector(selectedChild)]) {
60-
break ;
52+
break ;
6153
}
6254

6355
selectedChild = [(SSYHierarchicalTabViewItem*)leafItem selectedChild] ;
64-
if ([selectedChild isKindOfClass:[NSTabViewItem class]]) {
56+
if ([selectedChild isKindOfClass:[NSTabViewItem class]]) {
6557
leafItem = selectedChild ;
6658
}
6759
} while (selectedChild != nil) ;
6860

6961
return leafItem ;
7062
}
7163

72-
- (BOOL)isDeeplySelected {
73-
NSView* view = [[[self view] window] contentView] ;
74-
NSTabViewItem* tabViewItem = nil ;
75-
BOOL answer = NO ;
76-
while (view != nil) {
77-
NSArray* subviews = [view subviews] ;
78-
view = nil ;
79-
for (NSTabView* tabView in subviews) {
80-
// Of course, tabView is not necessarily an NSTabView. Test it…
81-
if ([tabView isKindOfClass:[NSTabView class]]) {
82-
tabViewItem = [tabView selectedTabViewItem] ;
83-
view = [tabViewItem view] ;
84-
break ;
85-
}
86-
}
87-
88-
if (tabViewItem == self) {
89-
answer = YES ;
90-
break ;
91-
}
92-
else if (!tabViewItem) {
93-
NSLog(
94-
@"%@ : %@",
95-
constDiscontiguousTabViewHierarchyString,
96-
[self identifier]) ;
97-
}
98-
}
99-
// NSLog(@"<< %s is returning %hhd for %@", __PRETTY_FUNCTION__, answer, [self identifier]) ;
100-
101-
return answer ;
102-
}
103-
10464
@end

SSYLazyView.h

+49-20
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,74 @@
11
#import <Cocoa/Cocoa.h>
22

3-
@class SSYExtrospectiveViewController ;
3+
/*
4+
@brief Notification which is posted when the payload view loads.
5+
6+
@details The notification object is the window in which the SSYLazyView object
7+
resides. Note that the
8+
loading of the payload, and hence the posting of this notification, occurs no
9+
more than once during the lifetime of an SSYLazyView object.
10+
*/
11+
extern NSString* SSYLazyViewDidLoadPayloadNotification;
12+
13+
/*
14+
@brief A companion to SSYLazyView; provides a method by which a tab view
15+
item whose view is an instance of SSYLazyView can look down and see if their
16+
view has been payloaded
17+
*/
18+
@interface NSTabViewItem (SSYLazyPayload)
19+
20+
/*
21+
@brief If the receiver's view is an instance of SSYLazyView, returns
22+
that view's response to -isPayloaded; otherwise, returns YES
23+
*/
24+
- (BOOL)isViewPayloaded ;
25+
26+
@end
427

528
/*
6-
@details
29+
@brief View which, upon being moved to a window for the first time, or
30+
upon demand (-loadWithOwner:), removes all of its original subviews
31+
("placeholders") and adds a in their place a single "payload" view which it
32+
loads from a designated nib
33+
34+
@details When the receiver loads its nib as a result of being moved to a
35+
window, the window controller of the window to which it was moved is assigned
36+
as the file's owner of the nib.
737
838
In the Xcode xib editor, you may have one or more initial placeholder subviews
939
in your Lazy View. For example, you may place a text field with large
1040
font size that says "Loading Stuff…". All of these placeholder subviews
1141
will be removed when the new view is placed in.
1242
*/
1343
@interface SSYLazyView : NSView {
14-
SSYExtrospectiveViewController* m_viewController ;
15-
BOOL m_isLoaded ;
44+
BOOL m_isPayloaded ;
45+
46+
// Needed in Mac OS X 10.8 or later…
47+
NSArray* m_topLevelObjects ;
1648
}
1749

18-
@property (retain) SSYExtrospectiveViewController* viewController ;
19-
@property (assign) BOOL isLoaded ;
50+
@property (assign) BOOL isPayloaded ;
2051

2152
/*
22-
@brief Returns the view controller class which will be instantiated
23-
when the receiver loads.
24-
25-
@details The default implementation returns NSViewController. Subclasses
26-
override this method to return the desired subclass of NSViewController.
27-
*/
28-
+ (Class)lazyViewControllerClass ;
29-
30-
/*
31-
@brief Returns the name of the nib. without the .nib extension, which will
32-
be loaded and become the one and only subview of the receiver when it loads.
53+
@brief Returns the name of the nib, without the .nib extension, which will
54+
be loaded and whose top-level view object become the one and only subview of
55+
the receiver when the payload view loads.
3356
3457
@details The default implementation returns @"Internal Error 939-7834".
35-
Subclasses should override this method.
58+
You must subclass this class and override this method.
3659
*/
3760
+ (NSString*)lazyNibName ;
3861

3962
/*
4063
@brief Creates the receiver's view controller and loads the receiver's
41-
view, or if these things have not already been done, no op.
64+
view, or if these things have not already been done, no op
65+
66+
@details This method is used to "manually" load the payload, before the
67+
receiver is moved to a window.
68+
69+
@param owner The object which to assign as the File's Owner when the
70+
nib is loaded.
4271
*/
43-
- (void)loadInWindow:(NSWindow*)window ;
72+
- (void)loadWithOwner:(id)owner ;
4473

4574
@end

0 commit comments

Comments
 (0)