This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CBElementViewController.m
73 lines (61 loc) · 2.07 KB
/
CBElementViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// CBElementViewController.m
// CubicusClient
//
// Created by James Potter on 07/03/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "CBElementViewController.h"
UIColor *makeColor(void) {
CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;
CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;
CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
return [UIColor colorWithRed:red green:green blue:blue alpha:1];
}
@implementation CBElementViewController
@synthesize element;
@synthesize eventReceiver;
- (id)initWithElement:(CBLayoutElement *)theElement
{
self = [super init];
if (self) {
element = theElement;
eventReceiver = nil;
inactiveColor = [[UIColor alloc] initWithRed:0.960784 green:0.960784 blue:0.941176 alpha:1.0];
activeColor = [[UIColor alloc] initWithRed:0.909804 green:0.909804 blue:0.858824 alpha:1.0];
labelColor = [[UIColor alloc] initWithRed:0.843137 green:0.333333 blue:0.152941 alpha:1.0];
}
return self;
}
- (void)loadView
{
// Default stub
UIView *v = [[UIView alloc] initWithFrame:CGRectZero];
v.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
v.backgroundColor = makeColor();
_label = [[UILabel alloc] initWithFrame:CGRectZero];
_label.text = [NSString stringWithFormat:@"<%@>", [self class]];
_label.backgroundColor = [UIColor clearColor];
[v addSubview:_label];
self.view = v;
}
- (void)viewDidLayoutSubviews
{
_label.frame = self.view.bounds;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- (void)fireEvent:(CBEvent *)event
{
if (self.eventReceiver) [self.eventReceiver sender:self didFireEvent:event];
}
#pragma mark -
#pragma mark CBEventReceiver
- (void)sender:(id)sender didFireEvent:(CBEvent *)event
{
[NSException raise:NSInternalInconsistencyException
format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)];
}
@end