Permalink
Browse files

Imported initial version of CMTextStylePicker along with a demo app.

  • Loading branch information...
0 parents commit e998ab99e8ac5d3f8ed13f0917f916a0b31a9dca @chrismiles committed Nov 20, 2010
Showing with 7,239 additions and 0 deletions.
  1. +37 −0 CMTextStylePicker/CMColourBlockView.h
  2. +103 −0 CMTextStylePicker/CMColourBlockView.m
  3. +46 −0 CMTextStylePicker/CMColourSelectTableViewController.h
  4. +224 −0 CMTextStylePicker/CMColourSelectTableViewController.m
  5. +400 −0 CMTextStylePicker/CMColourSelectTableViewController.xib
  6. +49 −0 CMTextStylePicker/CMFontSelectTableViewController.h
  7. +237 −0 CMTextStylePicker/CMFontSelectTableViewController.m
  8. +173 −0 CMTextStylePicker/CMFontSelectTableViewController.xib
  9. +47 −0 CMTextStylePicker/CMFontStyleSelectTableViewController.h
  10. +214 −0 CMTextStylePicker/CMFontStyleSelectTableViewController.m
  11. +173 −0 CMTextStylePicker/CMFontStyleSelectTableViewController.xib
  12. +77 −0 CMTextStylePicker/CMTextStylePickerViewController.h
  13. +433 −0 CMTextStylePicker/CMTextStylePickerViewController.m
  14. +1,206 −0 CMTextStylePicker/CMTextStylePickerViewController.xib
  15. +41 −0 CMTextStylePicker/CMUpDownControl.h
  16. +420 −0 CMTextStylePicker/CMUpDownControl.m
  17. +43 −0 Demo/CMTextStylePickerDemo-Info.plist
  18. +351 −0 Demo/CMTextStylePickerDemo.xcodeproj/project.pbxproj
  19. +8 −0 Demo/CMTextStylePickerDemo_Prefix.pch
  20. +35 −0 Demo/Shared/main.m
  21. +39 −0 Demo/iPad/AppDelegate_iPad.h
  22. +89 −0 Demo/iPad/AppDelegate_iPad.m
  23. +40 −0 Demo/iPad/IPadDemoViewController.h
  24. +228 −0 Demo/iPad/IPadDemoViewController.m
  25. +549 −0 Demo/iPad/IPadDemoViewController.xib
  26. +448 −0 Demo/iPad/MainWindow_iPad.xib
  27. +39 −0 Demo/iPhone/AppDelegate_iPhone.h
  28. +106 −0 Demo/iPhone/AppDelegate_iPhone.m
  29. +41 −0 Demo/iPhone/IPhoneDemoViewController.h
  30. +228 −0 Demo/iPhone/IPhoneDemoViewController.m
  31. +605 −0 Demo/iPhone/IPhoneDemoViewController.xib
  32. +489 −0 Demo/iPhone/MainWindow_iPhone.xib
  33. +21 −0 LICENSE
@@ -0,0 +1,37 @@
+//
+// CMColourBlockView.h
+// CMTextStylePicker
+//
+// Created by Chris Miles on 16/11/10.
+// Copyright (c) Chris Miles 2010.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface CMColourBlockView : UIView {
+
+}
+
+@property (nonatomic, retain) UIColor *colour;
+@property (nonatomic, assign) CGFloat cornerRadius;
+
+@end
@@ -0,0 +1,103 @@
+//
+// CMColourBlockView.m
+// CMTextStylePicker
+//
+// Created by Chris Miles on 16/11/10.
+// Copyright (c) Chris Miles 2010.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import "CMColourBlockView.h"
+
+
+@implementation CMColourBlockView
+
+@synthesize colour, cornerRadius;
+
+- (void)setColour:(UIColor *)newColour {
+ [newColour retain];
+ [colour release];
+ colour = newColour;
+
+ [self setNeedsDisplay];
+}
+
+- (void)setCornerRadius:(CGFloat)newCornerRadius {
+ cornerRadius = newCornerRadius;
+ [self setNeedsDisplay];
+}
+
+- (void)assignDefaults {
+ cornerRadius = 7.0; // default
+ self.opaque = NO;
+}
+
+- (id)initWithFrame:(CGRect)frame {
+
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self assignDefaults];
+ }
+ return self;
+}
+
+- (id)initWithCoder:(NSCoder *)decoder {
+
+ self = [super initWithCoder:decoder];
+ if (self) {
+ [self assignDefaults];
+ }
+ return self;
+}
+
+- (void)drawRect:(CGRect)rect {
+ UIColor *fillColor = self.colour;
+ if (nil == fillColor) {
+ fillColor = [UIColor blackColor];
+ }
+
+ CGContextRef c = UIGraphicsGetCurrentContext();
+ CGPoint origin = self.bounds.origin;
+ CGSize size = self.bounds.size;
+
+ CGContextMoveToPoint(c, origin.x+size.width-cornerRadius, origin.y);
+ CGContextAddArcToPoint(c, origin.x+size.width, origin.y, origin.x+size.width, origin.y+cornerRadius, cornerRadius);
+ CGContextAddLineToPoint(c, origin.x+size.width, origin.y+size.height-cornerRadius);
+ CGContextAddArcToPoint(c, origin.x+size.width, origin.y+size.height, origin.x+size.width-cornerRadius, origin.y+size.height, cornerRadius);
+ CGContextAddLineToPoint(c, origin.x+cornerRadius, origin.y+size.height);
+ CGContextAddArcToPoint(c, origin.x, origin.y+size.height, origin.x, origin.y+size.height-cornerRadius, cornerRadius);
+ CGContextAddLineToPoint(c, origin.x, origin.y+cornerRadius);
+ CGContextAddArcToPoint(c, origin.x, origin.y, origin.x+cornerRadius, origin.y, cornerRadius);
+ CGContextClosePath(c);
+
+ CGColorRef color = [fillColor CGColor];
+ CGContextSetFillColorSpace(c, CGColorGetColorSpace(color));
+ CGContextSetFillColor(c, CGColorGetComponents(color));
+ CGContextDrawPath(c, kCGPathFill);
+}
+
+- (void)dealloc {
+ [colour release];
+
+ [super dealloc];
+}
+
+
+@end
@@ -0,0 +1,46 @@
+//
+// CMColourSelectTableViewController.h
+// CMTextStylePicker
+//
+// Created by Chris Miles on 20/10/10.
+// Copyright (c) Chris Miles 2010.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol CMColourSelectTableViewControllerDelegate;
+
+
+@interface CMColourSelectTableViewController : UITableViewController {
+
+}
+
+@property (nonatomic, assign) id<CMColourSelectTableViewControllerDelegate> delegate;
+
+@property (nonatomic, retain) NSArray *availableColours;
+@property (nonatomic, retain) UIColor *selectedColour;
+
+@end
+
+
+@protocol CMColourSelectTableViewControllerDelegate
+- (void)colourSelectTableViewController:(CMColourSelectTableViewController *)colourSelectTableViewController didSelectColour:(UIColor *)selectedColour;
+@end
Oops, something went wrong.

0 comments on commit e998ab9

Please sign in to comment.