private:
CGColorRef color_;
+ static CGColorRef Create_(CGColorSpaceRef space, float red, float green, float blue, float alpha) {
+ CGFloat color[] = {red, green, blue, alpha};
+ return CGColorCreate(space, color);
+ }
+
public:
CYColor() :
color_(NULL)
}
CYColor(CGColorSpaceRef space, float red, float green, float blue, float alpha) :
- color_(NULL)
+ color_(Create_(space, red, green, blue, alpha))
{
Set(space, red, green, blue, alpha);
}
void Set(CGColorSpaceRef space, float red, float green, float blue, float alpha) {
Clear();
- float color[] = {red, green, blue, alpha};
- color_ = CGColorCreate(space, (CGFloat *) color);
+ color_ = Create_(space, red, green, blue, alpha);
}
operator CGColorRef() {
- (uint32_t) compareBySection:(NSArray *)sections;
-- (uint32_t) compareForChanges;
-
- (void) install;
- (void) remove;
_profile(Package$section)
std::replace(section_.data(), section_.data() + section_.size(), '_', ' ');
NSString *name(section_);
-
- lookup:
- if (NSDictionary *value = [SectionMap_ objectForKey:name])
- if (NSString *rename = [value objectForKey:@"Rename"]) {
- name = rename;
- goto lookup;
- }
-
- section$_ = name;
+ section$_ = [SectionMap_ objectForKey:name] ?: name;
_end
} return section$_;
}
return _not(uint32_t);
}
-- (uint32_t) compareForChanges {
- union {
- uint32_t key;
-
- struct {
- uint32_t timestamp : 30;
- uint32_t ignored : 1;
- uint32_t upgradable : 1;
- } bits;
- } value;
-
- bool upgradable([self upgradableAndEssential:YES]);
- value.bits.upgradable = upgradable ? 1 : 0;
-
- if (upgradable) {
- value.bits.timestamp = 0;
- value.bits.ignored = [self ignored] ? 0 : 1;
- value.bits.upgradable = 1;
- } else {
- value.bits.timestamp = static_cast<uint32_t>([[self seen] timeIntervalSince1970]) >> 2;
- value.bits.ignored = 0;
- value.bits.upgradable = 0;
- }
-
- return _not(uint32_t) - value.key;
-}
-
- (void) clear {
@synchronized (database_) {
pkgProblemResolver *resolver = [database_ resolver];
/* }}} */
static NSString *Colon_;
+static NSString *Elision_;
static NSString *Error_;
static NSString *Warning_;
@end
@implementation ContentView
+
- (id) initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame]) != nil) {
- /* Fix landscape stretching. */
[self setNeedsDisplayOnBoundsChange:YES];
} return self;
}
[super drawRect:rect];
[delegate_ drawContentRect:rect];
}
+
+@end
+/* }}} */
+/* Cydia TableView Cell {{{ */
+@interface CYTableViewCell : UITableViewCell {
+ ContentView *content_;
+ bool highlighted_;
+}
+
+@end
+
+@implementation CYTableViewCell
+
+- (void) dealloc {
+ [content_ release];
+ [super dealloc];
+}
+
+- (void) _updateHighlightColorsForView:(id)view highlighted:(BOOL)highlighted {
+ //NSLog(@"_updateHighlightColorsForView:%@ highlighted:%s [content_=%@]", view, highlighted ? "YES" : "NO", content_);
+
+ if (view == content_) {
+ //NSLog(@"_updateHighlightColorsForView:content_ highlighted:%s", highlighted ? "YES" : "NO", content_);
+ highlighted_ = highlighted;
+ }
+
+ [super _updateHighlightColorsForView:view highlighted:highlighted];
+}
+
+- (void) setSelected:(BOOL)selected animated:(BOOL)animated {
+ //NSLog(@"setSelected:%s animated:%s", selected ? "YES" : "NO", animated ? "YES" : "NO");
+ highlighted_ = selected;
+
+ [super setSelected:selected animated:animated];
+ [content_ setNeedsDisplay];
+}
+
@end
/* }}} */
/* Package Cell {{{ */
-@interface PackageCell : UITableViewCell <
+@interface PackageCell : CYTableViewCell <
ContentDelegate
> {
UIImage *icon_;
NSString *source_;
UIImage *badge_;
Package *package_;
- UIColor *color_;
- ContentView *content_;
- BOOL faded_;
- float fade_;
UIImage *placard_;
}
- (void) dealloc {
[self clearPackage];
- [content_ release];
- [color_ release];
[super dealloc];
}
-- (float) fade {
- return faded_ ? [self selectionPercent] : fade_;
-}
-
- (PackageCell *) init {
CGRect frame(CGRectMake(0, 0, 320, 74));
if ((self = [super initWithFrame:frame reuseIdentifier:@"Package"]) != nil) {
[content_ setDelegate:self];
[content_ setOpaque:YES];
- if ([self respondsToSelector:@selector(selectionPercent)])
- faded_ = YES;
} return self;
}
}
- (void) drawContentRect:(CGRect)rect {
- bool selected([self isSelected]);
+ bool highlighted(highlighted_);
float width([self bounds].size.width);
#if 0
)];
}
- if (selected)
+ if (highlighted)
UISetColor(White_);
- if (!selected)
+ if (!highlighted)
UISetColor(commercial_ ? Purple_ : Black_);
[name_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - (placard_ == nil ? 80 : 106)) withFont:Font18Bold_ lineBreakMode:UILineBreakModeTailTruncation];
[source_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ lineBreakMode:UILineBreakModeTailTruncation];
- if (!selected)
+ if (!highlighted)
UISetColor(commercial_ ? Purplish_ : Gray_);
[description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 46) withFont:Font14_ lineBreakMode:UILineBreakModeTailTruncation];
[placard_ drawAtPoint:CGPointMake(width - 52, 9)];
}
-- (void) setSelected:(BOOL)selected animated:(BOOL)fade {
- //[self _setBackgroundColor];
- [super setSelected:selected animated:fade];
- [content_ setNeedsDisplay];
-}
-
+ (int) heightForPackage:(Package *)package {
return 73;
}
@end
/* }}} */
/* Section Cell {{{ */
-@interface SectionCell : UITableViewCell <
+@interface SectionCell : CYTableViewCell <
ContentDelegate
> {
NSString *basic_;
NSString *name_;
NSString *count_;
UIImage *icon_;
- ContentView *content_;
UISwitch *switch_;
BOOL editing_;
}
[self clearSection];
[icon_ release];
[switch_ release];
- [content_ release];
-
[super dealloc];
}
}
- (void) drawContentRect:(CGRect)rect {
- BOOL selected = [self isSelected];
+ bool highlighted(highlighted_);
[icon_ drawInRect:CGRectMake(8, 7, 32, 32)];
- if (selected)
+ if (highlighted)
UISetColor(White_);
- if (!selected)
- UISetColor(Black_);
-
float width(rect.size.width);
if (editing_)
width -= 87;
+ if (!highlighted)
+ UISetColor(Black_);
[name_ drawAtPoint:CGPointMake(48, 9) forWidth:(width - 70) withFont:Font22Bold_ lineBreakMode:UILineBreakModeTailTruncation];
CGSize size = [count_ sizeWithFont:Font14_];
@end
/* }}} */
/* Source Cell {{{ */
-@interface SourceCell : UITableViewCell <
+@interface SourceCell : CYTableViewCell <
ContentDelegate
> {
UIImage *icon_;
NSString *origin_;
NSString *description_;
NSString *label_;
- ContentView *content_;
}
- (void) setSource:(Source *)source;
- (void) dealloc {
[self clearSource];
- [content_ release];
[super dealloc];
}
} return self;
}
-- (void) setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- [content_ setNeedsDisplay];
-}
-
- (void) drawContentRect:(CGRect)rect {
- bool selected([self isSelected]);
+ bool highlighted(highlighted_);
float width(rect.size.width);
if (icon_ != nil)
[icon_ drawInRect:CGRectMake(10, 10, 30, 30)];
- if (selected)
+ if (highlighted)
UISetColor(White_);
- if (!selected)
+ if (!highlighted)
UISetColor(Black_);
[origin_ drawAtPoint:CGPointMake(48, 8) forWidth:(width - 80) withFont:Font18Bold_ lineBreakMode:UILineBreakModeTailTruncation];
- if (!selected)
+ if (!highlighted)
UISetColor(Blue_);
[label_ drawAtPoint:CGPointMake(58, 29) forWidth:(width - 95) withFont:Font12_ lineBreakMode:UILineBreakModeTailTruncation];
- if (!selected)
+ if (!highlighted)
UISetColor(Gray_);
[description_ drawAtPoint:CGPointMake(12, 46) forWidth:(width - 40) withFont:Font14_ lineBreakMode:UILineBreakModeTailTruncation];
}
[sections_ removeAllObjects];
-#if 0
+#if 1
UIProgressHUD *hud([delegate_ addProgressHUD]);
- // XXX: localize
- [hud setText:@"Loading Changes"];
+ [hud setText:UCLocalize("LOADING")];
//NSLog(@"HUD:%@::%@", delegate_, hud);
[self yieldToSelector:@selector(_reloadPackages:) withObject:packages];
[delegate_ removeProgressHUD:hud];
[label setTextColor:[UIColor blackColor]];
[label setShadowColor:[UIColor whiteColor]];
[label setShadowOffset:CGSizeMake(0, 1)];
- [label setText:UCLocalize("LOADING_DATA")];
+ [label setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
[container addSubview:label];
CGSize viewsize = [[tabbar_ view] frame].size;
/* }}} */
Colon_ = UCLocalize("COLON_DELIMITED");
+ Elision_ = UCLocalize("ELISION");
Error_ = UCLocalize("ERROR");
Warning_ = UCLocalize("WARNING");