source: gs2-extensions/iOs-3.x/trunk/Classes/PrefView.mm@ 22603

Last change on this file since 22603 was 22603, checked in by davidb, 14 years ago

Initial cut as iOs 3.x version of Greenstone2.app

File size: 2.4 KB
Line 
1
2
3#import <Foundation/Foundation.h> // can remove?? *****
4
5#import <UIKit/CDStructures.h>
6#import <UIKit/UIKit.h>
7
8#import "GreenstoneApplication.h"
9
10#import "PrefTable.h"
11#import "PrefView.h"
12
13
14
15@implementation PrefView
16
17- (id)initWithFrame:(struct CGRect)frame withParent:(UIView*)parent
18 withCollection:(NSString*)collection withTitle:(NSString*)title
19{
20 self = [super initWithFrame:frame];
21
22 _parent = parent;
23 _collection = collection;
24
25 // Create the storage array.
26 // _cellResultList = [[NSMutableArray alloc] init]; // ****
27
28 int frame_x_dim = CGRectGetMaxX(frame)+1;
29 int frame_y_dim = CGRectGetMaxY(frame)+1;
30
31 int nav_x_org = 0.0f;
32 int nav_y_org = 0.0f;
33 int nav_x_dim = frame_x_dim;
34 int nav_y_dim = TOP_NAVBAR_HEIGHT;
35 CGRect navrect = CGRectMake(nav_x_org,nav_y_org,nav_x_dim,nav_y_dim);
36
37 // Create the navigation bar.
38 _navbar = [[UINavigationBar alloc] initWithFrame: navrect];
39 //[_navbar showLeftButton:@"Back" withStyle:2 rightButton:nil withStyle:0]; // 2 = arrow left. // *** do enum for "2"
40 [_navbar showButtonsWithLeftTitle:@"Back" rightTitle:nil leftBack:YES];
41 [_navbar enableAnimation];
42 [_navbar setBarStyle: UIBarStyleDefault];
43 [_navbar setDelegate:self];
44
45 [self setTitle:title];
46
47
48 CGRect pref_rect = frame;
49 pref_rect.origin.y += 45;
50 pref_rect.size.height -= 45;
51
52 _prefTable = [ [ PrefTable alloc ] initWithFrame: pref_rect ];
53 [_prefTable reloadData];
54
55 // [self setTitle:collection]; // ***** can't seem to be this to work!!!! but does in MenuCascadeView
56
57
58 [self addSubview: _navbar];
59 [self addSubview: _prefTable];
60
61 return self;
62}
63
64
65-(void) setTitle:(NSString*)title
66{
67 UINavigationItem* navtitle = [UINavigationItem alloc];
68 [_navbar pushNavigationItem: [navtitle initWithTitle: title]];
69}
70
71-(NSString*) languagePref
72{
73 return [_prefTable languagePref];
74}
75
76
77//***********
78//* Delegates
79//***********
80
81- (void)navigationBar:(UINavigationBar*)navbar buttonClicked:(int)button
82{
83 switch (button)
84 {
85 case 1: // left
86 [GreenstoneApplication setInCollection:nil];
87 [GreenstoneApplication transitionView:UITransitionBothShiftRight
88 fromView:self toView:_parent];
89 break;
90
91 default:
92 NSLog(@"Unrecognised navbar button = %d",button);
93 break;
94 }
95
96}
97
98
99-(void) dealloc
100{
101 [_collection release];
102
103 [super dealloc];
104}
105
106@end
107
Note: See TracBrowser for help on using the repository browser.