help-gnustep
[Top][All Lists]
Advanced

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

Re: nstextfieldcell backgroundcolor do not change as expected


From: Adam Fedor
Subject: Re: nstextfieldcell backgroundcolor do not change as expected
Date: Tue, 10 Feb 2004 14:51:11 -0700

Try asking on discuss-gnustep@gnu.org


On Tuesday, February 10, 2004, at 01:58 PM, reuss wrote:

No one could help me?

On Tue, 10 Feb 2004 03:23:38 +0100, reuss wrote:

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 andras















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

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


#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];
                else
                {
                [[matrix cellAtRow: i column: j] setIntValue: k];
                [[matrix cellAtRow: i column: j] setFont: [NSFont
                boldSystemFontOfSize: 12]]; [[matrix cellAtRow: i column: j]
                setAlignment: NSCenterTextAlignment]; }
                k++;
                }
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];
}

@end
_______________________________________________
Help-gnustep mailing list
Help-gnustep@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnustep





reply via email to

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