Mercurial > dwindows
comparison mac/dw.m @ 860:93ac372941c4
Formatting cleanups.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 01 Apr 2011 01:37:05 +0000 |
parents | 80a88c91ccf6 |
children | ca01c7d95b80 |
comparison
equal
deleted
inserted
replaced
859:80a88c91ccf6 | 860:93ac372941c4 |
---|---|
716 @end | 716 @end |
717 | 717 |
718 /* Subclass for a textfield that supports vertical centering */ | 718 /* Subclass for a textfield that supports vertical centering */ |
719 @interface DWTextFieldCell : NSTextFieldCell | 719 @interface DWTextFieldCell : NSTextFieldCell |
720 { | 720 { |
721 BOOL vcenter; | 721 BOOL vcenter; |
722 } | 722 } |
723 -(NSRect)drawingRectForBounds:(NSRect)theRect; | 723 -(NSRect)drawingRectForBounds:(NSRect)theRect; |
724 -(void)setVCenter:(BOOL)input; | 724 -(void)setVCenter:(BOOL)input; |
725 @end | 725 @end |
726 | 726 |
727 @implementation DWTextFieldCell | 727 @implementation DWTextFieldCell |
728 -(NSRect)drawingRectForBounds:(NSRect)theRect | 728 -(NSRect)drawingRectForBounds:(NSRect)theRect |
729 { | 729 { |
730 /* Get the parent's idea of where we should draw */ | 730 /* Get the parent's idea of where we should draw */ |
731 NSRect newRect = [super drawingRectForBounds:theRect]; | 731 NSRect newRect = [super drawingRectForBounds:theRect]; |
732 | 732 |
733 /* If we are being vertically centered */ | 733 /* If we are being vertically centered */ |
734 if(vcenter) | 734 if(vcenter) |
735 { | 735 { |
736 /* Get our ideal size for current text */ | 736 /* Get our ideal size for current text */ |
737 NSSize textSize = [self cellSizeForBounds:theRect]; | 737 NSSize textSize = [self cellSizeForBounds:theRect]; |
738 | 738 |
739 /* Center that in the proposed rect */ | 739 /* Center that in the proposed rect */ |
740 float heightDelta = newRect.size.height - textSize.height; | 740 float heightDelta = newRect.size.height - textSize.height; |
741 if (heightDelta > 0) | 741 if (heightDelta > 0) |
742 { | 742 { |
743 newRect.size.height -= heightDelta; | 743 newRect.size.height -= heightDelta; |
744 newRect.origin.y += (heightDelta / 2); | 744 newRect.origin.y += (heightDelta / 2); |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 return newRect; | 748 return newRect; |
749 } | 749 } |
750 -(void)setVCenter:(BOOL)input { vcenter = input; } | 750 -(void)setVCenter:(BOOL)input { vcenter = input; } |
751 @end | 751 @end |
752 | 752 |
753 /* Subclass for a entryfield type */ | 753 /* Subclass for a entryfield type */ |