]> git.saurik.com Git - cydia.git/blame - Cydia/LoadingView.mm
On 64-bit some of these floats are really CGFloat.
[cydia.git] / Cydia / LoadingView.mm
CommitLineData
70750ab3 1/* Cydia - iPhone UIKit Front-End for Debian APT
4c66fad9 2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
70750ab3
JF
3*/
4
6d9696a5 5/* GNU General Public License, Version 3 {{{ */
70750ab3 6/*
6d9696a5
JF
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
70750ab3 11 *
6d9696a5
JF
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
70750ab3 16 *
6d9696a5
JF
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
19**/
70750ab3
JF
20/* }}} */
21
22#include "Cydia/LoadingView.h"
23#include "CyteKit/Localize.h"
24
25@implementation CydiaLoadingView
26
27- (id) initWithFrame:(CGRect)frame {
28 if ((self = [super initWithFrame:frame]) != nil) {
29 container_ = [[[UIView alloc] init] autorelease];
30 [container_ setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin];
31
32 spinner_ = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
33 [spinner_ startAnimating];
34 [container_ addSubview:spinner_];
35
36 label_ = [[[UILabel alloc] init] autorelease];
37 [label_ setFont:[UIFont boldSystemFontOfSize:15.0f]];
38 [label_ setBackgroundColor:[UIColor clearColor]];
c8910aa3 39 [label_ setTextColor:[UIColor viewFlipsideBackgroundColor]];
70750ab3
JF
40 [label_ setShadowColor:[UIColor whiteColor]];
41 [label_ setShadowOffset:CGSizeMake(0, 1)];
42 [label_ setText:[NSString stringWithFormat:Elision_, UCLocalize("LOADING"), nil]];
43 [container_ addSubview:label_];
44
45 CGSize viewsize = frame.size;
46 CGSize spinnersize = [spinner_ bounds].size;
47 CGSize textsize = [[label_ text] sizeWithFont:[label_ font]];
48 float bothwidth = spinnersize.width + textsize.width + 5.0f;
49
50 CGRect containrect = {
51 CGPointMake(floorf((viewsize.width / 2) - (bothwidth / 2)), floorf((viewsize.height / 2) - (spinnersize.height / 2))),
52 CGSizeMake(bothwidth, spinnersize.height)
53 };
54 CGRect textrect = {
55 CGPointMake(spinnersize.width + 5.0f, floorf((spinnersize.height / 2) - (textsize.height / 2))),
56 textsize
57 };
58 CGRect spinrect = {
59 CGPointZero,
60 spinnersize
61 };
62
63 [container_ setFrame:containrect];
64 [spinner_ setFrame:spinrect];
65 [label_ setFrame:textrect];
66 [self addSubview:container_];
67 } return self;
68}
69
70@end