discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: some help with NSBrowser needed


From: Fred Kiefer
Subject: Re: some help with NSBrowser needed
Date: Tue, 01 Jan 2013 22:59:45 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

I think the problematic line is this one:

    browser = [[NSBrowser alloc] init];

You create a browser with a zero size frame. (The -init method of NSView calls -initWithFrame: with NSZeroRect) When the browser later tries to draw its various parts, some of these may end up with negative sizes. you could set a breakpoint on NSView.m:1182 to find out which parts are affected.

If your code works on Cocoa, but not on GNUstep, we might have to change the default rectangle for NSBrowser.

Hope this helps,
Fred


On 01.01.2013 18:17, Sebastian Reitenbach wrote:
for MPDCon, i want to have a filesystem like browser to browse through the music
directories. The Interface is created in Gorm, and in my class, I implemented 
the
"passive" NSBrowser delegate methods:

- (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column;
- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell 
atRow:(NSInteger)row column:(NSInteger)column;

My class is a subclass of NSWindowController, and is just a NSWindow, with
a NSBrowser in it, and one IBOutlet NSBrowser *browser.

I can see that both delegate methods get called from within awakeFromNib. There 
at the end I have:

   browser = [[NSBrowser alloc] init];
   [browser setDelegate:self];
   [browser setPath:@"/"];
}

the setPath: actually triggers calling the delegate methods. I have some NSLogs 
in them, to see if
they get called:

2013-01-01 17:56:10.400 MPDCon[2484] here in numberOfRowsInColumn 0
2013-01-01 17:56:10.400 MPDCon[2484] returning count: 5
2013-01-01 17:56:10.760 MPDCon[2484] here in willDisplayCell <NSBrowserCell: 
0x80c95704> 0 0, adding: /reggae
2013-01-01 17:56:11.031 MPDCon[2484] here in willDisplayCell <NSBrowserCell: 
0x80c95584> 1 0, adding: /techno
2013-01-01 17:56:11.287 MPDCon[2484] here in willDisplayCell <NSBrowserCell: 
0x80c95044> 2 0, adding: /ska
2013-01-01 17:56:11.539 MPDCon[2484] here in willDisplayCell <NSBrowserCell: 
0x80c955c4> 3 0, adding: /folk
2013-01-01 17:56:11.786 MPDCon[2484] here in willDisplayCell <NSBrowserCell: 
0x80c95144> 4 0, adding: /other
2013-01-01 17:56:11.787 MPDCon[2484] File NSView.m: 1182. In -[NSView 
setFrame:] given negative width

The delegate methods, as I have them for now, can be seen below.
It's my first time dealing with NSBrowser, so I hope its just something easy 
that I have overlooked while
trying to figure out what's (not) going on.
I also wonder about the last line of the output from NSView, what this could be 
about?
I'm on OpenBSD i386.

cheers,
Sebastian


- (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:(NSInteger)column
{
NSLog(@"here in numberOfRowsInColumn %d", column);
   NSInteger count, blubb=0;
   NSEnumerator *dirEnum;
   NSString *dir;
   NSMutableArray *tmpArray = [NSMutableArray array];

   dirEnum = [directories objectEnumerator];

   while ((dir = [dirEnum nextObject]) != nil && blubb < 5)
     {
       if ([[dir pathComponents] count] >= column)
         {
           dir = [[dir pathComponents] objectAtIndex:column];
           if (![tmpArray containsObject:dir])
             {
               [tmpArray addObject:dir];
               blubb++;
             }
         }
     }
   count = [tmpArray count];
   [tmpArray release];
NSLog(@"returning count: %d", count);
   return count;
}

- (void)browser:(NSBrowser *)sender willDisplayCell:(id)cell 
atRow:(NSInteger)row column:(NSInteger)column
{
   NSEnumerator *dirEnum;
   NSString *dir;
   NSMutableArray *tmpArray = [NSMutableArray array];

   dirEnum = [directories objectEnumerator];

   while ((dir = [dirEnum nextObject]) != nil)
     {
       if ([[dir pathComponents] count] >= column)
         {
           dir = [[dir pathComponents] objectAtIndex:column];
           if (![tmpArray containsObject:dir])
             {
               //[tmpArray addObject:dir];
               [tmpArray addObject:[NSString stringWithFormat:@"/%@", dir]];
             }
         }
     }
NSLog(@"here in willDisplayCell %@ %d %d, adding: %@", cell, row, column, 
[tmpArray objectAtIndex:row]);
   [cell setStringValue:[tmpArray objectAtIndex:row]];
   [cell setTitle:[tmpArray objectAtIndex:row]];
   [cell setLoaded: YES];
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]