project_files/HedgewarsMobile/Classes/SplitViewRootController.m
author unc0rr
Mon, 12 Sep 2011 21:51:14 +0400
changeset 5879 42cf124c305b
parent 5219 9e2a17ab178b
child 6000 dbcebcd3d79f
permissions -rw-r--r--
This should check if Qt provides zlib functions, and adds zlib dependency in case of zlibless Qt. Tested with Qt providing zlib functions only.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     1
/*
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     2
 * Hedgewars-iOS, a Hedgewars port for iOS devices
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4356
diff changeset
     3
 * Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
3829
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     4
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     8
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    12
 * GNU General Public License for more details.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    13
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    14
 * You should have received a copy of the GNU General Public License
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    15
 * along with this program; if not, write to the Free Software
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    17
 *
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    18
 * File created on 27/03/2010.
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    19
 */
81db3c85784b headers ftw, also right project file
koda
parents: 3783
diff changeset
    20
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    21
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    22
#import "SplitViewRootController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    23
#import "MasterViewController.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    24
#import "CommodityFunctions.h"
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    25
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    26
@implementation SplitViewRootController
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    27
@synthesize activeController, rightNavController, splitViewRootController;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    28
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    29
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    30
    return rotationManager(interfaceOrientation);
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    31
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    32
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    33
-(void) didReceiveMemoryWarning {
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    34
    if (self.activeController.view.superview == nil)
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    35
        self.activeController = nil;
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    36
    MSG_MEMCLEAN();
3971
5c82ee165ed5 minor stuff
koda
parents: 3829
diff changeset
    37
    [super didReceiveMemoryWarning];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    38
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    39
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    40
// load the view programmatically; we need a splitViewController that handles a MasterViewController
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    41
// (which is just a UITableViewController) and a DetailViewController where we present options
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    42
-(void) viewDidLoad {
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    43
    CGRect rect = [[UIScreen mainScreen] bounds];
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    44
    self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    45
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    46
    if (self.activeController == nil) {
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    47
        MasterViewController *rightController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped];
5219
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    48
        rightController.rootController = self;
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    49
        rightController.targetController = nil;
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    50
        self.activeController = rightController;
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    51
        [rightController release];
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    52
    }
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    53
    self.rightNavController = [[UINavigationController alloc] initWithRootViewController:self.activeController];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    54
3996
eb549fd864a5 the ios port is also iphone compatible
koda
parents: 3971
diff changeset
    55
    if (IS_IPAD()) {
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    56
        MasterViewController *leftController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
5219
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    57
        leftController.rootController = self;
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    58
        leftController.targetController = self.activeController;
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    59
        UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController];
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    60
        [leftController release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    61
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    62
        self.splitViewRootController = [[UISplitViewController alloc] init];
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    63
        self.splitViewRootController.delegate = nil;
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    64
        self.splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    65
        self.splitViewRootController.viewControllers = [NSArray arrayWithObjects: leftNavController, self.rightNavController, nil];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    66
        [leftNavController release];
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    67
        [self.rightNavController release];
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    68
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    69
        // add view to main controller
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    70
        [self.view addSubview:self.splitViewRootController.view];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    71
    } else {
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    72
        self.rightNavController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    73
        [self.view addSubview:self.rightNavController.view];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    74
    }
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    75
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    76
    [super viewDidLoad];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    77
}
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3662
diff changeset
    78
5219
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    79
-(void) dismissModalViewControllerAnimated:(BOOL)animated {
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    80
    playSound(@"backSound");
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    81
    [self.parentViewController dismissModalViewControllerAnimated:YES];
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    82
}
9e2a17ab178b this notification can be removed
koda
parents: 5208
diff changeset
    83
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    84
-(void) viewDidUnload {
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
    85
    self.activeController = nil;
4356
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    86
    self.rightNavController = nil;
d1d26f8963a3 update some files for new graphics and new ios4.2
koda
parents: 3996
diff changeset
    87
    self.splitViewRootController = nil;
3662
a44406f4369b polish polish polish polish (also: panning horizontal fix, panning momentum, settings page reworked yet again, memory leaks, crashes, segfaults)
koda
parents: 3547
diff changeset
    88
    MSG_DIDUNLOAD();
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    89
    [super viewDidUnload];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    90
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    91
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    92
-(void) dealloc {
5208
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
    93
    releaseAndNil(activeController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
    94
    releaseAndNil(rightNavController);
878e551f0b4a all together now! releaseAndNil ftw
koda
parents: 4976
diff changeset
    95
    releaseAndNil(splitViewRootController);
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    96
    [super dealloc];
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    97
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    98
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
    99
#pragma mark -
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   100
#pragma mark additional methods as we're using a UINavigationController programmatically
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   101
// see http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   102
-(void) viewWillAppear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   103
    [super viewWillAppear:animated];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
   104
    [self.activeController.navigationController viewWillAppear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   105
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   106
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   107
-(void) viewWillDisappear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   108
    [super viewWillDisappear:animated];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
   109
    [self.activeController.navigationController viewWillDisappear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   110
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   111
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   112
-(void) viewDidAppear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   113
    [super viewDidLoad];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
   114
    [self.activeController.navigationController viewDidAppear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   115
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   116
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   117
-(void) viewDidDisappear:(BOOL)animated {
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   118
    [super viewDidUnload];
3701
8c449776ebe6 rewrite portions of some uiviewcontrollers
koda
parents: 3697
diff changeset
   119
    [self.activeController.navigationController viewDidDisappear:animated];
3547
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   120
}
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   121
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   122
02875b1145b7 i <3 mercurial
koda
parents: 3546
diff changeset
   123
@end