Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 8 commits
  • 18 files changed
  • 0 commit comments
  • 2 contributors
View
3  .gitmodules
@@ -1,3 +0,0 @@
-[submodule "Components/CWFoundation"]
- path = Components/CWFoundation
- url = git@github.com:jayway/CWFoundation.git
View
368 CWUIKit.xcodeproj/project.pbxproj
@@ -3,9 +3,23 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
+/* Begin PBXAggregateTarget section */
+ A6E8C1A81404087C00C00910 /* CWUIKitEnsureDeps */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = A6E8C1A91404087C00C00910 /* Build configuration list for PBXAggregateTarget "CWUIKitEnsureDeps" */;
+ buildPhases = (
+ A6E8C1AC140408C500C00910 /* ShellScript */,
+ );
+ dependencies = (
+ );
+ name = CWUIKitEnsureDeps;
+ productName = CWUIKitEnsureDeps;
+ };
+/* End PBXAggregateTarget section */
+
/* Begin PBXBuildFile section */
8B3096C51386662300EE9727 /* CWSearchBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B3096C11386662300EE9727 /* CWSearchBar.h */; };
8B3096C61386662300EE9727 /* CWSearchBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B3096C21386662300EE9727 /* CWSearchBar.m */; };
@@ -34,6 +48,19 @@
A65D9BE8137BD56C007D25A0 /* bar_button@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A65D9BE4137BD56B007D25A0 /* bar_button@2x.png */; };
A65D9C07137BD9E3007D25A0 /* CWBackgroundBars.h in Headers */ = {isa = PBXBuildFile; fileRef = A65D9C05137BD9E3007D25A0 /* CWBackgroundBars.h */; };
A65D9C08137BD9E3007D25A0 /* CWBackgroundBars.m in Sources */ = {isa = PBXBuildFile; fileRef = A65D9C06137BD9E3007D25A0 /* CWBackgroundBars.m */; };
+ A691863113E1B39F006F25AD /* CWCalendarView.h in Headers */ = {isa = PBXBuildFile; fileRef = A691862D13E1B39F006F25AD /* CWCalendarView.h */; };
+ A691863213E1B39F006F25AD /* CWCalendarView.m in Sources */ = {isa = PBXBuildFile; fileRef = A691862E13E1B39F006F25AD /* CWCalendarView.m */; };
+ A691863313E1B39F006F25AD /* CWViewSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = A691862F13E1B39F006F25AD /* CWViewSheet.h */; };
+ A691863413E1B39F006F25AD /* CWViewSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = A691863013E1B39F006F25AD /* CWViewSheet.m */; };
+ A69186B113E1B464006F25AD /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6A42D55136988B00051E0C7 /* OpenGLES.framework */; };
+ A69186B213E1B464006F25AD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
+ A69186B313E1B464006F25AD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6ED9127136947C4002DCEE4 /* CoreGraphics.framework */; };
+ A69186B413E1B464006F25AD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6ED9129136947C4002DCEE4 /* QuartzCore.framework */; };
+ A69186B513E1B464006F25AD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6ED912B136947C4002DCEE4 /* UIKit.framework */; };
+ A69186B613E1B464006F25AD /* libCWUIKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libCWUIKit.a */; };
+ A69186C413E1B492006F25AD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A69186BF13E1B492006F25AD /* main.m */; };
+ A69186C513E1B492006F25AD /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A69186C013E1B492006F25AD /* MainWindow.xib */; };
+ A69186C613E1B492006F25AD /* SampleAppAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A69186C213E1B492006F25AD /* SampleAppAppDelegate.m */; };
A6A42D56136988B00051E0C7 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6A42D55136988B00051E0C7 /* OpenGLES.framework */; };
A6A97543136ABCA50065D9BE /* CWUIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = A6A97542136ABCA50065D9BE /* CWUIKit.h */; };
A6A975D3136AC3A50065D9BE /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6A42D55136988B00051E0C7 /* OpenGLES.framework */; };
@@ -98,54 +125,68 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
- A609632213C7C192005E7E4B /* PBXContainerItemProxy */ = {
+ A69186A913E1B464006F25AD /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = D2AAC07D0554694100DB518D;
+ remoteInfo = CWUIKit;
+ };
+ A6DAA6E81383E51700518CC8 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = D2AAC07D0554694100DB518D;
+ remoteInfo = CWUIKit;
+ };
+ A6E879051404102800DFABA1 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = D2AAC07D0554694100DB518D;
+ remoteInfo = CWFoundation;
+ };
+ A6E8C1BA1404091B00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = D2AAC07E0554694100DB518D;
remoteInfo = CWFoundation;
};
- A609632413C7C192005E7E4B /* PBXContainerItemProxy */ = {
+ A6E8C1BC1404091B00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A6B254EE136BF9E700D5F57F;
remoteInfo = CWNetworkMonitor;
};
- A609632613C7C192005E7E4B /* PBXContainerItemProxy */ = {
+ A6E8C1BE1404091B00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A6ED914F13694AD8002DCEE4;
remoteInfo = UnitTests;
};
- A609632813C7C192005E7E4B /* PBXContainerItemProxy */ = {
+ A6E8C1C01404091B00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A6A971981369B2D80065D9BE;
remoteInfo = NetworkMonitorSampleApp;
};
- A609632A13C7C192005E7E4B /* PBXContainerItemProxy */ = {
+ A6E8C1C21404091B00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A6A971C41369B3C90065D9BE;
remoteInfo = XMLTranslatorSampleApp;
};
- A609632D13C7C19F005E7E4B /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = D2AAC07D0554694100DB518D;
- remoteInfo = CWFoundation;
- };
- A6DAA6E81383E51700518CC8 /* PBXContainerItemProxy */ = {
+ A6E8C1C4140409AA00C00910 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
- remoteGlobalIDString = D2AAC07D0554694100DB518D;
- remoteInfo = CWUIKit;
+ remoteGlobalIDString = A6E8C1A81404087C00C00910;
+ remoteInfo = CWUIKitEnsureDeps;
};
A6ED92C213695A85002DCEE4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -191,6 +232,17 @@
A65D9BE4137BD56B007D25A0 /* bar_button@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "bar_button@2x.png"; path = "Resources/bar_button@2x.png"; sourceTree = "<group>"; };
A65D9C05137BD9E3007D25A0 /* CWBackgroundBars.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = CWBackgroundBars.h; path = Classes/CWBackgroundBars.h; sourceTree = "<group>"; };
A65D9C06137BD9E3007D25A0 /* CWBackgroundBars.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = CWBackgroundBars.m; path = Classes/CWBackgroundBars.m; sourceTree = "<group>"; };
+ A691862D13E1B39F006F25AD /* CWCalendarView.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = CWCalendarView.h; path = Classes/CWCalendarView.h; sourceTree = "<group>"; };
+ A691862E13E1B39F006F25AD /* CWCalendarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWCalendarView.m; path = Classes/CWCalendarView.m; sourceTree = "<group>"; };
+ A691862F13E1B39F006F25AD /* CWViewSheet.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = CWViewSheet.h; path = Classes/CWViewSheet.h; sourceTree = "<group>"; };
+ A691863013E1B39F006F25AD /* CWViewSheet.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; name = CWViewSheet.m; path = Classes/CWViewSheet.m; sourceTree = "<group>"; };
+ A69186BA13E1B464006F25AD /* CalendarViewSheetSampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CalendarViewSheetSampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ A69186BC13E1B464006F25AD /* CalloutViewSampleApp-Info copy.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CalloutViewSampleApp-Info copy.plist"; sourceTree = "<group>"; };
+ A69186BE13E1B492006F25AD /* CalendarViewSheetSampleApp-Info.plist */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.plist.xml; path = "CalendarViewSheetSampleApp-Info.plist"; sourceTree = "<group>"; };
+ A69186BF13E1B492006F25AD /* main.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ A69186C013E1B492006F25AD /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
+ A69186C113E1B492006F25AD /* SampleAppAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = SampleAppAppDelegate.h; sourceTree = "<group>"; };
+ A69186C213E1B492006F25AD /* SampleAppAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = SampleAppAppDelegate.m; sourceTree = "<group>"; };
A6A42D55136988B00051E0C7 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
A6A97542136ABCA50065D9BE /* CWUIKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWUIKit.h; path = Classes/CWUIKit.h; sourceTree = "<group>"; };
A6DAA69C1383E36000518CC8 /* CWColumnTableView.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = CWColumnTableView.h; path = Classes/CWColumnTableView.h; sourceTree = "<group>"; };
@@ -252,6 +304,19 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
+ A69186B013E1B464006F25AD /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A69186B113E1B464006F25AD /* OpenGLES.framework in Frameworks */,
+ A69186B213E1B464006F25AD /* Foundation.framework in Frameworks */,
+ A69186B313E1B464006F25AD /* CoreGraphics.framework in Frameworks */,
+ A69186B413E1B464006F25AD /* QuartzCore.framework in Frameworks */,
+ A69186B513E1B464006F25AD /* UIKit.framework in Frameworks */,
+ A69186B613E1B464006F25AD /* libCWUIKit.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
A6DAA6BC1383E40F00518CC8 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -300,6 +365,7 @@
A6ED92B913695A43002DCEE4 /* CalloutViewSampleApp.app */,
A6ED92ED13695BD3002DCEE4 /* CWUIKitResources.bundle */,
A6DAA6BE1383E40F00518CC8 /* ColumnTableViewSampleApp.app */,
+ A69186BA13E1B464006F25AD /* CalendarViewSheetSampleApp.app */,
);
name = Products;
sourceTree = "<group>";
@@ -346,6 +412,8 @@
A6FF9FA11369A3FD0083F2EC /* UIAlertView+AuxiliaryAction.m */,
A65D9C05137BD9E3007D25A0 /* CWBackgroundBars.h */,
A65D9C06137BD9E3007D25A0 /* CWBackgroundBars.m */,
+ A691862D13E1B39F006F25AD /* CWCalendarView.h */,
+ A691862E13E1B39F006F25AD /* CWCalendarView.m */,
A6ED928A13695A14002DCEE4 /* CWCalloutView.h */,
A6ED928B13695A14002DCEE4 /* CWCalloutView.m */,
A6DAA69C1383E36000518CC8 /* CWColumnTableView.h */,
@@ -360,6 +428,8 @@
A6ED928F13695A14002DCEE4 /* CWPrimaryViewWindow.m */,
A65D9B5D137BC3EA007D25A0 /* CWStyledSegmentedControl.h */,
A65D9B5E137BC3EA007D25A0 /* CWStyledSegmentedControl.m */,
+ A691862F13E1B39F006F25AD /* CWViewSheet.h */,
+ A691863013E1B39F006F25AD /* CWViewSheet.m */,
A6ED929013695A14002DCEE4 /* NSObject+CWNibLocalizations.h */,
A6ED929113695A14002DCEE4 /* NSObject+CWNibLocalizations.m */,
A6DAAB1C13853C5800518CC8 /* UIApplication+CWAdditions.h */,
@@ -384,16 +454,17 @@
name = Classes;
sourceTree = "<group>";
};
- A609631B13C7C192005E7E4B /* Products */ = {
+ A69186BD13E1B492006F25AD /* CalendarViewSheet */ = {
isa = PBXGroup;
children = (
- A609632313C7C192005E7E4B /* libCWFoundation.a */,
- A609632513C7C192005E7E4B /* libCWNetworkMonitor.a */,
- A609632713C7C192005E7E4B /* UnitTests.octest */,
- A609632913C7C192005E7E4B /* NetworkMonitorSampleApp.app */,
- A609632B13C7C192005E7E4B /* XMLTranslatorSampleApp.app */,
+ A69186BE13E1B492006F25AD /* CalendarViewSheetSampleApp-Info.plist */,
+ A69186BF13E1B492006F25AD /* main.m */,
+ A69186C113E1B492006F25AD /* SampleAppAppDelegate.h */,
+ A69186C213E1B492006F25AD /* SampleAppAppDelegate.m */,
+ A69186C013E1B492006F25AD /* MainWindow.xib */,
);
- name = Products;
+ name = CalendarViewSheet;
+ path = "Sample Classes/CalendarViewSheet";
sourceTree = "<group>";
};
A6DAA6D91383E48C00518CC8 /* ColumnTableView */ = {
@@ -411,6 +482,18 @@
path = "Sample Classes/ColumnTableView";
sourceTree = "<group>";
};
+ A6E8C1B21404091B00C00910 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ A6E8C1BB1404091B00C00910 /* libCWFoundation.a */,
+ A6E8C1BD1404091B00C00910 /* libCWNetworkMonitor.a */,
+ A6E8C1BF1404091B00C00910 /* UnitTests.octest */,
+ A6E8C1C11404091B00C00910 /* NetworkMonitorSampleApp.app */,
+ A6E8C1C31404091B00C00910 /* XMLTranslatorSampleApp.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
A6ED90171369470A002DCEE4 /* Test Classes */ = {
isa = PBXGroup;
children = (
@@ -422,6 +505,7 @@
isa = PBXGroup;
children = (
A6DAA6D91383E48C00518CC8 /* ColumnTableView */,
+ A69186BD13E1B492006F25AD /* CalendarViewSheet */,
A6ED92AC13695A2A002DCEE4 /* CalloutView */,
);
name = "Sample Classes";
@@ -435,6 +519,7 @@
A6ED92B013695A2A002DCEE4 /* SampleAppAppDelegate.h */,
A6ED92B113695A2A002DCEE4 /* SampleAppAppDelegate.m */,
A6ED92AF13695A2A002DCEE4 /* MainWindow.xib */,
+ A69186BC13E1B464006F25AD /* CalloutViewSampleApp-Info copy.plist */,
);
name = CalloutView;
path = "Sample Classes/CalloutView";
@@ -494,12 +579,32 @@
A6DAAB1E13853C5800518CC8 /* UIApplication+CWAdditions.h in Headers */,
8B3096C51386662300EE9727 /* CWSearchBar.h in Headers */,
8B3096C71386662300EE9727 /* CWTextField.h in Headers */,
+ A691863113E1B39F006F25AD /* CWCalendarView.h in Headers */,
+ A691863313E1B39F006F25AD /* CWViewSheet.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
+ A69186A713E1B464006F25AD /* CalendarViewSheetSampleApp */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = A69186B713E1B464006F25AD /* Build configuration list for PBXNativeTarget "CalendarViewSheetSampleApp" */;
+ buildPhases = (
+ A69186AA13E1B464006F25AD /* Resources */,
+ A69186AD13E1B464006F25AD /* Sources */,
+ A69186B013E1B464006F25AD /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ A69186A813E1B464006F25AD /* PBXTargetDependency */,
+ );
+ name = CalendarViewSheetSampleApp;
+ productName = CalloutViewSampleApp;
+ productReference = A69186BA13E1B464006F25AD /* CalendarViewSheetSampleApp.app */;
+ productType = "com.apple.product-type.application";
+ };
A6DAA6BD1383E40F00518CC8 /* ColumnTableViewSampleApp */ = {
isa = PBXNativeTarget;
buildConfigurationList = A6DAA6C61383E41000518CC8 /* Build configuration list for PBXNativeTarget "ColumnTableViewSampleApp" */;
@@ -562,8 +667,9 @@
buildRules = (
);
dependencies = (
- A609632E13C7C19F005E7E4B /* PBXTargetDependency */,
+ A6E8C1C5140409AA00C00910 /* PBXTargetDependency */,
A6ED92FC13695C69002DCEE4 /* PBXTargetDependency */,
+ A6E879061404102800DFABA1 /* PBXTargetDependency */,
);
name = CWUIKit;
productName = CWUIKit;
@@ -575,8 +681,11 @@
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0410;
+ };
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CWUIKit" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -590,59 +699,69 @@
projectDirPath = "";
projectReferences = (
{
- ProductGroup = A609631B13C7C192005E7E4B /* Products */;
+ ProductGroup = A6E8C1B21404091B00C00910 /* Products */;
ProjectRef = A6ED9279136959A8002DCEE4 /* CWFoundation.xcodeproj */;
},
);
projectRoot = "";
targets = (
+ A6E8C1A81404087C00C00910 /* CWUIKitEnsureDeps */,
A6ED92EC13695BD3002DCEE4 /* CWUIKitResources */,
D2AAC07D0554694100DB518D /* CWUIKit */,
A6ED92B813695A43002DCEE4 /* CalloutViewSampleApp */,
+ A69186A713E1B464006F25AD /* CalendarViewSheetSampleApp */,
A6DAA6BD1383E40F00518CC8 /* ColumnTableViewSampleApp */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
- A609632313C7C192005E7E4B /* libCWFoundation.a */ = {
+ A6E8C1BB1404091B00C00910 /* libCWFoundation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libCWFoundation.a;
- remoteRef = A609632213C7C192005E7E4B /* PBXContainerItemProxy */;
+ remoteRef = A6E8C1BA1404091B00C00910 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- A609632513C7C192005E7E4B /* libCWNetworkMonitor.a */ = {
+ A6E8C1BD1404091B00C00910 /* libCWNetworkMonitor.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libCWNetworkMonitor.a;
- remoteRef = A609632413C7C192005E7E4B /* PBXContainerItemProxy */;
+ remoteRef = A6E8C1BC1404091B00C00910 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- A609632713C7C192005E7E4B /* UnitTests.octest */ = {
+ A6E8C1BF1404091B00C00910 /* UnitTests.octest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = UnitTests.octest;
- remoteRef = A609632613C7C192005E7E4B /* PBXContainerItemProxy */;
+ remoteRef = A6E8C1BE1404091B00C00910 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- A609632913C7C192005E7E4B /* NetworkMonitorSampleApp.app */ = {
+ A6E8C1C11404091B00C00910 /* NetworkMonitorSampleApp.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = NetworkMonitorSampleApp.app;
- remoteRef = A609632813C7C192005E7E4B /* PBXContainerItemProxy */;
+ remoteRef = A6E8C1C01404091B00C00910 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
- A609632B13C7C192005E7E4B /* XMLTranslatorSampleApp.app */ = {
+ A6E8C1C31404091B00C00910 /* XMLTranslatorSampleApp.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = XMLTranslatorSampleApp.app;
- remoteRef = A609632A13C7C192005E7E4B /* PBXContainerItemProxy */;
+ remoteRef = A6E8C1C21404091B00C00910 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
+ A69186AA13E1B464006F25AD /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A69186C513E1B492006F25AD /* MainWindow.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
A6DAA6BA1383E40F00518CC8 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -685,7 +804,32 @@
};
/* End PBXResourcesBuildPhase section */
+/* Begin PBXShellScriptBuildPhase section */
+ A6E8C1AC140408C500C00910 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "ruby Scripts/ensdep.rb git@github.com:jayway/CWFoundation.git";
+ };
+/* End PBXShellScriptBuildPhase section */
+
/* Begin PBXSourcesBuildPhase section */
+ A69186AD13E1B464006F25AD /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A69186C413E1B492006F25AD /* main.m in Sources */,
+ A69186C613E1B492006F25AD /* SampleAppAppDelegate.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
A6DAA6BB1383E40F00518CC8 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -732,22 +876,34 @@
A6DAAB1F13853C5800518CC8 /* UIApplication+CWAdditions.m in Sources */,
8B3096C61386662300EE9727 /* CWSearchBar.m in Sources */,
8B3096C81386662300EE9727 /* CWTextField.m in Sources */,
+ A691863213E1B39F006F25AD /* CWCalendarView.m in Sources */,
+ A691863413E1B39F006F25AD /* CWViewSheet.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
- A609632E13C7C19F005E7E4B /* PBXTargetDependency */ = {
+ A69186A813E1B464006F25AD /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
- name = CWFoundation;
- targetProxy = A609632D13C7C19F005E7E4B /* PBXContainerItemProxy */;
+ target = D2AAC07D0554694100DB518D /* CWUIKit */;
+ targetProxy = A69186A913E1B464006F25AD /* PBXContainerItemProxy */;
};
A6DAA6E91383E51700518CC8 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D2AAC07D0554694100DB518D /* CWUIKit */;
targetProxy = A6DAA6E81383E51700518CC8 /* PBXContainerItemProxy */;
};
+ A6E879061404102800DFABA1 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = CWFoundation;
+ targetProxy = A6E879051404102800DFABA1 /* PBXContainerItemProxy */;
+ };
+ A6E8C1C5140409AA00C00910 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = A6E8C1A81404087C00C00910 /* CWUIKitEnsureDeps */;
+ targetProxy = A6E8C1C4140409AA00C00910 /* PBXContainerItemProxy */;
+ };
A6ED92C313695A85002DCEE4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D2AAC07D0554694100DB518D /* CWUIKit */;
@@ -764,8 +920,13 @@
1DEB921F08733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/CWUIKit.dst;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = CWUIKit;
@@ -775,7 +936,10 @@
1DEB922008733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
DSTROOT = /tmp/CWUIKit.dst;
+ GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
INSTALL_PATH = /usr/local/lib;
PRODUCT_NAME = CWUIKit;
@@ -786,18 +950,18 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
- COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
);
- PREBINDING = NO;
+ RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
- USER_HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/**";
+ USER_HEADER_SEARCH_PATHS = "../**";
};
name = Debug;
};
@@ -806,23 +970,76 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
);
- PREBINDING = NO;
+ RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
- USER_HEADER_SEARCH_PATHS = "$(BUILT_PRODUCTS_DIR)/**";
+ USER_HEADER_SEARCH_PATHS = "../**";
+ };
+ name = Release;
+ };
+ A69186B813E1B464006F25AD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
+ INFOPLIST_FILE = "Sample Classes/CalendarViewSheet/CalendarViewSheetSampleApp-Info.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-all_load",
+ "-framework",
+ Foundation,
+ "-framework",
+ UIKit,
+ );
+ PRODUCT_NAME = CalendarViewSheetSampleApp;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ A69186B913E1B464006F25AD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
+ INFOPLIST_FILE = "CalloutViewSampleApp-Info copy.plist";
+ INSTALL_PATH = "$(HOME)/Applications";
+ OTHER_LDFLAGS = (
+ "-all_load",
+ "-framework",
+ Foundation,
+ "-framework",
+ UIKit,
+ );
+ PRODUCT_NAME = CalloutViewSampleApp;
+ SDKROOT = iphoneos;
+ ZERO_LINK = NO;
};
name = Release;
};
A6DAA6C11383E41000518CC8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "Sample Classes/ColumnTableView/ColumnTableViewSampleApp-Info.plist";
@@ -834,6 +1051,7 @@
UIKit,
);
PRODUCT_NAME = ColumnTableViewSampleApp;
+ SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -841,8 +1059,10 @@
A6DAA6C21383E41000518CC8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "Sample Classes/ColumnTableView/ColumnTableViewSampleApp-Info.plist";
@@ -854,14 +1074,34 @@
UIKit,
);
PRODUCT_NAME = ColumnTableViewSampleApp;
+ SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
+ ZERO_LINK = NO;
+ };
+ name = Release;
+ };
+ A6E8C1AA1404087C00C00910 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ A6E8C1AB1404087C00C00910 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
A6ED92BC13695A44002DCEE4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "Sample Classes/CalloutView/CalloutViewSampleApp-Info.plist";
@@ -874,14 +1114,17 @@
UIKit,
);
PRODUCT_NAME = CalloutViewSampleApp;
+ SDKROOT = iphoneos;
};
name = Debug;
};
A6ED92BD13695A44002DCEE4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "Sample Classes/CalloutView/CalloutViewSampleApp-Info.plist";
@@ -894,13 +1137,19 @@
UIKit,
);
PRODUCT_NAME = CalloutViewSampleApp;
+ SDKROOT = iphoneos;
+ ZERO_LINK = NO;
};
name = Release;
};
A6ED92EF13695BD3002DCEE4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
INSTALL_PATH = "$(HOME)/Library/Bundles";
PRODUCT_NAME = CWUIKitResources;
WRAPPER_EXTENSION = bundle;
@@ -910,10 +1159,13 @@
A6ED92F013695BD3002DCEE4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ COPY_PHASE_STRIP = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
INSTALL_PATH = "$(HOME)/Library/Bundles";
PRODUCT_NAME = CWUIKitResources;
WRAPPER_EXTENSION = bundle;
+ ZERO_LINK = NO;
};
name = Release;
};
@@ -938,6 +1190,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ A69186B713E1B464006F25AD /* Build configuration list for PBXNativeTarget "CalendarViewSheetSampleApp" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A69186B813E1B464006F25AD /* Debug */,
+ A69186B913E1B464006F25AD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
A6DAA6C61383E41000518CC8 /* Build configuration list for PBXNativeTarget "ColumnTableViewSampleApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -947,6 +1208,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ A6E8C1A91404087C00C00910 /* Build configuration list for PBXAggregateTarget "CWUIKitEnsureDeps" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A6E8C1AA1404087C00C00910 /* Debug */,
+ A6E8C1AB1404087C00C00910 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
A6ED92BE13695A44002DCEE4 /* Build configuration list for PBXNativeTarget "CalloutViewSampleApp" */ = {
isa = XCConfigurationList;
buildConfigurations = (
View
133 Classes/CWCalendarView.h
@@ -0,0 +1,133 @@
+//
+// CWCalendarView.h
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol CWCalendarViewDelegate;
+
+/*!
+ * @abstract A calendar view close to the Calendar app in visual appearance.
+ *
+ * @discussion Supports selection with date validation, and annotation markers.
+ * Programatically setting selectedDate will not update currentMonthDate.
+ * CWCalendarView expects a 320x308 size.
+ */
+@interface CWCalendarView : UIView {
+@private
+ id<CWCalendarViewDelegate> _delegate;
+ NSDate* _selectedDate;
+ NSDate* _currentMonthDate;
+ NSDate* _maximumDate;
+ NSDate* _minimumDate;
+ NSCalendar* _calendar;
+ NSDate* currentTopLeftDate;
+ struct {
+ unsigned int delegateCanSelect:1;
+ unsigned int delegateHasAnnotation:1;
+ unsigned int delegateWillSelect:1;
+ unsigned int delegateDidSelect:1;
+ } flags;
+}
+
+/*!
+ * @abstract The calendar delegate.
+ */
+@property(nonatomic, assign) IBOutlet id<CWCalendarViewDelegate> delegate;
+
+/*!
+ * @abstract The date currently selected, or nil of no selection.
+ */
+@property(nonatomic, copy) NSDate* selectedDate;
+
+/*!
+ * @abstract The first day of the month to display.
+ * @discussion Truncated to first day of month when set.
+ * If nil it will reset to selectedDate if it exist, otherwise
+ * is restes to the current month.
+ */
+@property(nonatomic, copy) NSDate* currentMonthDate;
+
+/*!
+ * @abstract Minimum date to display and allow selection for.
+ * @discussion Truncated to a day.
+ */
+@property(nonatomic, copy) NSDate* maximumDate;
+
+/*!
+ * @abstract Maximum date to display and allow selection for.
+ * @discussion Truncated to a day.
+ */
+@property(nonatomic, copy) NSDate* minimumDate;
+
+/*!
+ * @abstract The calendar to use for the calendar view.
+ * @abstract Default is the current calendar, it is not safe to change the
+ * calendar after the view has been drawn to screen.
+ */
+@property(nonatomic, retain) NSCalendar* calendar;
+
+@end
+
+
+/*!
+ * @abstract The delegate for a CWCalendarView must adopt this protocol.
+ */
+@protocol CWCalendarViewDelegate <NSObject>
+@optional
+
+/*!
+ * @abstract Query if a date can be selected.
+ * @discussion Dates beyound minimim and maximum dates, if set, will not be queried.
+ */
+-(BOOL)calendarView:(CWCalendarView*)view canSelectDate:(NSDate*)date;
+
+/*!
+ * @abstract Query if a date has annotations, and should be drawn with a dot.
+ */
+-(BOOL)calendarView:(CWCalendarView *)view hasAnnotationForDate:(NSDate *)date;
+
+/*!
+ * @abstract Inform the delegate of a date selection change by the user.
+ * @discussion Return the date to allow the selection, nil to cancel the selection,
+ * or a new date to change the selection.
+ */
+-(NSDate*)calendarView:(CWCalendarView*)view willSelectDate:(NSDate*)date;
+
+/*!
+ * @abstract Inform the delegate of a date selection change by the user.
+ */
+-(void)calendarView:(CWCalendarView*)view didSelectDate:(NSDate*)date;
+
+/*!
+ * @abstract The designated initializer, initializing with a 320x308 frame.
+ */
+-(id)init;
+
+@end
View
638 Classes/CWCalendarView.m
@@ -0,0 +1,638 @@
+//
+// CWCalendarView.m
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import "CWCalendarView.h"
+#import <QuartzCore/QuartzCore.h>
+#import "NSCalendar+CWAdditions.h"
+
+@implementation CWCalendarView
+
+#pragma mark -
+#pragma mark Properties
+
+-(void)setDelegate:(id<CWCalendarViewDelegate>)delegate;
+{
+ flags.delegateCanSelect = [delegate respondsToSelector:@selector(calendarView:canSelectDate:)];
+ flags.delegateHasAnnotation = [delegate respondsToSelector:@selector(calendarView:hasAnnotationForDate:)];
+ flags.delegateWillSelect = [delegate respondsToSelector:@selector(calendarView:willSelectDate:)];
+ flags.delegateDidSelect = [delegate respondsToSelector:@selector(calendarView:didSelectDate:)];
+ _delegate = delegate;
+}
+
+-(void)setSelectedDate:(NSDate *)selectedDate;
+{
+ if (![_selectedDate isEqualToDate:selectedDate]) {
+ [_selectedDate autorelease];
+ _selectedDate = [selectedDate copy];
+ [self setNeedsDisplay];
+ }
+}
+
+-(NSDate*)currentMonthDate;
+{
+ if (_currentMonthDate == nil) {
+ if (_selectedDate) {
+ self.currentMonthDate = _selectedDate;
+ } else {
+ self.currentMonthDate = [[[NSDate date] laterDate:_minimumDate] earlierDate:_maximumDate];
+ }
+ }
+ return _currentMonthDate;
+}
+
+-(void)setCurrentMonthDate:(NSDate *)date;
+{
+ if (![_currentMonthDate isEqualToDate:date]) {
+ [_currentMonthDate autorelease];
+ _currentMonthDate = [[self.calendar truncateDate:date
+ toCalendarUnit:NSMonthCalendarUnit] retain];
+ [currentTopLeftDate release], currentTopLeftDate = nil;
+ [self setNeedsDisplay];
+ }
+ if (currentTopLeftDate == nil) {
+ NSDateComponents* currentMonthComponents = [self.calendar components:NSWeekdayCalendarUnit
+ fromDate:_currentMonthDate];
+ NSUInteger firstWeekDay = [self.calendar firstWeekday];
+ NSInteger firstMonthViewDayOffset = [currentMonthComponents weekday] - firstWeekDay;
+ while (firstMonthViewDayOffset < 0) {
+ firstMonthViewDayOffset += 7;
+ }
+ NSDateComponents* dateOffset = [[[NSDateComponents alloc] init] autorelease];
+ [dateOffset setDay:-firstMonthViewDayOffset];
+ currentTopLeftDate = [[self.calendar dateByAddingComponents:dateOffset
+ toDate:_currentMonthDate
+ options:0] retain];
+ }
+}
+
+-(void)setMinimumDate:(NSDate *)date;
+{
+ [_minimumDate autorelease];
+ _minimumDate = [[self.calendar truncateDate:date
+ toCalendarUnit:NSDayCalendarUnit] retain];
+ [self setNeedsDisplay];
+}
+
+-(void)setMaximumDate:(NSDate *)date;
+{
+ [_maximumDate autorelease];
+ _maximumDate = [[self.calendar truncateDate:date
+ toCalendarUnit:NSDayCalendarUnit] retain];
+ [self setNeedsDisplay];
+}
+
+@synthesize delegate = _delegate;
+@synthesize selectedDate = _selectedDate;
+@synthesize currentMonthDate = _currentMonthDate;
+@synthesize maximumDate = _maximumDate;
+@synthesize minimumDate = _minimumDate;
+@synthesize calendar = _calendar;
+
+#pragma mark -
+#pragma mark Instance life cycle
+
+-(void)primitiveInit;
+{
+ _calendar = [[NSCalendar currentCalendar] retain];
+ UITapGestureRecognizer* tap = [[[UITapGestureRecognizer alloc] initWithTarget:self
+ action:@selector(handleTapGesture:)] autorelease];
+ [self addGestureRecognizer:tap];
+}
+
+-(id)init;
+{
+ return [self initWithFrame:CGRectMake(0, 0, 320, 308)];
+}
+
+- (id)initWithFrame:(CGRect)frame
+{
+ frame.size = CGSizeMake(320, 44 * 7);
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self primitiveInit];
+ }
+ return self;
+}
+
+-(id)initWithCoder:(NSCoder *)aDecoder;
+{
+ self = [super initWithCoder:aDecoder];
+ if (self) {
+ [self primitiveInit];
+ CGRect bounds = self.bounds;
+ bounds.size = CGSizeMake(320, 44 * 7);
+ self.bounds = bounds;
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [_selectedDate release];
+ [_currentMonthDate release];
+ [_maximumDate release];
+ [_minimumDate release];
+ [_calendar release];
+ [currentTopLeftDate release];
+ [super dealloc];
+}
+
+#pragma mark -
+#pragma mark Helper methods
+
+-(BOOL)canGotoPreviousMonth;
+{
+ return [_minimumDate compare:self.currentMonthDate] != NSOrderedDescending;
+}
+
+-(BOOL)canGotoNextMonth;
+{
+ if (_maximumDate) {
+ NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
+ [components setMonth:1];
+ NSDate* nextMonthDate = [self.calendar dateByAddingComponents:components
+ toDate:self.currentMonthDate
+ options:0];
+ return [_maximumDate compare:nextMonthDate] != NSOrderedAscending;
+ }
+ return YES;
+}
+
+-(BOOL)canSelectDate:(NSDate*)date;
+{
+ BOOL canSelectDate = [_minimumDate compare:date] != NSOrderedDescending && [_maximumDate compare:date] != NSOrderedAscending;
+ if (canSelectDate && flags.delegateCanSelect) {
+ canSelectDate = [self.delegate calendarView:self canSelectDate:date];
+ }
+ return canSelectDate;
+}
+
+-(NSDate*)dateForRow:(NSInteger)row column:(NSInteger)col;
+{
+ NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
+ [components setDay:row * 7 + col];
+ return [self.calendar dateByAddingComponents:components
+ toDate:currentTopLeftDate
+ options:0];
+}
+
+#pragma mark -
+#pragma mark - Cached drawing primitives
+
+#define CWStaticColor(name, color) -(UIColor*)name{static UIColor*c=nil;if(c==nil)c=[(color)retain];return c;}
+
+CWStaticColor(cellBackgroundColor, [UIColor colorWithRed:0.87f green:0.87f blue:0.89f alpha:1])
+CWStaticColor(disabledCellBackgroundColor, [UIColor colorWithRed:0.80f green:0.75f blue:0.74f alpha:1])
+CWStaticColor(lightCellBorderColor, [UIColor colorWithWhite:0.92f alpha:1])
+CWStaticColor(darkCellBorderColor, [UIColor colorWithWhite:0.63f alpha:1])
+CWStaticColor(lightDisabledCellBorderColor, [UIColor colorWithRed:0.92f green:0.90f blue:0.89f alpha:1])
+CWStaticColor(darkDisabledCellBorderColor, [UIColor colorWithRed:0.63f green:0.61f blue:0.60f alpha:1])
+CWStaticColor(currentSelectedCellBackgroundColor, [UIColor colorWithRed:0.04f green:0.19f blue:0.57f alpha:1])
+CWStaticColor(currentCellBackgroundColor, [UIColor colorWithRed:0.15f green:0.25f blue:0.38f alpha:1])
+CWStaticColor(currentSelectedCellFillColor, [UIColor colorWithRed:0.10f green:0.50f blue:0.90f alpha:0.2f])
+CWStaticColor(currentCellFillColor, [UIColor colorWithRed:0.45f green:0.54f blue:0.65f alpha:0.2f])
+CWStaticColor(selectedCellBorder, [UIColor colorWithRed:0.16f green:0.21f blue:0.28f alpha:1])
+
+CWStaticColor(textColor, [UIColor colorWithRed:0.24f green:0.29f blue:0.35f alpha:1]);
+CWStaticColor(textHighlightColor, [UIColor whiteColor])
+CWStaticColor(disabledTextColor, [UIColor colorWithRed:0.57f green:0.59f blue:0.63f alpha:1])
+CWStaticColor(disabledTextHighlightColor, [UIColor colorWithWhite:0.9f alpha:1])
+CWStaticColor(selectedTextColor, [UIColor whiteColor])
+CWStaticColor(selectedTextHighlightColor, [UIColor colorWithWhite:0.10f alpha:1])
+CWStaticColor(dimmedCurrentTextColor, [UIColor colorWithRed:0.57f green:0.60f blue:0.63f alpha:1])
+CWStaticColor(dimmedSelectedTextColor, [UIColor colorWithRed:0.78f green:0.80f blue:0.82f alpha:1])
+CWStaticColor(invalidTextColor, [UIColor colorWithRed:0.43f green:0.44f blue:0.46f alpha:1])
+CWStaticColor(dimmedInvalidTextColor, [UIColor colorWithRed:0.63f green:0.59f blue:0.57f alpha:1])
+
+
+-(CGGradientRef)headerGradient;
+{
+ static CGGradientRef g = NULL;
+ if (g == NULL) {
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ NSArray* colors = [NSArray arrayWithObjects:
+ (id)[UIColor colorWithRed:0.96f green:0.96f blue:0.97f alpha:1].CGColor,
+ (id)[UIColor colorWithRed:0.80f green:0.80f blue:0.82f alpha:1].CGColor,
+ nil];
+ g = CGGradientCreateWithColors(space, (CFArrayRef)colors, (CGFloat[4]){0.f, 1.f});
+ CGColorSpaceRelease(space);
+ }
+ return g;
+}
+
+-(CGGradientRef)selectedCellGradient;
+{
+ static CGGradientRef g = NULL;
+ if (g == NULL) {
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ NSArray* colors = [NSArray arrayWithObjects:
+ (id)[UIColor colorWithRed:0.74f green:0.85f blue:0.97f alpha:1].CGColor,
+ (id)[UIColor colorWithRed:0.45f green:0.69f blue:0.94f alpha:1].CGColor,
+ (id)[UIColor colorWithRed:0.17f green:0.54f blue:0.91f alpha:1].CGColor,
+ (id)[UIColor colorWithRed:0.00f green:0.45f blue:0.89f alpha:1].CGColor,
+ nil];
+ g = CGGradientCreateWithColors(space, (CFArrayRef)colors, (CGFloat[4]){0.02f, 0.06f, 0.5f, 0.51f});
+ CGColorSpaceRelease(space);
+ }
+ return g;
+}
+
+-(NSDateFormatter*)dateFormatterWithFormat:(NSString*)format;
+{
+ static NSMutableDictionary* fs = nil;
+ NSDateFormatter* f = [fs objectForKey:format];
+ if (f == nil) {
+ f = [[[NSDateFormatter alloc] init] autorelease];
+ [f setDateFormat:format];
+ if (fs == nil) {
+ fs = [[NSMutableDictionary alloc] initWithCapacity:4];
+ }
+ [fs setObject:f forKey:format];
+ }
+ return f;
+}
+
+#pragma mark -
+#pragma mark Drawing methods
+
+-(void)drawHeaderBackgroundInRect:(CGRect)rect;
+{
+ // Draw background
+ CGContextRef c = UIGraphicsGetCurrentContext();
+ CGContextSaveGState(c);
+ CGContextClipToRect(c, rect);
+ CGContextDrawLinearGradient(c, [self headerGradient], rect.origin, CGPointMake(rect.origin.x, rect.origin.y + rect.size.height), 0);
+ CGContextRestoreGState(c);
+ [[self darkCellBorderColor] set];
+ [[UIBezierPath bezierPathWithRect:UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(-1, -1, 0.5f, -1))] stroke];
+
+}
+
+-(void)drawHeaderTitleInRect:(CGRect)rect;
+{
+ NSDateFormatter* formatter = [self dateFormatterWithFormat:@"MMM yyyy"];
+ NSString* month = [formatter stringFromDate:self.currentMonthDate];
+ CGRect monthRect = UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(4, 0, 10, 0));
+ UIFont* font = [UIFont boldSystemFontOfSize:20];
+ [[self textHighlightColor] set];
+ [month drawInRect:monthRect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ [[self textColor] set];
+ monthRect.origin.y--;
+ [month drawInRect:monthRect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+}
+
+-(void)drawHeaderDayColumnTitles;
+{
+ NSDateFormatter* formatter = [self dateFormatterWithFormat:@"EEE"];
+ UIFont* font = [UIFont boldSystemFontOfSize:10];
+ for (int col = 0; col < 7; col++) {
+ NSDate* date = [self dateForRow:0 column:col];
+ NSString* weekday = [formatter stringFromDate:date];
+ CGRect dayRect = CGRectMake(col * 46 - 1, 30, 46, 14);
+ [[self textHighlightColor] set];
+ [weekday drawInRect:dayRect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ [[self textColor] set];
+ dayRect.origin.y--;
+ [weekday drawInRect:dayRect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ }
+}
+
+-(void)drawHeaderNavigationArrows;
+{
+ UIBezierPath* prevPath = [UIBezierPath bezierPath];
+ [prevPath moveToPoint:CGPointMake(18, 14.5f)];
+ [prevPath addLineToPoint:CGPointMake(29, 7.5f)];
+ [prevPath addLineToPoint:CGPointMake(29, 21.5f)];
+ [prevPath closePath];
+ UIBezierPath* nextPath = [[prevPath copy] autorelease];
+ [nextPath applyTransform:CGAffineTransformTranslate(CGAffineTransformMakeScale(-1, 1), -320, 0)];
+
+ [[self textHighlightColor] setFill];
+ [prevPath fill];
+ [nextPath fill];
+
+ [prevPath applyTransform:CGAffineTransformMakeTranslation(0, -1)];
+ if ([self canGotoPreviousMonth]) {
+ [[self textColor] setFill];
+ } else {
+ [[self disabledTextColor] set];
+ }
+ [prevPath fill];
+ if ([self canGotoNextMonth]) {
+ [[self textColor] setFill];
+ } else {
+ [[self disabledTextColor] set];
+ }
+ [nextPath applyTransform:CGAffineTransformMakeTranslation(0, -1)];
+ [nextPath fill];
+}
+
+-(void)drawHeaderInRect:(CGRect)rect;
+{
+ [self drawHeaderBackgroundInRect: rect];
+ [self drawHeaderTitleInRect: rect];
+ [self drawHeaderDayColumnTitles];
+ [self drawHeaderNavigationArrows];
+}
+
+- (void)drawCurrentCellBackgroundInRect:(CGRect)rect isSelectedDate:(BOOL)isSelectedDate;
+{
+ if (isSelectedDate) {
+ [[self currentSelectedCellBackgroundColor] setFill];
+ } else {
+ [[self currentCellBackgroundColor] setFill];
+ }
+ [[UIBezierPath bezierPathWithRect:rect] fill];
+ if (isSelectedDate) {
+ [[self currentSelectedCellFillColor] setFill];
+ } else {
+ [[self currentCellFillColor] setFill];
+ }
+ for (CGFloat i = 0.0f; i < 5.0f; i += 0.5f) {
+ CGRect insetRect = UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(i, i, i, i));
+ [[UIBezierPath bezierPathWithRoundedRect:insetRect
+ cornerRadius:1.0f] fill];
+ }
+}
+
+-(void)drawCellBackgroundInRect:(CGRect)rect canSelectDate:(BOOL)canSelectDate isSelectedDate:(BOOL)isSelectedDate
+{
+ if (isSelectedDate) {
+ CGContextRef c = UIGraphicsGetCurrentContext();
+ CGContextSaveGState(c);
+ CGContextClipToRect(c, rect);
+ CGContextDrawLinearGradient(c, [self selectedCellGradient], rect.origin, CGPointMake(rect.origin.x, rect.origin.y + rect.size.height), 0);
+ CGContextRestoreGState(c);
+ CGRect insetRect = UIEdgeInsetsInsetRect(rect, UIEdgeInsetsMake(0.5f, 0.5f, 0.5f, 0.5f));
+ [[self selectedCellBorder] set];
+ [[UIBezierPath bezierPathWithRect:insetRect] stroke];
+ } else {
+ if (canSelectDate) {
+ [[self cellBackgroundColor] setFill];
+ } else {
+ [[self disabledCellBackgroundColor] setFill];
+ }
+ [[UIBezierPath bezierPathWithRect:rect] fill];
+ UIBezierPath* path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(rect.origin.x + 0.5f, rect.origin.y + 0.5f)];
+ [path addLineToPoint:CGPointMake((rect.origin.x + rect.size.width) - 0.5f , rect.origin.y + 0.5f)];
+ [path addLineToPoint:CGPointMake((rect.origin.x + rect.size.width) - 0.5f , (rect.origin.y + rect.size.height) - 0.5f)];
+ if (canSelectDate) {
+ [[self lightCellBorderColor] set];
+ } else {
+ [[self lightDisabledCellBorderColor] set];
+ }
+ [path stroke];
+ path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(rect.origin.x + 0.5f, rect.origin.y + 0.5f)];
+ [path addLineToPoint:CGPointMake(rect.origin.x + 0.5f , (rect.origin.y + rect.size.height) - 0.5f)];
+ [path addLineToPoint:CGPointMake((rect.origin.x + rect.size.width) - 0.5f , (rect.origin.y + rect.size.height) - 0.5f)];
+ if (canSelectDate) {
+ [[self darkCellBorderColor] set];
+ } else {
+ [[self darkDisabledCellBorderColor] set];
+ }
+ [path stroke];
+ }
+}
+
+-(void)drawCellText:(NSString*)day inRect:(CGRect)rect isSameMonth:(BOOL)isSameMonth canSelectDate:(BOOL)canSelectDate isSelectedDate:(BOOL)isSelectedDate isCurrentDate:(BOOL)isCurrentDate hasAnnotation:(BOOL)hasAnnotation;
+{
+ UIFont* font = [UIFont boldSystemFontOfSize:24];
+ UIFont* annotationFont = hasAnnotation ? [UIFont boldSystemFontOfSize:16] : nil;
+ if (isCurrentDate || isSelectedDate) {
+ [[self selectedTextHighlightColor] set];
+ } else {
+ if (canSelectDate) {
+ [[self textHighlightColor] set];
+ } else {
+ [[self disabledTextHighlightColor] set];
+ }
+ }
+ rect.origin.y += (!isCurrentDate && isSelectedDate) ? 4 : 6;
+ [day drawInRect:rect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ if (hasAnnotation) {
+ CGRect annotationRect = rect;
+ annotationRect.origin.y += 19;
+ annotationRect.origin.x += 1;
+ [@"" drawInRect:annotationRect
+ withFont:annotationFont
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ }
+ if (!isCurrentDate && isSelectedDate) {
+ rect.origin.y++;
+ } else {
+ rect.origin.y--;
+ }
+ if (canSelectDate && isSameMonth) {
+ if (isCurrentDate || isSelectedDate) {
+ [[self selectedTextColor] set];
+ } else {
+ [[self textColor] set];
+ }
+ } else {
+ if (isCurrentDate) {
+ [[self dimmedCurrentTextColor] set];
+ } else if (isSelectedDate) {
+ [[self dimmedSelectedTextColor] set];
+ } else {
+ if (canSelectDate) {
+ [[self disabledTextColor] set];
+ } else {
+ if (isSameMonth) {
+ [[self invalidTextColor] set];
+ } else {
+ [[self dimmedInvalidTextColor] set];
+ }
+ }
+ }
+ }
+ [day drawInRect:rect
+ withFont:font
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ if (hasAnnotation) {
+ CGRect annotationRect = rect;
+ annotationRect.origin.y += 19;
+ annotationRect.origin.x += 1;
+ [@"" drawInRect:annotationRect
+ withFont:annotationFont
+ lineBreakMode:UILineBreakModeMiddleTruncation
+ alignment:UITextAlignmentCenter];
+ }
+}
+
+-(void)drawCellForDate:(NSDate*)date inRect:(CGRect)rect;
+{
+ BOOL isSameMonth = [self.calendar compareDate:date
+ toDate:self.currentMonthDate
+ withCalendarUnitPrecision:NSMonthCalendarUnit] == NSOrderedSame;
+ BOOL canSelectDate = [self canSelectDate:date];
+ BOOL isSelectedDate = [self.calendar compareDate:date
+ toDate:self.selectedDate
+ withCalendarUnitPrecision:NSDayCalendarUnit] == NSOrderedSame;
+ BOOL isCurrentDate = [self.calendar compareDate:date
+ toDate:[NSDate date]
+ withCalendarUnitPrecision:NSDayCalendarUnit] == NSOrderedSame;
+ BOOL hasAnnotation = flags.delegateHasAnnotation ? [self.delegate calendarView:self hasAnnotationForDate:date] : NO;
+
+ if (isCurrentDate) {
+ [self drawCurrentCellBackgroundInRect:rect
+ isSelectedDate:isSelectedDate];
+ } else {
+ [self drawCellBackgroundInRect:rect
+ canSelectDate:canSelectDate
+ isSelectedDate:isSelectedDate];
+ }
+
+ NSDateComponents* components = [self.calendar components:NSDayCalendarUnit fromDate:date];
+ NSString* day = [NSString stringWithFormat:@"%d", [components day]];
+ [self drawCellText:day
+ inRect:rect
+ isSameMonth:isSameMonth
+ canSelectDate:canSelectDate
+ isSelectedDate:isSelectedDate
+ isCurrentDate:isCurrentDate
+ hasAnnotation:hasAnnotation];
+}
+
+-(CGRect)rectForCellAtRow:(NSInteger)row column:(NSInteger)col;
+{
+ return CGRectMake((46 * col) - 1, 44 * (row + 1), 46, 44);
+}
+
+-(void)drawSelectedDateCornerMarkersIfNeeded;
+{
+ if (_selectedDate == nil) {
+ return;
+ }
+ if ([_selectedDate compare:currentTopLeftDate] == NSOrderedAscending) {
+ UIBezierPath* path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(0, 44)];
+ [path addLineToPoint:CGPointMake(15, 44)];
+ [path addLineToPoint:CGPointMake(0, 44 + 15)];
+ [path closePath];
+ [path addClip];
+ [self drawCellBackgroundInRect:[self rectForCellAtRow:0 column:0]
+ canSelectDate:YES
+ isSelectedDate:YES];
+ [path stroke];
+ } else {
+ NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
+ [components setDay:7 * 6];
+ NSDate* nextTopLeftDate = [self.calendar dateByAddingComponents:components toDate:currentTopLeftDate options:0];
+ if ([_selectedDate compare:nextTopLeftDate] != NSOrderedAscending) {
+ UIBezierPath* path = [UIBezierPath bezierPath];
+ [path moveToPoint:CGPointMake(320, 44 * 7)];
+ [path addLineToPoint:CGPointMake(320 - 15, 44 * 7)];
+ [path addLineToPoint:CGPointMake(320, 44 * 7 - 15)];
+ [path closePath];
+ [path addClip];
+ [self drawCellBackgroundInRect:[self rectForCellAtRow:5 column:6]
+ canSelectDate:YES
+ isSelectedDate:YES];
+ [path stroke];
+ }
+ }
+}
+
+-(void)drawRect:(CGRect)rect;
+{
+ CGRect headerRect = rect;
+ headerRect.size.height = 44;
+ [self drawHeaderInRect:headerRect];
+ for (NSInteger row = 0; row < 7; row++) {
+ for (NSInteger col = 0; col < 7; col++) {
+ NSDate* date = [self dateForRow:row column:col];
+ CGRect rect = [self rectForCellAtRow:row column:col];
+ [self drawCellForDate:date inRect:rect];
+ }
+ }
+ [self drawSelectedDateCornerMarkersIfNeeded];
+}
+
+
+#pragma mark -
+#pragma mark Handle selections
+
+-(void)handleTapGesture:(UITapGestureRecognizer*)tap;
+{
+ CGPoint location = [tap locationInView:self];
+ if (location.y < 44) {
+ if (location.x < 50 && [self canGotoPreviousMonth]) {
+ NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
+ [components setMonth:-1];
+ self.currentMonthDate = [self.calendar dateByAddingComponents:components
+ toDate:self.currentMonthDate
+ options:0];
+ } else if (location.x > 270 && [self canGotoNextMonth]) {
+ NSDateComponents* components = [[[NSDateComponents alloc] init] autorelease];
+ [components setMonth:1];
+ self.currentMonthDate = [self.calendar dateByAddingComponents:components
+ toDate:self.currentMonthDate
+ options:0];
+ }
+ } else {
+ location.y -= 44;
+ int row = location.y / 44;
+ int col = location.x / 46;
+ NSDate* date = [self dateForRow:row column:col];
+ if ([self canSelectDate:date]) {
+ if (flags.delegateWillSelect) {
+ date = [self.delegate calendarView:self willSelectDate:date];
+ }
+ if (date) {
+ self.selectedDate = date;
+ self.currentMonthDate = date;
+ if (flags.delegateDidSelect) {
+ [self.delegate calendarView:self didSelectDate:date];
+ }
+ }
+ }
+ }
+}
+
+@end
View
4 Classes/CWColumnTableView.m
@@ -325,8 +325,8 @@ -(CWColumnTableViewCell*)cellForPositionAtIndex:(NSInteger)position;
if (_columnTableViewFlags.delegateHasWillDisplayCell) {
[self.delegate columnTableView:self willDisplayCell:cell forPositionAtIndex:position];
}
- cell.backgroundView;
- cell.selectedBackgroundView;
+ (void)cell.backgroundView;
+ (void)cell.selectedBackgroundView;
[cell setSelected:position == _selectedIndex];
NSInteger actualVisualPosition = [self actualVisualPositionForPosition:position];
CGRect frame = [self rectForPositionAtIndex:actualVisualPosition];
View
7 Classes/CWUIKit.h
@@ -32,12 +32,16 @@
#import "CWAuxiliaryAction.h"
#import "CWBackgroundBars.h"
#import "CWCalloutView.h"
+#import "CWCalendarView.h"
#import "CWColumnTableView.h"
#import "CWColumnTableViewCell.h"
#import "CWTableViewCellBackgroundView.h"
#import "CWLinearLayoutView.h"
#import "CWPrimaryViewWindow.h"
+#import "CWSearchBar.h"
#import "CWStyledSegmentedControl.h"
+#import "CWTextField.h"
+#import "CWViewSheet.h"
#import "NSObject+CWNibLocalizations.h"
#import "UIApplication+CWAdditions.h"
#import "UIAlertView+CWErrorHandler.h"
@@ -48,6 +52,3 @@
#import "UIImage+CWAdditions.h"
#import "UIView+CWVisualCue.h"
#import "UIViewController+CWPopover.h"
-#import "CWStyledSegmentedControl.h"
-#import "CWSearchBar.h"
-#import "CWTextField.h"
View
91 Classes/CWViewSheet.h
@@ -0,0 +1,91 @@
+//
+// CWViewSheet.h
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import <UIKit/UIKit.h>
+
+
+/*!
+ * @abstract An helper class for presenting a view as a sheet.
+ *
+ * @discussion Visually and conceptually it looks and behaves like a UIActionSheet.
+ * Is presented inside a popover on iPad.
+ * Only compatible with portrait orientation on iPhone.
+ */
+@interface CWViewSheet : UIView <UIPopoverControllerDelegate> {
+@private
+ UIView* _contentView;
+ BOOL _visible;
+ UIView* layoutView;
+ UIButton* dismissButton;
+ id retainDummy;
+ UIPopoverController* popoverController;
+ BOOL iPhoneIdiom;
+}
+
+/*!
+ * @abstract The content view the sheet presents.
+ */
+@property(nonatomic, readonly, retain) UIView* contentView;
+
+/*!
+ * @abstract Query of the sheet is currently visible.
+ */
+@property(nonatomic, readonly, getter=isVisible, assign) BOOL visible;
+
+/*!
+ * @abstract Initializes and returns an instance with a goven contemnt view.
+ *
+ * @discussion Title is optional, if available it will be displayed in a black
+ * bar above the content view in the sheet.
+ */
+-(id)initWithContentView:(UIView*)view title:(NSString*)title;
+
+/*!
+ * @abstract Displey the sheet originating in a view.
+ */
+-(void)showInView:(UIView*)view animated:(BOOL)animated;
+
+/*!
+ * @abstract Displey the sheet originating from a view.
+ */
+-(void)showFromRect:(CGRect)rect inView:(UIView*)view animated:(BOOL)animated;
+
+/*!
+ * @abstract Displey the sheet originating from a bar button.
+ */
+-(void)showFromBarButtonItem:(UIBarButtonItem*)item animated:(BOOL)animated;
+
+/*!
+ * @abstract Dismiss the sheet.
+ */
+-(void)dismissAnimated:(BOOL)animated;
+
+@end
+
View
238 Classes/CWViewSheet.m
@@ -0,0 +1,238 @@
+//
+// CWViewSheet.m
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import "CWViewSheet.h"
+
+@interface CWViewSheet (Private)
+@property(nonatomic, readwrite, assign) BOOL visible;
+@end
+
+@implementation CWViewSheet
+
+-(void)setVisible:(BOOL)visible;
+{
+ _visible = visible;
+ [self.window endEditing:YES];
+}
+
+@synthesize contentView = _contentView;
+@synthesize visible = _visible;
+
+-(void)primitiveInitForPhoneIdiomWithFrame:(CGRect)frame title:(NSString*)title;
+{
+ self.autoresizesSubviews = YES;
+ CGRect contentFrame = _contentView.bounds;
+ contentFrame.origin.y = (title ? 44 : 0);
+ _contentView.frame = contentFrame;
+ CGRect layoutFrame = frame;
+ layoutFrame.size.height = contentFrame.size.height + (title ? 44 : 0);
+ layoutFrame.origin.y = frame.size.height - layoutFrame.size.height;
+ layoutView = [[[UIView alloc] initWithFrame:layoutFrame] autorelease];
+ layoutView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
+ [layoutView addSubview:_contentView];
+ if (title) {
+ UIBarButtonItem* flexItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL] autorelease];
+ UILabel* label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1, 1)] autorelease];
+ label.text = title;
+ label.backgroundColor = [UIColor clearColor];
+ label.textColor = [UIColor whiteColor];
+ label.shadowColor = [UIColor blackColor];
+ label.font = [UIFont boldSystemFontOfSize:20];
+ [label sizeToFit];
+ UIBarButtonItem* titleItem = [[[UIBarButtonItem alloc] initWithCustomView:label] autorelease];
+ UIBarButtonItem* doneItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismiss)] autorelease];
+ UIBarButtonItem* spaceItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL] autorelease];
+ spaceItem.width = 30;
+ NSArray* items = [NSArray arrayWithObjects:spaceItem, flexItem, titleItem, flexItem, doneItem, nil];
+ CGRect toolbarFrame = contentFrame;
+ toolbarFrame.origin.y = 0;
+ toolbarFrame.size.height = 44;
+ UIToolbar* toolbar = [[[UIToolbar alloc] initWithFrame:toolbarFrame] autorelease];
+ toolbar.items = items;
+ toolbar.barStyle = UIBarStyleBlack;
+ [layoutView addSubview:toolbar];
+ }
+ dismissButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ dismissButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ [dismissButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
+ dismissButton.frame = self.bounds;
+ dismissButton.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5f];
+ [self addSubview:dismissButton];
+ [self addSubview:layoutView];
+}
+
+-(void)primitiveInitForPadIdiomWithFrame:(CGRect)frame title:(NSString*)title;
+{
+ UIViewController* vc = [[[UIViewController alloc] init] autorelease];
+ // This is done to avoid a resize bug in UIPopoverController.
+ UIView* contentView = [[[UIView alloc] initWithFrame:_contentView.bounds]autorelease];
+ [contentView addSubview:_contentView];
+ vc.view = contentView;
+ vc.contentSizeForViewInPopover = frame.size;
+ if (title) {
+ vc.title = title;
+ vc.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismiss)] autorelease];
+ vc = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
+ }
+ popoverController = [[UIPopoverController alloc] initWithContentViewController:vc];
+ popoverController.popoverContentSize = frame.size;
+ popoverController.delegate = self;
+}
+
+-(id)initWithContentView:(UIView*)view title:(NSString*)title;
+{
+ iPhoneIdiom = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone;
+ CGRect frame = iPhoneIdiom ? [[UIScreen mainScreen] applicationFrame] : view.bounds;
+ self = [self initWithFrame:frame];
+ if (self) {
+ _contentView = view;
+ if (iPhoneIdiom) {
+ [self primitiveInitForPhoneIdiomWithFrame:frame title:title];
+ } else {
+ [self primitiveInitForPadIdiomWithFrame:frame title:title];
+ }
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ popoverController.delegate = nil;
+ [popoverController release];
+ [super dealloc];
+}
+
+-(void)showInView:(UIView*)view animated:(BOOL)animated;
+{
+ if (self.visible) {
+ return;
+ }
+ if (iPhoneIdiom) {
+ if (view == nil) {
+ view = [[UIApplication sharedApplication] keyWindow];
+ }
+ if (![view isKindOfClass:[UIWindow class]]) {
+ view = view.window;
+ }
+ CGRect frame = [[(UIWindow*)view screen] applicationFrame];
+ self.frame = frame;
+ [view addSubview:self];
+ if (animated) {
+ CGRect layoutFrame = layoutView.frame;
+ layoutFrame.origin.y += layoutFrame.size.height;
+ layoutView.frame = layoutFrame;
+ dismissButton.alpha = 0;
+ [UIView beginAnimations:nil context:NULL];
+ layoutFrame.origin.y -= layoutFrame.size.height;
+ layoutView.frame = layoutFrame;
+ dismissButton.alpha = 1;
+ [UIView commitAnimations];
+ }
+ } else {
+ UIView* view = [[UIApplication sharedApplication] keyWindow];
+ CGRect rect = view.bounds;
+ rect = CGRectMake(rect.origin.x + rect.size.width / 2, rect.origin.y + rect.size.width / 2, 1, 1);
+ [popoverController presentPopoverFromRect:rect inView:view permittedArrowDirections:0 animated:animated];
+ retainDummy = [self retain];
+ }
+ self.visible = YES;
+}
+
+-(void)showFromRect:(CGRect)rect inView:(UIView*)view animated:(BOOL)animated;
+{
+ if (self.visible) {
+ return;
+ }
+ if (iPhoneIdiom) {
+ [self showInView:[[UIApplication sharedApplication] keyWindow] animated:animated];
+ } else {
+ [popoverController presentPopoverFromRect:rect inView:view permittedArrowDirections:UIPopoverArrowDirectionAny animated:animated];
+ retainDummy = [self retain];
+ }
+ self.visible = YES;
+}
+
+-(void)showFromBarButtonItem:(UIBarButtonItem*)item animated:(BOOL)animated;
+{
+ if (self.visible) {
+ return;
+ }
+ if (iPhoneIdiom) {
+ [self showInView:[[UIApplication sharedApplication] keyWindow] animated:animated];
+ } else {
+ [self showFromBarButtonItem:item animated:animated];
+ retainDummy = [self retain];
+ }
+ self.visible = YES;
+}
+
+-(void)dismiss;
+{
+ [self dismissAnimated:YES];
+}
+
+-(void)dismissAnimated:(BOOL)animated;
+{
+ if (!self.visible) {
+ return;
+ }
+ if (iPhoneIdiom) {
+ if (animated) {
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDelegate:self];
+ [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
+ CGRect layoutFrame = layoutView.frame;
+ layoutFrame.origin.y += layoutFrame.size.height;
+ layoutView.frame = layoutFrame;
+ dismissButton.alpha = 0;
+ [UIView commitAnimations];
+ } else {
+ [self removeFromSuperview];
+ }
+ } else {
+ [popoverController dismissPopoverAnimated:animated];
+ [retainDummy autorelease], retainDummy = nil;
+ }
+ self.visible = NO;
+}
+
+- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;
+{
+ [self removeFromSuperview];
+}
+
+-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController;
+{
+ [retainDummy autorelease], retainDummy = nil;
+ self.visible = NO;
+}
+
+
+@end
View
2  Classes/UIBarButtonItem+CWAdditions.m
@@ -86,7 +86,7 @@ +(UIBarButtonItem*)barButtonItemWithTitle:(NSString*)title titleColor:(UIColor*)
+(UIBarButtonItem*)barButtonItemWithTitle:(NSString*)title titleColor:(UIColor*)titleColor titleShadowColor:(UIColor*)titleShadowColor image:(UIImage*)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action;
{
- if (style = UIBarButtonItemStylePlain) {
+ if (style == UIBarButtonItemStylePlain) {
return [self barButtonItemWithTitle:title
titleColor:titleColor
titleShadowColor:titleShadowColor
1  Components/CWFoundation
@@ -1 +0,0 @@
-Subproject commit e99e358d34972bcc8845e58a88e6e30f540e1f4d
View
11 README
@@ -4,12 +4,11 @@ CWUIKit
Additions and utilities to augment the Foundation framework created by Jayway.
This project is created with the intent to be used as a sub-project for other
-Xcode project. Additionaly this project can be used as a git sub module.
+Xcode project.
This project has a dependency to CWFoundation. This dependency in added as
-a git sub module in Components/CWFoundation. You may need to update this
-dependency using:
- git submodule update --init --recursive
+a relative sub-project at ../CWFoundation. You can clone this repo yourself
+or it will be cloned for you when building through the CWUIKitEnsureDeps target.
CWUIKit is weakly linked agains CWFoundation in order to avoid duplicate
symbols if CWUIKit is used with other project that also have dependencies to
@@ -24,7 +23,7 @@ You add this project as a sub project in Xcode like this:
2. Make sure this project product (libCWUIKit.a) is a target member.
3. Make sure the subprojects product (libCWFoundation.a) is a target member.
4. Add the CWUIKit target as direct dependency.
-5. Add <Path To CWUIKit>/** to user header search paths.
+5. Add ../** to user header search paths.
6. Add -all_load to other linker flags.
7. Add CWUIKitResources to Copy Bundle Resource build phase.
@@ -45,11 +44,13 @@ The public headerfiles are the official source of documentation. This section
only describes a subset of the main funcationality.
* CWAuxiliaryActions - Use blocks as callbacks for UIAlertView & UIActionSheet.
+* CWCalendarView - A view visually like the iPhone Calendar app.
* CWCalloutView - Configurable callout view like in MapKit.
* CWColumnTableView - Like UITableView with multiple columns
* CWTableViewBackgroundCell - Configurabe background and highlight for cells.
* CWLinearLayout - Rule based linear layout, when springs&struts comes short.
* CWNibLocalization - Prefix text with @ in IB gets localized from strings.
+* CWViewSheet - A helper class for presenting views like a sheet.
* UIAlertView - Conviniece additions to construct from NSError instances.
* UIColor - Additions for extracting components, and accessing standard colors.
* UIDevice - Conviniece additions for quering for availible capabilities.
View
22 Sample Classes/CalendarViewSheet/CalendarViewSheetSampleApp-Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.jayway.cwcalloutview.SampleApp</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
View
5,125 Sample Classes/CalendarViewSheet/MainWindow.xib
5,125 additions, 0 deletions not shown
View
46 Sample Classes/CalendarViewSheet/SampleAppAppDelegate.h
@@ -0,0 +1,46 @@
+//
+// SampleAppAppDelegate.h
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import <UIKit/UIKit.h>
+#import "CWCalendarView.h"
+
+@interface SampleAppAppDelegate : NSObject <UIApplicationDelegate, CWCalendarViewDelegate> {
+ UIWindow *window;
+ IBOutlet UISwitch* aswitch;
+ IBOutlet UILabel* label;
+ IBOutlet UIButton* button;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+
+-(IBAction)showCalendar;
+
+@end
+
View
79 Sample Classes/CalendarViewSheet/SampleAppAppDelegate.m
@@ -0,0 +1,79 @@
+//
+// SampleAppAppDelegate.m
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import "SampleAppAppDelegate.h"
+#import "CWViewSheet.h"
+
+@implementation SampleAppAppDelegate
+
+@synthesize window;
+
+
+#pragma mark -
+#pragma mark Application lifecycle
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
+{
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+-(IBAction)showCalendar;
+{
+ CWCalendarView* calendarView = [[[CWCalendarView alloc] init] autorelease];
+ calendarView.delegate = self;
+ calendarView.minimumDate = [NSDate dateWithTimeIntervalSinceNow:-86400 * 14];
+ calendarView.maximumDate = [NSDate dateWithTimeIntervalSinceNow:86400 * 56];
+
+ NSString* title = aswitch.on ? @"Select Date" : nil;
+ CWViewSheet* sheet = [[[CWViewSheet alloc] initWithContentView:calendarView
+ title:title] autorelease];
+ [sheet showFromRect:button.bounds inView:button animated:YES];
+}
+
+-(BOOL)calendarView:(CWCalendarView *)view canSelectDate:(NSDate *)date;
+{
+ NSDateComponents* components = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit|NSDayCalendarUnit fromDate:date];
+ NSInteger weekday = [components weekday];
+ return weekday != 1 && weekday != 7 && [components day] != 13;
+}
+
+-(BOOL)calendarView:(CWCalendarView *)view hasAnnotationForDate:(NSDate *)date;
+{
+ NSInteger foo = (int)([date timeIntervalSinceReferenceDate] / 3000) % 3;
+ return foo == 0;
+}
+
+-(void)calendarView:(CWCalendarView *)view didSelectDate:(NSDate *)date;
+{
+ label.text = [date description];
+}
+
+@end
View
39 Sample Classes/CalendarViewSheet/main.m
@@ -0,0 +1,39 @@
+//
+// main.m
+// CWUIKit
+// Created by Fredrik Olsson
+//
+// Copyright (c) 2011, Jayway AB All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of Jayway AB nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL JAYWAY AB BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#import <UIKit/UIKit.h>
+
+int main(int argc, char *argv[]) {
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ [pool release];
+ return retVal;
+}
View
22 Sample Classes/CalloutView/CalloutViewSampleApp-Info copy.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.jayway.cwcalloutview.SampleApp</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
View
40 Scripts/ensdep.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+
+def printUsage
+ puts "You must specify dependencies to ensure existance of.
+
+usage: ensdep [-p] <repo> ...
+
+ -p Pull in existing repos
+ <repo> One or more git repos to ensure
+
+Repos are cloned into ../ unless DEPENDENCIES_PATH is set to a path."
+end
+
+def ensureRepoInDirectory(repo_url, dep_path, pull)
+ repo_path = File.join(dep_path, repo_url.slice(/[^\/]*(?=\.git$)/))
+ unless File.directory?(repo_path)
+ puts "will clone repo #{repo_url} into #{repo_path}"
+ system "git clone #{repo_url} #{repo_path}"
+ else
+ if pull
+ puts "will pull #{repo_url} in #{repo_path}"
+ system "git --git-dir=#{repo_path} --work-tree=#{repo_path} pull"
+ else
+ puts "will ignore #{repo_url} in #{repo_path}"
+ end
+ end
+end
+
+# Main
+if ARGV.length == 0
+ printUsage
+else
+ pull = ARGV[0] == '-p'
+ repos = ARGV[(pull ? 1 : 0)..-1]
+ dep_path = ENV['DEPENDENCIES_PATH'] || '..'
+ repos.each do|repo_url|
+ ensureRepoInDirectory(repo_url, dep_path, pull)
+ end
+end
+

No commit comments for this range

Something went wrong with that request. Please try again.