Skip to content

Commit

Permalink
fixed merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ettore committed Dec 15, 2012
2 parents fc16b47 + f5fb824 commit 6526d0c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
15 changes: 12 additions & 3 deletions CLCGCell.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
CGFloat mImgH; CGFloat mImgH;
CGFloat mPadding; CGFloat mPadding;
UIColor *mNormalColor; UIColor *mNormalColor;
UIColor *mEmphasizedColor; UIColor *mEmphasisColor;
BOOL mEmphasized; BOOL mEmphasized;
id mContext; id mContext;
} }
Expand All @@ -70,7 +70,15 @@
@property(nonatomic,retain) UILabel *infoTextLabel; @property(nonatomic,retain) UILabel *infoTextLabel;
@property(nonatomic,retain) UIColor *normalColor; @property(nonatomic,retain) UIColor *normalColor;


/*! Designated initializer. */ /*!
The designated initializer.
Sets up the styling of the cell, according to the given width and height of
the image and padding.
The padding value adds whitespace to all sides of the cell (i.e. left, right,
up, down), on the right side of the image and the left side of the accessory
view (if you use it) and between the textLabel and detailTextLabel.
To use no image, simply construct a cell with image width and height set to 0.
*/
-(id)initWithImageWidth:(CGFloat)w -(id)initWithImageWidth:(CGFloat)w
height:(CGFloat)h height:(CGFloat)h
padding:(CGFloat)padding padding:(CGFloat)padding
Expand Down Expand Up @@ -114,11 +122,12 @@
/*! /*!
@abstract The max width accounted during layout calculations for the @abstract The max width accounted during layout calculations for the
accessory view or discolosure arrow. accessory view or discolosure arrow.
@discussion By default, CLCGCell does not use a true accessory view. Rather, @discussion By default, CLCGCell does not use a true accessory view; rather,
it employs the default UITableViewCellAccessoryDisclosureIndicator type. it employs the default UITableViewCellAccessoryDisclosureIndicator type.
If you use actual custom views for your accessory element, you should If you use actual custom views for your accessory element, you should
probably create a subclass and override this method with actual probably create a subclass and override this method with actual
measurements. measurements.
If you don't use any accessory item, override this method and return 0.
@return A constant value that should account for the size of a default @return A constant value that should account for the size of a default
accessory type. accessory type.
*/ */
Expand Down
34 changes: 24 additions & 10 deletions CLCGCell.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ -(void)dealloc
CLCG_REL(mImgUrl); CLCG_REL(mImgUrl);
CLCG_REL(mContext); CLCG_REL(mContext);
CLCG_REL(mNormalColor); CLCG_REL(mNormalColor);
CLCG_REL(mEmphasizedColor); CLCG_REL(mEmphasisColor);
[super dealloc]; [super dealloc];
} }


Expand All @@ -111,22 +111,22 @@ -(id)initWithImageWidth:(CGFloat)w
mImgH = h; mImgH = h;
mPadding = padding; mPadding = padding;
[self setSelectionStyle:UITableViewCellSelectionStyleBlue]; [self setSelectionStyle:UITableViewCellSelectionStyleBlue];
[[self textLabel] setNumberOfLines:0];//set to 0 and calc height dynamically
[[self textLabel] setTextColor:[UIColor blackColor]]; [[self textLabel] setTextColor:[UIColor blackColor]];
[[self textLabel] setBackgroundColor:[UIColor clearColor]]; [[self textLabel] setLineBreakMode:UILineBreakModeWordWrap];
[[self textLabel] setNumberOfLines:0];//set to 0 and calc height dynamically
[[self detailTextLabel] setTextColor:[UIColor grayColor]]; [[self detailTextLabel] setTextColor:[UIColor grayColor]];
[[self detailTextLabel] setLineBreakMode:UILineBreakModeWordWrap];
[[self detailTextLabel] setNumberOfLines:0]; [[self detailTextLabel] setNumberOfLines:0];
[[self detailTextLabel] setAdjustsFontSizeToFitWidth:YES];
[[self detailTextLabel] setMinimumFontSize:9]; [[self detailTextLabel] setMinimumFontSize:9];
[[self detailTextLabel] setBackgroundColor:[UIColor clearColor]]; [[self detailTextLabel] setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
[[self imageView] setFrame:CGRectMake(padding, padding, w, h)]; [[self imageView] setFrame:CGRectMake(padding, padding, w, h)];
[[self imageView] setAutoresizingMask:UIViewAutoresizingNone]; [[self imageView] setAutoresizingMask:UIViewAutoresizingNone];
[[self imageView] setContentMode:UIViewContentModeScaleAspectFit]; [[self imageView] setContentMode:UIViewContentModeScaleAspectFit];
[[self textLabel] setFont:[UIFont boldSystemFontOfSize:15.0f]]; //reasonable default [[self textLabel] setFont:[UIFont boldSystemFontOfSize:15.0f]]; //reasonable default
[[self detailTextLabel] setFont:[UIFont systemFontOfSize:12.0f]];//reasonable default [[self detailTextLabel] setFont:[UIFont systemFontOfSize:12.0f]];//reasonable default
[mInfoTextLabel setFont:[UIFont systemFontOfSize:12.0f]]; //reasonable default [mInfoTextLabel setFont:[UIFont systemFontOfSize:12.0f]]; //reasonable default
mEmphasizedColor = [UIColor colorWithRed:1.0 green:0.98 blue:0.85 alpha:1.0]; mEmphasisColor = [UIColor colorWithRed:1.0 green:0.98 blue:0.85 alpha:1.0];
[mEmphasizedColor retain]; [mEmphasisColor retain];
[self setNormalColor:[UIColor whiteColor]]; [self setNormalColor:[UIColor whiteColor]];


// info label, this goes below the detail label // info label, this goes below the detail label
Expand All @@ -136,6 +136,11 @@ -(id)initWithImageWidth:(CGFloat)w
[mInfoTextLabel setBackgroundColor:[UIColor clearColor]]; [mInfoTextLabel setBackgroundColor:[UIColor clearColor]];
[self addSubview:mInfoTextLabel]; [self addSubview:mInfoTextLabel];


// NOTE: despite what the docs say, it seems necessary to set the background
// color here to have the emphasis color render correctly behind the labels.
[[self textLabel] setBackgroundColor:[UIColor clearColor]];
[[self detailTextLabel] setBackgroundColor:[UIColor clearColor]];

// needed for changing the background color // needed for changing the background color
UIView *bgview = [[UIView alloc] initWithFrame:CGRectZero]; UIView *bgview = [[UIView alloc] initWithFrame:CGRectZero];
[bgview setOpaque:YES]; [bgview setOpaque:YES];
Expand All @@ -153,7 +158,7 @@ -(void)updateBackgroundColor
// Note: setting the background color on the contentView or even all the // Note: setting the background color on the contentView or even all the
// subviews doesn't take care of changing the background of the accessoryView. // subviews doesn't take care of changing the background of the accessoryView.
// Setting the background of the accessoryView doesn't seem to work either. // Setting the background of the accessoryView doesn't seem to work either.
UIColor *color = (mEmphasized ? mEmphasizedColor : mNormalColor); UIColor *color = (mEmphasized ? mEmphasisColor : mNormalColor);
[[self backgroundView] setBackgroundColor:color]; [[self backgroundView] setBackgroundColor:color];
} }


Expand Down Expand Up @@ -257,12 +262,21 @@ +(void)setMaxAccessoryWidth:(CGFloat)w
} }




/*!
This method calculates the available width for the text content.
It accounts for:
- image width
- accessory item (we assume it's either present/absent on all views)
- padding left and right of the cell's borders,
- padding on the right side of the image, if we have it,
- padding on the left side of the accessory view, if we have it.
*/
+(CGFloat)textLabelWidthWithCellW:(CGFloat)maxw +(CGFloat)textLabelWidthWithCellW:(CGFloat)maxw
imageW:(CGFloat)imgw imageW:(CGFloat)imgw
padding:(CGFloat)pad padding:(CGFloat)pad
{ {
return maxw - imgw - ((imgw>0) ? pad:0) - pad CGFloat accw = [self maxAccessoryWidth];
- CLCG_DEFAULT_VIEWPORT_PADDING*2 - [self maxAccessoryWidth]; return maxw - imgw - pad*2 - (imgw>0 ? pad:0) - accw - (accw>0 ? pad:0);
} }




Expand Down

0 comments on commit 6526d0c

Please sign in to comment.