NSBrowser background color

  • Hi,

    I'm trying to get my NSBrowser subclass to draw with a grey background
    instead of the default white background.  From what I understand, I
    need to set the background color of the browser's NSScrollView but the
    API doesn't seem to give me access to that object.  Can anyone help me
    with this?

    Thanks so much,
    Cathy
  • On Sep 12, 2007, at 1:15 PM, Cathy Shive wrote:

    > Hi,
    >
    > I'm trying to get my NSBrowser subclass to draw with a grey background
    > instead of the default white background.  From what I understand, I
    > need to set the background color of the browser's NSScrollView but the
    > API doesn't seem to give me access to that object.  Can anyone help me
    > with this?

    NSBrowser is a subclass of NSView and NSView defines the method:

    - (NSScrollView *)enclosingScrollView;

    Does that help?

    Scott
  • Duh yes, thank you :)

    On 9/12/07, Scott Thompson <easco...> wrote:
    >
    >
    >
    > On Sep 12, 2007, at 1:15 PM, Cathy Shive wrote:
    > Hi,
    >
    > I'm trying to get my NSBrowser subclass to draw with a grey background
    > instead of the default white background.  From what I understand, I
    > need to set the background color of the browser's NSScrollView but the
    > API doesn't seem to give me access to that object.  Can anyone help me
    > with this?
    >
    > NSBrowser is a subclass of NSView and NSView defines the method:
    >
    >
    > - (NSScrollView *)enclosingScrollView;
    >
    > Does that help?
    >
    > Scott
    >
    >
  • Actually, that method is returning nothing!

    // I'm making the browser:
    mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];

    // configuring it
    [mFileBrowser setMaxVisibleColumns:4];
    [mFileBrowser setHasHorizontalScroller:YES];
    [mFileBrowser setDelegate:self];

    // and asking for the scroll view
    NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];

    and after that -  aScrollView is 0x0

    Is there anything obvious that I'm doing wrong here?

    On 9/12/07, Cathy Shive <catshive...> wrote:
    > Duh yes, thank you :)
    >
    > On 9/12/07, Scott Thompson <easco...> wrote:
    >>
    >>
    >>
    >> On Sep 12, 2007, at 1:15 PM, Cathy Shive wrote:
    >> Hi,
    >>
    >> I'm trying to get my NSBrowser subclass to draw with a grey background
    >> instead of the default white background.  From what I understand, I
    >> need to set the background color of the browser's NSScrollView but the
    >> API doesn't seem to give me access to that object.  Can anyone help me
    >> with this?
    >>
    >> NSBrowser is a subclass of NSView and NSView defines the method:
    >>
    >>
    >> - (NSScrollView *)enclosingScrollView;
    >>
    >> Does that help?
    >>
    >> Scott
    >>
    >>
    >
  • On Sep 12, 2007, at 2:35 PM, Cathy Shive wrote:

    > Actually, that method is returning nothing!
    >
    > // I'm making the browser:
    > mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];
    >
    > // configuring it
    > [mFileBrowser setMaxVisibleColumns:4];
    > [mFileBrowser setHasHorizontalScroller:YES];
    > [mFileBrowser setDelegate:self];
    >
    > // and asking for the scroll view
    > NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];
    >
    > and after that -  aScrollView is 0x0
    >
    > Is there anything obvious that I'm doing wrong here?

    Hmm... it doesn't look like the browser is contained within a scroll
    view.  Rather the file browser itself contains it's own scrolling
    mechanism. I note, for example, that the NSBrowser class has a private
    member "NSScroller".

    I suspect that in this case you are going to have to go through some
    other means to change the background color of the browser (if it's
    even possible to do so).

    Scott
  • On 9/12/07, Cathy Shive <catshive...> wrote:
    > Actually, that method is returning nothing!
    >
    > // I'm making the browser:
    > mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];
    >
    > // configuring it
    > [mFileBrowser setMaxVisibleColumns:4];
    > [mFileBrowser setHasHorizontalScroller:YES];
    > [mFileBrowser setDelegate:self];
    >
    > // and asking for the scroll view
    > NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];
    >
    > and after that -  aScrollView is 0x0
    >
    > Is there anything obvious that I'm doing wrong here?

    NSBrowser doesn't live inside of an NSScrollView so what was suggested
    wasn't correct (unless you put it inside of one of course).

    Anyway I have never tried to do what you are attempting so I cannot be
    of any "further help".

    -Shawn
  • Hi Cathy,

    I didn't think the NSBrowser was itself inside a scrollview.

    IIRC to customize NSBrowser appearance you have to mess with the
    NSMatrix instances in its columns.  I did a quick search on
    CocoaBuilder and only looked at the first couple of results, which
    looked like dead ends.

    NSBrowser has a -matrixInColumn: method which might be useful, though
    I'm not sure how.  Or maybe you could implement the -
    browser:createRowsForColumn:inMatrix: delegate method and tweak the
    NSMatrix there.

    --Andy

    On Sep 12, 2007, at 3:35 PM, Cathy Shive wrote:

    > Actually, that method is returning nothing!
    >
    > // I'm making the browser:
    > mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];
    >
    > // configuring it
    > [mFileBrowser setMaxVisibleColumns:4];
    > [mFileBrowser setHasHorizontalScroller:YES];
    > [mFileBrowser setDelegate:self];
    >
    > // and asking for the scroll view
    > NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];
    >
    > and after that -  aScrollView is 0x0
    >
    > Is there anything obvious that I'm doing wrong here?
    >
    > On 9/12/07, Cathy Shive <catshive...> wrote:
    >> Duh yes, thank you :)
    >>
    >> On 9/12/07, Scott Thompson <easco...> wrote:
    >>>
    >>>
    >>>
    >>> On Sep 12, 2007, at 1:15 PM, Cathy Shive wrote:
    >>> Hi,
    >>>
    >>> I'm trying to get my NSBrowser subclass to draw with a grey
    >>> background
    >>> instead of the default white background.  From what I understand, I
    >>> need to set the background color of the browser's NSScrollView
    >>> but the
    >>> API doesn't seem to give me access to that object.  Can anyone
    >>> help me
    >>> with this?
    >>>
    >>> NSBrowser is a subclass of NSView and NSView defines the method:
    >>>
    >>>
    >>> - (NSScrollView *)enclosingScrollView;
    >>>
    >>> Does that help?
    >>>
    >>> Scott
    >>>
    >>>
    >>

  • HI Andy,

    Yes, I tried to mess with the delegate method to get to the matrix
    objects but it didn't do anything.  From what I can understand, the
    matrix is sized according the content it's displaying - in my case
    nothing - so it has no height yet.  I could be totally wrong, though.
    I'm going to keep poking around.

    Thanks!

    Cathy

    On 9/12/07, Andy Lee <aglee...> wrote:
    > Hi Cathy,
    >
    > I didn't think the NSBrowser was itself inside a scrollview.
    >
    > IIRC to customize NSBrowser appearance you have to mess with the
    > NSMatrix instances in its columns.  I did a quick search on
    > CocoaBuilder and only looked at the first couple of results, which
    > looked like dead ends.
    >
    > NSBrowser has a -matrixInColumn: method which might be useful, though
    > I'm not sure how.  Or maybe you could implement the -
    > browser:createRowsForColumn:inMatrix: delegate method and tweak the
    > NSMatrix there.
    >
    > --Andy
    >
    > On Sep 12, 2007, at 3:35 PM, Cathy Shive wrote:
    >
    >> Actually, that method is returning nothing!
    >>
    >> // I'm making the browser:
    >> mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];
    >>
    >> // configuring it
    >> [mFileBrowser setMaxVisibleColumns:4];
    >> [mFileBrowser setHasHorizontalScroller:YES];
    >> [mFileBrowser setDelegate:self];
    >>
    >> // and asking for the scroll view
    >> NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];
    >>
    >> and after that -  aScrollView is 0x0
    >>
    >> Is there anything obvious that I'm doing wrong here?
    >>
    >> On 9/12/07, Cathy Shive <catshive...> wrote:
    >>> Duh yes, thank you :)
    >>>
    >>> On 9/12/07, Scott Thompson <easco...> wrote:
    >>>>
    >>>>
    >>>>
    >>>> On Sep 12, 2007, at 1:15 PM, Cathy Shive wrote:
    >>>> Hi,
    >>>>
    >>>> I'm trying to get my NSBrowser subclass to draw with a grey
    >>>> background
    >>>> instead of the default white background.  From what I understand, I
    >>>> need to set the background color of the browser's NSScrollView
    >>>> but the
    >>>> API doesn't seem to give me access to that object.  Can anyone
    >>>> help me
    >>>> with this?
    >>>>
    >>>> NSBrowser is a subclass of NSView and NSView defines the method:
    >>>>
    >>>>
    >>>> - (NSScrollView *)enclosingScrollView;
    >>>>
    >>>> Does that help?
    >>>>
    >>>> Scott
    >>>>
    >>>>
    >>>

    >
    >
  • Thanks!  I'm having a difficult time getting my head around this class.

    So, right now I'm confused because this:
    [mFileBrowser setHasHorizontalScroller:YES];

    results in a horizontal scroller being displayed under the browser,
    which makes me feel like NSBrowser is already living inside of an
    NSScrollView.

    If it isn't, does anyone know what I should be doing to change the
    background color of the browser?  I'm not displaying any data yet, so
    I'm not looking into the NSMatrix class or NSBrowserCell.

    On 9/12/07, Shawn Erickson <shawnce...> wrote:
    > On 9/12/07, Cathy Shive <catshive...> wrote:
    >> Actually, that method is returning nothing!
    >>
    >> // I'm making the browser:
    >> mFileBrowser = [[BWBrowser alloc] initWithFrame:aFrame];
    >>
    >> // configuring it
    >> [mFileBrowser setMaxVisibleColumns:4];
    >> [mFileBrowser setHasHorizontalScroller:YES];
    >> [mFileBrowser setDelegate:self];
    >>
    >> // and asking for the scroll view
    >> NSScrollView * aScrollView = [mFileBrowser enclosingScrollView];
    >>
    >> and after that -  aScrollView is 0x0
    >>
    >> Is there anything obvious that I'm doing wrong here?
    >
    > NSBrowser doesn't live inside of an NSScrollView so what was suggested
    > wasn't correct (unless you put it inside of one of course).
    >
    > Anyway I have never tried to do what you are attempting so I cannot be
    > of any "further help".
    >
    > -Shawn
    >
  • It's tricky.

    My version of "Docoa Browser" colors the background of its browsers,
    but I'm afraid that the method I used requires code scattered all
    over the place (i.e. I couldn't find a nice simple solution to get
    the result I was after).

    Source at <http://www.muratnkonar.com/docoafortiger/Docoa-0.3.4mnk.zip>

    _murat

    On Sep 12, 2007, at 11:15 AM, Cathy Shive wrote:

    > Hi,
    >
    > I'm trying to get my NSBrowser subclass to draw with a grey background
    > instead of the default white background.  From what I understand, I
    > need to set the background color of the browser's NSScrollView but the
    > API doesn't seem to give me access to that object.  Can anyone help me
    > with this?
    >
    > Thanks so much,
    > Cathy
    >
  • On Sep 12, 2007, at 4:11 PM, Cathy Shive wrote:
    > HI Andy,
    >
    > Yes, I tried to mess with the delegate method to get to the matrix
    > objects but it didn't do anything.  From what I can understand, the
    > matrix is sized according the content it's displaying - in my case
    > nothing - so it has no height yet.

    Hm.  Well, for what it's worth, here's the internal view hierarchy of
    an NSBrowser.  The closest-looking thing to an NSScrollView is a
    private class called _NSBrowserScrollView.  Maybe you can do
    something with the NSClipView.

    2007-09-12 16:45:36.847 Scratch[9322]  NSBrowser
    2007-09-12 16:45:36.847 Scratch[9322]    _NSBrowserScrollView
    2007-09-12 16:45:36.847 Scratch[9322]      NSClipView
    2007-09-12 16:45:36.847 Scratch[9322]
    _NSBrowserColumnsContainerView
    2007-09-12 16:45:36.847 Scratch[9322]          _NSBrowserColumnView
    2007-09-12 16:45:36.847 Scratch[9322]            NSClipView
    2007-09-12 16:45:36.847 Scratch[9322]              NSMatrix
    2007-09-12 16:45:36.847 Scratch[9322]            NSScroller
    2007-09-12 16:45:36.847 Scratch[9322]      NSScroller
    2007-09-12 16:45:36.847 Scratch[9322]    NSClipView
    2007-09-12 16:45:36.847 Scratch[9322]
    _NSBrowserTitlesContainerView

    I printed this with a quick-and-dirty method I wrote just now:

    + (void)printViewHierarchy:(NSView *)view withIndent:(NSString *)indent
    {
    NSLog(@"%@%@", indent, [view className]);

    NSArray *subviews = [view subviews];
    int i;
    for (i = 0; i < [subviews count]; i++) {
      [self printViewHierarchy:[subviews objectAtIndex:i]
      withIndent:[indent stringByAppendingString:@"  "]];
    }
    }

    + (void)printViewHierarchy:(NSView *)view
    {
    [self printViewHierarchy:view withIndent:@"  "];
    }
  • Yes I see, very tricky.  Thanks so much for the example, it's very helpful.

    Cathy

    On 9/12/07, Murat Konar <murat...> wrote:
    > It's tricky.
    >
    > My version of "Docoa Browser" colors the background of its browsers,
    > but I'm afraid that the method I used requires code scattered all
    > over the place (i.e. I couldn't find a nice simple solution to get
    > the result I was after).
    >
    > Source at <http://www.muratnkonar.com/docoafortiger/Docoa-0.3.4mnk.zip>
    >
    > _murat
    >
    >
    > On Sep 12, 2007, at 11:15 AM, Cathy Shive wrote:
    >
    >> Hi,
    >>
    >> I'm trying to get my NSBrowser subclass to draw with a grey background
    >> instead of the default white background.  From what I understand, I
    >> need to set the background color of the browser's NSScrollView but the
    >> API doesn't seem to give me access to that object.  Can anyone help me
    >> with this?
    >>
    >> Thanks so much,
    >> Cathy
    >>
    >
  • Thanks Andy!  This is a very useful trick!

    Check out Murat's example, too.  Amazing what it took to set the
    background color.  hahah.  :)

    Cathy

    On 9/12/07, Andy Lee <aglee...> wrote:
    > On Sep 12, 2007, at 4:11 PM, Cathy Shive wrote:
    >> HI Andy,
    >>
    >> Yes, I tried to mess with the delegate method to get to the matrix
    >> objects but it didn't do anything.  From what I can understand, the
    >> matrix is sized according the content it's displaying - in my case
    >> nothing - so it has no height yet.
    >
    > Hm.  Well, for what it's worth, here's the internal view hierarchy of
    > an NSBrowser.  The closest-looking thing to an NSScrollView is a
    > private class called _NSBrowserScrollView.  Maybe you can do
    > something with the NSClipView.
    >
    >
    > 2007-09-12 16:45:36.847 Scratch[9322]  NSBrowser
    > 2007-09-12 16:45:36.847 Scratch[9322]    _NSBrowserScrollView
    > 2007-09-12 16:45:36.847 Scratch[9322]      NSClipView
    > 2007-09-12 16:45:36.847 Scratch[9322]
    > _NSBrowserColumnsContainerView
    > 2007-09-12 16:45:36.847 Scratch[9322]          _NSBrowserColumnView
    > 2007-09-12 16:45:36.847 Scratch[9322]            NSClipView
    > 2007-09-12 16:45:36.847 Scratch[9322]              NSMatrix
    > 2007-09-12 16:45:36.847 Scratch[9322]            NSScroller
    > 2007-09-12 16:45:36.847 Scratch[9322]      NSScroller
    > 2007-09-12 16:45:36.847 Scratch[9322]    NSClipView
    > 2007-09-12 16:45:36.847 Scratch[9322]
    > _NSBrowserTitlesContainerView
    >
    >
    > I printed this with a quick-and-dirty method I wrote just now:
    >
    >
    > + (void)printViewHierarchy:(NSView *)view withIndent:(NSString *)indent
    > {
    > NSLog(@"%@%@", indent, [view className]);
    >
    > NSArray *subviews = [view subviews];
    > int i;
    > for (i = 0; i < [subviews count]; i++) {
    > [self printViewHierarchy:[subviews objectAtIndex:i]
    > withIndent:[indent stringByAppendingString:@"  "]];
    > }
    > }
    >
    > + (void)printViewHierarchy:(NSView *)view
    > {
    > [self printViewHierarchy:view withIndent:@"  "];
    > }
    >
    >
  • Even easier than instrumenting your code is using F-Script.

    <http://www.fscript.org/documentation/ExploringCocoaWithFScript/
    index.htm
    >

    _murat

    On Sep 12, 2007, at 1:50 PM, Andy Lee wrote:
    > Hm.  Well, for what it's worth, here's the internal view hierarchy
    > of an NSBrowser.  The closest-looking thing to an NSScrollView is a
    > private class called _NSBrowserScrollView.  Maybe you can do
    > something with the NSClipView.

    [snip]

    > I printed this with a quick-and-dirty method I wrote just now:
    >
    >
    > + (void)printViewHierarchy:(NSView *)view withIndent:(NSString *)
    > indent
    > {
    > NSLog(@"%@%@", indent, [view className]);
    >
    > NSArray *subviews = [view subviews];
    > int i;
    > for (i = 0; i < [subviews count]; i++) {
    > [self printViewHierarchy:[subviews objectAtIndex:i]
    > withIndent:[indent stringByAppendingString:@"  "]];
    > }
    > }
    >
    > + (void)printViewHierarchy:(NSView *)view
    > {
    > [self printViewHierarchy:view withIndent:@"  "];
    > }
  • I had this MacTech open in my browser for weeks until I lost it in a
    browser crash:

    <http://www.mactech.com/articles/mactech/Vol.23/23.05/
    LearnFScript20Min/index.html
    >
    "Learn F-Script in 20 Minutes
    And have fun playing with Core Image"

    I keep meaning to actually, you know, read it.

    (On a tangential note, I find it annoying that there's no date on the
    article, only a volume number and issue number.  What magazine
    doesn't put a publication date on their articles?)

    --Andy

    On Sep 12, 2007, at 11:38 PM, m wrote:

    > Even easier than instrumenting your code is using F-Script.
    >
    > <http://www.fscript.org/documentation/ExploringCocoaWithFScript/
    > index.htm>
    >
    > _murat
    >
    > On Sep 12, 2007, at 1:50 PM, Andy Lee wrote:
    >> Hm.  Well, for what it's worth, here's the internal view hierarchy
    >> of an NSBrowser.  The closest-looking thing to an NSScrollView is
    >> a private class called _NSBrowserScrollView.  Maybe you can do
    >> something with the NSClipView.
    >
    > [snip]
    >
    >> I printed this with a quick-and-dirty method I wrote just now:
    >>
    >>
    >> + (void)printViewHierarchy:(NSView *)view withIndent:(NSString *)
    >> indent
    >> {
    >> NSLog(@"%@%@", indent, [view className]);
    >>
    >> NSArray *subviews = [view subviews];
    >> int i;
    >> for (i = 0; i < [subviews count]; i++) {
    >> [self printViewHierarchy:[subviews objectAtIndex:i]
    >> withIndent:[indent stringByAppendingString:@"  "]];
    >> }
    >> }
    >>
    >> + (void)printViewHierarchy:(NSView *)view
    >> {
    >> [self printViewHierarchy:view withIndent:@"  "];
    >> }
    >
    >
    >
    >
  • ah yeah, i remember seeing f-script a while back.  i'll definitely
    play around with it now.  the object browser is really cool.

    -c

    On 9/12/07, Andy Lee <aglee...> wrote:
    > I had this MacTech open in my browser for weeks until I lost it in a
    > browser crash:
    >
    > <http://www.mactech.com/articles/mactech/Vol.23/23.05/
    > LearnFScript20Min/index.html>
    > "Learn F-Script in 20 Minutes
    > And have fun playing with Core Image"
    >
    > I keep meaning to actually, you know, read it.
    >
    > (On a tangential note, I find it annoying that there's no date on the
    > article, only a volume number and issue number.  What magazine
    > doesn't put a publication date on their articles?)
    >
    > --Andy
    >
    >
    > On Sep 12, 2007, at 11:38 PM, m wrote:
    >
    >> Even easier than instrumenting your code is using F-Script.
    >>
    >> <http://www.fscript.org/documentation/ExploringCocoaWithFScript/
    > > index.htm>
    >>
    >> _murat
    >>
    >> On Sep 12, 2007, at 1:50 PM, Andy Lee wrote:
    >>> Hm.  Well, for what it's worth, here's the internal view hierarchy
    >>> of an NSBrowser.  The closest-looking thing to an NSScrollView is
    >>> a private class called _NSBrowserScrollView.  Maybe you can do
    >>> something with the NSClipView.
    >>
    >> [snip]
    >>
    >>> I printed this with a quick-and-dirty method I wrote just now:
    >>>
    >>>
    >>> + (void)printViewHierarchy:(NSView *)view withIndent:(NSString *)
    >>> indent
    >>> {
    >>> NSLog(@"%@%@", indent, [view className]);
    >>>
    >>> NSArray *subviews = [view subviews];
    >>> int i;
    >>> for (i = 0; i < [subviews count]; i++) {
    >>> [self printViewHierarchy:[subviews objectAtIndex:i]
    >>> withIndent:[indent stringByAppendingString:@"  "]];
    >>> }
    >>> }
    >>>
    >>> + (void)printViewHierarchy:(NSView *)view
    >>> {
    >>> [self printViewHierarchy:view withIndent:@"  "];
    >>> }
    >>
    >>
    >>
    >>
    >
    >
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today