Skip to content

Instantly share code, notes, and snippets.

View j4johnfox's full-sized avatar

John C Fox j4johnfox

View GitHub Profile
- (CPString)bundleLocaleWithUserLanguage:(CPString)aUserLanguage
{
var defaultLocale = [self objectForInfoDictionaryKey:@"CPBundleDevelopmentRegion"];
var availableLocales = [self objectForInfoDictionaryKey:@"CPBundleLocalizedResourceKeys"];
var bestMatch, myLocale= nil;
UserLanguage = aUserLanguage;
// First try matching against the UserLanguage
if (UserLanguage && [UserLanguage length])
- (CPString)browserLanguage
{
// IE uses userLanguage to return the code. For now, we'll just deal with
// the "base" language (e.g. "en" vs. "en-GB"
var userLang = (navigator.language) ? navigator.language : navigator.userLanguage;
return userLang.substring(0,2)
}
- (CPString)pathForLocalizedResource:(CPString)aResourceName
{
var mainBundle = [CPBundle mainBundle];
return [mainBundle pathForResource:[mainBundle bundleLocale] + ".lproj/" +aResourceName];
}
+ (CPCib)loadLocalizedCibNamed:(CPString)aName
owner:(id)anOwner
loadDelegate:(id)aDelegate
{
@j4johnfox
j4johnfox / CPBundle.j
Created July 7, 2010 04:22 — forked from nickjs/CPBundle.sj
Modifications to support of multiple localized resources
/*
* CPBundle.j
* AppKit
*
* Created by Nicholas Small, extended by John C. Fox
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
/*
* MMSSimpleWhiteScroller.j
*
* Created by John C. Fox on 04/29/2010.
* Copyright 2010 GroupSmarts, LLC. All rights reserved.
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPTheme.j>
- (void)drawRect:(CGRect)aRect
{
log('here in MMSGradientView drawRect');
var myContext = [[CPGraphicsContext currentContext] graphicsPort];
var myGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [1, 1, 1,1.0, .5, .5, .5,1.0], [0,1], 2);
var startPoint = CGPointMake(0, 0);
var endPoint = CGPointMake(0, [self bounds].size.height);
CGContextDrawLinearGradient(myContext, myGradient, startPoint, endPoint, 0);
- (void)setAnchorPoint:(CGPoint)anAnchorPoint
inPhotoLayer:(CALayer)aPhotoLayer
{
log('anAnchorPoint is ' +CPStringFromPoint(anAnchorPoint));
if (aPhotoLayer._DOMContentsElement == null)
{
log('aPhotoLayer has no _DOMContentsElement cannot set its anchor point, bail');
return;
- (void)setAnchorPoint:(CGPoint)anAnchorPoint
inPhotoLayer:(CALayer)aPhotoLayer
{
log('anAnchorPoint is ' +CPStringFromPoint(anAnchorPoint));
if (aPhotoLayer._DOMContentsElement == null)
{
log('aPhotoLayer has no _DOMContentsElement cannot set its anchor point, bail');
return;
- (void)setFrame:(CGRect)aFrame
{
log('here in MKMapView setFrame aFrame is ' +CPStringFromRect(aFrame));
[super setFrame:aFrame];
log('[_frameView frame] is ' +CPStringFromRect([_frameView frame]));
var bounds = [self bounds];
// Time/Place markersTable View
var tableViewRect = CPRectCreateCopy([notesTextView frame]);
tableViewRect.origin.y += ([notesTextView frame].size.height + 10);
tableViewRect.size.width = ([containerView frame].size.width - (2 * margin));
// We want to fill the space between the bottom of the notes text view and the top of the buttons on the
// bottom of this form
var tableHeight = ([containerView frame].size.height - [createNewButton frame].size.height
- margin - 3 - tableViewRect.origin.y);