[Top][All Lists]

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

nstextfieldcell backgroundcolor do not change as expected

From: reuss
Subject: nstextfieldcell backgroundcolor do not change as expected
Date: Tue, 10 Feb 2004 02:23:38 GMT
User-agent: Pan/0.11.2 (Unix)

I am wondering why all selected cells become white one by one and why the
previous does not become gray thought it should - if I did not make a
mistake.The way they become gray is quite rhapsodic and imprevisible and
ununderstandable for me.
There is a mistake in my code? Where? And what? (ok, it is not too
elegant, but i think it should work).
please help

#include <AppKit/AppKit.h>
#include <Foundation/Foundation.h>

@interface CalViewer : NSControl
id matrix;
id previouscell;
- (id) initWithFrame: (NSRect) aFrame;

#include "CalViewer.h"

@implementation CalViewer
- (id) initWithFrame: (NSRect) aFrame
        self = [super initWithFrame: aFrame]; 
        int i, j, k;
        k = 0;

matrix = [[NSMatrix alloc] initWithFrame: NSMakeRect(0,0,25,25)];
id protocell = [[NSTextFieldCell alloc] init];
[protocell setDrawsBackground: YES];
[protocell setBackgroundColor: [NSColor windowBackgroundColor]];
[protocell setAction: @selector(changeBackground:)];
[protocell setTarget: matrix];
[matrix setPrototype: protocell];
[matrix setIntercellSpacing: NSMakeSize(0,0)];
[matrix insertRow: 3];
[matrix insertColumn: 3];

for (i=0; i< 4; i++)
        for(j=0; j<4; j++)
                if (k == 0)
                        [[matrix cellAtRow: i column: j] setEnabled: NO];
                [[matrix cellAtRow: i column: j] setIntValue: k];
                [[matrix cellAtRow: i column: j] setFont: [NSFont 
boldSystemFontOfSize: 12]];
                [[matrix cellAtRow: i column: j] setAlignment: 
previouscell = [matrix cellAtRow: 0 column: 2];
[previouscell setBackgroundColor: [NSColor whiteColor]];
[matrix sizeToCells];

        [self addSubview: matrix];
        return self;

- (void) changeBackground: (id) sender
        [previouscell setBackgroundColor: [NSColor windowBackgroundColor]];
        [[matrix selectedCell]  setBackgroundColor: [NSColor whiteColor]];
        previouscell = [matrix selectedCell];


reply via email to

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