This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AppController.j | |
* Locations | |
* | |
* Created by Johannes Fahrenkrug on September 8, 2009. | |
* Copyright 2009, Your Company All rights reserved. | |
*/ | |
@import <Foundation/CPObject.j> | |
@import "Location.j" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <AppKit/CPCollectionView.j> | |
@implementation LocationListView : CPCollectionView | |
{ | |
CPCollectionViewItem itemPrototype; | |
} | |
- (id)initWithFrame:(CGRect)aFrame | |
{ | |
self = [super initWithFrame:aFrame]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------ Locations --------------- */ | |
locationListView = [[LocationListView alloc] initWithFrame:CGRectMake(0.0, 0.0, 226.0, 400.0)]; | |
[locationListView setContent:[locationsController locations]]; | |
//1: we'll add something later | |
/* --------- Locations ScrollView ---------- */ | |
var locationScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(10.0, 65.0, 243.0, 400.0)]; | |
[locationScrollView setDocumentView:locationListView]; | |
[locationScrollView setAutohidesScrollers:YES]; | |
[[locationScrollView contentView] setBackgroundColor:[CPColor whiteColor]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <Foundation/CPObject.j> | |
@import <MapKit/MKMapView.j> | |
@import "Location.j" | |
@implementation MapController : CPObject | |
{ | |
MKMapView mapView @accessors; | |
CPTextField coordinatesLabel @accessors; | |
CPString latitude; | |
CPString longitude; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ----- Map Controller --------------- */ | |
mapController = [[MapController alloc] init]; | |
/* ------------- Map View ----------------- */ | |
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(510, 65, 400, 400) apiKey:'']; | |
[mapView setDelegate:self]; | |
mapController.mapView = mapView; | |
[contentView addSubview:mapView]; | |
/* ---------- Coordinates Label -------------- */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <Foundation/CPObject.j> | |
@import "Location.j" | |
@import "DemoData.j" | |
@import "LocationListView.j" | |
@implementation LocationsController : CPObject | |
{ | |
CPArray locations; | |
LocationListView locationListView @accessors; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Delegate method for the locationListView | |
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView | |
{ | |
var loc = [locationsController selectedLocation]; | |
[mapController moveMapToLat:[loc latitude] andLng:[loc longitude]]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <AppKit/CPView.j> | |
@implementation LocationsToolbar : CPView | |
{ | |
CPButton addButton; | |
CPButton removeButton; | |
id delegate @accessors; | |
} | |
- (id)initWithFrame:(CGRect)aFrame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ---- Locations Toolbar ----- */ | |
locationsToolbar = [[LocationsToolbar alloc] initWithFrame:CGRectMake(10.0, 467.0, 226.0, 25.0)]; | |
[locationsToolbar setDelegate:locationsController]; | |
[contentView addSubview:locationsToolbar]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)addLocation { | |
if (!locations) { | |
locations = [[CPArray alloc] init]; | |
} | |
loc = [[Location alloc] init]; | |
[loc setDescription:@""]; | |
[loc setPosition:([locations count] + 1)]; | |
[locations addObject:loc]; | |
[locationListView setContent:locations]; |