comparison mac/dw.m @ 1210:5a016a5a7412

Slight change in design behavior for dw_container_set_row_bg()... Setting both odd and even to DW_RGB_TRANSPARENT will disable row coloring. DW_CLR_DEFAULT will pick system default row colors... or some nice presets.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 08 Oct 2011 20:43:25 +0000
parents c7bb48cda53a
children 5271d5cb27ac
comparison
equal deleted inserted replaced
1209:a99a08671b64 1210:5a016a5a7412
1327 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 1327 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
1328 -(NSSize)cellSize; 1328 -(NSSize)cellSize;
1329 @end 1329 @end
1330 1330
1331 @implementation DWImageAndTextCell 1331 @implementation DWImageAndTextCell
1332 - (void)dealloc 1332 -(void)dealloc
1333 { 1333 {
1334 [image release]; 1334 [image release];
1335 image = nil; 1335 image = nil;
1336 [super dealloc]; 1336 [super dealloc];
1337 } 1337 }
1341 cell->image = [image retain]; 1341 cell->image = [image retain];
1342 return cell; 1342 return cell;
1343 } 1343 }
1344 -(void)setImage:(NSImage *)anImage 1344 -(void)setImage:(NSImage *)anImage
1345 { 1345 {
1346 if (anImage != image) 1346 if(anImage != image)
1347 { 1347 {
1348 [image release]; 1348 [image release];
1349 image = [anImage retain]; 1349 image = [anImage retain];
1350 } 1350 }
1351 } 1351 }
1353 { 1353 {
1354 return [[image retain] autorelease]; 1354 return [[image retain] autorelease];
1355 } 1355 }
1356 -(NSRect)imageFrameForCellFrame:(NSRect)cellFrame 1356 -(NSRect)imageFrameForCellFrame:(NSRect)cellFrame
1357 { 1357 {
1358 if (image != nil) 1358 if(image != nil)
1359 { 1359 {
1360 NSRect imageFrame; 1360 NSRect imageFrame;
1361 imageFrame.size = [image size]; 1361 imageFrame.size = [image size];
1362 imageFrame.origin = cellFrame.origin; 1362 imageFrame.origin = cellFrame.origin;
1363 imageFrame.origin.x += 3; 1363 imageFrame.origin.x += 3;
1379 NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); 1379 NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge);
1380 [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength]; 1380 [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength];
1381 } 1381 }
1382 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView 1382 -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
1383 { 1383 {
1384 if (image != nil) { 1384 if(image != nil)
1385 {
1385 NSSize imageSize; 1386 NSSize imageSize;
1386 NSRect imageFrame; 1387 NSRect imageFrame;
1387 1388
1388 imageSize = [image size]; 1389 imageSize = [image size];
1389 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge); 1390 NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 + imageSize.width, NSMinXEdge);
1390 if ([self drawsBackground]) { 1391 if ([self drawsBackground])
1392 {
1391 [[self backgroundColor] set]; 1393 [[self backgroundColor] set];
1392 NSRectFill(imageFrame); 1394 NSRectFill(imageFrame);
1393 } 1395 }
1394 imageFrame.origin.x += 3; 1396 imageFrame.origin.x += 3;
1395 imageFrame.size = imageSize; 1397 imageFrame.size = imageSize;
1517 NSColor *oldeven = evencolor; 1519 NSColor *oldeven = evencolor;
1518 unsigned long _odd = _get_color(oddcol); 1520 unsigned long _odd = _get_color(oddcol);
1519 unsigned long _even = _get_color(evencol); 1521 unsigned long _even = _get_color(evencol);
1520 1522
1521 /* Get the NSColor for non-default colors */ 1523 /* Get the NSColor for non-default colors */
1522 if(oddcol != DW_CLR_DEFAULT) 1524 if(oddcol != DW_RGB_TRANSPARENT)
1523 oddcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain]; 1525 oddcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain];
1524 else 1526 else
1525 oddcolor = NULL; 1527 oddcolor = NULL;
1526 if(evencol != DW_CLR_DEFAULT) 1528 if(evencol != DW_RGB_TRANSPARENT)
1527 evencolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain]; 1529 evencolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain];
1528 else 1530 else
1529 evencolor = NULL; 1531 evencolor = NULL;
1530 [oldodd release]; 1532 [oldodd release];
1531 [oldeven release]; 1533 [oldeven release];
5748 /* 5750 /*
5749 * Sets the alternating row colors for container window (widget) handle. 5751 * Sets the alternating row colors for container window (widget) handle.
5750 * Parameters: 5752 * Parameters:
5751 * handle: The window (widget) handle. 5753 * handle: The window (widget) handle.
5752 * oddcolor: Odd row background color in DW_RGB format or a default color index. 5754 * oddcolor: Odd row background color in DW_RGB format or a default color index.
5753 * DW_CLR_DEFAULT will disable coloring odd rows.
5754 * evencolor: Even row background color in DW_RGB format or a default color index. 5755 * evencolor: Even row background color in DW_RGB format or a default color index.
5755 * DW_CLR_DEFAULT will disable coloring even rows. 5756 * DW_RGB_TRANSPARENT will disable coloring rows.
5757 * DW_CLR_DEFAULT will use the system default alternating row colors.
5756 */ 5758 */
5757 void API dw_container_set_row_bg(HWND handle, unsigned long oddcolor, unsigned long evencolor) 5759 void API dw_container_set_row_bg(HWND handle, unsigned long oddcolor, unsigned long evencolor)
5758 { 5760 {
5759 int _locked_by_me = FALSE; 5761 int _locked_by_me = FALSE;
5760 DW_MUTEX_LOCK; 5762 DW_MUTEX_LOCK;
5761 DWContainer *cont = handle; 5763 DWContainer *cont = handle;
5762 [cont setRowBgOdd:oddcolor andEven:evencolor]; 5764 [cont setRowBgOdd:(oddcolor == DW_CLR_DEFAULT ? DW_RGB_TRANSPARENT : oddcolor)
5765 andEven:(evencolor == DW_CLR_DEFAULT ? DW_RGB(230,230,230) : evencolor)];
5763 DW_MUTEX_UNLOCK; 5766 DW_MUTEX_UNLOCK;
5764 } 5767 }
5765 5768
5766 /* 5769 /*
5767 * Sets the width of a column in the container. 5770 * Sets the width of a column in the container.