Version 1.0, Copyright ©1995, 1996 by Paul S. McCarthy and Eric Sunshine. All Rights Reserved.
Paul S. McCarthy and Eric Sunshine -- January 12, 1996
MiscTableCell |
Inherits From: | Cell | |
Declared In: | MiscTableCell.h |
Class Description |
- (unsigned int) tc1HighlightBackgroundColorPos
{
unsigned int pos = [self tc1HighlightTextColorPos];
if (tc1_flags & MISC_TC1_SELF_TEXT_COLOR_H)
pos += [self tc1HighlightTextColorLen];
return pos;
}
Since the highlighted background color is stored following the highlighted text color it first determines the location of the highlighted text color then adds the length of the highlighted text color to that address if the highlighted text color is in fact being stored locally. The actual shifting of the dynamic memory is done in the -setUseOwner... methods. For instance: |
- setUseOwnerHighlightBackgroundColor: (BOOL) flag
{
if ([self useOwnerHighlightBackgroundColor] != flag)
{
unsigned int const pos = [self tc1HighlightBackgroundColorPos];
unsigned int const len = [self tc1HighlightBackgroundColorLen];
if (flag)
{
[self tc1DeleteDataPos:pos len:len];
tc1_flags &= ~(MISC_TC1_SELF_BACKGROUND_COLOR_H);
}
else // (!flag)
{
NXColor color = [[self class] defaultHighlightBackgroundColor];
[self tc1InsertData:&color pos:pos len:len];
tc1_flags |= MISC_TC1_SELF_BACKGROUND_COLOR_H;
}
}
return self;
}
Finally, the -setHighlightBackgroundColor: method makes room for the data and then stores it: |
- setHighlightBackgroundColor: (NXColor) c
{
NXColor* p;
[self setUseOwnerHighlightBackgroundColor:NO];
p = [self tc1HighlightBackgroundColorPtr];
*p = c;
return self;
}
A subclass adding more data to the end of tc1_data would provide similar methods. Its counterpart to -tc1HighlightBackgroundColorPos would first call -tc1HighlightBackgroundColorPos to determine its address and then add the correct offset returned by -tc1HighlightBackgroundColorLen as appropriate. |
Instance Variables |
id owner; int tag; unsigned tc1_flags; void* tc1_data; |
Method Types |
Class Methods |
defaultBackgroundColor |
+ (NXColor)defaultBackgroundColor |
+ defaultFont |
+ (NXColor)defaultHighlightBackgroundColor |
+ (NXColor)defaultHighlightTextColor |
+ (NXColor)defaultTextColor |
Instance Methods |
backgroundColor |
- (NXColor)backgroundColor |
- (float)backgroundGray |
- (NXColor)bgColor |
- calcCellSize:(NXSize*)theSize |
inRect:(NXRect const*)aRect |
Returns self, and by reference in theSize the minimum width and height required for displaying the cell in aRect.
See also: - calcCellSize:inRect: (Cell)
|
- copyFromZone: |
- drawInside:(NXRect const*)cellFrame |
inView: controlView |
- drawSelf:(NXRect const*)cellFrame |
inView: controlView |
- (NXColor)fgColor |
- font |
Returns the Font used to display text in the cell. Returns nil if the receiver isn't a text cell.
See also:
|
- free |
Frees the memory used by the cell and returns nil.
See also:
|
- (NXColor)highlightBackgroundColor |
- (float)highlightBackgroundGray |
- (NXColor)highlightTextColor |
- (float)highlightTextGray |
- image |
Returns a pointer to an NXImage object if the cell is an icon cell, otherwise returns 0.
See also: - icon (Cell),
|
- initIconCell:(char const*)s |
Prepare a newly allocated cell that will display an icon. S is the name of the image.
See also:
|
- initTextCell:(char const*)s |
Prepare a newly allocated cell that will display text. The font and colors will use inherited or default values until
explicitly set.
See also:
|
- owner |
Returns the owner of the cell, or 0 if there is none.
See also:
|
- read:(NXTypedStream*)stream |
Unarchives a cell from stream, that was archived with -write:.
See also: -write:
|
- setBackgroundColor:(NXColor)c |
Sets the color that the cell will use to fill its background. This color will override any inherited value.
See also:
|
- setBackgroundGray:(float)value |
The gray value is converted to a color value which is passed to -setBackgroundColor:.
See also:
|
- setFont:font |
Sets the font of a text cell to font. This will override any inherited value.
See also:
|
- setHighlightBackgroundColor:(NXColor)c |
Sets the color that will be used to fill the background of a text cell when the cell is highlighted. This will override any
inherited value.
See also:
|
- setHighlightBackgroundGray:(float)value |
The gray value is converted to a color value which is passed to -setHighlightBackgroundColor:.
See also:
|
- setHighlightTextColor:(NXColor)c |
Sets the color that will be used to draw the text of a text cell. This will override any inherited value.
See also:
|
- setHighlightTextGray:(float)value |
The gray value is converted to a color value which is passed to -setHighlightTextColor:.
See also:
|
- setImage: image |
Sets the image that will be displayed in an icon cell.
See also: - icon (Cell),
|
- setOwner:obj |
Sets the owner of the cell to obj. The cell will inherit font and color values from obj.
See also:
|
- setOwnerBackgroundColor:(NXColor)c |
Informs the cell that the owner's backgroundColor value has changed to c. The current implementation does nothing,
since inherited owner values are not stored in the cells. However, the MiscTableScroll class tests for, and sends this
message in preference to the -setBackgroundColor: message when the table distributes colors to the cells, so that
cells can distinguish between cell-specific color assignments and global color assignments.
See also:
|
- setOwnerFont:font |
Informs the cell that the owner's font value has changed to font. If the cell is using the font value inherited from its
owner, it will change its font in response to this message. Otherwise, it will ignore the message. The MiscTableScroll
class tests for, and sends this message in preference to the -setFont: message when the table distributes fonts to the
cells, so that cells can distinguish between cell-specific font assignments and global font assignments.
See also:
|
- setOwnerHighlightBackgroundColor:(NXColor)c |
Informs the cell that the owner's highlightBackgroundColor value has changed to c. The current implementation
does nothing, since inherited owner values are not stored in the cells. However, the MiscTableScroll class tests for,
and sends this message in preference to the -setHighlightBackgroundColor: message when the table distributes
colors to the cells, so that cells can distinguish between cell-specific color assignments and global color assignments.
See also:
|
- setOwnerHighlightTextColor:(NXColor)c |
Informs the cell that the owner's highlightTextColor value has changed to c. The current implementation does
nothing, since inherited owner values are not stored in the cells. However, the MiscTableScroll class tests for, and
sends this message in preference to the -setHighlightTextColor: message when the table distributes colors to the
cells, so that cells can distinguish between cell-specific color assignments and global color assignments.
See also:
|
- setOwnerTextColor:(NXColor)c |
Informs the cell that the owner's textColor value has changed to c. The current implementation does nothing, since
inherited owner values are not stored in the cells. However, the MiscTableScroll class tests for, and sends this
message in preference to the -setTextColor: message when the table distributes colors to the cells, so that cells can
distinguish between cell-specific color assignments and global color assignments.
See also:
|
- setTag:(int)x |
Sets the cell's tag value to x.
See also: - tag
|
- setTextColor:(NXColor)c |
Causes the cell to render its text with the color, c. This overrides any textColor value inherited from the owner.
See also:
|
- setTextGray:(float)value |
Value is converted to a color value which is passed to -setTextColor:
See also:
|
- setUseOwnerBackgroundColor:(BOOL)flag |
If flag is YES, the cell will discard any backgroundColor value that it is currently storing, and begin using the
backgroundColor value provided by the owner. If the owner has not been set, or the owner does not respond to the
-backgroundColor message, then the value returned by +defaultBackgroundColor will be used. If flag is NO, the
cell will make room to store a backgroundColor value, and initialize it to the value returned by the
+defaultBackgroundColor method.
See also:
|
- setUseOwnerFont:(BOOL)flag |
If flag is YES, the cell will use the font value inherited from its owner. If flag is NO, the cell will continue using its
current font, or fonts set via the -setFont message rather than the font inherited from the owner. This method also
updates the MISC_TC1_SELF_FONT bit of the tc1_flags bit mask.
See also:
|
- setUseOwnerHighlightBackgroundColor:(BOOL)flag |
If flag is YES, the cell will discard any highlightBackgroundColor value that it is currently storing, and begin using
the highlightBackgroundColor value provided by the owner. If the owner has not been set, or the owner does not
respond to the -highlightBackgroundColor message, then the value returned by +defaultHighlightBackgroundColor
will be used. If flag is NO, the cell will make room to store a highlightBackgroundColor value, and initialize it to the
value returned by the +defaultHighlightBackgroundColor method.
See also:
|
- setUseOwnerHighlightTextColor:(BOOL)flag |
If flag is YES, the cell will discard any highlightTextColor value that it is currently storing, and begin using the
highlightColor value provided by the owner. If the owner has not been set, or the owner does not respond to the
-highlightTextColor message, then the value returned by +defaultHighlightTextColor will be used. If flag is NO,
the cell will make room to store a highlightTextColor value, and initialize it to the value returned by the
+defaultHighlightTextColor method.
See also:
|
- setUseOwnerTextColor:(BOOL)flag |
If flag is YES, the cell will discard any textColor value that it is currently storing, and begin using the textColor value
provided by the owner. If the owner has not been set, or the owner does not respond to the -textColor message, then
the value returned by +defaultTextColor will be used. If flag is NO, the cell will make room to store a textColor
value, and initialize it to the value returned by the +defaultTextColor method.
See also:
|
- (int)tag |
Returns the cell's tag value.
|
- (unsigned int)tc1BackgroundColorLen |
Returns the length of the backgroundColor value in the variable-length tc1_data field. This is currently
sizeof(NXColor).
See also:
|
- (unsigned int)tc1BackgroundColorPos |
Returns the current offset of the backgroundColor value in the variable-length tc1_data field. This value changes
whenever preceeding values are added or removed.
See also:
|
- (NXColor*)tc1BackgroundColorPtr |
Returns a pointer to the backgroundColor value in the variable-length tc1_data field. The value returned is only valid
if -useOwnerBackgroundColor returns NO.
See also:
|
- (unsigned int)tc1DataSize |
Returns the current total size of the variable-length tc1_data field. This value changes as optional values are added
and removed.
See also:
|
- (void)tc1DeleteDataPos:(unsigned int)pos |
len:(unsigned int)len |
Deletes len bytes at offset pos from the variable-length tc1_data field. All following data is shifted down by len bytes.
This method is called internally whenever an optional value no longer needs to be stored because the inherited value
from the owner is going to be used.
See also: -tc1InsertData:pos:len:
|
- (void)tc1DestroyData |
This method is provided as a hook for subclasses that need to perform special actions (destructors) before the
variable-length tc1_data field is freed. The MiscTableCell implementation of this class clears the tc1_flags bit mask
to zero.
See also: -tc1FreeData
|
- (unsigned int)tc1Flags |
Returns the current value of the tc1_flags field. This is a bit-mask indicating which optional values are currently stored in the variable-length tc1_data field. The flags also indicate whether or not the corresponding values inherited from the owner are used, since any value that has been set (and stored) in the cell overrides the inherited value. The values of the individual bits are declared in <MiscTableCell.h> as follows: |
#define MISC_TC1_HAS_TAG (1 << 0) /* obsolete */
#define MISC_TC1_SELF_FONT (1 << 1)
#define MISC_TC1_SELF_TEXT_COLOR (1 << 2)
#define MISC_TC1_SELF_BACKGROUND_COLOR (1 << 3)
#define MISC_TC1_SELF_TEXT_COLOR_H (1 << 4)
#define MISC_TC1_SELF_BACKGROUND_COLOR_H (1 << 5)
#define MISC_TC1_LAST_BIT (1 << 5)
See also:
|
- (void)tc1FreeData |
Frees the variable-length tc1_data variable. This method is invoked from within the -free method, and also within the
-read: method.
See also: -tc1DestroyData
|
- (unsigned int)tc1HighlightBackgroundColorLen |
Returns the length of the highlightBackgroundColor value in the variable-length tc1_data field. This is currently
sizeof(NXColor).
See also:
|
- (unsigned int)tc1HighlightBackgroundColorPos |
Returns the current offset of the highlightBackgroundColor value in the variable-length tc1_data field. This value
changes whenever preceeding values are added or removed.
See also:
|
- (NXColor*)tc1HighlightBackgroundColorPtr |
Returns a pointer to the highlightBackgroundColor value in the variable-length tc1_data field. The value returned is
only valid if -useOwnerHighlightBackgroundColor returns NO.
See also:
|
- (unsigned int)tc1HighlightTextColorLen |
Returns the length of the highlightTextColor value in the variable-length tc1_data field. This is currently
sizeof(NXColor).
See also:
|
- (unsigned int)tc1HighlightTextColorPos |
Returns the current offset of the highlightTextColor value in the variable-length tc1_data field. This value changes
whenever preceeding values are added or removed.
See also:
|
- (NXColor*)tc1HighlightTextColorPtr |
Returns a pointer to the highlightTextColor value in the variable-length tc1_data field. The value returned is only
valid if -useOwnerHighlightTextColor returns NO.
See also:
|
- (void*)tc1InsertData:(void const*)data |
pos:(unsigned int)pos len:(unsigned int)len |
Inserts data at offset pos in the variable-length tc1_data field, shifting all following data by len bytes. This method is
used internally to allocate the storage for optional values that do not already have storage allocated.
See also: -tc1DeleteDataPos:len:
|
- (unsigned int)tc1TextColorLen |
Returns the length of the textColor value in the variable-length tc1_data field. This is currently sizeof(NXColor).
See also:
|
- (unsigned int)tc1TextColorPos |
Returns the current offset of the textColor value in the variable-length tc1_data field. This offset changes as other
values are set or cleared.
See also:
|
- (NXColor*)tc1TextColorPtr |
Returns a pointer to the location of the textColor value stored in the variable-length tc1_data field. The value returned
is only valid if -useOwnerTextColor returns NO.
See also:
|
- (NXColor)textColor |
- (float)textGray |
Returns the gray value from by NXConvertColorToGray() given the color returned by ![]() See also:
|
- (BOOL)useOwnerBackgroundColor |
Returns YES if the cell uses the backgroundColor inherited from its owner, otherwise NO.
See also: -setBackgroundColor:, -setUseOwnerBackgroundColor:
|
- (BOOL)useOwnerFont |
Returns YES if the cell uses the font inherited from its owner, otherwise NO.
See also: -setFont:, -setUseOwnerFont:
|
- (BOOL)useOwnerHighlightBackgroundColor |
Returns YES if the cell uses the highlightBackgroundColor inherited from its owner, otherwise NO.
See also: -setHighlightBackgroundColor:, -setUseOwnerHighlightBackgroundColor:
|
- (BOOL)useOwnerHighlightTextColor |
Returns YES if the cell uses the highlightTextColor inherited from its owner, otherwise NO.
See also: -setHighlightTextColor:, -setUseOwnerHighlightTextColor:
|
- (BOOL)useOwnerTextColor |
Returns YES if the cell uses the textColor value inherited from its owner, otherwise NO.
See also: -setTextColor:, -setUseOwnerTextColor:
|
- write:(NXTypedStream*)stream |
Archives the cell on stream so that it can be unarchived with -read:.
See also: -read: |
Constants and Defined Types |
#define MISC_TC1_HAS_TAG (1 << 0) /* obsolete */
#define MISC_TC1_SELF_FONT (1 << 1)
#define MISC_TC1_SELF_TEXT_COLOR (1 << 2)
#define MISC_TC1_SELF_BACKGROUND_COLOR (1 << 3)
#define MISC_TC1_SELF_TEXT_COLOR_H (1 << 4)
#define MISC_TC1_SELF_BACKGROUND_COLOR_H (1 << 5)
#define MISC_TC1_LAST_BIT (1 << 5)