Skip to content

Instantly share code, notes, and snippets.

View jfahrenkrug's full-sized avatar

Johannes Fahrenkrug jfahrenkrug

View GitHub Profile
/* ------------ Search Field ------------- */
searchField = [CPTextField roundedTextFieldWithStringValue:@"" placeholder:@"Location" width:200.0];
[searchField setFrameOrigin:CGPointMake(510.0, 35.0)];
[searchField setDelegate:self];
[contentView addSubview:searchField];
/* ----------- Search Button ------------------- */
var searchButton = [[CPButton alloc] initWithFrame:CGRectMake(710.0, 37.0, 60.0, 24.0)];
[searchButton setTitle:"Search"];
[searchButton setTarget:self];
// Delegate method for the locationListView
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView
{
[locationDetailController setLocation:[self selectedLocation]];
}
/* ------- Location Detail Controller ----- */
locationDetailController = [[LocationDetailController alloc] init];
locationDetailController.mapController = mapController;
locationsController.locationDetailController = locationDetailController;
[mapController setDelegate:locationDetailController];
/* ------- Location Detail View ---------- */
locationDetailView = [[LocationDetailView alloc] initWithFrame:CGRectMake(510, 490, 400, 90)];
[locationDetailView setDelegate:locationDetailController];
[locationDetailController setLocationDetailView:locationDetailView];
@import <Foundation/CPObject.j>
@import "Location.j"
@import "MapController.j"
@import "LocationsController.j"
@import "LocationDetailView.j"
@implementation LocationDetailController : CPObject
{
Location location;
MapController mapController @accessors;
@import <AppKit/CPView.j>
@implementation LocationDetailView : CPView
{
CPTextField locationNameField;
id delegate @accessors;
}
- (id)initWithFrame:(CGRect)aFrame
{
- (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];
/* ---- Locations Toolbar ----- */
locationsToolbar = [[LocationsToolbar alloc] initWithFrame:CGRectMake(10.0, 467.0, 226.0, 25.0)];
[locationsToolbar setDelegate:locationsController];
[contentView addSubview:locationsToolbar];
@import <AppKit/CPView.j>
@implementation LocationsToolbar : CPView
{
CPButton addButton;
CPButton removeButton;
id delegate @accessors;
}
- (id)initWithFrame:(CGRect)aFrame
// Delegate method for the locationListView
- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView
{
var loc = [locationsController selectedLocation];
[mapController moveMapToLat:[loc latitude] andLng:[loc longitude]];
}
@import <Foundation/CPObject.j>
@import "Location.j"
@import "DemoData.j"
@import "LocationListView.j"
@implementation LocationsController : CPObject
{
CPArray locations;
LocationListView locationListView @accessors;
}