├── .gitignore ├── Framework ├── Controllers │ ├── KTController.h │ ├── KTLayerController.h │ ├── KTLayerController.m │ ├── KTTabItem.h │ ├── KTTabItem.m │ ├── KTTabViewController.h │ ├── KTTabViewController.m │ ├── KTViewController.h │ ├── KTViewController.m │ ├── KTWindowController.h │ └── KTWindowController.m ├── KTAnimator.h ├── KTAnimator.m ├── KTLayoutDynamicImplementation.h ├── KTLayoutDynamicImplementation.m ├── KTUIKit.h ├── Resources │ └── KTUIKitFramework-Info.plist └── Views │ ├── Drawing │ ├── NSBezierPathAdditions.h │ └── NSBezierPathAdditions.m │ ├── KTViewProtocol.h │ ├── Layout │ ├── KTLayoutManager.h │ ├── KTLayoutManager.m │ ├── KTViewLayout.h │ └── SharedCode │ │ ├── KTViewLayoutSharedImplementation_ChildlessNSView.m │ │ └── readme.txt │ ├── NSControlSubclasses │ ├── KTButton.h │ ├── KTButton.m │ ├── KTColorWell.h │ ├── KTColorWell.m │ ├── KTControl.h │ ├── KTControl.m │ ├── KTGradientPicker.h │ ├── KTGradientPicker.m │ ├── KTImageView.h │ ├── KTImageView.m │ ├── KTPopUpButton.h │ ├── KTPopUpButton.m │ ├── KTSearchField.h │ ├── KTSearchField.m │ ├── KTSecureTextField.h │ ├── KTSecureTextField.m │ ├── KTSegmentedControl.h │ ├── KTSegmentedControl.m │ ├── KTSlider.h │ ├── KTSlider.m │ ├── KTTextField.h │ ├── KTTextField.m │ ├── KTViewControl.h │ └── KTViewControl.m │ ├── NSViewSubclasses │ ├── KTAppKitSplitView.h │ ├── KTAppKitSplitView.m │ ├── KTImageKitBrowserView.h │ ├── KTImageKitBrowserView.m │ ├── KTLevelIndicator.h │ ├── KTLevelIndicator.m │ ├── KTProgressIndicator.h │ ├── KTProgressIndicator.m │ ├── KTScrollView.h │ ├── KTScrollView.m │ ├── KTScroller.h │ ├── KTScroller.m │ ├── KTView.h │ ├── KTView.m │ ├── KTWebView.h │ ├── KTWebView.m │ └── SplitView │ │ ├── KTSplitView.h │ │ ├── KTSplitView.m │ │ ├── KTSplitViewDivider.h │ │ └── KTSplitViewDivider.m │ ├── NSWindowSubclasses │ ├── KTViewOverlayWindow.h │ ├── KTViewOverlayWindow.m │ ├── KTWindow.h │ └── KTWindow.m │ ├── OpenGL │ ├── KTOpenGLButton.h │ ├── KTOpenGLButton.m │ ├── KTOpenGLControl.h │ ├── KTOpenGLControl.m │ ├── KTOpenGLLayer.h │ ├── KTOpenGLLayer.m │ ├── KTOpenGLTexture.h │ ├── KTOpenGLTexture.m │ ├── KTOpenGLView.h │ ├── KTOpenGLView.m │ ├── KTSharedContextOpenGLView.h │ └── KTSharedContextOpenGLView.m │ └── Styles │ ├── KTStyle.h │ ├── KTStyleManager.h │ └── KTStyleManager.m ├── KTOpenGLView.classdescription ├── KTUIKit.xcodeproj └── project.pbxproj ├── KTUIKit_Prefix.pch ├── Plugin ├── Class Descriptions │ ├── KTAppKitSplitView.classdescription │ ├── KTButton.classdescription │ ├── KTColorWell.classdescription │ ├── KTGradientPicker.classdescription │ ├── KTImageKitBrowserView.classdescription │ ├── KTImageView.classdescription │ ├── KTLevelIndicator.classdescription │ ├── KTPopUpButton.classdescription │ ├── KTProgressIndicator.classdescription │ ├── KTScrollView.classdescription │ ├── KTScroller.classdescription │ ├── KTSearchField.classdescription │ ├── KTSecureTextField.classdescription │ ├── KTSegmentedControl.classdescription │ ├── KTSlider.classdescription │ ├── KTSplitView.classdescription │ ├── KTTextField.classdescription │ ├── KTView.classdescription │ ├── KTViewControl.classdescription │ ├── KTViewController.classdescription │ ├── KTWebView.classdescription │ └── XSWindowController.classdescription ├── Inspectors │ ├── KTLayoutManagerControl.h │ ├── KTLayoutManagerControl.m │ ├── KTLayoutManagerInspector.h │ ├── KTLayoutManagerInspector.m │ ├── KTSplitViewInspector.h │ ├── KTSplitViewInspector.m │ ├── KTStyleInspector.h │ ├── KTStyleInspector.m │ ├── KTViewInspector.h │ └── KTViewInspector.m ├── Integration │ ├── KTAppKitSplitViewIntegration.m │ ├── KTButtonIntegration.m │ ├── KTColorWellIntegration.m │ ├── KTGradientPickerIntegration.m │ ├── KTImageKitBrowserViewIntegration.m │ ├── KTImageViewIntegration.m │ ├── KTLayoutManagerIntegration.m │ ├── KTLevelIndicatorIntegration.m │ ├── KTOpenGLViewIntegration.m │ ├── KTPopUpButtonIntegration.m │ ├── KTProgressIndicatorIntegration.m │ ├── KTScrollViewIntegration.m │ ├── KTSearchFieldIntegration.m │ ├── KTSecureTextFieldIntegration.m │ ├── KTSegmentedControlIntegration.m │ ├── KTSliderIntegration.m │ ├── KTSplitViewDividerIntegration.m │ ├── KTSplitViewIntegration.m │ ├── KTTextFieldIntegration.m │ ├── KTViewIntegration.m │ └── KTWebViewIntegration.m ├── KTUIKit.h ├── KTUIKit.m ├── KTUIKit_Prefix.pch └── Resources │ ├── English.lproj │ ├── KTLayoutManagerInspector.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ ├── KTSplitViewInspector.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ ├── KTStyleInspector.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ ├── KTUIKitLibrary.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ └── KTViewInspector.nib │ │ ├── designable.nib │ │ └── keyedobjects.nib │ └── Images │ ├── AKSplitView_horizontal.png │ ├── AKSplitView_vertical.png │ ├── KTScrollView.tif │ ├── KTView.png │ ├── TextView.tif │ ├── WebKit.png │ ├── align_bottom.png │ ├── align_horizontal_center.png │ ├── align_left.png │ ├── align_right.png │ ├── align_top.png │ ├── align_vertical_center.png │ ├── placement_bottom.png │ ├── placement_center_horizontal.png │ ├── placement_center_vertical.png │ ├── placement_left.png │ ├── placement_right.png │ └── placement_top.png ├── Resources ├── Info.plist ├── InfoPlist.strings └── KTUIKitFramework-Info.plist └── version.plist /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | build/ 3 | *.pbxuser 4 | *.mode1v3 -------------------------------------------------------------------------------- /Framework/Controllers/KTController.h: -------------------------------------------------------------------------------- 1 | @protocol KTController 2 | - (NSArray*)descendants; 3 | - (void)removeObservations; 4 | - (BOOL)hidden; 5 | @end -------------------------------------------------------------------------------- /Framework/Controllers/KTLayerController.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLLayerController.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 27/02/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTController.h" 11 | 12 | @class KTViewController; 13 | 14 | @interface KTLayerController : NSResponder 15 | { 16 | KTViewController * wViewController; 17 | NSMutableArray * mSubcontrollers; 18 | id mLayer; 19 | id wRepresentedObject; 20 | } 21 | 22 | @property (nonatomic, readwrite, assign) KTViewController * viewController; 23 | @property (nonatomic, readwrite, retain) NSMutableArray * subcontrollers; 24 | @property (nonatomic, readwrite, retain) id layer; 25 | @property (nonatomic, readwrite, assign) id representedObject; 26 | 27 | + (id)layerControllerWithViewController:(KTViewController*)theViewController; 28 | - (id)initWithViewController:(KTViewController*)theViewController; 29 | - (void)addSubcontroller:(KTLayerController*)theSubcontroller; 30 | - (void)removeSubcontroller:(KTLayerController*)theSubcontroller; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Framework/Controllers/KTLayerController.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLLayerController.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 27/02/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTLayerController.h" 10 | #import "KTViewController.h" 11 | #import "KTWindowController.h" 12 | 13 | @implementation KTLayerController 14 | 15 | //=========================================================== 16 | // synthesized properties 17 | //=========================================================== 18 | @synthesize viewController = wViewController; 19 | @synthesize subcontrollers = mSubcontrollers; 20 | @synthesize representedObject = wRepresentedObject; 21 | @synthesize layer = mLayer; 22 | 23 | 24 | //=========================================================== 25 | // - layerControllerWithViewController 26 | //=========================================================== 27 | + (id)layerControllerWithViewController:(KTViewController*)theViewController 28 | { 29 | return [[[self alloc] initWithViewController:theViewController] autorelease]; 30 | } 31 | 32 | 33 | //=========================================================== 34 | // - initWithViewController 35 | //=========================================================== 36 | - (id)initWithViewController:(KTViewController*)theViewController 37 | { 38 | if(self = [super init]) 39 | { 40 | wViewController = theViewController; 41 | mSubcontrollers = [[NSMutableArray alloc] init]; 42 | } 43 | return self; 44 | } 45 | 46 | //=========================================================== 47 | // - dealloc 48 | //=========================================================== 49 | - (void)dealloc 50 | { 51 | [mSubcontrollers release]; 52 | [mLayer release]; 53 | [super dealloc]; 54 | } 55 | 56 | //=========================================================== 57 | // - setRepresentedObject 58 | //=========================================================== 59 | - (void)setRepresentedObject:(id)theRepresentedObject 60 | { 61 | wRepresentedObject = theRepresentedObject; 62 | } 63 | 64 | 65 | //=========================================================== 66 | // - removeObservations 67 | //=========================================================== 68 | - (void)removeObservations 69 | { 70 | [mSubcontrollers makeObjectsPerformSelector:@selector(removeObservations)]; 71 | } 72 | 73 | 74 | //=========================================================== 75 | // - addSubcontroller 76 | //=========================================================== 77 | - (void)addSubcontroller:(KTLayerController*)theSubcontroller 78 | { 79 | if(theSubcontroller) 80 | { 81 | [mSubcontrollers addObject:theSubcontroller]; 82 | [[[self viewController] windowController] patchResponderChain]; 83 | } 84 | } 85 | 86 | //=========================================================== 87 | // - removeSubcontroller 88 | //=========================================================== 89 | - (void)removeSubcontroller:(KTLayerController*)theSubcontroller 90 | { 91 | if(theSubcontroller) 92 | { 93 | [mSubcontrollers removeObject:theSubcontroller]; 94 | [[[self viewController] windowController] patchResponderChain]; 95 | } 96 | } 97 | 98 | 99 | #pragma mark Controller Responder Chain Protocol 100 | //=========================================================== 101 | // - descendants 102 | //=========================================================== 103 | - (NSArray *)descendants 104 | { 105 | NSMutableArray * anArray = [NSMutableArray array]; 106 | for(KTLayerController * aLayerController in mSubcontrollers) 107 | { 108 | [anArray addObject:aLayerController]; 109 | if([[aLayerController subcontrollers] count] > 0) 110 | [anArray addObjectsFromArray:[aLayerController descendants]]; 111 | } 112 | return [[anArray copy] autorelease]; // return an immutable array 113 | } 114 | 115 | 116 | - (BOOL)hidden 117 | { 118 | return NO; 119 | } 120 | 121 | @end 122 | 123 | 124 | -------------------------------------------------------------------------------- /Framework/Controllers/KTTabItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTTabItem.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 18/03/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KTTabViewController; 12 | @class KTViewController; 13 | 14 | @interface KTTabItem : NSObject 15 | { 16 | NSString * mLabel; 17 | id wIdentifier; 18 | KTTabViewController * wTabViewController; 19 | KTViewController * wViewController; 20 | NSMutableDictionary * mUserInfo; 21 | } 22 | 23 | - (id)initWithViewController:(KTViewController*)theViewController; 24 | 25 | @property (nonatomic, readwrite, retain) NSString * label; 26 | @property (nonatomic, readwrite, assign) id identifier; 27 | @property (nonatomic, readwrite, assign) KTTabViewController * tabViewController; 28 | @property (nonatomic, readwrite, assign) KTViewController * viewController; 29 | @property (nonatomic, readonly) NSMutableDictionary *userInfo; 30 | @end 31 | -------------------------------------------------------------------------------- /Framework/Controllers/KTTabItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTTabItem.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 18/03/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTTabItem.h" 10 | 11 | 12 | @implementation KTTabItem 13 | @synthesize label = mLabel; 14 | @synthesize identifier = wIdentifier; 15 | @synthesize tabViewController = wTabViewController; 16 | @synthesize viewController = wViewController; 17 | 18 | 19 | - (id)initWithViewController:(KTViewController*)theViewController 20 | { 21 | if(theViewController==nil) 22 | { 23 | [self release]; 24 | return nil; 25 | } 26 | 27 | if(self = [super init]) 28 | { 29 | wViewController = theViewController; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)dealloc 35 | { 36 | // NSLog(@"%@ dealloc", self); 37 | [mLabel release]; 38 | [mUserInfo release]; 39 | [super dealloc]; 40 | } 41 | 42 | - (NSMutableDictionary *)userInfo; 43 | { 44 | if (mUserInfo != nil) 45 | return mUserInfo; 46 | mUserInfo = [[NSMutableDictionary alloc] init]; 47 | return mUserInfo; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Framework/Controllers/KTTabViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTTabViewController.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 18/03/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewController.h" 11 | 12 | @class KTView; 13 | @class KTTabItem; 14 | 15 | @interface KTTabViewController : KTViewController 16 | { 17 | @private 18 | NSArrayController * mTabItemArrayController; 19 | KTTabItem * wCurrentSelectedTab; 20 | BOOL mReleaseViewControllersWhenNotSeletcted; 21 | BOOL mShouldResizeTabViews; 22 | id wDelegate; 23 | } 24 | 25 | @property (nonatomic, readonly) NSArrayController * tabItemArrayController; 26 | @property (nonatomic, readwrite, assign) BOOL releaseViewControllersWhenNotSeletcted; 27 | @property (nonatomic, readwrite, assign) BOOL shouldResizeTabViews; 28 | @property (nonatomic, readwrite, assign) id delegate; 29 | 30 | 31 | // adding/removing/getting tabs 32 | - (void)addTabItem:(KTTabItem*)theTabItem; 33 | - (void)addTabItem:(KTTabItem *)theTabItem select:(BOOL)theBool; 34 | - (void)removeTabItem:(KTTabItem*)theTabItem; 35 | - (void)insertTabItem:(KTTabItem*)theTabItem atIndex:(NSInteger)theIndex; 36 | - (NSArray*)tabItems; 37 | - (KTTabItem*)tabItemForIdentifier:(id)theIdentifier; 38 | - (KTTabItem*)tabItemForViewController:(KTViewController*)theViewController; 39 | - (KTTabItem*)tabItemForIndex:(NSInteger)theIndex; 40 | 41 | // selection 42 | - (KTTabItem*)selectedTabItem; 43 | - (NSInteger)selectedTabIndex; 44 | - (void)selectTabAtIndex:(NSInteger)theTabIndex; 45 | - (void)selectTabItem:(KTTabItem*)theTabItem; 46 | - (BOOL)canSelectNextTabItem; 47 | - (BOOL)canSelectPreviousTabItem; 48 | - (void)selectNextTabItem; 49 | - (void)selectPreviousTabItem; 50 | @end -------------------------------------------------------------------------------- /Framework/Controllers/KTViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewController.h 3 | // View Controllers 4 | // 5 | // Created by Jonathan Dann and Cathy Shive on 14/04/2008. 6 | // 7 | // Copyright (c) 2008 Jonathan Dann and Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "View Controllers" by Jonathan Dann and Cathy Shive" will do. 32 | 33 | #import 34 | #import "KTViewProtocol.h" 35 | #import "KTController.h" 36 | #import "KTWindowController.h" 37 | 38 | @class KTLayerController; 39 | 40 | @interface KTViewController : NSViewController 41 | { 42 | @private 43 | KTWindowController * wWindowController; 44 | KTViewController * wParentViewController; 45 | NSMutableArray * mSubcontrollers; 46 | NSMutableArray * mTopLevelNibObjects; 47 | NSMutableArray * mLayerControllers; 48 | BOOL mHidden; 49 | } 50 | 51 | @property(nonatomic, assign) KTWindowController * windowController; 52 | @property (nonatomic, readonly, assign) KTViewController * parentViewController; 53 | @property(nonatomic, readwrite, assign) BOOL hidden; 54 | 55 | + (id)viewControllerWithWindowController:(KTWindowController*)theWindowController; 56 | - (id)initWithNibName:(NSString *)name bundle:(NSBundle *)bundle windowController:(KTWindowController *)windowController; 57 | - (BOOL)loadNibNamed:(NSString*)theNibName bundle:(NSBundle*)theBundle; 58 | 59 | 60 | #pragma mark View 61 | //- (NSView*)view; 62 | //- (void)setView:(NSView*)theView; 63 | 64 | #pragma mark Subcontrollers 65 | - (void)setSubcontrollers:(NSArray*)theSubcontrollers; 66 | - (NSArray*)subcontrollers; 67 | - (void)addSubcontroller:(KTViewController *)viewController; 68 | - (void)removeSubcontroller:(KTViewController *)viewController; 69 | - (void)removeAllSubcontrollers; 70 | 71 | #pragma mark Layer Controllers 72 | - (void)addLayerController:(KTLayerController*)theLayerController; 73 | - (void)removeLayerController:(KTLayerController*)theLayerController; 74 | - (NSArray*)layerControllers; 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /Framework/Controllers/KTViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewController.m 3 | // View Controllers 4 | // 5 | // Created by Jonathan Dann and Cathy Shive on 14/04/2008. 6 | // 7 | // Copyright (c) 2008 Jonathan Dann and Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "View Controllers" by Jonathan Dann and Cathy Shive" will do. 32 | 33 | 34 | /* 35 | (Cathy 11/10/08) NOTE: 36 | I've made the following changes that need to be documented: 37 | • When a child is removed, its view is removed from its superview and it is sent a "removeObservations" message 38 | • Added 'removeChild:(KTViewController*)theChild' method to remove specific subcontrollers 39 | • Added 'loadNibNamed' and 'releaseNibObjects' to support loading more than one nib per view controller. These take care 40 | of releasing the top level nib objects for those nib files. Users have to unbind any bindings in those nibs in the view 41 | controller's removeObservations method. 42 | • Added class method, 'viewControllerWithWindowController' 43 | • I'm considering overriding 'view' and 'setView:' so that the view controller only deals with KTViews. 44 | */ 45 | 46 | 47 | #import "KTViewController.h" 48 | #import "KTWindowController.h" 49 | #import "KTLayerController.h" 50 | 51 | @interface KTViewController () 52 | @property (nonatomic, readwrite, assign) KTViewController * parentViewController; 53 | @end 54 | 55 | 56 | @interface KTViewController (Private) 57 | - (void)releaseNibObjects; 58 | - (void)_setHidden:(BOOL)theHiddenFlag patchResponderChain:(BOOL)thePatchFlag; 59 | @end 60 | 61 | @implementation KTViewController 62 | //=========================================================== 63 | // - @synthesize 64 | //=========================================================== 65 | @synthesize windowController = wWindowController; 66 | @synthesize parentViewController = wParentViewController; 67 | @synthesize hidden = mHidden; 68 | 69 | 70 | //=========================================================== 71 | // - viewControllerWithWindowController 72 | //=========================================================== 73 | + (id)viewControllerWithWindowController:(KTWindowController*)theWindowController 74 | { 75 | return [[[self alloc] initWithNibName:nil bundle:nil windowController:theWindowController] autorelease]; 76 | } 77 | 78 | 79 | //=========================================================== 80 | // - initWithNibName 81 | //=========================================================== 82 | - (id)initWithNibName:(NSString *)theNibName bundle:(NSBundle *)theBundle windowController:(KTWindowController *)theWindowController; 83 | { 84 | if (![super initWithNibName:theNibName bundle:theBundle]) 85 | return nil; 86 | wWindowController = theWindowController; 87 | mSubcontrollers = [[NSMutableArray alloc] init]; 88 | mTopLevelNibObjects = [[NSMutableArray alloc] init]; 89 | mLayerControllers = [[NSMutableArray alloc] init]; 90 | return self; 91 | } 92 | 93 | //=========================================================== 94 | // - initWithNibName 95 | //=========================================================== 96 | - (id)initWithNibName:(NSString *)name bundle:(NSBundle *)bundle 97 | { 98 | [NSException raise:@"KTViewControllerException" format:@"An instance of an KTViewController concrete subclass was initialized using the NSViewController method -initWithNibName:bundle: all view controllers in the enusing tree will have no reference to an KTWindowController object and cannot be automatically added to the responder chain"]; 99 | return nil; 100 | } 101 | 102 | //=========================================================== 103 | // - awakeFromNib 104 | //=========================================================== 105 | - (void)awakeFromNib 106 | {} 107 | 108 | //=========================================================== 109 | // - dealloc 110 | //=========================================================== 111 | - (void)dealloc 112 | { 113 | //NSLog(@"%@ dealloc", self); 114 | [self releaseNibObjects]; 115 | // [mSubcontrollers makeObjectsPerformSelector:@selector(removeObservations)]; 116 | for(KTViewController * aViewController in mSubcontrollers) 117 | [aViewController setParentViewController:nil]; 118 | [mSubcontrollers release]; 119 | // [mLayerControllers makeObjectsPerformSelector:@selector(removeObservations)]; 120 | [mLayerControllers release]; 121 | [super dealloc]; 122 | } 123 | 124 | //=========================================================== 125 | // - releaseNibObjects 126 | //=========================================================== 127 | - (void)releaseNibObjects 128 | { 129 | NSInteger i; 130 | for(i = 0; i < [mTopLevelNibObjects count]; i++) 131 | { 132 | [[mTopLevelNibObjects objectAtIndex:i] release]; 133 | } 134 | [mTopLevelNibObjects release]; 135 | } 136 | 137 | 138 | // CS: I wonder about this situation 139 | // if the window controller changes, say a view controller is moved from one window to another 140 | // it is important that the view controller has been removed from the old window controller 141 | // and that that window controller has re-patched its responder chain 142 | // otherwise it is possible that actions from the other window will get handled by a view controller 143 | // that is no longer a part of that window 144 | //=========================================================== 145 | // - setWindowController 146 | //=========================================================== 147 | - (void)setWindowController:(KTWindowController*)theWindowController 148 | { 149 | wWindowController = theWindowController; 150 | [[self subcontrollers] makeObjectsPerformSelector:@selector(setWindowController:) withObject:theWindowController]; 151 | [[self windowController] patchResponderChain]; 152 | } 153 | 154 | 155 | //=========================================================== 156 | // - setHidden 157 | //=========================================================== 158 | - (void)setHidden:(BOOL)theBool 159 | { 160 | mHidden = theBool; 161 | for(KTViewController * aSubcontroller in [self subcontrollers]) 162 | [aSubcontroller setHidden:theBool]; 163 | // [aSubcontroller _setHidden:theBool patchResponderChain:NO];// 164 | [[self windowController] patchResponderChain]; 165 | } 166 | 167 | 168 | - (void)_setHidden:(BOOL)theHiddenFlag patchResponderChain:(BOOL)thePatchFlag 169 | { 170 | [self willChangeValueForKey:@"hidden"]; 171 | mHidden = theHiddenFlag; 172 | if(thePatchFlag) 173 | [[self windowController] patchResponderChain]; 174 | [self didChangeValueForKey:@"hidden"]; 175 | } 176 | 177 | 178 | //#pragma mark - 179 | //#pragma mark View 180 | //- (NSView*)view 181 | //{ 182 | // return (NSView*)[super view]; 183 | //} 184 | // 185 | //- (void)setView:(NSView*)theView 186 | //{ 187 | // [super setView:theView]; 188 | //} 189 | 190 | 191 | #pragma mark Subcontrollers 192 | //=========================================================== 193 | // - setSubcontrollers 194 | //=========================================================== 195 | - (void)setSubcontrollers:(NSArray *)theSubcontrollers; 196 | { 197 | if(mSubcontrollers != theSubcontrollers) 198 | { 199 | NSMutableArray * aNewSubcontrollers = [theSubcontrollers mutableCopy]; 200 | [mSubcontrollers release]; 201 | mSubcontrollers = aNewSubcontrollers; 202 | [[self windowController] patchResponderChain]; 203 | for(KTViewController*aSubcontroller in mSubcontrollers) 204 | [aSubcontroller setParentViewController:self]; 205 | } 206 | } 207 | 208 | //=========================================================== 209 | // - subcontrollers 210 | //=========================================================== 211 | - (NSArray*)subcontrollers 212 | { 213 | return mSubcontrollers; 214 | } 215 | 216 | 217 | 218 | //=========================================================== 219 | // - addSubcontroller 220 | //=========================================================== 221 | - (void)addSubcontroller:(KTViewController *)theViewController; 222 | { 223 | if(theViewController) 224 | { 225 | [mSubcontrollers addObject:theViewController]; 226 | [[self windowController] patchResponderChain]; 227 | [theViewController setParentViewController:self]; 228 | } 229 | } 230 | 231 | 232 | 233 | //=========================================================== 234 | // - removeSubcontroller 235 | //=========================================================== 236 | - (void)removeSubcontroller:(KTViewController *)theViewController; 237 | { 238 | if(theViewController) 239 | { 240 | [theViewController setParentViewController:nil]; 241 | [theViewController removeObservations]; 242 | [mSubcontrollers removeObject:theViewController]; 243 | [[self windowController] patchResponderChain]; 244 | } 245 | } 246 | 247 | 248 | 249 | //=========================================================== 250 | // - removeAllSubcontrollers 251 | //=========================================================== 252 | - (void)removeAllSubcontrollers 253 | { 254 | for(KTViewController*aSubcontroller in mSubcontrollers) 255 | [aSubcontroller setParentViewController:nil]; 256 | [self setSubcontrollers:[NSArray array]]; 257 | [[self windowController] patchResponderChain]; 258 | } 259 | 260 | 261 | #pragma mark Layer Controllers 262 | //=========================================================== 263 | // - addLayerController 264 | //=========================================================== 265 | - (void)addLayerController:(KTLayerController*)theLayerController 266 | { 267 | if(theLayerController) 268 | { 269 | [mLayerControllers addObject:theLayerController]; 270 | [[self windowController] patchResponderChain]; 271 | } 272 | } 273 | 274 | 275 | 276 | //=========================================================== 277 | // - removeLayerController 278 | //=========================================================== 279 | - (void)removeLayerController:(KTLayerController*)theLayerController 280 | { 281 | if(theLayerController) 282 | { 283 | [mLayerControllers removeObject:theLayerController]; 284 | [[self windowController] patchResponderChain]; 285 | } 286 | } 287 | 288 | 289 | 290 | //=========================================================== 291 | // - layerControllers 292 | //=========================================================== 293 | - (NSArray*)layerControllers 294 | { 295 | return mLayerControllers; 296 | } 297 | 298 | 299 | //=========================================================== 300 | // - descendants 301 | //=========================================================== 302 | - (NSArray *)descendants 303 | { 304 | NSMutableArray *aDescendantsList = [[[NSMutableArray alloc] init] autorelease]; 305 | 306 | for (KTViewController * aSubViewController in mSubcontrollers) 307 | { 308 | if([aSubViewController hidden]==NO) 309 | { 310 | [aDescendantsList addObject:aSubViewController]; 311 | if ( [[aSubViewController subcontrollers] count] > 0 312 | || [[aSubViewController layerControllers] count] > 0) 313 | [aDescendantsList addObjectsFromArray:[aSubViewController descendants]]; 314 | } 315 | } 316 | for(KTLayerController * aLayerController in mLayerControllers) 317 | { 318 | [aDescendantsList addObject:aLayerController]; 319 | if([[aLayerController subcontrollers] count] > 0) 320 | [aDescendantsList addObjectsFromArray:[aLayerController descendants]]; 321 | } 322 | return aDescendantsList; 323 | } 324 | 325 | 326 | //=========================================================== 327 | // - removeAllViewControllers 328 | //=========================================================== 329 | - (void)removeObservations 330 | { 331 | // subcontrollers 332 | [mSubcontrollers makeObjectsPerformSelector:@selector(removeObservations)]; 333 | // layer controllers 334 | [mLayerControllers makeObjectsPerformSelector:@selector(removeObservations)]; 335 | } 336 | 337 | 338 | //=========================================================== 339 | // - loadNibNamed: 340 | //=========================================================== 341 | - (BOOL)loadNibNamed:(NSString*)theNibName bundle:(NSBundle*)theBundle 342 | { 343 | BOOL aSuccess; 344 | NSArray * anObjectList = nil; 345 | NSNib * aNib = [[[NSNib alloc] initWithNibNamed:theNibName bundle:theBundle] autorelease]; 346 | aSuccess = [aNib instantiateNibWithOwner:self topLevelObjects:&anObjectList]; 347 | if(aSuccess) 348 | { 349 | int i; 350 | for(i = 0; i < [anObjectList count]; i++) 351 | [mTopLevelNibObjects addObject:[anObjectList objectAtIndex:i]]; 352 | } 353 | return aSuccess; 354 | } 355 | 356 | @end 357 | -------------------------------------------------------------------------------- /Framework/Controllers/KTWindowController.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTWindowController.h 3 | // View Controllers 4 | // 5 | // Created by Jonathan Dann and Cathy Shive on 14/04/2008. 6 | // 7 | // Copyright (c) 2008 Jonathan Dann and Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "View Controllers" by Jonathan Dann and Cathy Shive" will do. 32 | 33 | #import 34 | 35 | @class KTViewController; 36 | @interface KTWindowController : NSWindowController 37 | { 38 | @private 39 | NSMutableArray * mViewControllers; 40 | } 41 | 42 | - (NSArray*)viewControllers; 43 | - (void)setViewControllers:(NSArray*)theViewControllers; 44 | - (void)addViewController:(KTViewController *)theViewController; 45 | - (void)removeViewController:(KTViewController *)theViewController; 46 | - (void)removeAllViewControllers; 47 | - (void)patchResponderChain; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Framework/Controllers/KTWindowController.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTWindowController.m 3 | // View Controllers 4 | // 5 | // Created by Jonathan Dann and Cathy Shive on 14/04/2008. 6 | // 7 | // Copyright (c) 2008 Jonathan Dann and Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "View Controllers" by Jonathan Dann and Cathy Shive" will do. 32 | 33 | #import "KTWindowController.h" 34 | #import "KTViewController.h" 35 | 36 | @implementation KTWindowController 37 | 38 | //=========================================================== 39 | // - initWithWindowNibName: 40 | //=========================================================== 41 | - (id)initWithWindowNibName:(NSString *)theNibName; 42 | { 43 | if (![super initWithWindowNibName:theNibName]) 44 | return nil; 45 | 46 | mViewControllers = [[NSMutableArray alloc] init]; 47 | return self; 48 | } 49 | 50 | 51 | 52 | //=========================================================== 53 | // - dealloc 54 | //=========================================================== 55 | - (void)dealloc 56 | { 57 | [mViewControllers release]; 58 | [super dealloc]; 59 | } 60 | 61 | 62 | 63 | //=========================================================== 64 | // - setViewControllers 65 | //=========================================================== 66 | - (void)windowWillClose:(NSNotification *)theNotification 67 | { 68 | /*CS: I don't know if we want to actually do this in the framework 69 | it only really truely works if the view controllers are actually released when the window closes 70 | and they are re-initialized when the window is created. You might have a window that you want 71 | to open and close without releasing the controllers/views. In this case, we would have the 72 | controllers remove all their observations or bindings when the window closes and we don't have a way or hook to re-establish 73 | the observations/bindings when the window opens again - needs to be balanced*/ 74 | //[[self viewControllers] makeObjectsPerformSelector:@selector(removeObservations)]; 75 | } 76 | 77 | 78 | //=========================================================== 79 | // - setViewControllers 80 | //=========================================================== 81 | - (void)setViewControllers:(NSArray *)theViewControllers 82 | { 83 | if(mViewControllers != theViewControllers) 84 | { 85 | NSMutableArray * aNewViewControllers = [theViewControllers mutableCopy]; 86 | [mViewControllers makeObjectsPerformSelector:@selector(removeObservations)]; 87 | [mViewControllers release]; 88 | mViewControllers = aNewViewControllers; 89 | } 90 | } 91 | 92 | 93 | 94 | //=========================================================== 95 | // - viewControllers 96 | //=========================================================== 97 | - (NSArray*)viewControllers 98 | { 99 | return mViewControllers; 100 | } 101 | 102 | 103 | 104 | //=========================================================== 105 | // - addViewController: 106 | //=========================================================== 107 | - (void)addViewController:(KTViewController *)theViewController 108 | { 109 | if(theViewController) 110 | { 111 | [mViewControllers addObject:theViewController]; 112 | [self patchResponderChain]; 113 | } 114 | } 115 | 116 | 117 | 118 | //=========================================================== 119 | // - removeViewController: 120 | //=========================================================== 121 | - (void)removeViewController:(KTViewController *)theViewController 122 | { 123 | if(theViewController) 124 | { 125 | [theViewController removeObservations]; 126 | [mViewControllers removeObject:theViewController]; 127 | [self patchResponderChain]; 128 | } 129 | } 130 | 131 | 132 | 133 | //=========================================================== 134 | // - removeAllViewControllers 135 | //=========================================================== 136 | - (void)removeAllViewControllers 137 | { 138 | [mViewControllers makeObjectsPerformSelector:@selector(removeObservations)]; 139 | [mViewControllers removeAllObjects]; 140 | } 141 | 142 | //=========================================================== 143 | // - removeObservations 144 | //=========================================================== 145 | - (void)removeObservations 146 | { 147 | [mViewControllers makeObjectsPerformSelector:@selector(removeObservations)]; 148 | } 149 | 150 | //=========================================================== 151 | // - patchResponderChain 152 | //=========================================================== 153 | - (void)patchResponderChain 154 | { 155 | 156 | NSMutableArray * aFlatViewControllersList = [NSMutableArray array]; 157 | for (KTViewController * aViewController in mViewControllers) 158 | { // flatten the view controllers into an array 159 | if([aViewController hidden]==NO) 160 | { 161 | [aFlatViewControllersList addObject:aViewController]; 162 | [aFlatViewControllersList addObjectsFromArray:[aViewController descendants]]; 163 | } 164 | } 165 | if([aFlatViewControllersList count]>0) 166 | { 167 | [self setNextResponder:[aFlatViewControllersList objectAtIndex:0]]; 168 | NSUInteger i = 0; 169 | NSUInteger viewControllerCount = [aFlatViewControllersList count] - 1; 170 | for (i = 0; i < viewControllerCount ; i++) 171 | { 172 | // set the next responder of each controller to the next, the last in the array has no next responder. 173 | [[aFlatViewControllersList objectAtIndex:i] setNextResponder:[aFlatViewControllersList objectAtIndex:i + 1]]; 174 | } 175 | [[aFlatViewControllersList lastObject] setNextResponder:nil]; 176 | } 177 | } 178 | 179 | 180 | @end -------------------------------------------------------------------------------- /Framework/KTAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // BWAnimator.h 3 | // Photoshoot 4 | // 5 | // Created by Cathy Shive on 7/24/07. 6 | // Copyright 2007 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | @class KTAnimator; 11 | @interface NSObject (KTANimatorDelegateMethods) 12 | - (void)animatorDidStartAnimating:(KTAnimator*)theAnimator; 13 | - (void)animator:(KTAnimator*)theAnimator didStartAnimation:(NSDictionary*)theAnimation; 14 | - (void)animator:(KTAnimator*)theAnimator didUpdateAnimation:(NSDictionary*)theAnimation; 15 | - (void)animator:(KTAnimator*)theAnimator didEndAnimation:(NSDictionary*)theAnimation; 16 | - (void)animatorDidEndAllAnimations:(KTAnimator*)theAnimator; 17 | @end 18 | 19 | extern NSString *const KTAnimatorAnimationNameKey; 20 | extern NSString *const KTAnimatorAnimationObjectKey; 21 | extern NSString *const KTAnimatorAnimationKeyPathKey; 22 | extern NSString *const KTAnimatorAnimationDurationKey; 23 | extern NSString *const KTAnimatorAnimationSpeedKey; 24 | extern NSString *const KTAnimatorAnimationStartValueKey; 25 | extern NSString *const KTAnimatorAnimationEndValueKey; 26 | extern NSString *const KTAnimatorAnimationLocationKey; 27 | extern NSString *const KTAnimatorAnimationTypeKey; 28 | extern NSString *const KTAnimatorFloatAnimation; 29 | extern NSString *const KTAnimatorRectAnimation; 30 | extern NSString *const KTAnimatorPointAnimation; 31 | extern NSString *const KTAnimatorAnimationCurveKey; 32 | 33 | typedef enum 34 | { 35 | kKTAnimationType_EaseInAndOut = 0, 36 | kKTAnimationType_EaseIn, 37 | kKTAnimationType_EaseOut, 38 | kKTAnimationType_Linear 39 | 40 | }KTAnimationType; 41 | 42 | 43 | @interface KTAnimator : NSObject 44 | { 45 | NSTimer * mAnimationTimer; 46 | NSMutableArray * mAnimationQueue; 47 | id wDelegate; 48 | CGFloat mFramesPerSecond; 49 | BOOL mDoubleDuration; 50 | } 51 | 52 | @property (nonatomic, readwrite, assign) CGFloat framesPerSecond; 53 | @property (nonatomic, readwrite, assign) id delegate; 54 | - (void)animateObject:(NSMutableDictionary*)theAnimationProperties; 55 | - (void)removeAllAnimations; 56 | - (void)doubleDurationOfAllAnimations; 57 | @end 58 | -------------------------------------------------------------------------------- /Framework/KTLayoutDynamicImplementation.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTLayoutDynamicImplementation.h 3 | // KTUIKit 4 | // 5 | // Created by Jonathan on 11/03/2009. 6 | // Copyright 2009 espresso served here. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //const char *const KTViewLayoutManagerIvarName = "mLayoutManager"; 12 | extern NSString *const KTViewLayoutManagerKey; 13 | 14 | extern id layoutManagerDynamicMethodIMP(id self, SEL _cmd); 15 | 16 | extern void setLayoutManagerDynamicMethodIMP(id self, SEL _cmd, id layoutManager); 17 | 18 | extern id parentDynamicMethodIMP(id self, SEL _cmd); 19 | 20 | extern id childrenDynamicMethodIMP(id self, SEL _cmd); 21 | 22 | extern id initWithFrameDynamicIMP(id self, SEL _cmd, NSRect frame); 23 | 24 | extern id initWithCoderDynamicIMP(id self, SEL _cmd, NSCoder *coder); 25 | 26 | extern void encodeWithCoderDynamicIMP(id self, SEL _cmd, NSCoder *coder); 27 | 28 | extern void deallocDynamicIMP(id self, SEL _cmd); 29 | -------------------------------------------------------------------------------- /Framework/KTLayoutDynamicImplementation.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTLayoutDynamicImplementation.m 3 | // KTUIKit 4 | // 5 | // Created by Jonathan on 11/03/2009. 6 | // Copyright 2009 espresso served here. All rights reserved. 7 | // 8 | 9 | #import "KTLayoutDynamicImplementation.h" 10 | #import "KTLayoutManager.h" 11 | #import 12 | 13 | NSString *const KTViewLayoutManagerKey = @"viewLayoutManager"; 14 | 15 | id layoutManagerDynamicMethodIMP(id self, SEL _cmd) { 16 | Ivar mLayoutManagerAsIvar = class_getInstanceVariable([self class], "mLayoutManager"); 17 | return object_getIvar(self, mLayoutManagerAsIvar); 18 | } 19 | 20 | void setLayoutManagerDynamicMethodIMP(id self, SEL _cmd, id layoutManager) { 21 | Ivar mLayoutManagerAsIvar = class_getInstanceVariable([self class], "mLayoutManager"); 22 | id mLayoutManager = object_getIvar(self, mLayoutManagerAsIvar); 23 | 24 | if (mLayoutManager == layoutManager) 25 | return; 26 | [mLayoutManager release]; 27 | mLayoutManager = [layoutManager retain]; 28 | } 29 | 30 | id parentDynamicMethodIMP(id self, SEL _cmd) { 31 | if([[self superview] conformsToProtocol:@protocol(KTViewLayout)]) 32 | return (id )[self superview]; 33 | return nil; 34 | } 35 | 36 | id childrenDynamicMethodIMP(id self, SEL _cmd) { 37 | return nil; 38 | } 39 | 40 | id initWithFrameDynamicIMP(id self, SEL _cmd, NSRect frame) { 41 | struct objc_super s = {self, [self superclass]}; 42 | if (self = objc_msgSendSuper(&s, _cmd, frame)) 43 | [self setViewLayoutManager:[[[KTLayoutManager alloc] initWithView:self] autorelease]]; 44 | return self; 45 | } 46 | 47 | id initWithCoderDynamicIMP(id self, SEL _cmd, NSCoder *coder) { 48 | struct objc_super s = {self, [self superclass]}; 49 | if (self = objc_msgSendSuper(&s, _cmd, coder)) { 50 | KTLayoutManager * aLayoutManager = [coder decodeObjectForKey:KTViewLayoutManagerKey]; 51 | if(aLayoutManager == nil) 52 | aLayoutManager = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 53 | else 54 | [aLayoutManager setView:self]; 55 | [self setViewLayoutManager:aLayoutManager]; 56 | } 57 | return self; 58 | } 59 | 60 | void encodeWithCoderDynamicIMP(id self, SEL _cmd, NSCoder *coder) { 61 | struct objc_super s = {self, [self superclass]}; 62 | (void)objc_msgSendSuper(&s, _cmd, coder); 63 | [coder encodeObject:[self viewLayoutManager] forKey:KTViewLayoutManagerKey]; 64 | } 65 | 66 | void deallocDynamicIMP(id self, SEL _cmd) { 67 | Ivar mLayoutManagerAsIvar = class_getInstanceVariable([self class], "mLayoutManager"); 68 | [object_getIvar(self, mLayoutManagerAsIvar) release]; 69 | 70 | struct objc_super s = {self, [self superclass]}; 71 | (void)objc_msgSendSuper(&s, _cmd); 72 | } 73 | -------------------------------------------------------------------------------- /Framework/KTUIKit.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | #import 11 | #import "KTUIKit/KTScroller.h" 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | #import 33 | #import 34 | #import -------------------------------------------------------------------------------- /Framework/Resources/KTUIKitFramework-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | KTUIKitFramework 9 | CFBundleIdentifier 10 | com.katidev.KTUIKit 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 0.9.1 19 | NSPrincipalClass 20 | KTUIKit 21 | 22 | 23 | -------------------------------------------------------------------------------- /Framework/Views/Drawing/NSBezierPathAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBezierPathCategory.h 3 | // 4 | // Created by Cathy Shive on 12/21/07. 5 | // Copyright 2007 __MyCompanyName__. All rights reserved. 6 | // 7 | 8 | // http://developer.apple.com/samplecode/Reducer/listing20.html 9 | 10 | #import 11 | 12 | 13 | @interface NSBezierPath (RoundRect) 14 | + (NSBezierPath *)bezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius; 15 | - (void)appendBezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius; 16 | 17 | + (NSBezierPath *)bezierPathWithLeftRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 18 | + (NSBezierPath *)bezierPathWithRightRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 19 | + (NSBezierPath *)bezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 20 | + (NSBezierPath *)bezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 21 | + (NSBezierPath *)bezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theRadius; 22 | + (NSBezierPath *)bezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theRadius; 23 | - (void)appendBezierPathWithLeftRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 24 | - (void)appendBezierPathWithRightRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 25 | - (void)appendBezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 26 | - (void)appendBezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius; 27 | @end 28 | -------------------------------------------------------------------------------- /Framework/Views/Drawing/NSBezierPathAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBezierPathCategory.m 3 | // 4 | // Created by Cathy Shive on 12/21/07. 5 | // Copyright 2007 __MyCompanyName__. All rights reserved. 6 | // 7 | 8 | #import "NSBezierPathAdditions.h" 9 | 10 | @implementation NSBezierPath (RoundRect) 11 | 12 | + (NSBezierPath *)bezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius { 13 | NSBezierPath *result = [NSBezierPath bezierPath]; 14 | [result appendBezierPathWithRoundedRect:rect cornerRadius:radius]; 15 | return result; 16 | } 17 | 18 | - (void)appendBezierPathWithRoundedRect:(NSRect)rect cornerRadius:(float)radius { 19 | if (!NSIsEmptyRect(rect)) { 20 | if (radius > 0.0) { 21 | // Clamp radius to be no larger than half the rect's width or height. 22 | float clampedRadius = MIN(radius, 0.5 * MIN(rect.size.width, rect.size.height)); 23 | 24 | NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); 25 | NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); 26 | NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect)); 27 | 28 | [self moveToPoint:NSMakePoint(NSMidX(rect), NSMaxY(rect))]; 29 | [self appendBezierPathWithArcFromPoint:topLeft toPoint:rect.origin radius:clampedRadius]; 30 | [self appendBezierPathWithArcFromPoint:rect.origin toPoint:bottomRight radius:clampedRadius]; 31 | [self appendBezierPathWithArcFromPoint:bottomRight toPoint:topRight radius:clampedRadius]; 32 | [self appendBezierPathWithArcFromPoint:topRight toPoint:topLeft radius:clampedRadius]; 33 | [self closePath]; 34 | } else { 35 | // When radius == 0.0, this degenerates to the simple case of a plain rectangle. 36 | [self appendBezierPathWithRect:rect]; 37 | } 38 | } 39 | } 40 | 41 | 42 | + (NSBezierPath *)bezierPathWithLeftRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 43 | { 44 | NSBezierPath * aBezierPathToReturn = [NSBezierPath bezierPath]; 45 | [aBezierPathToReturn appendBezierPathWithLeftRoundedRect:theRect cornerRadius:theCornerRadius]; 46 | return aBezierPathToReturn; 47 | } 48 | 49 | - (void)appendBezierPathWithLeftRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 50 | { 51 | if (!NSIsEmptyRect(theRect)) 52 | { 53 | if (theCornerRadius > 0.0) 54 | { 55 | float aClampedRadius = MIN(theCornerRadius, 0.5*MIN(theRect.size.width, theRect.size.height)); 56 | NSPoint aTopLeftPoint = NSMakePoint(NSMinX(theRect), NSMaxY(theRect)); 57 | NSPoint aTopRightPoint = NSMakePoint(NSMaxX(theRect), NSMaxY(theRect)); 58 | NSPoint aBottomRightPoint = NSMakePoint(NSMaxX(theRect), NSMinY(theRect)); 59 | 60 | // start at the top middle 61 | [self moveToPoint:NSMakePoint(NSMidX(theRect), NSMaxY(theRect))]; 62 | [self appendBezierPathWithArcFromPoint:aTopLeftPoint toPoint:theRect.origin radius:aClampedRadius]; 63 | [self appendBezierPathWithArcFromPoint:theRect.origin toPoint:aBottomRightPoint radius:aClampedRadius]; 64 | // now connect the last line 65 | 66 | [self lineToPoint:aBottomRightPoint]; 67 | [self lineToPoint:aTopRightPoint]; 68 | [self closePath]; 69 | } 70 | else 71 | [self appendBezierPathWithRect:theRect]; 72 | } 73 | } 74 | 75 | + (NSBezierPath *)bezierPathWithRightRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 76 | { 77 | NSBezierPath * aBezierPathToReturn = [NSBezierPath bezierPath]; 78 | [aBezierPathToReturn appendBezierPathWithRightRoundedRect:theRect cornerRadius:theCornerRadius]; 79 | return aBezierPathToReturn; 80 | 81 | } 82 | - (void)appendBezierPathWithRightRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 83 | { 84 | if (!NSIsEmptyRect(theRect)) 85 | { 86 | if (theCornerRadius > 0.0) 87 | { 88 | float aClampedRadius = MIN(theCornerRadius, 0.5*MIN(theRect.size.width, theRect.size.height)); 89 | NSPoint aTopLeftPoint = NSMakePoint(NSMinX(theRect), NSMaxY(theRect)); 90 | NSPoint aTopRightPoint = NSMakePoint(NSMaxX(theRect), NSMaxY(theRect)); 91 | NSPoint aBottomRightPoint = NSMakePoint(NSMaxX(theRect), NSMinY(theRect)); 92 | 93 | // start at the top middle 94 | [self moveToPoint:NSMakePoint(NSMidX(theRect), NSMaxY(theRect))]; 95 | [self appendBezierPathWithArcFromPoint:aTopRightPoint toPoint:aBottomRightPoint radius:aClampedRadius]; 96 | [self appendBezierPathWithArcFromPoint:aBottomRightPoint toPoint:theRect.origin radius:aClampedRadius]; 97 | // now connect the last line 98 | 99 | [self lineToPoint:theRect.origin]; 100 | [self lineToPoint:aTopLeftPoint]; 101 | [self closePath]; 102 | } 103 | else 104 | [self appendBezierPathWithRect:theRect]; 105 | } 106 | } 107 | 108 | + (NSBezierPath *)bezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 109 | { 110 | NSBezierPath * aBezierPathToReturn = [NSBezierPath bezierPath]; 111 | [aBezierPathToReturn appendBezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius]; 112 | return aBezierPathToReturn; 113 | } 114 | 115 | - (void)appendBezierPathWithTopRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 116 | { 117 | if (!NSIsEmptyRect(theRect)) 118 | { 119 | if (theCornerRadius > 0.0) 120 | { 121 | float aClampedRadius = MIN(theCornerRadius, 0.5*MIN(theRect.size.width, theRect.size.height)); 122 | NSPoint aTopLeftPoint = NSMakePoint(NSMinX(theRect), NSMaxY(theRect)); 123 | NSPoint aTopRightPoint = NSMakePoint(NSMaxX(theRect), NSMaxY(theRect)); 124 | NSPoint aBottomRightPoint = NSMakePoint(NSMaxX(theRect), NSMinY(theRect)); 125 | 126 | // start at the bottom left 127 | [self moveToPoint:theRect.origin]; 128 | [self appendBezierPathWithArcFromPoint:aTopLeftPoint toPoint:aTopRightPoint radius:aClampedRadius]; 129 | [self appendBezierPathWithArcFromPoint:aTopRightPoint toPoint:aBottomRightPoint radius:aClampedRadius]; 130 | 131 | [self lineToPoint:aBottomRightPoint]; 132 | [self lineToPoint:theRect.origin]; 133 | [self closePath]; 134 | } 135 | else 136 | [self appendBezierPathWithRect:theRect]; 137 | } 138 | } 139 | 140 | + (NSBezierPath *)bezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 141 | { 142 | NSBezierPath * aBezierPathToReturn = [NSBezierPath bezierPath]; 143 | [aBezierPathToReturn appendBezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius]; 144 | return aBezierPathToReturn; 145 | } 146 | 147 | - (void)appendBezierPathWithBottomRoundedRect:(NSRect)theRect cornerRadius:(float)theCornerRadius 148 | { 149 | if (!NSIsEmptyRect(theRect)) 150 | { 151 | if (theCornerRadius > 0.0) 152 | { 153 | float aClampedRadius = MIN(theCornerRadius, 0.5*MIN(theRect.size.width, theRect.size.height)); 154 | NSPoint aTopLeftPoint = NSMakePoint(NSMinX(theRect), NSMaxY(theRect)); 155 | NSPoint aTopRightPoint = NSMakePoint(NSMaxX(theRect), NSMaxY(theRect)); 156 | NSPoint aBottomRightPoint = NSMakePoint(NSMaxX(theRect), NSMinY(theRect)); 157 | 158 | // start at the top right 159 | [self moveToPoint:aTopRightPoint]; 160 | [self appendBezierPathWithArcFromPoint:aBottomRightPoint toPoint:theRect.origin radius:aClampedRadius]; 161 | [self appendBezierPathWithArcFromPoint:theRect.origin toPoint:aTopLeftPoint radius:aClampedRadius]; 162 | // now connect the last line 163 | 164 | [self lineToPoint:aTopLeftPoint]; 165 | [self lineToPoint:aTopRightPoint]; 166 | [self closePath]; 167 | } 168 | else 169 | [self appendBezierPathWithRect:theRect]; 170 | } 171 | } 172 | 173 | 174 | @end -------------------------------------------------------------------------------- /Framework/Views/KTViewProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTView 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | #import "KTViewLayout.h" 34 | #import "KTStyle.h" 35 | 36 | @protocol KTView 37 | 38 | - (void)setLabel:(NSString*)theLabel; 39 | - (NSString*)label; 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /Framework/Views/Layout/KTLayoutManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTLayoutManager.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | #import 34 | #import "KTViewProtocol.h" 35 | 36 | typedef enum 37 | { 38 | KTSizeAbsolute = 0, 39 | KTSizeFill, 40 | KTSizePercentage, 41 | 42 | } KTSizeType; 43 | 44 | 45 | typedef enum 46 | { 47 | KTHorizontalPositionAbsolute = 0, 48 | KTHorizontalPositionStickLeft, 49 | KTHorizontalPositionStickRight, 50 | KTHorizontalPositionKeepCentered, 51 | KTHorizontalPositionFloatLeft, 52 | KTHorizontalPositionFloatRight, 53 | KTHorizontalPositionProportional 54 | 55 | }KTHorizontalPositionType; 56 | 57 | 58 | typedef enum 59 | { 60 | 61 | KTVerticalPositionAbsolute = 0, 62 | KTVerticalPositionStickTop, 63 | KTVerticalPositionStickBottom, 64 | KTVerticalPositionKeepCentered, 65 | KTVerticalPositionFloatUp, 66 | KTVerticalPositionFloatDown, 67 | KTVerticalPositionProportional 68 | 69 | }KTVerticalPositionType; 70 | 71 | 72 | @interface KTLayoutManager : NSObject 73 | { 74 | id wView; 75 | 76 | BOOL mShouldDoLayout; 77 | 78 | KTSizeType mWidthType; 79 | KTSizeType mHeightType; 80 | 81 | KTHorizontalPositionType mHorizontalPositionType; 82 | KTVerticalPositionType mVerticalPositionType; 83 | 84 | CGFloat mWidthPercentage; 85 | CGFloat mHeightPercentage; 86 | CGFloat mHorizontalPositionPercentage; 87 | CGFloat mVerticalPositionPercentage; 88 | 89 | CGFloat mMarginLeft; 90 | CGFloat mMarginRight; 91 | CGFloat mMarginTop; 92 | CGFloat mMarginBottom; 93 | 94 | CGFloat mMinWidth; 95 | CGFloat mMaxWidth; 96 | CGFloat mMinHeight; 97 | CGFloat mMaxHeight; 98 | } 99 | 100 | @property(nonatomic, readwrite, assign) BOOL shouldDoLayout; 101 | @property(nonatomic, readwrite, assign) KTSizeType heightType; 102 | @property(nonatomic, readwrite, assign) KTSizeType widthType; 103 | @property(nonatomic, readwrite, assign) KTHorizontalPositionType horizontalPositionType; 104 | @property(nonatomic, readwrite, assign) KTVerticalPositionType verticalPositionType; 105 | @property(nonatomic, readwrite, assign) CGFloat marginTop; 106 | @property(nonatomic, readwrite, assign) CGFloat marginBottom; 107 | @property(nonatomic, readwrite, assign) CGFloat marginLeft; 108 | @property(nonatomic, readwrite, assign) CGFloat marginRight; 109 | @property(nonatomic, readwrite, assign) CGFloat heightPercentage; 110 | @property(nonatomic, readwrite, assign) CGFloat widthPercentage; 111 | @property(nonatomic, readwrite, assign) CGFloat horizontalPositionPercentage; 112 | @property(nonatomic, readwrite, assign) CGFloat verticalPositionPercentage; 113 | @property(nonatomic, readwrite, assign) CGFloat minWidth; 114 | @property(nonatomic, readwrite, assign) CGFloat maxWidth; 115 | @property(nonatomic, readwrite, assign) CGFloat minHeight; 116 | @property(nonatomic, readwrite, assign) CGFloat maxHeight; 117 | @property(nonatomic, readwrite, assign) id view; 118 | - (NSArray *)keysForCoding; 119 | 120 | - (id)initWithView:(id)theView; 121 | - (void)setMargin:(float)theMargin; 122 | - (void)setMarginTop:(float)theTopMargin 123 | right:(float)theRightMargin 124 | bottom:(float)theBottomMargin 125 | left:(float)theLeftMargin; 126 | 127 | - (void)refreshLayout; 128 | 129 | @end 130 | -------------------------------------------------------------------------------- /Framework/Views/Layout/KTViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewLayout.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | @class KTLayoutManager; 34 | 35 | @protocol KTViewLayout 36 | 37 | - (void)setViewLayoutManager:(KTLayoutManager*)theLayoutManager; 38 | - (KTLayoutManager*)viewLayoutManager; 39 | 40 | - (void)setFrame:(NSRect)theFrame; 41 | - (NSRect)frame; 42 | 43 | - (id)parent; 44 | - (NSArray*)children; 45 | 46 | @end -------------------------------------------------------------------------------- /Framework/Views/Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m: -------------------------------------------------------------------------------- 1 | //=========================================================== 2 | // - initWithFrame 3 | //=========================================================== 4 | - (id)initWithFrame:(NSRect)theFrame 5 | { 6 | if(![super initWithFrame:theFrame]) 7 | return nil; 8 | 9 | // Layout 10 | KTLayoutManager * aLayoutManger = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 11 | [self setViewLayoutManager:aLayoutManger]; 12 | return self; 13 | } 14 | 15 | //=========================================================== 16 | // - encodeWithCoder: 17 | //=========================================================== 18 | - (void)encodeWithCoder:(NSCoder*)theCoder 19 | { 20 | [super encodeWithCoder:theCoder]; 21 | [theCoder encodeObject:[self viewLayoutManager] forKey:@"layoutManager"]; 22 | } 23 | 24 | //=========================================================== 25 | // - initWithCoder: 26 | //=========================================================== 27 | - (id)initWithCoder:(NSCoder*)theCoder 28 | { 29 | if (![super initWithCoder:theCoder]) 30 | return nil; 31 | 32 | KTLayoutManager * aLayoutManager = [theCoder decodeObjectForKey:@"layoutManager"]; 33 | if(aLayoutManager == nil) 34 | aLayoutManager = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 35 | else 36 | [aLayoutManager setView:self]; 37 | [self setViewLayoutManager:aLayoutManager]; 38 | 39 | return self; 40 | } 41 | 42 | //=========================================================== 43 | // - dealloc 44 | //=========================================================== 45 | - (void)dealloc 46 | { 47 | [mLayoutManager release]; 48 | [super dealloc]; 49 | } 50 | 51 | //=========================================================== 52 | // - setViewLayoutManager 53 | //=========================================================== 54 | - (void)setViewLayoutManager:(KTLayoutManager*)theLayoutManager 55 | { 56 | if(mLayoutManager != theLayoutManager) 57 | { 58 | [mLayoutManager release]; 59 | mLayoutManager = [theLayoutManager retain]; 60 | //[self setAutoresizingMask:NSViewNotSizable]; 61 | } 62 | } 63 | 64 | //=========================================================== 65 | // - viewLayoutManager 66 | //=========================================================== 67 | - (KTLayoutManager*)viewLayoutManager 68 | { 69 | return mLayoutManager; 70 | } 71 | 72 | //=========================================================== 73 | // - setFrame 74 | //=========================================================== 75 | - (void)setFrame:(NSRect)theFrame 76 | { 77 | [super setFrame:theFrame]; 78 | } 79 | 80 | //=========================================================== 81 | // - frame 82 | //=========================================================== 83 | - (NSRect)frame 84 | { 85 | return [super frame]; 86 | } 87 | 88 | //=========================================================== 89 | // - parent 90 | //=========================================================== 91 | - (id)parent 92 | { 93 | if([[self superview] conformsToProtocol:@protocol(KTViewLayout)]) 94 | return (id)[self superview]; 95 | else 96 | return nil; 97 | } 98 | 99 | //=========================================================== 100 | // - children 101 | //=========================================================== 102 | - (NSArray*)children 103 | { 104 | return nil; 105 | } 106 | -------------------------------------------------------------------------------- /Framework/Views/Layout/SharedCode/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Framework/Views/Layout/SharedCode/readme.txt -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTButton.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTButton : NSButton 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTButton.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTButton.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTButton 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTColorWell.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTColorWell.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/23/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | extern NSString *const KTColorWellDidActivateNotification; 13 | 14 | @class KTLayoutManager; 15 | 16 | @interface KTColorWell : NSColorWell 17 | { 18 | KTLayoutManager * mLayoutManager; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTColorWell.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTColorWell.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/23/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTColorWell.h" 10 | #import "KTLayoutManager.h" 11 | 12 | NSString* const KTColorWellDidActivateNotification = @"KTColorWellDidActivateNotification"; 13 | 14 | @implementation KTColorWell 15 | //=========================================================== 16 | // - initWithFrame 17 | //=========================================================== 18 | - (id)initWithFrame:(NSRect)theFrame 19 | { 20 | if(![super initWithFrame:theFrame]) 21 | return nil; 22 | 23 | // Layout 24 | KTLayoutManager * aLayoutManger = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 25 | [self setViewLayoutManager:aLayoutManger]; 26 | return self; 27 | } 28 | 29 | //=========================================================== 30 | // - encodeWithCoder: 31 | //=========================================================== 32 | - (void)encodeWithCoder:(NSCoder*)theCoder 33 | { 34 | [super encodeWithCoder:theCoder]; 35 | [theCoder encodeObject:[self viewLayoutManager] forKey:@"layoutManager"]; 36 | } 37 | 38 | //=========================================================== 39 | // - initWithCoder: 40 | //=========================================================== 41 | - (id)initWithCoder:(NSCoder*)theCoder 42 | { 43 | if (![super initWithCoder:theCoder]) 44 | return nil; 45 | 46 | KTLayoutManager * aLayoutManager = [theCoder decodeObjectForKey:@"layoutManager"]; 47 | if(aLayoutManager == nil) 48 | aLayoutManager = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 49 | else 50 | [aLayoutManager setView:self]; 51 | [self setViewLayoutManager:aLayoutManager]; 52 | 53 | return self; 54 | } 55 | 56 | //=========================================================== 57 | // - dealloc 58 | //=========================================================== 59 | - (void)dealloc 60 | { 61 | [mLayoutManager release]; 62 | [super dealloc]; 63 | } 64 | 65 | //=========================================================== 66 | // - activate: 67 | //=========================================================== 68 | - (void)activate:(BOOL)exclusive 69 | { 70 | // make NSColorWell slightly more friendly by broadcasting a notificaiton that it is is now active 71 | // so that other custom views using the color panel can stop listening to the color changes 72 | [[NSNotificationCenter defaultCenter] postNotificationName:KTColorWellDidActivateNotification object:self userInfo:nil]; 73 | [super activate:exclusive]; 74 | } 75 | 76 | //=========================================================== 77 | // - setViewLayoutManager 78 | //=========================================================== 79 | - (void)setViewLayoutManager:(KTLayoutManager*)theLayoutManager 80 | { 81 | if(mLayoutManager != theLayoutManager) 82 | { 83 | [mLayoutManager release]; 84 | mLayoutManager = [theLayoutManager retain]; 85 | [self setAutoresizingMask:NSViewNotSizable]; 86 | } 87 | } 88 | 89 | //=========================================================== 90 | // - viewLayoutManager 91 | //=========================================================== 92 | - (KTLayoutManager*)viewLayoutManager 93 | { 94 | return mLayoutManager; 95 | } 96 | 97 | //=========================================================== 98 | // - setFrame 99 | //=========================================================== 100 | - (void)setFrame:(NSRect)theFrame 101 | { 102 | [super setFrame:theFrame]; 103 | } 104 | 105 | //=========================================================== 106 | // - frame 107 | //=========================================================== 108 | - (NSRect)frame 109 | { 110 | return [super frame]; 111 | } 112 | 113 | //=========================================================== 114 | // - parent 115 | //=========================================================== 116 | - (id)parent 117 | { 118 | if([[self superview] conformsToProtocol:@protocol(KTViewLayout)]) 119 | return (id)[self superview]; 120 | else 121 | return nil; 122 | } 123 | 124 | //=========================================================== 125 | // - children 126 | //=========================================================== 127 | - (NSArray*)children 128 | { 129 | return nil; 130 | } 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTControl.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 28/10/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTControl : NSControl 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTControl.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 28/10/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTControl.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTControl 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTGradientPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTGradientPicker.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewControl.h" 11 | typedef enum 12 | { 13 | kKTGradientPickerMouseDragState_NoDrag = 0, 14 | kKTGradientPickerMouseDragState_DraggingColorStop 15 | 16 | }KTGradientPickerMouseDragState; 17 | 18 | @interface KTGradientPicker : KTViewControl 19 | { 20 | NSGradient * mGradientValue; 21 | NSInteger mActiveColorStop; 22 | BOOL mRemoveActiveColorStop; 23 | KTGradientPickerMouseDragState mMouseDragState; 24 | } 25 | 26 | @property(readwrite,retain) NSGradient * gradientValue; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTImageView : NSImageView 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTImageView.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTImageView 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTPopUpButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTPopUpButton.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTPopUpButton : NSPopUpButton 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTPopUpButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTPopUpButton.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTPopUpButton.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTPopUpButton 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSearchField.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSearchField.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTSearchField : NSSearchField 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSearchField.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSearchField.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTSearchField.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTSearchField 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSecureTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSecureTextField.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTSecureTextField : NSSecureTextField 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSecureTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSecureTextField.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTSecureTextField.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTSecureTextField 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSegmentedControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSegmentedControl.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTSegmentedControl : NSSegmentedControl 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSegmentedControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSegmentedControl.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTSegmentedControl.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTSegmentedControl 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSlider.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSlider.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTSlider : NSSlider 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTSlider.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSlider.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTSlider.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTSlider 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTTextField.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTTextField : NSTextField 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTTextField.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTTextField.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTTextField 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTViewControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewControl.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/3/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTView.h" 11 | 12 | @interface KTViewControl : KTView 13 | { 14 | BOOL mIsEnabled; 15 | 16 | @private 17 | NSObject * wTarget; 18 | SEL wAction; 19 | } 20 | 21 | 22 | @property (readwrite, assign) BOOL isEnabled; 23 | @property (readwrite, assign) id target; 24 | @property (readwrite, assign) SEL action; 25 | - (void)performAction; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Framework/Views/NSControlSubclasses/KTViewControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewControl.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/3/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTViewControl.h" 10 | 11 | @interface KTViewControl (Private) 12 | 13 | @end 14 | 15 | @implementation KTViewControl 16 | 17 | @synthesize isEnabled = mIsEnabled; 18 | @synthesize target = wTarget; 19 | @synthesize action = wAction; 20 | 21 | //=========================================================== 22 | // - initWithFrame: 23 | //=========================================================== 24 | - (id)initWithFrame:(NSRect)theFrame 25 | { 26 | if(![super initWithFrame:theFrame]) 27 | return nil; 28 | mIsEnabled = YES; 29 | return self; 30 | } 31 | 32 | //=========================================================== 33 | // - initWithCoder: 34 | //=========================================================== 35 | - (id)initWithCoder:(NSCoder*)theCoder 36 | { 37 | if (![super initWithCoder:theCoder]) 38 | return nil; 39 | 40 | mIsEnabled = YES; 41 | return self; 42 | } 43 | 44 | //=========================================================== 45 | // - encodeWithCoder: 46 | //=========================================================== 47 | - (void)encodeWithCoder:(NSCoder*)theCoder 48 | { 49 | [super encodeWithCoder:theCoder]; 50 | } 51 | 52 | 53 | //=========================================================== 54 | // - performAction: 55 | //=========================================================== 56 | - (void)performAction 57 | { 58 | if([wTarget respondsToSelector:wAction]) 59 | [wTarget performSelector:wAction withObject:self]; 60 | } 61 | 62 | //=========================================================== 63 | // - setIsEnabled: 64 | //=========================================================== 65 | - (void)setIsEnabled:(BOOL)theBool 66 | { 67 | mIsEnabled = theBool; 68 | if(theBool==NO && [[self window] firstResponder]==self) 69 | [[self window] makeFirstResponder:nil]; 70 | [self setNeedsDisplay:YES]; 71 | } 72 | @end 73 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTAppKitSplitView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTAppKitSplitView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTAppKitSplitView : NSSplitView 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTAppKitSplitView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTAppKitSplitView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTAppKitSplitView.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTAppKitSplitView 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTImageKitBrowserView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageKitBrowserView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "KTViewLayout.h" 12 | 13 | @class KTLayoutManager; 14 | 15 | @interface KTImageKitBrowserView : IKImageBrowserView 16 | { 17 | KTLayoutManager * mLayoutManager; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTImageKitBrowserView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageKitBrowserView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTImageKitBrowserView.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTImageKitBrowserView 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTLevelIndicator.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTLevelIndicator.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTLevelIndicator : NSLevelIndicator 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTLevelIndicator.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTLevelIndicator.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTLevelIndicator.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTLevelIndicator 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTProgressIndicator.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTProgressIndicator.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTProgressIndicator : NSProgressIndicator 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTProgressIndicator.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTProgressIndicator.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTProgressIndicator.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTProgressIndicator 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTScrollView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | 14 | @interface KTScrollView : NSScrollView 15 | { 16 | KTLayoutManager * mLayoutManager; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTScrollView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTScrollView.h" 10 | #import "KTLayoutManager.h" 11 | @implementation KTScrollView 12 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 13 | @end 14 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTScroller.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTScroller.h 3 | // KTUIKit 4 | // 5 | // Created by Jonathan on 11/03/2009. 6 | // Copyright 2009 espresso served here. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTLayoutManager; 13 | @interface KTScroller : NSScroller { 14 | @private 15 | KTLayoutManager *mLayoutManager; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTScroller.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTScroller.m 3 | // KTUIKit 4 | // 5 | // Created by Jonathan on 11/03/2009. 6 | // Copyright 2009 espresso served here. All rights reserved. 7 | // 8 | 9 | #import "KTScroller.h" 10 | #import "KTLayoutManager.h" 11 | #import "KTLayoutDynamicImplementation.h" 12 | 13 | @interface KTScroller () 14 | 15 | @end 16 | 17 | @interface KTScroller (Private) 18 | 19 | @end 20 | 21 | @implementation KTScroller 22 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 23 | @end 24 | 25 | @implementation KTScroller (Private) 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | #import 34 | #import "KTViewProtocol.h" 35 | #import "KTLayoutManager.h" 36 | #import "KTStyleManager.h" 37 | 38 | 39 | 40 | @interface KTView : NSView 41 | { 42 | KTLayoutManager * mLayoutManager; 43 | KTStyleManager * mStyleManager; 44 | NSString * mLabel; 45 | BOOL mOpaque; 46 | BOOL mMouseDownCanMoveWindow; 47 | BOOL mAcceptsFirstMouse; 48 | BOOL mCanBecomeKeyView; 49 | BOOL mCanBecomeFirstResponder; 50 | BOOL mDrawAsImage; 51 | NSImage * mCachedImage; 52 | 53 | BOOL mDrawDebuggingRect; 54 | } 55 | 56 | @property (nonatomic, readwrite, assign) BOOL opaque; 57 | @property (nonatomic, readwrite, assign) BOOL mouseDownCanMoveWindow; 58 | @property (nonatomic, readwrite, assign) BOOL acceptsFirstMouse; 59 | @property (nonatomic, readwrite, assign) BOOL canBecomeKeyView; 60 | @property (nonatomic, readwrite, assign) BOOL canBecomeFirstResponder; 61 | @property (nonatomic, readwrite, assign) BOOL drawAsImage; 62 | @property (nonatomic, readonly) NSImage * cachedImage; 63 | @property (nonatomic, readwrite, assign) BOOL drawDebuggingRect; 64 | - (void)drawInContext:(CGContextRef)theContext; 65 | 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | #import "KTView.h" 34 | 35 | @interface KTView (Private) 36 | - (void)_drawDebugginRect; 37 | @end 38 | 39 | @implementation KTView 40 | 41 | @synthesize mouseDownCanMoveWindow = mMouseDownCanMoveWindow; 42 | @synthesize opaque = mOpaque; 43 | @synthesize canBecomeKeyView = mCanBecomeKeyView; 44 | @synthesize canBecomeFirstResponder = mCanBecomeFirstResponder; 45 | @synthesize acceptsFirstMouse = mAcceptsFirstMouse; 46 | @synthesize drawAsImage = mDrawAsImage; 47 | @synthesize cachedImage = mCachedImage; 48 | @synthesize drawDebuggingRect = mDrawDebuggingRect; 49 | 50 | //=========================================================== 51 | // - initWithFrame: 52 | //=========================================================== 53 | - (id)initWithFrame:(NSRect)theFrame 54 | { 55 | if(![super initWithFrame:theFrame]) 56 | return nil; 57 | 58 | // Layout 59 | KTLayoutManager * aLayoutManger = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 60 | [self setViewLayoutManager:aLayoutManger]; 61 | [self setAutoresizesSubviews:NO]; 62 | 63 | // Styles 64 | KTStyleManager * aStyleManager = [[[KTStyleManager alloc] initWithView:self] autorelease]; 65 | [self setStyleManager:aStyleManager]; 66 | 67 | // For Debugging 68 | [self setLabel:@"KTView"]; 69 | 70 | [self setOpaque:NO]; 71 | return self; 72 | } 73 | 74 | //=========================================================== 75 | // - encodeWithCoder: 76 | //=========================================================== 77 | - (void)encodeWithCoder:(NSCoder*)theCoder 78 | { 79 | [super encodeWithCoder:theCoder]; 80 | [theCoder encodeObject:[self viewLayoutManager] forKey:@"layoutManager"]; 81 | [theCoder encodeObject:[self styleManager] forKey:@"styleManager"]; 82 | [theCoder encodeObject:[self label] forKey:@"label"]; 83 | } 84 | 85 | //=========================================================== 86 | // - initWithCoder: 87 | //=========================================================== 88 | - (id)initWithCoder:(NSCoder*)theCoder 89 | { 90 | if (self = [super initWithCoder:theCoder]) 91 | { 92 | KTLayoutManager * aLayoutManager = [theCoder decodeObjectForKey:@"layoutManager"]; 93 | if(aLayoutManager == nil) 94 | aLayoutManager = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 95 | else 96 | [aLayoutManager setView:self]; 97 | [self setViewLayoutManager:aLayoutManager]; 98 | [self setAutoresizesSubviews:NO]; 99 | [self setAutoresizingMask:NSViewNotSizable]; 100 | 101 | KTStyleManager * aStyleManager = [theCoder decodeObjectForKey:@"styleManager"]; 102 | if(aStyleManager == nil) 103 | aStyleManager = [[[KTStyleManager alloc] initWithView:self] autorelease]; 104 | else 105 | [aStyleManager setView:self]; 106 | [self setStyleManager:aStyleManager]; 107 | [self setOpaque:NO]; 108 | 109 | NSString * aLabel = [theCoder decodeObjectForKey:@"label"]; 110 | if(aLabel == nil) 111 | aLabel = [self description]; 112 | [self setLabel:[theCoder decodeObjectForKey:@"label"]]; 113 | } 114 | return self; 115 | } 116 | 117 | //=========================================================== 118 | // - dealloc 119 | //=========================================================== 120 | - (void)dealloc 121 | { 122 | [mLayoutManager release]; 123 | [mStyleManager release]; 124 | [mLabel release]; 125 | [mCachedImage release]; 126 | [super dealloc]; 127 | } 128 | 129 | //=========================================================== 130 | // - isOpaque 131 | //=========================================================== 132 | - (BOOL)isOpaque 133 | { 134 | return mOpaque; 135 | } 136 | 137 | //=========================================================== 138 | // - canBecomeKeyView 139 | //=========================================================== 140 | - (BOOL)canBecomeKeyView 141 | { 142 | if(mCanBecomeKeyView == NO) 143 | return mCanBecomeKeyView; 144 | 145 | return [super canBecomeKeyView]; 146 | } 147 | 148 | //=========================================================== 149 | // - canBecomeFirstResponder 150 | //=========================================================== 151 | - (BOOL)canBecomeFirstResponder 152 | { 153 | return mCanBecomeFirstResponder; 154 | } 155 | 156 | 157 | //=========================================================== 158 | // - mouseDownCanMoveWindow 159 | //=========================================================== 160 | - (BOOL)mouseDownCanMoveWindow 161 | { 162 | return mMouseDownCanMoveWindow; 163 | } 164 | 165 | //=========================================================== 166 | // - setMouseDownCanMoveWindow: 167 | //=========================================================== 168 | - (void)setMouseDownCanMoveWindow:(BOOL)theBool 169 | { 170 | mMouseDownCanMoveWindow = theBool; 171 | if(mMouseDownCanMoveWindow == YES) 172 | { 173 | if([[self superview] isKindOfClass:[KTView class]]) 174 | [(KTView*)[self superview] setMouseDownCanMoveWindow:YES]; 175 | } 176 | } 177 | 178 | //=========================================================== 179 | // - acceptsFirstMouse 180 | //=========================================================== 181 | - (BOOL)acceptsFirstMouse 182 | { 183 | return mAcceptsFirstMouse; 184 | } 185 | 186 | //=========================================================== 187 | // - drawAsImage 188 | //=========================================================== 189 | - (void)drawAsImage:(BOOL)theBool 190 | { 191 | // mDrawAsImage = theBool; 192 | // if(mDrawAsImage) 193 | // { 194 | // [self lockFocus]; 195 | // NSBitmapImageRep * aBitmap = [[[NSBitmapImageRep alloc] initWithFocusedViewRect:[self bounds]] autorelease]; 196 | // [self unlockFocus]; 197 | // NSImage * anImage = [[[NSImage alloc] initWithData:[aBitmap TIFFRepresentation]] autorelease]; 198 | // if(mCachedImage!=nil) 199 | // [mCachedImage release]; 200 | // mCachedImage = [anImage retain]; 201 | // } 202 | // else 203 | // { 204 | // [mCachedImage release]; 205 | // mCachedImage = nil; 206 | // } 207 | } 208 | 209 | 210 | #pragma mark - 211 | #pragma mark Drawing 212 | //=========================================================== 213 | // - drawRect: 214 | //=========================================================== 215 | - (void)drawRect:(NSRect)theRect 216 | { 217 | CGContextRef aContext = [[NSGraphicsContext currentContext] graphicsPort]; 218 | if([self drawDebuggingRect]) 219 | [self _drawDebugginRect]; 220 | 221 | // if(mDrawAsImage) 222 | // { 223 | // [mCachedImage drawInRect:theRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1]; 224 | //// NSLog(@"drawing cached image of view"); 225 | // } 226 | // else 227 | // { 228 | [mStyleManager drawStylesInRect:theRect context:aContext view:self]; 229 | [self drawInContext:aContext]; 230 | // } 231 | } 232 | 233 | //=========================================================== 234 | // - drawInContext: 235 | //=========================================================== 236 | - (void)drawInContext:(CGContextRef)theContext 237 | { 238 | // subclasses can override this to do custom drawing over the styles 239 | } 240 | 241 | 242 | //=========================================================== 243 | // - _drawDebugginRect: 244 | //=========================================================== 245 | - (void)_drawDebugginRect 246 | { 247 | [[NSColor colorWithCalibratedRed:0 green:1 blue:0 alpha:.5] set]; 248 | NSRect anInsetBounds = NSInsetRect([self bounds], 10, 10); 249 | [NSBezierPath fillRect:anInsetBounds]; 250 | 251 | NSRect anOriginSquare = NSMakeRect(0, 0, 10, 10); 252 | [[NSColor colorWithCalibratedRed:1 green:0 blue:0 alpha:.5] set]; 253 | [NSBezierPath fillRect:anOriginSquare]; 254 | } 255 | 256 | 257 | #pragma mark - 258 | #pragma mark Layout protocol 259 | //=========================================================== 260 | // - setViewLayoutManager: 261 | //=========================================================== 262 | - (void)setViewLayoutManager:(KTLayoutManager*)theLayoutManager 263 | { 264 | if(mLayoutManager != theLayoutManager) 265 | { 266 | [mLayoutManager release]; 267 | mLayoutManager = [theLayoutManager retain]; 268 | } 269 | } 270 | 271 | //=========================================================== 272 | // - viewLayoutManager 273 | //=========================================================== 274 | - (KTLayoutManager*)viewLayoutManager 275 | { 276 | return mLayoutManager; 277 | } 278 | 279 | //=========================================================== 280 | // - setFrame: 281 | //=========================================================== 282 | - (void)setFrame:(NSRect)theFrame 283 | { 284 | [super setFrame:theFrame]; 285 | } 286 | 287 | 288 | //=========================================================== 289 | // - setFrameSize: 290 | //=========================================================== 291 | - (void)setFrameSize:(NSSize)theSize 292 | { 293 | [super setFrameSize:theSize]; 294 | NSArray * aSubviewList = [self children]; 295 | int aSubviewCount = [aSubviewList count]; 296 | int i; 297 | for(i = 0; i < aSubviewCount; i++) 298 | { 299 | NSView * aSubview = [aSubviewList objectAtIndex:i]; 300 | 301 | // if the subview conforms to the layout protocol, tell its layout 302 | // manager to refresh its layout 303 | if( [aSubview conformsToProtocol:@protocol(KTViewLayout)] ) 304 | { 305 | [[(KTView*)aSubview viewLayoutManager] refreshLayout]; 306 | } 307 | } 308 | } 309 | 310 | //=========================================================== 311 | // - frame 312 | //=========================================================== 313 | - (NSRect)frame 314 | { 315 | return [super frame]; 316 | } 317 | 318 | //=========================================================== 319 | // - parent 320 | //=========================================================== 321 | - (id)parent 322 | { 323 | if([[self superview] conformsToProtocol:@protocol(KTViewLayout)]) 324 | return (id)[self superview]; 325 | else 326 | return nil; 327 | } 328 | 329 | //=========================================================== 330 | // - children 331 | //=========================================================== 332 | - (NSArray*)children 333 | { 334 | return [super subviews]; 335 | } 336 | 337 | //=========================================================== 338 | // - addSubview: 339 | //=========================================================== 340 | - (void)addSubview:(NSView*)theView 341 | { 342 | [super addSubview:theView]; 343 | if( [theView conformsToProtocol:@protocol(KTViewLayout)] == NO 344 | && [theView autoresizingMask] != NSViewNotSizable) 345 | [self setAutoresizesSubviews:YES]; 346 | if([theView isKindOfClass:[KTView class]]) 347 | { 348 | if([theView mouseDownCanMoveWindow]) 349 | [self setMouseDownCanMoveWindow:YES]; 350 | } 351 | } 352 | 353 | 354 | 355 | #pragma mark - 356 | #pragma mark KTStyle protocol 357 | //=========================================================== 358 | // - setStyleManager: 359 | //=========================================================== 360 | - (void)setStyleManager:(KTStyleManager*)theStyleManager 361 | { 362 | if(mStyleManager != theStyleManager) 363 | { 364 | [mStyleManager release]; 365 | mStyleManager = [theStyleManager retain]; 366 | } 367 | } 368 | 369 | //=========================================================== 370 | // - styleManager 371 | //=========================================================== 372 | - (KTStyleManager*)styleManager 373 | { 374 | return mStyleManager; 375 | } 376 | 377 | //=========================================================== 378 | // - window 379 | //=========================================================== 380 | - (NSWindow *)window 381 | { 382 | return [super window]; 383 | } 384 | 385 | #pragma mark - 386 | #pragma mark KTView protocol 387 | //=========================================================== 388 | // - setLabel: 389 | //=========================================================== 390 | - (void)setLabel:(NSString*)theLabel 391 | { 392 | if(mLabel != theLabel) 393 | { 394 | [mLabel release]; 395 | mLabel = [[NSString alloc] initWithString:theLabel]; 396 | } 397 | } 398 | 399 | //=========================================================== 400 | // - label 401 | //=========================================================== 402 | - (NSString*)label 403 | { 404 | return mLabel; 405 | } 406 | 407 | 408 | 409 | @end 410 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTWebView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTWebView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "KTViewLayout.h" 12 | 13 | @class KTLayoutManager; 14 | 15 | @interface KTWebView : WebView 16 | { 17 | KTLayoutManager * mLayoutManager; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/KTWebView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTWebView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTWebView.h" 10 | #import "KTLayoutManager.h" 11 | 12 | @implementation KTWebView 13 | #include "../Layout/SharedCode/KTViewLayoutSharedImplementation_ChildlessNSView.m" 14 | @end 15 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/SplitView/KTSplitView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 30/03/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTView.h" 11 | 12 | 13 | @class KTSplitView; 14 | 15 | @protocol KTSplitView 16 | - (void)layoutViews; 17 | - (void)resetResizeInformation; 18 | @end 19 | 20 | @protocol KTSplitViewDelegate 21 | @optional 22 | - (void)splitViewDivderAnimationDidEnd:(KTSplitView*)theSplitView; 23 | - (void)dividerPositionDidChangeForSplitView:(KTSplitView*)theSplitView; 24 | @end 25 | //animationDidEndForSplitView 26 | typedef enum 27 | { 28 | KTSplitViewResizeBehavior_MaintainProportions = 0, 29 | KTSplitViewResizeBehavior_MaintainFirstViewSize, 30 | KTSplitViewResizeBehavior_MaintainSecondViewSize, 31 | 32 | }KTSplitViewResizeBehavior; 33 | 34 | typedef enum 35 | { 36 | KTSplitViewDividerOrientation_NoSet = 0, 37 | KTSplitViewDividerOrientation_Horizontal, 38 | KTSplitViewDividerOrientation_Vertical 39 | 40 | }KTSplitViewDividerOrientation; 41 | 42 | typedef enum 43 | { 44 | KTSplitViewFocusedViewFlag_Unknown = 0, 45 | KTSplitViewFocusedViewFlag_FirstView = 1, 46 | KTSplitViewFocusedViewFlag_SecondView = 2 47 | 48 | }KTSplitViewFocusedViewFlag; 49 | 50 | @class KTSplitViewDivider; 51 | 52 | @interface KTSplitView : KTView MAC_OS_X_VERSION_10_5 54 | , NSAnimationDelegate 55 | #endif 56 | > 57 | { 58 | @private 59 | id wDelegate; 60 | 61 | KTSplitViewDivider * mDivider; 62 | KTView * mFirstView; 63 | KTView * mSecondView; 64 | 65 | KTSplitViewDividerOrientation mDividerOrientation; 66 | KTSplitViewResizeBehavior mResizeBehavior; 67 | BOOL mAdjustable; 68 | BOOL mUserInteractionEnabled; 69 | 70 | KTSplitViewFocusedViewFlag mPositionRelativeToViewFlag; 71 | BOOL mCanSetDividerPosition; 72 | CGFloat mDividerPositionToSet; 73 | BOOL mResetResizeInformation; 74 | CGFloat mResizeInformation; 75 | CGFloat mAbsoluteResizeInformation; 76 | CGFloat mProportionalResizeInformation; 77 | NSViewAnimation * mAnimator; 78 | 79 | CGFloat mPreferredFirstViewMinSize; 80 | CGFloat mPreferredSecondViewMinSize; 81 | CGFloat mPreferredMaxSize; 82 | KTSplitViewFocusedViewFlag mPreferredMaxSizeRelativeView; 83 | } 84 | 85 | @property (nonatomic, readwrite, assign) IBOutlet id delegate; 86 | @property (nonatomic, readwrite, assign) KTSplitViewDividerOrientation dividerOrientation; 87 | @property (nonatomic, readwrite, assign) KTSplitViewResizeBehavior resizeBehavior; 88 | @property (nonatomic, readwrite, assign) BOOL userInteractionEnabled; 89 | @property (nonatomic, readwrite, assign) CGFloat dividerThickness; 90 | @property (nonatomic, readwrite, retain) KTSplitViewDivider * divider; 91 | 92 | - (id)initWithFrame:(NSRect)theFrame dividerOrientation:(KTSplitViewDividerOrientation)theDividerOrientation; 93 | - (void)setFirstView:(NSView*)theView; 94 | - (void)setSecondView:(NSView*)theView; 95 | - (KTView*)firstView; 96 | - (KTView*)secondView; 97 | - (KTView*)firstViewContainer; 98 | - (KTView*)secondViewContainer; 99 | - (void)setFirstView:(NSView*)theFirstView secondView:(NSView*)theSecondView; 100 | - (void)setPreferredMinSize:(CGFloat)theFloat relativeToView:(KTSplitViewFocusedViewFlag)theView; 101 | - (void)setPreferredMaxSize:(CGFloat)theFloat relativeToView:(KTSplitViewFocusedViewFlag)theView; 102 | - (void)disableMaxSizeConstraint; 103 | 104 | - (void)setDividerPosition:(CGFloat)thePosition relativeToView:(KTSplitViewFocusedViewFlag)theView; 105 | - (void)setDividerPosition:(CGFloat)thePosition relativeToView:(KTSplitViewFocusedViewFlag)theView animate:(BOOL)theBool animationDuration:(float)theTimeInSeconds; 106 | - (CGFloat)dividerPositionRelativeToView:(KTSplitViewFocusedViewFlag)theFocusedViewFlag; 107 | - (void)setDividerFillColor:(NSColor*)theColor; 108 | - (void)setDividerBackgroundGradient:(NSGradient*)theGradient; 109 | - (void)setDividerStrokeColor:(NSColor*)theColor; 110 | - (void)setDividerFirstStrokeColor:(NSColor*)theFirstColor secondColor:(NSColor*)theSecondColor; 111 | //- (void)setDivider:(KTSplitViewDivider*)theDivider; 112 | 113 | // Called from the divider's mouse handling code 114 | - (CGFloat)dividerPositionForProposedPosition:(CGFloat)thePosition; 115 | - (BOOL)canResizeRelativeToView:(KTSplitViewFocusedViewFlag)theView; 116 | @end 117 | -------------------------------------------------------------------------------- /Framework/Views/NSViewSubclasses/SplitView/KTSplitViewDivider.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitViewDivider.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 30/03/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTView.h" 11 | 12 | @class KTSplitView; 13 | 14 | @interface KTSplitViewDivider : KTView 15 | { 16 | KTSplitView * wSplitView; 17 | BOOL mIsInDrag; 18 | NSTrackingArea * mTrackingArea; 19 | NSCursor * mCurrentCursor; 20 | CGSize mInitialMouseOffset; 21 | } 22 | @property (nonatomic, readwrite, assign) KTSplitView * splitView; 23 | @property (nonatomic, readonly) BOOL isInDrag; 24 | - (id)initWithSplitView:(KTSplitView*)theSplitView; 25 | 26 | - (NSCursor *)cursorForCurrentPosition; 27 | @end 28 | -------------------------------------------------------------------------------- /Framework/Views/NSWindowSubclasses/KTViewOverlayWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewOverlayWindow.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 22/09/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTWindow.h" 11 | #import "KTViewLayout.h" 12 | 13 | @class KTView; 14 | @class KTLayoutManager; 15 | 16 | @interface KTViewOverlayWindow : KTWindow 17 | { 18 | @private 19 | KTLayoutManager * mLayoutManager; 20 | id wParentView; 21 | } 22 | - (void)setParentView:(id)theParentView; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Framework/Views/NSWindowSubclasses/KTViewOverlayWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewOverlayWindow.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 22/09/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTViewOverlayWindow.h" 10 | #import "KTView.h" 11 | #import "KTLayoutManager.h" 12 | 13 | @implementation KTViewOverlayWindow 14 | //---------------------------------------------------------------------------------------- 15 | // initWithContentRect 16 | //---------------------------------------------------------------------------------------- 17 | - (id)initWithContentRect:(NSRect)theContentRect styleMask:(NSUInteger)theStyleMask backing:(NSBackingStoreType)theBacking defer:(BOOL)theDefer 18 | { 19 | if(self = [super initWithContentRect:theContentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) 20 | { 21 | [self setBackgroundColor:[NSColor clearColor]]; 22 | [self setMovableByWindowBackground:NO]; 23 | [self setExcludedFromWindowsMenu:YES]; 24 | [self useOptimizedDrawing:YES]; 25 | [self setReleasedWhenClosed:NO]; 26 | [self setHidesOnDeactivate:NO]; 27 | KTLayoutManager * aLayoutManger = [[[KTLayoutManager alloc] initWithView:self] autorelease]; 28 | [self setViewLayoutManager:aLayoutManger]; 29 | 30 | // KTView * aDebugView = [[[KTView alloc] initWithFrame:theContentRect] autorelease]; 31 | // [[self contentView] addSubview:aDebugView]; 32 | // [[aDebugView styleManager] setBackgroundColor:[[NSColor greenColor] colorWithAlphaComponent:.5]]; 33 | } 34 | return self; 35 | } 36 | 37 | //---------------------------------------------------------------------------------------- 38 | // initWithContentRect 39 | //---------------------------------------------------------------------------------------- 40 | - (void)dealloc 41 | { 42 | [mLayoutManager release]; 43 | [super dealloc]; 44 | } 45 | 46 | 47 | //---------------------------------------------------------------------------------------- 48 | // initWithContentRect 49 | //---------------------------------------------------------------------------------------- 50 | - (void)setParentView:(id)theParentView 51 | { 52 | wParentView = theParentView; 53 | } 54 | 55 | 56 | #pragma mark - 57 | #pragma mark KTViewLayout Protocol Methods 58 | //---------------------------------------------------------------------------------------- 59 | // initWithContentRect 60 | //---------------------------------------------------------------------------------------- 61 | - (void)setViewLayoutManager:(KTLayoutManager*)theLayoutManager 62 | { 63 | if(theLayoutManager != mLayoutManager) 64 | { 65 | [theLayoutManager retain]; 66 | [mLayoutManager release]; 67 | mLayoutManager = theLayoutManager; 68 | } 69 | } 70 | 71 | //---------------------------------------------------------------------------------------- 72 | // initWithContentRect 73 | //---------------------------------------------------------------------------------------- 74 | - (KTLayoutManager*)viewLayoutManager 75 | { 76 | return mLayoutManager; 77 | } 78 | 79 | //---------------------------------------------------------------------------------------- 80 | // initWithContentRect 81 | //---------------------------------------------------------------------------------------- 82 | - (void)setFrame:(NSRect)theFrame 83 | { 84 | // the frame passed in will be in terms of the parent view's coordiinate system 85 | // we need to translate this to screen coordinates 86 | // and call NSWindow's setFrame:display: 87 | // NSLog(@"OverlayWindow setFrame %@", self); 88 | // NSLog(@"current frame: %@", NSStringFromRect([self frame])); 89 | NSRect aFrameToSet = theFrame; 90 | // convert from the parent view's coords to its its window's coords 91 | if( wParentView 92 | && [wParentView isKindOfClass:[NSView class]]) 93 | { 94 | // now get the screen origin from the parent's window 95 | NSPoint aBasePoint = [(NSView*)wParentView convertPointToBase:aFrameToSet.origin]; 96 | NSPoint aScreenPoint = [[(NSView*)wParentView window] convertBaseToScreen:aBasePoint]; 97 | aFrameToSet.origin = aScreenPoint; 98 | aFrameToSet.size = theFrame.size; 99 | // NSLog(@"a frame to set: %@", NSStringFromRect(aFrameToSet)); 100 | } 101 | [self setFrame:aFrameToSet display:YES animate:NO]; 102 | //NSLog(@"new frame: %@", NSStringFromRect([self frame])); 103 | } 104 | // 105 | //- (void)setFrameOrigin:(NSPoint)point 106 | //{ 107 | // NSLog(@"setFrameOrigin:%s", NSStringFromPoint(point)); 108 | //} 109 | // 110 | //- (void)setFrameTopLeftPoint:(NSPoint)point 111 | //{ 112 | // NSLog(@"set frame top left point"); 113 | //} 114 | 115 | // 116 | // -(void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews 117 | // { 118 | // NSLog(@"set Frame: display:"); 119 | // [super setFrame:windowFrame display:displayViews]; 120 | // } 121 | // 122 | //---------------------------------------------------------------------------------------- 123 | // initWithContentRect 124 | //---------------------------------------------------------------------------------------- 125 | - (NSRect)frame 126 | { 127 | // our frame is in terms of screen coordinates 128 | return [super frame]; 129 | } 130 | 131 | //---------------------------------------------------------------------------------------- 132 | // initWithContentRect 133 | //---------------------------------------------------------------------------------------- 134 | - (id)parent 135 | { 136 | return wParentView; 137 | } 138 | 139 | //---------------------------------------------------------------------------------------- 140 | // initWithContentRect 141 | //---------------------------------------------------------------------------------------- 142 | - (NSArray*)children 143 | { 144 | return nil; 145 | } 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /Framework/Views/NSWindowSubclasses/KTWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTWindow.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/16/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface KTWindow : NSWindow 13 | { 14 | BOOL mCanBecomeKeyWindow; 15 | } 16 | 17 | - (void)setCanBecomeKeyWindow:(BOOL)theBool; 18 | @end 19 | -------------------------------------------------------------------------------- /Framework/Views/NSWindowSubclasses/KTWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTWindow.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/16/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTWindow.h" 10 | 11 | 12 | @implementation KTWindow 13 | - (void)setCanBecomeKeyWindow:(BOOL)theBool 14 | { 15 | mCanBecomeKeyWindow = theBool; 16 | } 17 | 18 | - (BOOL)canBecomeKeyWindow 19 | { 20 | return mCanBecomeKeyWindow; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLButton.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 20/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTOpenGLControl.h" 11 | 12 | typedef enum 13 | { 14 | KTOpenGLButtonState_Up = 0, 15 | KTOpenGLButtonState_Down 16 | 17 | }KTOpenGLButtonState; 18 | 19 | 20 | typedef enum 21 | { 22 | KTOpenGLMomentaryPushButton = 0, 23 | KTOpenGLToggleButton 24 | 25 | }KTOpenGLButtonType; 26 | 27 | @interface KTOpenGLButton : KTOpenGLControl 28 | { 29 | KTOpenGLButtonType mButtonType; 30 | KTOpenGLButtonState mState; 31 | 32 | } 33 | 34 | 35 | 36 | @property (readwrite, assign) KTOpenGLButtonType buttonType; 37 | @property (readwrite, assign) KTOpenGLButtonState state; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLButton.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 20/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTOpenGLButton.h" 10 | 11 | 12 | @implementation KTOpenGLButton 13 | @synthesize buttonType = mButtonType; 14 | @synthesize state = mState; 15 | 16 | - (void)setState:(KTOpenGLButtonState)theState 17 | { 18 | mState = theState; 19 | [self setNeedsDisplay:YES]; 20 | } 21 | 22 | - (void)mouseDown:(NSEvent*)theEvent 23 | { 24 | if([self enabled]) 25 | { 26 | [self setState:KTOpenGLButtonState_Down]; 27 | } 28 | } 29 | 30 | - (void)mouseUp:(NSEvent*)theEvent 31 | { 32 | if([self enabled]) 33 | { 34 | switch(mButtonType) 35 | { 36 | case KTOpenGLMomentaryPushButton: 37 | [self setState:KTOpenGLButtonState_Up]; 38 | [self performAction]; 39 | break; 40 | 41 | // case KTOpenGLToggleButton: 42 | // 43 | // break: 44 | } 45 | } 46 | } 47 | 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLControl.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 20/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTOpenGLLayer.h" 11 | 12 | @interface KTOpenGLControl : KTOpenGLLayer 13 | { 14 | @private 15 | BOOL mEnabled; 16 | BOOL mHighlighted; 17 | id wTarget; 18 | SEL wAction; 19 | CGFloat mFloatValue; 20 | NSInteger mIntValue; 21 | id mObjectValue; 22 | } 23 | 24 | @property (readwrite, assign) BOOL enabled; 25 | @property (readwrite, assign) BOOL highlighted; 26 | @property (readwrite, assign) id target; 27 | @property (readwrite, assign) SEL action; 28 | @property (readwrite, assign) CGFloat floatValue; 29 | @property (readwrite, assign) NSInteger intValue; 30 | @property (readwrite, retain) id objectValue; 31 | 32 | - (void)performAction; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLControl.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 20/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTOpenGLControl.h" 10 | 11 | 12 | @implementation KTOpenGLControl 13 | 14 | //=========================================================== 15 | // - @synthesize-ers 16 | //=========================================================== 17 | @synthesize enabled = mEnabled; 18 | @synthesize highlighted = mHighlighted; 19 | @synthesize target = wTarget; 20 | @synthesize action = wAction; 21 | @synthesize floatValue = mFloatValue; 22 | @synthesize intValue = mIntValue; 23 | @synthesize objectValue = mObjectValue; 24 | 25 | 26 | //=========================================================== 27 | // - initWithFrame 28 | //=========================================================== 29 | - (id)initWithFrame:(NSRect)theFrame 30 | { 31 | if(![super initWithFrame:theFrame]) 32 | return nil; 33 | 34 | [self setEnabled:YES]; 35 | return self; 36 | } 37 | 38 | //=========================================================== 39 | // - dealloc 40 | //=========================================================== 41 | - (void)dealloc 42 | { 43 | [mObjectValue release]; 44 | [super dealloc]; 45 | } 46 | 47 | //=========================================================== 48 | // - performAction 49 | //=========================================================== 50 | - (void)performAction 51 | { 52 | if([self action]) 53 | { 54 | // if our action is nil targeted - send the action 55 | // to th responder chain 56 | if([self target] == nil) 57 | [[self nextResponder] tryToPerform:[self action] with:self]; 58 | else 59 | { 60 | if([[self target] respondsToSelector:[self action]]) 61 | [[self target] performSelector:[self action] withObject:self]; 62 | } 63 | } 64 | } 65 | 66 | //=========================================================== 67 | // - setIntValue 68 | //=========================================================== 69 | - (void)setIntValue:(NSInteger)theIntValue 70 | { 71 | mIntValue = theIntValue; 72 | [self setNeedsDisplay:YES]; 73 | } 74 | 75 | //=========================================================== 76 | // - setFloatValue 77 | //=========================================================== 78 | - (void)setFloatValue:(CGFloat)theFloatValue 79 | { 80 | mFloatValue = theFloatValue; 81 | [self setNeedsDisplay:YES]; 82 | } 83 | 84 | 85 | 86 | @end -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLLayer.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 19/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "KTViewLayout.h" 11 | 12 | @class KTOpenGLView; 13 | @class KTLayoutManager; 14 | 15 | @interface KTOpenGLLayer : NSResponder 16 | { 17 | @private 18 | KTLayoutManager * mLayoutManager; 19 | NSRect mFrame; 20 | CGFloat mRotation; 21 | NSPoint mAnchorPoint; 22 | CGFloat mAlpha; 23 | NSMutableArray * mSublayers; 24 | KTOpenGLLayer * mSuperlayer; 25 | KTOpenGLView * wView; 26 | BOOL mDrawDebuggingRects; 27 | } 28 | 29 | @property (readwrite, assign) NSRect frame; 30 | @property (readwrite, assign) CGFloat rotation; 31 | @property (readwrite, assign) NSPoint anchorPoint; 32 | @property (readwrite, assign) CGFloat alpha; 33 | @property (readwrite, retain) KTLayoutManager * viewLayoutManager; 34 | @property (readwrite, assign) KTOpenGLView * view; 35 | @property (readwrite, assign) KTOpenGLLayer * superlayer; 36 | @property (readwrite, retain) NSMutableArray * sublayers; 37 | @property (readwrite, assign) BOOL drawDebuggingRects; 38 | 39 | 40 | - (id)initWithFrame:(NSRect)theFrame; 41 | - (NSRect)bounds; 42 | - (NSPoint)position; 43 | - (void)notifiyLayersViewDidReshape; 44 | - (void)viewDidReshape; 45 | 46 | - (void)addSublayer:(KTOpenGLLayer*)theSublayer; 47 | - (void)removeSublayer:(KTOpenGLLayer*)theSublayer; 48 | 49 | 50 | - (void)drawLayers; 51 | - (void)draw; 52 | - (void)drawOverlays; 53 | - (void)setNeedsDisplay:(BOOL)theBool; 54 | - (void)display; 55 | - (void)viewWillMoveToWindow:(NSWindow*)theWindow;// subclasses shouldn't override this, instead use layerWillMoveToWindow: 56 | - (void)viewDidMoveToWindow; // subclasses shouldn't override this, instead use layerDidMoveToWindow: 57 | - (void)layerWillMoveToWindow:(NSWindow *)theWindow; 58 | - (void)layerDidMoveToWindow; 59 | 60 | - (KTOpenGLLayer*)hitTest:(NSPoint)thePoint; 61 | - (void)updateTrackingAreas; 62 | 63 | // converting coordinates 64 | - (NSRect)convertRect:(NSRect)theRect fromLayer:(KTOpenGLLayer*)theLayer; 65 | - (NSPoint)convertPoint:(NSPoint)thePoint fromLayer:(KTOpenGLLayer*)theLayer; 66 | - (NSRect)convertRectToViewRect:(NSRect)theRect; 67 | - (NSPoint)convertPointToViewPoint:(NSPoint)thePoint; 68 | - (NSPoint)convertViewPointToLayerPoint:(NSPoint)thePoint; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLTexture.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 19/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | 16 | @interface KTOpenGLTexture : NSObject 17 | { 18 | GLuint mTextureName; 19 | GLuint mOriginalPixelsWide; 20 | GLuint mOriginalPixelsHigh; 21 | id mBitmapSource; 22 | NSOpenGLContext * mOpenGLContext; 23 | BOOL mHasAlpha; 24 | } 25 | 26 | @property (nonatomic, readwrite, retain) id bitmapSource; 27 | @property (nonatomic, readwrite, retain) NSOpenGLContext * openGLContext; 28 | 29 | 30 | - (void)uploadTextureWithNSImage:(NSImage *)theImage openGLContext:(NSOpenGLContext *)theContext; 31 | - (void)createTextureFromNSBitmapImageRep:(NSBitmapImageRep*)theNSBitmapImageRep openGLContext:(NSOpenGLContext*)theContext; 32 | - (void)drawInRect:(NSRect)theRect alpha:(CGFloat)theAlpha; 33 | - (void)drawInRect:(NSRect)theRect anchorPoint:(NSPoint)theAnchorPoint alpha:(CGFloat)theAlpha; 34 | - (void)deleteTexture; 35 | - (NSSize)size; 36 | - (BOOL)hasAlpha; 37 | - (GLuint)textureName; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLTexture.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLTexture.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 19/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | // Apple Docs: Techniques for working with texture data: 9 | //http://developer.apple.com/documentation/graphicsimaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/chapter_10_section_5.html#//apple_ref/doc/uid/TP40001987-CH407-SW28 10 | 11 | #import "KTOpenGLTexture.h" 12 | #if __BIG_ENDIAN__ 13 | #define ARGB_IMAGE_TYPE GL_UNSIGNED_INT_8_8_8_8 14 | #else 15 | #define ARGB_IMAGE_TYPE GL_UNSIGNED_INT_8_8_8_8_REV 16 | #endif 17 | 18 | #define glReportError()\ 19 | {\ 20 | GLenum error=glGetError();\ 21 | if(GL_NO_ERROR!=error)\ 22 | {\ 23 | printf("OpenGL error at %s:%d: %s\n",__FILE__,__LINE__,(char*)gluErrorString(error));\ 24 | }\ 25 | }\ 26 | 27 | @implementation KTOpenGLTexture 28 | @synthesize bitmapSource = mBitmapSource; 29 | @synthesize openGLContext = mOpenGLContext; 30 | 31 | //---------------------------------------------------------------------------------------- 32 | // init 33 | //---------------------------------------------------------------------------------------- 34 | - (id)init 35 | { 36 | if(self = [super init]) 37 | { 38 | mTextureName = 0; 39 | mOriginalPixelsWide = 0; 40 | mOriginalPixelsHigh = 0; 41 | mBitmapSource = nil; 42 | } 43 | return self; 44 | } 45 | 46 | //---------------------------------------------------------------------------------------- 47 | // dealloc 48 | //---------------------------------------------------------------------------------------- 49 | - (void)dealloc 50 | { 51 | //NSLog(@"%@ dealloc", self); 52 | [self performSelectorOnMainThread:@selector(deleteTexture) withObject:nil waitUntilDone:YES]; 53 | [super dealloc]; 54 | } 55 | 56 | 57 | //---------------------------------------------------------------------------------------- 58 | // createTextureFromNSBitmapImageRep 59 | //---------------------------------------------------------------------------------------- 60 | - (void)createTextureFromNSBitmapImageRep:(NSBitmapImageRep*)theNSBitmapImageRep openGLContext:(NSOpenGLContext*)theContext 61 | { 62 | NSDictionary * anInfoDict = [NSDictionary dictionaryWithObjectsAndKeys:theNSBitmapImageRep, @"NSBitmapImageRepInfoKey", theContext, @"NSOpenGLContextInfoKey", nil]; 63 | [self performSelectorOnMainThread:@selector(uploadTextureWithTextureInfo:) withObject:anInfoDict waitUntilDone:YES]; 64 | 65 | } 66 | //---------------------------------------------------------------------------------------- 67 | // uploadTextureWithNSImage:openGLContext: 68 | //---------------------------------------------------------------------------------------- 69 | - (void)uploadTextureWithNSImage:(NSImage*)theImage openGLContext:(NSOpenGLContext*)theContext 70 | { 71 | NSBitmapImageRep * aBitmapImageRep = [[[NSBitmapImageRep alloc] initWithData:[theImage TIFFRepresentation]] autorelease]; 72 | NSDictionary * anInfoDict = [NSDictionary dictionaryWithObjectsAndKeys:aBitmapImageRep, @"NSBitmapImageRepInfoKey", theContext, @"NSOpenGLContextInfoKey", nil]; 73 | [self performSelectorOnMainThread:@selector(uploadTextureWithTextureInfo:) withObject:anInfoDict waitUntilDone:YES]; 74 | } 75 | 76 | //---------------------------------------------------------------------------------------- 77 | // uploadTextureWithTextureInfo 78 | //---------------------------------------------------------------------------------------- 79 | - (void)uploadTextureWithTextureInfo:(NSDictionary*)theInfoDict 80 | { 81 | if( mOpenGLContext != nil 82 | || mTextureName != 0 83 | || mBitmapSource != nil) 84 | { 85 | [self deleteTexture]; 86 | } 87 | 88 | [self setOpenGLContext:[theInfoDict objectForKey:@"NSOpenGLContextInfoKey"]]; 89 | [self setBitmapSource:[theInfoDict objectForKey:@"NSBitmapImageRepInfoKey"]]; 90 | 91 | if ( mTextureName == 0 92 | && [self bitmapSource] != nil 93 | && [self openGLContext] != nil) 94 | { 95 | 96 | [[self openGLContext] makeCurrentContext]; 97 | 98 | GLenum aFormat1; 99 | GLenum aFormat2; 100 | GLenum aType; 101 | unsigned char * aBitmapData; 102 | 103 | id aBitmapSource = [self bitmapSource]; 104 | aBitmapData = [aBitmapSource bitmapData]; 105 | mOriginalPixelsWide = (GLuint)[(NSBitmapImageRep*)aBitmapSource pixelsWide]; 106 | mOriginalPixelsHigh = (GLuint)[(NSBitmapImageRep*)aBitmapSource pixelsHigh]; 107 | 108 | mHasAlpha = [aBitmapSource hasAlpha]; 109 | if([aBitmapSource bitsPerPixel]==8) 110 | { 111 | // gray scale image 112 | aFormat1 = GL_LUMINANCE8; 113 | aFormat2 = GL_LUMINANCE; 114 | } 115 | else 116 | { 117 | aFormat1 = mHasAlpha ? GL_RGBA8 : GL_RGB8; 118 | aFormat2 = mHasAlpha ? GL_RGBA : GL_RGB; 119 | } 120 | 121 | aType = mHasAlpha ? ARGB_IMAGE_TYPE : GL_UNSIGNED_BYTE; 122 | 123 | // NSLog(@"pixels wide: %d high:%d", mOriginalPixelsWide, mOriginalPixelsHigh); 124 | // NSLog(@"bits per sample: %d", [mBitmapSource bitsPerSample]); 125 | // NSLog(@"bytes per row: %d", [mBitmapSource bytesPerRow]); 126 | // NSLog(@"bits per pixels: %d", [mBitmapSource bitsPerPixel]); 127 | // NSLog(@"samples per pixel: %d", [mBitmapSource bitsPerPixel]/[mBitmapSource bitsPerSample]); 128 | 129 | glEnable(GL_TEXTURE_RECTANGLE_EXT); 130 | glGenTextures(1, &mTextureName); 131 | glReportError(); 132 | 133 | NSLog(@"mTexture Name: %d", mTextureName); 134 | // 135 | glBindTexture(GL_TEXTURE_RECTANGLE_EXT, mTextureName); 136 | glReportError(); 137 | glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 138 | glReportError(); 139 | glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 140 | glReportError(); 141 | glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 142 | glReportError(); 143 | glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 144 | glReportError(); 145 | glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE); 146 | glReportError(); 147 | glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); 148 | glReportError(); 149 | glPixelStorei(GL_UNPACK_ROW_LENGTH, mOriginalPixelsWide); 150 | glReportError(); 151 | glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, aFormat1, mOriginalPixelsWide, mOriginalPixelsHigh, 0, aFormat2, aType, aBitmapData); 152 | glReportError(); 153 | glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0); 154 | glReportError(); 155 | glDisable(GL_TEXTURE_RECTANGLE_EXT); 156 | } 157 | } 158 | 159 | 160 | //---------------------------------------------------------------------------------------- 161 | // drawInRect:alpha 162 | //---------------------------------------------------------------------------------------- 163 | - (void)drawInRect:(NSRect)theRect alpha:(CGFloat)theAlpha 164 | { 165 | if( mTextureName == 0 ) 166 | return; 167 | 168 | [mOpenGLContext makeCurrentContext]; 169 | 170 | GLuint aTextureWidth = mOriginalPixelsWide; 171 | GLuint aTextureHeight = mOriginalPixelsHigh; 172 | GLuint aTextureXPos = 0; 173 | GLuint aTextureYPos = 0; 174 | 175 | GLuint aDrawingWidth = (GLuint)ceil(theRect.size.width); 176 | GLuint aDrawingHeight = (GLuint)ceil(theRect.size.height); 177 | 178 | GLuint anXPosition = theRect.origin.x; 179 | GLuint aYPosition = theRect.origin.y; 180 | 181 | glColor4f(1.0, 1.0, 1.0, theAlpha); 182 | glEnable(GL_TEXTURE_RECTANGLE_EXT); 183 | glReportError(); 184 | glBindTexture( GL_TEXTURE_RECTANGLE_EXT, mTextureName); 185 | glReportError(); 186 | glPushMatrix(); 187 | glTranslatef(anXPosition, aYPosition, 0); 188 | glRotatef(0, 1, 0, 0); 189 | glRotatef(0, 0, 1, 0); 190 | glRotatef(0, 0, 0, 1); 191 | // glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); 192 | glBegin( GL_QUADS ); 193 | glTexCoord2i(aTextureXPos, aTextureYPos); glVertex3i(aTextureXPos, aDrawingHeight, 0); 194 | glTexCoord2i(aTextureWidth, aTextureYPos); glVertex3i(aDrawingWidth, aDrawingHeight, 0); 195 | glTexCoord2i(aTextureWidth, aTextureHeight); glVertex3i(aDrawingWidth, aTextureYPos, 0); 196 | glTexCoord2i(aTextureXPos, aTextureHeight); glVertex3i(aTextureXPos, aTextureYPos, 0); 197 | glEnd(); 198 | 199 | glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0); 200 | glReportError(); 201 | glDisable(GL_TEXTURE_RECTANGLE_EXT); 202 | glReportError(); 203 | glPopMatrix(); 204 | } 205 | 206 | //---------------------------------------------------------------------------------------- 207 | // drawInRect:anchorPoint:alpha 208 | //---------------------------------------------------------------------------------------- 209 | - (void)drawInRect:(NSRect)theRect anchorPoint:(NSPoint)theAnchorPoint alpha:(CGFloat)theAlpha 210 | { 211 | if( mTextureName == 0 ) 212 | return; 213 | 214 | [mOpenGLContext makeCurrentContext]; 215 | 216 | CGFloat aTextureWidth = mOriginalPixelsWide; 217 | CGFloat aTextureHeight = mOriginalPixelsHigh; 218 | CGFloat aTextureXPos = 0; 219 | CGFloat aTextureYPos = 0; 220 | 221 | CGFloat aDrawingWidth = theRect.size.width; 222 | CGFloat aDrawingHeight = theRect.size.height; 223 | 224 | CGFloat anXPosition = theRect.origin.x; 225 | CGFloat aYPosition = theRect.origin.y; 226 | 227 | glColor4f(1.0, 1.0, 1.0, theAlpha); 228 | glEnable(GL_TEXTURE_RECTANGLE_EXT); 229 | glBindTexture( GL_TEXTURE_RECTANGLE_EXT, mTextureName); 230 | 231 | glPushMatrix(); 232 | glTranslatef(anXPosition, aYPosition, 0); 233 | 234 | glBegin( GL_QUADS ); 235 | glTexCoord2i(aTextureXPos, aTextureYPos); glVertex3i(aTextureXPos, aDrawingHeight, 0); 236 | glTexCoord2i(aTextureWidth, aTextureYPos); glVertex3i(aDrawingWidth, aDrawingHeight, 0); 237 | glTexCoord2i(aTextureWidth, aTextureHeight); glVertex3i(aDrawingWidth, aTextureYPos, 0); 238 | glTexCoord2i(aTextureXPos, aTextureHeight); glVertex3i(aTextureXPos, aTextureYPos, 0); 239 | glEnd(); 240 | 241 | glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0); 242 | glDisable(GL_TEXTURE_RECTANGLE_EXT); 243 | 244 | glPopMatrix(); 245 | } 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | //---------------------------------------------------------------------------------------- 257 | // size 258 | //---------------------------------------------------------------------------------------- 259 | - (NSSize)size 260 | { 261 | return NSMakeSize(mOriginalPixelsWide, mOriginalPixelsHigh); 262 | } 263 | 264 | //---------------------------------------------------------------------------------------- 265 | // hasAlpha 266 | //---------------------------------------------------------------------------------------- 267 | - (BOOL)hasAlpha 268 | { 269 | return mHasAlpha; 270 | } 271 | 272 | 273 | //---------------------------------------------------------------------------------------- 274 | // textureName 275 | //---------------------------------------------------------------------------------------- 276 | - (GLuint)textureName 277 | { 278 | return mTextureName; 279 | } 280 | 281 | //---------------------------------------------------------------------------------------- 282 | // deleteTexture 283 | //---------------------------------------------------------------------------------------- 284 | - (void)deleteTexture 285 | { 286 | if(mTextureName) 287 | { 288 | [mOpenGLContext makeCurrentContext]; 289 | glDeleteTextures(1,&mTextureName); 290 | mTextureName = 0; 291 | } 292 | [self setBitmapSource:nil]; 293 | [self setOpenGLContext:nil]; 294 | } 295 | 296 | 297 | 298 | @end 299 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTOpenGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 16/02/2009. 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | #import "KTSharedContextOpenGLView.h" 16 | #import "KTViewProtocol.h" 17 | #import "KTLayoutManager.h" 18 | #import "KTStyleManager.h" 19 | 20 | @class KTOpenGLLayer; 21 | @class KTViewOverlayWindow; 22 | 23 | @interface KTOpenGLView : NSOpenGLView 24 | { 25 | KTLayoutManager * mLayoutManager; 26 | KTStyleManager * mStyleManager; 27 | NSString * mLabel; 28 | KTOpenGLLayer * mOpenGLLayer; 29 | KTOpenGLLayer * wCurrentMouseEventHandler; 30 | KTOpenGLLayer * wCurrentKeyLayer; 31 | BOOL mShouldAcceptFirstResponder; 32 | BOOL mOpaque; 33 | NSMutableArray * mOverlayWindows; 34 | } 35 | 36 | @property (readwrite, retain) KTOpenGLLayer * openGLLayer; 37 | @property (readwrite, assign) BOOL shouldAcceptFirstResponder; 38 | @property (nonatomic, readwrite, assign) BOOL opaque; 39 | 40 | + (NSOpenGLPixelFormat*)defaultPixelFormat; 41 | - (void)drawInContext:(NSOpenGLContext*)theContext; 42 | 43 | - (void)addOverlayWindow:(KTViewOverlayWindow*)theOverlayWindow; 44 | - (void)removeOverlayWindow:(KTViewOverlayWindow*)theOverlayWindow; 45 | @end 46 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTSharedContextOpenGLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSharedContextOpenGLView.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 23/10/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface KTSharedContextOpenGLView : NSView 13 | { 14 | @private 15 | NSOpenGLContext* _openGLContext; 16 | NSOpenGLPixelFormat* _pixelFormat; 17 | } 18 | + (NSOpenGLPixelFormat*)defaultPixelFormat; 19 | - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat*)format; 20 | - (void)setOpenGLContext:(NSOpenGLContext*)context; 21 | - (NSOpenGLContext*)openGLContext; 22 | - (void)clearGLContext; 23 | - (void)prepareOpenGL; 24 | - (void)reshape; 25 | - (void)update; 26 | - (void)setPixelFormat:(NSOpenGLPixelFormat*)pixelFormat; 27 | - (NSOpenGLPixelFormat*)pixelFormat; 28 | @end 29 | -------------------------------------------------------------------------------- /Framework/Views/OpenGL/KTSharedContextOpenGLView.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSharedContextOpenGLView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 23/10/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTSharedContextOpenGLView.h" 10 | 11 | 12 | static NSOpenGLContext * gSharedOpenGLContext = nil; 13 | 14 | @implementation KTSharedContextOpenGLView 15 | + (NSOpenGLPixelFormat*)defaultPixelFormat 16 | { 17 | NSOpenGLPixelFormatAttribute anAttributes[] = { 18 | NSOpenGLPFAAccelerated, 19 | NSOpenGLPFADoubleBuffer, 20 | NSOpenGLPFANoRecovery, 21 | NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)32, 22 | (NSOpenGLPixelFormatAttribute)0 23 | }; 24 | return [[(NSOpenGLPixelFormat *)[NSOpenGLPixelFormat alloc] initWithAttributes:anAttributes] autorelease]; 25 | } 26 | 27 | 28 | + (NSOpenGLContext*)_createNewNSOpenGLContextWithSharedContext 29 | { 30 | 31 | if(!gSharedOpenGLContext) 32 | { 33 | gSharedOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:[[self class] defaultPixelFormat] shareContext:nil]; 34 | NSLog(@"ORIGINAL cgl share context: %p", [gSharedOpenGLContext CGLContextObj]); 35 | return gSharedOpenGLContext; 36 | } 37 | else 38 | { 39 | // CGLGetPixelFormat(gSharedOpenGLContext); 40 | return [[NSOpenGLContext alloc] initWithFormat:[[self class] defaultPixelFormat] shareContext:gSharedOpenGLContext]; 41 | NSLog(@"cgl share context: %p", [gSharedOpenGLContext CGLContextObj]); 42 | } 43 | } 44 | 45 | 46 | - (id)initWithFrame:(NSRect)theFrame pixelFormat:(NSOpenGLPixelFormat*)theFormat 47 | { 48 | self = [super initWithFrame:theFrame]; 49 | if (self != nil) { 50 | _pixelFormat = [theFormat retain]; 51 | } 52 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_surfaceNeedsUpdate:) name:NSViewGlobalFrameDidChangeNotification object:self]; 53 | return self; 54 | } 55 | 56 | - (void)dealloc 57 | { 58 | // get rid of the context and pixel format 59 | [[NSNotificationCenter defaultCenter] removeObserver:self name:NSViewGlobalFrameDidChangeNotification object:self]; 60 | [self clearGLContext]; 61 | [_pixelFormat release]; 62 | 63 | [super dealloc]; 64 | } 65 | 66 | - (void)setOpenGLContext:(NSOpenGLContext*)context 67 | { 68 | [self clearGLContext]; 69 | _openGLContext = [context retain]; 70 | } 71 | 72 | 73 | 74 | - (NSOpenGLContext*)openGLContext 75 | { 76 | if (_openGLContext == NULL) { 77 | _openGLContext = [[self class] _createNewNSOpenGLContextWithSharedContext]; 78 | [_openGLContext makeCurrentContext]; 79 | [self prepareOpenGL]; // call to initialize OpenGL state here 80 | } 81 | return _openGLContext; 82 | } 83 | 84 | 85 | 86 | - (void)clearGLContext 87 | { 88 | if (_openGLContext != nil) { 89 | if ([_openGLContext view] == self) { 90 | [_openGLContext clearDrawable]; 91 | } 92 | [_openGLContext release]; 93 | _openGLContext = nil; 94 | } 95 | } 96 | 97 | - (void)prepareOpenGL 98 | { 99 | // for overriding to initialize OpenGL state, occurs after context creation 100 | } 101 | 102 | - (BOOL)isOpaque 103 | { 104 | return YES; 105 | } 106 | 107 | - (void)setPixelFormat:(NSOpenGLPixelFormat*)pixelFormat 108 | { 109 | [_pixelFormat release]; 110 | _pixelFormat = [pixelFormat retain]; 111 | } 112 | 113 | - (NSOpenGLPixelFormat*)pixelFormat 114 | { 115 | return _pixelFormat; 116 | } 117 | 118 | - (void)lockFocus 119 | { 120 | // get context. will create if we don't have one yet 121 | NSOpenGLContext* context = [self openGLContext]; 122 | 123 | // make sure we are ready to draw 124 | [super lockFocus]; 125 | 126 | // when we are about to draw, make sure we are linked to the view 127 | if ([context view] != self) { 128 | [context setView:self]; 129 | } 130 | 131 | // make us the current OpenGL context 132 | [context makeCurrentContext]; 133 | } 134 | 135 | 136 | - (void)reshape 137 | { 138 | } 139 | 140 | - (void)update 141 | { 142 | if ([_openGLContext view] == self) { 143 | [_openGLContext update]; 144 | } 145 | } 146 | 147 | - (void) _surfaceNeedsUpdate:(NSNotification*)notification 148 | { 149 | [self reshape]; 150 | [self update]; 151 | } 152 | 153 | - (void)encodeWithCoder:(NSCoder *)coder 154 | { 155 | 156 | [super encodeWithCoder:coder]; 157 | if (![coder allowsKeyedCoding]) { 158 | [coder encodeValuesOfObjCTypes:"@iii", &_pixelFormat]; 159 | } else { 160 | [coder encodeObject:_pixelFormat forKey:@"NSPixelFormat"]; 161 | } 162 | } 163 | 164 | - (id)initWithCoder:(NSCoder *)coder 165 | { 166 | 167 | self = [super initWithCoder:coder]; 168 | 169 | if (![coder allowsKeyedCoding]) { 170 | [coder decodeValuesOfObjCTypes:"@iii", &_pixelFormat]; 171 | } else { 172 | _pixelFormat = [[coder decodeObjectForKey:@"NSPixelFormat"] retain]; 173 | } 174 | 175 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_surfaceNeedsUpdate:) name:NSViewGlobalFrameDidChangeNotification object:self]; 176 | 177 | return self; 178 | } 179 | 180 | @end 181 | -------------------------------------------------------------------------------- /Framework/Views/Styles/KTStyle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * KTStyledView.h 3 | * KTUIKit 4 | * 5 | * Created by Cathy Shive on 11/2/08. 6 | * Copyright 2008 __MyCompanyName__. All rights reserved. 7 | * 8 | */ 9 | 10 | @class KTStyleManager; 11 | @class NSWindow; 12 | 13 | @protocol KTStyle 14 | - (KTStyleManager*)styleManager; 15 | - (void)setStyleManager:(KTStyleManager*)theStyleManager; 16 | - (void)setNeedsDisplay:(BOOL)theBool; 17 | - (NSWindow *)window; 18 | @end -------------------------------------------------------------------------------- /Framework/Views/Styles/KTStyleManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTStyleManager.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 05/20/2008. 6 | // 7 | // Copyright (c) Cathy Shive 8 | // 9 | // Permission is hereby granted, free of charge, to any person 10 | // obtaining a copy of this software and associated documentation 11 | // files (the "Software"), to deal in the Software without 12 | // restriction, including without limitation the rights to use, 13 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the 15 | // Software is furnished to do so, subject to the following 16 | // conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | // OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | // If you use it, acknowledgement in an About Page or other appropriate place would be nice. 31 | // For example, "Contains "KTUIKit" by Cathy Shive" will do. 32 | 33 | #import 34 | #import "KTStyle.h" 35 | 36 | @interface KTStyleManager : NSObject 37 | { 38 | NSColor * mBackgroundColor; 39 | NSColor * mBorderColorTop; 40 | NSColor * mBorderColorRight; 41 | NSColor * mBorderColorBottom; 42 | NSColor * mBorderColorLeft; 43 | //NSColor * mRoundedRectBorderColor; 44 | //BOOL mDrawAsRoundedRect; 45 | 46 | CGFloat mBorderWidthTop; 47 | CGFloat mBorderWidthRight; 48 | CGFloat mBorderWidthBottom; 49 | CGFloat mBorderWidthLeft; 50 | //CGFloat mRoundedRectBorderWidth; 51 | 52 | NSGradient * mBackgroundGradient; 53 | CGFloat mGradientAngle; 54 | NSImage * mBackgroundImage; 55 | CGImageRef mBackgroundImageRef; 56 | BOOL mTileImage; 57 | 58 | id wView; 59 | } 60 | 61 | @property(readwrite,retain) NSColor * backgroundColor; 62 | @property(readwrite,retain) NSGradient * backgroundGradient; 63 | @property(readwrite,assign) CGFloat gradientAngle; 64 | @property(readwrite,retain) NSColor * borderColorTop; 65 | @property(readwrite,retain) NSColor * borderColorRight; 66 | @property(readwrite,retain) NSColor * borderColorBottom; 67 | @property(readwrite,retain) NSColor * borderColorLeft; 68 | @property(readwrite,assign) CGFloat borderWidthTop; 69 | @property(readwrite,assign) CGFloat borderWidthRight; 70 | @property(readwrite,assign) CGFloat borderWidthBottom; 71 | @property(readwrite,assign) CGFloat borderWidthLeft; 72 | 73 | - (id)initWithView:(id)theView; 74 | - (void)setView:(id)theView; 75 | 76 | // Extra configuration API 77 | - (void)setBackgroundImage:(NSImage*)theBackgroundImage tile:(BOOL)theBool; 78 | - (void)setBackgroundGradient:(NSGradient*)theGradient angle:(CGFloat)theAngle; 79 | - (void)setBorderColor:(NSColor*)theColor; 80 | - (void)setBorderColorTop:(NSColor*)TheTopColor right:(NSColor*)theRightColor bottom:(NSColor*)theBottomColor left:(NSColor*)theLeftColor; 81 | - (void)setBorderWidth:(CGFloat)theWidth; 82 | - (void)setBorderWidthTop:(CGFloat)theTopWidth right:(CGFloat)theRightWidth bottom:(CGFloat)theBottomWidth left:(CGFloat)theLeftWidth; 83 | - (void)drawStylesInRect:(NSRect)TheFrame context:(CGContextRef)theContext view:(id)theView; 84 | 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /KTOpenGLView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTOpenGLView; 11 | SuperClass = NSOpenGLView; 12 | } 13 | -------------------------------------------------------------------------------- /KTUIKit_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'KTUIKit' target in the 'KTUIKit' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTAppKitSplitView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTAppKitSplitView; 11 | SuperClass = NSSplitView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTButton.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTButton; 11 | SuperClass = NSButton; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTColorWell.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTColorWell; 11 | SuperClass = NSColorWell; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTGradientPicker.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTGradientPicker; 11 | SuperClass = KTViewControl; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTImageKitBrowserView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTImageKitBrowserView; 11 | SuperClass = IKImageBrowserView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTImageView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTImageView; 11 | SuperClass = NSImageView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTLevelIndicator.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTLevelIndicator; 11 | SuperClass = NSLevelIndicator; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTPopUpButton.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTPopUpButton; 11 | SuperClass = NSPopUpButton; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTProgressIndicator.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTProgressIndicator; 11 | SuperClass = NSProgressIndicator; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTScrollView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTScrollView; 11 | SuperClass = NSScrollView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTScroller.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTScroller; 11 | SuperClass = NSScroller; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTSearchField.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTSearchField; 11 | SuperClass = NSSearchField; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTSecureTextField.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTSecureTextField; 11 | SuperClass = NSTextField; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTSegmentedControl.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTSegmentedControl; 11 | SuperClass = NSSegmentedControl; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTSlider.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTSlider; 11 | SuperClass = NSSlider; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTSplitView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | delegate = id; 10 | }; 11 | ClassName = KTSplitView; 12 | SuperClass = KTView; 13 | } 14 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTTextField.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTTextField; 11 | SuperClass = NSTextField; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTView; 11 | SuperClass = NSView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTViewControl.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | action: = id; 6 | }; 7 | Outlets = { 8 | // Define outlet descriptions here, for example 9 | // myOutlet = NSView; 10 | }; 11 | ClassName = KTViewControl; 12 | SuperClass = KTView; 13 | } 14 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTViewController.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTViewController; 11 | SuperClass = NSViewController; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/KTWebView.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = KTWebView; 11 | SuperClass = WebView; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Class Descriptions/XSWindowController.classdescription: -------------------------------------------------------------------------------- 1 | { 2 | Actions = { 3 | // Define action descriptions here, for example 4 | // "myAction:" = id; 5 | }; 6 | Outlets = { 7 | // Define outlet descriptions here, for example 8 | // myOutlet = NSView; 9 | }; 10 | ClassName = XSWindowController; 11 | SuperClass = NSWindowController; 12 | } 13 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTLayoutManagerControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTLayoutManagerUI.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/16/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | typedef enum 14 | { 15 | KTLayoutControlStrutState_Fixed = 0, 16 | KTLayoutControlStrutState_Flexible, 17 | KTLayoutControlStrutState_Mixed 18 | 19 | }KTLayoutControlStrutState; 20 | 21 | @protocol KTLayoutManagerControlDelegate 22 | - (NSArray*)inspectedViews; 23 | @end 24 | 25 | @interface KTLayoutManagerControl : KTView 26 | #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 27 | 28 | #endif 29 | { 30 | IBInspector * wDelegate; 31 | BOOL mIsEnabled; 32 | 33 | NSTextField * wTopMarginTextField; 34 | NSTextField * wRightMarginTextField; 35 | NSTextField * wBottomMarginTextField; 36 | NSTextField * wLeftMarginTextField; 37 | 38 | NSRect mCenterRect; 39 | NSRect mTopMarginRect; 40 | NSRect mRightMarginRect; 41 | NSRect mBottomMarginRect; 42 | NSRect mLeftMarginRect; 43 | NSRect mCenterHorizontalRect; 44 | NSRect mCenterVerticalRect; 45 | 46 | NSNumber * mMarginTop; 47 | NSNumber * mMarginRight; 48 | NSNumber * mMarginBottom; 49 | NSNumber * mMarginLeft; 50 | 51 | KTLayoutControlStrutState mTopStrutState; 52 | KTLayoutControlStrutState mRightStrutState; 53 | KTLayoutControlStrutState mBottomStrutState; 54 | KTLayoutControlStrutState mLeftStrutState; 55 | KTLayoutControlStrutState mHeightStrutState; 56 | KTLayoutControlStrutState mWidthStrutState; 57 | } 58 | 59 | @property (nonatomic, readwrite,assign) IBInspector * delegate; 60 | @property (nonatomic, readwrite,assign) BOOL isEnabled; 61 | @property (nonatomic, readwrite, retain) NSNumber * marginTop; 62 | @property (nonatomic, readwrite, retain) NSNumber * marginRight; 63 | @property (nonatomic, readwrite, retain) NSNumber * marginBottom; 64 | @property (nonatomic, readwrite, retain) NSNumber * marginLeft; 65 | - (void)refresh; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTLayoutManagerInspector.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewInspector.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 5/25/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KTLayoutManagerControl; 12 | @class KTView; 13 | @interface KTLayoutManagerInspector : IBInspector 14 | { 15 | IBOutlet NSTextField * oLabel; 16 | IBOutlet KTView * oRow1View; 17 | // Frame 18 | IBOutlet NSTextField * oXPosition; 19 | IBOutlet NSTextField * oYPosition; 20 | IBOutlet NSTextField * oWidth; 21 | IBOutlet NSTextField * oHeight; 22 | IBOutlet NSButton * oFillWidthButton; 23 | IBOutlet NSButton * oFillHeightButton; 24 | 25 | // placement contrls 26 | IBOutlet NSButton * oCenterVerticallyButton; 27 | IBOutlet NSButton * oCenterHorizontallyButton; 28 | IBOutlet NSButton * oFlushTopButton; 29 | IBOutlet NSButton * oFlushBottomButton; 30 | IBOutlet NSButton * oFlushRightButton; 31 | IBOutlet NSButton * oFlushLeftButton; 32 | 33 | // alignment controls 34 | IBOutlet NSButton * oAlignTopButton; 35 | IBOutlet NSButton * oAlignVerticalCenterButton; 36 | IBOutlet NSButton * oAlignBottomButton; 37 | IBOutlet NSButton * oAlignLeftButton; 38 | IBOutlet NSButton * oAlignHorizontalCenterButton; 39 | IBOutlet NSButton * oAlignRightButton; 40 | 41 | // Autoresizing 42 | IBOutlet KTLayoutManagerControl * oLayoutControl; 43 | IBOutlet NSButton * oShouldDoLiveResizingCheckBox; 44 | } 45 | 46 | - (IBAction)setXPosition:(id)theSender; 47 | - (IBAction)setYPosition:(id)theSender; 48 | - (IBAction)setWidth:(id)theSender; 49 | - (IBAction)setHeight:(id)theSender; 50 | 51 | - (IBAction)fillCurrentWidth:(id)theSender; 52 | - (IBAction)fillCurrentHeight:(id)theSender; 53 | - (IBAction)centerHorizontally:(id)theSender; 54 | - (IBAction)centerVertically:(id)theSender; 55 | - (IBAction)flushTop:(id)theSender; 56 | - (IBAction)flushBottom:(id)theSender; 57 | - (IBAction)flushLeft:(id)theSender; 58 | - (IBAction)flushRight:(id)theSender; 59 | 60 | - (IBAction)alignTop:(id)theSender; 61 | - (IBAction)alignVerticalCenter:(id)theSender; 62 | - (IBAction)alignBottom:(id)theSender; 63 | - (IBAction)alignLeft:(id)theSender; 64 | - (IBAction)alignHorizontalCenter:(id)theSender; 65 | - (IBAction)alignRight:(id)theSender; 66 | 67 | - (IBAction)setShouldDoLiveResizing:(id)theSender; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTSplitViewInspector.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitViewInspector.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 15/05/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KTSplitViewInspector : IBInspector 12 | { 13 | IBOutlet NSColorWell * oBackgroundColorWell; 14 | IBOutlet NSColorWell * oFirstStrokeColorWell; 15 | IBOutlet NSColorWell * oSecondStrokeColorWell; 16 | IBOutlet NSPopUpButton * oOrientationPopUpButton; 17 | IBOutlet NSPopUpButton * oResizeBehaviorPopUpButton; 18 | IBOutlet NSTextField * oDividerThicknessTextField; 19 | } 20 | 21 | - (IBAction)setOrientation:(id)theSender; 22 | - (IBAction)setDividerThickness:(id)theSender; 23 | - (IBAction)setDividerBackgroundColor:(id)theSender; 24 | - (IBAction)setDividerFirstBorderColor:(id)theSender; 25 | - (IBAction)setDividerSecondBorderColor:(id)theSender; 26 | - (IBAction)setResizeBehavior:(id)theSender; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTSplitViewInspector.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitViewInspector.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 15/05/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import "KTSplitViewInspector.h" 10 | #import 11 | 12 | @interface KTSplitViewInspector (Private) 13 | - (KTSplitView*)inspectedSplitView; 14 | @end 15 | 16 | @implementation KTSplitViewInspector 17 | 18 | - (NSString *)viewNibName 19 | { 20 | return @"KTSplitViewInspector"; 21 | } 22 | 23 | + (BOOL)supportsMultipleObjectInspection 24 | { 25 | return NO; 26 | } 27 | 28 | - (void)refresh 29 | { 30 | KTSplitView * anInspectedSplitView = [self inspectedSplitView]; 31 | [oDividerThicknessTextField setIntValue:[anInspectedSplitView dividerThickness]]; 32 | [oOrientationPopUpButton selectItemWithTag:[anInspectedSplitView dividerOrientation]]; 33 | [oResizeBehaviorPopUpButton selectItemWithTag:[anInspectedSplitView resizeBehavior]]; 34 | 35 | // [oBackgroundColorWell setColor:[anInspectedSplitView fillColor]]; 36 | [super refresh]; 37 | } 38 | 39 | - (IBAction)setOrientation:(id)theSender 40 | { 41 | [[self inspectedSplitView] setDividerOrientation:[[theSender selectedItem] tag]]; 42 | } 43 | 44 | - (IBAction)setDividerThickness:(id)theSender 45 | { 46 | [[self inspectedSplitView] setDividerThickness:[theSender floatValue]]; 47 | } 48 | 49 | - (IBAction)setDividerBackgroundColor:(id)theSender 50 | { 51 | [[self inspectedSplitView] setDividerFillColor:[oBackgroundColorWell color]]; 52 | } 53 | 54 | - (IBAction)setDividerFirstBorderColor:(id)theSender 55 | { 56 | [[self inspectedSplitView] setDividerFirstStrokeColor:[oFirstStrokeColorWell color] secondColor:[oSecondStrokeColorWell color]]; 57 | } 58 | 59 | - (IBAction)setDividerSecondBorderColor:(id)theSender 60 | { 61 | [[self inspectedSplitView] setDividerFirstStrokeColor:[oFirstStrokeColorWell color] secondColor:[oSecondStrokeColorWell color]]; 62 | } 63 | 64 | - (IBAction)setResizeBehavior:(id)theSender 65 | { 66 | [[self inspectedSplitView] setResizeBehavior:[[theSender selectedItem] tag]]; 67 | } 68 | 69 | - (KTSplitView*)inspectedSplitView 70 | { 71 | KTSplitView * aSplitViewToReturn = nil; 72 | if([[self inspectedObjects] count] > 0) 73 | { 74 | id anInspectedView = [[self inspectedObjects] objectAtIndex:0]; 75 | if([anInspectedView isKindOfClass:[KTSplitView class]]) 76 | aSplitViewToReturn = anInspectedView; 77 | // else if([[anInspectedView superview] isKindOfClass:[KTSplitView class]]) 78 | // aSplitViewToReturn = (KTSplitView*)[anInspectedView superview]; 79 | } 80 | return aSplitViewToReturn; 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTStyleInspector.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTStyleInspector.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class KTGradientPicker; 12 | @class KTColorWell; 13 | 14 | @interface KTStyleInspector : IBInspector 15 | { 16 | // Background 17 | IBOutlet NSButton * oDrawBackgroundCheckBox; 18 | IBOutlet NSMatrix * oBackgroundOptionsRadioButton; 19 | IBOutlet NSColorWell * oBackgroundColorWell; 20 | IBOutlet KTGradientPicker * oBackgroundGradientPicker; 21 | 22 | // Borders 23 | IBOutlet NSButton * oDrawBordersCheckBox; 24 | IBOutlet NSButton * oEditAllBordersCheckBox; 25 | // top 26 | IBOutlet NSTextField * oTopBorderWidthTextField; 27 | IBOutlet KTColorWell* oTopBorderColorWell; 28 | // right 29 | IBOutlet NSTextField * oRightBorderWidthTextField; 30 | IBOutlet KTColorWell* oRightBorderColorWell; 31 | // bottom 32 | IBOutlet NSTextField * oBottomBorderWidthTextField; 33 | IBOutlet KTColorWell* oBottomBorderColorWell; 34 | // left 35 | IBOutlet NSTextField * oLeftBorderWidthTextField; 36 | IBOutlet KTColorWell* oLeftBorderColorWell; 37 | } 38 | 39 | - (IBAction)setDrawsBackground:(id)theSender; 40 | - (IBAction)setBackgroundOption:(id)theSender; 41 | - (IBAction)setBackgroundColor:(id)theSender; 42 | - (IBAction)setBackgroundGradient:(id)theSender; 43 | 44 | - (IBAction)setDrawsBorders:(id)theSender; 45 | - (IBAction)setBorderWidth:(id)theSender; 46 | - (IBAction)setBorderColor:(id)theSender; 47 | - (IBAction)setEditAllBorders:(id)theSender; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTViewInspector.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewInspector.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KTViewInspector : IBInspector 12 | { 13 | IBOutlet NSTextField * oLabelTextField; 14 | IBOutlet NSColorWell * oBackgroundColorWell; 15 | } 16 | 17 | - (IBAction)setLabel:(id)theSender; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Plugin/Inspectors/KTViewInspector.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewInspector.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTViewInspector.h" 10 | #import 11 | 12 | @implementation KTViewInspector 13 | 14 | - (NSString *)viewNibName 15 | { 16 | return @"KTViewInspector"; 17 | } 18 | 19 | + (BOOL)supportsMultipleObjectInspection 20 | { 21 | return NO; 22 | } 23 | 24 | - (void)refresh 25 | { 26 | NSArray * anInspectedObjectsList = [self inspectedObjects]; 27 | KTView * anInspectedView = [anInspectedObjectsList objectAtIndex:0]; 28 | [oLabelTextField setStringValue:[anInspectedView label]]; 29 | [super refresh]; 30 | } 31 | 32 | - (IBAction)setLabel:(id)theSender 33 | { 34 | NSString * aLabel = [theSender stringValue]; 35 | NSArray * anInspectedObjectsList = [self inspectedObjects]; 36 | KTView * anInspectedView = [anInspectedObjectsList objectAtIndex:0]; 37 | [anInspectedView setLabel:aLabel]; 38 | 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Plugin/Integration/KTAppKitSplitViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTAppKitSplitViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTAppKitSplitView ( KTAppKitSplitViewIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTAppKitSplitViewIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTButtonIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTButtonIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTButton ( KTButtonIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTButtonIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTColorWellIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTColorWellIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/23/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | // #import 13 | // #import "MyInspector.h" 14 | #import 15 | #import "KTLayoutManagerInspector.h" 16 | @implementation KTColorWell ( KTColorWellIntegration ) 17 | 18 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 19 | [super ibPopulateKeyPaths:keyPaths]; 20 | 21 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 22 | // in the following line with a list of your view's KVC-compliant properties. 23 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 24 | } 25 | 26 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 27 | [super ibPopulateAttributeInspectorClasses:classes]; 28 | // Replace "KTColorWellIntegrationInspector" with the name of your inspector class. 29 | [classes addObject:[KTLayoutManagerInspector class]]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Plugin/Integration/KTGradientPickerIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTGradientPickerIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/3/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTGradientPicker ( KTGradientPickerIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes 26 | { 27 | [super ibPopulateAttributeInspectorClasses:classes]; 28 | } 29 | 30 | - (NSSize)ibPreferredDesignSize 31 | { 32 | return NSMakeSize(200, 36); 33 | } 34 | 35 | - (NSSize)ibMinimumSize 36 | { 37 | return NSMakeSize(50, 36); 38 | } 39 | 40 | - (NSSize)ibMaximumSize 41 | { 42 | return NSMakeSize(2000, 36); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Plugin/Integration/KTImageKitBrowserViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageKitBrowserView.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTImageKitBrowserView ( KTImageKitBrowserViewIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTImageKitBrowserViewInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTImageViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTImageViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTImageView ( KTImageViewIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTImageViewIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTLayoutManagerIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTLayoutManagerIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 23/05/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @implementation KTLayoutManager ( KTLayoutManagerIntegration ) 13 | // 14 | //- (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths 15 | //{ 16 | // [super ibPopulateKeyPaths:keyPaths]; 17 | // [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[self keysForCoding]]; 18 | //} 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Plugin/Integration/KTLevelIndicatorIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTLevelIndicatorIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/10/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTLevelIndicator ( KTLevelIndicatorIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTLevelIndicatorIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTOpenGLViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTOpenGLViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 21/09/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "KTLayoutManagerInspector.h" 12 | #import "KTStyleInspector.h" 13 | 14 | @implementation KTOpenGLView ( KTOpenGLViewIntegration ) 15 | 16 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 17 | [super ibPopulateKeyPaths:keyPaths]; 18 | 19 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 20 | // in the following line with a list of your view's KVC-compliant properties. 21 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 22 | } 23 | 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTScrollViewIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | [classes addObject:[KTStyleInspector class]]; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Plugin/Integration/KTPopUpButtonIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTPopUpButtonIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTPopUpButton ( KTPopUpButtonIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTPopUpButtonIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Plugin/Integration/KTProgressIndicatorIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTProgressIndicatorIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTProgressIndicator ( KTProgressIndicatorIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTProgressIndicatorIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTScrollViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTScrollViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTScrollView ( KTScrollViewIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTScrollViewIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSearchFieldIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSearchFieldIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTSearchField ( KTSearchFieldIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTSearchFieldIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSecureTextFieldIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSecureTextFieldIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTSecureTextField ( KTSecureTextFieldIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTSecureTextFieldIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSegmentedControlIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSegmentedControlIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTSegmentedControl ( KTSegmentedControlIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTSegmentedControlIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSliderIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSliderIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTSlider ( KTSliderIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTSliderIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSplitViewDividerIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitViewDividerIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 14/05/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | // #import 13 | #import "KTSplitViewDivider.h" 14 | #import "KTSplitView.h" 15 | 16 | @implementation KTSplitViewDivider ( KTSplitViewDividerIntegration ) 17 | 18 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 19 | [super ibPopulateKeyPaths:keyPaths]; 20 | 21 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 22 | // in the following line with a list of your view's KVC-compliant properties. 23 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 24 | } 25 | 26 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 27 | [super ibPopulateAttributeInspectorClasses:classes]; 28 | // Replace "KTSplitViewDividerIntegrationInspector" with the name of your inspector class. 29 | // [classes addObject:[KTSplitViewDividerIntegrationInspector class]]; 30 | } 31 | 32 | 33 | - (void)drawInContext:(CGContextRef)theContext 34 | { 35 | if([[self styleManager] backgroundColor] == [NSColor clearColor] 36 | && [[self styleManager] backgroundGradient] == nil) 37 | { 38 | [[NSColor colorWithDeviceRed:103.0/255.0 green:154.0/255.0 blue:255.0/255.0 alpha:.2] set]; 39 | [NSBezierPath fillRect:[self bounds]]; 40 | // NSRect aFirstViewRect = NSInsetRect([self bounds], 1.5, 1.5); 41 | // [[NSColor colorWithCalibratedWhite:1 alpha:1] set]; 42 | // [NSBezierPath strokeRect:aFirstViewRect]; 43 | } 44 | } 45 | 46 | // 47 | //- (NSView*)hitTest:(NSPoint)thePoint 48 | //{ 49 | // if(NSPointInRect([self convertPoint:thePoint fromView:nil], [self bounds])) 50 | // { 51 | // if([[NSApp currentEvent] type]==NSLeftMouseDown) 52 | // [self mouseDown:[NSApp currentEvent]]; 53 | // return self; 54 | // } 55 | // else 56 | // return [super hitTest:thePoint]; 57 | //} 58 | // 59 | 60 | - (void) mouseDown:(NSEvent *)theEvent 61 | { 62 | 63 | 64 | 65 | NSEvent * aNextEvent = nil; 66 | while ((aNextEvent = [[self window] nextEventMatchingMask:NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSMouseMovedMask 67 | untilDate:[NSDate distantFuture] 68 | inMode:NSDefaultRunLoopMode dequeue:YES])) 69 | { 70 | switch ([aNextEvent type]) 71 | { 72 | case NSLeftMouseDragged: 73 | [self mouseDragged:aNextEvent]; 74 | break; 75 | 76 | case NSMouseMovedMask: 77 | break; 78 | 79 | case NSLeftMouseUp: 80 | [self mouseUp:aNextEvent]; 81 | // [[NSCursor arrowCursor] set]; 82 | return; 83 | 84 | 85 | 86 | default: 87 | return; 88 | } 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /Plugin/Integration/KTSplitViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTSplitViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy on 13/05/2009. 6 | // Copyright 2009 Sofa. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "KTSplitViewInspector.h" 13 | 14 | //[[[[NSDocumentController sharedDocumentController] documents] lastObject] editorManager] 15 | 16 | @implementation KTSplitView ( KTSplitViewIntegration ) 17 | 18 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)theKeyPaths 19 | { 20 | [super ibPopulateKeyPaths:theKeyPaths]; 21 | NSArray * aKeyPathsToAdd = [NSArray arrayWithObjects:@"dividerOrientation", 22 | @"dividerThickness", 23 | @"resizeBehavior", 24 | nil]; 25 | [[theKeyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:aKeyPathsToAdd]; 26 | } 27 | 28 | 29 | 30 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)theClasses 31 | { 32 | [theClasses addObject:[KTSplitViewInspector class]]; 33 | [super ibPopulateAttributeInspectorClasses:theClasses]; 34 | } 35 | 36 | - (void)ibDidAddToDesignableDocument:(IBDocument *)theDocument 37 | { 38 | [self setDividerOrientation:KTSplitViewDividerOrientation_Vertical]; 39 | [self setDividerThickness:8]; 40 | [self setDividerPosition:[self frame].size.width*.5 relativeToView:KTSplitViewFocusedViewFlag_FirstView]; 41 | [[mFirstView styleManager] setBorderColor:[NSColor whiteColor]]; 42 | [[mFirstView styleManager] setBorderWidth:1]; 43 | [[mFirstView styleManager] setBackgroundColor:[NSColor colorWithCalibratedWhite:.8 alpha:1]]; 44 | [[mSecondView styleManager] setBorderColor:[NSColor whiteColor]]; 45 | [[mSecondView styleManager] setBorderWidth:1]; 46 | [[mSecondView styleManager] setBackgroundColor:[NSColor colorWithCalibratedWhite:.8 alpha:1]]; 47 | [super ibDidAddToDesignableDocument:theDocument]; 48 | } 49 | 50 | 51 | - (NSView*)hitTest:(NSPoint)thePoint 52 | { 53 | NSPoint aMousePoint = [self convertPoint:thePoint fromView:nil]; 54 | // if there are any split views in our subviews, we'll let them handle the hittest 55 | id aViewToTest = nil; 56 | if(NSPointInRect(aMousePoint, [mFirstView frame])) 57 | aViewToTest = mFirstView; 58 | else if(NSPointInRect(aMousePoint, [mSecondView frame])) 59 | aViewToTest = mSecondView; 60 | 61 | if(aViewToTest) 62 | { 63 | if([[aViewToTest subviews] count] > 0) 64 | { 65 | if([[[aViewToTest subviews] objectAtIndex:0] isKindOfClass:[KTSplitView class]]) 66 | { 67 | return [[[aViewToTest subviews] objectAtIndex:0] hitTest:thePoint]; 68 | } 69 | } 70 | } 71 | 72 | // if we've made it to here, we can check our divider against the point 73 | id aTestResult = [super hitTest:thePoint]; 74 | if(aTestResult == mDivider) 75 | { 76 | if([[NSApp currentEvent] type] == NSMouseMoved) 77 | { 78 | if([self dividerOrientation] == KTSplitViewDividerOrientation_Horizontal) 79 | [[NSCursor resizeUpDownCursor] set]; 80 | else 81 | [[NSCursor resizeLeftRightCursor] set]; 82 | } 83 | if([[NSApp currentEvent] type] == NSLeftMouseDown) 84 | { 85 | [mDivider mouseDown:[NSApp currentEvent]]; 86 | } 87 | } 88 | else if( aTestResult==mFirstView 89 | || aTestResult==mSecondView) 90 | aTestResult = self; 91 | return aTestResult; 92 | } 93 | 94 | - (NSView*)ibDesignableContentView 95 | { 96 | return nil; 97 | } 98 | 99 | - (BOOL)ibIsChildViewUserMovable:(NSView *)theChildView 100 | { 101 | return NO; 102 | } 103 | 104 | - (BOOL)ibIsChildViewUserSizable:(NSView *)theChildView 105 | { 106 | return NO; 107 | } 108 | 109 | - (BOOL)ibIsChildInitiallySelectable:(id)child 110 | { 111 | return NO; 112 | } 113 | 114 | - (NSArray*)ibDefaultChildren 115 | { 116 | return [NSArray arrayWithObjects:mFirstView, mSecondView, nil]; 117 | } 118 | 119 | - (void)cursorUpdate:(NSEvent*)theEvent 120 | { 121 | //NSLog(@"split view UPDATE CURSOR"); 122 | if([mDivider isInDrag]) 123 | { 124 | // if([self dividerOrientation] == KTSplitViewDividerOrientation_Horizontal) 125 | // [[NSCursor resizeUpDownCursor] set]; 126 | // else 127 | // [[NSCursor resizeLeftRightCursor] set]; 128 | } 129 | else 130 | [super cursorUpdate:theEvent]; 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /Plugin/Integration/KTTextFieldIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTTextFieldIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/1/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTTextField ( KTTextFieldIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTTextFieldIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Plugin/Integration/KTViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 5/25/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | // #import "KTViewInspector.h" 15 | #import "KTStyleInspector.h" 16 | #import "KTGradientPicker.h" 17 | #import "KTSplitView.h" 18 | #import "KTSplitViewDivider.h" 19 | #import "KTSplitViewInspector.h" 20 | 21 | 22 | 23 | @implementation KTView ( KTViewIntegration ) 24 | //=========================================================== 25 | // - ibPopulateKeyPaths: 26 | //=========================================================== 27 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths 28 | { 29 | [super ibPopulateKeyPaths:keyPaths]; 30 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 31 | // in the following line with a list of your view's KVC-compliant properties. 32 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 33 | } 34 | 35 | //=========================================================== 36 | // - ibPopulateAttributeInspectorClasses: 37 | //=========================================================== 38 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes 39 | { 40 | [super ibPopulateAttributeInspectorClasses:classes]; 41 | // style inspector 42 | if( [self isKindOfClass:[KTGradientPicker class]] == NO 43 | && [self isKindOfClass:[KTSplitView class]] == NO 44 | && [[self parent] isKindOfClass:[KTSplitView class]] == NO) 45 | [classes addObject:[KTStyleInspector class]]; 46 | 47 | // layout inspector 48 | if( [self isKindOfClass:[KTSplitViewDivider class]] == NO 49 | && [[self parent] isKindOfClass:[KTSplitView class]] == NO) 50 | [classes addObject:[KTLayoutManagerInspector class]]; 51 | 52 | if([[self parent] isKindOfClass:[KTSplitView class]]) 53 | { 54 | [classes removeAllObjects]; 55 | // [classes addObject:[KTSplitViewInspector class]]; 56 | } 57 | } 58 | 59 | //=========================================================== 60 | // - drawInContext: 61 | //=========================================================== 62 | - (void)drawInContext:(CGContextRef)theContext 63 | { 64 | NSWindow * aWindow = [self window]; 65 | if(self == [aWindow contentView] 66 | && ( [[self styleManager] backgroundColor] == [NSColor clearColor] 67 | && [[self styleManager] backgroundGradient] == nil)) 68 | { 69 | NSRect aViewBounds = [self bounds]; 70 | [[NSColor colorWithCalibratedWhite:.9 alpha:1] set]; 71 | NSRectFill(aViewBounds); 72 | // CGFloat aCheckerSize = 50; 73 | // NSInteger aNumCols = ceil(aViewBounds.size.width / aCheckerSize); 74 | // NSInteger aNumRows = ceil(aViewBounds.size.height / aCheckerSize); 75 | // NSInteger i, j; 76 | // NSPoint aMovingOrigin = NSMakePoint(0, 0);//aViewBounds.size.height-aCheckerSize); 77 | // for(i = 0; i < aNumCols; i++) 78 | // { 79 | // for(j = 0; j < aNumRows; j++) 80 | // { 81 | // NSColor * aCheckerColor = nil; 82 | // if(j % 2 == 0 && i % 2 == 0) 83 | // aCheckerColor = [NSColor colorWithCalibratedWhite:.95 alpha:1]; 84 | // else if( j % 2 == 1 && i % 2 == 1) 85 | // aCheckerColor = [NSColor colorWithCalibratedWhite:.95 alpha:1]; 86 | // else 87 | // aCheckerColor = [NSColor colorWithCalibratedWhite:1 alpha:1]; 88 | // 89 | // NSRect aCheckerRect; 90 | // aCheckerRect.origin = aMovingOrigin; 91 | // aCheckerRect.size = NSMakeSize(aCheckerSize, aCheckerSize); 92 | // [aCheckerColor set]; 93 | // NSRectFill(aCheckerRect); 94 | // aMovingOrigin.y+=aCheckerSize; 95 | // } 96 | // aMovingOrigin.y = 0;//aViewBounds.size.height-aCheckerSize; 97 | // aMovingOrigin.x+=aCheckerSize; 98 | // } 99 | 100 | } 101 | else if([[self styleManager] backgroundColor] == [NSColor clearColor] 102 | && [[self styleManager] backgroundGradient] == nil) 103 | { 104 | [[NSColor colorWithDeviceRed:103.0/255.0 green:154.0/255.0 blue:255.0/255.0 alpha:.2] set]; 105 | [NSBezierPath fillRect:[self bounds]]; 106 | // NSRect aFirstViewRect = NSInsetRect([self bounds], 1.5, 1.5); 107 | // [[NSColor colorWithCalibratedWhite:1 alpha:1] set]; 108 | // [NSBezierPath strokeRect:aFirstViewRect]; 109 | } 110 | } 111 | 112 | //=========================================================== 113 | // - ibDesignableContentView 114 | //=========================================================== 115 | - (NSView*)ibDesignableContentView 116 | { 117 | return self; 118 | } 119 | // 120 | - (IBInset)ibLayoutInset 121 | { 122 | IBInset anInsetToReturn; 123 | anInsetToReturn.top = 0; 124 | anInsetToReturn.right = 0; 125 | anInsetToReturn.bottom = 0; 126 | anInsetToReturn.left = 0; 127 | if( [[self parent] isKindOfClass:[KTSplitView class]] 128 | && [[NSApp currentEvent] type] == NSLeftMouseUp) 129 | { 130 | anInsetToReturn.top = NSWidth([self frame])*.5; 131 | anInsetToReturn.right = NSWidth([self frame])*.5; 132 | anInsetToReturn.bottom = NSWidth([self frame])*.5; 133 | anInsetToReturn.left = NSWidth([self frame])*.5; 134 | } 135 | return anInsetToReturn; 136 | } 137 | // 138 | //- (BOOL)ibIsChildInitiallySelectable:(id)theChild 139 | //{ 140 | // if([[self parent] isKindOfClass:[KTSplitView class]]) 141 | // { 142 | // return YES; 143 | // } 144 | // return NO; 145 | //} 146 | 147 | @end 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /Plugin/Integration/KTWebViewIntegration.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTWebViewIntegration.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 11/2/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // Import your framework view and your inspector 12 | #import 13 | #import "KTLayoutManagerInspector.h" 14 | 15 | @implementation KTWebView ( KTWebViewIntegration ) 16 | 17 | - (void)ibPopulateKeyPaths:(NSMutableDictionary *)keyPaths { 18 | [super ibPopulateKeyPaths:keyPaths]; 19 | 20 | // Remove the comments and replace "MyFirstProperty" and "MySecondProperty" 21 | // in the following line with a list of your view's KVC-compliant properties. 22 | [[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:[NSArray arrayWithObjects:/* @"MyFirstProperty", @"MySecondProperty",*/ nil]]; 23 | } 24 | 25 | - (void)ibPopulateAttributeInspectorClasses:(NSMutableArray *)classes { 26 | [super ibPopulateAttributeInspectorClasses:classes]; 27 | // Replace "KTWebViewIntegrationInspector" with the name of your inspector class. 28 | [classes addObject:[KTLayoutManagerInspector class]]; 29 | } 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Plugin/KTUIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // KTUIKit.h 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 5/25/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface KTUIKit : IBPlugin 12 | { 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Plugin/KTUIKit.m: -------------------------------------------------------------------------------- 1 | // 2 | // KTUIKit.m 3 | // KTUIKit 4 | // 5 | // Created by Cathy Shive on 5/25/08. 6 | // Copyright 2008 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "KTUIKit.h" 10 | 11 | @implementation KTUIKit 12 | - (NSString *)label 13 | { 14 | return @"KATI"; 15 | } 16 | 17 | - (NSArray *)libraryNibNames 18 | { 19 | return [NSArray arrayWithObject:@"KTUIKitLibrary"]; 20 | } 21 | 22 | - (NSArray *)requiredFrameworks 23 | { 24 | return [NSArray arrayWithObjects:[NSBundle bundleWithIdentifier:@"com.katidev.KTUIKit"], nil]; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Plugin/KTUIKit_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'KTUIKit' target in the 'KTUIKit' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /Plugin/Resources/English.lproj/KTLayoutManagerInspector.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/English.lproj/KTLayoutManagerInspector.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Plugin/Resources/English.lproj/KTSplitViewInspector.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/English.lproj/KTSplitViewInspector.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Plugin/Resources/English.lproj/KTStyleInspector.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/English.lproj/KTStyleInspector.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Plugin/Resources/English.lproj/KTUIKitLibrary.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/English.lproj/KTUIKitLibrary.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Plugin/Resources/English.lproj/KTViewInspector.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/English.lproj/KTViewInspector.nib/keyedobjects.nib -------------------------------------------------------------------------------- /Plugin/Resources/Images/AKSplitView_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/AKSplitView_horizontal.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/AKSplitView_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/AKSplitView_vertical.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/KTScrollView.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/KTScrollView.tif -------------------------------------------------------------------------------- /Plugin/Resources/Images/KTView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/KTView.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/TextView.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/TextView.tif -------------------------------------------------------------------------------- /Plugin/Resources/Images/WebKit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/WebKit.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_bottom.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_horizontal_center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_horizontal_center.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_left.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_right.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_top.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/align_vertical_center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/align_vertical_center.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_bottom.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_center_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_center_horizontal.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_center_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_center_vertical.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_left.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_right.png -------------------------------------------------------------------------------- /Plugin/Resources/Images/placement_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Plugin/Resources/Images/placement_top.png -------------------------------------------------------------------------------- /Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.katidev.KTUIKitIBPlugin 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleSignature 20 | ???? 21 | CFBundleShortVersionString 22 | 0.9.1 23 | CFBundleVersion 24 | 0.9.1 25 | NSPrincipalClass 26 | KTUIKit 27 | 28 | 29 | -------------------------------------------------------------------------------- /Resources/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/catshive/KTUIKit/4383b949ad37f3f75a54651d961c89024b307d23/Resources/InfoPlist.strings -------------------------------------------------------------------------------- /Resources/KTUIKitFramework-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | KTUIKit 9 | CFBundleIdentifier 10 | com.katidev.KTUIKit 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | FMWK 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | NSPrincipalClass 20 | KTUIKit 21 | 22 | 23 | -------------------------------------------------------------------------------- /version.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildVersion 6 | 10 7 | CFBundleShortVersionString 8 | 1.0 9 | CFBundleVersion 10 | 1 11 | ProjectName 12 | IBXcodeIntegration 13 | SourceVersion 14 | 220000 15 | 16 | 17 | --------------------------------------------------------------------------------