From 4695fd10ed12ac1725c47ae308a0e69725cb9633 Mon Sep 17 00:00:00 2001 From: vng Date: Wed, 24 Oct 2012 23:43:42 +0300 Subject: [PATCH] Forgotten file to previous commit. --- iphone/Maps/Bookmarks/BookmarkCell.mm | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/iphone/Maps/Bookmarks/BookmarkCell.mm b/iphone/Maps/Bookmarks/BookmarkCell.mm index e1525bbd8c..69a7028e2a 100644 --- a/iphone/Maps/Bookmarks/BookmarkCell.mm +++ b/iphone/Maps/Bookmarks/BookmarkCell.mm @@ -8,21 +8,28 @@ - (id)initWithReuseIdentifier:(NSString *)identifier { - self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; + self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier]; if (self) { - // Fonts and sizes are hard-coded because they can't be easily retrieved - UIFont * large = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont labelFontSize] + 1]; - UIFont * small = [UIFont fontWithName:@"Helvetica" size:[UIFont systemFontSize]]; - bmName = [[[UILabel alloc] init] autorelease]; - bmName.font = large; - bmDistance = [[[UILabel alloc] init] autorelease]; - bmDistance.font = small; - bmDistance.textColor = [UIColor grayColor]; bmDistance.textAlignment = UITextAlignmentRight; - + + // There is a hack below to get standart fonts and colors. + self.textLabel.text = @"tmpText"; + self.detailTextLabel.text = @"tmpText"; + + [super layoutSubviews]; + + bmName.font = self.textLabel.font; + bmName.textColor = self.textLabel.textColor; + + bmDistance.font = self.detailTextLabel.font; + bmDistance.textColor = self.detailTextLabel.textColor; + + self.detailTextLabel.text = nil; + self.textLabel.text = nil; + [self.contentView addSubview:bmName]; [self.contentView addSubview:bmDistance]; } @@ -35,9 +42,17 @@ CGRect r = self.contentView.bounds; // Leave some experimentally choosen paddings - CGFloat const KPaddingX = 10.0; + CGFloat const KPaddingX = 9.0; CGFloat const KPaddingBottom = 1.0; + if (self.imageView.image) + { + CGRect const imgRect = self.imageView.frame; + CGFloat const imgPadding = imgRect.size.width + imgRect.origin.x; + r.origin.x += imgPadding; + r.size.width -= imgPadding; + } + r.origin.x += KPaddingX; r.size.width -= 2 * KPaddingX; r.size.height -= KPaddingBottom; @@ -45,7 +60,7 @@ // Labels on the right should always fit and be visible, but not more than half of the cell CGFloat const w = r.size.width; CGFloat const h = r.size.height; - + CGFloat xDelim = (int)(r.origin.x + w / 2); if (bmDistance.text.length) { @@ -57,7 +72,7 @@ { xDelim = r.origin.x + w - KPaddingX; } - + bmName.frame = CGRectMake(r.origin.x, r.origin.y, xDelim - r.origin.x, h); bmDistance.frame = CGRectMake(xDelim, r.origin.y, r.origin.x + w - xDelim, h); }