-/* Refresh Bar {{{ */
-@interface RefreshBar : UINavigationBar {
- _H<UIProgressIndicator> indicator_;
- _H<UITextLabel> prompt_;
- _H<UINavigationButton> cancel_;
-}
-
-@end
-
-@implementation RefreshBar
-
-- (void) positionViews {
- CGRect frame = [cancel_ frame];
- frame.size = [cancel_ sizeThatFits:frame.size];
- frame.origin.x = [self frame].size.width - frame.size.width - 5;
- frame.origin.y = ([self frame].size.height - frame.size.height) / 2;
- [cancel_ setFrame:frame];
-
- CGSize indsize([UIProgressIndicator defaultSizeForStyle:[indicator_ activityIndicatorViewStyle]]);
- unsigned indoffset = ([self frame].size.height - indsize.height) / 2;
- CGRect indrect = {{indoffset, indoffset}, indsize};
- [indicator_ setFrame:indrect];
-
- CGSize prmsize = {215, indsize.height + 4};
- CGRect prmrect = {{
- indoffset * 2 + indsize.width,
- unsigned([self frame].size.height - prmsize.height) / 2 - 1
- }, prmsize};
- [prompt_ setFrame:prmrect];
-}
-
-- (void) setFrame:(CGRect)frame {
- [super setFrame:frame];
- [self positionViews];
-}
-
-- (id) initWithFrame:(CGRect)frame delegate:(id)delegate {
- if ((self = [super initWithFrame:frame]) != nil) {
- [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
-
- [self setBarStyle:UIBarStyleBlack];
-
- UIBarStyle barstyle([self _barStyle:NO]);
- bool ugly(barstyle == UIBarStyleDefault);
-
- UIProgressIndicatorStyle style = ugly ?
- UIProgressIndicatorStyleMediumBrown :
- UIProgressIndicatorStyleMediumWhite;
-
- indicator_ = [[[UIProgressIndicator alloc] initWithFrame:CGRectZero] autorelease];
- [(UIProgressIndicator *) indicator_ setStyle:style];
- [indicator_ startAnimation];
- [self addSubview:indicator_];
-
- prompt_ = [[[UITextLabel alloc] initWithFrame:CGRectZero] autorelease];
- [prompt_ setColor:[UIColor colorWithCGColor:(ugly ? Blueish_ : Off_)]];
- [prompt_ setBackgroundColor:[UIColor clearColor]];
- [prompt_ setFont:[UIFont systemFontOfSize:15]];
- [self addSubview:prompt_];
-
- cancel_ = [[[UINavigationButton alloc] initWithTitle:UCLocalize("CANCEL") style:UINavigationButtonStyleHighlighted] autorelease];
- [cancel_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
- [cancel_ addTarget:delegate action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside];
- [cancel_ setBarStyle:barstyle];
-
- [self positionViews];
- } return self;
-}
-
-- (void) setCancellable:(bool)cancellable {
- if (cancellable)
- [self addSubview:cancel_];
- else
- [cancel_ removeFromSuperview];
-}
-
-- (void) start {
- [prompt_ setText:UCLocalize("UPDATING_DATABASE")];
-}
-
-- (void) stop {
- [self setCancellable:NO];
-}
-
-- (void) setPrompt:(NSString *)prompt {
- [prompt_ setText:prompt];
-}
-
-- (void) setProgress:(float)progress {
-}
-
-@end
-/* }}} */
-