Compare commits

...
182 Commits
Author SHA1 Message Date
Tom Robinson 2aacd3e807 Better xib/nib examples 2008-12-10 23:53:17 -08:00
Tom Robinson 1d2d37334c nib2cib installation fix. 2008-12-10 23:42:21 -08:00
Francisco Ryan Tolmasky I fbf4f426db Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-10 23:41:56 -08:00
Francisco Ryan Tolmasky I 5ecb83aafa Fix for menus in IE.
Reviewed by me.
2008-12-10 23:41:25 -08:00
tlrobinson 77315d0268 Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-10 19:03:03 -08:00
tlrobinson f29be2f69c CPTabView and CPTabViewItem coding and nib2cib support 2008-12-10 19:02:22 -08:00
Francisco Ryan Tolmasky I 4a9f09570e Updated SubEthaEdit syntax mode.
Reviewed by me.
2008-12-10 18:04:18 -08:00
Francisco Ryan Tolmasky I fd46487c82 Updated default bake template.
Reviewed by me.
2008-12-10 16:56:28 -08:00
Francisco Ryan Tolmasky I d92fc8c4d0 Cleaned up old deprecated documentation stuff and added documentation to deploy.
Reviewed by me.
2008-12-10 15:57:31 -08:00
Francisco Ryan Tolmasky I b87493bd5f Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-10 12:06:37 -08:00
Francisco Ryan Tolmasky I 6925bfd416 RemainingBuild change.
Reviewed by me.
2008-12-10 12:06:00 -08:00
Francisco Ryan Tolmasky I 2d9d9f3e93 Fix for timer issue in firefox.
Reviewed by me.
2008-12-10 11:24:19 -08:00
Francisco Ryan Tolmasky I 87f644e5ba Forgot to commit this earlier.
Reviewed by me.
2008-12-09 15:03:41 -08:00
Francisco Ryan Tolmasky I 5c57d241ca Changed an import to @import.
Reviewed by me.
2008-12-09 14:43:18 -08:00
Francisco Tolmasky a966e7520f Added better support for debugging.
Reviewed by me.
2008-12-09 14:08:57 -08:00
tlrobinson f6b3afa75c Various nib2cib conversion improvements (sizes, autoresize, button/window styles, etc) 2008-12-09 02:00:09 -08:00
tlrobinson cfbdb1ce76 nib2cib support for CPMenu, CPMenuItem, CPPopUpButton, including MainMenu support. New test NIBs. 2008-12-09 01:58:42 -08:00
tlrobinson 39ff2b46ab Another fix for non-ASCII characters in NIBs 2008-12-09 01:54:29 -08:00
tlrobinson 29d33193cd bridge.js XMLHttpRequest force UTF-8 encoding to fix nib2cib NIBs w/ non-ASCII characters.
Possibly incorrect assumption, but nothing appears to have broken.
2008-12-09 01:47:39 -08:00
Francisco Tolmasky 5babf3708e Fix for broken steam with new build system.
Reviewed by me.
2008-12-06 15:12:05 -08:00
Francisco Tolmasky ab40761a6c Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-05 20:43:17 -08:00
Francisco Tolmasky cf5fa034b9 Fix for textfields no longer working with new timers -- timers firing before one native run loop has occured.
[#154 state:resolved]

Reviewed by me.
2008-12-05 20:42:12 -08:00
Thomas Robinson 9d6ebf79cd Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-05 19:38:59 -08:00
Thomas Robinson c992b61ca2 Fixed _imageScaling typos 2008-12-05 19:38:18 -08:00
Ross Boucher 3ba2f208d4 Some changes to color pickers to allow you to make your own. 2008-12-05 14:57:50 -08:00
Francisco Tolmasky 462bed7d67 Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-05 09:30:20 -08:00
Francisco Tolmasky d938d39929 Fix for (At least one occurence of) the "empty menu" bug.
Reviewed by me.
2008-12-05 09:29:32 -08:00
Tom Robinson abe2e14af4 CPLog integration with sprintf. 2008-12-04 22:16:24 -08:00
Tom Robinson 3516e026d0 Improved nib2cib support for windows (min/max size, correct autoresize mask, flipped Y coordinate) 2008-12-04 22:13:41 -08:00
Tom Robinson 10db0dab7e Add %b specifier to sprintf for printing in binary. 2008-12-04 22:11:25 -08:00
Tom Robinson e0967272e7 Explicitly set radix to 10 for Ross. 2008-12-04 22:04:41 -08:00
Tom Robinson c0aa78eb76 Make CPColorWell resize correctly, and display immediately upon unarchiving. 2008-12-04 21:58:01 -08:00
Tom Robinson 09d03bf270 Merge branch 'master' of git@github.com:280north/cappuccino 2008-12-04 21:55:53 -08:00
Tom Robinson 6399ac0c95 Fixed CPStringFromRect and CPStringFromPoint 2008-12-04 21:54:50 -08:00
Francisco Tolmasky 2639b7beeb Added "all" target for building both debug and release.
Reviewed by me.
2008-12-04 21:48:00 -08:00
Francisco Tolmasky 062ff28a5c Fixed a few issues with bootstrap.
Reviewed by me.
2008-12-04 17:52:04 -08:00
Francisco Tolmasky d59403cc5b We don't need steam.xml in common.xml.
Reviewed by me.
2008-12-04 17:33:42 -08:00
Francisco Tolmasky 9565ad2cb2 Improvements to the build system.
Reviewed by me.
2008-12-04 16:29:42 -08:00
Francisco Tolmasky 72375fe1cd Fix for CPMenuItem dieing with nil keyEquivalent.
[#153 state:resolved]

Reviewed by me.
2008-12-02 18:25:29 -08:00
Francisco Tolmasky ce696a50f1 Fix for windowShouldClose: being called twice.
[#152 state:resolved]

Reviewed by me.
2008-12-02 18:08:41 -08:00
Thomas Robinson a7a4740c60 Ant task for creating docs ("ant docs") and removed absolute paths from Doxyfile. 2008-12-02 02:10:44 -08:00
Francisco Ryan Tolmasky I d0b52f7118 Replaced some imports with @imports.
Reviewed by me.
2008-11-28 11:28:20 -08:00
Francisco Ryan Tolmasky I a92243314a Fix for using transform() instead of in code calculation when available.
[#148 state:resolved]

Reviewed by me.
2008-11-24 19:42:00 -08:00
Francisco Ryan Tolmasky I 538adfeb61 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-24 17:03:42 -08:00
Francisco Ryan Tolmasky I 2dc5458e63 Fix for intervals not being clearable after one run.
[#147 state:resolved]

Reviewed by nciagra
2008-11-24 16:49:34 -08:00
Thomas Robinson 043bcc5729 gzip support in steam, removed special "cat" dependency, improved install-tools script 2008-11-21 17:24:11 -08:00
Francisco Ryan Tolmasky I 2ff51a3dbb Further press fix.
Reviewed by me.
2008-11-21 16:04:37 -08:00
Tom RobinsonandFrancisco Ryan Tolmasky I 5d8cea9ed6 Fix for press being broken.
[#143 state:resolved]

Reviewed by tolmasky.
2008-11-21 03:48:19 -08:00
Francisco Ryan Tolmasky I f3dcfbac52 Fix for hiTests always returning true in CPView.
Reviewed by me.
2008-11-20 04:39:22 -08:00
Ross Boucher 952fe0091b Compatibilty update to the whitespace commit. 2008-11-19 16:31:31 -08:00
Rich CollinsandRoss Boucher 6ea22a96ad Fix for line break bug from Rich Collins. 2008-11-19 14:19:48 -08:00
Tom Robinson b4b28cda92 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-18 20:19:56 -08:00
Tom Robinson db542fa905 objj console fix for missing file/bundle 2008-11-18 20:19:15 -08:00
Francisco Ryan Tolmasky I 30f905a253 Changed imports to @imports.
Reviewed by me.
2008-11-18 20:17:24 -08:00
Francisco Ryan Tolmasky I cc8e6e5820 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-18 20:13:05 -08:00
Francisco Ryan Tolmasky I 67ee22c6d9 Fix for nib2cib with new timeout system.
Reviewed by me.
2008-11-18 20:12:31 -08:00
Tom Robinson 20830ae349 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-18 19:42:37 -08:00
Tom Robinson 44b6f8cfc5 Objective-J backtrace prints object hash id 2008-11-18 19:38:33 -08:00
Francisco Ryan Tolmasky I 1be4ba0075 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-18 19:38:19 -08:00
Francisco Ryan Tolmasky I bbeba1e735 Fix for regression in toolbar copying behavior.
Reviewed by me.
2008-11-18 19:34:42 -08:00
Tom Robinson 3b65f460d6 Simplified stringWithHash 2008-11-18 19:28:55 -08:00
Tom Robinson fbb3959e66 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-18 18:15:29 -08:00
Francisco Ryan Tolmasky I 663f28e541 Fix for objj in the console.
Reviewed by me.
2008-11-18 18:13:39 -08:00
Tom Robinson 9321084d84 CPTimer semicolon/comma typo 2008-11-18 18:11:09 -08:00
Tom Robinson 7e352676c9 nib2cib null _superview bug fix 2008-11-18 18:10:28 -08:00
Nick TakayamaandFrancisco Ryan Tolmasky I 4c8d7b0f1c Timers.
[#116 state:resolved]

Reviewed by ross and me.
2008-11-18 02:09:35 -08:00
Francisco Ryan Tolmasky I 827e56b23f Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-15 14:57:36 -08:00
Francisco Ryan Tolmasky I 04294cf8b9 Updated SubEthaEdit mode with new syntax additions.
Reviewed by me.
2008-11-15 14:57:05 -08:00
Francisco Ryan Tolmasky I 7f0aa75ba1 Fixed inconsistency in docs.
[#118 state:resolved]

Reviewed by me.
2008-11-15 14:04:08 -08:00
Francisco Ryan Tolmasky I cb7c8046e4 Fix for plist URL encoding instead of HTML entity encoding.
[#81 state:resolved]

Reviewed by me.
2008-11-15 02:57:29 -08:00
Francisco Ryan Tolmasky I ad2bf51fd9 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-14 17:56:29 -08:00
Francisco Ryan Tolmasky I 26333c3d2b A number of improvements to the parser.
Reviewed by me.
2008-11-14 17:56:04 -08:00
Thomas Robinson cbf51a6127 Removed AppKit from test task until we actually have AppKit tests 2008-11-14 04:16:03 -08:00
Tom Robinson 4dbfe1f23e Make ant test task depend on build task 2008-11-13 21:27:45 -08:00
Tom Robinson ea5221bfda Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-13 21:27:29 -08:00
Ross Boucher ea0c9af0f8 Merge branch 'master' into atrstring 2008-11-13 21:25:52 -08:00
Tom Robinson ba43925f22 "ant test" now tests frameworks in $STEAM_BUILD/Release instead of installed 2008-11-13 21:06:02 -08:00
Tom Robinson e51b1cb7e1 Integrated OJUnit with build scripts ("ant test" runs tests, "ant release" now pulls OJUnit from separate repo) 2008-11-13 20:54:40 -08:00
Ross Boucher d64e55226d Add CPMutableAttributedString 2008-11-13 19:33:48 -08:00
Patrick CrosbyandFrancisco Ryan Tolmasky I 311939ecb9 Fix for indeterminate check in CPProgressIndicator.
[#140 state:resolved]

Reviewed by me.
2008-11-13 16:59:55 -08:00
Francisco Ryan Tolmasky I e1d57aac3b Fix for broken insertObjects:atIndexes: and tests and isEqual.
[#136 state:resolved]

Reviewed by me.
2008-11-13 16:55:33 -08:00
Ross Boucher 102c741ca3 Initial commit of CPAttributedString, and test cases. All test cases currently pass. 2008-11-13 11:23:00 -08:00
Francisco Ryan Tolmasky I 1a8093c314 Fix for minimizer not recognizing a var.
Reviewed by me.
2008-11-13 00:40:40 -08:00
Francisco Ryan Tolmasky I 7d8b02dd96 Fix for addSubview:positioned:relativeTo: not working with view already in the view treey.
Reviewed by me.
2008-11-13 00:21:13 -08:00
Glenn RempeandFrancisco Ryan Tolmasky I 6e15ce0c00 Some updates to NewApplication.
[#137 state:resolved]

Reviewed by me.
2008-11-12 19:24:04 -08:00
Francisco Ryan Tolmasky I 9e8eff4543 Fix for broken resources in DEBUG builds.
[#139 state:resolved]

Reviewed by me.
2008-11-12 18:25:42 -08:00
Thomas Robinson eee0338b63 Build script changes to allow a bootstrapped build with no existing installed tools 2008-11-11 17:55:40 -08:00
Ross Boucher 75bedef465 Merge branch 'master' into atrstring 2008-11-11 13:40:01 -08:00
Francisco Ryan Tolmasky I 8adaa2d3c8 Added CGContextSetAlpha VML implementation for use in IE, and fixed a bug where CGContextCanvas.j and CGContextVML.j were being added to AppKit.sj inappropriately.
Reviewed by me.
2008-11-11 12:21:33 -08:00
Tom Robinson 581a004ed0 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-11 02:30:44 -08:00
Tom Robinson 88fbecb4d3 Intial CPToolbar coding / nib2cib support (still need CPToolbarItem support) 2008-11-11 02:29:33 -08:00
Tom Robinson ac5c59f8ba Fixed incorrect viewClass/windowClass archiving keys 2008-11-11 02:27:56 -08:00
Ross Boucher add1776125 Fix for local CPURLConnection requests (file:///) 2008-11-10 23:16:29 -08:00
Ross Boucher 937865ef83 There was a missing @end in CPAlert.j 2008-11-10 11:17:39 -08:00
Ross Boucher bf72b5cd13 Merge branch 'master' into atrstring 2008-11-10 10:34:36 -08:00
Ross Boucher 88f12bad93 implement NSString compare:options:range
Thanks to Cacaodev for the ticket and initial stab at this.

[#105 state:resolved milestone:0.6]
2008-11-10 10:29:46 -08:00
Ross Boucher 9b764caf79 Fixes for CPAlert (style, cleanup, and some behavior). 2008-11-10 10:15:35 -08:00
Ross Boucher 56c2b9d755 Revert previous tools commit. 2008-11-10 10:07:50 -08:00
Ross Boucher 814696070d Merge branch 'master' into alert 2008-11-10 09:31:01 -08:00
Brian TaylorandRoss Boucher 0907f287af fix for future installs not overwriting previous installs
[#134 state:resolved milestone:0.6]
2008-11-10 09:29:24 -08:00
Francisco Ryan Tolmasky I 08c1973f11 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-09 18:51:21 -08:00
Francisco Ryan Tolmasky I 3156de3a5c Fixed bad CPNotificationCenter call.
Reviewed by me.
2008-11-09 18:50:46 -08:00
Tom Robinson 16209b3e3f press --main fix 2008-11-09 16:55:35 -08:00
Sam McDonaldandFrancisco Ryan Tolmasky I 9f9cc4c22c Fix for stringByDeletingLastPathComponent.
[#126 state:resolved]

Reviewed by tolmasky
2008-11-08 13:53:53 -08:00
Francisco Ryan Tolmasky I 9def3ba765 Added error output.
Reviewed by me.
2008-11-08 13:01:13 -08:00
Francisco Ryan Tolmasky I 5d5aa0a4d2 Fix for typo in build.xml.
Reviewed by me.
2008-11-08 12:38:11 -08:00
Tom Robinson edf463ab31 Fixed missing CPTabView and CPFlashView/Movie imports in AppKit.j
[#128 state:resolved responsible:tlrobinson]
2008-11-08 04:39:38 -08:00
Francisco Ryan Tolmasky I 7702fd9929 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-07 11:30:44 -08:00
Francisco Ryan Tolmasky I eae1dc2568 Fix for setHidden: not working in main menu bar.
[#78 state:resolved]

Reviewed by me.
2008-11-07 11:29:18 -08:00
Francisco Ryan Tolmasky I 204739e220 Merge branch 'master' of git@github.com:280north/cappuccino 2008-11-07 11:07:21 -08:00
Francisco Ryan Tolmasky I 41b3d7987a Hopefully this resolved the issues with isntalling the tools.
[#13 state:resolved]

Reviewed by me.
2008-11-07 11:06:39 -08:00
Francisco Ryan Tolmasky I f5b0542d35 Ugh, two remaining references.
Reviewed by me.
2008-11-07 03:09:37 -08:00
Francisco Ryan Tolmasky I b754d60752 Forgot to take out these references to the old arrow images.
Reviewed by me.
2008-11-07 03:04:56 -08:00
Francisco Ryan Tolmasky I edd49f222e Added a number of customization options to the main menubar.
Reviewed by me.
2008-11-06 00:12:47 -08:00
Francisco Ryan Tolmasky I 6cff27c7bb Fix for minimization in Cappuccino.
[#9 state:resolved]

Reviewed by ross.
2008-11-03 16:57:28 -08:00
Francisco Ryan Tolmasky I 54d48e9292 Fix for minimization in Cappuccino.
Need to figure out licensing for this.

[#9 state:resolved]

Reviewed by rossco.
2008-11-03 16:53:46 -08:00
Francisco Ryan Tolmasky I 07507eac1e Make press create 280North style plists instead of xml plists.
Reviewed by me.
2008-11-02 18:30:08 -08:00
Francisco Ryan Tolmasky I 912895d1ad Added cplutil app to convert between plist types.
Reviewed by me.
2008-11-02 10:42:05 -08:00
Ross Boucher 5823db8319 Fix for bug in CPKeyedArchiver (typo aNuumber). 2008-10-28 18:35:02 -07:00
Tom Robinson b9b109daf0 More comprehensive test XIB 2008-10-28 01:20:12 -07:00
Tom Robinson ed5aa5b54c CPColorWell coding and nib2cib support. 2008-10-28 01:08:07 -07:00
Tom Robinson 1457f5d1c8 Changed deprecated setValues/value to setFloatValue/floatValue. 2008-10-28 01:07:03 -07:00
Tom Robinson e8febcda15 Reverting to previous CPControl/CPSlider event system 2008-10-28 00:56:21 -07:00
Ross Boucher 5c04acf840 Make isEqual: more like Cocoa's version. 2008-10-27 19:27:37 -07:00
Tom Robinson a3ae869f1d Removed CPLogs and an extra performSelectors, cleaned up rest of string literals. 2008-10-27 16:49:18 -07:00
Tom Robinson 7a3fab1d6d Numerous improvements and nib2cib support for CPControl, CPSlider, CPTextField, CPWebView, etc.
Fixed broken @accessors preprocessing.
2008-10-27 04:54:43 -07:00
Francisco Ryan Tolmasky I 745df353c4 Fix for toolbar item's target set to null.
[#115 state:resolved]

Reviewed by me.
2008-10-27 01:51:08 -07:00
Francisco Ryan Tolmasky I f7dd436b81 Stop flash of scrollers when autohidden.
Reviewed by me.
2008-10-27 01:20:23 -07:00
Ross Boucher 80f95e4d58 Fix binary search in CPArray to allow searching for 0. 2008-10-26 23:06:23 -07:00
Ross Boucher 8fcf7581e6 Starting a test class for attributed string. 2008-10-26 14:37:54 -07:00
Francisco Ryan Tolmasky I 12b58cd938 Merge branch 'master' of git@github.com:280north/cappuccino 2008-10-26 00:49:28 -07:00
Francisco Ryan Tolmasky I 5144a5a579 Added @accessor support, @import, and fixed spacing bug with @selector.
Reviewed by ross.
2008-10-26 00:48:49 -07:00
Ross Boucher b5ad11323c Merge branch 'master' into string 2008-10-26 00:16:53 -07:00
Nick TakayamaandRoss Boucher 748d5b84bd ix for bad code in CPArray (incorrect range calculations) 2008-10-25 23:59:04 -07:00
Francisco Ryan Tolmasky I b7bba7dc7f Added @synthesize.
Reviewed by tom.
2008-10-24 17:40:30 -07:00
Nick TakayamaandFrancisco Ryan Tolmasky I 3e6fa883cf Removed Kuler Color Picker from Cappuccino.
Reviewed by tolmasky.
2008-10-24 14:07:14 -07:00
Francisco Ryan Tolmasky I 6f8a6bde62 Whitespace cleanup.
Reviewed by ross.
2008-10-24 13:59:32 -07:00
Francisco Ryan Tolmasky I 75aa1e591a Fix for bad copyright and spacing in NewApplication.
Reviewed by ross.
2008-10-24 13:57:09 -07:00
Ross Boucher 7568d91d28 Add copy method on CPDictionary 2008-10-23 15:36:03 -07:00
Ross Boucher 5023588af4 CPAttributedString necessary additions 2008-10-22 18:54:19 -07:00
Francisco Ryan Tolmasky I 98e5c0ed3e Merge branch 'master' of git@github.com:280north/cappuccino 2008-10-22 18:16:24 -07:00
Francisco Ryan Tolmasky I 2e9e38ebaf Fix for multiline string literals not working in Objective-J.
[#80 state:resolved]

Reviewed by me.
2008-10-22 18:13:44 -07:00
Tom Robinson f34265a864 nib2cib fix for multiple subviews in a Custom View 2008-10-22 18:01:54 -07:00
Tom Robinson cb53db05dc Merge branch 'master' of git@github.com:280north/cappuccino 2008-10-22 17:04:15 -07:00
Tom Robinson 88c64c5071 Temporary fix for lack of <data> tag support in PLISTs (for nib2cib) 2008-10-22 17:03:39 -07:00
Francisco Ryan Tolmasky I abebe2e081 Get rid of this.
Reviewed by me.
2008-10-22 16:33:05 -07:00
Tom Robinson fabd1df4dd Fix for missing debug variable 2008-10-22 16:22:41 -07:00
Tom Robinson abbbc6e8f0 Replaced regex literals with RegExp objects, due to bug [#117] 2008-10-22 16:00:26 -07:00
Tom Robinson a6e4712524 Cleanup of bridge.js. "correct" setTimeout and setInterval implementations. Removed extra code. 2008-10-22 01:04:31 -07:00
Tom Robinson 0798e47459 Cleanup of objj. Fixed bug preventing static code from working. 2008-10-22 01:03:58 -07:00
Tom Robinson 5c6b82c172 Missing headers 2008-10-21 22:28:02 -07:00
Tom Robinson 2c7c53084f Merge branch 'master' of git@github.com:280north/cappuccino 2008-10-21 16:26:55 -07:00
Tom Robinson 04695597b2 Coerce Java string to JS string in "switch" statement (otherwise they don't match) 2008-10-21 16:26:06 -07:00
Tom Robinson 956bc7fe14 Merge branch 'master' into experimental 2008-10-21 16:24:30 -07:00
Francisco Ryan Tolmasky I 75117d77a9 This shouldn't be in there.
Reviewed by me.
2008-10-21 15:59:28 -07:00
Ross Boucher 3190b57ad3 Merge branch 'array' 2008-10-21 15:54:30 -07:00
Ross Boucher 94ea70f4d4 Add binary search of a sorted array. 2008-10-21 15:53:42 -07:00
Tom Robinson d3a0d90ce7 "press" support for flattening to a single JavaScript file, and foundation of intelligent image sprites 2008-10-21 03:42:24 -07:00
Tom Robinson 010fe01265 CPBundle -resourcePath 2008-10-20 21:26:35 -07:00
Ross Boucher f8ee950339 Add a doxygen configuration. If you have doxygen, you should be able to build your own docs with this. 2008-10-20 16:17:29 -07:00
Ross Boucher f7aa5c15c9 New style for documentation (/*! vs. /*).
Enabled doxygen support.

Merge branch 'documentation'

Conflicts:
	AppKit/CPTextField.j
2008-10-20 16:14:09 -07:00
Ross Boucher 17ec9a0cae Add -l option to steam create 2008-10-20 16:05:43 -07:00
Ross Boucher 42a68812a9 Missing import in CPString 2008-10-20 01:56:24 -07:00
Ross Boucher 82f26fbdc0 Fix for an error in the last commit. 2008-10-20 01:17:22 -07:00
Nick TakayamaandRoss Boucher f19793f8a3 add delegate functions to CPTextField and CPControl 2008-10-20 00:57:54 -07:00
Jake MacMullinandRoss Boucher 13940ad38f Added an initial implementation of CPAlert. 2008-10-19 22:12:52 -07:00
Tom Robinson abe4dd7abc sprintf and related functions support for "%@" format specifier 2008-10-19 20:39:04 -07:00
Ross Boucher c6a2d55821 Fix for a broken exception raise in CPToolbar.
THanks terhorst for reporting the issue.

[#102 state:resolved];
2008-10-19 20:35:25 -07:00
Nick TakayamaandRoss Boucher dd56b75bd6 Better behavior for placeholder text in CPTextField.
Primarily from Nick, partially from me.

[#101 state:resolved]
2008-10-19 20:08:24 -07:00
Tom Robinson cd2a66a644 objjc now checks syntax of preprocessed code. 2008-10-18 22:42:16 -07:00
Tom Robinson 32fd299d1d Fixed encoding issue with objj console.
[#108 state:resolved responsible:tlrobinson]
2008-10-18 21:45:05 -07:00
Nick TakayamaandRoss Boucher fc9e5b3a4c implementing CPString compare: so that sorting will work with default selector 2008-10-17 14:43:43 -07:00
Francisco Ryan Tolmasky I 0ac0a84b18 Fix for CPSplitView indents its subviews by frame.origin.
[#106 state:resolved]

Reviewed by me.
2008-10-16 05:39:28 -07:00
Francisco Ryan Tolmasky I dad6d613e6 Merge branch 'master' of git@github.com:280north/cappuccino 2008-10-14 22:26:44 -07:00
Francisco Ryan Tolmasky I fd23867c93 Make sure non-static files store their fragments.
Reviewed  by me.
2008-10-14 22:23:23 -07:00
Ross Boucher 59b7c55ba2 Else protecting dom opacity access. 2008-10-13 20:11:22 -07:00
Ross Boucher 0997042dcd Performance improvement in CPView setAlphaValue: 2008-10-13 19:49:53 -07:00
Ross Boucher 847118c35b Addendum to previous commit.
Thanks to Jake MacMullin for this fix.

[#99 state:resolved]
2008-10-12 21:23:19 -07:00
Jake MacMullinandRoss Boucher 5a086243f5 Implemented missing methods on CPString:
stringByReplacingOccurrencesOfString:target withString:replacement options:options range:searchRange
stringByReplacingCharactersInRange:range withString:replacement

Signed-off-by: Jake MacMullin <jmacmullin@mac.com>
2008-10-12 21:05:56 -07:00
Ross Boucher f228934e54 Initial conversion to Doxygen style comments. 2008-10-12 15:57:01 -07:00
Ross Boucher 5404b0bbfa style guide fix 2008-10-09 23:19:00 -07:00
Ross Boucher c2b1130e23 Fix for setStringValue on CPTextField being broken if first responder.
First commit by Nick Takayama! Thanks!

[#100 state:resolved]
2008-10-09 23:15:18 -07:00
218 changed files with 18374 additions and 5633 deletions
+45 -41
View File
@@ -20,44 +20,48 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CALayer.j"
import "CPAnimation.j"
import "CPApplication.j"
import "CPButton.j"
import "CPClipView.j"
import "CPCollectionView.j"
import "CPColor.j"
import "CPColorPanel.j"
import "CPColorWell.j"
import "CPCompatibility.j"
import "CPControl.j"
import "CPCookie.j"
import "CPDocument.j"
import "CPDocumentController.j"
import "CPEvent.j"
import "CPFont.j"
import "CPFontManager.j"
import "CPGeometry.j"
import "CPImage.j"
import "CPImageView.j"
import "CPMenu.j"
import "CPMenuItem.j"
import "CPPanel.j"
import "CPPasteboard.j"
import "CPPopUpButton.j"
import "CPProgressIndicator.j"
import "CPResponder.j"
import "CPScroller.j"
import "CPScrollView.j"
import "CPSecureTextField.j"
import "CPSegmentedControl.j"
import "CPShadow.j"
import "CPSlider.j"
import "CPSplitView.j"
import "CPTextField.j"
import "CPToolbar.j"
import "CPToolbarItem.j"
import "CPView.j"
import "CPWebView.j"
import "CPWindow.j"
import "CPWindowController.j"
@import "CALayer.j"
@import "CPAlert.j"
@import "CPAnimation.j"
@import "CPApplication.j"
@import "CPButton.j"
@import "CPClipView.j"
@import "CPCollectionView.j"
@import "CPColor.j"
@import "CPColorPanel.j"
@import "CPColorWell.j"
@import "CPCompatibility.j"
@import "CPControl.j"
@import "CPCookie.j"
@import "CPDocument.j"
@import "CPDocumentController.j"
@import "CPEvent.j"
@import "CPFlashMovie.j"
@import "CPFlashView.j"
@import "CPFont.j"
@import "CPFontManager.j"
@import "CPGeometry.j"
@import "CPImage.j"
@import "CPImageView.j"
@import "CPMenu.j"
@import "CPMenuItem.j"
@import "CPPanel.j"
@import "CPPasteboard.j"
@import "CPPopUpButton.j"
@import "CPProgressIndicator.j"
@import "CPResponder.j"
@import "CPScrollView.j"
@import "CPScroller.j"
@import "CPSecureTextField.j"
@import "CPSegmentedControl.j"
@import "CPShadow.j"
@import "CPSlider.j"
@import "CPSplitView.j"
@import "CPTabView.j"
@import "CPTextField.j"
@import "CPToolbar.j"
@import "CPToolbarItem.j"
@import "CPView.j"
@import "CPWebView.j"
@import "CPWindow.j"
@import "CPWindowController.j"
+9 -13
View File
@@ -14,6 +14,9 @@
<string>CPOutlineView.j</string>
<string>CPTableColumn.j</string>
<string>CPTableView.j</string>
<!-- These get compiled into CGContext -->
<string>CoreGraphics/CGContextCanvas.j</string>
<string>CoreGraphics/CGContextVML.j</string>
</array>
<key>Flags</key>
<string>-DPLATFORM_DOM</string>
@@ -26,6 +29,9 @@
<string>CPOutlineView.j</string>
<string>CPTableColumn.j</string>
<string>CPTableView.j</string>
<!-- These get compiled into CGContext -->
<string>CoreGraphics/CGContextCanvas.j</string>
<string>CoreGraphics/CGContextVML.j</string>
</array>
</dict>
</array>
@@ -35,23 +41,13 @@
<key>Name</key>
<string>Debug</string>
<key>Flags</key>
<string>-DDEBUG</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
</dict>
<string>-DDEBUG -g</string>
</dict>
<dict>
<key>Name</key>
<string>Release</string>
<key>Settings</key>
<dict>
<key>PREPROCESS</key>
<true/>
<key>PREINTERPRET</key>
<true/>
</dict>
<key>Flags</key>
<string>-O</string>
</dict>
</array>
</dict>
+243
View File
@@ -0,0 +1,243 @@
/*
* CPAlert.j
* AppKit
*
* Created by Jake MacMullin.
* Copyright 2008, Jake MacMullin.
*
* 11/10/2008 Ross Boucher
* - Make it conform to style guidelines, general cleanup and ehancements
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@import <AppKit/CPApplication.j>
@import <AppKit/CPButton.j>
@import <AppKit/CPColor.j>
@import <AppKit/CPFont.j>
@import <AppKit/CPImage.j>
@import <AppKit/CPImageView.j>
@import <AppKit/CPPanel.j>
@import <AppKit/CPTextField.j>
/*
@global
@group CPAlertStyle
*/
CPWarningAlertStyle = 0;
/*
@global
@group CPAlertStyle
*/
CPInformationalAlertStyle = 1;
/*
@global
@group CPAlertStyle
*/
CPCriticalAlertStyle = 2;
var CPAlertWarningImage,
CPAlertInformationImage,
CPAlertErrorImage;
/*
CPAlert is an alert panel that can be displayed modally to present the
user with a message and one or more options.
It can be used to display an information message (<pre>CPInformationalAlertStyle</pre>),
a warning message (<pre>CPWarningAlertStyle</pre> - which is the default), or a critical
alert (<pre>CPCriticalAlertStyle</pre>). In each case the user can be presented with one
or more options by adding buttons using the <pre>addButtonWithTitle:</pre> method.
The panel is displayed modally by calling <pre>runModal</pre> and once the user has
dismissed the panel, a message will be sent to the panel's delegate (if set), informing
it which button was clicked (see delegate methods).
@delegate -(void)alertDidEnd:(CPAlert)theAlert returnCode:(int)returnCode;
Called when the user dismisses the alert by clicking one of the buttons.
@param theAlert the alert panel that the user dismissed
@param returnCode the index of the button that the user clicked (starting from 0,
representing the first button added to the alert which appears on the
right, 1 representing the next button to the left and so on)
*/
@implementation CPAlert : CPObject
{
CPPanel _alertPanel;
CPTextField _messageLabel;
CPImageView _alertImageView;
CPAlertStyle _alertStyle;
int _buttonCount;
id _delegate;
}
+ (void)initialize
{
if (self != CPAlert)
return;
var bundle = [CPBundle bundleForClass:[self class]];
CPAlertWarningImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-warning.png"]
size:CGSizeMake(32,32)];
CPAlertInformationImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-information.png"]
size:CGSizeMake(32,32)];
CPAlertErrorImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPAlert/dialog-error.png"]
size:CGSizeMake(32,32)];
}
/*!
Initializes a <pre>CPAlert</pre> panel with the default alert style (<pre>CPWarningAlertStyle</pre>).
*/
- (id)init
{
self = [super init];
if (self)
{
_buttonCount = 0;
_alertStyle = CPWarningAlertStyle;
_alertPanel = [[CPPanel alloc] initWithContentRect:CGRectMake(0, 0, 300, 150) styleMask:CPHUDBackgroundWindowMask|CPTitledWindowMask];
[_alertPanel setFloatingPanel:YES];
[_alertPanel center];
_messageLabel = [[CPTextField alloc] initWithFrame: CGRectMake(70,10, 200, 100)];
[_messageLabel setFont: [CPFont fontWithName: "Helvetica Neue" size: 12.0]];
[_messageLabel setTextColor: [CPColor whiteColor]];
[_messageLabel setLineBreakMode:CPLineBreakByWordWrapping];
[[_alertPanel contentView] addSubview: _messageLabel];
_alertImageView = [[CPImageView alloc] initWithFrame:CGRectMake(25,12,32,32)];
[[_alertPanel contentView] addSubview: _alertImageView];
}
return self;
}
/*!
Sets the receivers delegate.
@param delegate - Delegate for the alert. nil removes the delegate.
*/
- (void)setDelegate:(id)delegate
{
_delegate = delegate;
}
/*!
Gets the receiver's delegate.
*/
- (void)delegate
{
return _delegate;
}
/*!
Sets the alert style of the receiver.
@param style - Alert style for the alert.
*/
- (void)setAlertStyle:(CPAlertStyle)style
{
_alertStyle = style;
}
/*!
Gets the alert style.
*/
- (CPAlertStyle)alertStyle
{
return _alertStyle;
}
/*!
Sets the receivers message text, or title, to a given text.
@param messageText - Message text for the alert.
*/
- (void)setMessageText:(CPString)messageText
{
[_messageLabel setStringValue:messageText];
}
/*!
Return's the receiver's message text body.
*/
- (CPString)messageText
{
return [_messageLabel stringValue];
}
/*!
Adds a button with a given title to the receiver.
Buttons will be added starting from the right hand side of the <pre>CPAlert</pre> panel.
The first button will have the index 0, the second button 1 and so on.
You really shouldn't need more than 3 buttons.
*/
- (void)addButtonWithTitle:(CPString)title
{
var button = [[CPButton alloc] initWithFrame:CGRectMake(190 - (_buttonCount * 90),80,80,18)];
[button setTitle:title];
[button setTarget:self];
[button setTag:_buttonCount];
[button setBezelStyle:CPHUDBezelStyle];
[button setAction:@selector(_notifyDelegate:)];
[[_alertPanel contentView] addSubview:button];
_buttonCount++;
}
/*!
Displays the <pre>CPAlert</pre> panel as a modal dialog. The user will not be
able to interact with any other controls until s/he has dismissed the alert
by clicking on one of the buttons.
*/
- (void)runModal
{
switch (_alertStyle)
{
case CPWarningAlertStyle: [_alertImageView setImage:CPAlertWarningImage];
break;
case CPInformationalAlertStyle: [_alertImageView setImage:CPAlertInformationImage];
break;
case CPCriticalAlertStyle: [_alertImageView setImage:CPAlertErrorImage];
break;
}
[CPApp runModalForWindow:_alertPanel];
}
/* @ignore */
- (void)_notifyDelegate:(id)button
{
if (_delegate && [_delegate respondsToSelector:@selector(alertDidEnd:returnCode:)])
[_delegate alertDidEnd:self returnCode:[button tag]];
[CPApp abortModal];
[_alertPanel close];
}
@end
+27 -27
View File
@@ -20,9 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
@import "CAMediaTimingFunction.j"
import "CAMediaTimingFunction.j"
/*
@global
@@ -47,9 +48,11 @@ CPAnimationLinear = 3;
ACTUAL_FRAME_RATE = 0;
/*
/*! @class CPAnimation
Manages an animation. Contains timing and progress information.
@par Delegate Methods
@delegate -(BOOL)animationShouldStart:(CPAnimation)animation;
Called at the beginning of <code>startAnimation</code>.
@param animation the animation that will start
@@ -65,7 +68,7 @@ ACTUAL_FRAME_RATE = 0;
@param animation the animation that was stopped
@delegate - (float)animation:(CPAnimation)animation valueForProgress:(float)progress;
The value from this method will be returned when <objj>CPAnimation</objj>'s
The value from this method will be returned when CPAnimation's
<code>currentValue</code> method is called.
@param animation the animation to obtain the curve value for
@param progress the current animation progress
@@ -86,7 +89,7 @@ ACTUAL_FRAME_RATE = 0;
CPTimer _timer;
}
/*
/*!
Initializes the animation with a duration and animation curve.
@param aDuration the length of the animation
@param anAnimationCurve defines the animation's pace
@@ -106,7 +109,7 @@ ACTUAL_FRAME_RATE = 0;
return self;
}
/*
/*!
Sets the animation's pace.
@param anAnimationCurve the animation's pace
@throws CPInvalidArgumentException if an invalid animation curve is specified
@@ -136,7 +139,7 @@ ACTUAL_FRAME_RATE = 0;
_timingFunction = [CAMediaTimingFunction functionWithName:timingFunctionName];
}
/*
/*!
Returns the animation's pace
*/
- (CPAnimationCurve)animationCurve
@@ -144,7 +147,7 @@ ACTUAL_FRAME_RATE = 0;
return _animationCurve;
}
/*
/*!
Sets the animation's length.
@param aDuration the new animation length
@throws CPInvalidArgumentException if <code>aDuration</code> is negative
@@ -157,7 +160,7 @@ ACTUAL_FRAME_RATE = 0;
_duration = aDuration;
}
/*
/*!
Returns the length of the animation.
*/
- (CPTimeInterval)duration
@@ -165,7 +168,7 @@ ACTUAL_FRAME_RATE = 0;
return _duration;
}
/*
/*!
Sets the animation frame rate. This is not a guaranteed frame rate. 0 means to go as fast as possible.
@param frameRate the new desired frame rate
@throws CPInvalidArgumentException if <code>frameRate</code> is negative
@@ -178,7 +181,7 @@ ACTUAL_FRAME_RATE = 0;
_frameRate = frameRate;
}
/*
/*!
Returns the desired frame rate.
*/
- (float)frameRate
@@ -186,7 +189,7 @@ ACTUAL_FRAME_RATE = 0;
return _frameRate;
}
/*
/*!
Returns the animation's delegate
*/
- (id)delegate
@@ -194,7 +197,7 @@ ACTUAL_FRAME_RATE = 0;
return _delegate;
}
/*
/*!
Sets the animation's delegate.
@param aDelegate the new delegate
*/
@@ -203,7 +206,7 @@ ACTUAL_FRAME_RATE = 0;
_delegate = aDelegate;
}
/*
/*!
Starts the animation. The method calls <code>animationShouldStart:</code>
on the delegate (if it implements it) to see if the animation
should begin.
@@ -217,11 +220,8 @@ ACTUAL_FRAME_RATE = 0;
_progress = 0.0;
ACTUAL_FRAME_RATE = 0;
_startTime = new Date();
// FIXME: THIS SHOULD BE A CPTIMER!!!
_timer = window.setInterval(function() {
[self animationTimerDidFire:_timer];
[[CPRunLoop currentRunLoop] performSelectors];
}, 1); // must be 1ms not 0 for IE. //_duration * 1000 / _frameRate);
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
}
/*
@@ -236,9 +236,9 @@ ACTUAL_FRAME_RATE = 0;
[self setCurrentProgress:progress];
if (progress == 1.0)
if (progress === 1.0)
{
window.clearTimeout(_timer);
[_timer invalidate];
_timer = nil;
if ([_delegate respondsToSelector:@selector(animationDidEnd:)])
@@ -247,7 +247,7 @@ ACTUAL_FRAME_RATE = 0;
}
/*
/*!
Stops the animation before it has completed.
*/
- (void)stopAnimation
@@ -255,14 +255,14 @@ ACTUAL_FRAME_RATE = 0;
if (!_timer)
return;
window.clearTimeout(_timer);
[_timer invalidate];
_timer = nil;
if ([_delegate respondsToSelector:@selector(animationDidStop:)])
[_delegate animationDidStop:self];
}
/*
/*!
Returns <code>YES</code> if the animation
is running.
*/
@@ -271,7 +271,7 @@ ACTUAL_FRAME_RATE = 0;
return _timer;
}
/*
/*!
Sets the animation's progress.
@param aProgress the animation's progress
*/
@@ -280,7 +280,7 @@ ACTUAL_FRAME_RATE = 0;
_progress = aProgress;
}
/*
/*!
Returns the animation's progress
*/
- (float)currentProgress
@@ -288,7 +288,7 @@ ACTUAL_FRAME_RATE = 0;
return _progress;
}
/*
/*!
Returns the animation's timing progress.
*/
- (float)currentValue
+41 -39
View File
@@ -20,13 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPBundle.j>
@import <Foundation/CPBundle.j>
@import "CPCompatibility.j"
@import "CPEvent.j"
@import "CPMenu.j"
@import "CPResponder.j"
@import "CPDocumentController.j"
import "CPCompatibility.j"
import "CPEvent.j"
import "CPMenu.j"
import "CPResponder.j"
import "CPDocumentController.j"
CPApp = nil;
@@ -37,7 +38,8 @@ CPRunStoppedResponse = -1000;
CPRunAbortedResponse = -1001;
CPRunContinuesResponse = -1002;
/*
/*! @class CPApplication
CPApplication is THE way to start up the Cappucino framework for your application to use.
Every GUI application has exactly one instance of CPApplication (or of a custom subclass of
CPApplication). Your program's main() function can create that instance by calling the
@@ -81,7 +83,7 @@ CPRunContinuesResponse = -1002;
CPArray _args;
}
/*
/*!
Returns the singleton instance of the running application. If it
doesn't exist, it will be created, and then returned.
@return the application singleton
@@ -94,7 +96,7 @@ CPRunContinuesResponse = -1002;
return CPApp;
}
/*
/*!
Initializes the Document based application with basic menu functions.
Functions are <code>New, Open, Undo, Redo, Save, Cut, Copy, Paste</code>.
@return the initialized application
@@ -174,7 +176,7 @@ CPRunContinuesResponse = -1002;
// Configuring Applications
/*
/*!
Sets the delegate for this application. The delegate will receive various notifications
caused by user interactions during the application's run. The delegate can choose to
react to these events.
@@ -217,7 +219,7 @@ CPRunContinuesResponse = -1002;
object:self];
}
/*
/*!
Returns the application's delegate. The app can only have one delegate at a time.
*/
- (id)delegate
@@ -225,10 +227,10 @@ CPRunContinuesResponse = -1002;
return _delegate;
}
/*
/*!
This method is called by <code>run</code> before the event loop begins.
When it successfully completes, it posts the notification
<objj>CPApplicationDidFinishLaunchingNotification</objj>. If you override
CPApplicationDidFinishLaunchingNotification. If you override
<code>finishLaunching</code>, the subclass method should invoke the superclass method.
*/
- (void)finishLaunching
@@ -265,10 +267,10 @@ CPRunContinuesResponse = -1002;
postNotificationName:CPApplicationDidFinishLaunchingNotification
object:self];
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
/*
/*!
Calls <code>finishLaunching</code> method which results in starting
the main event loop.
*/
@@ -278,7 +280,7 @@ CPRunContinuesResponse = -1002;
}
// Managing the Event Loop
/*
/*!
Starts a modal event loop for <code>aWindow</code>
@param aWindow the window to start the event loop for
*/
@@ -287,7 +289,7 @@ CPRunContinuesResponse = -1002;
[self runModalSession:[self beginModalSessionForWindow:aWindow]];
}
/*
/*!
Stops the event loop started by <code>runModalForWindow:</code> and
sets the code that <code>runModalForWindow:</code> will return.
@param aCode the return code for the modal event
@@ -321,7 +323,7 @@ CPRunContinuesResponse = -1002;
}
}
/*
/*!
Stops the modal event loop
*/
- (void)stopModal
@@ -329,7 +331,7 @@ CPRunContinuesResponse = -1002;
[self stopModalWithCode:CPRunStoppedResponse]
}
/*
/*!
Aborts the event loop started by <code>runModalForWindow:</code>
*/
- (void)abortModal
@@ -337,7 +339,7 @@ CPRunContinuesResponse = -1002;
[self stopModalWithCode:CPRunAbortedResponse];
}
/*
/*!
Sets up a modal session with <code>theWindow</code>.
@param aWindow the window to set up the modal session for
*/
@@ -346,7 +348,7 @@ CPRunContinuesResponse = -1002;
return _CPModalSessionMake(aWindow, 0);
}
/*
/*!
Runs a modal session
@param CPModalSession the session to run
*/
@@ -365,7 +367,7 @@ CPRunContinuesResponse = -1002;
[CPApp setCallback:_CPRunModalLoop forNextEventMatchingMask:CPAnyEventMask untilDate:nil inMode:0 dequeue:NO];
}
/*
/*!
Returns the window for the current modal session. If there is no
modal session, it returns <code>nil</code>.
*/
@@ -386,7 +388,7 @@ CPRunContinuesResponse = -1002;
return NO;
}
/*
/*!
Dispatches events to other objects.
@param anEvent the event to dispatch
*/
@@ -418,7 +420,7 @@ CPRunContinuesResponse = -1002;
[super doCommandBySelector:aSelector];
}
/*
/*!
Returns the key window.
*/
- (CPWindow)keyWindow
@@ -426,7 +428,7 @@ CPRunContinuesResponse = -1002;
return _keyWindow;
}
/*
/*!
Returns the main window.
*/
- (CPWindow)mainWindow
@@ -434,16 +436,16 @@ CPRunContinuesResponse = -1002;
return _mainWindow;
}
/*
Returns the <objj>CPWindow</objj> object corresponding to <code>aWindowNumber</code>.
/*!
Returns the CPWindow object corresponding to <code>aWindowNumber</code>.
*/
- (CPWindow)windowWithWindowNumber:(int)aWindowNumber
{
return _windows[aWindowNumber];
}
/*
Returns an array of the application's <objj>CPWindow</objj>s
/*!
Returns an array of the application's CPWindows
*/
- (CPArray)windows
{
@@ -451,7 +453,7 @@ CPRunContinuesResponse = -1002;
}
// Accessing the Main Menu
/*
/*!
Returns the application's main menu
*/
- (CPMenu)mainMenu
@@ -459,7 +461,7 @@ CPRunContinuesResponse = -1002;
return _mainMenu;
}
/*
/*!
Sets the main menu for the application
@param aMenu the menu to set for the application
*/
@@ -469,7 +471,7 @@ CPRunContinuesResponse = -1002;
}
// Posting Actions
/*
/*!
Tries to perform the action with an argument. Performs
the action on itself (if it responds to it), then
tries to perform the action on the delegate.
@@ -496,7 +498,7 @@ CPRunContinuesResponse = -1002;
return NO;
}
/*
/*!
Sends an action to a target.
@param anAction the action to send
@param aTarget the target for the action
@@ -515,7 +517,7 @@ CPRunContinuesResponse = -1002;
return YES;
}
/*
/*!
Finds a target for the specified action. If the
action is <code>nil</code>, returns <code>nil</code>.
If the target is not <code>nil</code>, <code>aTarget</code> is
@@ -537,7 +539,7 @@ CPRunContinuesResponse = -1002;
return [self targetForAction:anAction];
}
/*
/*!
Finds an action-target for a specified window.
It finds a matching target in the following order:
<ol>
@@ -591,13 +593,13 @@ CPRunContinuesResponse = -1002;
return nil;
}
/*
/*!
Looks for a target that can handle the specified action.
Checks for a target in the following order:
<ol>
<li>a responder from the key window</li>
<li>a responder frmo the main window</li>
<li>the <objj>CPApplication</objj> instance</li>
<li>the CPApplication instance</li>
<li>the application delegate</li>
<li>the document controller</li>
</ol>
@@ -646,7 +648,7 @@ CPRunContinuesResponse = -1002;
// Managing Sheets
/*
/*!
Displays a window as a sheet.
@param aSheet the window to display as a sheet
@param aWindow the window that will hold the sheet as a child
@@ -698,7 +700,7 @@ var _CPRunModalLoop = function(anEvent)
[CPApp _removeRunModalLoop];
}
/*
/*!
Starts the GUI and Cappuccino frameworks. This function should be
called from the <code>main()</code> function of your program.
@class CPApplication
+48 -46
View File
@@ -20,13 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "_CPImageAndTitleView.j"
import "CGGeometry.j"
@import "_CPImageAndTitleView.j"
@import "CGGeometry.j"
import "CPControl.j"
@import "CPControl.j"
#include "CoreGraphics/CGGeometry.h"
CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;
@@ -219,8 +220,9 @@ var _CPButtonClassName = nil,
_CPButtonBezelStyleIdentifiers = {},
_CPButtonBezelStyleHighlightedIdentifier = @"Highlighted";
/*
<objj>CPButton</objj> is a subclass of <objj>CPControl</objj> that
/*! @class CPButton
CPButton is a subclass of CPControl that
intercepts mouse-down events and sends an action message to a
target object when it's clicked or pressed.
*/
@@ -235,7 +237,7 @@ var _CPButtonClassName = nil,
CPImage _alternateImage;
CPCellImagePosition _imagePosition;
CPImageScaling _imageScalng;
CPImageScaling _imageScaling;
CPString _title;
CPString _alternateTitle;
@@ -249,8 +251,8 @@ var _CPButtonClassName = nil,
_CPImageAndTitleView _imageAndTitleView;
}
/*
Initializes the <objj>CPButton</objj> class.
/*!
Initializes the CPButton class.
@ignore
*/
+ (void)initialize
@@ -303,7 +305,7 @@ var _CPButtonClassName = nil,
}
// Configuring Buttons
/*
/*!
Sets how the button highlights and shows its state.
@param aButtonType Defines the behavior of the button.
*/
@@ -338,7 +340,7 @@ var _CPButtonClassName = nil,
return self;
}
/*
/*!
Sets the position of the button's image to <code>anImagePosition</code>.
@param anImagePosition the position for the button's image
*/
@@ -352,7 +354,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Returns the buton's image position
*/
- (CPCellImagePosition)imagePosition
@@ -360,7 +362,7 @@ var _CPButtonClassName = nil,
return _imagePosition;
}
/*
/*!
Sets the button's images scaling method
@param anImageScaling the image scaling method
*/
@@ -374,7 +376,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Returns the button's image scaling method
*/
- (CPImageScaling)imageScaling
@@ -382,7 +384,7 @@ var _CPButtonClassName = nil,
return _imageScaling;
}
/*
/*!
Sets the color of the button's text
@param aColor the color to use for drawing the button text
*/
@@ -393,7 +395,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Sets the font that will be used to draw the button text
@param aFont the font used to draw the button text
*/
@@ -405,7 +407,7 @@ var _CPButtonClassName = nil,
}
// Setting the state
/*
/*!
Returns <code>YES</code> if the button has a 'mixed' state in addition to on and off.
*/
- (BOOL)allowsMixedState
@@ -413,7 +415,7 @@ var _CPButtonClassName = nil,
return _allowsMixedState;
}
/*
/*!
Sets whether the button can have a 'mixed' state.
@param aFlag specifies whether a 'mixed' state is allowed or not
*/
@@ -422,7 +424,7 @@ var _CPButtonClassName = nil,
_allowsMixedState = aFlag;
}
/*
/*!
Sets the button to its next state.
*/
- (void)setNextState
@@ -433,9 +435,9 @@ var _CPButtonClassName = nil,
_state = (_state >= CPOnState && _allowsMixedState) ? CPMixedState : CPOffState;
}
/*
/*!
Sets the button's state to <code>aState</code>.
@param aState Possible states are any of the <objj>CPButton</objj> globals:
@param aState Possible states are any of the CPButton globals:
<code>CPOffState, CPOnState, CPMixedState</code>
*/
- (void)setState:(int)aState
@@ -443,7 +445,7 @@ var _CPButtonClassName = nil,
_state = aState;
}
/*
/*!
Returns the button's current state
*/
- (int)state
@@ -451,7 +453,7 @@ var _CPButtonClassName = nil,
return _state;
}
/*
/*!
Sets the alignment of the text on the button.
@param anAlignment an alignment object
*/
@@ -462,7 +464,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Sets the image that will be drawn on the button.
@param anImage the image that will be drawn
*/
@@ -476,7 +478,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Returns the image that will be drawn on the button
*/
- (CPImage)image
@@ -484,7 +486,7 @@ var _CPButtonClassName = nil,
return _image;
}
/*
/*!
Sets the button's image which is used in its alternate state.
@param anImage the image to be used while the button is in an alternate state
*/
@@ -493,7 +495,7 @@ var _CPButtonClassName = nil,
_alternateImage = anImage;
}
/*
/*!
Returns the image used when the button is in an alternate state.
*/
- (CPImage)alternateImage
@@ -501,7 +503,7 @@ var _CPButtonClassName = nil,
return _alternateImage;
}
/*
/*!
Sets the button's title.
@param aTitle the new title for the button
*/
@@ -515,7 +517,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:_isHighlighted];
}
/*
/*!
Returns the button's title string
*/
- (CPString)title
@@ -523,7 +525,7 @@ var _CPButtonClassName = nil,
return _title;
}
/*
/*!
Lays out the button.
*/
- (void)tile
@@ -547,7 +549,7 @@ var _CPButtonClassName = nil,
[_imageAndTitleView setFrameSize:size];
}
/*
/*!
Compacts the button's frame to fit its contents.
*/
- (void)sizeToFit
@@ -568,7 +570,7 @@ var _CPButtonClassName = nil,
[self setFrameSize:CGSizeMake(CGRectGetWidth(frame), height)];
}
/*
/*!
Sets the frame size for the button.
@param the new frame size
*/
@@ -579,7 +581,7 @@ var _CPButtonClassName = nil,
[self tile];
}
/*
/*!
Highlights the receiver based on <code>aFlag</code>.
@param If <code>YES</code> the button will highlight, <code>NO</code> the button will unhighlight.
*/
@@ -589,7 +591,7 @@ var _CPButtonClassName = nil,
[self drawContentsWithHighlight:aFlag];
}
/*
/*!
Sets button's tag.
@param aTag the button's new tag
*/
@@ -598,7 +600,7 @@ var _CPButtonClassName = nil,
_tag = aTag;
}
/*
/*!
Returns the button's tag.
*/
- (int)tag
@@ -606,7 +608,7 @@ var _CPButtonClassName = nil,
return _tag;
}
/*
/*!
Called when the user clicks on this button.
@param anEvent the event with information about the click
*/
@@ -617,7 +619,7 @@ var _CPButtonClassName = nil,
[self highlight:_isHighlighted];
}
/*
/*!
Called when the user drags on the button.
@param anEvent the event with information about the drag
*/
@@ -628,7 +630,7 @@ var _CPButtonClassName = nil,
[self highlight:_isHighlighted];
}
/*
/*!
Called when the user releases the mouse button
@param anEvent the event with information about the mouse release
*/
@@ -641,7 +643,7 @@ var _CPButtonClassName = nil,
[super mouseUp:anEvent];
}
/*
/*!
Sets the button's control size.
@param aControlSize the button's new control size
*/
@@ -656,7 +658,7 @@ var _CPButtonClassName = nil,
[self _updateTextAttributes];
}
/*
/*!
Returns the button's control size.
*/
- (CPControlSize)controlSize
@@ -664,7 +666,7 @@ var _CPButtonClassName = nil,
return _controlSize;
}
/*
/*!
Sets whether the button has a bezeled border.
@param If <code>YES</code>, the the button will have a bezeled border.
*/
@@ -681,7 +683,7 @@ var _CPButtonClassName = nil,
[self tile];
}
/*
/*!
Returns <code>YES</code> if the border is bezeled.
*/
- (BOOL)isBordered
@@ -689,7 +691,7 @@ var _CPButtonClassName = nil,
return _isBordered;
}
/*
/*!
Sets the button's bezel style.
@param aBezelStye one of the predefined bezel styles
*/
@@ -723,7 +725,7 @@ var _CPButtonClassName = nil,
[self tile];
}
/*
/*!
Returns the current bezel style
*/
- (int)bezelStyle
@@ -826,9 +828,9 @@ var CPButtonImageKey = @"CPButtonImageKey",
@implementation CPButton (CPCoding)
/*
/*!
Initializes the button by unarchiving data from <code>aCoder</code>.
@param aCoder the coder containing the archived <objj>CPButton</objj>.
@param aCoder the coder containing the archived CPButton.
*/
- (id)initWithCoder:(CPCoder)aCoder
{
@@ -853,7 +855,7 @@ var CPButtonImageKey = @"CPButtonImageKey",
return self;
}
/*
/*!
Archives this button into the provided coder.
@param aCoder the coder to which the button's instance data will be written.
*/
+14 -12
View File
@@ -20,20 +20,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPView.j"
@import "CPView.j"
#include "CoreGraphics/CGGeometry.h"
/*
<objj>CPClipView</objj> allows you to define a clip rect and display only that portion of its containing view.
It is used to hold the document view in a <objj>CPScrollView</objj>.
/*! @class CPClipView
CPClipView allows you to define a clip rect and display only that portion of its containing view.
It is used to hold the document view in a CPScrollView.
*/
@implementation CPClipView : CPView
{
CPView _documentView;
}
/*
/*!
Sets the document view to be <code>aView</code>.
@param aView the new document view. It's frame origin will be changed to <code>(0,0)</code> after calling this method.
*/
@@ -85,7 +87,7 @@ import "CPView.j"
}
}
/*
/*!
Returns the document view.
*/
- (id)documentView
@@ -93,7 +95,7 @@ import "CPView.j"
return _documentView;
}
/*
/*!
Returns a new point that may be adjusted from <code>aPoint</code>
to make sure it lies within the document view.
@param aPoint
@@ -122,7 +124,7 @@ import "CPView.j"
[superview reflectScrolledClipView:self];
}
/*
/*!
Scrolls the clip view to the specified point. The method
sets its bounds origin to <code>aPoint</code>.
*/
@@ -131,8 +133,8 @@ import "CPView.j"
[self setBoundsOrigin:[self constrainScrollPoint:aPoint]];
}
/*
Handles a <objj>CPViewBoundsDidChangeNotification</objj>.
/*!
Handles a CPViewBoundsDidChangeNotification.
@param aNotification the notification event
*/
- (void)viewBoundsChanged:(CPNotification)aNotification
@@ -140,8 +142,8 @@ import "CPView.j"
[self viewFrameChanged:aNotification];
}
/*
Handles a <objj>CPViewFrameDidChangeNotification</objj>.
/*!
Handles a CPViewFrameDidChangeNotification.
@param aNotification the notification event
*/
- (void)viewFrameChanged:(CPNotification)aNotification
+51 -45
View File
@@ -20,16 +20,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
import <Foundation/CPData.j>
import <Foundation/CPIndexSet.j>
import <Foundation/CPKeyedArchiver.j>
import <Foundation/CPKeyedUnarchiver.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPData.j>
@import <Foundation/CPIndexSet.j>
@import <Foundation/CPKeyedArchiver.j>
@import <Foundation/CPKeyedUnarchiver.j>
import <AppKit/CPView.j>
@import <AppKit/CPView.j>
/*
This class presents an array of content as a grid of views.
/*! @class CPCollectionView
This class displays an array as a grid of objects, where each object is represented by a view.
The view is controlled by creating a CPCollectionViewItem and specifying its view, then
setting that item as the collection view prototype.
@par Delegate Methods
@delegate -(void)collectionViewDidChangeSelection:(CPCollectionView)collectionView;
Called when the selection in the collection view has changed.
@@ -51,7 +57,7 @@ import <AppKit/CPView.j>
Invoked to obtain the data types supported by the specified indices for placement on the pasteboard.
@param collectionView the collection view the items reside in
@param indices the indices to obtain drag types
@return an array of drag types (<objj>CPString</objj>)
@return an array of drag types (CPString)
*/
@implementation CPCollectionView : CPView
{
@@ -110,7 +116,7 @@ import <AppKit/CPView.j>
return self;
}
/*
/*!
Sets the item prototype to <code>anItem</code>
@param anItem the new item prototype
*/
@@ -122,7 +128,7 @@ import <AppKit/CPView.j>
[self reloadContent];
}
/*
/*!
Returns the current item prototype
*/
- (CPCollectionViewItem)itemPrototype
@@ -130,7 +136,7 @@ import <AppKit/CPView.j>
return _itemPrototype;
}
/*
/*!
Returns a collection view item for <code>anObject</code>.
@param anObject the object to be represented.
*/
@@ -150,7 +156,7 @@ import <AppKit/CPView.j>
}
// Working with the Responder Chain
/*
/*!
Returns <code>YES</code> by default.
*/
- (BOOL)acceptsFirstResponder
@@ -158,7 +164,7 @@ import <AppKit/CPView.j>
return YES;
}
/*
/*!
Returns whether the receiver is currently the first responder.
*/
- (BOOL)isFirstResponder
@@ -167,7 +173,7 @@ import <AppKit/CPView.j>
}
// Setting the Content
/*
/*!
Sets the content of the collection view to the content in <code>anArray</code>.
This array can be of any type, and each element will be passed to the <code>setRepresentedObject:</code> method.
It's the responsibility of your custom collection view item to interpret the object.
@@ -183,7 +189,7 @@ import <AppKit/CPView.j>
[self reloadContent];
}
/*
/*!
Returns the collection view content array
*/
- (CPArray)content
@@ -191,7 +197,7 @@ import <AppKit/CPView.j>
return _content;
}
/*
/*!
Returns the collection view items.
*/
- (CPArray)items
@@ -200,7 +206,7 @@ import <AppKit/CPView.j>
}
// Setting the Selection Mode
/*
/*!
Sets whether the user is allowed to select items
@param isSelectable <code>YES</code> allows the user to select items.
*/
@@ -220,7 +226,7 @@ import <AppKit/CPView.j>
}
}
/*
/*!
Returns <code>YES</code> if the collection view is
selected, and <code>NO</code> otherwise.
*/
@@ -229,7 +235,7 @@ import <AppKit/CPView.j>
return _isSelected;
}
/*
/*!
Sets whether the user can select multiple items.
@param shouldAllowMultipleSelection <code>YES</code> allows the user to select multiple items
*/
@@ -238,7 +244,7 @@ import <AppKit/CPView.j>
_allowsMultipleSelection = shouldAllowMultipleSelection;
}
/*
/*!
Returns <code>YES</code> if the user can select multiple items, <code>NO</code> otherwise.
*/
- (BOOL)allowsMultipleSelection
@@ -246,7 +252,7 @@ import <AppKit/CPView.j>
return _allowsMultipleSelection;
}
/*
/*!
Sets the selected items based on the provided indices.
@param anIndexSet the set of items to be selected
*/
@@ -271,7 +277,7 @@ import <AppKit/CPView.j>
[_delegate collectionViewDidChangeSelection:self]
}
/*
/*!
Returns a set of the selected indices.
*/
- (CPIndexSet)selectionIndexes
@@ -382,7 +388,7 @@ import <AppKit/CPView.j>
}
// Laying Out the Collection View
/*
/*!
Sets the maximum number of rows.
@param aMaxNumberOfRows the new maximum number of rows
*/
@@ -396,7 +402,7 @@ import <AppKit/CPView.j>
[self tile];
}
/*
/*!
Returns the maximum number of rows.
*/
- (unsigned)maxNumberOfRows
@@ -404,7 +410,7 @@ import <AppKit/CPView.j>
return _maxNumberOfRows;
}
/*
/*!
Sets the maximum number of columns.
@param aMaxNumberOfColumns the new maximum number of columns
*/
@@ -418,7 +424,7 @@ import <AppKit/CPView.j>
[self tile];
}
/*
/*!
Returns the maximum number of columns
*/
- (unsigned)maxNumberOfColumns
@@ -426,7 +432,7 @@ import <AppKit/CPView.j>
return _maxNumberOfColumns;
}
/*
/*!
Sets the minimum size for an item
@param aSize the new minimum item size
*/
@@ -440,7 +446,7 @@ import <AppKit/CPView.j>
[self tile];
}
/*
/*!
Returns the current minimum item size
*/
- (CGSize)minItemSize
@@ -448,7 +454,7 @@ import <AppKit/CPView.j>
return _minItemSize;
}
/*
/*!
Sets the maximum item size.
@param aSize the new maximum item size
*/
@@ -462,7 +468,7 @@ import <AppKit/CPView.j>
[self tile];
}
/*
/*!
Returns the current maximum item size.
*/
- (CGSize)maxItemSize
@@ -519,7 +525,7 @@ import <AppKit/CPView.j>
slideBack:YES];
}
/*
/*!
Places the selected items on the specified pasteboard. The items are requested from the collection's delegate.
@param aPasteboard the pasteboard to put the items on
@param aType the format the pasteboard data
@@ -541,7 +547,7 @@ import <AppKit/CPView.j>
[self tile];
}
/*
/*!
Sets the collection view's delegate
@param aDelegate the new delegate
*/
@@ -550,7 +556,7 @@ import <AppKit/CPView.j>
_delegate = aDelegate;
}
/*
/*!
Returns the collection view's delegate
*/
- (id)delegate
@@ -560,8 +566,8 @@ import <AppKit/CPView.j>
@end
/*
Represents an object inside a <objj>CPCollectionView</objj>.
/*!
Represents an object inside a CPCollectionView.
*/
@implementation CPCollectionViewItem : CPObject
{
@@ -573,7 +579,7 @@ import <AppKit/CPView.j>
}
// Setting the Represented Object
/*
/*!
Sets the object to be represented by this item.
@param anObject the object to be represented
*/
@@ -588,7 +594,7 @@ import <AppKit/CPView.j>
[_view setRepresentedObject:anObject];
}
/*
/*!
Returns the object represented by this view item
*/
- (id)representedObject
@@ -597,7 +603,7 @@ import <AppKit/CPView.j>
}
// Modifying the View
/*
/*!
Sets the view that is used represent this object.
@param aView the view used to represent this object
*/
@@ -606,7 +612,7 @@ import <AppKit/CPView.j>
_view = aView;
}
/*
/*!
Returns the view that represents this object.
*/
- (CPView)view
@@ -615,7 +621,7 @@ import <AppKit/CPView.j>
}
// Modifying the Selection
/*
/*!
Sets whether this view item should be selected.
@param shouldBeSelected <code>YES</code> makes the item selected. <code>NO</code> deselects it.
*/
@@ -630,7 +636,7 @@ import <AppKit/CPView.j>
[_view setSelected:_isSelected];
}
/*
/*!
Returns <code>YES</code> if the item is currently selected. <code>NO</code> if the item is not selected.
*/
- (BOOL)isSelected
@@ -639,7 +645,7 @@ import <AppKit/CPView.j>
}
// Parent Collection View
/*
/*!
Returns the collection view of which this item is a part.
*/
- (CPCollectionView)collectionView
@@ -667,7 +673,7 @@ var CPCollectionViewItemViewKey = @"CPCollectionViewItemViewKey";
@implementation CPCollectionViewItem (CPCoding)
/*
/*!
Initializes the view item by unarchiving data from a coder.
@param aCoder the coder from which the data will be unarchived
@return the initialized collection view item
@@ -682,7 +688,7 @@ var CPCollectionViewItemViewKey = @"CPCollectionViewItemViewKey";
return self;
}
/*
/*!
Archives the colletion view item to the provided coder.
@param aCoder the coder to which the view item should be archived
*/
+39 -37
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
import "CGColor.j"
@import "CGColor.j"
@import "CPCompatibility.j"
@import "CPImage.j"
import "CPCompatibility.j"
import "CPImage.j"
var _redComponent = 0,
_greenComponent = 1,
@@ -36,7 +37,8 @@ var _hueComponent = 0,
_saturationComponent = 1,
_brightnessComponent = 2;
/*
/*! @code CPColor
<code>CPColor</code> can be used to represent color
in an RGB or HSB model with an optional transparency value.</p>
@@ -46,7 +48,7 @@ var _hueComponent = 0,
<p>The class does not have a <code>set:</code> method
like NextStep based frameworks to change the color of
the current context. To change the color of the current
context, use <objj>CGContextSetFillColor()</objj>.
context, use CGContextSetFillColor().
*/
@implementation CPColor : CPObject
{
@@ -56,7 +58,7 @@ var _hueComponent = 0,
CPString _cssString;
}
/*
/*!
Creates a color in the RGB color space, with an alpha value.
Each component should be between the range of 0.0 to 1.0. For
the alpha component, a value of 1.0 is opaque, and 0.0 means
@@ -74,7 +76,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[red, green, blue, alpha]];
}
/*
/*!
Creates a new color object with <code>white</code> for the RGB components.
For the alpha component, a value of 1.0 is opaque, and 0.0 means completely transparent.
@@ -88,7 +90,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[white, white, white, alpha]];
}
/*
/*!
Creates a new color in HSB space.
@param hue the hue value
@@ -119,7 +121,7 @@ var _hueComponent = 0,
}
}
/*
/*!
Creates an RGB color from a hexadecimal string. For example,
the a string of "FFFFFF" would return a white CPColor.
"FF0000" would return a pure red, "00FF00" would return a
@@ -134,7 +136,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA: hexToRGB(hex)];
}
/*
/*!
Returns a black color object. (RGBA=[0.0, 0.0, 0.0, 1.0])
*/
+ (CPColor)blackColor
@@ -142,7 +144,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 0.0, 1.0]];
}
/*
/*!
Returns a blue color object. (RGBA=[0.0, 0.0, 1.0, 1.0])
*/
+ (CPColor)blueColor
@@ -150,7 +152,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 1.0, 1.0]];
}
/*
/*!
Returns a dark gray color object. (RGBA=[0.33 ,0.33, 0.33, 1.0])
*/
+ (CPColor)darkGrayColor
@@ -158,7 +160,7 @@ var _hueComponent = 0,
return [CPColor colorWithCalibratedWhite:1.0 / 3.0 alpha:1.0];
}
/*
/*!
Returns a gray color object. (RGBA=[0.5, 0.5, 0.5, 1.0])
*/
+ (CPColor)grayColor
@@ -166,7 +168,7 @@ var _hueComponent = 0,
return [CPColor colorWithCalibratedWhite:0.5 alpha: 1.0];
}
/*
/*!
Returns a green color object. (RGBA=[0.0, 1.0, 0.0, 1.0])
*/
+ (CPColor)greenColor
@@ -174,7 +176,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[0.0, 1.0, 0.0, 1.0]];
}
/*
/*!
Returns a light gray color object (RGBA=[0.66, 0.66, 0.66, 1.0])
*/
+ (CPColor)lightGrayColor
@@ -182,7 +184,7 @@ var _hueComponent = 0,
return [CPColor colorWithCalibratedWhite:2.0 / 3.0 alpha:1.0];
}
/*
/*!
Returns a red color object (RGBA=[1.0, 0.0, 0.0, 1.0])
*/
+ (CPColor)redColor
@@ -190,7 +192,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[1.0, 0.0, 0.0, 1.0]];
}
/*
/*!
Returns a white color object (RGBA=[1.0, 1.0, 1.0, 1.0])
*/
+ (CPColor)whiteColor
@@ -198,7 +200,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[1.0, 1.0, 1.0, 1.0]];
}
/*
/*!
Returns a yellow color object (RGBA=[1.0, 1.0, 0.0, 1.0])
*/
+ (CPColor)yellowColor
@@ -206,7 +208,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[1.0, 1.0, 0.0, 1.0]];
}
/*
/*!
Returns a shadow looking color (RGBA=[0.0, 0.0, 0.0, 0.33])
*/
+ (CPColor)shadowColor
@@ -214,7 +216,7 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithRGBA:[0.0, 0.0, 0.0, 1.0 / 3.0]];
}
/*
/*!
Creates a color using a tile pattern with <code>anImage</code>
@param the image to tile
@return a tiled image color object
@@ -224,8 +226,8 @@ var _hueComponent = 0,
return [[CPColor alloc] _initWithPatternImage:anImage];
}
/*
Creates a <objj>CPColor</objj> from a valid CSS RGB string. Example, "rgb(32,64,129)".
/*!
Creates a CPColor from a valid CSS RGB string. Example, "rgb(32,64,129)".
@param aString a CSS color string
@return a color initialized to the value in the css string
@@ -328,7 +330,7 @@ var _hueComponent = 0,
return self;
}
/*
/*!
Returns the image being used as the pattern for the tile in this color.
*/
- (CPImage)patternImage
@@ -336,7 +338,7 @@ var _hueComponent = 0,
return _patternImage;
}
/*
/*!
Returns the alpha component of this color.
*/
- (float)alphaComponent
@@ -344,7 +346,7 @@ var _hueComponent = 0,
return _components[3];
}
/*
/*!
Returns the blue component of this color.
*/
- (float)blueComponent
@@ -352,7 +354,7 @@ var _hueComponent = 0,
return _components[2];
}
/*
/*!
Returns the green component of this color.
*/
- (float)greenComponent
@@ -360,7 +362,7 @@ var _hueComponent = 0,
return _components[1];
}
/*
/*!
Return the red component of this color.
*/
- (float)redComponent
@@ -368,7 +370,7 @@ var _hueComponent = 0,
return _components[0];
}
/*
/*!
Returns the RGBA components of this color in an array.
The index values are ordered as:
<pre>
@@ -384,7 +386,7 @@ var _hueComponent = 0,
return _components;
}
/*
/*!
Returns a new color with the same RGB as the receiver but a new alpha component.
@param anAlphaComponent the alpha component for the new color
@@ -400,7 +402,7 @@ var _hueComponent = 0,
return [[[self class] alloc] _initWithRGBA:components];
}
/*
/*!
Returns an array with the HSB values for this color.
The index values are ordered as:
<pre>
@@ -451,7 +453,7 @@ var _hueComponent = 0,
];
}
/*
/*!
Returns the CSS representation of this color. The color will
be in one of the following forms:
<pre>
@@ -465,7 +467,7 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
return _cssString;
}
/*
/*!
Returns a 6 character long hex string of this color.
*/
- (CPString)hexString
@@ -480,7 +482,7 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
@implementation CPColor (CPCoding)
/*
/*!
Initializes this color from the data archived in a coder.
@param aCoder the coder from which the color will be loaded
*/
@@ -492,7 +494,7 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
return [self _initWithRGBA:[aCoder decodeObjectForKey:CPColorComponentsKey]];
}
/*
/*!
Archives this color into a coder.
@param aCoder the coder into which the color will be archived.
*/
@@ -508,8 +510,8 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
var hexCharacters = "0123456789ABCDEF";
/*
Used for the <objj>CPColor</objj> <code>colorWithHexString:</code> implementation
/*!
Used for the CPColor <code>colorWithHexString:</code> implementation
@ignore
@class CPColor
@return an array of rgb components
+123 -183
View File
@@ -20,47 +20,41 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPButton.j"
import "CPColorPicker.j"
import "CPCookie.j"
import "CPKulerColorPicker.j"
import "CPPanel.j"
import "CPSliderColorPicker.j"
import "CPView.j"
@import "CPButton.j"
@import "CPCookie.j"
@import "CPPanel.j"
@import "CPView.j"
CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";
var PREVIEW_HEIGHT = 20.0,
TOOLBAR_HEIGHT = 32.0,
SWATCH_HEIGHT = 14.0;
var SharedColorPanel = nil;
SWATCH_HEIGHT = 14.0,
ICON_WIDTH = 32.0,
ICON_PADDING = 12.0;
var SharedColorPanel = nil,
ColorPickerClasses = [];
/*
A color wheel
@global
@group CPColorPanelMode
*/
CPWheelColorPickerMode = 1;
/*
Kuler color picker
@global
@group CPColorPanelMode
*/
CPKulerColorPickerMode = 2;
/*
Slider based picker
@global
@group CPColorPanelMode
*/
CPSliderColorPickerMode = 3;
CPSliderColorPickerMode = 2;
CPColorPickerViewWidth = 265,
CPColorPickerViewHeight = 370;
/*
<objj>CPColorPanel</objj> provides a reusable panel that can be used
/*! @class CPColorPanel
CPColorPanel provides a reusable panel that can be used
displayed on screen to prompt the user for a color selection. To
obtain the panel, call the <code>sharedColorPanel</code> method.
*/
@@ -73,12 +67,8 @@ CPColorPickerViewHeight = 370;
CPTextField _previewLabel;
CPTextField _swatchLabel;
CPView _activeView;
CPColorPicker _activePicker;
CPColorPicker _wheelPicker;
CPColorPicker _kulerPicker;
CPColorPicker _sliderPicker;
CPArray _colorPickers;
CPView _currentView;
CPColor _color;
@@ -88,7 +78,16 @@ CPColorPickerViewHeight = 370;
int _mode;
}
/*
/*!
A list of color pickers is collected here, and any color panel created will contain
any picker in this list up to this point. In other words, call before creating a color panel.
*/
+ (void)provideColorPickerClass:(Class)aColorPickerSubclass
{
ColorPickerClasses.push(aColorPickerSubclass);
}
/*!
Returns (and if necessary, creates) the shared color panel.
*/
+ (CPColorPanel)sharedColorPanel
@@ -99,7 +98,7 @@ CPColorPickerViewHeight = 370;
return SharedColorPanel;
}
/*
/*!
Sets the mode for the shared color panel.
@param mode the mode to which the color panel will be set
*/
@@ -133,7 +132,7 @@ CPColorPickerViewHeight = 370;
return self;
}
/*
/*!
Sets the color of the panel, and updates the picker. Also posts a <code>CPColorPanelDidChangeNotification</code>.
*/
- (void)setColor:(CPColor)aColor
@@ -144,28 +143,27 @@ CPColorPickerViewHeight = 370;
[CPApp sendAction:@selector(changeColor:) to:nil from:self];
if (_target && _action)
objj_msgSend(_target, _action, self);
[CPApp sendAction:_action to:_target from:self];
[[CPNotificationCenter defaultCenter]
postNotificationName:CPColorPanelColorDidChangeNotification
object:self];
}
/*
/*!
Sets the selected color of the panel and optionally updates the picker.
@param bool whether or not to update the picker
@ignore
*/
-(void)setColor:(CPColor)aColor updatePicker:(BOOL)bool
{
[self setColor: aColor];
- (void)setColor:(CPColor)aColor updatePicker:(BOOL)bool
{
[self setColor:aColor];
if (bool)
[_activePicker setColor:_color];
}
if(bool)
[_activePicker setColor: _color];
}
/*
/*!
Returns the panel's currently selected color.
*/
- (CPColor)color
@@ -173,7 +171,7 @@ CPColorPickerViewHeight = 370;
return _color;
}
/*
/*!
Sets the target for the color panel. Messages are sent
to the target when colors are selected in the panel.
*/
@@ -182,7 +180,7 @@ CPColorPickerViewHeight = 370;
_target = aTarget;
}
/*
/*!
Returns the current target. The target receives messages
when colors are selected in the panel.
*/
@@ -191,7 +189,7 @@ CPColorPickerViewHeight = 370;
return _target;
}
/*
/*!
Sets the action that gets sent to the target.
This action is sent whenever a color is selected in the panel.
@param anAction the action that will be sent
@@ -201,7 +199,7 @@ CPColorPickerViewHeight = 370;
_action = anAction;
}
/*
/*!
Returns the current target action.
*/
- (selector)action
@@ -209,36 +207,47 @@ CPColorPickerViewHeight = 370;
return _action;
}
/*
/*!
Sets the mode (look) of the color panel.
@param mode the mode in which to display the color panel
*/
- (void)setMode:(CPColorPanelMode)mode
{
if(mode == _mode)
return;
var frame = CPRectCreateCopy([_currentView frame]);
[_currentView removeFromSuperview];
switch(mode)
{
case CPWheelColorPickerMode: _activePicker = _wheelPicker; break;
case CPKulerColorPickerMode: _activePicker = _kulerPicker; break;
case CPSliderColorPickerMode: _activePicker = _sliderPicker; break;
}
_currentView = [_activePicker provideNewView: NO];
[_activePicker setColor: _color];
_mode = mode;
[_currentView setFrame: frame];
[_currentView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)];
[[self contentView] addSubview: _currentView];
}
/*
- (void)_setPicker:(id)sender
{
var picker = _colorPickers[[sender tag]],
view = [picker provideNewView:NO];
if (!view)
view = [picker provideNewView:YES];
if (view == _currentView)
return;
if (_currentView)
[view setFrame:[_currentView frame]];
else
{
var height = (TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10),
bounds = [[self contentView] bounds];
[view setFrameSize: CPSizeMake(bounds.size.width - 10, bounds.size.height - height)];
[view setFrameOrigin: CPPointMake(5, height)];
}
[_currentView removeFromSuperview];
[[self contentView] addSubview:view];
_currentView = view;
_activePicker = picker;
[picker setColor:[self color]];
}
/*!
Returns the color panel's current display mode.
*/
- (CPColorPanelMode)mode
@@ -249,7 +258,6 @@ CPColorPickerViewHeight = 370;
- (void)orderFront:(id)aSender
{
[self _loadContentsIfNecessary];
[super orderFront:aSender];
}
@@ -258,13 +266,49 @@ CPColorPickerViewHeight = 370;
{
if (_toolbar)
return;
_colorPickers = [];
var count = [ColorPickerClasses count];
for (var i=0; i<count; i++)
{
var currentPickerClass = ColorPickerClasses[i],
currentPicker = [[currentPickerClass alloc] initWithPickerMask:0 colorPanel:self];
_colorPickers.push(currentPicker);
}
var contentView = [self contentView],
bounds = [contentView bounds];
_toolbar = [[_CPColorPanelToolbar alloc] initWithFrame: CPRectMake(0, 0, CGRectGetWidth(bounds), TOOLBAR_HEIGHT)];
_toolbar = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bounds), TOOLBAR_HEIGHT)];
[_toolbar setAutoresizingMask: CPViewWidthSizable];
var totalToolbarWidth = count * ICON_WIDTH + (count - 1) * ICON_PADDING,
leftOffset = (CGRectGetWidth(bounds) - totalToolbarWidth) / 2.0,
buttonForLater = nil;
for (var i=0; i<count; i++)
{
var image = [_colorPickers[i] provideNewButtonImage],
highlightImage = [_colorPickers[i] provideNewAlternateButtonImage],
button = [[CPButton alloc] initWithFrame:CGRectMake(leftOffset + i*(ICON_WIDTH+ICON_PADDING), 0, ICON_WIDTH, ICON_WIDTH)];
[button setTag:i];
[button setTarget:self];
[button setAction:@selector(_setPicker:)];
[button setBordered:NO];
[button setAutoresizingMask:CPViewMinXMargin|CPViewMaxXMargin];
[button setImage:image];
[button setAlternateImage:highlightImage];
[_toolbar addSubview:button];
if (!buttonForLater)
buttonForLater = button;
}
// FIXME: http://280north.lighthouseapp.com/projects/13294-cappuccino/tickets/25-implement-cpbox
var previewBox = [[CPView alloc] initWithFrame:CGRectMake(76, TOOLBAR_HEIGHT + 10, CGRectGetWidth(bounds) - 86, PREVIEW_HEIGHT)];
@@ -301,135 +345,25 @@ CPColorPickerViewHeight = 370;
[_swatchLabel setTextColor:[CPColor whiteColor]];
[_swatchLabel setAlignment:CPRightTextAlignment];
_wheelPicker = [[CPColorWheelColorPicker alloc] initWithPickerMask: 1|2|3 colorPanel: self];
_currentView = [_wheelPicker provideNewView: YES];
var height = (TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10);
[_currentView setFrameSize: CPSizeMake(bounds.size.width - 10, bounds.size.height - height)];
[_currentView setFrameOrigin: CPPointMake(5, TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10)];
[_currentView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)];
_kulerPicker = [[CPKulerColorPicker alloc] initWithPickerMask: 1|2|3 colorPanel: self];
[_kulerPicker provideNewView: YES];
_sliderPicker = [[CPSliderColorPicker alloc] initWithPickerMask: 1|2|3 colorPanel: self];
[_sliderPicker provideNewView: YES];
[contentView addSubview: _toolbar];
[contentView addSubview: previewBox];
[contentView addSubview: _previewLabel];
[contentView addSubview: swatchBox];
[contentView addSubview: _swatchLabel];
[contentView addSubview: _currentView];
_target = nil;
_action = nil;
_activePicker = _wheelPicker;
_activePicker = nil;
[self setColor:[CPColor whiteColor]];
[_activePicker setColor:[CPColor whiteColor]];
if (buttonForLater)
[self _setPicker:buttonForLater];
}
@end
var iconSize = 32,
totalIcons = 3;
/* @ignore */
@implementation _CPColorPanelToolbar : CPView
{
CPImage _wheelImage;
CPImage _wheelAlternateImage;
CPButton _wheelButton;
CPImage _sliderImage;
CPImage _sliderAlternateImage;
CPButton _sliderButton;
CPImage _kulerImage;
CPImage _kulerAlternateImage;
CPButton _kulerButton;
}
- (id)initWithFrame:(CPRect)aFrame
{
self = [super initWithFrame:aFrame];
var width = aFrame.size.width;
var center = width / 2.0;
var start = center - ((totalIcons * iconSize) + (totalIcons - 1) * 8.0) / 2.0;
_wheelButton = [[CPButton alloc] initWithFrame:CPRectMake(start, 0, iconSize, iconSize)];
start += iconSize + 8;
var path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"wheel_button.png"];
_wheelImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"wheel_button_h.png"];
_wheelAlternateImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
[_wheelButton setBordered:NO];
[_wheelButton setImage: _wheelImage];
[_wheelButton setAlternateImage: _wheelAlternateImage];
[_wheelButton setTarget: self];
[_wheelButton setAction: @selector(setMode:)];
[_wheelButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
[self addSubview: _wheelButton];
_sliderButton = [[CPButton alloc] initWithFrame:CPRectMake(start, 0, iconSize, iconSize)];
start += iconSize + 8;
path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"slider_button.png"];
_sliderImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"slider_button_h.png"];
_sliderAlternateImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
[_sliderButton setBordered:NO];
[_sliderButton setImage: _sliderImage];
[_sliderButton setAlternateImage: _sliderAlternateImage];
[_sliderButton setTarget: self];
[_sliderButton setAction: @selector(setMode:)];
[_sliderButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
[self addSubview: _sliderButton];
_kulerButton = [[CPButton alloc] initWithFrame:CPRectMake(start, 0, iconSize, iconSize)];
start += iconSize + 8;
path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"kuler_button.png"];
_kulerImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"kuler_button_h.png"];
_kulerAlternateImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)];
[_kulerButton setBordered:NO];
[_kulerButton setImage: _kulerImage];
[_kulerButton setAlternateImage: _kulerAlternateImage];
[_kulerButton setTarget: self];
[_kulerButton setAction: @selector(setMode:)];
[_kulerButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
[self addSubview: _kulerButton];
return self;
}
- (void)setMode:(id)sender
{
if(sender == _kulerButton)
[[CPColorPanel sharedColorPanel] setMode: CPKulerColorPickerMode];
else if(sender == _wheelButton)
[[CPColorPanel sharedColorPanel] setMode: CPWheelColorPickerMode];
else
[[CPColorPanel sharedColorPanel] setMode: CPSliderColorPickerMode];
}
@end
CPColorDragType = "CPColorDragType";
var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
@@ -682,3 +616,9 @@ var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";
}
@end
@import "CPColorPicker.j"
@import "CPSliderColorPicker.j"
[CPColorPanel provideColorPickerClass:CPColorWheelColorPicker];
[CPColorPanel provideColorPickerClass:CPSliderColorPicker];
+31 -19
View File
@@ -20,13 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/Foundation.j>
import <AppKit/CPView.j>
import <AppKit/CPImage.j>
import <AppKit/CPImageView.j>
@import <Foundation/CPObject.j>
@import "CPColorPanel.j"
/*
<objj>CPColorPicker</objj> is an abstract superclass for all color picker subclasses. If you want a particular color picker, use <objj>CPColorPanel</objj>'s <code>setPickerMode:</code> method. The simplest way to implement your own color picker is to create a subclass of CPColorPicker.
/*! @class CPColorPicker
CPColorPicker is an abstract superclass for all color picker subclasses. If you want a particular color picker, use CPColorPanel's <code>setPickerMode:</code> method. The simplest way to implement your own color picker is to create a subclass of CPColorPicker.
*/
@implementation CPColorPicker : CPObject
{
@@ -34,7 +33,7 @@ import <AppKit/CPImageView.j>
int _mask;
}
/*
/*!
Initializes the color picker.
@param aMask a unique unsigned int identifying your color picker
@param aPanel the color panel that owns this picker
@@ -49,7 +48,7 @@ import <AppKit/CPImageView.j>
return self;
}
/*
/*!
Returns the color panel that owns this picker
*/
- (CPColorPanel)colorPanel
@@ -67,7 +66,7 @@ import <AppKit/CPImageView.j>
return nil;
}
/*
/*!
Sets the color picker's mode.
@param mode the color panel mode
*/
@@ -76,7 +75,7 @@ import <AppKit/CPImageView.j>
return;
}
/*
/*!
Sets the picker's color.
@param aColor the new color for the picker
*/
@@ -107,7 +106,9 @@ import <AppKit/CPImageView.j>
-(id)initView
{
aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
_pickerView = [[CPView alloc] initWithFrame:aFrame];
[_pickerView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
var path = [[CPBundle bundleForClass: CPColorPicker] pathForResource:@"brightness_bar.png"];
@@ -124,9 +125,9 @@ import <AppKit/CPImageView.j>
brightnessBarView._DOMElement.appendChild(_brightnessBarImage);
_brightnessSlider = [[CPSlider alloc] initWithFrame: CPRectMake(0, aFrame.size.height - 22, aFrame.size.width, 12)];
[_brightnessSlider setMaxValue: 100.0];
[_brightnessSlider setMinValue: 0.0];
[_brightnessSlider setValue: 100.0];
[_brightnessSlider setMaxValue: 100.0];
[_brightnessSlider setMinValue: 0.0];
[_brightnessSlider setFloatValue:100.0];
[_brightnessSlider setTarget: self];
[_brightnessSlider setAction: @selector(brightnessSliderDidChange:)];
@@ -155,7 +156,7 @@ import <AppKit/CPImageView.j>
{
var hue = [_hueSaturationView angle],
saturation = [_hueSaturationView distance],
brightness = [_brightnessSlider value];
brightness = [_brightnessSlider floatValue];
[_hueSaturationView setWheelBrightness: brightness / 100.0];
_brightnessBarImage.style.backgroundColor = "#"+[[CPColor colorWithHue: hue saturation: saturation brightness: 100] hexString];
@@ -185,11 +186,21 @@ import <AppKit/CPImageView.j>
{
var hsb = [newColor hsbComponents];
[_hueSaturationView setPositionToColor: newColor];
[_brightnessSlider setValue: hsb[2]];
[_hueSaturationView setWheelBrightness: hsb[2] / 100.0];
[_hueSaturationView setPositionToColor:newColor];
[_brightnessSlider setFloatValue:hsb[2]];
[_hueSaturationView setWheelBrightness:hsb[2] / 100.0];
_brightnessBarImage.style.backgroundColor = "#"+[[CPColor colorWithHue: hsb[0] saturation: hsb[1] brightness: 100] hexString];
_brightnessBarImage.style.backgroundColor = "#"+[[CPColor colorWithHue:hsb[0] saturation:hsb[1] brightness:100] hexString];
}
- (CPImage)provideNewButtonImage
{
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:CPColorPicker] pathForResource:"wheel_button.png"] size:CGSizeMake(32, 32)];
}
- (CPImage)provideNewAlternateButtonImage
{
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:CPColorPicker] pathForResource:"wheel_button_h.png"] size:CGSizeMake(32, 32)];
}
@end
@@ -360,5 +371,6 @@ import <AppKit/CPImageView.j>
{
return -(((degrees - 360) / 180) * PI);
}
@end
@end
+109 -29
View File
@@ -20,23 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPString.j>
@import <Foundation/CPString.j>
import "CPView.j"
import "CPColor.j"
import "CPColorPanel.j"
@import "CPView.j"
@import "CPColor.j"
@import "CPColorPanel.j"
var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiveNotification";
/*
<objj>CPColorWell</objj> is a <objj>CPControl</objj> for selecting and displaying a single color value. An example of a <objj>CPColorWell</objj> object (or simply color well) is found in <objj>CPColorPanel</objj>, which uses a color well to display the current color selection.</p>
/*! @class CPColorWell
<p>An application can have one or more active <objj>CPColorWell</objj>s. You can activate multiple <objj>CPColorWell</objj>s by invoking the <code>activate:</code> method with <code>NO</code> as its argument. When a mouse-down event occurs on an <objj>CPColorWell</objj>'s border, it becomes the only active color well. When a color well becomes active, it brings up the color panel also.
CPColorWell is a CPControl for selecting and displaying a single color value. An example of a CPColorWell object (or simply color well) is found in CPColorPanel, which uses a color well to display the current color selection.</p>
<p>An application can have one or more active CPColorWells. You can activate multiple CPColorWells by invoking the <code>activate:</code> method with <code>NO</code> as its argument. When a mouse-down event occurs on an CPColorWell's border, it becomes the only active color well. When a color well becomes active, it brings up the color panel also.
*/
@implementation CPColorWell : CPControl
{
BOOL _active;
BOOL _bordered;
CPColor _color;
CPView _wellView;
@@ -49,33 +51,59 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
if (self)
{
_active = NO;
_bordered = YES;
_color = [CPColor whiteColor];
[self drawBezelWithHighlight:NO];
[self drawWellInside:CGRectInset([self bounds], 3.0, 3.0)];
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
addObserver:self
selector:@selector(colorWellDidBecomeExclusive:)
name:_CPColorWellDidBecomeExclusiveNotification
object:nil];
[defaultCenter
addObserver:self
selector:@selector(colorPanelWillClose:)
name:CPWindowWillCloseNotification
object:[CPColorPanel sharedColorPanel]];
[self _registerForNotifications];
}
return self;
}
- (void)_registerForNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
addObserver:self
selector:@selector(colorWellDidBecomeExclusive:)
name:_CPColorWellDidBecomeExclusiveNotification
object:nil];
[defaultCenter
addObserver:self
selector:@selector(colorPanelWillClose:)
name:CPWindowWillCloseNotification
object:[CPColorPanel sharedColorPanel]];
}
/*!
Returns whether the color well is bordered
*/
- (BOOL)isBordered
{
return _bordered;
}
/*!
Sets the color well's current color.
*/
- (void)setBordered:(BOOL)bordered
{
if (_bordered == bordered)
return;
_bordered = bordered;
[self drawWellInside:CGRectInset([self bounds], 3.0, 3.0)];
}
// Managing Color From Color Wells
/*
/*!
Returns the color well's current color.
*/
- (CPColor)color
@@ -83,7 +111,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
return _color;
}
/*
/*!
Sets the color well's current color.
*/
- (void)setColor:(CPColor)aColor
@@ -96,7 +124,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
[self drawWellInside:CGRectInset([self bounds], 3.0, 3.0)];
}
/*
/*!
Changes the color of the well to that of <code>aSender</code>.
@param aSender the object from which to retrieve the color
*/
@@ -106,9 +134,9 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
}
// Activating and Deactivating Color Wells
/*
/*!
Activates the color well, displays the color panel, and makes the panel's current color the same as its own.
If exclusive is <code>YES</code>, deactivates any other <objj>CPColorWell</objj>s. <code>NO</code>, keeps them active.
If exclusive is <code>YES</code>, deactivates any other CPColorWells. <code>NO</code>, keeps them active.
@param shouldBeExclusive whether other color wells should be deactivated.
*/
- (void)activate:(BOOL)shouldBeExclusive
@@ -132,7 +160,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
/*
/*!
Deactivates the color well.
*/
- (void)deactivate
@@ -148,7 +176,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
/*
/*!
Returns <code>YES</code> if the color well is active.
*/
- (BOOL)isActive
@@ -162,7 +190,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
{
}
/*
/*!
Draws the colored area inside the color well without borders.
@param aRect the location at which to draw
*/
@@ -171,6 +199,7 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
if (!_wellView)
{
_wellView = [[CPView alloc] initWithFrame:aRect];
[_wellView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[self addSubview:_wellView];
}
@@ -225,3 +254,54 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
}
@end
var CPColorWellColorKey = "CPColorWellColorKey",
CPColorWellBorderedKey = "CPColorWellBorderedKey";
@implementation CPColorWell (CPCoding)
/*!
Initializes the color well by unarchiving data from <code>aCoder</code>.
@param aCoder the coder containing the archived CPColorWell.
*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
_active = NO;
_bordered = [aCoder decodeObjectForKey:CPColorWellBorderedKey];
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
[self drawBezelWithHighlight:NO];
[self drawWellInside:CGRectInset([self bounds], 3.0, 3.0)];
[self _registerForNotifications];
}
return self;
}
/*!
Archives this button into the provided coder.
@param aCoder the coder to which the color well's instance data will be written.
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
// We do this in order to avoid encoding the _wellView, which
// should just automatically be created programmatically as needed.
var actualSubviews = _subviews;
_subviews = [_subviews copy];
[_subviews removeObjectIdenticalTo:_wellView];
[super encodeWithCoder:aCoder];
_subviews = actualSubviews;
[aCoder encodeObject:_color forKey:CPColorWellColorKey];
[aCoder encodeObject:_bordered forKey:CPColorWellBorderedKey];
}
@end
+18 -4
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPEvent.j"
@import "CPEvent.j"
// Browser Engines
CPUnknownBrowserEngine = 0;
@@ -41,6 +41,7 @@ CPJavascriptTextContentFeature = 1 << 9;
CPJavascriptClipboardEventsFeature = 1 << 10;
CPJavascriptClipboardAccessFeature = 1 << 11;
CPJavaScriptCanvasDrawFeature = 1 << 12;
CPJavaScriptCanvasTransformFeature = 1 << 13;
CPVMLFeature = 1 << 14;
@@ -49,6 +50,8 @@ CPJavaScriptShadowFeature = 1 << 20;
CPJavaScriptNegativeMouseWheelValues = 1 << 22;
CPOpacityRequiresFilterFeature = 1 << 23;
var USER_AGENT = "";
PLATFORM_ENGINE = CPUnknownBrowserEngine,
@@ -74,6 +77,8 @@ else if (window.attachEvent) // Must follow Opera check.
PLATFORM_FEATURES |= CPVMLFeature;
PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature;
}
// WebKit
@@ -97,13 +102,13 @@ else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
}
// KHTML
else if (USER_AGENT.indexOf('KHTML') != -1) // Must follow WebKit check.
else if (USER_AGENT.indexOf("KHTML") != -1) // Must follow WebKit check.
{
PLATFORM_ENGINE = CPKHTMLBrowserEngine;
}
// Gecko
else if (USER_AGENT.indexOf('Gecko') != -1) // Must follow KHTML check.
else if (USER_AGENT.indexOf("Gecko") != -1) // Must follow KHTML check.
{
PLATFORM_ENGINE = CPGeckoBrowserEngine;
@@ -119,10 +124,19 @@ else if (USER_AGENT.indexOf('Gecko') != -1) // Must follow KHTML check.
// Feature Specific Checks
if (typeof document != "undefined")
{
var canvasElement = document.createElement("canvas");
// Detect Canvas Support
if (document.createElement("canvas").getContext)
if (canvasElement && canvasElement.getContext)
{
PLATFORM_FEATURES |= CPHTMLCanvasFeature;
// Detect Canvas setTransform/transform support
var context = document.createElement("canvas").getContext("2d");
if (context && context.setTransform && context.transform)
PLATFORM_FEATURES |= CPJavaScriptCanvasTransformFeature;
}
var DOMElement = document.createElement("div");
// Detect whether we have innerText or textContent (or neither)
+204 -77
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPFont.j"
import "CPShadow.j"
import "CPView.j"
@import "CPFont.j"
@import "CPShadow.j"
@import "CPView.j"
#include "Platform/Platform.h"
/*
@global
@group CPTextAlignment
@@ -68,15 +69,20 @@ CPSmallControlSize = 1;
*/
CPMiniControlSize = 2;
CPControlNormalBackgroundColor = @"CPControlNormalBackgroundColor";
CPControlSelectedBackgroundColor = @"CPControlSelectedBackgroundColor";
CPControlHighlightedBackgroundColor = @"CPControlHighlightedBackgroundColor";
CPControlDisabledBackgroundColor = @"CPControlDisabledBackgroundColor";
CPControlNormalBackgroundColor = "CPControlNormalBackgroundColor";
CPControlSelectedBackgroundColor = "CPControlSelectedBackgroundColor";
CPControlHighlightedBackgroundColor = "CPControlHighlightedBackgroundColor";
CPControlDisabledBackgroundColor = "CPControlDisabledBackgroundColor";
CPControlTextDidBeginEditingNotification = "CPControlTextDidBeginEditingNotification";
CPControlTextDidChangeNotification = "CPControlTextDidChangeNotification";
CPControlTextDidEndEditingNotification = "CPControlTextDidEndEditingNotification";
var CPControlBlackColor = [CPColor blackColor];
/*
<objj>CPControl</objj> is an abstract superclass used to implement user interface elements. As a subclass of <objj>CPView</objj> and <objj>CPResponder</objj> it has the ability to handle screen drawing and handling user input.
/*! @class CPControl
CPControl is an abstract superclass used to implement user interface elements. As a subclass of CPView and CPResponder it has the ability to handle screen drawing and handling user input.
*/
@implementation CPControl : CPView
{
@@ -93,9 +99,6 @@ var CPControlBlackColor = [CPColor blackColor];
SEL _action;
int _sendActionOn;
CPColor _backgroundColor;
CPColor _highlightedBackgroundColor;
CPDictionary _backgroundColors;
CPString _currentBackgroundColorName;
}
@@ -118,7 +121,7 @@ var CPControlBlackColor = [CPColor blackColor];
return self;
}
/*
/*!
Sets whether the receiver responds to mouse events.
@param isEnabled whether the receiver will respond to mouse events
*/
@@ -127,7 +130,7 @@ var CPControlBlackColor = [CPColor blackColor];
[self setAlphaValue:(_isEnabled = isEnabled) ? 1.0 : 0.3];
}
/*
/*!
Returns <code>YES</code> if the receiver responds to mouse events.
*/
- (BOOL)isEnabled
@@ -136,7 +139,7 @@ var CPControlBlackColor = [CPColor blackColor];
}
/*
/*!
Sets the color of the receiver's text.
*/
- (void)setTextColor:(CPColor)aColor
@@ -151,7 +154,7 @@ var CPControlBlackColor = [CPColor blackColor];
#endif
}
/*
/*!
Returns the color of the receiver's text
*/
- (CPColor)textColor
@@ -159,7 +162,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _textColor;
}
/*
/*!
Returns the receiver's alignment
*/
- (CPTextAlignment)alignment
@@ -167,7 +170,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _alignment;
}
/*
/*!
Sets the receiver's alignment
@param anAlignment the receiver's alignment
*/
@@ -176,7 +179,7 @@ var CPControlBlackColor = [CPColor blackColor];
_alignment = anAlignment;
}
/*
/*!
Sets the receiver's font
@param aFont the font for the receiver
*/
@@ -192,7 +195,7 @@ var CPControlBlackColor = [CPColor blackColor];
#endif
}
/*
/*!
Returns the receiver's font
*/
- (CPFont)font
@@ -200,7 +203,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _font;
}
/*
/*!
Sets the shadow for the receiver's text.
@param aTextShadow the text shadow
*/
@@ -209,7 +212,7 @@ var CPControlBlackColor = [CPColor blackColor];
_DOMElement.style.textShadow = [_textShadow = aTextShadow cssString];
}
/*
/*!
Returns the receiver's text shadow
*/
- (CPShadow)textShadow
@@ -217,7 +220,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _textShadow;
}
/*
/*!
Returns the receiver's target action
*/
- (SEL)action
@@ -225,7 +228,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _action;
}
/*
/*!
Sets the receiver's target action
@param anAction Sets the action message that gets sent to the target.
*/
@@ -234,7 +237,7 @@ var CPControlBlackColor = [CPColor blackColor];
_action = anAction;
}
/*
/*!
Returns the receiver's target. The target receives action messages from the receiver.
*/
- (id)target
@@ -242,7 +245,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _target;
}
/*
/*!
Sets the receiver's target. The target receives action messages from the receiver.
@param aTarget the object that will receive the message specified by action
*/
@@ -259,7 +262,7 @@ var CPControlBlackColor = [CPColor blackColor];
[super mouseUp:anEvent];
}
/*
/*!
Causes <code>anAction</code> to be sent to <code>anObject</code>.
@param anAction the action to send
@param anObject the object to which the action will be sent
@@ -269,23 +272,37 @@ var CPControlBlackColor = [CPColor blackColor];
[CPApp sendAction:anAction to:anObject from:self];
}
/*
Returns the receiver's float value
*/
- (float)floatValue
- (int)sendActionOn:(int)mask
{
return _value ? parseFloat(_value, 10) : 0.0;
var previousMask = _sendActionOn;
_sendActionOn = mask;
return previousMask;
}
/*
Sets the receiver's float value
/*!
Returns whether the control can continuously send its action messages.
*/
- (void)setFloatValue:(float)aValue
- (BOOL)isContinuous
{
[self setObjectValue:aValue];
// Some subclasses should redefine this with CPLeftMouseDraggedMask
return (_sendActionOn & CPPeriodicMask) != 0;
}
/*
/*!
Sets whether the cell can continuously send its action messages.
*/
- (void)setContinuous:(BOOL)flag
{
// Some subclasses should redefine this with CPLeftMouseDraggedMask
if (flag)
_sendActionOn |= CPPeriodicMask;
else
_sendActionOn &= ~CPPeriodicMask;
}
/*!
Returns the receiver's object value
*/
- (id)objectValue
@@ -293,7 +310,7 @@ var CPControlBlackColor = [CPColor blackColor];
return _value;
}
/*
/*!
Set's the receiver's object value
*/
- (void)setObjectValue:(id)anObject
@@ -301,54 +318,133 @@ var CPControlBlackColor = [CPColor blackColor];
_value = anObject;
}
/*
/*!
Returns the receiver's float value
*/
- (float)floatValue
{
var floatValue = parseFloat(_value, 10);
return isNaN(floatValue) ? 0.0 : floatValue;
}
/*!
Sets the receiver's float value
*/
- (void)setFloatValue:(float)aValue
{
[self setObjectValue:aValue];
}
/*!
Returns the receiver's double value
*/
- (id)doubleValue
- (double)doubleValue
{
return [self floatValue];
var doubleValue = parseFloat(_value, 10);
return isNaN(doubleValue) ? 0.0 : doubleValue;
}
/*
/*!
Set's the receiver's double value
*/
- (void)setDoubleValue:(id)anObject
- (void)setDoubleValue:(double)anObject
{
[self setObjectValue:anObject];
}
/*
/*!
Returns the receiver's int value
*/
- (id)intValue
- (int)intValue
{
return _value ? parseInt(_value, 10) : 0;
var intValue = parseInt(_value, 10);
return isNaN(intValue) ? 0.0 : intValue;
}
/*
/*!
Set's the receiver's int value
*/
- (void)setIntValue:(id)anObject
- (void)setIntValue:(int)anObject
{
[self setObjectValue:anObject];
}
/*
/*!
Returns the receiver's int value
*/
- (id)stringValue
- (int)integerValue
{
return _value ? ""+_value : "";
var intValue = parseInt(_value, 10);
return isNaN(intValue) ? 0.0 : intValue;
}
/*
/*!
Set's the receiver's int value
*/
- (void)setStringValue:(id)anObject
- (void)setIntegerValue:(int)anObject
{
[self setObjectValue:anObject];
}
/*!
Returns the receiver's int value
*/
- (CPString)stringValue
{
return _value ? String(_value) : "";
}
/*!
Set's the receiver's int value
*/
- (void)setStringValue:(CPString)anObject
{
[self setObjectValue:anObject];
}
- (void)takeDoubleValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(doubleValue)])
[self setDoubleValue:[sender doubleValue]];
}
- (void)takeFloatValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(floatValue)])
[self setFloatValue:[sender floatValue]];
}
- (void)takeIntegerValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(integerValue)])
[self setIntegerValue:[sender integerValue]];
}
- (void)takeIntValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(intValue)])
[self setIntValue:[sender intValue]];
}
- (void)takeObjectValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(objectValue)])
[self setObjectValue:[sender objectValue]];
}
- (void)takeStringValueFrom:(id)sender
{
if ([sender respondsToSelector:@selector(stringValue)])
[self setStringValue:[sender stringValue]];
}
- (void)setBackgroundColor:(CPColor)aColor
{
_backgroundColors = [CPDictionary dictionary];
@@ -386,6 +482,33 @@ var CPControlBlackColor = [CPColor blackColor];
[super setBackgroundColor:[self backgroundColorForName:aName]];
}
- (void)textDidBeginEditing:(CPNotification)note
{
//this looks to prevent false propagation of notifications for other objects
if([note object] != self)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidBeginEditingNotification object:self userInfo:[CPDictionary dictionaryWithObject:[note object] forKey:"CPFieldEditor"]];
}
- (void)textDidChange:(CPNotification)note
{
//this looks to prevent false propagation of notifications for other objects
if([note object] != self)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidChangeNotification object:self userInfo:[CPDictionary dictionaryWithObject:[note object] forKey:"CPFieldEditor"]];
}
- (void)textDidEndEditing:(CPNotification)note
{
//this looks to prevent false propagation of notifications for other objects
if([note object] != self)
return;
[[CPNotificationCenter defaultCenter] postNotificationName:CPControlTextDidEndEditingNotification object:self userInfo:[CPDictionary dictionaryWithObject:[note object] forKey:"CPFieldEditor"]];
}
/*
Ð doubleValue
Ð setDoubleValue:
@@ -402,13 +525,14 @@ var CPControlBlackColor = [CPColor blackColor];
@end
var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
CPControlAlignmentKey = @"CPControlAlignmentKey",
CPControlFontKey = @"CPControlFontKey",
CPControlTextColorKey = @"CPControlTextColorKey",
CPControlTargetKey = @"CPControlTargetKey",
CPControlActionKey = @"CPControlActionKey",
CPControlSendActionOnKey = @"CPControlSendActionOnKey";
var CPControlValueKey = "CPControlValueKey",
CPControlIsEnabledKey = "CPControlIsEnabledKey",
CPControlAlignmentKey = "CPControlAlignmentKey",
CPControlFontKey = "CPControlFontKey",
CPControlTextColorKey = "CPControlTextColorKey",
CPControlTargetKey = "CPControlTargetKey",
CPControlActionKey = "CPControlActionKey",
CPControlSendActionOnKey = "CPControlSendActionOnKey";
@implementation CPControl (CPCoding)
@@ -423,7 +547,9 @@ var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
if (self)
{
[self setEnabled:[aCoder decodeIntForKey:CPControlIsEnabledKey]];
[self setObjectValue:[aCoder decodeObjectForKey:CPControlValueKey]];
[self setEnabled:[aCoder decodeBoolForKey:CPControlIsEnabledKey]];
[self setAlignment:[aCoder decodeIntForKey:CPControlAlignmentKey]];
[self setFont:[aCoder decodeObjectForKey:CPControlFontKey]];
@@ -431,8 +557,7 @@ var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
[self setTarget:[aCoder decodeObjectForKey:CPControlTargetKey]];
[self setAction:[aCoder decodeObjectForKey:CPControlActionKey]];
_sendActionOn = [aCoder decodeIntForKey:CPControlSendActionOnKey];
[self sendActionOn:[aCoder decodeIntForKey:CPControlSendActionOnKey]];
}
return self;
@@ -446,7 +571,9 @@ var CPControlIsEnabledKey = @"CPControlIsEnabledKey",
{
[super encodeWithCoder:aCoder];
[aCoder encodeInt:_isEnabled forKey:CPControlIsEnabledKey];
[aCoder encodeObject:_value forKey:CPControlValueKey];
[aCoder encodeBool:_isEnabled forKey:CPControlIsEnabledKey];
[aCoder encodeInt:_alignment forKey:CPControlAlignmentKey];
[aCoder encodeObject:_font forKey:CPControlFontKey];
@@ -465,9 +592,9 @@ var _CPControlSizeIdentifiers = [],
_CPControlCachedColorWithPatternImages = {},
_CPControlCachedThreePartImagePattern = {};
_CPControlSizeIdentifiers[CPRegularControlSize] = @"Regular";
_CPControlSizeIdentifiers[CPSmallControlSize] = @"Small";
_CPControlSizeIdentifiers[CPMiniControlSize] = @"Mini";
_CPControlSizeIdentifiers[CPRegularControlSize] = "Regular";
_CPControlSizeIdentifiers[CPSmallControlSize] = "Small";
_CPControlSizeIdentifiers[CPMiniControlSize] = "Mini";
function _CPControlIdentifierForControlSize(aControlSize)
{
@@ -478,7 +605,7 @@ function _CPControlColorWithPatternImage(sizes, aClassName)
{
var index = 1,
count = arguments.length,
identifier = @"";
identifier = "";
for (; index < count; ++index)
identifier += arguments[index];
@@ -489,7 +616,7 @@ function _CPControlColorWithPatternImage(sizes, aClassName)
{
var bundle = [CPBundle bundleForClass:[CPControl class]];
color = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:aClassName + "/" + identifier + @".png"] size:sizes[identifier]]];
color = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:aClassName + "/" + identifier + ".png"] size:sizes[identifier]]];
_CPControlCachedColorWithPatternImages[identifier] = color;
}
@@ -501,7 +628,7 @@ function _CPControlThreePartImages(sizes, aClassName)
{
var index = 1,
count = arguments.length,
identifier = @"";
identifier = "";
for (; index < count; ++index)
identifier += arguments[index];
@@ -516,9 +643,9 @@ function _CPControlThreePartImages(sizes, aClassName)
sizes = sizes[identifier];
images = [
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"0.png"] size:sizes[0]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"1.png"] size:sizes[1]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"2.png"] size:sizes[2]]
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "0.png"] size:sizes[0]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "1.png"] size:sizes[1]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "2.png"] size:sizes[2]]
];
_CPControlCachedThreePartImages[identifier] = images;
@@ -531,7 +658,7 @@ function _CPControlThreePartImagePattern(isVertical, sizes, aClassName)
{
var index = 2,
count = arguments.length,
identifier = @"";
identifier = "";
for (; index < count; ++index)
identifier += arguments[index];
@@ -546,9 +673,9 @@ function _CPControlThreePartImagePattern(isVertical, sizes, aClassName)
sizes = sizes[identifier];
color = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:[
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"0.png"] size:sizes[0]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"1.png"] size:sizes[1]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + @"2.png"] size:sizes[2]]
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "0.png"] size:sizes[0]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "1.png"] size:sizes[1]],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:path + "2.png"] size:sizes[2]]
] isVertical:isVertical]];
_CPControlCachedThreePartImagePattern[identifier] = color;
+9 -9
View File
@@ -20,12 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
/*
<objj>CPCookie</objj> is the Cappuccino interface to a web browser cookie. You can set the name
/*! @class CPCookie
CPCookie is the Cappuccino interface to a web browser cookie. You can set the name
*/
@implementation CPCookie : CPObject
{
@@ -35,7 +35,7 @@ import <Foundation/CPString.j>
CPString _expires;
}
/*
/*!
Initializes a cookie with a given name <code>aName</code>.
@param the name for the cookie
*/
@@ -49,7 +49,7 @@ import <Foundation/CPString.j>
return self;
}
/*
/*!
Returns the cookie's data value
*/
- (CPString)value
@@ -57,7 +57,7 @@ import <Foundation/CPString.j>
return _cookieValue;
}
/*
/*!
Returns the cookie's name
*/
- (CPString)name
@@ -65,7 +65,7 @@ import <Foundation/CPString.j>
return _cookieName;
}
/*
/*!
Returns the cookie's expiration date
*/
- (CPString)expires
@@ -73,7 +73,7 @@ import <Foundation/CPString.j>
return _expires;
}
/*
/*!
Sets a value, expiration date, and domain for the cookie
@param value the cookie's value
@param date the cookie's expiration date
+39 -37
View File
@@ -20,11 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPString.j>
import <Foundation/CPArray.j>
@import <Foundation/CPString.j>
@import <Foundation/CPArray.j>
@import "CPResponder.j"
@import "CPWindowController.j"
import "CPResponder.j"
import "CPWindowController.j"
/*
@global
@@ -79,11 +80,12 @@ CPDocumentDidFailToSaveNotification = @"CPDocumentDidFailToSaveNotification";
var CPDocumentUntitledCount = 0;
/*
<objj>CPDocument</objj> is used to represent a document/file in a Cappuccino application.
/*! @class CPDocument
CPDocument is used to represent a document/file in a Cappuccino application.
In a document-based application, generally multiple documents are open simutaneously
(multiple text documents, slide presentations, spreadsheets, etc.), and multiple
<objj>CPDocument</objj>s should be used to represent this.
CPDocuments should be used to represent this.
*/
@implementation CPDocument : CPResponder
{
@@ -101,7 +103,7 @@ var CPDocumentUntitledCount = 0;
CPURLRequest _writeRequest;
}
/*
/*!
Initializes an empty document.
@return the initialized document
*/
@@ -122,7 +124,7 @@ var CPDocumentUntitledCount = 0;
return self;
}
/*
/*!
Initializes the document with a specific data type.
@param aType the type of document to initialize
@param anError not used
@@ -138,7 +140,7 @@ var CPDocumentUntitledCount = 0;
return self;
}
/*
/*!
Initializes a document of a specific type located at a URL. Notifies
the provided delegate after initialization.
@param anAbsoluteURL the url of the document content
@@ -164,7 +166,7 @@ var CPDocumentUntitledCount = 0;
return self;
}
/*
/*!
Initializes the document from a URL.
@param anAbsoluteURL the document location
@param absoluteContentsURL the location of the document's contents
@@ -189,7 +191,7 @@ var CPDocumentUntitledCount = 0;
return self;
}
/*
/*!
Returns the receiver's data in a specified type. The default implementation just
throws an exception.
@param aType the format of the data
@@ -203,7 +205,7 @@ var CPDocumentUntitledCount = 0;
reason:"dataOfType:error: must be overridden by the document subclass."];
}
/*
/*!
Sets the content of the document by reading the provided
data. The default implementation just throws an exception.
@param aData the document's data
@@ -219,7 +221,7 @@ var CPDocumentUntitledCount = 0;
}
// Creating and managing window controllers
/*
/*!
Creates the window controller for this document.
*/
- (void)makeWindowControllers
@@ -229,7 +231,7 @@ var CPDocumentUntitledCount = 0;
[self addWindowController:controller];
}
/*
/*!
Returns the document's window controllers
*/
- (CPArray)windowControllers
@@ -237,7 +239,7 @@ var CPDocumentUntitledCount = 0;
return _windowControllers;
}
/*
/*!
Add a controller to the document's list of controllers. This should
be called after making a new window controller.
@param aWindowController the controller to add
@@ -254,7 +256,7 @@ var CPDocumentUntitledCount = 0;
}
// Managing Document Windows
/*
/*!
Shows all the document's windows.
*/
- (void)showWindows
@@ -262,7 +264,7 @@ var CPDocumentUntitledCount = 0;
[_windowControllers makeObjectsPerformSelector:@selector(showWindow:) withObject:self];
}
/*
/*!
Returns the name of the document as displayed in the title bar.
*/
- (CPString)displayName
@@ -279,7 +281,7 @@ var CPDocumentUntitledCount = 0;
return @"Untitled " + _untitledDocumentIndex;
}
/*
/*!
Returns the document's Cib name
*/
- (CPString)windowCibName
@@ -287,7 +289,7 @@ var CPDocumentUntitledCount = 0;
return nil;
}
/*
/*!
Called after <code>aWindowController<code> loads the document's Nib file.
@param aWindowController the controller that loaded the Nib file
*/
@@ -295,7 +297,7 @@ var CPDocumentUntitledCount = 0;
{
}
/*
/*!
Called before <code>aWindowController</code> will load the document's Nib file.
@param aWindowController the controller that will load the Nib file
*/
@@ -304,7 +306,7 @@ var CPDocumentUntitledCount = 0;
}
// Reading from and Writing to URLs
/*
/*!
Set the document's data from a URL. Notifies the provided delegate afterwards.
@param anAbsoluteURL the URL to the document's content
@param aType the document type
@@ -322,7 +324,7 @@ var CPDocumentUntitledCount = 0;
_readConnection.session = _CPReadSessionMake(aType, aDelegate, aDidReadSelector, aContextInfo);
}
/*
/*!
Returns the path to the document's file.
*/
- (CPURL)fileURL
@@ -330,7 +332,7 @@ var CPDocumentUntitledCount = 0;
return _fileURL;
}
/*
/*!
Sets the path to the document's file.
@param aFileURL the path to the document's file
*/
@@ -344,7 +346,7 @@ var CPDocumentUntitledCount = 0;
[_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)];
}
/*
/*!
Saves the document to the specified URL. Notifies the provided delegate
with the provided selector and context info afterwards.
@param anAbsoluteURL the url to write the document data to
@@ -493,7 +495,7 @@ var CPDocumentUntitledCount = 0;
}
// Managing Document Status
/*
/*!
Returns <code>YES</code> if there are any unsaved changes.
*/
- (BOOL)isDocumentEdited
@@ -501,7 +503,7 @@ var CPDocumentUntitledCount = 0;
return _changeCount != 0;
}
/*
/*!
Updates the number of unsaved changes to the document.
@param aChangeType a new document change to apply
*/
@@ -521,7 +523,7 @@ var CPDocumentUntitledCount = 0;
}
// Managing File Types
/*
/*!
Sets the document's file type
@param aType the document's type
*/
@@ -530,7 +532,7 @@ var CPDocumentUntitledCount = 0;
_fileType = aType;
}
/*
/*!
Returns the document's file type
*/
- (CPString)fileType
@@ -539,17 +541,17 @@ var CPDocumentUntitledCount = 0;
}
// Working with Undo Manager
/*
/*!
Returns <code>YES</code> if the document has a
<objj>CPUndoManager</objj>.
CPUndoManager.
*/
- (BOOL)hasUndoManager
{
return _hasUndoManager;
}
/*
Sets whether the document should have a <objj>CPUndoManager</objj>.
/*!
Sets whether the document should have a CPUndoManager.
@param aFlag <code>YES</code> makes the document have an undo manager
*/
- (void)setHasUndoManager:(BOOL)aFlag
@@ -632,7 +634,7 @@ var CPDocumentUntitledCount = 0;
}
}
/*
/*!
Returns the document's undo manager. If the document
should have one, but the manager is <code>nil</code>, it
will be created and then returned.
@@ -647,7 +649,7 @@ var CPDocumentUntitledCount = 0;
}
/*
Implemented as a delegate of a <objj>CPWindow</objj>
Implemented as a delegate of a CPWindow
@ignore
*/
- (CPUndoManager)windowWillReturnUndoManager:(CPWindow)aWindow
@@ -656,7 +658,7 @@ var CPDocumentUntitledCount = 0;
}
// Handling User Actions
/*
/*!
Saves the document. If the document does not
have a file path to save to (<code>fileURL</code>)
then <code>saveDocumentAs:</code> will be called.
@@ -676,7 +678,7 @@ var CPDocumentUntitledCount = 0;
[self saveDocumentAs:self];
}
/*
/*!
Saves the document to a user specified path.
@param aSender the object requesting the operation
*/
+20 -19
View File
@@ -20,14 +20,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPBundle.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPBundle.j>
@import "CPDocument.j"
import "CPDocument.j"
var CPSharedDocumentController = nil;
/*
/*! @class CPDocumentController
This class is responsible for managing an application's open documents.
*/
@implementation CPDocumentController : CPObject
@@ -36,10 +37,10 @@ var CPSharedDocumentController = nil;
CPArray _documentTypes;
}
/*
/*!
Returns the singleton instance of the application's document controller. If it has not
been created yet, it will be created then returned.
@return a <objj>CPDocumentController</objj>
@return a CPDocumentController
*/
+ (id)sharedDocumentController
{
@@ -70,7 +71,7 @@ var CPSharedDocumentController = nil;
// Creating and Opening Documents
/*
/*!
Returns the document matching the specified URL. This
method searches documents already open. It does not
open the document at the URL if it is not already open.
@@ -93,7 +94,7 @@ var CPSharedDocumentController = nil;
return nil;
}
/*
/*!
Creates a new document of the specified type.
@param aType the type of the new document
@param shouldDisplay whether to display the document on screen
@@ -114,7 +115,7 @@ var CPSharedDocumentController = nil;
return theDocument;
}
/*
/*!
Creates a document of the specified type.
@param aType the document type
@param anError not used
@@ -125,7 +126,7 @@ var CPSharedDocumentController = nil;
return [[[self documentClassForType:aType] alloc] initWithType:aType error:anError];
}
/*
/*!
Opens the document at the specified URL.
@param anAbsoluteURL the path to the document's file
@param shouldDisplay whether to display the document on screen
@@ -148,7 +149,7 @@ var CPSharedDocumentController = nil;
return result;
}
/*
/*!
Loads a document for a specified URL with it's content
retrieved from another URL.
@param anAbsoluteURL the document URL
@@ -161,7 +162,7 @@ var CPSharedDocumentController = nil;
return [self makeDocumentForURL:anAbsoluteURL withContentsOfURL:absoluteContentsURL ofType:[[_documentTypes objectAtIndex:0] objectForKey:@"CPBundleTypeName"] delegate:self didReadSelector:@selector(document:didRead:contextInfo:) contextInfo:nil];
}
/*
/*!
Creates a document from the contents at the specified URL.
Notifies the provided delegate with the provided selector afterwards.
@param anAbsoluteURL the location of the document data
@@ -175,7 +176,7 @@ var CPSharedDocumentController = nil;
return [[[self documentClassForType:aType] alloc] initWithContentsOfURL:anAbsoluteURL ofType:aType delegate:aDelegate didReadSelector:aSelector contextInfo:aContextInfo];
}
/*
/*!
Creates a document from the contents of a URL, and sets
the document's URL location as another URL.
@param anAbsoluteURL the document's location
@@ -207,7 +208,7 @@ var CPSharedDocumentController = nil;
[aDocument showWindows];
}
/*
/*!
Opens a new document in the application.
@param aSender the requesting object
*/
@@ -218,7 +219,7 @@ var CPSharedDocumentController = nil;
// Managing Documents
/*
/*!
Returns the array of all documents being managed. This is
the same as all open documents in the application.
*/
@@ -227,7 +228,7 @@ var CPSharedDocumentController = nil;
return _documents;
}
/*
/*!
Adds <code>aDocument</code> under the control of the receiver.
@param aDocument the document to add
*/
@@ -236,7 +237,7 @@ var CPSharedDocumentController = nil;
[_documents addObject:aDocument];
}
/*
/*!
Removes <code>aDocument</code> from the control of the receiver.
@param aDocument the document to remove
*/
@@ -292,8 +293,8 @@ var CPSharedDocumentController = nil;
return nil;
}
/*
Returns the <objj>CPDocument</objj> subclass associated with <code>aType</code>.
/*!
Returns the CPDocument subclass associated with <code>aType</code>.
@param aType the type of document
@return a Cappuccino Class object, or <code>nil</code> if no match was found
*/
+8 -7
View File
@@ -20,10 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <AppKit/CPView.j>
import <AppKit/CPEvent.j>
import <AppKit/CPPasteboard.j>
import <AppKit/CPImageView.j>
@import <AppKit/CPView.j>
@import <AppKit/CPEvent.j>
@import <AppKit/CPPasteboard.j>
@import <AppKit/CPImageView.j>
var CPSharedDragServer = nil;
@@ -115,7 +116,7 @@ var CPDragServerUpdateDragging = function(anEvent)
}
/*
<objj>CPDraggingInfo</objj> is a container of information about a specific dragging session.
CPDraggingInfo is a container of information about a specific dragging session.
@ignore
*/
@implementation CPDraggingInfo : CPObject
@@ -195,7 +196,7 @@ var CPDragServerUpdateDragging = function(anEvent)
return self;
}
/*
/*!
Initiates a drag session.
@param aView the view being dragged
@param aWindow the window where the drag source is
@@ -250,7 +251,7 @@ var CPDragServerUpdateDragging = function(anEvent)
CPDragServerStartDragging(anEvent);
}
/*
/*!
Initiates a drag session.
@param anImage the image to be dragged
@param aWindow the source window of the drag session
+34 -35
View File
@@ -20,10 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
#include "CoreGraphics/CGGeometry.h"
/*
@global
@group CPEventType
@@ -178,8 +179,8 @@ CPDOMEventScrollWheel = "mousewheel";
var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = nil;
/*
<objj>CPEvent</objj> encapsulates the details of a Cappuccino keyboard or mouse event.
/*! @class CPEvent
CPEvent encapsulates the details of a Cappuccino keyboard or mouse event.
*/
@implementation CPEvent : CPObject
{
@@ -203,20 +204,20 @@ var _CPEventPeriodicEventPeriod = 0,
float _deltaZ;
}
/*
/*!
Creates a new keyboard event.
@param anEventType the event type. Must be one of <objj>CPKeyDown</objj>, <objj>CPKeyUp</objj> or <objj>CPFlagsChanged</objj>
@param anEventType the event type. Must be one of CPKeyDown, CPKeyUp or CPFlagsChanged
@param aPoint the location of the cursor in the window specified by <code>aWindowNumber</code>
@param modifierFlags a bitwise combination of the modifiers specified in the <objj>CPEvent</objj> globals
@param modifierFlags a bitwise combination of the modifiers specified in the CPEvent globals
@param aTimestamp the time the event occurred
@param aWindowNumber the number of the <objj>CPWindow</objj> where the event occurred
@param aWindowNumber the number of the CPWindow where the event occurred
@param aGraphicsContext the graphics context where the event occurred
@param characters the characters associated with the event
@param unmodCharacters the string of keys pressed without the presence of any modifiers other than Shift
@param repeatKey <code>YES</code> if this is caused by the system repeat as opposed to the user pressing the key again
@param code a number associated with the keyboard key of this event
@throws CPInternalInconsistencyException if <code>anEventType</code> is not a <objj>CPKeyDown</objj>,
<objj>CPKeyUp</objj> or <objj>CPFlagsChanged</objj>
@throws CPInternalInconsistencyException if <code>anEventType</code> is not a CPKeyDown,
CPKeyUp or CPFlagsChanged
@return the keyboard event
*/
+ (CPEvent)keyEventWithType:(CPEventType)anEventType location:(CGPoint)aPoint modifierFlags:(unsigned int)modifierFlags
@@ -228,13 +229,13 @@ var _CPEventPeriodicEventPeriod = 0,
characters:characters charactersIgnoringModifiers:unmodCharacters isARepeat:repeatKey keyCode:code];
}
/*
/*!
Creates a new mouse event
@param anEventType the event type
@param aPoint the location of the cursor in the window specified by <code>aWindowNumber</code>
@param modifierFlags a bitwise combination of the modifiers specified in the <objj>CPEvent</objj> globals
@param modifierFlags a bitwise combination of the modifiers specified in the CPEvent globals
@param aTimestamp the time the event occurred
@param aWindowNumber the number of the <objj>CPWindow</objj> where the event occurred
@param aWindowNumber the number of the CPWindow where the event occurred
@param aGraphicsContext the graphics context where the event occurred
@param anEventNumber a number for this event
@param aClickCount the number of clicks that caused this event
@@ -250,13 +251,13 @@ var _CPEventPeriodicEventPeriod = 0,
timestamp:aTimestamp windowNumber:aWindowNumber context:aGraphicsContext eventNumber:anEventNumber clickCount:aClickCount pressure:aPressure];
}
/*
/*!
Creates a new custom event
@param anEventType the event type. Must be one of <objj>CPAppKitDefined</objj>, <objj>CPSystemDefined</objj>, <objj>CPApplicationDefined</objj> or <objj>CPPeriodic</objj>
@param anEventType the event type. Must be one of CPAppKitDefined, CPSystemDefined, CPApplicationDefined or CPPeriodic
@param aLocation the location of the cursor in the window specified by <code>aWindowNumber</code>
@param modifierFlags a bitwise combination of the modifiers specified in the <objj>CPEvent</objj> globals
@param modifierFlags a bitwise combination of the modifiers specified in the CPEvent globals
@param aTimestamp the time the event occurred
@param aWindowNumber the number of the <objj>CPWindow</objj> where the event occurred
@param aWindowNumber the number of the CPWindow where the event occurred
@param aGraphicsContext the graphics context where the event occurred
@param aSubtype a numeric identifier to differentiate this event from other custom events
@param aData1 more data that describes the event
@@ -341,7 +342,7 @@ var _CPEventPeriodicEventPeriod = 0,
return self;
}
/*
/*!
Returns the location of the mouse (for mouse events).
If this is not a mouse event, it returns <code>nil</code>.
If <code>window</code> returns <code>nil</code>, then
@@ -354,7 +355,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _location;
}
/*
/*!
Returns event information as a bit mask
*/
- (unsigned)modifierFlags
@@ -362,7 +363,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _modifierFlags;
}
/*
/*!
Returns the time the event occurred
*/
- (CPTimeInterval)timestamp
@@ -370,7 +371,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _timestamp;
}
/*
/*!
Returns the type of event.
*/
- (CPEventType)type
@@ -378,7 +379,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _type;
}
/*
/*!
Returns the event's associated window
*/
- (CPWindow)window
@@ -386,7 +387,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _window;
}
/*
/*!
The number of the window associated with the event.
*/
- (int)windowNumber
@@ -395,7 +396,7 @@ var _CPEventPeriodicEventPeriod = 0,
}
// Mouse Event Information
/*
/*!
Returns the button number for the mouse that generated the event.
*/
- (int)buttonNumber
@@ -403,7 +404,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _buttonNumber;
}
/*
/*!
Returns the number of clicks that caused this event. (mouse only)
*/
- (int)clickCount
@@ -411,7 +412,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _clickCount;
}
/*
/*!
Returns the characters associated with this event (keyboard only)
@throws CPInternalInconsistencyException if this method is called on a non-key event
*/
@@ -420,7 +421,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _characters;
}
/*
/*!
Returns the character ignoring any modifiers (except shift).
@throws CPInternalInconsistencyException if this method is called on a non-key event
*/
@@ -429,7 +430,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _charactersIgnoringModifiers;
}
/*
/*!
Returns <code>YES</code> if the keyboard event was caused by the key being held down.
@throws CPInternalInconsistencyException if this method is called on a non-key event
*/
@@ -438,7 +439,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _isARepeat;
}
/*
/*!
Returns the key's key code.
@throws CPInternalInconsistencyException if this method is called on a non-key event
*/
@@ -461,7 +462,7 @@ var _CPEventPeriodicEventPeriod = 0,
}
// Getting Scroll Wheel Event Infomration
/*
/*!
Returns the change in the x-axis for a mouse event.
*/
- (float)deltaX
@@ -469,7 +470,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaX;
}
/*
/*!
Returns the change in the y-axis for a mouse event.
*/
- (float)deltaY
@@ -477,7 +478,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaY;
}
/*
/*!
Returns the change in the x-axis for a mouse event.
*/
- (float)deltaZ
@@ -485,7 +486,7 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaZ;
}
/*
/*!
Generates periodic events every <code>aPeriod</code> seconds.
@param aDelay the number of seconds before the first event
@param aPeriod the length of time in seconds between successive events
@@ -498,7 +499,7 @@ var _CPEventPeriodicEventPeriod = 0,
_CPEventPeriodicEventTimer = window.setTimeout(function() { _CPEventPeriodicEventTimer = window.setInterval(_CPEventFirePeriodEvent, aPeriod * 1000.0); }, aDelay * 1000.0);
}
/*
/*!
Stops the periodic events from being generated
*/
+ (void)stopPeriodicEvents
@@ -516,7 +517,5 @@ var _CPEventPeriodicEventPeriod = 0,
function _CPEventFirePeriodEvent()
{
[CPApp sendEvent:[CPEvent otherEventWithType:CPPeriodic location:_CGPointMakeZero() modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:0 data1:0 data2:0]];
[[CPRunLoop currentRunLoop] performSelectors];
}
+1 -1
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
@implementation CPFlashMovie : CPObject
+3 -3
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPDOMWindowBridge.j"
import "CPFlashMovie.j"
import "CPView.j"
@import "CPDOMWindowBridge.j"
@import "CPFlashMovie.j"
@import "CPView.j"
@implementation CPFlashView : CPView
+13 -12
View File
@@ -25,8 +25,9 @@ var _CPFonts = {};
#define _CPCachedFont(aName, aSize, isBold) _CPFonts[(isBold ? @"bold " : @"") + ROUND(aSize) + @"px '" + aName + @"'"]
/*
The <objj>CPFont</objj> class allows control of the fonts used for displaying text anywhere on the screen. The primary method for getting a particular font is through one of the class methods that take a name and/or size as arguments, and return the appropriate <objj>CPFont</objj>.
/*! @class CPFont
The CPFont class allows control of the fonts used for displaying text anywhere on the screen. The primary method for getting a particular font is through one of the class methods that take a name and/or size as arguments, and return the appropriate CPFont.
*/
@implementation CPFont : CPObject
{
@@ -37,7 +38,7 @@ var _CPFonts = {};
CPString _cssString;
}
/*
/*!
Returns a font with the specified name and size.
@param aName the name of the font
@param aSize the size of the font (in points)
@@ -48,7 +49,7 @@ var _CPFonts = {};
return _CPCachedFont(aName, aSize, NO) || [[CPFont alloc] _initWithName:aName size:aSize bold:NO];
}
/*
/*!
Returns a bold font with the specified name and size.
@param aName the name of the font
@param aSize the size of the font (in points)
@@ -59,7 +60,7 @@ var _CPFonts = {};
return _CPCachedFont(aName, aSize, YES) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES];
}
/*
/*!
Returns the system font scaled to the specified size
@param aSize the size of the font (in points)
@return the requested system font
@@ -69,7 +70,7 @@ var _CPFonts = {};
return _CPCachedFont(_CPFontSystemFontFace, aSize, NO) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:NO];
}
/*
/*!
Returns the bold system font scaled to the specified size
@param aSize the size of the font (in points)
@return the requested bold system font
@@ -79,7 +80,7 @@ var _CPFonts = {};
return _CPCachedFont(_CPFontSystemFontFace, aSize, YES) || [[CPFont alloc] _initWithName:_CPFontSystemFontFace size:aSize bold:YES];
}
/** FIXME Font Descriptor
/* FIXME Font Descriptor
@ignore
*/
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold
@@ -100,7 +101,7 @@ var _CPFonts = {};
return self;
}
/*
/*!
Returns the font size (in points)
*/
- (float)size
@@ -108,7 +109,7 @@ var _CPFonts = {};
return _size;
}
/*
/*!
Returns the font as a CSS string
*/
- (CPString)cssString
@@ -116,7 +117,7 @@ var _CPFonts = {};
return _cssString;
}
/*
/*!
Returns the font's family name
*/
- (CPString)familyName
@@ -132,7 +133,7 @@ var CPFontNameKey = @"CPFontNameKey",
@implementation CPFont (CPCoding)
/*
/*!
Initializes the font from a coder.
@param aCoder the coder from which to read the font data
@return the initialized font
@@ -144,7 +145,7 @@ var CPFontNameKey = @"CPFontNameKey",
bold:[aCoder decodeBoolForKey:CPFontIsBoldKey]];
}
/*
/*!
Writes the font information out to a coder.
@param aCoder the coder to which the data will be written
*/
+6 -6
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
import <AppKit/CPFont.j>
@import <AppKit/CPFont.j>
var CPSharedFontManager = nil,
@@ -34,7 +34,7 @@ var CPSharedFontManager = nil,
}
// Getting the Shared Font Manager
/*
/*!
Returns the application's font manager. If the font
manager does not exist yet, it will be created.
*/
@@ -47,7 +47,7 @@ var CPSharedFontManager = nil,
}
// Changing the Default Font Conversion Classes
/*
/*!
Sets the class that will be used to create the applcation's
font manager.
*/
@@ -56,7 +56,7 @@ var CPSharedFontManager = nil,
CPFontManagerFactory = aClass;
}
/*
/*!
Returns an array of the available fonts
*/
- (CPArray)availableFonts
@@ -84,7 +84,7 @@ var CPSharedFontManager = nil,
return _availableFonts;
}
/*
/*!
Returns the available fonts matching the provided name.
@param aFontName the name of the font
*/
+81 -80
View File
@@ -20,7 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CGGeometry.j"
@import "CGGeometry.j"
CPMinXEdge = 0;
CPMinYEdge = 1;
@@ -32,7 +33,7 @@ CPMakePoint = CGPointMake;
CPMakeSize = CGSizeMake;
CPMakeRect = CGRectMake;
/**
/*!
Creates a copy of a specified point and returns the copy
@group CGPoint
@param the point to be copied
@@ -43,7 +44,7 @@ function CPPointCreateCopy(aPoint)
return { x: aPoint.x, y: aPoint.y };
}
/**
/*!
Makes a CGPoint object out of two numbers provided as arguments
@group CGPoint
@param x the x-coordinate of the CGPoint
@@ -55,7 +56,7 @@ function CPPointMake(x, y)
return { x: x, y: y };
}
/*
/*!
Makes a CGRect with an origin and size equal to <code>aRect</code> less the <code>dX/dY</code> insets specified.
@param dX the size of the inset in the x-axis
@param dY the size of the inset in the y-axis
@@ -68,7 +69,7 @@ function CPRectInset(aRect, dX, dY)
aRect.size.width - 2 * dX, aRect.size.height - 2*dY);
}
/*
/*!
@group CGRect
@ignore
@return void
@@ -80,7 +81,7 @@ function CPRectIntegral(aRect)
alert("CPRectIntegral unimplemented");
}
/*
/*!
Returns the intersection of the two provided rectangles as a new rectangle
@group CGRect
@param lhsRect the first rectangle used for calculation
@@ -100,7 +101,7 @@ function CPRectIntersection(lhsRect, rhsRect)
return CPRectIsEmpty(intersection) ? CPRectMakeZero() : intersection;
}
/*
/*!
Creates a copy of the provided rectangle
@group CGRect
@param aRect the CGRect that will be copied
@@ -111,7 +112,7 @@ function CPRectCreateCopy(aRect)
return { origin: CPPointCreateCopy(aRect.origin), size: CPSizeCreateCopy(aRect.size) };
}
/*
/*!
Returns a CGRect made of the specified arguments
@group CGRect
@param x the x-coordinate of the rectangle's origin
@@ -125,7 +126,7 @@ function CPRectMake(x, y, width, height)
return { origin: CPPointMake(x, y), size: CPSizeMake(width, height) };
}
/*
/*!
Creates a new rectangle with its origin offset by <code>dX</code> and <code>dY</code>.
@group CGRect
@param aRect the rectangle to copy the origin and size from
@@ -138,7 +139,7 @@ function CPRectOffset(aRect, dX, dY)
return CPRectMake(aRect.origin.x + dX, aRect.origin.y + dY, aRect.size.width, aRect.size.height);
}
/*
/*!
@group CGRect
@param aRect a CGRect
@return CGRect
@@ -164,7 +165,7 @@ function CPRectStandardize(aRect)
return standardized;
}
/*
/*!
Returns the smallest rectangle that can contain the two argument <code>CGRect</code>s.
@group CGRect
@param lhsRect the first CGRect to use for the union calculation
@@ -181,7 +182,7 @@ function CPRectUnion(lhsRect, rhsRect)
return CPRectMake(minX, minY, maxX - minX, maxY - minY);
}
/*
/*!
Creates and returns a copy of the provided CGSize
@group CGSize
@param aSize the CGSize to copy
@@ -192,7 +193,7 @@ function CPSizeCreateCopy(aSize)
return { width: aSize.width, height: aSize.height };
}
/*
/*!
Creates and returns a new CGSize object from the provided dimensions.
@group CGSize
@param width the width for the new CGSize
@@ -204,9 +205,9 @@ function CPSizeMake(width, height)
return { width: width, height: height };
}
/*
Returns <code>YES</code> if the <objj>CGRect</objj>, <code>aRect</code>, contains
the <objj>CGPoint</objj>, <code>aPoint</code>.
/*!
Returns <code>YES</code> if the CGRect, <code>aRect</code>, contains
the CGPoint, <code>aPoint</code>.
@param aRect the rectangle to test with
@param aPoint the point to test with
@group CGRect
@@ -220,12 +221,12 @@ function CPRectContainsPoint(aRect, aPoint)
aPoint.y < CPRectGetMaxY(aRect);
}
/*
Returns a <code>BOOL</code> indicating whether <objj>CGRect</objj> <code>possibleOuter</code>
contains <objj>CGRect</objj> <code>possibleInner</code>.
/*!
Returns a <code>BOOL</code> indicating whether CGRect <code>possibleOuter</code>
contains CGRect <code>possibleInner</code>.
@group CGRect
@param possibleOuter the <objj>CGRect</objj> to test if <code>possibleInner</code> is inside of
@param possibleInner the <objj>CGRect</objj> to test if it fits inside <code>possibleOuter</code>.
@param possibleOuter the CGRect to test if <code>possibleInner</code> is inside of
@param possibleInner the CGRect to test if it fits inside <code>possibleOuter</code>.
@return BOOL <code>YES</code> if <code>possibleInner</code> fits inside <code>possibleOuter</code>.
*/
function CPRectContainsRect(lhsRect, rhsRect)
@@ -233,12 +234,12 @@ function CPRectContainsRect(lhsRect, rhsRect)
return CPRectEqualToRect(CPUnionRect(lhsRect, rhsRect), rhsRect);
}
/*
Tests whether the two <objj>CGPoint</objj>s are equal to each other by comparing their
/*!
Tests whether the two CGPoints are equal to each other by comparing their
<code>x</code> and <code>y</code> members.
@group @CGPoint
@param lhsPoint the first <objj>CGPoint</objj> to check
@param rhsPoint the second <objj>CGPoint</objj> to check
@param lhsPoint the first CGPoint to check
@param rhsPoint the second CGPoint to check
@return BOOL <code>YES</code> if the two points have the same x's, and the same y's.
*/
function CPPointEqualToPoint(lhsPoint, rhsPoint)
@@ -246,11 +247,11 @@ function CPPointEqualToPoint(lhsPoint, rhsPoint)
return lhsPoint.x == rhsPoint.x && lhsPoint.y == rhsPoint.y;
}
/*
Test whether the two <objj>CGRect</objj>s have the same origin and size
/*!
Test whether the two CGRects have the same origin and size
@group CGRect
@param lhsRect the first <objj>CGRect</objj> to compare
@param rhsRect the second <objj>CGRect</objj> to compare
@param lhsRect the first CGRect to compare
@param rhsRect the second CGRect to compare
@return BOOL <code>YES</code> if the two rectangles have the same origin and size. <code>NO</code>, otherwise.
*/
function CPRectEqualToRect(lhsRect, rhsRect)
@@ -259,9 +260,9 @@ function CPRectEqualToRect(lhsRect, rhsRect)
CPSizeEqualToSize(lhsRect.size, rhsRect.size);
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetHeight(aRect)
@@ -269,9 +270,9 @@ function CPRectGetHeight(aRect)
return aRect.size.height;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetMaxX(aRect)
@@ -279,9 +280,9 @@ function CPRectGetMaxX(aRect)
return aRect.origin.x + aRect.size.width;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetMaxY(aRect)
@@ -289,9 +290,9 @@ function CPRectGetMaxY(aRect)
return aRect.origin.y + aRect.size.height;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return float
*/
function CPRectGetMidX(aRect)
@@ -299,9 +300,9 @@ function CPRectGetMidX(aRect)
return aRect.origin.x + (aRect.size.width) / 2.0;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return float
*/
function CPRectGetMidY(aRect)
@@ -309,9 +310,9 @@ function CPRectGetMidY(aRect)
return aRect.origin.y + (aRect.size.height) / 2.0;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetMinX(aRect)
@@ -319,9 +320,9 @@ function CPRectGetMinX(aRect)
return aRect.origin.x;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetMinY(aRect)
@@ -329,9 +330,9 @@ function CPRectGetMinY(aRect)
return aRect.origin.y;
}
/*
/*!
@group CGRect
@param aRect a <objj>CGRect</objj>
@param aRect a CGRect
@return int
*/
function CPRectGetWidth(aRect)
@@ -339,11 +340,11 @@ function CPRectGetWidth(aRect)
return aRect.size.width;
}
/*
/*!
Returns <code>YES</code> if the two rectangles intersect
@group CGRect
@param lhsRect the first <objj>CGRect</objj>
@param rhsRect the second <objj>CGRect</objj>
@param lhsRect the first CGRect
@param rhsRect the second CGRect
@return BOOL <code>YES</code> if the two rectangles have any common spaces, and <code>NO</code>, otherwise.
*/
function CPRectIntersectsRect(lhsRect, rhsRect)
@@ -351,34 +352,34 @@ function CPRectIntersectsRect(lhsRect, rhsRect)
return !CPRectIsEmpty(CPRectIntersection(lhsRect, rhsRect));
}
/*
Returns <code>YES</code> if the <objj>CGRect</objj> has no area.
/*!
Returns <code>YES</code> if the CGRect has no area.
The test is performed by checking if the width and height are both zero.
@group CGRect
@param aRect the <objj>CGRect</objj> to test
@return BOOL <code>YES</code> if the <objj>CGRect</objj> has no area, and <code>NO</code>, otherwise.
@param aRect the CGRect to test
@return BOOL <code>YES</code> if the CGRect has no area, and <code>NO</code>, otherwise.
*/
function CPRectIsEmpty(aRect)
{
return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}
/*
Returns <code>YES</code> if the <objj>CGRect</objj> has no area.
/*!
Returns <code>YES</code> if the CGRect has no area.
The test is performed by checking if the width and height are both zero.
@group CGRect
@return BOOL <code>YES</code> if the <objj>CGRect</objj> has no area, and <code>NO</code>, otherwise.
@return BOOL <code>YES</code> if the CGRect has no area, and <code>NO</code>, otherwise.
*/
function CPRectIsNull(aRect)
{
return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}
/*
Returns <code>YES</code> if the two <objj>CGSize</objj>s are identical.
/*!
Returns <code>YES</code> if the two CGSizes are identical.
@group CGSize
@param lhsSize the first <objj>CGSize</objj> to compare
@param rhsSize the second <objj>CGSize</objj> to compare
@param lhsSize the first CGSize to compare
@param rhsSize the second CGSize to compare
@return BOOL <code>YES</code> if the two sizes are identical. <code>NO</code>, otherwise.
*/
function CPSizeEqualToSize(lhsSize, rhsSize)
@@ -386,30 +387,30 @@ function CPSizeEqualToSize(lhsSize, rhsSize)
return lhsSize.width == rhsSize.width && lhsSize.height == rhsSize.height;
}
/*
Returns a human readable string of the provided <objj>CGPoint</objj>.
/*!
Returns a human readable string of the provided CGPoint.
@group CGPoint
@param aPoint the point to represent
@return CGPoint a string representation of the <objj>CGPoint</objj>
@return CGPoint a string representation of the CGPoint
*/
function CPStringFromPoint(aPoint)
{
return "{" + aPoint.x + ", " + aPoint.y + "}";
}
/*
Returns a human readable string of the provided <objj>CGSize</objj>.
/*!
Returns a human readable string of the provided CGSize.
@group CGSize
@param aSize the size to represent
@return CGSize a string representation of the <objj>CGSize</objj>
@return CGSize a string representation of the CGSize
*/
function CPStringFromSize(aSize)
{
return "{" + aSize.width + ", " + aSize.height + "}";
}
/*
Returns a human readable string of the provided <objj>CGRect</objj>.
/*!
Returns a human readable string of the provided CGRect.
@group CGRect
@param aRect the rectangle to represent
@return CGString the string representation of the rectangle
@@ -419,8 +420,8 @@ function CPStringFromRect(aRect)
return "{" + CPStringFromPoint(aRect.origin) + ", " + CPStringFromSize(aRect.size) + "}";
}
/*
Returns a <objj>CGPoint</objj> from a string with a comma separated pair of integers.
/*!
Returns a CGPoint from a string with a comma separated pair of integers.
@group CGPoint
@param aString a string containing two comma separated integers
@return CGPoint the point object created from the string
@@ -429,11 +430,11 @@ function CPPointFromString(aString)
{
var comma = aString.indexOf(',');
return { x:parseInt(aString.substr(1, comma - 1)), y:parseInt(aString.substring(comma + 1, aString.length)) };
return { x:parseFloat(aString.substr(1, comma - 1), 10), y:parseFloat(aString.substring(comma + 1, aString.length), 10) };
}
/*
Returns a <objj>CGSize</objj> from a string containing a pair of comma separated integers.
/*!
Returns a CGSize from a string containing a pair of comma separated integers.
@group CGSize
@param aString a string containing two comma separated integers
@return CGSize the size object created from the string
@@ -442,11 +443,11 @@ function CPSizeFromString(aString)
{
var comma = aString.indexOf(',');
return { width:parseInt(aString.substr(1, comma - 1)), height:parseInt(aString.substring(comma + 1, aString.length)) };
return { width:parseFloat(aString.substr(1, comma - 1), 10), height:parseFloat(aString.substring(comma + 1, aString.length), 10) };
}
/*
Returns a <objj>CGRect</objj> created from a string.
/*!
Returns a CGRect created from a string.
@group CGRect
@param aString a string in the form generated by <code>CPStringFromRect</code>
@return CGRect the rectangle created from the string
@@ -458,7 +459,7 @@ function CPRectFromString(aString)
return { origin:CPPointFromString(aString.substr(1, comma - 1)), size:CPSizeFromString(aString.substring(comma + 2, aString.length)) };
}
/*
/*!
@group CGPoint
@param anEvent
@return CGPoint
@@ -468,8 +469,8 @@ function CPPointFromEvent(anEvent)
return CPPointMake(anEvent.clientX, anEvent.clientY, 0);
}
/*
Returns a zero sized <objj>CGSize</objj>.
/*!
Returns a zero sized CGSize.
@group CGSize
@return CGSize a size object with zeros for <code>width</code> and <code>height</code>
*/
@@ -478,7 +479,7 @@ function CPSizeMakeZero()
return CPSizeMake(0, 0);
}
/*
/*!
Returns a rectangle at origin <code>(0,0)</code> and size of <code>(0,0)</code>.
@group CGRect
@return CGRect a zeroed out CGRect
@@ -488,7 +489,7 @@ function CPRectMakeZero()
return CPRectMake(0, 0, 0, 0);
}
/*
/*!
Returns a point located at <code>(0, 0)</code>.
@group CGPoint
@return CGPoint a point located at <code>(0, 0)</code>
+6 -6
View File
@@ -22,7 +22,7 @@
var CPGraphicsContextCurrent = nil;
/*
/*!
Provides an interface for drawing to the screen.
*/
@implementation CPGraphicsContext : CPObject
@@ -30,7 +30,7 @@ var CPGraphicsContextCurrent = nil;
CPContext _graphicsPort;
}
/*
/*!
Returns the current graphics context.
*/
+ (CPGraphicsContext)currentContext
@@ -38,7 +38,7 @@ var CPGraphicsContextCurrent = nil;
return CPGraphicsContextCurrent;
}
/*
/*!
Sets the current graphics context
*/
+ (void)setCurrentContext:(CPGraphicsContext)aGraphicsContext
@@ -46,7 +46,7 @@ var CPGraphicsContextCurrent = nil;
CPGraphicsContextCurrent = aGraphicsContext;
}
/*
/*!
Creates a graphics context with a provided port.
@param aContext the context to initialize with
@param aFlag whether the context should be flipped
@@ -57,7 +57,7 @@ var CPGraphicsContextCurrent = nil;
return [[self alloc] initWithGraphicsPort:aContext];
}
/*
/*!
Initializes the context with a graphics port.
@param aGraphicsPort the graphics port to initialize with
@return the initialized context
@@ -72,7 +72,7 @@ var CPGraphicsContextCurrent = nil;
return self;
}
/*
/*!
Returns the graphics context's port.
*/
- (CGContext)graphicsPort
+57 -30
View File
@@ -20,13 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPBundle.j>
import <Foundation/CPNotificationCenter.j>
import <Foundation/CPObject.j>
import <Foundation/CPRunLoop.j>
import <Foundation/CPString.j>
@import <Foundation/CPBundle.j>
@import <Foundation/CPNotificationCenter.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPRunLoop.j>
@import <Foundation/CPString.j>
import "CPGeometry.j"
@import "CPGeometry.j"
CPImageLoadStatusInitialized = 0;
CPImageLoadStatusLoading = 1;
@@ -42,15 +42,18 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
- (CPString)pathForResource:(CPString)aFilename
{
return [self bundlePath] + "Resources/" + aFilename;
return [self resourcePath] + '/' + aFilename;
}
@end
/*
<objj>CPImage</objj> is used to represent images in the Cappuccino framework. It supports loading
/*! @class CPImage
CPImage is used to represent images in the Cappuccino framework. It supports loading
all image types supported by the browser.
@par Delegate Methods
@delegate -(void)imageDidLoad:(CPImage)image;
Called when the specified image has finished loading.
@param image the image that loaded
@@ -74,7 +77,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
Image _image;
}
/*
/*!
Initializes the image, by associating it with a filename. The image
denoted in <code>aFilename</code> is not actually loaded. It will
be loaded once needed.
@@ -96,7 +99,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return self;
}
/*
/*!
Initializes the image. Loads the specified image into memory.
@param aFilename the image to load
@param aSize the size of the image
@@ -112,7 +115,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return self;
}
/*
/*!
Initializes the receiver with the contents of the specified
image file. The method loads the data into memory.
@param aFilename the file name of the image
@@ -128,7 +131,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return self;
}
/*
/*!
Returns the path of the file associated with this image.
*/
- (CPString)filename
@@ -136,7 +139,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return _filename;
}
/*
/*!
Sets the size of the image.
@param the size of the image
*/
@@ -145,7 +148,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
_size = CGSizeMakeCopy(aSize);
}
/*
/*!
Returns the size of the image
*/
- (CGSize)size
@@ -153,7 +156,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return _size;
}
/*
/*!
Sets the receiver's delegate.
@param the delegate
*/
@@ -162,7 +165,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
_delegate = aDelegate;
}
/*
/*!
Returns the receiver's delegate
*/
- (id)delegate
@@ -170,7 +173,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return _delegate;
}
/*
/*!
Returns <code>YES</code> if the image data has already been loaded.
*/
- (BOOL)loadStatus
@@ -178,11 +181,12 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return _loadStatus;
}
/*
/*!
Loads the image data from the file into memory. You
should not call this method directly. Instead use
one of the initializers.
*/
- (void)load
{
if (_loadStatus == CPImageLoadStatusLoading || _loadStatus == CPImageLoadStatusCompleted)
@@ -195,9 +199,38 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
var isSynchronous = YES;
// FIXME: We need a better/performance way of doing this.
_image.onload = function () { if (isSynchronous) window.setTimeout(function() { [self _imageDidLoad] }, 0); else [self _imageDidLoad]; }
_image.onerror = function () { if (isSynchronous) window.setTimeout(function() { [self _imageDidError] }, 0); else [self _imageDidError]; }
_image.onabort = function () { if (isSynchronous) window.setTimeout(function() { [self _imageDidAbort] }, 0); else [self _imageDidAbort]; }
_image.onload = function ()
{
if (isSynchronous)
window.setTimeout(function() { [self _imageDidLoad]; }, 0);
else
{
[self _imageDidLoad];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
}
_image.onerror = function ()
{
if (isSynchronous)
window.setTimeout(function() { [self _imageDidError]; }, 0);
else
{
[self _imageDidError];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
}
_image.onabort = function ()
{
if (isSynchronous)
window.setTimeout(function() { [self _imageDidAbort]; }, 0);
else
{
[self _imageDidAbort];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
}
_image.src = _filename;
@@ -229,8 +262,6 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
if ([_delegate respondsToSelector:@selector(imageDidLoad:)])
[_delegate imageDidLoad:self];
[[CPRunLoop currentRunLoop] performSelectors];
}
/* @ignore */
@@ -240,8 +271,6 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
if ([_delegate respondsToSelector:@selector(imageDidError:)])
[_delegate imageDidError:self];
[[CPRunLoop currentRunLoop] performSelectors];
}
/* @ignore */
@@ -251,15 +280,13 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
if ([_delegate respondsToSelector:@selector(imageDidAbort:)])
[_delegate imageDidAbort:self];
[[CPRunLoop currentRunLoop] performSelectors];
}
@end
@implementation CPImage (CPCoding)
/*
/*!
Initializes the image with data from a coder.
@param aCoder the coder from which to read the image data
@return the initialized image
@@ -269,7 +296,7 @@ CPImageDidLoadNotification = @"CPImageDidLoadNotification";
return [self initWithContentsOfFile:[aCoder decodeObjectForKey:@"CPFilename"] size:[aCoder decodeSizeForKey:@"CPSize"]];
}
/*
/*!
Writes the image data from memory into the coder.
@param aCoder the coder to which the data will be written
*/
+17 -16
View File
@@ -20,11 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPNotificationCenter.j>
@import <Foundation/CPNotificationCenter.j>
import "CPControl.j"
import "CPImage.j"
import "CPShadowView.j"
@import "CPControl.j"
@import "CPImage.j"
@import "CPShadowView.j"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
@@ -58,7 +58,8 @@ var LEFT_SHADOW_INSET = 3.0,
VERTICAL_SHADOW_INSET = TOP_SHADOW_INSET + BOTTOM_SHADOW_INSET,
HORIZONTAL_SHADOW_INSET = LEFT_SHADOW_INSET + RIGHT_SHADOW_INSET;
/*
/*! @class CPImageView
This class is a control that displays an image.
*/
@implementation CPImageView : CPControl
@@ -95,7 +96,7 @@ var LEFT_SHADOW_INSET = 3.0,
return self;
}
/*
/*!
Returns the view's image.
*/
- (CPImage)image
@@ -103,7 +104,7 @@ var LEFT_SHADOW_INSET = 3.0,
return _image;
}
/*
/*!
Sets the image for the view.
@param anImage the view's image
*/
@@ -144,7 +145,7 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
/*
/*!
Returns <code>YES</code> if the image view draws with
a drop shadow. The default is <code>NO</code>.
*/
@@ -153,7 +154,7 @@ var LEFT_SHADOW_INSET = 3.0,
return _hasShadow;
}
/*
/*!
Sets whether the image view should draw with a drop shadow.
@param shouldHaveShadow whether the image view should have a shadow
*/
@@ -182,7 +183,7 @@ var LEFT_SHADOW_INSET = 3.0,
[self hideOrDisplayContents];
}
/*
/*!
Sets the type of image scaling that should be used to
render the image.
@param anImageScaling the type of scaling to use
@@ -202,7 +203,7 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
/*
/*!
Returns the image scaling method used to
render this image.
*/
@@ -218,7 +219,7 @@ var LEFT_SHADOW_INSET = 3.0,
[self tile];
}
/*
/*!
Toggles the display of the image view.
*/
- (void)hideOrDisplayContents
@@ -235,7 +236,7 @@ var LEFT_SHADOW_INSET = 3.0,
}
}
/*
/*!
Returns the view's image rectangle
*/
- (CGRect)imageRect
@@ -243,7 +244,7 @@ var LEFT_SHADOW_INSET = 3.0,
return _imageRect;
}
/*
/*!
Add a description
*/
- (void)tile
@@ -328,7 +329,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
@implementation CPImageView (CPCoding)
/*
/*!
Initializes the image view with the provided coder.
@param aCoder the coder from which data will be read.
@return the initialized image view
@@ -358,7 +359,7 @@ var CPImageViewImageKey = @"CPImageViewImageKey",
return self;
}
/*
/*!
Writes the image view out to the coder.
@param aCoder the coder to which the image
view will be written
-372
View File
@@ -1,372 +0,0 @@
/*
* CPApplication.j
* AppKit
*
* Created by Ross Boucher.
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/Foundation.j>
import "CPView.j"
import "CPButton.j"
import "CPImage.j"
import "CPImageView.j"
import "CPColorPicker.j"
import "CPColorPanel.j"
import "CPTabView.j"
import "CPTabViewItem.j"
/*
@ignore
*/
@implementation CPKulerColorPicker : CPColorPicker
{
CPView _contentView;
CPTabView _tabView;
CPScrollView _searchView;
CPScrollView _popularView;
CPView _searchView;
DOMElement _FIXME_searchField;
CPURLConnection _searchConnection;
CPURLConnection _popularConnection
}
- (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel
{
return [super initWithPickerMask:mask colorPanel: owningColorPanel];
}
-(id)initView
{
aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
_contentView = [[CPView alloc] initWithFrame:aFrame];
_tabView = [[CPTabView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(aFrame), CGRectGetHeight(aFrame) - 20)];
[_tabView setAutoresizingMask: CPViewWidthSizable | CPViewHeightSizable];
[_tabView setDelegate: self];
[_contentView addSubview: _tabView];
var label = [[CPButton alloc] initWithFrame:CPRectMake((CPColorPickerViewWidth-150)/2, CPColorPickerViewHeight-20, 150, 20)];
[label setAutoresizingMask: CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin];
[label setFont:[CPFont boldSystemFontOfSize:10.0]];
[label setTextColor: [CPColor whiteColor]];
[label setTitle: @"Powered by Adobe Kuler"];
[label setTarget: self];
[label setAction: @selector(openKulerLink:)];
[label setBordered: NO];
[_contentView addSubview: label];
var searchThemeView = [[_CPKulerThemeView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, 0)];
[searchThemeView setDelegate: self];
[searchThemeView setAutoresizingMask: CPViewWidthSizable];
_searchView = [[CPScrollView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, CPColorPickerViewHeight - 10)];
[_searchView setDocumentView: searchThemeView];
[_searchView setHasHorizontalScroller: NO];
[_searchView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)];
[[_searchView verticalScroller] setControlSize:CPSmallControlSize];
[_searchView setAutohidesScrollers:YES];
var auxiliarySearchView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, CPColorPickerViewWidth, 26.0)];
[auxiliarySearchView setAutoresizingMask: (CPViewMinYMargin | CPViewWidthSizable)];
_FIXME_searchField = document.createElement("input");
if(!window.addEventListener)
_FIXME_searchField.type = "text";
else
_FIXME_searchField.type = "search";
_FIXME_searchField.style.position = "absolute";
_FIXME_searchField.style.width = "96%";
_FIXME_searchField.style.left = "2%";
_FIXME_searchField.style.top = "2px";
_FIXME_searchField.onkeypress = function(aDOMEvent)
{
aDOMEvent = aDOMEvent || window.event;
if (aDOMEvent.keyCode == 13)
{
[self search];
if(aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
else if(aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
_FIXME_searchField.blur();
}
};
auxiliarySearchView._DOMElement.appendChild(_FIXME_searchField);
var popularThemeView = [[_CPKulerThemeView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, 0)];
[popularThemeView setDelegate: self];
[popularThemeView setAutoresizingMask: CPViewWidthSizable];
_popularView = [[CPScrollView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, CPColorPickerViewHeight)];
[_popularView setDocumentView: popularThemeView];
[_popularView setHasHorizontalScroller: NO];
[_popularView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)];
[[_popularView verticalScroller] setControlSize:CPSmallControlSize];
[_popularView setAutohidesScrollers:YES];
var mostPopularItem = [[CPTabViewItem alloc] initWithIdentifier:@"Popular"];
var searchItem = [[CPTabViewItem alloc] initWithIdentifier:@"Search"];
[searchItem setLabel:@"Search"];
[searchItem setView:_searchView];
[searchItem setAuxiliaryView: auxiliarySearchView];
[mostPopularItem setLabel:@"Popular"];
[mostPopularItem setView: _popularView];
[_tabView addTabViewItem: mostPopularItem];
[_tabView addTabViewItem: searchItem];
[self popularThemes];
}
- (void)openKulerLink:(id)sender
{
window.open("http://kuler.adobe.com");
}
- (CPView)provideNewView:(BOOL)initialRequest
{
if (initialRequest)
[self initView];
return _contentView;
}
- (int)currentMode
{
return CPKulerColorPickerMode;
}
- (BOOL)supportsMode:(int)mode
{
return (mode == CPKulerColorPickerMode) ? YES : NO;
}
-(void)search
{
var query = escape(_FIXME_searchField.value);
if(query.replace("%20", "") == "")
return;
[_searchConnection cancel];
_searchConnection = nil;
_searchConnection = [CPURLConnection connectionWithRequest:
[CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=search&query="+query]
delegate: self];
}
-(void)popularThemes
{
[_popularConnection cancel];
_popularConnection = nil;
_popularConnection = [CPURLConnection connectionWithRequest:
[CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=popular"] delegate: self];
}
/*
-(void)topRatedThemes
{
_connection = [CPURLConnection connectionWithRequest:
[CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=rating"] delegate:self];
}
*/
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{
var data = CPJSObjectCreateWithJSON(data);
if(!data)
var themes = [];
else
var themes = data.result;
if(aConnection == _popularConnection)
[[_popularView documentView] setThemes: themes];
if(aConnection == _searchConnection)
[[_searchView documentView] setThemes: themes];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
{
[self connectionDidFinishLoading:aConnection];
}
-(void)connectionDidFinishLoading:(CPURLConnection)aConnection
{
}
-(void)chooseColor:(CPColor)aColor
{
[[self colorPanel] setColor: aColor];
}
@end
/* @ignore */
@implementation _CPKulerThemeView : CPView
{
CPArray _themes;
id _delegate;
CPColor _alternateBGColor;
}
-(id)initWithFrame:(CPRect)aFrame
{
self = [super initWithFrame:aFrame];
_alternateBGColor = [CPColor colorWithCalibratedRed: 241.0/255.0 green: 245.0/255.0 blue: 250.0/255.0 alpha: 1.0];
return self;
}
-(id)delegate
{
return _delegate;
}
-(void)setDelegate:(id)delegate
{
_delegate = delegate;
}
-(CPArray)themes
{
return _themes;
}
-(void)setThemes:(CPArray)themes
{
_themes = themes;
[self updateDisplay];
}
-(void)updateDisplay
{
var width = [self frame].size.width;
var subviews = [self subviews];
for(var i = [subviews count]-1; i >= 0; --i)
[subviews[i] removeFromSuperview];
for(var i=0, count = [_themes count]; i<count; i++)
{
var swatches = _themes[i].swatches;
var containerView = [[CPView alloc] initWithFrame: CPRectMake(0, 1+ 20*i, width, 20)];
[containerView setAutoresizingMask: CPViewWidthSizable];
for(var j=0; j<swatches.length; j++)
{
var outerView = [[CPView alloc] initWithFrame: CGRectMake(2+20*j, 1, 18, 18)],
innerView = [[_CPColorView alloc] initWithFrame: CGRectInset([outerView bounds], 1.0, 1.0)];
[innerView setTarget: self];
[innerView setAction: @selector(selectedColor:)];
[innerView setBackgroundColor: [CPColor colorWithHexString: swatches[j].hexColor]];
[outerView setBackgroundColor: [CPColor blackColor]];
[outerView addSubview: innerView];
[containerView addSubview: outerView];
}
var label = [[CPTextField alloc] initWithFrame: CPRectMake(102, 0, width - 102, 20)];
[label setStringValue: _themes[i].title];
[label setFont: [CPFont systemFontOfSize: 11.0]];
[label setLineBreakMode: CPLineBreakByTruncatingTail];
[label setAutoresizingMask: CPViewWidthSizable];
[containerView addSubview: label];
if(i%2 == 1)
[containerView setBackgroundColor: _alternateBGColor];
[self addSubview: containerView];
}
[self setFrameSize: CPSizeMake(width, (count)*20 + 2)];
}
-(void)selectedColor:(id)sender
{
[_delegate chooseColor:[sender backgroundColor]];
}
@end
/* @ignore */
@implementation _CPColorView : CPControl
{
}
-(id)initWithFrame:(CPRect)aFrame
{
self = [super initWithFrame: aFrame];
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPColorDragType]];
return self;
}
- (void)mouseDragged:(CPEvent)anEvent
{
[[CPPasteboard pasteboardWithName:CPDragPboard] declareTypes:[CPArray arrayWithObject:CPColorDragType] owner:self];
var bounds = CPRectMake(0, 0, 15, 15),
point = [self convertPoint:[anEvent locationInWindow] fromView:nil];
var outerView = [[CPView alloc] initWithFrame: bounds],
innerView = [[CPView alloc] initWithFrame: CGRectInset([outerView bounds], 1.0, 1.0)];
[innerView setBackgroundColor: [self backgroundColor]];
[outerView setBackgroundColor: [CPColor blackColor]];
[outerView addSubview: innerView];
[self dragView: outerView
at: CPPointMake(point.x - bounds.size.width / 2.0, point.y - bounds.size.height / 2.0)
offset: CPPointMake(0.0, 0.0)
event: anEvent
pasteboard: nil
source: self
slideBack: YES];
}
- (void)pasteboard:(CPPasteboard)aPasteboard provideDataForType:(CPString)aType
{
if(aType == CPColorDragType)
[aPasteboard setData:[self backgroundColor] forType:aType];
}
@end
+140 -64
View File
@@ -20,16 +20,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
import <Foundation/CPDictionary.j>
import <Foundation/CPNotificationCenter.j>
import <Foundation/CPString.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPNotificationCenter.j>
@import <Foundation/CPString.j>
import "_CPImageAndTitleView.j"
import "CPApplication.j"
import "CPClipView.j"
import "CPMenuItem.j"
import "CPPanel.j"
@import "CPApplication.j"
@import "CPClipView.j"
@import "CPMenuItem.j"
@import "CPPanel.j"
#include "Platform/Platform.h"
@@ -46,9 +45,11 @@ var _CPMenuBarVisible = NO,
_CPMenuBarTitle = @"",
_CPMenuBarIconImage = nil,
_CPMenuBarIconImageAlphaValue = 1.0,
_CPMenuBarAttributes = nil,
_CPMenuBarSharedWindow = nil;
/*
/*! @class CPMenu
Menus provide the user with a list of actions and/or submenus. Submenus themselves are full fledged menus and so a heirarchical structure appears.
*/
@implementation CPMenu : CPObject
@@ -92,6 +93,10 @@ var _CPMenuBarVisible = NO,
[_CPMenuBarSharedWindow setIconImage:_CPMenuBarIconImage];
[_CPMenuBarSharedWindow setIconImageAlphaValue:_CPMenuBarIconImageAlphaValue];
[_CPMenuBarSharedWindow setColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarBackgroundColor"]];
[_CPMenuBarSharedWindow setTextColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarTextColor"]];
[_CPMenuBarSharedWindow setTitleColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarTitleColor"]];
[_CPMenuBarSharedWindow orderFront:self];
}
else
@@ -125,6 +130,41 @@ var _CPMenuBarVisible = NO,
return _CPMenuBarImage;
}
+ (void)setMenuBarAttributes:(CPDictionary)attributes
{
if (_CPMenuBarAttributes == attributes)
return;
_CPMenuBarAttributes = [attributes copy];
var textColor = [attributes objectForKey:@"CPMenuBarTextColor"],
titleColor = [attributes objectForKey:@"CPMenuBarTitleColor"];
if (!textColor && titleColor)
[_CPMenuBarAttributes setObject:titleColor forKey:@"CPMenuBarTextColor"];
else if (textColor && !titleColor)
[_CPMenuBarAttributes setObject:textColor forKey:@"CPMenuBarTitleColor"];
else if (!textColor && !titleColor)
{
[_CPMenuBarAttributes setObject:[CPColor blackColor] forKey:@"CPMenuBarTextColor"];
[_CPMenuBarAttributes setObject:[CPColor blackColor] forKey:@"CPMenuBarTitleColor"];
}
if (_CPMenuBarSharedWindow)
{
[_CPMenuBarSharedWindow setColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarBackgroundColor"]];
[_CPMenuBarSharedWindow setTextColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarTextColor"]];
[_CPMenuBarSharedWindow setTitleColor:[_CPMenuBarAttributes objectForKey:@"CPMenuBarTitleColor"]];
}
}
+ (CPDictionary)menuBarAttributes
{
return _CPMenuBarAttributes;
}
+ (void)_setMenuBarIconImageAlphaValue:(float)anAlphaValue
{
_CPMenuBarIconImageAlphaValue = anAlphaValue;
@@ -140,7 +180,7 @@ var _CPMenuBarVisible = NO,
}
// Creating a CPMenu Object
/*
/*!
Initializes the menu with a specified title.
@param aTile the menu title
@return the initialized menu
@@ -162,7 +202,7 @@ var _CPMenuBarVisible = NO,
}
// Setting Up Menu Commands
/*
/*!
Inserts a menu item at the specified index.
@param aMenuItem the item to insert
@param anIndex the index in the menu to insert the item.
@@ -187,7 +227,7 @@ var _CPMenuBarVisible = NO,
}
/*
/*!
Creates and inserts a new menu item with the specified attributes.
@param aTitle the title of the menu item
@param anAction the action initiated when the user selects the item
@@ -204,7 +244,7 @@ var _CPMenuBarVisible = NO,
return item;
}
/*
/*!
Adds a menu item at the end of the menu.
@param aMenuItem the menu item to add
*/
@@ -213,7 +253,7 @@ var _CPMenuBarVisible = NO,
[self insertItem:aMenuItem atIndex:[_items count]];
}
/*
/*!
Creates and adds a menu item with the specified attributes
at the end of the menu.
@param aTitle the title of the new menu item
@@ -226,7 +266,7 @@ var _CPMenuBarVisible = NO,
return [self insertItemWithTitle:aTitle action:anAction keyEquivalent:aKeyEquivalent atIndex:[_items count]];
}
/*
/*!
Removes the specified item from the menu
@param aMenuItem the item to remove
*/
@@ -235,7 +275,7 @@ var _CPMenuBarVisible = NO,
[self removeItemAtIndex:[_items indexOfObjectIdenticalTo:aMenuItem]];
}
/*
/*!
Removes the item at the specified index from the menu
@param anIndex the index of the item to remove
*/
@@ -253,7 +293,7 @@ var _CPMenuBarVisible = NO,
userInfo:[CPDictionary dictionaryWithObject:anIndex forKey:@"CPMenuItemIndex"]];
}
/*
/*!
Called when a menu item has visually changed.
@param aMenuItem the item that changed
*/
@@ -269,7 +309,7 @@ var _CPMenuBarVisible = NO,
}
// Finding Menu Items
/*
/*!
Returns the menu item with the specified tag
@param the tag of the desired menu item
@return the menu item or <code>nil</code> if a match was not found
@@ -284,7 +324,7 @@ var _CPMenuBarVisible = NO,
return _items[index];
}
/*
/*!
Returns the menu item with the specified title.
@param aTitle the title of the menu item
@return the menu item or <code>nil</code> if a match was not found
@@ -299,7 +339,7 @@ var _CPMenuBarVisible = NO,
return _items[index];
}
/*
/*!
Returns the menu item at the specified index
@param anIndex the index of the requested item
*/
@@ -308,7 +348,7 @@ var _CPMenuBarVisible = NO,
return [_items objectAtIndex:anIndex];
}
/*
/*!
Returns the number of menu items in the menu
*/
- (unsigned)numberOfItems
@@ -316,7 +356,7 @@ var _CPMenuBarVisible = NO,
return [_items count];
}
/*
/*!
Returns the array of menu items backing this menu
*/
- (CPArray)itemArray
@@ -325,10 +365,10 @@ var _CPMenuBarVisible = NO,
}
// Finding Indices of Menu Items
/*
/*!
Returns the index of the specified menu item
@param aMenuItem the item to find the index for
@return the item index or <objj>CPNotFound</objj>
@return the item index or CPNotFound
*/
- (int)indexOfItem:(CPMenuItem)aMenuItem
{
@@ -338,10 +378,10 @@ var _CPMenuBarVisible = NO,
return [_items indexOfObjectIdenticalTo:aMenuItem];
}
/*
/*!
Returns the index of the item with the specified title.
@param aTitle the desired title to match
@return the index of the item or <objj>CPNotFound</objj>
@return the index of the item or CPNotFound
*/
- (int)indexOfItemWithTitle:(CPString)aTitle
{
@@ -355,10 +395,10 @@ var _CPMenuBarVisible = NO,
return CPNotFound;
}
/*
/*!
Returns the index of the item with the specified tag
@param aTag the desired tag to match
@return the index of the item or <objj>CPNotFound</objj>
@return the index of the item or CPNotFound
*/
- (int)indexOfItemWithTag:(int)aTag
{
@@ -372,11 +412,11 @@ var _CPMenuBarVisible = NO,
return CPNotFound;
}
/*
/*!
Returns the index of the item with the specified target and action.
@param aTarget the target of the desired menu item
@param anAction the action of the desired menu item
@return the index of the item or <objj>CPNotFound</objj>
@return the index of the item or CPNotFound
*/
- (int)indexOfItemWithTarget:(id)aTarget andAction:(SEL)anAction
{
@@ -394,10 +434,10 @@ var _CPMenuBarVisible = NO,
return CPNotFound;
}
/*
/*!
Returns the index of the menu item with the specified represented object.
@param anObject the represented object of the desired item
@return the index of the item or <objj>CPNotFound</objj>
@return the index of the item or CPNotFound
*/
- (int)indexOfItemWithRepresentedObject:(id)anObject
{
@@ -411,10 +451,10 @@ var _CPMenuBarVisible = NO,
return CPNotFound;
}
/*
/*!
Returns the index of the item with the specified submenu.
@param the submenu of the desired menu item
@return the index of the item or <objj>CPNotFound</objj>
@return the index of the item or CPNotFound
*/
- (int)indexOfItemWithSubmenu:(CPMenu)aMenu
{
@@ -429,7 +469,7 @@ var _CPMenuBarVisible = NO,
}
// Managing Submenus
/*
/*!
Sets a submenu for a menu item
@param aMenu the submenu
@param aMenuItem the menu item to set the submenu on
@@ -442,7 +482,7 @@ var _CPMenuBarVisible = NO,
[aMenuItem setSubmenu:aMenu];
}
/*
/*!
The action method of menu items that open submenus.
The default implementation does nothing, but it may
be subclassed to provide different behavior.
@@ -453,7 +493,7 @@ var _CPMenuBarVisible = NO,
}
/*
/*!
Returns the attaced menu, or <code>nil</code> if there isn't one.
*/
- (CPMenu)attachedMenu
@@ -461,7 +501,7 @@ var _CPMenuBarVisible = NO,
return _attachedMenu;
}
/*
/*!
Returns <code>YES</code> if the menu is attached to another menu.
*/
- (BOOL)isAttached
@@ -469,7 +509,7 @@ var _CPMenuBarVisible = NO,
return _isAttached;
}
/*
/*!
Not yet implemented
*/
- (CGPoint)locationOfSubmenu:(CPMenu)aMenu
@@ -477,7 +517,7 @@ var _CPMenuBarVisible = NO,
// FIXME: IMPLEMENT.
}
/*
/*!
Returns the super menu or <code>nil</code> if there is none.
*/
- (CPMenu)supermenu
@@ -485,7 +525,7 @@ var _CPMenuBarVisible = NO,
return _supermenu;
}
/*
/*!
Sets the super menu.
@param aMenu the new super menu
*/
@@ -494,7 +534,7 @@ var _CPMenuBarVisible = NO,
_supermenu = aMenu;
}
/*
/*!
If there are two instances of this menu visible, return <code>NO</code>.
Otherwise, return <code>YES</code> if we are a detached menu and visible.
*/
@@ -504,7 +544,7 @@ var _CPMenuBarVisible = NO,
}
// Enabling and Disabling Menu Items
/*
/*!
Sets whether the menu automatically enables menu items.
@param aFlag <code>YES</code> sets the menu to automatically enable items.
*/
@@ -513,7 +553,7 @@ var _CPMenuBarVisible = NO,
_autoenablesItems = aFlag;
}
/*
/*!
Returns <code>YES</code> if the menu auto enables items.
*/
- (BOOL)autoenablesItems
@@ -521,7 +561,7 @@ var _CPMenuBarVisible = NO,
return _autoenablesItems;
}
/*
/*!
Not implemented.
*/
- (void)update
@@ -530,7 +570,7 @@ var _CPMenuBarVisible = NO,
}
// Managing the Title
/*
/*!
Sets the menu title.
@param the new title
*/
@@ -539,7 +579,7 @@ var _CPMenuBarVisible = NO,
_title = aTitle;
}
/*
/*!
Returns the menu title
*/
- (CPString)title
@@ -607,7 +647,7 @@ var _CPMenuBarVisible = NO,
}
// Managing Display of State Column
/*
/*!
Sets whether to show the state column
@param shouldShowStateColumn <code>YES</code> shows the state column
*/
@@ -616,7 +656,7 @@ var _CPMenuBarVisible = NO,
_showsStateColumn = shouldShowStateColumn;
}
/*
/*!
Returns <code>YES</code> if the menu shows the state column
*/
- (BOOL)showsStateColumn
@@ -625,7 +665,7 @@ var _CPMenuBarVisible = NO,
}
// Handling Highlighting
/*
/*!
Returns the currently highlighted menu item.
@return the highlighted menu item or <code>nil</code> if no item is currently highlighted
*/
@@ -647,7 +687,7 @@ var _CPMenuBarVisible = NO,
}
// Handling Tracking
/*
/*!
Cancels tracking.
*/
- (void)cancelTracking
@@ -661,7 +701,7 @@ var _CPMenuBarVisible = NO,
_menuWindow = aMenuWindow;
}
/*
/*!
Initiates the action of the menu item that
has a keyboard shortcut equivalent to <code>anEvent</code>
@param anEvent the keyboard event
@@ -703,7 +743,7 @@ var _CPMenuBarVisible = NO,
}
// Simulating Mouse Clicks
/*
/*!
Sends the action of the menu item at the specified index.
@param anIndex the index of the item
*/
@@ -747,7 +787,7 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
@implementation CPMenu (CPCoding)
/*
/*!
Initializes the menu with data from the specified coder.
@param aCoder the coder from which to read the data
@return the initialized menu
@@ -765,7 +805,7 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
return self;
}
/*
/*!
Encodes the data of the menu into a coder
@param aCoder the coder to which the data will be written
*/
@@ -1154,6 +1194,9 @@ var STICKY_TIME_INTERVAL = 500,
if (_trackingCanceled)
{
// Stop all periodic events at this point.
[CPEvent stopPeriodicEvents];
var highlightedItem = [[_menuView menu] highlightedItem];
[menu _highlightItemAtIndex:CPNotFound];
@@ -1311,6 +1354,9 @@ var _CPMenuBarWindowBackgroundColor = nil,
CPImageView _iconImageView;
CPTextField _titleField;
CPColor _textColor;
CPColor _titleColor;
}
+ (void)initialize
@@ -1320,8 +1366,6 @@ var _CPMenuBarWindowBackgroundColor = nil,
var bundle = [CPBundle bundleForClass:self];
_CPMenuBarWindowBackgroundColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"_CPMenuBarWindow/_CPMenuBarWindowBackground.png"] size:CGSizeMake(1.0, 18.0)]];
_CPMenuBarWindowFont = [CPFont systemFontOfSize:11.0];
}
@@ -1339,7 +1383,6 @@ var _CPMenuBarWindowBackgroundColor = nil,
var contentView = [self contentView];
[contentView setBackgroundColor:_CPMenuBarWindowBackgroundColor];
[contentView setAutoresizesSubviews:NO];
[self setBecomesKeyOnlyIfNeeded:YES];
@@ -1349,11 +1392,9 @@ var _CPMenuBarWindowBackgroundColor = nil,
[contentView addSubview:_iconImageView];
_titleField = [[_CPImageAndTitleView alloc] initWithFrame:CGRectMakeZero()];
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_titleField setFont:[CPFont boldSystemFontOfSize:12.0]];
[_titleField setImagePosition:CPImageLeft];
[_titleField setAlignment:CPCenterTextAlignment];
[contentView addSubview:_titleField];
@@ -1375,7 +1416,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
document.title = bundleName;
#endif
[_titleField setTitle:aTitle];
[_titleField setStringValue:aTitle];
[_titleField sizeToFit];
[self tile];
@@ -1394,6 +1435,39 @@ var _CPMenuBarWindowBackgroundColor = nil,
[_iconImageView setAlphaValue:anAlphaValue];
}
- (void)setColor:(CPColor)aColor
{
if (!aColor)
{
if (!_CPMenuBarWindowBackgroundColor)
_CPMenuBarWindowBackgroundColor = [CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[_CPMenuBarWindow class]] pathForResource:@"_CPMenuBarWindow/_CPMenuBarWindowBackground.png"] size:CGSizeMake(1.0, 18.0)]];
[[self contentView] setBackgroundColor:_CPMenuBarWindowBackgroundColor];
}
else
[[self contentView] setBackgroundColor:aColor];
}
- (void)setTextColor:(CPColor)aColor
{
if (_textColor == aColor)
return;
_textColor = aColor;
[_menuItemViews makeObjectsPerformSelector:@selector(setTextColor:) withObject:_textColor];
}
- (void)setTitleColor:(CPColor)aColor
{
if (_titleColor == aColor)
return;
_titleColor = aColor;
[_titleField setTextColor:aColor ? aColor : [CPColor blackColor]];
}
- (void)setMenu:(CPMenu)aMenu
{
if (_menu == aMenu)
@@ -1464,6 +1538,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
[menuItemView setShowsStateColumn:NO];
[menuItemView setBelongsToMenuBar:YES];
[menuItemView setFont:_CPMenuBarWindowFont];
[menuItemView setTextColor:_textColor];
[menuItemView setHidden:[item isHidden]];
[menuItemView synchronizeWithMenuItem];
@@ -1496,6 +1571,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
[menuItemView setShowsStateColumn:NO];
[menuItemView setBelongsToMenuBar:YES];
[menuItemView setFont:_CPMenuBarWindowFont];
[menuItemView setTextColor:_textColor];
[menuItemView setHidden:[menuItem isHidden]];
[menuItemView synchronizeWithMenuItem];
@@ -1566,7 +1642,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
{
var type = [anEvent type];
if (type == CPPeriodic)
if (type === CPPeriodic)
return [self showMenu:anEvent];
var frame = [self frameForMenuItem:_trackingMenuItem],
+157 -108
View File
@@ -20,16 +20,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPCoder.j>
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPCoder.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
import <AppKit/CPImage.j>
import <AppKit/CPMenu.j>
import <AppKit/CPView.j>
@import <AppKit/CPImage.j>
@import <AppKit/CPMenu.j>
@import <AppKit/CPView.j>
/*
A <objj>CPMenuItem</objj> is added to a <objj>CPMenu</objj>.
/*! @class CPMenuItem
A CPMenuItem is added to a CPMenu.
It has an action and a target for that action to be sent to
whenever the item is 'activated'.
*/
@@ -73,7 +74,7 @@ import <AppKit/CPView.j>
_CPMenuItemView _menuItemView;
}
/*
/*!
Initializes the menu item with a title, action, and keyboard equivalent.
@param aTitle the menu item's title
@param anAction the action that gets triggered when the item is selected
@@ -93,7 +94,7 @@ import <AppKit/CPView.j>
_state = CPOffState;
_keyEquivalent = aKeyEquivalent;
_keyEquivalent = aKeyEquivalent || @"";
_keyEquivalentModifierMask = CPPlatformActionKeyMask;
_mnemonicLocation = CPNotFound;
@@ -103,7 +104,7 @@ import <AppKit/CPView.j>
}
// Enabling a Menu Item
/*
/*!
Sets whether the menu item is enabled or not
@param isEnabled <code>YES</code> enables the item. <code>NO</code> disables it.
*/
@@ -119,7 +120,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns <code>YES</code> if the item is enabled.
*/
- (BOOL)isEnabled
@@ -128,16 +129,21 @@ import <AppKit/CPView.j>
}
// Managing Hidden Status
/*
/*!
Sets whether the item should be hidden. A hidden item can not be triggered by keyboard shortcuts.
@param isHidden <code>YES</code> hides the item. <code>NO</code> reveals it.
*/
- (void)setHidden:(BOOL)isHidden
{
if (_isHidden == isHidden)
return;
_isHidden = isHidden;
[_menu itemChanged:self];
}
/*
/*!
Returns <code>YES</code> if the item is hidden.
*/
- (BOOL)isHidden
@@ -145,7 +151,7 @@ import <AppKit/CPView.j>
return _isHidden;
}
/*
/*!
Returns <code>YES</code> if the item is hidden or if one of it's supermenus is hidden.
*/
- (BOOL)isHiddenOrHasHiddenAncestor
@@ -153,14 +159,16 @@ import <AppKit/CPView.j>
if (_isHidden)
return YES;
if ([[[_menu supermenu] indexOfItemWithSubmenu:_menu] isHiddenOrHasHiddenAncestor])
var supermenu = [_menu supermenu];
if ([[supermenu itemAtIndex:[supermenu indexOfItemWithSubmenu:_menu]] isHiddenOrHasHiddenAncestor])
return YES;
return NO;
}
// Managing Target and Action
/*
/*!
Sets the menu item's action target.
@param aTarget the target for the action
*/
@@ -169,7 +177,7 @@ import <AppKit/CPView.j>
_target = aTarget;
}
/*
/*!
Returns the item's action target
*/
- (id)target
@@ -177,7 +185,7 @@ import <AppKit/CPView.j>
return _target;
}
/*
/*!
Sets the action that gets sent to the item's target when triggered.
@param anAction the action to send
*/
@@ -186,7 +194,7 @@ import <AppKit/CPView.j>
_action = anAction;
}
/*
/*!
Returns the item's action.
*/
- (SEL)action
@@ -195,7 +203,7 @@ import <AppKit/CPView.j>
}
// Managing the Title
/*
/*!
Sets the item's title.
@param aTitle the item's new title
*/
@@ -213,7 +221,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the menu item's title.
*/
- (CPString)title
@@ -221,7 +229,7 @@ import <AppKit/CPView.j>
return _title;
}
/*
/*!
Sets the font for the text of this menu item
@param aFont the font for the menu item
*/
@@ -237,7 +245,7 @@ import <AppKit/CPView.j>
[_menuItemView setDirty];
}
/*
/*!
Returns the menu item's font
*/
- (CPFont)font
@@ -256,7 +264,7 @@ import <AppKit/CPView.j>
*/
// Managing the Tag
/*
/*!
Sets the menu item's tag
@param aTag the tag for the item
*/
@@ -265,7 +273,7 @@ import <AppKit/CPView.j>
_tag = aTag;
}
/*
/*!
Returns the item's tag
*/
- (int)tag
@@ -273,12 +281,12 @@ import <AppKit/CPView.j>
return _tag;
}
/*
/*!
Sets the state of the menu item. Possible states are:
<pre>
<objj>CPMixedState</objj>
<objj>CPOnState</objj>
<objj>CPOffState</objj>
CPMixedState
CPOnState
CPOffState
</pre>
*/
- (void)setState:(int)aState
@@ -293,12 +301,12 @@ import <AppKit/CPView.j>
[_menuItemView setDirty];
}
/*
/*!
Returns the menu item's current state. Possible states are:
<pre>
<objj>CPMixedState</objj>
<objj>CPOnState</objj>
<objj>CPOffState</objj>
CPMixedState
CPOnState
CPOffState
</pre>
*/
- (int)state
@@ -307,7 +315,7 @@ import <AppKit/CPView.j>
}
// Managing the Image
/*
/*!
Sets the menu item's image
@param anImage the menu item's image
*/
@@ -323,7 +331,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the menu item's image
*/
- (CPImage)image
@@ -331,7 +339,7 @@ import <AppKit/CPView.j>
return _image;
}
/*
/*!
Sets the menu item's alternate image
@param anImage the menu item's alternate image
*/
@@ -340,7 +348,7 @@ import <AppKit/CPView.j>
_alternateImage = anImage;
}
/*
/*!
Returns the menu item's alternate image
*/
- (CPImage)alternateImage
@@ -348,7 +356,7 @@ import <AppKit/CPView.j>
return _alternateImage;
}
/*
/*!
Sets the image that is shown when the
menu item is in the 'on' state.
@param anImage the image to show
@@ -362,7 +370,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the image shown when the menu item is in the 'on' state.
*/
- (CPImage)onStateImage
@@ -370,7 +378,7 @@ import <AppKit/CPView.j>
return _onStateImage;
}
/*
/*!
Sets the image that is shown when the menu item is in the 'off' state.
@param anImage the image to show
*/
@@ -383,7 +391,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the image shown when the menu item is in the 'off' state.
*/
- (CPImage)offStateImage
@@ -391,7 +399,7 @@ import <AppKit/CPView.j>
return _offStateImage;
}
/*
/*!
Sets the image that is shown when the menu item is in the 'mixed' state.
@param anImage the image to show
*/
@@ -404,7 +412,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the image shown when the menu item is
in the 'mixed' state.
*/
@@ -414,7 +422,7 @@ import <AppKit/CPView.j>
}
// Managing Subemenus
/*
/*!
Sets the submenu for this item
@param aMenu the submenu
*/
@@ -437,7 +445,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the submenu of the item. <code>nil</code> if there is no submenu.
*/
- (CPMenu)submenu
@@ -445,7 +453,7 @@ import <AppKit/CPView.j>
return _submenu;
}
/*
/*!
Returns <code>YES</code> if the menu item has a submenu.
*/
- (BOOL)hasSubmenu
@@ -455,7 +463,7 @@ import <AppKit/CPView.j>
// Getting a Separator Item
/*
/*!
Returns a new menu item separator.
*/
+ (CPMenuItem)separatorItem
@@ -463,7 +471,7 @@ import <AppKit/CPView.j>
return [[_CPMenuItemSeparator alloc] init];
}
/*
/*!
Returns <code>YES</code> if the menu item is a separator.
*/
- (BOOL)isSeparatorItem
@@ -472,7 +480,7 @@ import <AppKit/CPView.j>
}
// Managing the Owning Menu
/*
/*!
Set the container menu of this item.
@param aMenu the item's container menu
*/
@@ -481,7 +489,7 @@ import <AppKit/CPView.j>
_menu = aMenu;
}
/*
/*!
Returns the container menu of this item
*/
- (CPMenu)menu
@@ -491,16 +499,16 @@ import <AppKit/CPView.j>
//
/*
/*!
Sets the keyboard shortcut for this menu item
@param aString the keyboard shortcut
*/
- (void)setKeyEquivalent:(CPString)aString
{
_keyEquivalent = aString;
_keyEquivalent = aString || @"";
}
/*
/*!
Returns the keyboard shortcut for this menu item
*/
- (CPString)keyEquivalent
@@ -508,14 +516,14 @@ import <AppKit/CPView.j>
return _keyEquivalent;
}
/*
/*!
Sets the modifier mask used for the item's keyboard shortcut.
Can be a combination of:
<pre>
<objj>CPShiftKeyMask</objj>
<objj>CPAlternateKeyMask</objj>
<objj>CPCommandKeyMask</objj>
<objj>CPControlKeyMask</objj>
CPShiftKeyMask
CPAlternateKeyMask
CPCommandKeyMask
CPControlKeyMask
</pre>
*/
- (void)setKeyEquivalentModifierMask:(unsigned)aMask
@@ -523,14 +531,14 @@ import <AppKit/CPView.j>
_keyEquivalentModifierMask = aMask;
}
/*
/*!
Returns the item's keyboard shortcut modifier mask.
Can be a combination of:
<pre>
<objj>CPShiftKeyMask</objj>
<objj>CPAlternateKeyMask</objj>
<objj>CPCommandKeyMask</objj>
<objj>CPControlKeyMask</objj>
CPShiftKeyMask
CPAlternateKeyMask
CPCommandKeyMask
CPControlKeyMask
</pre>
*/
- (unsigned)keyEquivalentModifierMask
@@ -539,7 +547,7 @@ import <AppKit/CPView.j>
}
// Managing Mnemonics
/*
/*!
Sets the index of the mnemonic character in the title. The character
will be underlined and is used as a shortcut for navigation.
@param aLocation the index of the character in the title
@@ -549,7 +557,7 @@ import <AppKit/CPView.j>
_mnemonicLocation = aLocation;
}
/*
/*!
Returns the index of the mnemonic character in the title.
*/
- (unsigned)mnemonicLocation
@@ -557,7 +565,7 @@ import <AppKit/CPView.j>
return _mnemonicLocation;
}
/*
/*!
Sets the title of the menu item and the mnemonic character. The mnemonic chracter should be preceded by an '&'.
@param aTitle the title string with a denoted mnemonic
*/
@@ -574,7 +582,7 @@ import <AppKit/CPView.j>
}
}
/*
/*!
Returns the menu items mnemonic character
*/
- (CPString)mnemonic
@@ -584,7 +592,7 @@ import <AppKit/CPView.j>
// Managing Alternates
/*
/*!
Sets whether this item is an alternate for the previous menu item.
@param isAlternate <code>YES</code> denotes that this menu item is an alternate
*/
@@ -593,7 +601,7 @@ import <AppKit/CPView.j>
_isAlternate = isAlternate;
}
/*
/*!
Returns <code>YES</code> if the menu item is an alternate for the previous item.
*/
- (BOOL)isAlternate
@@ -603,7 +611,7 @@ import <AppKit/CPView.j>
// Managing Indentation Levels
/*
/*!
Sets the indentation level of the menu item. Must be a value between 0 and 15 (inclusive).
@param aLevel the item's new indentation level
@throws CPInvalidArgumentException if aLevel is less than 0
@@ -616,7 +624,7 @@ import <AppKit/CPView.j>
_indentationLevel = MIN(15, aLevel);
}
/*
/*!
Returns the menu item's indentation level. This is a value between 0 and 15 (inclusive).
*/
- (unsigned)indentationLevel
@@ -625,7 +633,7 @@ import <AppKit/CPView.j>
}
// Managing Tool Tips
/*
/*!
Sets the tooltip for the menu item.
@param aToolTip the tool tip for the item
*/
@@ -634,7 +642,7 @@ import <AppKit/CPView.j>
_toolTip = aToolTip;
}
/*
/*!
Returns the item's tooltip
*/
- (CPString)toolTip
@@ -644,7 +652,7 @@ import <AppKit/CPView.j>
// Representing an Object
/*
/*!
Sets the menu item's represented object. This is a kind of tag for the developer. Not a UI feature.
@param anObject the represented object
*/
@@ -653,7 +661,7 @@ import <AppKit/CPView.j>
_representedObject = anObject;
}
/*
/*!
Returns the item's represented object.
*/
- (id)representedObject
@@ -663,7 +671,7 @@ import <AppKit/CPView.j>
// Managing the View
/*
/*!
Sets the view for the menu item
@param aView the menu's item's view
*/
@@ -679,7 +687,7 @@ import <AppKit/CPView.j>
[_menu itemChanged:self];
}
/*
/*!
Returns the menu item's view
*/
- (CPView)view
@@ -689,7 +697,7 @@ import <AppKit/CPView.j>
// Getting Highlighted Status
/*
/*!
Returns <code>YES</code> if the menu item is highlighted.
*/
- (BOOL)isHighlighted
@@ -745,7 +753,7 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
CPMenuItemRepresentedObjectKey = @"CPMenuItemRepresentedObjectKey";
@implementation CPMenuItem (CPCoding)
/*
/*!
Initializes the menu item from a coder.
@param aCoder the coder from which to initialize
@return the initialized menu item
@@ -796,7 +804,7 @@ var CPMenuItemTitleKey = @"CPMenuItemTitleKey",
return self;
}
/*
/*!
Writes the menu item out to a coder.
@param aCoder the coder to write the menu item out to
*/
@@ -829,10 +837,7 @@ var LEFT_MARGIN = 3.0,
var _CPMenuItemSelectionColor = nil,
_CPMenuItemDefaultStateImages = [],
_CPMenuItemDefaultStateHighlightedImages = [],
_CPMenuItemViewMenuBarArrowImage = nil,
_CPMenuItemViewMenuBarArrowActivatedImage = nil;
_CPMenuItemDefaultStateHighlightedImages = [];
/*
@ignore
@@ -842,6 +847,7 @@ var _CPMenuItemSelectionColor = nil,
CPMenuItem _menuItem;
CPFont _font;
CPColor _textColor;
CGSize _minSize;
BOOL _isDirty;
@@ -850,7 +856,7 @@ var _CPMenuItemSelectionColor = nil,
CPImageView _stateView;
_CPImageAndTitleView _imageAndTitleView;
CPImageView _submenuImageView;
CPView _submenuView;
}
+ (void)initialize
@@ -922,8 +928,8 @@ var _CPMenuItemSelectionColor = nil,
[_stateView removeFromSuperview];
_stateView = nil;
[_submenuImageView removeFromSuperview];
_submenuImageView = nil;
[_submenuView removeFromSuperview];
_submenuView = nil;
_minSize = [view frame].size;
@@ -984,11 +990,11 @@ var _CPMenuItemSelectionColor = nil,
if (!font)
font = _font;
[_imageAndTitleView setFont:font];
[_imageAndTitleView setImage:[_menuItem image]];
[_imageAndTitleView setTitle:[_menuItem title]];
[_imageAndTitleView setTextColor:[_menuItem isEnabled] ? [CPColor blackColor] : [CPColor darkGrayColor]];
[_imageAndTitleView setTextColor:[self textColor]];
[_imageAndTitleView setFrameOrigin:CGPointMake(x, 0.0)];
[_imageAndTitleView sizeToFit];
@@ -1000,24 +1006,21 @@ var _CPMenuItemSelectionColor = nil,
// Submenu Arrow
if ([_menuItem hasSubmenu])
{
if (!_submenuImageView)
if (!_submenuView)
{
_submenuImageView = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)];
_submenuView = [[_CPMenuItemArrowView alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)];
[self addSubview:_submenuImageView];
[self addSubview:_submenuView];
}
if (_belongsToMenuBar && !_CPMenuItemViewMenuBarArrowImage)
_CPMenuItemViewMenuBarArrowImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[_CPMenuItemView class]] pathForResource:@"_CPMenuItemView/_CPMenuItemViewMenuBarArrow.png"] size:CGSizeMake(10.0, 10.0)];
[_submenuImageView setHidden:NO];
[_submenuImageView setImage:_belongsToMenuBar ? _CPMenuItemViewMenuBarArrowImage : nil];
[_submenuImageView setFrameOrigin:CGPointMake(x, (CGRectGetHeight(frame) - 10.0) / 2.0)];
[_submenuView setHidden:NO];
[_submenuView setColor:_belongsToMenuBar ? [self textColor] : nil];
[_submenuView setFrameOrigin:CGPointMake(x, (CGRectGetHeight(frame) - 10.0) / 2.0)];
x += 10.0;
}
else
[_submenuImageView setHidden:YES];
[_submenuView setHidden:YES];
_minSize = CGSizeMake(x + (_belongsToMenuBar ? 0.0 : RIGHT_MARGIN), CGRectGetHeight(frame));
@@ -1051,7 +1054,7 @@ var _CPMenuItemSelectionColor = nil,
else
{
[_imageAndTitleView setTextColor:shouldHighlight ? [CPColor whiteColor] : [CPColor blackColor]];
[_imageAndTitleView setTextColor:shouldHighlight ? [CPColor whiteColor] : [self textColor]];
if (shouldHighlight)
[self setBackgroundColor:_CPMenuItemSelectionColor];
@@ -1078,16 +1081,13 @@ var _CPMenuItemSelectionColor = nil,
if (shouldActivate)
{
if (!_CPMenuItemViewMenuBarArrowActivatedImage)
_CPMenuItemViewMenuBarArrowActivatedImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[_CPMenuItemView class]] pathForResource:@"_CPMenuItemView/_CPMenuItemViewMenuBarArrowActivated.png"] size:CGSizeMake(10.0, 10.0)];
[_imageAndTitleView setTextColor:[CPColor whiteColor]];
[_submenuImageView setImage:_CPMenuItemViewMenuBarArrowActivatedImage];
[_submenuView setColor:[CPColor whiteColor]];
}
else
{
[_imageAndTitleView setTextColor:[CPColor blackColor]];
[_submenuImageView setImage:_CPMenuItemViewMenuBarArrowImage];
[_imageAndTitleView setTextColor:[self textColor]];
[_submenuView setColor:[self textColor]];
}
}
@@ -1096,7 +1096,7 @@ var _CPMenuItemSelectionColor = nil,
if (![_menuItem hasSubmenu])
return NO;
return CGRectContainsPoint([_submenuImageView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]);
return CGRectContainsPoint([_submenuView frame], [self convertPoint:[anEvent locationInWindow] fromView:nil]);
}
- (BOOL)isHidden
@@ -1119,5 +1119,54 @@ var _CPMenuItemSelectionColor = nil,
[self setDirty];
}
- (void)setTextColor:(CPColor)aColor
{
if (_textColor == aColor)
return;
_textColor = aColor;
[_imageAndTitleView setTextColor:[self textColor]];
[_submenuView setColor:[self textColor]];
}
- (CPColor)textColor
{
return [_menuItem isEnabled] ? (_textColor ? _textColor : [CPColor blackColor]) : [CPColor darkGrayColor];
}
@end
@implementation _CPMenuItemArrowView : CPView
{
CPColor _color;
}
- (void)setColor:(CPColor)aColor
{
if (_color == aColor)
return;
_color = aColor;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextBeginPath(context);
CGContextMoveToPoint(context, 1.0, 4.0);
CGContextAddLineToPoint(context, 9.0, 4.0);
CGContextAddLineToPoint(context, 5.0, 8.0);
CGContextAddLineToPoint(context, 1.0, 4.0);
CGContextClosePath(context);
CGContextSetFillColor(context, _color);
CGContextFillPath(context);
}
@end
+8 -8
View File
@@ -20,11 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPTableView.j"
@import "CPTableView.j"
/*
/*!
@ignore
This class is a subclass of <objj>CPTableView</objj> which provides the user with a way to display
This class is a subclass of CPTableView which provides the user with a way to display
tree structured data in an outline format. It is particularly useful for displaying hierarchical data
such as a class inheritance tree or any other set of relationships.
*/
@@ -48,14 +48,14 @@ import "CPTableView.j"
return self;
}
/*
/*!
@ignore
Sets the outline's data source. The data source must implement the following methods:
<pre>
- (id)outlineView:(<objj>CPOutlineView</objj>)outlineView child:(int)index ofItem:(id)item
- (BOOL)outlineView:(<objj>CPOutlineView</objj>)outlineView isItemExpandable:(id)item
- (int)outlineView:(<objj>CPOutlineView</objj>)outlineView numberOfChildrenOfItem:(id)item
- (id)outlineView:(<objj>CPOutlineView</objj>)outlineView objectValueForTableColumn:(<objj>CPTableColumn</objj>)tableColumn byItem:(id)item
- (id)outlineView:(CPOutlineView)outlineView child:(int)index ofItem:(id)item
- (BOOL)outlineView:(CPOutlineView)outlineView isItemExpandable:(id)item
- (int)outlineView:(CPOutlineView)outlineView numberOfChildrenOfItem:(id)item
- (id)outlineView:(CPOutlineView)outlineView objectValueForTableColumn:(CPTableColumn)tableColumn byItem:(id)item
</pre>
@param aDataSource the outline's data source
@throws CPInternalInconsistencyException if the data source does not implement all the required methods
+9 -8
View File
@@ -20,14 +20,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPWindow.j"
@import "CPWindow.j"
CPOKButton = 1;
CPCancelButton = 0;
/*
The <objj>CPPanel</objj> class defines objects that manage the panels of the Cappuccino user interface. A panel is a window that serves an auxiliary function within an application. It generally displays controls that the user can act on to give instructions to the application or to modify the contents of a standard window.</p>
/*! @class CPPanel
The CPPanel class defines objects that manage the panels of the Cappuccino user interface. A panel is a window that serves an auxiliary function within an application. It generally displays controls that the user can act on to give instructions to the application or to modify the contents of a standard window.</p>
<p>Panels behave differently from standard windows in only a small number of ways, but the ways are important to the user interface:</p>
@@ -49,7 +50,7 @@ CPCancelButton = 0;
BOOL _worksWhenModal;
}
/*
/*!
Returns <code>YES</code> if the receiver is a floating panel (like a palette).
*/
- (BOOL)isFloatingPanel
@@ -57,7 +58,7 @@ CPCancelButton = 0;
return [self level] == CPFloatingWindowLevel;
}
/*
/*!
Sets the receiver to be a floating panel. <code>YES</code>
makes the window a floating panel. <code>NO</code> makes it a normal window.
@param isFloatingPanel specifies whether to make it floating
@@ -67,7 +68,7 @@ CPCancelButton = 0;
[self setLevel:isFloatingPanel ? CPFloatingWindowLevel : CPNormalWindowLevel];
}
/*
/*!
Returns <code>YES</code> if the window only becomes key
if needed. <code>NO</code> means it behaves just like other windows.
*/
@@ -76,7 +77,7 @@ CPCancelButton = 0;
return _becomesKeyOnlyIfNeeded;
}
/*
/*!
Sets whether the the window becomes key only if needed.
@param shouldBecomeKeyOnlyIfNeeded <code>YES</code> makes the window become key only if needed
*/
@@ -90,7 +91,7 @@ CPCancelButton = 0;
return _worksWhenModal;
}
/*
/*!
Sets whether this window can receive input while another window is running modally.
@param shouldWorkWhenModal whether to receive input while another window is modal
*/
+20 -19
View File
@@ -20,10 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPArray.j>
import <Foundation/CPDictionary.j>
import <Foundation/CPPropertyListSerialization.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPPropertyListSerialization.j>
CPGeneralPboard = @"CPGeneralPboard";
@@ -42,8 +42,9 @@ CPImagePboardType = @"CPImagePboardType";
var CPPasteboards = nil;
/*
<objj>CPPasteBoard</objj> is the object responsible for cut/copy/paste and drag&drop operations.
/*! @class CPPasteboard
CPPasteBoard is the object responsible for cut/copy/paste and drag&drop operations.
*/
@implementation CPPasteboard : CPObject
{
@@ -68,7 +69,7 @@ var CPPasteboards = nil;
CPPasteboards = [CPDictionary dictionary];
}
/*
/*!
Returns a new instance of a pasteboard
*/
+ (id)generalPasteboard
@@ -76,7 +77,7 @@ var CPPasteboards = nil;
return [CPPasteboard pasteboardWithName:CPGeneralPboard];
}
/*
/*!
Returns a pasteboard with the specified name. If the pasteboard doesn't exist, it will be created.
@param aName the name of the pasteboard
@return the requested pasteboard
@@ -113,7 +114,7 @@ var CPPasteboards = nil;
return self;
}
/*
/*!
Adds supported data types to the pasteboard
@param types the data types
@param anOwner the object that contains the data types
@@ -140,7 +141,7 @@ var CPPasteboards = nil;
return ++_changeCount;
}
/*
/*!
Sets the data types that this pasteboard will contain.
@param type the data types it will support
@param anOwner the object that contains the the data
@@ -161,7 +162,7 @@ var CPPasteboards = nil;
return ++_changeCount;
}
/*
/*!
Sets the pasteboard data for the specified type
@param aData the data
@param aType the data type being set
@@ -174,7 +175,7 @@ var CPPasteboards = nil;
return YES;
}
/*
/*!
Writes the specified property list as data for the specified type
@param aPropertyList the property list to write
@param aType the data type
@@ -185,7 +186,7 @@ var CPPasteboards = nil;
return [self setData:[CPPropertyListSerialization dataFromPropertyList:aPropertyList format:CPPropertyListXMLFormat_v1_0 errorDescription:nil] forType:aType];
}
/*
/*!
Sets the specified string as data for the specified type
@param aString the string to write
@param aType the data type
@@ -197,7 +198,7 @@ var CPPasteboards = nil;
}
// Determining Types
/*
/*!
Checks the pasteboard's types for a match with the types listen in the specified array. The array should
be ordered by the requestor's most preferred data type first.
@param anArray an array of requested types ordered by preference
@@ -208,7 +209,7 @@ var CPPasteboards = nil;
return [_types firstObjectCommonWithArray:anArray];
}
/*
/*!
Returns the pasteboards supported types
*/
- (CPArray)types
@@ -217,7 +218,7 @@ var CPPasteboards = nil;
}
// Reading data
/*
/*!
Returns the number of changes that have occurred to this pasteboard
*/
- (unsigned)changeCount
@@ -225,7 +226,7 @@ var CPPasteboards = nil;
return _changeCount;
}
/*
/*!
Returns the pasteboard data for the specified data type
@param aType the requested data type
@return the requested data or <code>nil</code> if the data doesn't exist
@@ -251,7 +252,7 @@ var CPPasteboards = nil;
return nil;
}
/*
/*!
Returns the property list for the specified data type
@param aType the requested data type
@return the property list or <code>nil</code> if the list was not found
@@ -266,7 +267,7 @@ var CPPasteboards = nil;
return nil;
}
/*
/*!
Returns the string for the specified data type
@param aType the requested data type
@return the string or <code>nil</code> if the string was not found
+56 -58
View File
@@ -20,18 +20,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPButton.j"
import "CPGeometry.j"
import "CPMenu.j"
import "CPMenuItem.j"
@import "CPButton.j"
@import "CPGeometry.j"
@import "CPMenu.j"
@import "CPMenuItem.j"
var VISIBLE_MARGIN = 7.0;
var CPPopUpButtonArrowsImage = nil;
/*
A <objj>CPPopUpButton</objj> contains a pop-up menu of items that a user can select from.
/*! @class CPPopUpButton
A CPPopUpButton contains a pop-up menu of items that a user can select from.
*/
@implementation CPPopUpButton : CPButton
{
@@ -44,7 +45,7 @@ var CPPopUpButtonArrowsImage = nil;
CPMenu _menu;
}
/*
/*!
Initializes the pop-up button to the specified size.
@param aFrame the size for the button
@param shouldPullDown <code>YES</code> makes this a pull-down menu, <code>NO</code> makes it a pop-up menu.
@@ -105,7 +106,7 @@ var CPPopUpButtonArrowsImage = nil;
// Setting the Type of Menu
/*
/*!
Specifies whether the object is a pull-down or a pop-up menu.
@param shouldPullDown <code>YES</code> makes the pop-up button
a pull-down menu. <code>NO</code> makes it a pop-up menu.
@@ -127,7 +128,7 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
/*
/*!
Returns <code>YES</code> if the button is a pull-down menu. <code>NO</code> if the button is a pop-up menu.
*/
- (BOOL)pullsDown
@@ -136,7 +137,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Inserting and Deleting Items
/*
/*!
Adds a new menu item with the specified title.
@param the new menu item's tite
*/
@@ -145,7 +146,7 @@ var CPPopUpButtonArrowsImage = nil;
[_menu addItemWithTitle:aTitle action:NULL keyEquivalent:NULL];
}
/*
/*!
Adds multiple new menu items with the titles specified in the provided array.
@param titles an arry of names for the new items
*/
@@ -158,7 +159,7 @@ var CPPopUpButtonArrowsImage = nil;
[self addItemWithTitle:titles[index]];
}
/*
/*!
Inserts a new item with the specified title and index location.
@param aTitle the new itme's title
@param anIndex the item's index in the menu
@@ -175,7 +176,7 @@ var CPPopUpButtonArrowsImage = nil;
[_menu insertItemWithTitle:aTitle action:NULL keyEquivalent:NULL atIndex:anIndex];
}
/*
/*!
Removes all menu items from the pop-up button's menu
*/
- (void)removeAllItems
@@ -186,7 +187,7 @@ var CPPopUpButtonArrowsImage = nil;
[_menu removeItemAtIndex:0];
}
/*
/*!
Removes a menu item with the specified title from the button.
@param aTitle the title of the item to remove
*/
@@ -196,7 +197,7 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
/*
/*!
Removes the menu item at the specified index
@param anIndex the index of the item to remove
*/
@@ -207,7 +208,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Getting the User's Selection
/*
/*!
Returns the selected item or <code>nil</code> if no item is selected.
*/
- (CPMenuItem)selectedItem
@@ -218,7 +219,7 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu itemAtIndex:_selectedIndex];
}
/*
/*!
Returns the title of the selected item or <code>nil</code> if no item is selected.
*/
- (CPString)titleOfSelectedItem
@@ -226,8 +227,8 @@ var CPPopUpButtonArrowsImage = nil;
return [[self selectedItem] title];
}
/*
Returns the index of the selected item. If no item is selected, it returns <objj>CPNotFound</objj>.
/*!
Returns the index of the selected item. If no item is selected, it returns CPNotFound.
*/
- (int)indexOfSelectedItem
{
@@ -235,8 +236,8 @@ var CPPopUpButtonArrowsImage = nil;
}
// For us, CPNumber is toll-free bridged to Number, so just return the selected index.
/*
Returns the selected item's index. If no item is selected, it returns <objj>CPNotFound</objj>.
/*!
Returns the selected item's index. If no item is selected, it returns CPNotFound.
*/
- (id)objectValue
{
@@ -244,7 +245,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Setting the Current Selection
/*
/*!
Selects the specified menu item.
@param aMenuItem the item to select
*/
@@ -253,7 +254,7 @@ var CPPopUpButtonArrowsImage = nil;
[self selectItemAtIndex:[self indexOfItem:aMenuItem]];
}
/*
/*!
Selects the item at the specified index
@param anIndex the index of the item to select
*/
@@ -273,7 +274,7 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
/*
/*!
Selects the menu item with the specified tag
@param the tag of the item to select
*/
@@ -282,7 +283,7 @@ var CPPopUpButtonArrowsImage = nil;
[self selectItemAtIndex:[self indexOfItemWithTag:aTag]];
}
/*
/*!
Selects the item with the specified title
@param the title of the item to select
*/
@@ -291,7 +292,7 @@ var CPPopUpButtonArrowsImage = nil;
[self selectItemAtIndex:[self indexOfItemWithTitle:aTitle]];
}
/*
/*!
Sets the object for the selected item. If no item is selected, then this method has no effect.
@param the object set for the selected item
*/
@@ -301,7 +302,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Getting Menu Items
/*
/*!
Returns the button's menu of items.
*/
- (CPMenu)menu
@@ -309,7 +310,7 @@ var CPPopUpButtonArrowsImage = nil;
return _menu;
}
/*
/*!
Sets the menu for the button
*/
- (void)setMenu:(CPMenu)aMenu
@@ -323,19 +324,16 @@ var CPPopUpButtonArrowsImage = nil;
{
[defaultCenter
removeObserver:self
selector:@selector(menuDidAddItem:)
name:CPMenuDidAddItemNotification
object:_menu];
[defaultCenter
removeObserver:self
selector:@selector(menuDidChangeItem:)
name:CPMenuDidChangeItemNotification
object:_menu];
[defaultCenter
removeObserver:self
selector:@selector(menuDidRemoveItem:)
name:CPMenuDidRemoveItemNotification
object:_menu];
}
@@ -366,7 +364,7 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
/*
/*!
Returns a count of the number of items in the button's menu.
*/
- (int)numberOfItems
@@ -374,7 +372,7 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu numberOfItems];
}
/*
/*!
Returns an array of the items in the menu
*/
- (CPArray)itemArray
@@ -382,7 +380,7 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu itemArray];
}
/*
/*!
Returns the item at the specified index or <code>nil</code> if the item does not exist.
@param anIndex the index of the item to obtain
*/
@@ -391,7 +389,7 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu itemAtIndex:anIndex];
}
/*
/*!
Returns the title of the item at the specified index or <code>nil</code> if no item exists.
@param anIndex the index of the item
*/
@@ -400,7 +398,7 @@ var CPPopUpButtonArrowsImage = nil;
return [[_menu itemAtIndex:anIndex] title];
}
/*
/*!
Returns an array of all the menu item titles.
*/
- (CPArray)itemTitles
@@ -415,7 +413,7 @@ var CPPopUpButtonArrowsImage = nil;
items.push([items[index] title]);
}
/*
/*!
Returns the menu item with the specified title.
@param aTitle the title of the desired menu item
*/
@@ -424,7 +422,7 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu itemAtIndex:[_menu indexOfItemWithTitle:aTitle]];
}
/*
/*!
Returns the last menu item
*/
- (CPMenuItem)lastItem
@@ -433,8 +431,8 @@ var CPPopUpButtonArrowsImage = nil;
}
// Getting the Indices of Menu Items
/*
Returns the index of the specified item or <objj>CPNotFound</objj> if the item is not in the list.
/*!
Returns the index of the specified item or CPNotFound if the item is not in the list.
@param aMenuItem the item to obtain the index for
*/
- (int)indexOfItem:(CPMenuItem)aMenuItem
@@ -442,8 +440,8 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu indexOfItem:aMenuItem];
}
/*
Returns the index of the item with the specified tag or <objj>CPNotFound</objj> if the item is not in the list.
/*!
Returns the index of the item with the specified tag or CPNotFound if the item is not in the list.
@param aTag the item's tag
*/
- (int)indexOfItemWithTag:(int)aTag
@@ -451,8 +449,8 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu indexOfItemWithTag:aMenuItem];
}
/*
Returns the index of the item with the specified title or <objj>CPNotFound</objj>.
/*!
Returns the index of the item with the specified title or CPNotFound.
@param aTitle the item's titel
*/
- (int)indexOfItemWithTitle:(CPString)aTitle
@@ -460,9 +458,9 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu indexOfItemWithTitle:aTitle];
}
/*
/*!
Returns the index of the item with the specified
represented object or <objj>CPNotFound</objj>
represented object or CPNotFound
if a match does not exist.
@param anObject the item's represented object
*/
@@ -471,9 +469,9 @@ var CPPopUpButtonArrowsImage = nil;
return [_menu indexOfItemWithRepresentedObejct:anObject];
}
/*
/*!
Returns the index of the item with the specified target
and action. Returns <objj>CPNotFound</objj> if the no
and action. Returns CPNotFound if the no
such item is in the list.
@param aTarget the item's target
@param anAction the item's action
@@ -484,7 +482,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Setting the Cell Edge to Pop out in Restricted Situations
/*
/*!
Returns the button's edge where the pop-up menu will be
displayed when there is not enough room to display directly
above the button.
@@ -494,7 +492,7 @@ var CPPopUpButtonArrowsImage = nil;
return _preferredEdge;
}
/*
/*!
Sets the preffered edge of the button to display the
pop-up when there is a limited amount of screen space.
By default, the pop-up should draw on top of the button.
@@ -505,7 +503,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Setting the Title
/*
/*!
Sets the pop-up button's title.
@param aTitle the new title
*/
@@ -535,7 +533,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Setting the Image
/*
/*!
This method has no effect. Because the image is taken
from the currently selected item, this method serves
no purpose.
@@ -546,7 +544,7 @@ var CPPopUpButtonArrowsImage = nil;
}
// Setting the State
/*
/*!
Makes sure the selected item and the item
being displayed are one and the same.
*/
@@ -569,7 +567,7 @@ var CPPopUpButtonArrowsImage = nil;
}
//
/*
/*!
Called when the menu has a new item added to it.
@param aNotification information about the event
*/
@@ -597,7 +595,7 @@ var CPPopUpButtonArrowsImage = nil;
}
}
/*
/*!
Called when a menu item has changed.
@param aNotification information about the event
*/
@@ -614,7 +612,7 @@ var CPPopUpButtonArrowsImage = nil;
[self synchronizeTitleAndSelectedItem];
}
/*
/*!
Called when an item was removed from the menu.
@param aNotification information about the event
*/
@@ -706,7 +704,7 @@ var CPPopUpButtonMenuKey = @"CPPopUpButtonMenuKey",
CPPopUpButtonPullsDownKey = @"CPPopUpButtonPullsDownKey";
@implementation CPPopUpButton (CPCoding)
/*
/*!
Initializes the pop-up button with data from the
specified coder.
@param aCoder the coder from which to read
@@ -727,7 +725,7 @@ var CPPopUpButtonMenuKey = @"CPPopUpButtonMenuKey",
return self;
}
/*
/*!
Encodes the data of the pop-up button into a coder
@param aCoder the coder to which the data
will be written
+26 -24
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <AppKit/CGGeometry.j>
import <AppKit/CPImageView.j>
import <AppKit/CPView.j>
@import <AppKit/CGGeometry.j>
@import <AppKit/CPImageView.j>
@import <AppKit/CPView.j>
#include "CoreGraphics/CGGeometry.h"
/*
@global
@group CPProgressIndicatorStyle
@@ -48,7 +49,8 @@ var CPProgressIndicatorSpinningStyleColors = nil,
CPProgressIndicatorStyleIdentifiers = nil,
CPProgressIndicatorStyleSizes = nil;
/*
/*! @class CPProgressIndicator
This class is used in a Cappuccino GUI to display the progress of a
function or task. If the duration of the task is unknown, there is
also an indeterminate mode for the indicator.
@@ -178,7 +180,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
{
}
/*
/*!
Starts the animation of the progress indicator in indeterminate mode.
@param the requesting object
*/
@@ -189,7 +191,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self _hideOrDisplay];
}
/*
/*!
Stops the animation of the progress indicator in indeterminate mode.
@param the requesting object
*/
@@ -200,7 +202,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self _hideOrDisplay];
}
/*
/*!
Always returns <code>NO</code>. Cappuccino does not have multiple threads.
*/
- (BOOL)usesThreadedAnimation
@@ -209,7 +211,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
}
// Advancing the Progress Bar
/*
/*!
Increases the progress of the bar by the specified value.
@param aValue the amount to increase the progress value
*/
@@ -218,7 +220,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self setDoubleValue:_doubleValue + aValue];
}
/*
/*!
Sets the progress value of the indicator.
*/
- (void)setDoubleValue:(double)aValue
@@ -228,7 +230,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self drawBar];
}
/*
/*!
Returns the value of the progress indicator.
*/
- (double)doubleValue
@@ -236,7 +238,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
return _doubleValue;
}
/*
/*!
Sets the minimum value of the progress indicator. The default is 0.0.
@param aValue the new minimum value
*/
@@ -245,7 +247,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
_minValue = aValue;
}
/*
/*!
Returns the minimum value of the progress indicator.
*/
- (double)minValue
@@ -253,7 +255,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
return _minValue;
}
/*
/*!
Sets the maximum value of the progress indicator. The default is 100.0.
@param aValue the new maximum value.
*/
@@ -262,7 +264,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
_maxValue = aValue;
}
/*
/*!
Returns the maximum value of the progress indicator.
*/
- (double)maxValue
@@ -271,7 +273,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
}
// Setting the Appearance
/*
/*!
Sets the progress indicator's size.
@param aControlSize the new size
*/
@@ -285,7 +287,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
/*
/*!
Returns the progress indicator's size
*/
- (CPControlSize)controlSize
@@ -323,13 +325,13 @@ var CPProgressIndicatorSpinningStyleColors = nil,
return YES;
}
/*
/*!
Specifies whether this progress indicator should be indeterminate or display progress based on it's max and min.
@param isDeterminate <code>YES</code> makes the indicator indeterminate
*/
- (void)setIndeterminate:(BOOL)isIndeterminate
{
if (_indeterminate == isIndeterminate)
if (_isIndeterminate == isIndeterminate)
return;
_isIndeterminate = isIndeterminate;
@@ -337,7 +339,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
/*
/*!
Returns <code>YES</code> if the progress bar is indeterminate.
*/
- (BOOL)isIndeterminate
@@ -345,7 +347,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
return _isIndeterminate;
}
/*
/*!
Sets the progress indicator's style
@param aStyle the style to set it to
*/
@@ -359,7 +361,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self updateBackgroundColor];
}
/*
/*!
Resizes the indicator based on it's style.
*/
- (void)sizeToFit
@@ -372,9 +374,9 @@ var CPProgressIndicatorSpinningStyleColors = nil,
_CPControlIdentifierForControlSize(_controlSize)][0].height)];
}
/*
/*!
Sets whether the indicator should be displayed when it isn't animating. By default this is <code>YES</code> if the style
is <objj>CPProgressIndicatorBarStyle</objj>, and <code>NO</code> if it's <objj>CPProgressIndicatorSpinningStyle</objj>.
is CPProgressIndicatorBarStyle, and <code>NO</code> if it's CPProgressIndicatorSpinningStyle.
@param isDisplayedWhenStopped <code>YES</code> means the indicator will be displayed when it's not animating.
*/
- (void)setDisplayedWhenStopped:(BOOL)isDisplayedWhenStopped
@@ -389,7 +391,7 @@ var CPProgressIndicatorSpinningStyleColors = nil,
[self _hideOrDisplay];
}
/*
/*!
Returns <code>YES</code> if the progress bar is displayed when not animating.
*/
- (BOOL)isDisplayedWhenStopped
+31 -25
View File
@@ -20,7 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
CPDeleteKeyCode = 8;
CPUpArrowKeyCode = 63232;
@@ -28,6 +29,11 @@ CPDownArrowKeyCode = 63233;
CPLeftArrowKeyCode = 63234;
CPRightArrowKeyCode = 63235;
/*!
@class CPResponder
Subclasses of CPResonder can be part of the responder chain.
*/
@implementation CPResponder : CPObject
{
CPMenu _menu;
@@ -35,7 +41,7 @@ CPRightArrowKeyCode = 63235;
}
// Changing the first responder
/*
/*!
Returns <code>YES</code> if the receiver is able to become the first responder. <code>NO</code> otherwise.
*/
- (BOOL)acceptsFirstResponder
@@ -43,7 +49,7 @@ CPRightArrowKeyCode = 63235;
return NO;
}
/*
/*!
Notifies the receiver that it will become the first responder. The receiver can reject first
responder if it returns <code>NO</code>. The default implementation always returns <code>YES</code>.
@return <code>YES</code> if the receiver accepts first responder status.
@@ -53,7 +59,7 @@ CPRightArrowKeyCode = 63235;
return YES;
}
/*
/*!
Notifies the receiver that it has been asked to give up first responder status.
@return <code>YES</code> if the receiver is willing to give up first responder status.
*/
@@ -63,7 +69,7 @@ CPRightArrowKeyCode = 63235;
}
// Setting the next responder
/*
/*!
Sets the receiver's next responder.
@param aResponder the responder after the receiver
*/
@@ -72,7 +78,7 @@ CPRightArrowKeyCode = 63235;
_nextResponder = aResponder;
}
/*
/*!
Returns the responder after the receiver.
*/
- (CPResponder)nextResponder
@@ -80,9 +86,9 @@ CPRightArrowKeyCode = 63235;
return _nextResponder;
}
/*
/*!
Called to interpret a series of key events.
@param events an array of key <objj>CPEvent</objj>s
@param events an array of key CPEvents
*/
- (void)interpretKeyEvents:(CPArray)events
{
@@ -111,7 +117,7 @@ CPRightArrowKeyCode = 63235;
}
}
/*
/*!
Notifies the receiver that the user has clicked the mouse down in its area.
@param anEvent contains information about the click
*/
@@ -120,7 +126,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the user has initiated a drag
over it. A drag is a mouse movement while the left button is down.
@param anEvent contains information about the drag
@@ -130,7 +136,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the user has released the left mouse button.
@param anEvent contains information about the release
*/
@@ -139,7 +145,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the user has moved the mouse (with no buttons down).
@param anEvent contains information about the movement
*/
@@ -153,7 +159,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the mouse exited the receiver's area.
@param anEvent contains information about the exit
*/
@@ -162,7 +168,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the mouse scroll wheel has moved.
@param anEvent information about the scroll
*/
@@ -171,7 +177,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the user has pressed a key.
@param anEvent information about the key press
*/
@@ -180,7 +186,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder performSelector:_cmd withObject:anEvent];
}
/*
/*!
Notifies the receiver that the user has released a key.
@param anEvent information about the key press
*/
@@ -201,7 +207,7 @@ CPRightArrowKeyCode = 63235;
}
// Action Methods
/*
/*!
Deletes one character backward, or the selection if anything is selected.
@param aSender the object requesting this
*/
@@ -209,7 +215,7 @@ CPRightArrowKeyCode = 63235;
{
}
/*
/*!
Insert a line break at the caret position or selection.
@param aSender the object requesting this
*/
@@ -217,7 +223,7 @@ CPRightArrowKeyCode = 63235;
{
}
/*
/*!
Inserts some text at the caret position or selection.
@param aString the string to insert
*/
@@ -226,7 +232,7 @@ CPRightArrowKeyCode = 63235;
}
// Dispatch methods
/*
/*!
The receiver will attempt to perform the command,
if it responds to it. If not, the <code>nextResponder</code> will be called to do it.
@param aSelector the command to attempt
@@ -239,7 +245,7 @@ CPRightArrowKeyCode = 63235;
[_nextResponder doCommandBySelector:aSelector];
}
/*
/*!
The receiver will attempt to perform the command, or pass it on to the next responder if it doesn't respond to it.
@param aSelector the command to perform
@param anObject the argument to the method
@@ -271,7 +277,7 @@ CPRightArrowKeyCode = 63235;
}
// Getting the Undo Manager
/*
/*!
Returns the undo manager for the receiver.
*/
- (CPUndoManager)undoManager
@@ -280,7 +286,7 @@ CPRightArrowKeyCode = 63235;
}
// Terminating the responder chain
/*
/*!
Called when an event finds no suitable responder.
@param anEventSelector the command that failed
*/
@@ -294,7 +300,7 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey";
@implementation CPResponder (CPCoding)
/*
/*!
Initializes the responder with data from a coder.
@param aCoder the coder from which data will be read
@return the initialized responder
@@ -309,7 +315,7 @@ var CPResponderNextResponderKey = @"CPResponderNextResponderKey";
return self;
}
/*
/*!
Archives the responder to a coder.
@param aCoder the coder to which the responder will be archived
*/
+57 -65
View File
@@ -20,14 +20,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPView.j"
import "CPClipView.j"
import "CPScroller.j"
@import "CPView.j"
@import "CPClipView.j"
@import "CPScroller.j"
#include "CoreGraphics/CGGeometry.h"
/*
Used to display views that are too large for the viewing area. the <objj>CPScrollView</objj>
/*! @class CPScrollView
Used to display views that are too large for the viewing area. the CPScrollView
places scroll bars on the side of the view to allow the user to scroll and see the entire
contents of the view.
*/
@@ -74,7 +76,7 @@ import "CPScroller.j"
}
// Determining component sizes
/*
/*!
Returns the size of the scroll view's content view.
*/
- (CGRect)contentSize
@@ -82,7 +84,7 @@ import "CPScroller.j"
return [_contentView frame].size;
}
/*
/*!
Returns the view that is scrolled for the user.
*/
- (id)documentView
@@ -90,7 +92,7 @@ import "CPScroller.j"
return [_contentView documentView];
}
/*
/*!
Sets the content view that clips the document
@param aContentView the content view
*/
@@ -116,7 +118,7 @@ import "CPScroller.j"
[self addSubview:_contentView];
}
/*
/*!
Returns the content view that clips the document.
*/
- (CPClipView)contentView
@@ -124,7 +126,7 @@ import "CPScroller.j"
return _contentView;
}
/*
/*!
Sets the view that is scrolled for the user.
@param aView the view that will be scrolled
*/
@@ -134,9 +136,8 @@ import "CPScroller.j"
[self reflectScrolledClipView:_contentView];
}
/*
Resizes the scroll view to contain the specified
clip view.
/*!
Resizes the scroll view to contain the specified clip view.
@param aClipView the clip view to resize to
*/
- (void)reflectScrolledClipView:(CPClipView)aClipView
@@ -231,7 +232,7 @@ import "CPScroller.j"
}
// Managing Scrollers
/*
/*!
Sets the scroll view's horizontal scroller.
@param aScroller the horizontal scroller for the scroll view
*/
@@ -254,7 +255,7 @@ import "CPScroller.j"
[self reflectScrolledClipView:_contentView];
}
/*
/*!
Returns the scroll view's horizontal scroller
*/
- (CPScroller)horizontalScroller
@@ -262,7 +263,7 @@ import "CPScroller.j"
return _horizontalScroller;
}
/*
/*!
Specifies whether the scroll view can have a horizontal scroller.
@param hasHorizontalScroller <code>YES</code> lets the scroll view
allocate a horizontal scroller if necessary.
@@ -285,16 +286,15 @@ import "CPScroller.j"
}
}
/*
Returns <code>YES</code> if the scroll view can have a horizontal
scroller.
/*!
Returns <code>YES</code> if the scroll view can have a horizontal scroller.
*/
- (BOOL)hasHorizontalScroller
{
return _hasHorizontalScroller;
}
/*
/*!
Sets the scroll view's vertical scroller.
@param aScroller the vertical scroller
*/
@@ -317,7 +317,7 @@ import "CPScroller.j"
[self reflectScrolledClipView:_contentView];
}
/*
/*!
Return's the scroll view's vertical scroller
*/
- (CPScroller)verticalScroller
@@ -325,7 +325,7 @@ import "CPScroller.j"
return _verticalScroller;
}
/*
/*!
Specifies whether the scroll view has can have
a vertical scroller. It allocates it if necessary.
@param hasVerticalScroller <code>YES</code> allows
@@ -349,26 +349,30 @@ import "CPScroller.j"
}
}
/*
Returns <code>YES</code> if the scroll view can have
a vertical scroller.
/*!
Returns <code>YES</code> if the scroll view can have a vertical scroller.
*/
- (BOOL)hasHorizontalScroller
{
return _hasHorizontalScroller;
}
/*
/*!
Sets whether the scroll view hides its scoll bars when not needed.
@param autohidesScrollers <code>YES</code> causes the scroll bars
to be hidden when not needed.
*/
- (void)setAutohidesScrollers:(BOOL)autohidesScrollers
{
if (_autohidesScrollers == autohidesScrollers)
return;
_autohidesScrollers = autohidesScrollers;
[self reflectScrolledClipView:_contentView];
}
/*
/*!
Returns <code>YES</code> if the scroll view hides its scroll
bars when not necessary.
*/
@@ -442,7 +446,7 @@ import "CPScroller.j"
[_contentView scrollToPoint:contentBounds.origin];
}
/*
/*!
Lays out the scroll view's components.
*/
- (void)tile
@@ -462,11 +466,9 @@ import "CPScroller.j"
}
// Setting Scrolling Behavior
/*
Sets how much the document moves when scrolled. Sets
the vertical and horizontal scroll.
@param aLineScroll the amount to move the document
when scrolled
/*!
Sets how much the document moves when scrolled. Sets the vertical and horizontal scroll.
@param aLineScroll the amount to move the document when scrolled
*/
- (void)setLineScroll:(float)aLineScroll
{
@@ -474,59 +476,51 @@ import "CPScroller.j"
[self setVerticalLineScroll:aLineScroll];
}
/*
Returns how much the document moves
when scrolled
/*!
Returns how much the document moves when scrolled
*/
- (float)lineScroll
{
return [self horizontalLineScroll];
}
/*
Sets how much the document moves when scrolled
horizontally.
@param aLineScroll the amount to move horizontally
when scrolled.
/*!
Sets how much the document moves when scrolled horizontally.
@param aLineScroll the amount to move horizontally when scrolled.
*/
- (void)setHorizontalLineScroll:(float)aLineScroll
{
_horizontalLineScroll = aLineScroll;
}
/*
Returns how much the document moves horizontally
when scrolled.
/*!
Returns how much the document moves horizontally when scrolled.
*/
- (float)horizontalLineScroll
{
return _horizontalLineScroll;
}
/*
Sets how much the document moves when scrolled
vertically.
@param aLineScroll the new amount to move vertically
when scrolled.
/*!
Sets how much the document moves when scrolled vertically.
@param aLineScroll the new amount to move vertically when scrolled.
*/
- (void)setVerticalLineScroll:(float)aLineScroll
{
_verticalLineScroll = aLineScroll;
}
/*
Returns how much the document moves vertically
when scrolled.
/*!
Returns how much the document moves vertically when scrolled.
*/
- (float)verticalLineScroll
{
return _verticalLineScroll;
}
/*
/*!
Sets the horizontal and vertical page scroll amount.
@param aPageScroll the new horizontal and vertical page
scroll amount
@param aPageScroll the new horizontal and vertical page scroll amount
*/
- (void)setPageScroll:(float)aPageScroll
{
@@ -534,16 +528,15 @@ import "CPScroller.j"
[self setVerticalPageScroll:aPageScroll];
}
/*
Returns the vertical and horizontal page scroll
amount.
/*!
Returns the vertical and horizontal page scroll amount.
*/
- (float)pageScroll
{
return [self horizontalPageScroll];
}
/*
/*!
Sets the horizontal page scroll amount.
@param aPageScroll the new horizontal page scroll amount
*/
@@ -552,7 +545,7 @@ import "CPScroller.j"
_horizontalPageScroll = aPageScroll;
}
/*
/*!
Returns the horizontal page scroll amount.
*/
- (float)horizontalPageScroll
@@ -560,17 +553,16 @@ import "CPScroller.j"
return _horizontalPageScroll;
}
/*
/*!
Sets the vertical page scroll amount.
@param aPageScroll the new vertcal page scroll
amount
@param aPageScroll the new vertcal page scroll amount
*/
- (void)setVerticalPageScroll:(float)aPageScroll
{
_verticalPageScroll = aPageScroll;
}
/*
/*!
Returns the vertical page scroll amount.
*/
- (float)verticalPageScroll
@@ -578,7 +570,7 @@ import "CPScroller.j"
return _verticalPageScroll;
}
/*
/*!
Handles a scroll wheel event from the user.
@param anEvent the scroll wheel event
*/
+26 -22
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPControl.j"
@import "CPControl.j"
#include "CoreGraphics/CGGeometry.h"
@@ -74,6 +74,10 @@ var _CPScrollerKnobIdentifier = @"Knob",
var _CPScrollerClassName = nil,
_CPScrollerPartSizes = {};
/*! @class CPScroller
*/
@implementation CPScroller : CPControl
{
CPControlSize _controlSize;
@@ -206,16 +210,16 @@ var _CPScrollerClassName = nil,
}
// Determining CPScroller Size
/*
Returns the <objj>CPScroller</objj>'s width for a <objj>CPRegularControlSize</objj>.
/*!
Returns the CPScroller's width for a CPRegularControlSize.
*/
+ (float)scrollerWidth
{
return [self scrollerWidthForControlSize:CPRegularControlSize];
}
/*
Returns the width of a <objj>CPScroller</objj> for the specified <objj>CPControlSize</objj>.
/*!
Returns the width of a CPScroller for the specified CPControlSize.
@param aControlSize the size of a controller to return the width for
*/
+ (float)scrollerWidthForControlSize:(CPControlSize)aControlSize
@@ -223,7 +227,7 @@ var _CPScrollerClassName = nil,
return _CPScrollerWidths[aControlSize];
}
/*
/*!
Sets the scroller's size.
@param aControlSize the scroller's size
*/
@@ -242,7 +246,7 @@ var _CPScrollerClassName = nil,
[self layoutSubviews];
}
/*
/*!
Returns the scroller's control size
*/
- (CPControlSize)controlSize
@@ -251,7 +255,7 @@ var _CPScrollerClassName = nil,
}
// Setting the Knob Position
/*
/*!
Sets the scroller's knob position (ranges from 0.0 to 1.0).
@param aValue the knob position (ranges from 0.0 to 1.0)
*/
@@ -263,7 +267,7 @@ var _CPScrollerClassName = nil,
[self layoutSubviews];
}
/*
/*!
Sets the position and proportion of the knob.
@param aValue the knob position (ranges from 0.0 to 1.0)
@param aProportion the knob's proportion (ranges from 0.0 to 1.0)
@@ -275,7 +279,7 @@ var _CPScrollerClassName = nil,
[self setFloatValue:aValue];
}
/*
/*!
Return's the knob's proportion
*/
- (float)knobProportion
@@ -293,7 +297,7 @@ var _CPScrollerClassName = nil,
return _partRects[aPart];
}
/*
/*!
Returns the part of the scroller that would be hit by <code>aPoint</code>.
@param aPoint the simulated point hit
@return the part of the scroller that intersects the point
@@ -326,7 +330,7 @@ var _CPScrollerClassName = nil,
return CPScrollerNoPart;
}
/*
/*!
Check if there's enough space in the scroller to display the knob
*/
- (void)checkSpaceForParts
@@ -386,7 +390,7 @@ var _CPScrollerClassName = nil,
}
}
/*
/*!
Returns all the parts of the scroller that
are usable for displaying.
*/
@@ -396,7 +400,7 @@ var _CPScrollerClassName = nil,
}
// Drawing the Parts
/*
/*!
Draws the specified arrow and sets the highlight.
@param anArrow the arrow to draw
@param shouldHighlight sets whether the arrow should be highlighted
@@ -415,7 +419,7 @@ var _CPScrollerClassName = nil,
shouldHighlight ? _CPScrollerHighlightedIdentifier : @"")];
}
/*
/*!
Draws the knob
*/
- (void)drawKnob
@@ -429,7 +433,7 @@ var _CPScrollerClassName = nil,
_CPControlIdentifierForControlSize(_controlSize))];
}
/*
/*!
Draws the knob's slot
*/
- (void)drawKnobSlot
@@ -442,7 +446,7 @@ var _CPScrollerClassName = nil,
_CPControlIdentifierForControlSize(_controlSize))];
}
/*
/*!
Caches images for the scroll arrow and knob.
*/
- (void)drawParts
@@ -480,7 +484,7 @@ var _CPScrollerClassName = nil,
[self drawArrow:CPScrollerIncrementArrow highlight:NO];
}
/*
/*!
Draws the scroller's arrow with a possible highlight,
if the user's mouse is over it.
@param shouldHighlight <code>YES</code> will draw the
@@ -496,7 +500,7 @@ var _CPScrollerClassName = nil,
}
// Event Handling
/*
/*!
Returns the part of the scroller that was hit.
*/
- (CPScrollerPart)hitPart
@@ -504,7 +508,7 @@ var _CPScrollerClassName = nil,
return _hitPart;
}
/*
/*!
Tracks the knob.
@param anEvent the input event
*/
@@ -547,7 +551,7 @@ var _CPScrollerClassName = nil,
[self sendAction:[self action] to:[self target]];
}
/*
/*!
Tracks the scroll button.
@param anEvent the input event
*/
@@ -644,7 +648,7 @@ var _CPScrollerClassName = nil,
[self layoutSubviews];
}
/*
/*!
Lays out the scrollers subviews
*/
- (void)layoutSubviews
+1 -1
View File
@@ -1,4 +1,4 @@
import "CPTextField.j"
@import "CPTextField.j"
#include "Platform/Platform.h"
+33 -35
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
@import <Foundation/CPArray.j>
import "CPControl.j"
@import "CPControl.j"
/*
@global
@@ -40,9 +40,9 @@ CPSegmentSwitchTrackingSelectAny = 1;
*/
CPSegmentSwitchTrackingMomentary = 2;
/*
This class is a horizontal button with multiple
segments.
/*! @class CPSegmentedControl
This class is a horizontal button with multiple segments.
*/
@implementation CPSegmentedControl : CPControl
{
@@ -73,7 +73,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return self;
}
/*
/*!
Returns the tag of the selected segment.
*/
- (int)selectedTag
@@ -82,10 +82,9 @@ CPSegmentSwitchTrackingMomentary = 2;
}
// Specifying the number of segments
/*
/*!
Sets the number of segments in the button.
@param aCount the number of segments on
the button
@param aCount the number of segments on the button
*/
- (void)setSegmentCount:(unsigned)aCount
{
@@ -125,7 +124,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:0];
}
/*
/*!
Returns the number of segments in the button.
*/
- (unsigned)segmentCount
@@ -134,7 +133,7 @@ CPSegmentSwitchTrackingMomentary = 2;
}
// Specifying Selected Segment
/*
/*!
Selects a segment.
@param aSegment the segment to select
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -145,7 +144,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self setSelected:YES forSegment:aSegment];
}
/*
/*!
Returns the selected segment.
*/
- (unsigned)selectedSegment
@@ -153,9 +152,8 @@ CPSegmentSwitchTrackingMomentary = 2;
return _selectedSegment;
}
/*
Selects the button segment with the
specified tag.
/*!
Selects the button segment with the specified tag.
*/
- (BOOL)selectSegmentWithTag:(int)aTag
{
@@ -209,7 +207,7 @@ CPSegmentSwitchTrackingMomentary = 2;
}
}
/*
/*!
Returns the control's tracking mode.
*/
- (CPSegmentSwitchTracking)trackingMode
@@ -218,7 +216,7 @@ CPSegmentSwitchTrackingMomentary = 2;
}
// Working with Individual Segments
/*
/*!
Sets the width of the specified segment.
@param aWidth the new width for the segment
@param aSegment the segment to set the width for
@@ -231,7 +229,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
/*
/*!
Returns the width for the specified segment.
@param aSegment the segment to get the width for
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -241,7 +239,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].width;
}
/*
/*!
Sets the image for the specified segment.
@param anImage the image for the segment
@param aSegment the segment to set the image on
@@ -279,7 +277,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
/*
/*!
Returns the image for the specified segment
@param aSegment the segment to obtain the image for
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -289,7 +287,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].image;
}
/*
/*!
Sets the label for the specified segment
@param aLabel the label for the segment
@param aSegment the segment to label
@@ -329,7 +327,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self tileWithChangedSegment:aSegment];
}
/*
/*!
Returns the label for the specified segment
@param the segment to obtain the label for
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -339,7 +337,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].label;
}
/*
/*!
Sets the menu for the specified segment
@param aMenu the menu to set
@param aSegment the segment to set the menu on
@@ -350,7 +348,7 @@ CPSegmentSwitchTrackingMomentary = 2;
_segments[aSegment].menu = aMenu;
}
/*
/*!
Returns the menu for the specified segment.
@param aSegment the segment to obtain the menu for
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -360,7 +358,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].menu;
}
/*
/*!
Sets the selection for the specified segment. If only one segment
can be selected at a time, any other segment will be deselected.
@param isSelected <code>YES</code> selects the segment. <code>NO</code> deselects it.
@@ -396,7 +394,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self drawSegmentBezel:aSegment highlight:NO];
}
/*
/*!
Returns <code>YES</code> if the specified segment is selected.
@param aSegment the segment to check for selection
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -406,7 +404,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].selected;
}
/*
/*!
Enables/diables the specified segment.
@param isEnabled <code>YES</code> enables the segment
@param aSegment the segment to enable/disble
@@ -417,7 +415,7 @@ CPSegmentSwitchTrackingMomentary = 2;
_segments[aSegment].enabled = isEnabled;
}
/*
/*!
Returns <code>YES</code> if the specified segment is enabled.
@param aSegment the segment to check
@throws CPRangeException if <code>aSegment</code> is out of bounds
@@ -427,7 +425,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].enabled;
}
/*
/*!
Sets a tag for the specified segment.
@param aTag the tag to set
@param aSegment the segment to set the tag on
@@ -437,7 +435,7 @@ CPSegmentSwitchTrackingMomentary = 2;
_segments[aSegment].tag = aTag;
}
/*
/*!
Returns the tag for the specified segment.
@param aSegment the segment to obtain the tag for
*/
@@ -447,7 +445,7 @@ CPSegmentSwitchTrackingMomentary = 2;
}
// Drawings
/*
/*!
Draws the specified segment bezel
@param aSegment the segment to draw the bezel for
@param shouldHighlight <code>YES</code> highlights the bezel
@@ -456,7 +454,7 @@ CPSegmentSwitchTrackingMomentary = 2;
{
}
/*
/*!
Draws the specified segment
@param aSegment the segment to draw
@param shouldHighlight <code>YES</code> highlights the bezel
@@ -550,7 +548,7 @@ CPSegmentSwitchTrackingMomentary = 2;
[self drawSegment:aSegment highlight:NO];
}
/*
/*!
Returns the bounding rectangle for the specified segment.
@param aSegment the segment to get the rectangle for
*/
@@ -559,7 +557,7 @@ CPSegmentSwitchTrackingMomentary = 2;
return _segments[aSegment].frame;
}
/*
/*!
Returns the segment that is hit by the specified point.
@param aPoint the point to test for a segment hit
@return the intersecting segment
@@ -589,7 +587,7 @@ CPSegmentSwitchTrackingMomentary = 2;
{
}
/*
/*!
Handles events for the segment
@param anEvent the event to handle
*/
+9 -7
View File
@@ -20,9 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
/*! @class CPShadow
/*
Instances of this class contain the attributes of a drop shadow used in Cappuccino.
*/
@implementation CPShadow : CPObject
@@ -34,7 +36,7 @@ import <Foundation/CPObject.j>
CPString _cssString;
}
/*
/*!
Creates a shadow with the specified attributes.
@param anOffset the shadow's offset
@param aBlurRadius the shadow's blur radius
@@ -63,7 +65,7 @@ import <Foundation/CPObject.j>
return self;
}
/*
/*!
Returns the shadow's offset.
*/
- (CGSize)shadowOffset
@@ -71,7 +73,7 @@ import <Foundation/CPObject.j>
return _offset;
}
/*
/*!
Returns the shadow's blur radius
*/
- (float)shadowBlurRadius
@@ -79,7 +81,7 @@ import <Foundation/CPObject.j>
return _blurRadius;
}
/*
/*!
Returns the shadow's color.
*/
- (CPColor)shadowColor
@@ -87,7 +89,7 @@ import <Foundation/CPObject.j>
return _color;
}
/*
/*!
Returns a CSS string representation of the shadow.
*/
- (CPString)cssString
+6 -5
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPBundle.j>
@import <Foundation/CPBundle.j>
@import "CGGeometry.j"
@import "CPImage.j"
@import "CPImageView.j"
@import "CPView.j"
import "CGGeometry.j"
import "CPImage.j"
import "CPImageView.j"
import "CPView.j"
#include "CoreGraphics/CGGeometry.h"
+91 -49
View File
@@ -20,27 +20,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPControl.j"
@import "CPControl.j"
var CPSliderHorizontalKnobImage = nil,
CPSliderHorizontalBarLeftImage = nil,
CPSliderHorizontalBarRightImage = nil,
CPSliderHorizontalBarCenterImage = nil;
/*
An <objj>CPSlider</objj> displays, and allows control of, some value in the application. It represents a continuous stream of values of type <code>float</code>, which can be retrieved by the method <code>floatValue</code> and set by the method <code>setFloatValue:</code>.
/*! @class CPSlider
An CPSlider displays, and allows control of, some value in the application. It represents a continuous stream of values of type <code>float</code>, which can be retrieved by the method <code>floatValue</code> and set by the method <code>setFloatValue:</code>.
*/
@implementation CPSlider : CPControl
{
double _value;
double _minValue;
double _maxValue;
double _altIncrementValue;
BOOL _isVertical;
CPView _bar;
CPView _knob;
BOOL _isVertical;
CPImageView _standardKnob;
CPView _standardVerticalBar;
CPView _standardHorizontalBar;
@@ -56,11 +57,11 @@ var CPSliderHorizontalKnobImage = nil,
var bundle = [CPBundle bundleForClass:self];
CPSliderKnobImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderKnobRegular.png"] size:CPSizeMake(11.0, 11.0)],
CPSliderKnobPushedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderKnobRegularPushed.png"] size:CPSizeMake(11.0, 11.0)],
CPSliderHorizontalBarLeftImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderTrackHorizontalLeft.png"] size:CPSizeMake(2.0, 4.0)],
CPSliderHorizontalBarRightImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderTrackHorizontalRight.png"] size:CPSizeMake(2.0, 4.0)],
CPSliderHorizontalBarCenterImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPSlider/CPSliderTrackHorizontalCenter.png"] size:CPSizeMake(1.0, 4.0)];
CPSliderKnobImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPSlider/CPSliderKnobRegular.png"] size:CPSizeMake(11.0, 11.0)],
CPSliderKnobPushedImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPSlider/CPSliderKnobRegularPushed.png"] size:CPSizeMake(11.0, 11.0)],
CPSliderHorizontalBarLeftImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPSlider/CPSliderTrackHorizontalLeft.png"] size:CPSizeMake(2.0, 4.0)],
CPSliderHorizontalBarRightImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPSlider/CPSliderTrackHorizontalRight.png"] size:CPSizeMake(2.0, 4.0)],
CPSliderHorizontalBarCenterImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPSlider/CPSliderTrackHorizontalCenter.png"] size:CPSizeMake(1.0, 4.0)];
}
- (id)initWithFrame:(CGRect)aFrame
@@ -78,6 +79,8 @@ var CPSliderHorizontalKnobImage = nil,
_knobSize = [[self knobImage] size];
_isVertical = [self isVertical];
[self setContinuous:YES];
[_knob setFrameOrigin:[self knobPosition]];
[self addSubview:_bar];
@@ -89,7 +92,7 @@ var CPSliderHorizontalKnobImage = nil,
- (void)setFrameSize:(CGSize)aSize
{
if(aSize.height > 21.0)
if (aSize.height > 21.0)
aSize.height = 21.0;
if (_isVertical != [self isVertical])
@@ -116,7 +119,7 @@ var CPSliderHorizontalKnobImage = nil,
[_knob setFrameOrigin:[self knobPosition]];
}
/*
/*!
Returns the value by which the slider will be
incremented if the user holds down the <code>ALT</code>s key.
*/
@@ -125,7 +128,34 @@ var CPSliderHorizontalKnobImage = nil,
return _altIncrementValue;
}
/*
/*!
Sets the value the slider will be incremented if the user holds the <code>ALT</code> key.
*/
- (void)setAltIncrementValue:(double)anIncrementValue
{
_altIncrementValue = anIncrementValue;
}
/*!
Returns whether the control can continuously send its action messages.
*/
- (BOOL)isContinuous
{
return (_sendActionOn & CPLeftMouseDraggedMask) != 0;
}
/*!
Sets whether the cell can continuously send its action messages.
*/
- (void)setContinuous:(BOOL)flag
{
if (flag)
_sendActionOn |= CPLeftMouseDraggedMask;
else
_sendActionOn &= ~CPLeftMouseDraggedMask;
}
/*!
Returns the thickness of the slider's knob. This value is in pixels,
and is the size of the knob along the slider's track.
*/
@@ -174,7 +204,7 @@ var CPSliderHorizontalKnobImage = nil,
return CPSliderKnobPushedImage;
}
/*
/*!
Returns the slider's knob.
*/
- (CPView)knob
@@ -192,7 +222,7 @@ var CPSliderHorizontalKnobImage = nil,
return _standardKnob;
}
/*
/*!
Returns the slider's bar.
*/
- (CPView)bar
@@ -220,15 +250,7 @@ var CPSliderHorizontalKnobImage = nil,
}
}
/*
Sets the value the slider will be incremented if the user holds the <code>ALT</code> key.
*/
- (void)setAltIncrementValue:(double)anIncrementValue
{
_altIncrementValue = anIncrementValue;
}
/*
/*!
Returns <code>YES</code> if the slider is vertical.
*/
- (BOOL)isVertical
@@ -241,7 +263,7 @@ var CPSliderHorizontalKnobImage = nil,
return CPRectGetWidth(frame) < CPRectGetHeight(frame);
}
/*
/*!
Returns the slider's maximum value
*/
- (double)maxValue
@@ -249,7 +271,7 @@ var CPSliderHorizontalKnobImage = nil,
return _maxValue;
}
/*
/*!
Returns the slider's minimum value
*/
- (double)minValue
@@ -257,7 +279,7 @@ var CPSliderHorizontalKnobImage = nil,
return _minValue;
}
/*
/*!
Sets the slider's maximum value
@param aMaxValue the new maximum value
*/
@@ -266,7 +288,7 @@ var CPSliderHorizontalKnobImage = nil,
_maxValue = aMaxValue;
}
/*
/*!
Sets the slider's minimum value
@param aMinValue the new minimum value
*/
@@ -275,23 +297,31 @@ var CPSliderHorizontalKnobImage = nil,
_minValue = aMinValue;
}
/*
/*!
Sets the slider's value
@param aValue the new slider value
@deprecated Use setFloatValue, setObjectValue, etc
*/
- (void)setValue:(double)aValue
{
_value = aValue;
[_knob setFrameOrigin:[self knobPosition]];
[self setObjectValue:aValue];
}
/*
/*!
Returns the slider's value
@deprecated Use floatValue, objectValue, etc
*/
- (double)value
{
return _value;
return [self floatValue];
}
- (void)setObjectValue:(id)anObject
{
[super setObjectValue:anObject];
if (_knob)
[_knob setFrameOrigin:[self knobPosition]];
}
/*
@@ -304,7 +334,7 @@ var CPSliderHorizontalKnobImage = nil,
return CPPointMake(0.0, 0.0);
else
return CPPointMake(
((_value - _minValue) / (_maxValue - _minValue)) * (CPRectGetWidth([self frame]) - CPRectGetWidth([_knob frame])),
(([self floatValue] - _minValue) / (_maxValue - _minValue)) * (CPRectGetWidth([self frame]) - CPRectGetWidth([_knob frame])),
(CPRectGetHeight([self frame]) - CPRectGetHeight([_knob frame])) / 2.0);
}
@@ -328,40 +358,50 @@ var CPSliderHorizontalKnobImage = nil,
- (void)mouseUp:(CPEvent)anEvent
{
[[self knob] setImage: [self knobImage]];
[[self knob] setImage:[self knobImage]];
if ([_target respondsToSelector:@selector(sliderDidFinish:)])
[_target sliderDidFinish:self];
if (_sendActionOn & CPLeftMouseUpMask)
[self sendAction:_action to:_target];
//[super mouseUp:anEvent];
}
- (void)mouseDown:(CPEvent)anEvent
{
[_knob setFrameOrigin:[self constrainKnobPosition:[self convertPoint:[anEvent locationInWindow] fromView:nil]]];
_value = [self valueForKnobPosition:[_knob frame].origin];
[super setObjectValue:[self valueForKnobPosition:[_knob frame].origin]];
[[self knob] setImage: [self pushedKnobImage]];
[self sendAction:_action to:_target];
[[self knob] setImage:[self pushedKnobImage]];
if (_sendActionOn & CPLeftMouseDraggedMask)
[self sendAction:_action to:_target];
//[super mouseDown:anEvent];
}
- (void)mouseDragged:(CPEvent)anEvent
{
[_knob setFrameOrigin:[self constrainKnobPosition:[self convertPoint:[anEvent locationInWindow] fromView:nil]]];
_value = [self valueForKnobPosition:[_knob frame].origin];
[self sendAction:_action to:_target];
[super setObjectValue:[self valueForKnobPosition:[_knob frame].origin]];
if (_sendActionOn & CPLeftMouseDraggedMask)
[self sendAction:_action to:_target];
//[super mouseDown:anEvent];
}
@end
var CPSliderMinValueKey = @"CPSliderMinValueKey",
CPSliderMaxValueKey = @"CPSliderMaxValueKey",
CPSliderValueKey = @"CPSliderValueKey";
var CPSliderMinValueKey = "CPSliderMinValueKey",
CPSliderMaxValueKey = "CPSliderMaxValueKey",
CPSliderAltIncrValueKey = "CPSliderAltIncrValueKey",
CPSliderIsVerticalKey = "CPSliderIsVerticalKey";
@implementation CPSlider (CPCoding)
/*
/*!
Initializes the slider from the data in a coder.
@param aCoder the coder from which to read the data
@return the initialized slider
@@ -372,9 +412,10 @@ var CPSliderMinValueKey = @"CPSliderMinValueKey",
if (self)
{
_value = [aCoder decodeDoubleForKey:CPSliderValueKey];
_minValue = [aCoder decodeDoubleForKey:CPSliderMinValueKey];
_maxValue = [aCoder decodeDoubleForKey:CPSliderMaxValueKey];
_altIncrementValue = [aCoder decodeDoubleForKey:CPSliderAltIncrValueKey];
_isVertical = [aCoder decodeDoubleForKey:CPSliderIsVerticalKey];
_bar = [self bar];
_knob = [self knob];
@@ -390,7 +431,7 @@ var CPSliderMinValueKey = @"CPSliderMinValueKey",
return self;
}
/*
/*!
Writes out the slider's instance information to a coder.
@param aCoder the coder to which to write the data
*/
@@ -404,9 +445,10 @@ var CPSliderMinValueKey = @"CPSliderMinValueKey",
_subviews = subviews;
[aCoder encodeDouble:_value forKey:CPSliderValueKey];
[aCoder encodeDouble:_minValue forKey:CPSliderMinValueKey];
[aCoder encodeDouble:_maxValue forKey:CPSliderMaxValueKey];
[aCoder encodeDouble:_altIncrementValue forKey:CPSliderAltIncrValueKey];
[aCoder encodeBool:_isVertical forKey:CPSliderIsVerticalKey];
}
@end
+43 -37
View File
@@ -20,12 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/Foundation.j>
import <AppKit/CPView.j>
import <AppKit/CPSlider.j>
import <AppKit/CPColorPicker.j>
import <AppKit/CPColorPanel.j>
@import "CPColorPicker.j"
/*
@ignore
@@ -68,8 +63,10 @@ import <AppKit/CPColorPanel.j>
-(id)initView
{
aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
_contentView = [[CPView alloc] initWithFrame:aFrame];
[_contentView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
_rgbLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 10, 100, 20)];
[_rgbLabel setStringValue: "RGB"];
[_rgbLabel setTextColor:[CPColor whiteColor]];
@@ -92,28 +89,28 @@ import <AppKit/CPColorPanel.j>
switch(this)
{
case _redValue: [_redSlider setValue: MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
[self sliderChanged: _redSlider];
case _redValue: [_redSlider setFloatValue:MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
//[self sliderChanged: _redSlider];
break;
case _greenValue: [_greenSlider setValue: MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
[self sliderChanged: _greenSlider];
case _greenValue: [_greenSlider setFloatValue:MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
//[self sliderChanged: _greenSlider];
break;
case _blueValue: [_blueSlider setValue: MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
[self sliderChanged: _blueSlider];
case _blueValue: [_blueSlider setFloatValue:MAX(MIN(ROUND(this.value), 255) / 255.0, 0)];
//[self sliderChanged: _blueSlider];
break;
case _hueValue: [_hueSlider setValue: MAX(MIN(ROUND(this.value), 360), 0)];
[self sliderChanged: _hueSlider];
case _hueValue: [_hueSlider setFloatValue:MAX(MIN(ROUND(this.value), 360), 0)];
//[self sliderChanged: _hueSlider];
break;
case _saturationValue: [_saturationSlider setValue: MAX(MIN(ROUND(this.value), 100), 0)];
[self sliderChanged: _saturationSlider];
case _saturationValue: [_saturationSlider setFloatValue:MAX(MIN(ROUND(this.value), 100), 0)];
//[self sliderChanged: _saturationSlider];
break;
case _brightnessValue: [_brightnessSlider setValue: MAX(MIN(ROUND(this.value), 100), 0)];
[self sliderChanged: _brightnessSlider];
case _brightnessValue: [_brightnessSlider setFloatValue:MAX(MIN(ROUND(this.value), 100), 0)];
//[self sliderChanged: _brightnessSlider];
break;
}
@@ -338,18 +335,18 @@ import <AppKit/CPColorPanel.j>
{
case _hueSlider:
case _saturationSlider:
case _brightnessSlider: newColor = [CPColor colorWithHue: [_hueSlider value]
saturation: [_saturationSlider value]
brightness: [_brightnessSlider value]];
case _brightnessSlider: newColor = [CPColor colorWithHue: [_hueSlider floatValue]
saturation: [_saturationSlider floatValue]
brightness: [_brightnessSlider floatValue]];
[self updateRGBSliders: newColor];
break;
case _redSlider:
case _greenSlider:
case _blueSlider: newColor = [CPColor colorWithCalibratedRed: [_redSlider value]
green: [_greenSlider value]
blue: [_blueSlider value]
case _blueSlider: newColor = [CPColor colorWithCalibratedRed: [_redSlider floatValue]
green: [_greenSlider floatValue]
blue: [_blueSlider floatValue]
alpha: 1.0];
[self updateHSBSliders: newColor];
@@ -373,9 +370,9 @@ import <AppKit/CPColorPanel.j>
{
var hsb = [aColor hsbComponents];
[_hueSlider setValue: hsb[0]];
[_saturationSlider setValue: hsb[1]];
[_brightnessSlider setValue: hsb[2]];
[_hueSlider setFloatValue:hsb[0]];
[_saturationSlider setFloatValue:hsb[1]];
[_brightnessSlider setFloatValue:hsb[2]];
}
- (void)updateHex:(CPColor)aColor
@@ -387,21 +384,30 @@ import <AppKit/CPColorPanel.j>
{
var rgb = [aColor components];
[_redSlider setValue: rgb[0]];
[_greenSlider setValue: rgb[1]];
[_blueSlider setValue: rgb[2]];
[_redSlider setFloatValue:rgb[0]];
[_greenSlider setFloatValue:rgb[1]];
[_blueSlider setFloatValue:rgb[2]];
}
- (void)updateLabels
{
_hueValue.value = ROUND([_hueSlider value]);
_saturationValue.value = ROUND([_saturationSlider value]);
_brightnessValue.value = ROUND([_brightnessSlider value]);
_hueValue.value = ROUND([_hueSlider floatValue]);
_saturationValue.value = ROUND([_saturationSlider floatValue]);
_brightnessValue.value = ROUND([_brightnessSlider floatValue]);
_redValue.value = ROUND([_redSlider value] * 255);
_greenValue.value = ROUND([_greenSlider value] * 255);
_blueValue.value = ROUND([_blueSlider value] * 255);
_redValue.value = ROUND([_redSlider floatValue] * 255);
_greenValue.value = ROUND([_greenSlider floatValue] * 255);
_blueValue.value = ROUND([_blueSlider floatValue] * 255);
}
- (CPImage)provideNewButtonImage
{
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:CPColorPicker] pathForResource:"slider_button.png"] size:CGSizeMake(32, 32)];
}
- (CPImage)provideNewAlternateButtonImage
{
return [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:CPColorPicker] pathForResource:"slider_button_h.png"] size:CGSizeMake(32, 32)];
}
@end
+9 -10
View File
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPImage.j"
import "CPView.j"
@import "CPImage.j"
@import "CPView.j"
#include "CoreGraphics/CGGeometry.h"
#include "Platform/Platform.h"
@@ -451,25 +451,24 @@ var CPSplitViewHorizontalImage = nil,
[self _postNotificationWillResize];
var frame = [self frame];
var index = 0,
count = [_subviews count],
bounds = [self bounds],
dividerThickness = [self dividerThickness];
for (; index < count; ++index)
{
var view = _subviews[index],
newFrame = CGRectCreateCopy(frame);
viewFrame = CGRectMakeCopy(bounds);
if (index + 1 == count)
newFrame.size[_sizeComponent] = frame.size[_sizeComponent] - newFrame.origin[_originComponent];
viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] - viewFrame.origin[_originComponent];
else
newFrame.size[_sizeComponent] = frame.size[_sizeComponent] * ([view frame].size[_sizeComponent] / oldSize[_sizeComponent]);
viewFrame.size[_sizeComponent] = bounds.size[_sizeComponent] * ([view frame].size[_sizeComponent] / oldSize[_sizeComponent]);
frame.origin[_originComponent] += newFrame.size[_sizeComponent] + dividerThickness;
bounds.origin[_originComponent] += viewFrame.size[_sizeComponent] + dividerThickness;
[view setFrame:newFrame];
[view setFrame:viewFrame];
}
[self _postNotificationDidResize];
@@ -516,7 +515,7 @@ var CPSplitViewDelegateKey = "CPSplitViewDelegateKey",
/*
Initializes the split view by unarchiving data from <code>aCoder</code>.
@param aCoder the coder containing the archived <objj>CPSplitView</objj>.
@param aCoder the coder containing the archived CPSplitView.
*/
- (id)initWithCoder:(CPCoder)aCoder
{
+2 -2
View File
@@ -20,14 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPString.j>
@import <Foundation/CPString.j>
var CPStringReferenceElement = nil;
@implementation CPString (CPStringDrawing)
/*
/*!
Returns the string
*/
- (CPString)cssString
+83 -32
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPImageView.j"
import "CPTabViewItem.j"
import "CPView.j"
@import "CPImageView.j"
@import "CPTabViewItem.j"
@import "CPView.j"
#include "CoreGraphics/CGGeometry.h"
/*
Places tabs on top with a bezeled border.
@global
@@ -68,15 +69,16 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
CPTabViewWillSelectTabViewItemSelector = 4,
CPTabViewDidChangeNumberOfTabViewItemsSelector = 8;
/*
This class represents a view that has multiple subviews (<objj>CPTabViewItem</objj>) presented as individual tabs.
Only one <objj>CPTabViewItem</objj> is shown at a time, and other <objj>CPTabViewItem</objj>s can be made visible
(one at a time) by clicking on the <objj>CPTabViewItem</objj>'s tab at the top of the tab view.
/*! @class CPTabView
This class represents a view that has multiple subviews (CPTabViewItem) presented as individual tabs.
Only one CPTabViewItem is shown at a time, and other CPTabViewItems can be made visible
(one at a time) by clicking on the CPTabViewItem's tab at the top of the tab view.
THe currently selected <objj>CPTabViewItem</objj> is the view that is displayed.
THe currently selected CPTabViewItem is the view that is displayed.
*/
@implementation CPTabView : CPView
{
{
CPView _labelsView;
CPView _backgroundView;
CPView _separatorView;
@@ -219,8 +221,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}
// Adding and Removing Tabs
/*
Adds a <objj>CPTabViewItem</objj> to the tab view.
/*!
Adds a CPTabViewItem to the tab view.
@param aTabViewItem the item to add
*/
- (void)addTabViewItem:(CPTabViewItem)aTabViewItem
@@ -228,8 +230,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self insertTabViewItem:aTabViewItem atIndex:[_tabViewItems count]];
}
/*
Inserts a <objj>CPTabViewItem</objj> into the tab view
/*!
Inserts a CPTabViewItem into the tab view
at the specified index.
@param aTabViewItem the item to insert
@param anIndex the index for the item
@@ -247,7 +249,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[_delegate tabViewDidChangeNumberOfTabViewItems:self];
}
/*
/*!
Removes the specified tab view item from the tab view.
@param aTabViewItem the item to remove
*/
@@ -262,7 +264,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}
// Accessing Tabs
/*
/*!
Returns the index of the specified item
@param aTabViewItem the item to find the index for
*/
@@ -271,8 +273,8 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
return [_tabViewItems indexOfObjectIdenticalTo:aTabViewItem];
}
/*
Returns the index of the <objj>CPTabViewItem</objj> with the specified identifier.
/*!
Returns the index of the CPTabViewItem with the specified identifier.
@param anIdentifier the identifier of the item
*/
- (int)indexOfTabViewItemWithIdentifier:(CPString)anIdentifier
@@ -287,7 +289,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
return index;
}
/*
/*!
Returns the number of items in the tab view.
*/
- (unsigned)numberOfTabViewItems
@@ -295,15 +297,15 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
return [_tabViewItems count];
}
/*
Returns the <objj>CPTabViewItem</objj> at the specified index.
/*!
Returns the CPTabViewItem at the specified index.
*/
- (CPTabViewItem)tabViewItemAtIndex:(unsigned)anIndex
{
return _tabViewItems[anIndex];
}
/*
/*!
Returns the array of items that backs this tab view.
*/
- (CPArray)tabViewItems
@@ -312,7 +314,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}
// Selecting a Tab
/*
/*!
Sets the first tab view item in the array to be displayed to the user.
@param aSender the object making this request
*/
@@ -324,7 +326,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self selectTabViewItemAtIndex:0];
}
/*
/*!
Sets the last tab view item in the array to be displayed to the user.
@param aSender the object making this request
*/
@@ -336,7 +338,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self selectTabViewItemAtIndex:count - 1];
}
/*
/*!
Sets the next tab item in the array to be displayed.
@param aSender the object making this request
*/
@@ -351,7 +353,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self selectTabViewItemAtIndex:index + 1 % count];
}
/*
/*!
Selects the previous item in the array for display.
@param aSender the object making this request
*/
@@ -366,7 +368,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self selectTabViewItemAtIndex:index == 0 ? count : index - 1];
}
/*
/*!
Displays the specified item in the tab view.
@param aTabViewItem the item to display
*/
@@ -409,7 +411,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[_delegate tabView:self didSelectTabViewItem:aTabViewItem];
}
/*
/*!
Selects the item at the specified index.
@param anIndex the index of the item to display.
*/
@@ -418,7 +420,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self selectTabViewItem:_tabViewItems[anIndex]];
}
/*
/*!
Returns the current item being displayed.
*/
- (CPTabViewItem)selectedTabViewItem
@@ -427,7 +429,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}
//
/*
/*!
Sets the tab view type.
@param aTabViewType the view type
*/
@@ -451,7 +453,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
[self layoutSubviews];
}
/*
/*!
Returns the tab view type.
*/
- (CPTabViewType)tabViewType
@@ -460,7 +462,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}
// Determining the Size
/*
/*!
Returns the content rectangle.
*/
- (CGRect)contentRect
@@ -483,7 +485,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
return contentRect;
}
/*
/*!
Sets the delegate for this tab view.
@param aDelegate the tab view's delegate
*/
@@ -522,6 +524,55 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
@end
var CPTabViewItemsKey = "CPTabViewItemsKey",
CPTabViewSelectedItemKey = "CPTabViewSelectedItemKey",
CPTabViewTypeKey = "CPTabViewTypeKey",
CPTabViewDelegateKey = "CPTabViewDelegateKey";
@implementation CPTabView (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
if (self = [super initWithCoder:aCoder])
{
_tabViewType = [aCoder decodeIntForKey:CPTabViewTypeKey];
_tabViewItems = [];
// FIXME: this is somewhat hacky
[self _createBezelBorder];
var items = [aCoder decodeObjectForKey:CPTabViewItemsKey];
for (var i = 0; items && i < items.length; i++)
[self insertTabViewItem:items[i] atIndex:i];
var selected = [aCoder decodeObjectForKey:CPTabViewSelectedItemKey];
if (selected)
[self selectTabViewItem:selected];
[self setDelegate:[aCoder decodeObjectForKey:CPTabViewDelegateKey]];
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
var actualSubviews = _subviews;
_subviews = [];
[super encodeWithCoder:aCoder];
_subviews = actualSubviews;
[aCoder encodeObject:_tabViewItems forKey:CPTabViewItemsKey];;
[aCoder encodeObject:_selectedTabViewItem forKey:CPTabViewSelectedItemKey];
[aCoder encodeInt:_tabViewType forKey:CPTabViewTypeKey];
[aCoder encodeConditionalObject:_delegate forKey:CPTabViewDelegateKey];
}
@end
var _CPTabLabelsViewBackgroundColor = nil,
_CPTabLabelsViewInsideMargin = 10.0,
_CPTabLabelsViewOutsideMargin = 15.0;
+58 -19
View File
@@ -20,9 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
@import <AppKit/CPView.j>
import <AppKit/CPView.j>
/*
The tab is currently selected.
@@ -43,9 +44,10 @@ CPBackgroundTab = 1;
*/
CPPressedTab = 2;
/*
The class representation of an item in a <objj>CPTabView</objj>. One tab view item
can be shown at a time in a <objj>CPTabView</objj>.
/*! @class CPTabView
The class representation of an item in a CPTabView. One tab view item
can be shown at a time in a CPTabView.
*/
@implementation CPTabViewItem : CPObject
{
@@ -56,9 +58,9 @@ CPPressedTab = 2;
CPView _auxiliaryView;
}
/*
/*!
Initializes the tab view item with the specified identifier.
@return the initialized <objj>CPTabViewItem</objj>
@return the initialized CPTabViewItem
*/
- (id)initWithIdentifier:(id)anIdentifier
{
@@ -71,8 +73,8 @@ CPPressedTab = 2;
}
// Working With Labels
/*
Sets the <objj>CPTabViewItem</objj>'s label.
/*!
Sets the CPTabViewItem's label.
@param aLabel the label for the item
*/
- (void)setLabel:(CPString)aLabel
@@ -80,8 +82,8 @@ CPPressedTab = 2;
_label = aLabel;
}
/*
Returns the <objj>CPTabViewItem</objj>'s label
/*!
Returns the CPTabViewItem's label
*/
- (CPString)label
{
@@ -89,7 +91,7 @@ CPPressedTab = 2;
}
// Checking the Tab Display State
/*
/*!
Returns the tab's current state.
*/
- (CPTabState)tabState
@@ -98,7 +100,7 @@ CPPressedTab = 2;
}
// Assigning an Identifier Object
/*
/*!
Sets the item's identifier.
@param anIdentifier the new identifier for the item
*/
@@ -107,7 +109,7 @@ CPPressedTab = 2;
_identifier = anIdentifier;
}
/*
/*!
Returns the tab's identifier.
*/
- (id)identifier
@@ -116,7 +118,7 @@ CPPressedTab = 2;
}
// Assigning a View
/*
/*!
Sets the view that gets displayed in this tab.
*/
- (void)setView:(CPView)aView
@@ -124,7 +126,7 @@ CPPressedTab = 2;
_view = aView;
}
/*
/*!
Returns the tab's view.
*/
- (CPView)view
@@ -133,7 +135,7 @@ CPPressedTab = 2;
}
// Assigning an Auxiliary View
/*
/*!
Sets the tab's auxillary view.
@param anAuxillaryView the new auxillary view
*/
@@ -142,7 +144,7 @@ CPPressedTab = 2;
_auxiliaryView = anAuxiliaryView;
}
/*
/*!
Returns the tab's auxillary view
*/
- (CPView)auxiliaryView
@@ -151,7 +153,7 @@ CPPressedTab = 2;
}
// Accessing the Parent Tab View
/*
/*!
Returns the tab view that contains this item.
*/
- (CPTabView)tabView
@@ -160,3 +162,40 @@ CPPressedTab = 2;
}
@end
var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
CPTabViewItemLabelKey = "CPTabViewItemLabelKey",
CPTabViewItemViewKey = "CPTabViewItemViewKey",
CPTabViewItemAuxViewKey = "CPTabViewItemAuxViewKey";
@implementation CPTabViewItem (CPCoding)
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey];
_label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey];
_view = [aCoder decodeObjectForKey:CPTabViewItemViewKey];
_auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey];
CPLog.warn("_identifier="+_identifier+" _label="+_label+" _view="+_view+" _auxiliaryView="+_auxiliaryView);
}
return self;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey];
[aCoder encodeObject:_label forKey:CPTabViewItemLabelKey];
[aCoder encodeObject:_view forKey:CPTabViewItemViewKey];
[aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey];
}
@end
+25 -24
View File
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/Foundation.j>
import <Foundation/Foundation.j>
/*
@ignore
@@ -43,10 +43,11 @@ CPTableColumnAutoresizingMask = 1;
*/
CPTableColumnUserResizingMask = 2;
/*
An <objj>CPTableColumn</objj> object mainly keeps information about the width of the column, its minimum and maximum width; whether the column can be edited or resized; and the cells used to draw the column header and the data in the column. You can change all these attributes of the column by calling the appropriate methods. Please note that the table column does not hold nor has access to the data to be displayed in the column; this data is maintained in the table view's data source.</p>
/*! @class CPTableColumn
An CPTableColumn object mainly keeps information about the width of the column, its minimum and maximum width; whether the column can be edited or resized; and the cells used to draw the column header and the data in the column. You can change all these attributes of the column by calling the appropriate methods. Please note that the table column does not hold nor has access to the data to be displayed in the column; this data is maintained in the table view's data source.</p>
<p>Each <objj>CPTableColumn</objj> object is identified by a <objj>CPString</objj>, called the column identifier. The reason is that, after a column has been added to a table view, the user might move the columns around, so there is a need to identify the columns regardless of its position in the table.
<p>Each CPTableColumn object is identified by a CPString, called the column identifier. The reason is that, after a column has been added to a table view, the user might move the columns around, so there is a need to identify the columns regardless of its position in the table.
@ignore
*/
@@ -63,7 +64,7 @@ CPTableColumnUserResizingMask = 2;
unsigned _resizingMask;
}
/*
/*!
Initializes the table column with the specified identifier.
@param anIdentifier the identifier
@return the initialized table column
@@ -87,7 +88,7 @@ CPTableColumnUserResizingMask = 2;
return self;
}
/*
/*!
Sets the table column's identifier
@param anIdentifier the new identifier
*/
@@ -96,7 +97,7 @@ CPTableColumnUserResizingMask = 2;
_identifier = anIdentifier;
}
/*
/*!
Returns the table column's identifier
*/
- (CPString)identifier
@@ -105,7 +106,7 @@ CPTableColumnUserResizingMask = 2;
}
// Setting the CPTableView
/*
/*!
Sets the table's view. This is called automatically by Cappuccino.
@param aTableView the new table view
*/
@@ -114,7 +115,7 @@ CPTableColumnUserResizingMask = 2;
_tableView = aTableView;
}
/*
/*!
Returns the column's table view.
*/
- (CPTableView)tableView
@@ -123,7 +124,7 @@ CPTableColumnUserResizingMask = 2;
}
// Controlling size
/*
/*!
Sets the column's width.
@param aWidth the new column width
*/
@@ -132,7 +133,7 @@ CPTableColumnUserResizingMask = 2;
_width = aWidth;
}
/*
/*!
Returns the column's width
*/
- (float)width
@@ -140,7 +141,7 @@ CPTableColumnUserResizingMask = 2;
return _width;
}
/*
/*!
Sets column's minimum width.
@param aWidth the new minimum column width
*/
@@ -150,7 +151,7 @@ CPTableColumnUserResizingMask = 2;
[self setWidth:_minWidth];
}
/*
/*!
The column's minimum width
*/
- (float)minWidth
@@ -158,7 +159,7 @@ CPTableColumnUserResizingMask = 2;
return _minWidth;
}
/*
/*!
Sets the column's maximum width.
@param aWidth the new maximum width
*/
@@ -168,7 +169,7 @@ CPTableColumnUserResizingMask = 2;
[self setWidth:_maxWidth];
}
/*
/*!
Sets the resizing mask. The mask is one of:
<pre>
CPTableColumnNoResizing;
@@ -182,7 +183,7 @@ CPTableColumnUserResizingMask;
_resizingMask = aMask;
}
/*
/*!
Returns the column's resizing mask. One of:
<pre>
CPTableColumnNoResizing;
@@ -195,7 +196,7 @@ CPTableColumnUserResizingMask;
return _resizingMask;
}
/*
/*!
Resizes the column according to the min, max and set width.
*/
- (void)sizeToFit
@@ -211,7 +212,7 @@ CPTableColumnUserResizingMask;
[self setWidth:width];
}
/*
/*!
Sets whether the column in this data is editable.
@param aFlag <code>YES</code> means the column data is editable
*/
@@ -220,7 +221,7 @@ CPTableColumnUserResizingMask;
_isEditable = aFlag;
}
/*
/*!
Returns <code>YES</code> if the column data is editable.
*/
- (BOOL)isEditable
@@ -228,7 +229,7 @@ CPTableColumnUserResizingMask;
return _isEditable;
}
/*
/*!
Sets the view that draws the column's header.
@param aHeaderView the view that will draws the column header
*/
@@ -237,7 +238,7 @@ CPTableColumnUserResizingMask;
_headerView = aHeaderView;
}
/*
/*!
Return the view that draws the column's header
*/
- (CPView)headerView
@@ -245,7 +246,7 @@ CPTableColumnUserResizingMask;
return _headerView;
}
/*
/*!
Sets the data cell that draws rows in this column.
*/
- (void)setDataCell:(CPCell)aDataCell
@@ -253,7 +254,7 @@ CPTableColumnUserResizingMask;
_dataCell = aDataCell;
}
/*
/*!
Returns the data cell that draws rows in this column
*/
- (CPCell)dataCell
@@ -261,7 +262,7 @@ CPTableColumnUserResizingMask;
return _dataCell;
}
/*
/*!
By default returns the value from <code>dataCell</code>. This can
be overridden by a subclass to return different cells for different
rows.
+4 -4
View File
@@ -27,7 +27,7 @@ import "CPTableColumn.j"
var CPTableViewCellPlaceholder = nil;
/*
<objj>CPTableView</objj> is located within the AppKit framework and is used to display tables. It uses a delegate model for getting its data i.e. you give it an object that provides it with the data it should display.
CPTableView is located within the AppKit framework and is used to display tables. It uses a delegate model for getting its data i.e. you give it an object that provides it with the data it should display.
@ignore
*/
@@ -284,7 +284,7 @@ var CPTableViewCellPlaceholder = nil;
}
/*
Returns an array containing the table's <objj>CPTableColumn</objj>s.
Returns an array containing the table's CPTableColumns.
*/
- (CPArray)tableColumns
{
@@ -323,8 +323,8 @@ var CPTableViewCellPlaceholder = nil;
Sets the object that is used to obtain the table data. The data source must implement the following
methods:
<pre>
- (int)numberOfRowsInTableView:(<objj>CPTableView</objj>)aTableView
- (id)tableView:(<objj>CPTableView</objj>)aTableView objectValueForTableColumn:(<objj>CPTableColumn</objj>)aTableColumn row:(int)rowIndex
- (int)numberOfRowsInTableView:(CPTableView)aTableView
- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aTableColumn row:(int)rowIndex
</pre>
@param aDataSource the object with the table data
@throws CPInternalInconsistencyException if <code>aDataSource</code> doesn't implement all the required methods
+303 -101
View File
@@ -20,12 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPControl.j"
import "CPStringDrawing.j"
@import "CPControl.j"
@import "CPStringDrawing.j"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
/*
@global
@group CPLineBreakMode
@@ -78,11 +79,12 @@ var TOP_PADDING = 4.0,
var CPTextFieldDOMInputElement = nil;
#endif
var _CPTextFieldSquareBezelColor = nil;
var _CPTextFieldSquareBezelColor = nil,
_CPTextFieldRoundedBezelColor = nil;
@implementation CPString (CPTextFieldAdditions)
/*
/*!
Returns the string (<code>self</code>).
*/
- (CPString)string
@@ -92,22 +94,28 @@ var _CPTextFieldSquareBezelColor = nil;
@end
/*
/*!
This control displays editable text in a Cappuccino application.
*/
@implementation CPTextField : CPControl
{
BOOL _isEditable;
BOOL _isSelectable;
BOOL _isBordered;
BOOL _isBezeled;
CPTextFieldBezelStyle _bezelStyle;
BOOL _isEditable;
BOOL _isSelectable;
id _value;
id _placeholderString;
BOOL _drawsBackground;
CPLineBreakMode _lineBreakMode;
CPColor _textFieldBackgroundColor;
id _placeholderString;
id _delegate;
CPString _textDidChangeValue;
#if PLATFORM(DOM)
DOMElement _DOMTextElement;
#endif
@@ -119,21 +127,21 @@ var _CPTextFieldSquareBezelColor = nil;
{
if (!CPTextFieldDOMInputElement)
{
CPTextFieldDOMInputElement = document.createElement("input");
CPTextFieldDOMInputElement.style.position = "absolute";
CPTextFieldDOMInputElement.style.top = "0px";
CPTextFieldDOMInputElement.style.left = "0px";
CPTextFieldDOMInputElement.style.width = "100%"
CPTextFieldDOMInputElement.style.height = "100%";
CPTextFieldDOMInputElement.style.border = "0px";
CPTextFieldDOMInputElement.style.padding = "0px";
CPTextFieldDOMInputElement.style.whiteSpace = "pre";
CPTextFieldDOMInputElement.style.background = "transparent";
CPTextFieldDOMInputElement.style.outline = "none";
CPTextFieldDOMInputElement.style.paddingLeft = HORIZONTAL_PADDING - 1.0 + "px";
CPTextFieldDOMInputElement.style.paddingTop = TOP_PADDING - 2.0 + "px";
CPTextFieldDOMInputElement = document.createElement("input");
CPTextFieldDOMInputElement.style.position = "absolute";
CPTextFieldDOMInputElement.style.top = "0px";
CPTextFieldDOMInputElement.style.left = "0px";
CPTextFieldDOMInputElement.style.width = "100%"
CPTextFieldDOMInputElement.style.height = "100%";
CPTextFieldDOMInputElement.style.border = "0px";
CPTextFieldDOMInputElement.style.padding = "0px";
CPTextFieldDOMInputElement.style.whiteSpace = "pre";
CPTextFieldDOMInputElement.style.background = "transparent";
CPTextFieldDOMInputElement.style.outline = "none";
CPTextFieldDOMInputElement.style.paddingLeft = HORIZONTAL_PADDING - 1.0 + "px";
CPTextFieldDOMInputElement.style.paddingTop = TOP_PADDING - 2.0 + "px";
}
return CPTextFieldDOMInputElement;
}
#endif
@@ -144,9 +152,11 @@ var _CPTextFieldSquareBezelColor = nil;
if (self)
{
_value = @"";
_placeholderString = @"";
_value = "";
_placeholderString = "";
_sendActionOn = CPKeyUpMask | CPKeyDownMask;
#if PLATFORM(DOM)
_DOMTextElement = document.createElement("div");
_DOMTextElement.style.position = "absolute";
@@ -166,8 +176,36 @@ var _CPTextFieldSquareBezelColor = nil;
return self;
}
- (void)setDelegate:(id)aDelegate
{
var center = [CPNotificationCenter defaultCenter];
//unsubscribe the existing delegate if it exists
if (_delegate)
{
[center removeObserver:_delegate name:CPControlTextDidBeginEditingNotification object:self];
[center removeObserver:_delegate name:CPControlTextDidChangeNotification object:self];
[center removeObserver:_delegate name:CPControlTextDidEndEditingNotification object:self];
}
_delegate = aDelegate;
if ([_delegate respondsToSelector:@selector(controlTextDidBeginEditing:)])
[center addObserver:_delegate selector:@selector(controlTextDidBeginEditing:) name:CPControlTextDidBeginEditingNotification object:self];
if ([_delegate respondsToSelector:@selector(controlTextDidChange:)])
[center addObserver:_delegate selector:@selector(controlTextDidChange:) name:CPControlTextDidChangeNotification object:self];
if ([_delegate respondsToSelector:@selector(controlTextDidEndEditing:)])
[center addObserver:_delegate selector:@selector(controlTextDidEndEditing:) name:CPControlTextDidEndEditingNotification object:self];
}
- (id)delegate
{
return _delegate;
}
// Setting the Bezel Style
/*
/*!
Sets whether the textfield will have a bezeled border.
@param shouldBeBezeled <code>YES</code> means the textfield will draw a bezeled border
*/
@@ -181,7 +219,7 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
/*
/*!
Returns <code>YES</code> if the textfield draws a bezeled border.
*/
- (BOOL)isBezeled
@@ -189,7 +227,7 @@ var _CPTextFieldSquareBezelColor = nil;
return _isBezeled;
}
/*
/*!
Sets the textfield's bezel style.
@param aBezelStyle the constant for the desired bezel style
*/
@@ -203,7 +241,7 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
/*
/*!
Returns the textfield's bezel style.
*/
- (CPTextFieldBezelStyle)bezelStyle
@@ -211,7 +249,7 @@ var _CPTextFieldSquareBezelColor = nil;
return _bezelStyle;
}
/*
/*!
Sets whether the textfield will have a border drawn.
@param shouldBeBordered <code>YES</code> makes the textfield draw a border
*/
@@ -225,7 +263,7 @@ var _CPTextFieldSquareBezelColor = nil;
[self _updateBackground];
}
/*
/*!
Returns <code>YES</code> if the textfield has a border.
*/
- (BOOL)isBordered
@@ -233,33 +271,102 @@ var _CPTextFieldSquareBezelColor = nil;
return _isBordered;
}
/*!
Sets whether the textfield will have a background drawn.
@param shouldDrawBackground <code>YES</code> makes the textfield draw a background
*/
- (void)setDrawsBackground:(BOOL)shouldDrawBackground
{
if (_drawsBackground == shouldDrawBackground)
return;
_drawsBackground = shouldDrawBackground;
[self _updateBackground];
}
/*!
Returns <code>YES</code> if the textfield draws a background.
*/
- (BOOL)drawsBackground
{
return _drawsBackground;
}
/*!
Sets the background color, which is shown for non-bezeled text fields with drawsBackground set to YES
@param aColor The background color
*/
- (void)setTextFieldBackgroundColor:(BOOL)aColor
{
if (_textFieldBackgroundColor == aColor)
return;
_textFieldBackgroundColor = aColor;
[self _updateBackground];
}
/*!
Returns the background color.
*/
- (BOOL)textFieldBackgroundColor
{
return _textFieldBackgroundColor;
}
/* @ignore */
- (void)_updateBackground
{
if (_isBordered && _bezelStyle == CPTextFieldSquareBezel && _isBezeled)
if (_isBezeled)
{
if (!_CPTextFieldSquareBezelColor)
if (_bezelStyle == CPTextFieldSquareBezel)
{
var bundle = [CPBundle bundleForClass:[CPTextField class]];
if (!_CPTextFieldSquareBezelColor)
{
var bundle = [CPBundle bundleForClass:[CPTextField class]];
_CPTextFieldSquareBezelColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare0.png"] size:CGSizeMake(2.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare1.png"] size:CGSizeMake(1.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare2.png"] size:CGSizeMake(2.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare3.png"] size:CGSizeMake(2.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare4.png"] size:CGSizeMake(1.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare5.png"] size:CGSizeMake(2.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare6.png"] size:CGSizeMake(2.0, 2.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare7.png"] size:CGSizeMake(1.0, 2.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPTextField/CPTextFieldBezelSquare8.png"] size:CGSizeMake(2.0, 2.0)]
]]];
_CPTextFieldSquareBezelColor = [CPColor colorWithPatternImage:[[CPNinePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare0.png"] size:CGSizeMake(2.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare1.png"] size:CGSizeMake(1.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare2.png"] size:CGSizeMake(2.0, 3.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare3.png"] size:CGSizeMake(2.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare4.png"] size:CGSizeMake(1.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare5.png"] size:CGSizeMake(2.0, 1.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare6.png"] size:CGSizeMake(2.0, 2.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare7.png"] size:CGSizeMake(1.0, 2.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelSquare8.png"] size:CGSizeMake(2.0, 2.0)]
]]];
}
[self setBackgroundColor:_CPTextFieldSquareBezelColor];
}
else if (_bezelStyle == CPTextFieldRoundedBezel)
{
if (!_CPTextFieldRoundedBezelColor)
{
var bundle = [CPBundle bundleForClass:[CPTextField class]];
_CPTextFieldRoundedBezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelRounded0.png"] size:CGSizeMake(12.0, 22.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelRounded1.png"] size:CGSizeMake(16.0, 22.0)],
[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"CPTextField/CPTextFieldBezelRounded2.png"] size:CGSizeMake(12.0, 22.0)]
] isVertical:NO]];
}
[self setBackgroundColor:_CPTextFieldRoundedBezelColor];
}
[self setBackgroundColor:_CPTextFieldSquareBezelColor];
}
else
[self setBackgroundColor:nil];
{
if (_drawsBackground)
[self setBackgroundColor:_textFieldBackgroundColor];
else
[self setBackgroundColor:nil];
// FIXME: do something for bordered textfields
//if (_isBordered)
}
}
/* @ignore */
@@ -273,7 +380,7 @@ var _CPTextFieldSquareBezelColor = nil;
{
var string = [self stringValue];
[self setStringValue:@""];
[self setStringValue:""];
#if PLATFORM(DOM)
var element = [[self class] _inputElement];
@@ -283,37 +390,72 @@ var _CPTextFieldSquareBezelColor = nil;
element.style.font = _DOMElement.style.font;
element.style.zIndex = 1000;
element.style.width = CGRectGetWidth([self bounds]) - 3.0 + "px";
element.style.marginTop = "-1px";
element.style.marginTop = "0px";
//element.style.left = _DOMTextElement.style.left;
//element.style.top = _DOMTextElement.style.top;
_DOMElement.appendChild(element);
window.setTimeout(function() { element.focus(); }, 0.0);
element.onblur = function ()
{
[self setObjectValue:element.value];
[self sendAction:[self action] to:[self target]];
[[self window] makeFirstResponder:nil];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
};
//element.onblur = function() { objj_debug_print_backtrace(); }
//element.select();
element.onkeydown = function(aDOMEvent)
{
//all key presses might trigger the delegate method controlTextDidChange:
//record the current string value before we allow this keydown to propagate
_textDidChangeValue = [self stringValue];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
return true;
}
element.onkeypress = function(aDOMEvent)
{
{
aDOMEvent = aDOMEvent || window.event;
if (aDOMEvent.keyCode == 13)
{
if(aDOMEvent.preventDefault)
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
else if(aDOMEvent.stopPropagation)
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
aDOMEvent.cancelBubble = true;
element.blur();
[self sendAction:[self action] to:[self target]];
[[self window] makeFirstResponder:nil];
}
}
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
};
// If current value is the placeholder value, remove it to allow user to update.
if ([_value lowercaseString] == [[self placeholderString] lowercaseString])
[self setStringValue:@""];
//inspect keyup to detect changes in order to trigger controlTextDidChange: delegate method
element.onkeyup = function(aDOMEvent)
{
//check if we should fire a notification for CPControlTextDidChange
if ([self stringValue] != _textDidChangeValue)
{
_textDidChangeValue = [self stringValue];
//call to CPControls methods for posting the notification
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
}
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
};
// If current value is the placeholder value, remove it to allow user to update.
if ([string lowercaseString] == [[self placeholderString] lowercaseString])
[self setStringValue:""];
//post CPControlTextDidBeginEditingNotification
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
[[CPDOMWindowBridge sharedDOMWindowBridge] _propagateCurrentDOMEvent:YES];
#endif
@@ -325,19 +467,35 @@ var _CPTextFieldSquareBezelColor = nil;
{
#if PLATFORM(DOM)
var element = [[self class] _inputElement];
//nil out dom handlers
element.onkeyup = nil;
element.onkeydown = nil;
element.onkeypress = nil;
_DOMElement.removeChild(element);
[self setStringValue:element.value];
[self setStringValue:element.value]; // redundant?
// If textfield has no value, then display the placeholderValue
if (!_value)
[self setStringValue:[self placeholderString]];
#endif
//post CPControlTextDidEndEditingNotification
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
return YES;
}
/*
- (void)mouseUp:(CPEvent)anEvent
{
if (_isEditable && [[self window] firstResponder] == self)
return;
[super mouseUp:anEvent];
}
/*!
Sets whether or not the receiver text field can be edited
*/
- (void)setEditable:(BOOL)shouldBeEditable
@@ -345,7 +503,7 @@ var _CPTextFieldSquareBezelColor = nil;
_isEditable = shouldBeEditable;
}
/*
/*!
Returns <code>YES</code> if the textfield is currently editable by the user.
*/
- (BOOL)isEditable
@@ -362,7 +520,7 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
/*
/*!
Returns <code>YES</code> if the field's text is selectable by the user.
*/
- (BOOL)isSelectable
@@ -370,7 +528,7 @@ var _CPTextFieldSquareBezelColor = nil;
return _isSelectable;
}
/*
/*!
Sets whether the field's text is selectable by the user.
@param aFlag <code>YES</code> makes the text selectable
*/
@@ -379,7 +537,7 @@ var _CPTextFieldSquareBezelColor = nil;
_isSelectable = aFlag;
}
/*
/*!
Sets the alignment of the text in the field.
@param anAlignment
*/
@@ -407,7 +565,7 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
/*
/*!
Sets the way line breaks occur in the text field.
@param aLineBreakMode the line break style
*/
@@ -419,30 +577,50 @@ var _CPTextFieldSquareBezelColor = nil;
switch (aLineBreakMode)
{
case CPLineBreakByTruncatingTail: _DOMTextElement.style.textOverflow = "ellipsis";
_DOMTextElement.style.whiteSpace = "nowrap";
_DOMTextElement.style.overflow = "hidden";
_DOMTextElement.style.whiteSpace = "nowrap";
_DOMTextElement.style.overflow = "hidden";
if (document.attachEvent)
_DOMTextElement.style.wordWrap = "normal";
break;
case CPLineBreakByWordWrapping: _DOMTextElement.style.whiteSpace = "normal";
_DOMTextElement.style.overflow = "hidden";
case CPLineBreakByWordWrapping: if (document.attachEvent)
{
_DOMTextElement.style.whiteSpace = "pre";
_DOMTextElement.style.wordWrap = "break-word";
}
else
{
_DOMTextElement.style.whiteSpace = "-o-pre-wrap";
_DOMTextElement.style.whiteSpace = "-pre-wrap";
_DOMTextElement.style.whiteSpace = "-moz-pre-wrap";
_DOMTextElement.style.whiteSpace = "pre-wrap";
}
_DOMTextElement.style.overflow = "hidden";
_DOMTextElement.style.textOverflow = "clip";
break;
}
#endif
}
/*
/*!
Returns the string the text field.
*/
- (CPString)stringValue
- (id)objectValue
{
// All of this needs to be better.
#if PLATFORM(DOM)
if ([[self window] firstResponder] == self)
return [[self class] _inputElement].value;
#endif
//if the content is the same as the placeholder value, return "" instead
if ([super objectValue] == [self placeholderString])
return "";
return [super stringValue];
return [super objectValue];
}
/*
@@ -460,6 +638,9 @@ var _CPTextFieldSquareBezelColor = nil;
else if (aValue)
displayString += aValue;
if ([[self window] firstResponder] == self)
[[self class] _inputElement].value = displayString;
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
_DOMTextElement.innerText = displayString;
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
@@ -467,7 +648,7 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
/*
/*!
Returns the receiver's placeholder string
*/
- (CPString)placeholderString
@@ -475,28 +656,32 @@ var _CPTextFieldSquareBezelColor = nil;
return _placeholderString;
}
/*
/*!
Sets a placeholder string for the receiver. The placeholder is displayed until editing begins,
and after editing ends, if the text field has an empty string value
*/
-(void)setPlaceholderString:(CPString)aStringValue
{
_placeholderString = aStringValue;
//if there is no set value, automatically display the placeholder
if (!_value)
[self setStringValue:aStringValue];
}
/*
/*!
Adjusts the text field's size in the application.
*/
- (void)sizeToFit
{
#if PLATFORM(DOM)
var size = [_value ? _value : @" " sizeWithFont:[self font]];
var size = [(_value || " ") sizeWithFont:[self font]];
[self setFrameSize:CGSizeMake(size.width + 2 * HORIZONTAL_PADDING, size.height + TOP_PADDING + BOTTOM_PADDING)];
#endif
}
/*
/*!
Select all the text in the CPTextField.
*/
- (void)selectText:(id)sender
@@ -509,16 +694,23 @@ var _CPTextFieldSquareBezelColor = nil;
#endif
}
@end
var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
CPTextFieldLineBreakModeKey = @"CPTextFieldLineBreakModeKey",
CPTextFieldStringValueKey = @"CPTextFieldStringValueKey",
CPTextFieldIsEditableKey = @"CPTextFieldIsEditableKey";
var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
CPTextFieldIsSelectableKey = "CPTextFieldIsSelectableKey",
CPTextFieldIsBorderedKey = "CPTextFieldIsBorderedKey",
CPTextFieldIsBezeledKey = "CPTextFieldIsBezeledKey",
CPTextFieldBezelStyleKey = "CPTextFieldBezelStyleKey",
CPTextFieldDrawsBackgroundKey = "CPTextFieldDrawsBackgroundKey",
CPTextFieldLineBreakModeKey = "CPTextFieldLineBreakModeKey",
CPTextFieldBackgroundColorKey = "CPTextFieldBackgroundColorKey",
CPTextFieldPlaceholderStringKey = "CPTextFieldPlaceholderStringKey";
@implementation CPTextField (CPCoding)
/*
/*!
Initializes the textfield with data from a coder.
@param aCoder the coder from which to read the textfield data
@return the initialized textfield
@@ -533,11 +725,8 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
if (self)
{
var bounds = [self bounds];
_value = @"";
#if PLATFORM(DOM)
var bounds = [self bounds];
_DOMTextElement.style.position = "absolute";
_DOMTextElement.style.top = TOP_PADDING + "px";
_DOMTextElement.style.left = HORIZONTAL_PADDING + "px";
@@ -550,16 +739,23 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
#endif
[self setEditable:[aCoder decodeBoolForKey:CPTextFieldIsEditableKey]];
[self setSelectable:[aCoder decodeBoolForKey:CPTextFieldIsSelectableKey]];
[self setLineBreakMode:[aCoder decodeIntForKey:CPTextFieldLineBreakModeKey]];
[self setSelectable:[aCoder decodeBoolForKey:CPTextFieldIsSelectableKey]];
[self setStringValue:[aCoder decodeObjectForKey:CPTextFieldStringValueKey]];
[self setBordered:[aCoder decodeBoolForKey:CPTextFieldIsBorderedKey]];
[self setBezeled:[aCoder decodeBoolForKey:CPTextFieldIsBezeledKey]];
[self setBezelStyle:[aCoder decodeIntForKey:CPTextFieldBezelStyleKey]];
[self setDrawsBackground:[aCoder decodeBoolForKey:CPTextFieldDrawsBackgroundKey]];
[self setLineBreakMode:[aCoder decodeIntForKey:CPTextFieldLineBreakModeKey]];
[self setTextFieldBackgroundColor:[aCoder decodeObjectForKey:CPTextFieldBackgroundColorKey]];
[self setPlaceholderString:[aCoder decodeObjectForKey:CPTextFieldPlaceholderStringKey]];
}
return self;
}
/*
/*!
Encodes the data of this textfield into the provided coder.
@param aCoder the coder into which the data will be written
*/
@@ -567,12 +763,18 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey",
{
[super encodeWithCoder:aCoder];
[aCoder encodeBool:_isSelectable forKey:CPTextFieldIsSelectableKey];
[aCoder encodeInt:_lineBreakMode forKey:CPTextFieldLineBreakModeKey];
[aCoder encodeObject:_value forKey:CPTextFieldStringValueKey];
[aCoder encodeBool:_isEditable forKey:CPTextFieldIsEditableKey];
[aCoder encodeBool:_isSelectable forKey:CPTextFieldIsSelectableKey];
[aCoder encodeBool:_isBordered forKey:CPTextFieldIsBorderedKey];
[aCoder encodeBool:_isBezeled forKey:CPTextFieldIsBezeledKey];
[aCoder encodeInt:_bezelStyle forKey:CPTextFieldBezelStyleKey];
[aCoder encodeBool:_drawsBackground forKey:CPTextFieldDrawsBackgroundKey];
[aCoder encodeInt:_lineBreakMode forKey:CPTextFieldLineBreakModeKey];
[aCoder encodeObject:_textFieldBackgroundColor forKey:CPTextFieldBackgroundColorKey];
[aCoder encodeObject:_placeholderString forKey:CPTextFieldPlaceholderStringKey];
}
@end
+179 -83
View File
@@ -2,6 +2,9 @@
* CPToolbar.j
* AppKit
*
* Portions based on NSToolbar.m (11/10/2008) in Cocotron (http://www.cocotron.org/)
* Copyright (c) 2006-2007 Christopher J. W. Lloyd
*
* Created by Francisco Tolmasky.
* Copyright 2008, 280 North, Inc.
*
@@ -20,10 +23,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
@import "CPPopUpButton.j"
@import "CPToolbarItem.j"
import "CPPopUpButton.j"
import "CPToolbarItem.j"
/*
@global
@@ -49,25 +53,14 @@ CPToolbarDisplayModeLabelOnly = 3;
var CPToolbarsByIdentifier = nil;
var CPToolbarConfigurationsByIdentifier = nil;
/* @ignore */
var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
{
var lhsVisibilityPriority = [lhs visibilityPriority],
rhsVisibilityPriority = [rhs visibilityPriority];
if (lhsVisibilityPriority == rhsVisibilityPriority)
return CPOrderedSame;
/*!
@class CPToolbar
if (lhsVisibilityPriority > rhsVisibilityPriority)
return CPOrderedAscending;
return CPOrderedDescending;
}
/*
A <objj>CPToolbar</objj> is displayed at the top of a window with multiple
A CPToolbar is displayed at the top of a window with multiple
buttons (tools) that offer the user quick access to features.
@par Delegate Methods
@delegate -(CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar;
Called to obtain the toolbar's default item identifiers. Required.
@param toolbar the toolbar to obtain identifiers for
@@ -93,18 +86,20 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
BOOL _showsBaselineSeparator;
BOOL _allowsUserCustomization;
BOOL _isVisible;
BOOL _needsReloadOfItems;
id _delegate;
CPView _toolbarView;
CPArray _itemIdentifiers;
CPArray _allowedItemIdentifiers;
CPDictionary _identifiedItems;
CPArray _defaultItems;
CPArray _allowedItems;
CPArray _selectableItems;
CPArray _items;
CPArray _labels;
CPArray _itemsSortedByVisibilityPriority;
CPMutableDictionary _itemIndexes;
CPView _toolbarView;
}
/* @ignore */
@@ -117,7 +112,21 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
CPToolbarConfigurationsByIdentifier = [CPDictionary dictionary];
}
/*
/* @ignore */
+ (void)_addToolbar:(CPToolbar)toolbar forIdentifier:(CPString)identifier
{
var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:identifier];
if (!toolbarsSharingIdentifier)
{
toolbarsSharingIdentifier = []
[CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:identifier];
}
[toolbarsSharingIdentifier addObject:toolbar];
}
/*!
Initializes the toolbar with the specified identifier.
@param anIdentifier the identifier for the toolbar
@return the initialized toolbar
@@ -129,26 +138,18 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
if (self)
{
_items = [];
_labels = [];
_identifier = anIdentifier;
_isVisible = YES;
var toolbarsSharingIdentifier = [CPToolbarsByIdentifier objectForKey:_identifier];
if (!toolbarsSharingIdentifier)
{
toolbarsSharingIdentifier = []
[CPToolbarsByIdentifier setObject:toolbarsSharingIdentifier forKey:_identifier];
}
[toolbarsSharingIdentifier addObject:self];
[CPToolbar _addToolbar:self forIdentifier:_identifier];
}
return self;
}
/*
/*!
Sets the toolbar's display mode. NOT YET IMPLEMENTED.
*/
- (void)setDisplayMode:(CPToolbarDisplayMode)aDisplayMode
@@ -156,7 +157,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
}
/*
/*!
Returns the toolbar's identifier
*/
- (CPString)identifier
@@ -164,7 +165,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _identifier;
}
/*
/*!
Returns the toolbar's delegate
*/
- (id)delegate
@@ -172,7 +173,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _delegate;
}
/*
/*!
Returns <code>YES</code> if the toolbar is currently visible
*/
- (BOOL)isVisible
@@ -180,7 +181,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _isVisible;
}
/*
/*!
Sets whether the toolbar should be visible.
@param aFlag <code>YES</code> makes the toolbar visible
*/
@@ -195,7 +196,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
[self _reloadToolbarItems];
}
/*
/*!
Sets the delegate for the toolbar.
@param aDelegate the new toolbar delegate
*/
@@ -206,10 +207,6 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
_delegate = aDelegate;
// When _delegate is nil, this will be cleared out.
_itemIdentifiers = nil;
_allowedItemIdentifiers = [_delegate toolbarAllowedItemIdentifiers:self];
[self _reloadToolbarItems];
}
@@ -243,15 +240,13 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
if (!count)
{
_itemIdentifiers = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy];
count = [_itemIdentifiers count];
_itemIdentifiers = [[_delegate toolbarDefaultItemIdentifiers:self] mutableCopy];
count = [_itemIdentifiers count];
}
[[_toolbarView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
_items = [];
_labels = [];
var index = 0;
@@ -262,13 +257,15 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
if (!item)
item = [[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:YES] copy];
if (item == nil)
[CPException raise:CPInvalidArgumentException
format:@"_delegate %@ returned nil toolbar item returned for identifier %@", _delegate, identifier];
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
[_items addObject:item];
}
// _items = [[self _defaultToolbarItems] mutableCopy];
// Store items sorted by priority. We want items to be removed first at the end of the array,
// items to be removed last at the front.
@@ -278,7 +275,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
[_toolbarView reloadToolbarItems];
}
/*
/*!
Returns all the items in this toolbar.
*/
- (CPArray)items
@@ -286,7 +283,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _items;
}
/*
/*!
Returns all the visible items in this toolbar
*/
- (CPArray)visibleItems
@@ -294,21 +291,7 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return [_toolbarView visibleItems];
}
/*
Returns the index of the specified toolbar item
@param anItem the item to obtain the index for
*/
- (int)indexOfItem:(CPToolbarItem)anItem
{
var info = [_itemIndexes objectForKey:[anItem hash]];
if (!info)
return CPNotFound;
return info.index;
}
/*
/*!
Returns the toolbar items sorted by their <code>visibilityPriority</code>(ies).
*/
- (CPArray)itemsSortedByVisibilityPriority
@@ -316,6 +299,113 @@ var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
return _itemsSortedByVisibilityPriority;
}
/* @ignore */
- (id)_itemForItemIdentifier:(CPString)identifier willBeInsertedIntoToolbar:(BOOL)toolbar
{
var item = [_identifiedItems objectForKey:identifier];
if (!item)
{
item = [CPToolbarItem _standardItemWithItemIdentifier:identifier];
if (_delegate && !item)
{
item = [[_delegate toolbar:self itemForItemIdentifier:identifier willBeInsertedIntoToolbar:toolbar] copy];
if (!item)
[CPException raise:CPInvalidArgumentException
reason:sprintf(@"_delegate %s returned nil toolbar item returned for identifier %s", _delegate, identifier)];
}
[_identifiedItems setObject:item forKey:identifier];
}
return item;
}
/* @ignore */
- (id)_itemsWithIdentifiers:(CPArray)identifiers
{
var items = [];
for (var i = 0; i < identifiers.length; i++)
[items addObject:[self _itemForItemIdentifier:identifiers[i] willBeInsertedIntoToolbar:NO]];
return items;
}
/* @ignore */
-(id)_defaultToolbarItems
{
if (!_defaultItems)
if ([_delegate respondsToSelector:@selector(toolbarDefaultItemIdentifiers:)])
_defaultItems = [self _itemsWithIdentifiers:[_delegate toolbarDefaultItemIdentifiers:self]];
return _defaultItems;
}
@end
var CPToolbarIdentifierKey = "CPToolbarIdentifierKey",
CPToolbarDisplayModeKey = "CPToolbarDisplayModeKey",
CPToolbarShowsBaselineSeparatorKey = "CPToolbarShowsBaselineSeparatorKey",
CPToolbarAllowsUserCustomizationKey = "CPToolbarAllowsUserCustomizationKey",
CPToolbarIsVisibleKey = "CPToolbarIsVisibleKey",
CPToolbarDelegateKey = "CPToolbarDelegateKey",
CPToolbarIdentifiedItemsKey = "CPToolbarIdentifiedItemsKey",
CPToolbarDefaultItemsKey = "CPToolbarDefaultItemsKey",
CPToolbarAllowedItemsKey = "CPToolbarAllowedItemsKey",
CPToolbarSelectableItemsKey = "CPToolbarSelectableItemsKey";
@implementation CPToolbar (CPCoding)
/*
Initializes the toolbar by unarchiving data from <code>aCoder</code>.
@param aCoder the coder containing the archived CPToolbar.
*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
_identifier = [aCoder decodeObjectForKey:CPToolbarIdentifierKey];
_displayMode = [aCoder decodeIntForKey:CPToolbarDisplayModeKey];
_showsBaselineSeparator = [aCoder decodeBoolForKey:CPToolbarShowsBaselineSeparatorKey];
_allowsUserCustomization = [aCoder decodeBoolForKey:CPToolbarAllowsUserCustomizationKey];
_isVisible = [aCoder decodeBoolForKey:CPToolbarIsVisibleKey];
_identifiedItems = [aCoder decodeObjectForKey:CPToolbarIdentifiedItemsKey];
_defaultItems = [aCoder decodeObjectForKey:CPToolbarDefaultItemsKey];
_allowedItems = [aCoder decodeObjectForKey:CPToolbarAllowedItemsKey];
_selectableItems = [aCoder decodeObjectForKey:CPToolbarSelectableItemsKey];
_items = [];
[CPToolbar _addToolbar:self forIdentifier:_identifier];
[self setDelegate:[aCoder decodeObjectForKey:CPToolbarDelegateKey]];
}
return self;
}
/*
Archives this toolbar into the provided coder.
@param aCoder the coder to which the toolbar's instance data will be written.
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeObject:_identifier forKey:CPToolbarIdentifierKey];
[aCoder encodeInt:_displayMode forKey:CPToolbarDisplayModeKey];
[aCoder encodeBool:_showsBaselineSeparator forKey:CPToolbarShowsBaselineSeparatorKey];
[aCoder encodeBool:_allowsUserCustomization forKey:CPToolbarAllowsUserCustomizationKey];
[aCoder encodeBool:_isVisible forKey:CPToolbarIsVisibleKey];
[aCoder encodeObject:_identifiedItems forKey:CPToolbarIdentifiedItemsKey];
[aCoder encodeObject:_defaultItems forKey:CPToolbarDefaultItemsKey];
[aCoder encodeObject:_allowedItems forKey:CPToolbarAllowedItemsKey];
[aCoder encodeObject:_selectableItems forKey:CPToolbarSelectableItemsKey];
[aCoder encodeConditionalObject:_delegate forKey:CPToolbarDelegateKey];
}
@end
@@ -340,7 +430,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
CPIndexSet _flexibleWidthIndexes;
CPIndexSet _visibleFlexibleWidthIndexes;
CPMutableDictionary _itemInfos;
CPDictionary _itemInfos;
CPArray _visibleItems;
CPArray _invisibleItems;
@@ -440,6 +530,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
// Determine all the items that have flexible width.
// Also determine the height of the toolbar.
// NOTE: height is height without top margin, and bottom margin/label.
var index = _visibleItems.length,
height = 0.0;
@@ -521,7 +612,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
itemWidth = MAX([self minWidthForItem:item], viewWidth),
viewHeight = MAX([item minSize].height, MIN([item maxSize].height, height));
viewHeight = CGRectGetHeight(viewFrame);
// itemWidth != viewWidth. itemWidth is MAX(size of view, size of label). If the label is larger,
// *center* the view, don't resize it.
@@ -589,16 +680,6 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
}
- (int)indexOfItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem hash]];
if (!info)
return CPNotFound;
return info.index;
}
- (CPView)viewForItem:(CPToolbarItem)anItem
{
var info = [_itemInfos objectForKey:[anItem hash]];
@@ -698,3 +779,18 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
}
@end
/* @ignore */
var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
{
var lhsVisibilityPriority = [lhs visibilityPriority],
rhsVisibilityPriority = [rhs visibilityPriority];
if (lhsVisibilityPriority == rhsVisibilityPriority)
return CPOrderedSame;
if (lhsVisibilityPriority > rhsVisibilityPriority)
return CPOrderedAscending;
return CPOrderedDescending;
}
+119 -59
View File
@@ -20,11 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@import <AppKit/CPImage.j>
@import <AppKit/CPView.j>
import <AppKit/CPImage.j>
import <AppKit/CPView.j>
/*
@global
@@ -57,8 +58,9 @@ CPToolbarPrintItemIdentifier = @"CPToolbarPrintItemIdentifier";
var _CPToolbarSeparatorItemView = nil;
/*
A representation of an item in a <objj>CPToolbar</objj>.
/*! @class CPToolbarItem
A representation of an item in a CPToolbar.
*/
@implementation CPToolbarItem : CPObject
{
@@ -75,7 +77,9 @@ var _CPToolbarSeparatorItemView = nil;
BOOL _isEnabled;
CPImage _image;
CPImage _alternateImage;
CPView _view;
CGSize _minSize;
CGSize _maxSize;
@@ -83,7 +87,7 @@ var _CPToolbarSeparatorItemView = nil;
}
// Creating a Toolbar Item
/*
/*!
Initializes the toolbar item with a specified identifier.
@param anItemIdentifier the item's identifier
@return the initialized toolbar item
@@ -96,6 +100,9 @@ var _CPToolbarSeparatorItemView = nil;
{
_itemIdentifier = anItemIdentifier;
_tag = 0;
_isEnabled = YES;
_minSize = CGSizeMakeZero();
_maxSize = CGSizeMakeZero();
@@ -106,7 +113,7 @@ var _CPToolbarSeparatorItemView = nil;
}
// Managing Attributes
/*
/*!
Returns the item's identifier.
*/
- (CPString)itemIdentifier
@@ -114,7 +121,7 @@ var _CPToolbarSeparatorItemView = nil;
return _itemIdentifier;
}
/*
/*!
Returns the toolbar of which this item is a part.
*/
- (CPToolbar)toolbar
@@ -122,7 +129,7 @@ var _CPToolbarSeparatorItemView = nil;
return _toolbar;
}
/*
/*!
Returns the item's label
*/
- (CPString)label
@@ -130,7 +137,7 @@ var _CPToolbarSeparatorItemView = nil;
return _label;
}
/*
/*!
Sets the item's label.
@param aLabel the new label for the item
*/
@@ -139,7 +146,7 @@ var _CPToolbarSeparatorItemView = nil;
_label = aLabel;
}
/*
/*!
Returns the palette label.
*/
- (CPString)paletteLabel
@@ -147,7 +154,7 @@ var _CPToolbarSeparatorItemView = nil;
return _paletteLabel;
}
/*
/*!
Sets the palette label
@param aPaletteLabel the new palette label
*/
@@ -156,148 +163,188 @@ var _CPToolbarSeparatorItemView = nil;
_paletteLabel = aPaletteLabel;
}
/*
/*!
Returns the item's tooltip. A tooltip pops up
next to the cursor when the user hovers over
the item with the mouse.
*/
- (CPString)toolTip
{
if ([_view respondsToSelector:@selector(toolTip)])
return [_view toolTip];
return _toolTip;
}
/*
/*!
Sets the item's tooltip. A tooltip pops up next to the cursor when the user hovers over the item with the mouse.
@param aToolTip the new item tool tip
*/
- (void)setToolTip:(CPString)aToolTip
{
if ([_view respondsToSelector:@selector(setToolTip:)])
[view setToolTip:aToolTip];
_toolTip = aToolTip;
}
/*
/*!
Returns the item's tag.
*/
- (int)tag
{
if ([_view respondsToSelector:@selector(tag)])
return [_view tag];
return _tag;
}
/*
/*!
Sets the item's tag.
@param aTag the new tag for the item
*/
- (void)setTag:(int)aTag
{
if ([_view respondsToSelector:@selector(setTag:)])
[_view setTag:aTag];
_tag = aTag;
}
/*
/*!
Returns the item's action target.
*/
- (id)target
{
if (_view)
return [_view respondsToSelector:@selector(target)] ? [_view target] : nil;
return _target;
}
/*
/*!
Sets the target of the action that is triggered when the user clicks this item. <code>nil</code> will cause
the action to be passed on to the first responder.
@param aTarget the new target
*/
- (void)setTarget:(id)aTarget
{
_target = aTarget;
if (!_view)
_target = aTarget;
else if ([_view respondsToSelector:@selector(setTarget:)])
[_view setTarget:aTarget];
}
/*
/*!
Returns the action that is triggered when the user clicks this item.
*/
- (SEL)action
{
if (_view)
return [_view respondsToSelector:@selector(action)] ? [_view action] : nil;
return _action;
}
/*
/*!
Sets the action that is triggered when the user clicks this item.
@param anAction the new action
*/
- (void)setAction:(SEL)anAction
{
_action = anAction;
if (!_view)
_action = anAction;
else if ([_view respondsToSelector:@selector(setAction:)])
[_view setAction:anAction];
}
/*
/*!
Returns <code>YES</code> if the item is enabled.
*/
- (BOOL)isEnabled
{
if ([_view respondsToSelector:@selector(isEnabled)])
return [_view isEnabled];
return _isEnabled;
}
/*
/*!
Sets whether the item is enabled.
@param aFlag <code>YES</code> enables the item
*/
- (void)setEnabled:(BOOL)aFlag
- (void)setEnabled:(BOOL)shouldBeEnabled
{
_isEnabled = aFlag;
if ([_view respondsToSelector:@selector(setEnabled:)])
[_view setEnabled:shouldBeEnabled];
_isEnabled = shouldBeEnabled;
}
/*
/*!
Returns the item's image
*/
- (CPImage)image
{
if ([_view respondsToSelector:@selector(image)])
return [_view image];
return _image;
}
/*
/*!
Sets the item's image.
@param anImage the new item image
*/
- (void)setImage:(CPImage)anImage
{
if ([_view respondsToSelector:@selector(setImage:)])
[_view setImage:anImage];
_image = anImage;
// FIXME: We can't keep assuming this.
[_view setImage:anImage];
if (!_image)
return;
var imageSize = [_image size];
if (_minSize.width == 0 && _minSize.height == 0 &&
_maxSize.width == 0 && _maxSize.height == 0 &&
(imageSize.width > 0 || imageSize.height > 0))
_maxSize.width == 0 && _maxSize.height == 0)
{
[self setMinSize:imageSize];
[self setMaxSize:imageSize];
var imageSize = [_image size];
if (imageSize.width > 0 || imageSize.height > 0)
{
[self setMinSize:imageSize];
[self setMaxSize:imageSize];
}
}
}
/*
/*!
Sets the alternate image. This image is displayed on the item when the user is clicking it.
@param anImage the new alternate image
*/
- (void)setAlternateImage:(CPImage)anImage
{
_alternateImage = anImage;
if ([_view respondsToSelector:@selector(setAlternateImage:)])
[_view setAlternateImage:anImage];
// FIXME: We can't keep assuming this.
[_view setAlternateImage:anImage];
_alternateImage = anImage;
}
/*
/*!
Returns the alternate image. This image is displayed on the item when the user is clicking it.
*/
- (CPImage)alternateImage
{
if ([_view respondsToSelector:@selector(alternateIamge)])
return [_view alternateImage];
return _alternateImage;
}
/*
/*!
Returns the item's view.
*/
- (CPView)view
@@ -305,16 +352,29 @@ var _CPToolbarSeparatorItemView = nil;
return _view;
}
/*
/*!
Sets the item's view
@param aView the item's new view
*/
- (void)setView:(CPView)aView
{
if (_view == aView)
return;
_view = aView;
if (_view)
{
// Tags get forwarded.
if (_tag !== 0 && [_view respondsToSelector:@selector(setTag:)])
[_view setTag:_tag];
_target = nil;
_action = nil;
}
}
/*
/*!
Returns the item's minimum size.
*/
- (CGSize)minSize
@@ -322,7 +382,7 @@ var _CPToolbarSeparatorItemView = nil;
return _minSize;
}
/*
/*!
Sets the item's minimum size.
@param aMinSize the new minimum size
*/
@@ -334,7 +394,7 @@ var _CPToolbarSeparatorItemView = nil;
_maxSize = CGSizeMake(MAX(_minSize.width, _maxSize.width), MAX(_minSize.height, _maxSize.height));
}
/*
/*!
Returns the item's maximum size.
*/
- (CGSize)maxSize
@@ -342,7 +402,7 @@ var _CPToolbarSeparatorItemView = nil;
return _maxSize;
}
/*
/*!
Sets the item's new maximum size.
@param aMaxSize the new maximum size
*/
@@ -355,7 +415,7 @@ var _CPToolbarSeparatorItemView = nil;
}
// Visibility Priority
/*
/*!
Returns the item's visibility priority. The value will be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
@@ -369,7 +429,7 @@ CPToolbarItemVisibilityPriorityUser
return _visibilityPriority;
}
/*
/*!
Sets the item's visibility priority. The value must be one of:
<pre>
CPToolbarItemVisibilityPriorityStandard
@@ -392,21 +452,21 @@ CPToolbarItemVisibilityPriorityUser
{
var copy = [[[self class] alloc] initWithItemIdentifier:_itemIdentifier];
if (_view)
[copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]];
[copy setLabel:_label];
[copy setPaletteLabel:_paletteLabel];
[copy setToolTip:_toolTip];
[copy setToolTip:[self toolTip]];
[copy setTag:_tag];
[copy setTarget:_target];
[copy setAction:_action];
[copy setTag:[self tag]];
[copy setTarget:[self target]];
[copy setAction:[self action]];
[copy setEnabled:_isEnabled];
[copy setEnabled:[self isEnabled]];
[copy setImage:_image];
[copy setAlternateImage:_alternateImage];
if (_view)
[copy setView:[CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:_view]]];
[copy setMinSize:_minSize];
[copy setMaxSize:_maxSize];
+141 -128
View File
@@ -20,17 +20,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
import <Foundation/CPObjJRuntime.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPObjJRuntime.j>
import "CGAffineTransform.j"
import "CGGeometry.j"
@import "CGAffineTransform.j"
@import "CGGeometry.j"
@import "CPColor.j"
@import "CPDOMDisplayServer.j"
@import "CPGeometry.j"
@import "CPResponder.j"
@import "CPGraphicsContext.j"
import "CPColor.j"
import "CPDOMDisplayServer.j"
import "CPGeometry.j"
import "CPResponder.j"
import "CPGraphicsContext.j"
#include "Platform/Platform.h"
#include "CoreGraphics/CGAffineTransform.h"
@@ -99,18 +100,19 @@ var DOMElementPrototype = nil,
CustomDrawRectViews = {};
#endif
/*
<objj>CPView</objj> is an abstract class which provides facilities for drawing
/*! @class CPView
<p>CPView is a class which provides facilities for drawing
in a window and receiving events. It is the superclass of many of the visual
elements of the GUI.</p>
<p>In order to display itself, a view must be placed in a window (represented by an
<objj>CPWindow</objj> object). Within the window is a hierarchy of <objj>CPView</objj>s,
CPWindow object). Within the window is a hierarchy of CPViews,
headed by the window's content view. Every other view in a window is a descendant
of this view.</p>
<p>Subclasses can override <code>-drawRect:</code> in order to implement their
appearance. Other methods of <objj>CPView</objj> and <objj>CPResponder</objj> can
appearance. Other methods of CPView and CPResponder can
also be overridden to handle user generated events.
*/
@implementation CPView : CPResponder
@@ -195,7 +197,7 @@ var DOMElementPrototype = nil,
return [self initWithFrame:CGRectMakeZero()];
}
/*
/*!
Initializes the receiver for usage with the specified bounding rectangle
@return the initialized view
*/
@@ -240,7 +242,7 @@ var DOMElementPrototype = nil,
return self;
}
/*
/*!
Returns the container view of the receiver
@return the receiver's containing view
*/
@@ -249,16 +251,16 @@ var DOMElementPrototype = nil,
return _superview;
}
/*
/*!
Returns an array of all the views contained as direct children of the receiver
@return an array of <objj>CPView</objj>s
@return an array of CPViews
*/
- (CPArray)subviews
{
return _subviews;
}
/*
/*!
Returns the window containing this receiver
*/
- (CPWindow)window
@@ -266,16 +268,16 @@ var DOMElementPrototype = nil,
return _window;
}
/*
/*!
Makes the argument a subview of the receiver.
@param aSubview the <objj>CPView</objj> to make a subview
@param aSubview the CPView to make a subview
*/
- (void)addSubview:(CPView)aSubview
{
[self _insertSubview:aSubview atIndex:CPNotFound];
}
/*
/*!
Makes <code>aSubview</code> a subview of the receiver. It is positioned relative to <code>anotherView</code>
@param aSubview the view to add as a subview
@param anOrderingMode specifies <code>aSubview</code>'s ordering relative to <code>anotherView</code>
@@ -286,11 +288,11 @@ var DOMElementPrototype = nil,
var index = anotherView ? [_subviews indexOfObjectIdenticalTo:anotherView] : CPNotFound;
// In other words, if no view, then either all the way at the bottom or all the way at the top.
if (index == CPNotFound)
index = (anOrderingMode == CPWindowAbove) ? [_subviews count] : 0;
if (index === CPNotFound)
index = (anOrderingMode === CPWindowAbove) ? [_subviews count] : 0;
// else, if we have a view, above if above.
else if (anOrderingMode == CPWindowAbove)
else if (anOrderingMode === CPWindowAbove)
++index;
[self _insertSubview:aSubview atIndex:index];
@@ -307,7 +309,8 @@ var DOMElementPrototype = nil,
{
var index = [_subviews indexOfObjectIdenticalTo:aSubview];
if (index == anIndex || index == count - 1 && anIndex == count)
// FIXME: should this be anIndex >= count? (last one)
if (index === anIndex || index === count - 1 && anIndex === count)
return;
[_subviews removeObjectAtIndex:index];
@@ -318,6 +321,9 @@ var DOMElementPrototype = nil,
if (anIndex > index)
--anIndex;
//We've effectively made the subviews array shorter, so represent that.
--count;
}
else
{
@@ -334,7 +340,7 @@ var DOMElementPrototype = nil,
aSubview._superview = self;
}
if (anIndex == CPNotFound || anIndex >= count)
if (anIndex === CPNotFound || anIndex >= count)
{
_subviews.push(aSubview);
@@ -359,7 +365,7 @@ var DOMElementPrototype = nil,
[self didAddSubview:aSubview];
}
/*
/*!
Called when the receiver has added <code>aSubview</code> to it's child views.
@param aSubview the view that was added
*/
@@ -367,7 +373,7 @@ var DOMElementPrototype = nil,
{
}
/*
/*!
Removes the receiver from it's container view and window.
Does nothing if there's no container view.
*/
@@ -388,7 +394,7 @@ var DOMElementPrototype = nil,
[self _setWindow:nil];
}
/*
/*!
Replaces the specified child view with another view
@param aSubview the view to replace
@param aView the replacement view
@@ -421,7 +427,7 @@ var DOMElementPrototype = nil,
[self viewDidMoveToWindow];
}
/*
/*!
Returns <code>YES</code> if the receiver is, or is a descendant of, <code>aView</code>.
@param aView the view to test for ancestry
*/
@@ -438,7 +444,7 @@ var DOMElementPrototype = nil,
return NO;
}
/*
/*!
Called when the receiver's superview has changed.
*/
- (void)viewDidMoveToSuperview
@@ -447,14 +453,14 @@ var DOMElementPrototype = nil,
[self setNeedsDisplay:YES];
}
/*
Called when the receiver has been moved to a new <objj>CPWindow</objj>.
/*!
Called when the receiver has been moved to a new CPWindow.
*/
- (void)viewDidMoveToWindow
{
}
/*
/*!
Called when the receiver is about to be moved to a new view.
@param aView the view to which the receiver will be moved
*/
@@ -462,7 +468,7 @@ var DOMElementPrototype = nil,
{
}
/*
/*!
Called when the receiver is about to be moved to a new window.
@param aWindow the window to which the receiver will be moved.
*/
@@ -470,7 +476,7 @@ var DOMElementPrototype = nil,
{
}
/*
/*!
Called when the receiver is about to be remove one of its subviews.
@param aView the view that will be removed
*/
@@ -478,7 +484,7 @@ var DOMElementPrototype = nil,
{
}
/*
/*!
Returns the menu item containing the receiver or one of its ancestor views.
@return a menu item, or <code>nil</code> if the view or one of its ancestors wasn't found
*/
@@ -507,7 +513,7 @@ var DOMElementPrototype = nil,
return _tag;
}
/*
/*!
Returns whether the view is flipped.
@return <code>YES</code> if the view is flipped. <code>NO</code>, otherwise.
*/
@@ -516,9 +522,9 @@ var DOMElementPrototype = nil,
return YES;
}
/*
/*!
Sets the frame size of the receiver to the dimensions and origin of the provided rectangle in the coordinate system
of the superview. The method also posts an <objj>CPViewFrameDidChangeNotification</objj> to the notification
of the superview. The method also posts an CPViewFrameDidChangeNotification to the notification
center if the receiver is configured to do so. If the frame is the same as the current frame, the method simply
returns (and no notificaion is posted).
@param aFrame the rectangle specifying the new origin and size of the receiver
@@ -539,7 +545,7 @@ var DOMElementPrototype = nil,
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
/*
/*!
Returns the receiver's frame.
@return a copy of the receiver's frame
*/
@@ -548,9 +554,9 @@ var DOMElementPrototype = nil,
return _CGRectMakeCopy(_frame);
}
/*
/*!
Sets the receiver's frame origin to the provided point. The point is defined in the superview's coordinate system.
The method posts a <objj>CPViewFrameDidChangeNotification</objj> to the default notification center if the receiver
The method posts a CPViewFrameDidChangeNotification to the default notification center if the receiver
is configured to do so. If the specified origin is the same as the frame's current origin, the method will
simply return (and no notification will be posted).
@param aPoint the new origin point
@@ -573,9 +579,9 @@ var DOMElementPrototype = nil,
#endif
}
/*
/*!
Sets the receiver's frame size. If <code>aSize</code> is the same as the frame's current dimensions, this
method simply returns. The method posts a <objj>CPViewFrameDidChangeNotification</objj> to the
method simply returns. The method posts a CPViewFrameDidChangeNotification to the
default notification center if the receiver is configured to do so.
@param aSize the new size for the frame
*/
@@ -646,9 +652,9 @@ var DOMElementPrototype = nil,
#endif
}
/*
/*!
Sets the receiver's bounds. The bounds define the size and location of the receiver inside it's frame. Posts a
<objj>CPViewBoundsDidChangeNotification</objj> to the default notification center if the receiver is configured to do so.
CPViewBoundsDidChangeNotification to the default notification center if the receiver is configured to do so.
@param bounds the new bounds
*/
- (void)setBounds:(CGRect)bounds
@@ -667,7 +673,7 @@ var DOMElementPrototype = nil,
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*
/*!
Returns the receiver's bounds. The bounds define the size
and location of the receiver inside its frame.
*/
@@ -676,9 +682,9 @@ var DOMElementPrototype = nil,
return _CGRectMakeCopy(_bounds);
}
/*
/*!
Sets the location of the receiver inside its frame. The method
posts a <objj>CPViewBoundsDidChangeNotification</objj> to the
posts a CPViewBoundsDidChangeNotification to the
default notification center if the receiver is configured to do so.
@param aPoint the new location for the receiver
*/
@@ -719,9 +725,9 @@ var DOMElementPrototype = nil,
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*
/*!
Sets the receiver's size inside its frame. The method posts a
<objj>CPViewBoundsDidChangeNotification</objj> to the default
CPViewBoundsDidChangeNotification to the default
notification center if the receiver is configured to do so.
@param aSize the new size for the receiver
*/
@@ -758,7 +764,7 @@ var DOMElementPrototype = nil,
}
/*
/*!
Notifies subviews that the superview changed size.
@param aSize the size of the old superview
*/
@@ -789,7 +795,7 @@ var DOMElementPrototype = nil,
[self setFrame:newFrame];
}
/*
/*!
Initiates <code>superviewSizeChanged:</code> messages to subviews.
@param aSize the size for the subviews
*/
@@ -801,7 +807,7 @@ var DOMElementPrototype = nil,
[_subviews[count] resizeWithOldSuperviewSize:aSize];
}
/*
/*!
Specifies whether the receiver view should automatically resize its
subviews when its <code>setFrameSize:</code> method receives a change.
@param aFlag If <code>YES</code>, then subviews will automatically be resized
@@ -813,7 +819,7 @@ var DOMElementPrototype = nil,
_autoresizesSubviews = aFlag;
}
/*
/*!
Reports whether the receiver automatically resizes its subviews when its frame size changes.
@return <code>YES</code> means it resizes its subviews on a frame size change.
*/
@@ -822,7 +828,7 @@ var DOMElementPrototype = nil,
return _autoresizesSubviews;
}
/*
/*!
Determines automatic resizing behavior.
@param aMask a bit mask with options
*/
@@ -831,7 +837,7 @@ var DOMElementPrototype = nil,
_autoresizingMask = aMask;
}
/*
/*!
Returns the bit mask options for resizing behavior
*/
- (unsigned)autoresizingMask
@@ -840,7 +846,7 @@ var DOMElementPrototype = nil,
}
// Fullscreen Mode
/*
/*!
Puts the receiver into full screen mode.
@param aScreen the that should be used
@param options configuration options
@@ -871,7 +877,7 @@ var DOMElementPrototype = nil,
return YES;
}
/*
/*!
The receiver should exit full screen mode.
@param options configurations options
*/
@@ -889,7 +895,7 @@ var DOMElementPrototype = nil,
[[self window] orderOut:self];
}
/*
/*!
Returns <code>YES</code> if the receiver is currently in full screen mode.
*/
- (BOOL)isInFullScreenMode
@@ -897,7 +903,7 @@ var DOMElementPrototype = nil,
return _isInFullScreenMode;
}
/*
/*!
Sets whether the receiver should be hidden.
@param aFlag <code>YES</code> makes the receiver hidden.
*/
@@ -913,7 +919,7 @@ var DOMElementPrototype = nil,
#endif
}
/*
/*!
Returns <code>YES</code> if the receiver is hidden.
*/
- (BOOL)isHidden
@@ -921,7 +927,7 @@ var DOMElementPrototype = nil,
return _isHidden;
}
/*
/*!
Sets the opacity of the receiver. The value must be in the range of 0.0 to 1.0, where 0.0 is
completely transparent and 1.0 is completely opaque.
@param anAlphaValue an alpha value ranging from 0.0 to 1.0.
@@ -934,16 +940,21 @@ var DOMElementPrototype = nil,
_opacity = anAlphaValue;
#if PLATFORM(DOM)
_DOMElement.style.opacity = anAlphaValue;
if (anAlphaValue == 1.0)
try { _DOMElement.style.removeAttribute("filter") } catch (anException) { }
if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature))
{
if (anAlphaValue == 1.0)
try { _DOMElement.style.removeAttribute("filter") } catch (anException) { }
else
_DOMElement.style.filter = "alpha(opacity=" + anAlphaValue * 100 + ")";
}
else
_DOMElement.style.filter = "alpha(opacity=" + anAlphaValue * 100 + ")";
_DOMElement.style.opacity = anAlphaValue;
#endif
}
/*
/*!
Returns the alpha value of the receiver. Ranges from 0.0 to
1.0, where 0.0 is completely transparent and 1.0 is completely opaque.
*/
@@ -952,7 +963,7 @@ var DOMElementPrototype = nil,
return _opacity;
}
/*
/*!
Returns <code>YES</code> if the receiver is hidden, or one
of it's ancestor views is hidden. <code>NO</code>, otherwise.
*/
@@ -966,7 +977,7 @@ var DOMElementPrototype = nil,
return view != nil;
}
/*
/*!
Returns whether the receiver should be sent a <code>mouseDown:</code> message for <code>anEvent</code>.<br/>
Returns <code>YES</code> by default.
@return <code>YES</code>, if the view object accepts first mouse-down event. <code>NO</code>, otherwise.
@@ -977,16 +988,16 @@ var DOMElementPrototype = nil,
return YES;
}
/*
/*!
Returns whether or not the view responds to hit tests.
@return <code>YES</code> if this view listens to hitTest messages, <code>NO</code> otherwise.
*/
- (BOOL)hitTests
{
return YES;
return _hitTests;
}
/*
/*!
Set whether or not the view should respond to hit tests.
@param shouldHitTest should be <code>YES</code> if this view should respond to hit tests, <code>NO</code> otherwise.
*/
@@ -995,7 +1006,7 @@ var DOMElementPrototype = nil,
_hitTests = shouldHitTest;
}
/*
/*!
Tests whether a point is contained within this view, or one of its subviews.
@param aPoint the point to test
@return returns the containing view, or nil if the point is not contained
@@ -1019,7 +1030,7 @@ var DOMElementPrototype = nil,
return self;
}
/*
/*!
Returns <code>YES</code> if mouse events aren't needed by the receiver and can be sent to the superview. The
default implementation returns <code>NO</code> if the view is opaque.
*/
@@ -1034,7 +1045,7 @@ var DOMElementPrototype = nil,
[super mouseDown:anEvent];
}
/*
/*!
Sets the background color of the receiver.
@param aColor the new color for the receiver's background
*/
@@ -1149,7 +1160,7 @@ var DOMElementPrototype = nil,
#endif
}
/*
/*!
Returns the background color of the receiver
*/
- (CPColor)backgroundColor
@@ -1158,7 +1169,7 @@ var DOMElementPrototype = nil,
}
// Converting Coordinates
/*
/*!
Converts <code>aPoint</code> from the coordinate space of <code>aView</code> to the coordinate space of the receiver.
@param aPoint the point to convert
@param aView the view space to convert from
@@ -1169,7 +1180,7 @@ var DOMElementPrototype = nil,
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(aView, self));
}
/*
/*!
Converts <code>aPoint</code> from the receiver's coordinate space to the coordinate space of <code>aView</code>.
@param aPoint the point to convert
@param aView the coordinate space to which the point will be converted
@@ -1180,7 +1191,7 @@ var DOMElementPrototype = nil,
return CGPointApplyAffineTransform(aPoint, _CPViewGetTransform(self, aView));
}
/*
/*!
Convert's <code>aSize</code> from <code>aView</code>'s coordinate space to the receiver's coordinate space.
@param aSize the size to convert
@param aView the coordinate space to convert from
@@ -1191,7 +1202,7 @@ var DOMElementPrototype = nil,
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(aView, self));
}
/*
/*!
Convert's <code>aSize</code> from the receiver's coordinate space to <code>aView</code>'s coordinate space.
@param aSize the size to convert
@param the coordinate space to which the size will be converted
@@ -1202,7 +1213,7 @@ var DOMElementPrototype = nil,
return CGSizeApplyAffineTransform(aSize, _CPViewGetTransform(self, aView));
}
/*
/*!
Converts <code>aRect</code> from <code>aView</code>'s coordinate space to the receiver's space.
@param aRect the rectangle to convert
@param aView the coordinate space from which to convert
@@ -1213,7 +1224,7 @@ var DOMElementPrototype = nil,
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(aView, self));
}
/*
/*!
Converts <code>aRect</code> from the receiver's coordinate space to <code>aView</code>'s coordinate space.
@param aRect the rectangle to convert
@param aView the coordinate space to which the rectangle will be converted
@@ -1224,8 +1235,8 @@ var DOMElementPrototype = nil,
return CGRectApplyAffineTransform(aRect, _CPViewGetTransform(self, aView));
}
/*
Sets whether the receiver posts a <objj>CPViewFrameDidChangeNotification</objj> notification
/*!
Sets whether the receiver posts a CPViewFrameDidChangeNotification notification
to the default notification center when its frame is changed. The default is <code>NO</code>.
Methods that could cause a frame change notification are:
<pre>
@@ -1247,16 +1258,16 @@ setFrameOrigin:
[_CPViewNotificationCenter postNotificationName:CPViewFrameDidChangeNotification object:self];
}
/*
Returns <code>YES</code> if the receiver posts a <objj>CPViewFrameDidChangeNotification</objj> if its frame is changed.
/*!
Returns <code>YES</code> if the receiver posts a CPViewFrameDidChangeNotification if its frame is changed.
*/
- (BOOL)postsFrameChangedNotifications
{
return _postsFrameChangedNotifications;
}
/*
Sets whether the receiver posts a <objj>CPViewBoundsDidChangeNotification</objj> notification
/*!
Sets whether the receiver posts a CPViewBoundsDidChangeNotification notification
to the default notification center when its bounds is changed. The default is <code>NO</code>.
Methods that could cause a bounds change notification are:
<pre>
@@ -1278,9 +1289,9 @@ setBoundsOrigin:
[_CPViewNotificationCenter postNotificationName:CPViewBoundsDidChangeNotification object:self];
}
/*
/*!
Returns <code>YES</code> if the receiver posts a
<objj>CPViewBoundsDidChangeNotification</objj> when its
CPViewBoundsDidChangeNotification when its
bounds is changed.
*/
- (BOOL)postsBoundsChangedNotifications
@@ -1288,7 +1299,7 @@ setBoundsOrigin:
return _postsBoundsChangedNotifications;
}
/*
/*!
Initiates a drag operation from the receiver to another view that accepts dragged data.
@param anImage the image to be dragged
@param aLocation the lower-left corner coordinate of <code>anImage</code>
@@ -1303,7 +1314,7 @@ setBoundsOrigin:
[_window dragImage:anImage at:[self convertPoint:aLocation toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
/*
/*!
Initiates a drag operation from the receiver to another view that accepts dragged data.
@param aView the view to be dragged
@param aLocation the lower-left corner coordinate of <code>aView</code>
@@ -1318,25 +1329,25 @@ setBoundsOrigin:
[_window dragView:aView at:[self convertPoint:aLocation toView:nil] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
/*
/*!
Sets the receiver's list of acceptable data types for a dragging operation.
@param pasteboardTypes an array of <objj>CPPasteboard</objj>s
@param pasteboardTypes an array of CPPasteboards
*/
- (void)registerForDraggedTypes:(CPArray)pasteboardTypes
{
_registeredDraggedTypes = [pasteboardTypes copy];
}
/*
/*!
Returns an array of all types the receiver accepts for dragging operations.
@return an array of <objj>CPPasteBoard</objj>s
@return an array of CPPasteBoards
*/
- (CPArray)registeredDraggedTypes
{
return _registeredDraggedTypes;
}
/*
/*!
Resets the array of acceptable data types for a dragging operation.
*/
- (void)unregisterDraggedTypes
@@ -1344,7 +1355,7 @@ setBoundsOrigin:
_registeredDraggedTypes = nil;
}
/*
/*!
Draws the receiver into <code>aRect</code>. This method should be overridden by subclasses.
@param aRect the area that should be drawn into
*/
@@ -1355,7 +1366,7 @@ setBoundsOrigin:
// Displaying
/*
/*!
Marks the entire view as dirty, and needing a redraw.
*/
- (void)setNeedsDisplay:(BOOL)aFlag
@@ -1368,7 +1379,7 @@ setBoundsOrigin:
#endif
}
/*
/*!
Marks the area denoted by <code>aRect</code> as dirty, and initiates a redraw on it.
@param aRect the area that needs to be redrawn
*/
@@ -1406,7 +1417,7 @@ setBoundsOrigin:
return _dirtyRect && !_CGRectIsEmpty(_dirtyRect);
}
/*
/*!
Displays the receiver and any of its subviews that need to be displayed.
*/
- (void)displayIfNeeded
@@ -1415,7 +1426,7 @@ setBoundsOrigin:
[self displayRect:_dirtyRect];
}
/*
/*!
Draws the entire area of the receiver as defined by its <code>bounds</code>.
*/
- (void)display
@@ -1429,7 +1440,7 @@ setBoundsOrigin:
[self displayRect:aRect];
}
/*
/*!
Draws the receiver into the area defined by <code>aRect</code>.
@param aRect the area to be drawn
*/
@@ -1456,7 +1467,7 @@ setBoundsOrigin:
{
}
/*
/*!
Locks focus on the receiver, so drawing commands apply to it.
*/
- (void)lockFocus
@@ -1491,7 +1502,7 @@ setBoundsOrigin:
CGContextSaveGState([_graphicsContext graphicsPort]);
}
/*
/*!
Takes focus away from the receiver, and restores it to the previous view.
*/
- (void)unlockFocus
@@ -1501,7 +1512,7 @@ setBoundsOrigin:
[CPGraphicsContext setCurrentContext:nil];
}
/*
/*!
Returns whether the receiver is completely opaque. By default, returns <code>NO</code>.
*/
- (BOOL)isOpaque
@@ -1509,7 +1520,7 @@ setBoundsOrigin:
return NO;
}
/*
/*!
Returns the rectangle of the receiver not clipped by its superview.
*/
- (CGRect)visibleRect
@@ -1533,7 +1544,7 @@ setBoundsOrigin:
return superview;
}
/*
/*!
Changes the receiver's frame origin to a 'constrained' <code>aPoint</code>.
@param aPoint the proposed frame origin
*/
@@ -1547,8 +1558,8 @@ setBoundsOrigin:
[clipView scrollToPoint:[self convertPoint:aPoint toView:clipView]];
}
/*
Scrolls the nearest ancestor <objj>CPClipView</objj> a minimum amount so <code>aRect</code> can become visible.
/*!
Scrolls the nearest ancestor CPClipView a minimum amount so <code>aRect</code> can become visible.
@param aRect the area to become visible
@return <codeYES</code> if any scrolling occurred, <code>NO</code> otherwise.
*/
@@ -1596,7 +1607,7 @@ setBoundsOrigin:
return NO;
}
/*
/*!
Subclasses can override this to modify the visible rectangle after a
scrolling operation. The default implementation simply returns the provided rectangle.
@param proposedVisibleRect the rectangle to alter
@@ -1607,7 +1618,7 @@ setBoundsOrigin:
return proposedVisibleRect;
}
/*
/*!
Should be overridden by subclasses.
*/
- (void)scrollRect:(CGRect)aRect by:(float)anAmount
@@ -1615,9 +1626,9 @@ setBoundsOrigin:
}
/*
Returns the <objj>CPScrollView</objj> containing the receiver.
@return the <objj>CPScrollView</objj> containing the receiver.
/*!
Returns the CPScrollView containing the receiver.
@return the CPScrollView containing the receiver.
*/
- (CPScrollView)enclosingScrollView
{
@@ -1630,7 +1641,7 @@ setBoundsOrigin:
return superview;
}
/*
/*!
Scrolls the clip view to a specified point
@param the clip view to scoll
@param the point to scroll to
@@ -1640,8 +1651,8 @@ setBoundsOrigin:
[aClipView scrollToPoint:aPoint];
}
/*
Notifies the receiver (superview of a <objj>CPClipView</objj>)
/*!
Notifies the receiver (superview of a CPClipView)
that the clip view bounds or the document view bounds have changed.
@param aClipView the clip view of the superview being notified
*/
@@ -1653,7 +1664,7 @@ setBoundsOrigin:
@implementation CPView (CoreAnimationAdditions)
/*
/*!
Sets the core animation layer to be used by this receiver.
*/
- (void)setLayer:(CALayer)aLayer
@@ -1685,7 +1696,7 @@ setBoundsOrigin:
}
}
/*
/*!
Returns the core animation layer used by the receiver.
*/
- (CALayer)layer
@@ -1693,7 +1704,7 @@ setBoundsOrigin:
return _layer;
}
/*
/*!
Sets whether the receiver wants a core animation layer.
@param <code>YES</code> means the receiver wants a layer.
*/
@@ -1702,9 +1713,9 @@ setBoundsOrigin:
_wantsLayer = aFlag;
}
/*
Returns <code>YES</code> if the receiver uses a <objj>CALayer</objj>
@returns <code>YES</code> if the receiver uses a <objj>CALayer</objj>
/*!
Returns <code>YES</code> if the receiver uses a CALayer
@returns <code>YES</code> if the receiver uses a CALayer
*/
- (BOOL)wantsLayer
{
@@ -1728,7 +1739,7 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
@implementation CPView (CPCoding)
/*
/*!
Initializes the view from an archive.
@param aCoder the coder from which to initialize
@return the initialized view
@@ -1787,12 +1798,14 @@ var CPViewAutoresizingMaskKey = @"CPViewAutoresizingMask",
_displayHash = [self hash];
[self setBackgroundColor:[aCoder decodeObjectForKey:CPViewBackgroundColorKey]];
[self setNeedsDisplay:YES];
}
return self;
}
/*
/*!
Archives the view to a coder.
@param aCoder the object into which the view's data will be archived.
*/
+124 -56
View File
@@ -20,7 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPView.j"
@import "CPView.j"
// FIXME: implement these where possible:
/*
@@ -70,45 +71,91 @@ CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNoti
_mainFrameURL = nil;
_backwardStack = [];
_forwardStack = [];
_ignoreLoadEvent = NO;
_iframe = document.createElement("iframe");
_iframe.name = "iframe_" + Math.floor(Math.random()*10000);
_iframe.style.width = "100%";
_iframe.style.height = "100%";
_iframe.style.borderWidth = "0px";
var loadCallback = function() {
// HACK: this block handles the case where we don't know about loads initiated by the user clicking a link
if (!_ignoreLoadEvent)
{
// post the start load notification
[self _startedLoading];
if (_mainFrameURL)
[_backwardStack addObject:_mainFrameURL];
// FIXME: this doesn't actually get the right URL for different domains. Probably not be possible due to browser security restrictions.
_mainFrameURL = _iframe.src;
[_forwardStack removeAllObjects];
}
_ignoreLoadEvent = NO;
[self _finishedLoading]
}
if (_iframe.addEventListener)
_iframe.addEventListener("load", loadCallback, false);
else if (_iframe.attachEvent)
_iframe.attachEvent("onload", loadCallback);
_DOMElement.appendChild(_iframe);
[self _initDOMWithFrame:aFrame];
}
return self;
}
- (id)_initDOMWithFrame:(CPRect)aFrame
{
_ignoreLoadEvent = NO;
_iframe = document.createElement("iframe");
_iframe.name = "iframe_" + Math.floor(Math.random()*10000);
_iframe.style.width = "100%";
_iframe.style.height = "100%";
_iframe.style.borderWidth = "0px";
[self setDrawsBackground:YES];
var loadCallback = function() {
// HACK: this block handles the case where we don't know about loads initiated by the user clicking a link
if (!_ignoreLoadEvent)
{
// post the start load notification
[self _startedLoading];
if (_mainFrameURL)
[_backwardStack addObject:_mainFrameURL];
// FIXME: this doesn't actually get the right URL for different domains. Probably not be possible due to browser security restrictions.
_mainFrameURL = _iframe.src;
[_forwardStack removeAllObjects];
}
_ignoreLoadEvent = NO;
[self _finishedLoading]
}
if (_iframe.addEventListener)
_iframe.addEventListener("load", loadCallback, false);
else if (_iframe.attachEvent)
_iframe.attachEvent("onload", loadCallback);
_DOMElement.appendChild(_iframe);
}
// IBActions
- (IBAction)takeStringURLFrom:(id)sender
{
[self setMainFrameURL:[sender stringValue]];
}
- (IBAction)goBack:(id)sender
{
[self goBack];
}
- (IBAction)goForward:(id)sender
{
[self goForward];
}
- (IBAction)stopLoading:(id)sender
{
// FIXME: what to do?
}
- (IBAction)reload:(id)sender
{
[self _loadMainFrameURL];
}
- (IBAction)print:(id)sender
{
try
{
[self window].print();
}
catch (e)
{
alert('Please click the webpage and select "Print" from the "File" menu');
}
}
- (BOOL)drawsBackground
{
return _iframe.style.backgroundColor != "";
@@ -119,11 +166,6 @@ CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNoti
_iframe.style.backgroundColor = drawsBackround ? "white" : "";
}
- (CPString)mainFrameURL
{
return _mainFrameURL;
}
- (void)_loadMainFrameURL
{
[self _startedLoading];
@@ -148,19 +190,19 @@ CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNoti
[_frameLoadDelegate webView:self didFinishLoadForFrame:nil]; // FIXME: give this a frame somehow?
}
- (CPString)mainFrameURL
{
return _mainFrameURL;
}
- (void)setMainFrameURL:(CPString)URLString
{
if (_mainFrameURL)
[_backwardStack addObject:_mainFrameURL];
_mainFrameURL = URLString;
[_forwardStack removeAllObjects];
[self _loadMainFrameURL];
}
- (IBAction)takeStringURLFrom:(id)sender
{
[self setMainFrameURL:[sender stringValue]];
[self _loadMainFrameURL];
}
- (BOOL)goBack
@@ -195,16 +237,6 @@ CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNoti
return NO;
}
- (IBAction)goBack:(id)sender
{
[self goBack];
}
- (IBAction)goForward:(id)sender
{
[self goForward];
}
- (BOOL)canGoBack
{
return (_backwardStack.length > 0);
@@ -376,3 +408,39 @@ CPWebViewProgressFinishedNotification = "CPWebViewProgressFinishedNoti
}
@end
@implementation CPWebView (CPCoding)
/*!
Initializes the web view from the data in a coder.
@param aCoder the coder from which to read the data
@return the initialized web view
*/
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
if (self)
{
// FIXME: encode/decode these?
_mainFrameURL = nil;
_backwardStack = [];
_forwardStack = [];
[self _initDOMWithFrame:[self frame]];
}
return self;
}
/*!
Writes out the web view's instance information to a coder.
@param aCoder the coder to which to write the data
*/
- (void)encodeWithCoder:(CPCoder)aCoder
{
[super encodeWithCoder:aCoder];
}
@end
+100 -90
View File
@@ -20,12 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPNotificationCenter.j>
import <Foundation/CPUndoManager.j>
@import <Foundation/CPNotificationCenter.j>
@import <Foundation/CPUndoManager.j>
import "CGGeometry.j"
import "CPAnimation.j"
import "CPResponder.j"
@import "CGGeometry.j"
@import "CPAnimation.j"
@import "CPResponder.j"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
@@ -184,8 +184,9 @@ var SHADOW_MARGIN_LEFT = 20.0,
var CPWindowSaveImage = nil,
CPWindowSavingImage = nil;
/*
An <objj>CPWindow</objj> instance represents a window, panel or menu on the screen.</p>
/*! @class CPWindow
An CPWindow instance represents a window, panel or menu on the screen.</p>
<p>Each window has a style, which determines how the window is decorated; whether it has a border, a title bar, a resize bar, minimise and close buttons.</p>
@@ -193,7 +194,9 @@ var CPWindowSaveImage = nil,
<p>A window always contains a content view which is the highest level view available for public (application) use. This view fills the area of the window inside any decoration/border. This is the only part of the window that application programmers are allowed to draw in directly.</p>
<p>You can convert between view coordinates and window base coordinates using the <objj>[CPView -convertPoint:fromView:]</objj>, <objj>[CPView -convertPoint:toView:]</objj>, <objj>[CPView -convertRect:fromView:]</objj>, and <objj>[CPView -convertRect:toView:]</objj> methods with a <objj>nil</objj> view argument.
<p>You can convert between view coordinates and window base coordinates using the [CPView -convertPoint:fromView:], [CPView -convertPoint:toView:], [CPView -convertRect:fromView:], and [CPView -convertRect:toView:] methods with a nil view argument.
@par Delegate Methods
@delegate -(void)windowDidResize:(CPNotification)notification;
Sent from the notification center when the window has been resized.
@@ -294,7 +297,7 @@ var CPWindowSaveImage = nil,
CPWindowSavingImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"] size:CGSizeMake(16.0, 16.0)]
}
/*
/*!
Initializes the window. The method also takes a style bit mask made up
of any of the following values:
<pre>
@@ -314,7 +317,7 @@ CPTexturedBackgroundWindowMask
return [self initWithContentRect:aContentRect styleMask:aStyleMask bridge:[CPDOMWindowBridge sharedDOMWindowBridge]];
}
/*
/*!
Initializes the window. The method also takes a style bit mask made up
of any of the following values:
<pre>
@@ -388,7 +391,7 @@ CPTexturedBackgroundWindowMask
return self;
}
/*
/*!
Returns the window's style mask.
*/
- (unsigned)styleMask
@@ -396,7 +399,7 @@ CPTexturedBackgroundWindowMask
return _styleMask;
}
/*
/*!
Returns the frame rectangle used by a window.
@param aContentRect the content rectangle of the window
@param aStyleMask the style mask of the window
@@ -409,7 +412,7 @@ CPTexturedBackgroundWindowMask
return frame;
}
/*
/*!
Returns the receiver's content rectangle. A content rectangle does not include toolbars.
@param aFrame the window's frame rectangle
*/
@@ -442,7 +445,7 @@ CPTexturedBackgroundWindowMask
return contentRect;
}
/*
/*!
Retrieves the frame rectangle for this window.
@param aContentRect the window's content rectangle
@return the window's frame rectangle
@@ -457,7 +460,7 @@ CPTexturedBackgroundWindowMask
return frame;
}
/*
/*!
Returns the window's frame rectangle
*/
- (CGRect)frame
@@ -465,7 +468,7 @@ CPTexturedBackgroundWindowMask
return _frame;
}
/*
/*!
Sets the window's frame rectangle. Also tells the window whether it should animate
the resize operation, and redraw itself if necessary.
@param aFrame the new size and location for the window
@@ -487,7 +490,7 @@ CPTexturedBackgroundWindowMask
}
}
/*
/*!
Sets the window's frame rectangle
*/
- (void)setFrame:(CGRect)aFrame
@@ -495,7 +498,7 @@ CPTexturedBackgroundWindowMask
[self setFrame:aFrame display:YES animate:NO];
}
/*
/*!
Sets the window's location.
@param anOrigin the new location for the window
*/
@@ -514,7 +517,7 @@ CPTexturedBackgroundWindowMask
#endif
}
/*
/*!
Sets the window's size.
@param aSize the new size for the window
*/
@@ -581,7 +584,7 @@ CPTexturedBackgroundWindowMask
[CPApp setTarget:self selector:@selector(trackResizeWithEvent:) forNextEventMatchingMask:CPLeftMouseDraggedMask | CPLeftMouseUpMask untilDate:nil inMode:nil dequeue:YES];
}
/*
/*!
Makes the receiver the front most window in the screen ordering.
@param aSender the object that requested this
*/
@@ -600,7 +603,7 @@ CPTexturedBackgroundWindowMask
//[_bridge order:CPWindowBelow
}
/*
/*!
Hides the window.
@param the object that requested this
*/
@@ -619,7 +622,7 @@ CPTexturedBackgroundWindowMask
}
}
/*
/*!
Relocates the window in the screen list.
@param aPlace the positioning relative to <code>otherWindowNumber</code>
@param otherWindowNumber the window relative to which the receiver should be placed
@@ -629,7 +632,7 @@ CPTexturedBackgroundWindowMask
[_bridge order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]];
}
/*
/*!
Sets the window's level
@param the window's new level
*/
@@ -638,7 +641,7 @@ CPTexturedBackgroundWindowMask
_level = aLevel;
}
/*
/*!
Returns the window's current level
*/
- (int)level
@@ -646,7 +649,7 @@ CPTexturedBackgroundWindowMask
return _level;
}
/*
/*!
Returns <code>YES</code> if the window is visible. It does not mean that the window is not obscured by other windows.
*/
- (BOOL)isVisible
@@ -654,7 +657,7 @@ CPTexturedBackgroundWindowMask
return _isVisible;
}
/*
/*!
Returns <code>YES</code> if the window's resize indicator is showing. <code>NO</code> otherwise.
*/
- (BOOL)showsResizeIndicator
@@ -662,7 +665,7 @@ CPTexturedBackgroundWindowMask
return [_windowView showsResizeIndicator];
}
/*
/*!
Sets the window's resize indicator.
@param shouldShowResizeIndicator <code>YES</code> sets the window to show its resize indicator.
*/
@@ -671,7 +674,7 @@ CPTexturedBackgroundWindowMask
[_windowView setShowsResizeIndicator:shouldShowResizeIndicator];
}
/*
/*!
Returns the offset of the window's resize indicator.
*/
- (CGSize)resizeIndicatorOffset
@@ -679,7 +682,7 @@ CPTexturedBackgroundWindowMask
return [_windowView resizeIndicatorOffset];
}
/*
/*!
Sets the offset of the window's resize indicator.
@param aSize the offset for the resize indicator
*/
@@ -688,7 +691,7 @@ CPTexturedBackgroundWindowMask
[_windowView setResizeIndicatorOffset:anOffset];
}
/*
/*!
Sets the window's content view. The new view will be resized to fit
inside the content rectangle of the window.
@param aView the new content view for the receiver
@@ -705,7 +708,7 @@ CPTexturedBackgroundWindowMask
[_windowView addSubview:_contentView positioned:CPWindowBelow relativeTo:nil];
}
/*
/*!
Returns the window's current content view.
*/
- (CPView)contentView
@@ -713,7 +716,7 @@ CPTexturedBackgroundWindowMask
return _contentView;
}
/*
/*!
Sets the window's background color.
@param aColor the new color for the background
*/
@@ -722,7 +725,7 @@ CPTexturedBackgroundWindowMask
[_windowView setBackgroundColor:aColor];
}
/*
/*!
Returns the window's background color.
*/
- (CPColor)backgroundColor
@@ -730,7 +733,7 @@ CPTexturedBackgroundWindowMask
return [_windowView backgroundColor];
}
/*
/*!
Sets the window's minimum size. If the provided
size is the same as the current minimum size, the method simply returns.
@aSize the new minimum size for the window
@@ -761,7 +764,7 @@ CPTexturedBackgroundWindowMask
[self setFrameSize:size];
}
/*
/*!
Returns the windows minimum size.
*/
- (CGSize)minSize
@@ -769,7 +772,7 @@ CPTexturedBackgroundWindowMask
return _minSize;
}
/*
/*!
Sets the window's maximum size. If the provided
size is the same as the current maximum size,
the method simply returns.
@@ -801,7 +804,7 @@ CPTexturedBackgroundWindowMask
[self setFrameSize:size];
}
/*
/*!
Returns the window's maximum size.
*/
- (CGSize)maxSize
@@ -809,7 +812,7 @@ CPTexturedBackgroundWindowMask
return _maxSize;
}
/*
/*!
Returns <code>YES</code> if the window has a drop shadow. <code>NO</code> otherwise.
*/
- (BOOL)hasShadow
@@ -817,7 +820,7 @@ CPTexturedBackgroundWindowMask
return _hasShadow;
}
/*
/*!
Sets whether the window should have a drop shadow.
@param shouldHaveShadow <code>YES</code> to have a drop shadow.
*/
@@ -871,9 +874,9 @@ CPTexturedBackgroundWindowMask
}
}
/*
/*!
Sets the delegate for the window. Passing <code>nil</code> will just remove the window's current delegate.
@param aDelegate an object to respond to the various delegate methods of <objj>CPWindow</objj>
@param aDelegate an object to respond to the various delegate methods of CPWindow
*/
- (void)setDelegate:(id)aDelegate
{
@@ -898,7 +901,7 @@ CPTexturedBackgroundWindowMask
object:self];
}
/*
/*!
Returns window's delegate
*/
- (id)delegate
@@ -906,7 +909,7 @@ CPTexturedBackgroundWindowMask
return _delegate;
}
/*
/*!
Sets the window's controller
@param aWindowController a window controller
*/
@@ -915,7 +918,7 @@ CPTexturedBackgroundWindowMask
_windowController = aWindowController;
}
/*
/*!
Returns the window's controller.
*/
- (CPWindowController)windowController
@@ -936,7 +939,7 @@ CPTexturedBackgroundWindowMask
return YES;
}
/*
/*!
Attempts to make the <code>aResponder</code> the first responder. Before trying
to make it the first responder, the receiver will ask the current first responder
to resign its first responder status. If it resigns, it will ask
@@ -963,7 +966,7 @@ CPTexturedBackgroundWindowMask
return YES;
}
/*
/*!
Returns the window's current first responder.
*/
- (CPResponder)firstResponder
@@ -983,7 +986,7 @@ CPTexturedBackgroundWindowMask
// Managing Titles
/*
/*!
Returns the window's title bar string
*/
- (CPString)title
@@ -991,7 +994,7 @@ CPTexturedBackgroundWindowMask
return _title;
}
/*
/*!
Sets the window's title bar string
*/
- (void)setTitle:(CPString)aTitle
@@ -1003,7 +1006,7 @@ CPTexturedBackgroundWindowMask
[self _synchronizeMenuBarTitleWithWindowTitle];
}
/*
/*!
Sets the title bar to represent a file path
*/
- (void)setTitleWithRepresentedFilename:(CPString)aFilePath
@@ -1012,7 +1015,7 @@ CPTexturedBackgroundWindowMask
[self setTitle:[aFilePath lastPathComponent]];
}
/*
/*!
Sets the path to the file the receiver represents
*/
- (void)setRepresentedFilename:(CPString)aFilePath
@@ -1021,7 +1024,7 @@ CPTexturedBackgroundWindowMask
[self setRepresentedURL:aFilePath];
}
/*
/*!
Returns the path to the file the receiver represents
*/
- (CPString)representedFilename
@@ -1029,7 +1032,7 @@ CPTexturedBackgroundWindowMask
return _representedURL;
}
/*
/*!
Sets the URL that the receiver represents
*/
- (void)setRepresentedURL:(CPURL)aURL
@@ -1037,7 +1040,7 @@ CPTexturedBackgroundWindowMask
_representedURL = aURL;
}
/*
/*!
Returns the URL that the receiver represents
*/
- (CPURL)representedURL
@@ -1047,7 +1050,7 @@ CPTexturedBackgroundWindowMask
// Moving
/*
/*!
Sets whether the window can be moved by dragging its background. The default is based on the window style.
@param shouldBeMovableByWindowBackground <code>YES</code> makes the window move from a background drag.
*/
@@ -1056,7 +1059,7 @@ CPTexturedBackgroundWindowMask
_isMovableByWindowBackground = shouldBeMovableByWindowBackground;
}
/*
/*!
Returns <code>YES</code> if the window can be moved by dragging its background.
*/
- (BOOL)isMovableByWindowBackground
@@ -1064,7 +1067,7 @@ CPTexturedBackgroundWindowMask
return _isMovableByWindowBackground;
}
/*
/*!
Sets the window location to be the center of the screen
*/
- (void)center
@@ -1075,8 +1078,8 @@ CPTexturedBackgroundWindowMask
[self setFrameOrigin:CGPointMake((bridgeSize.width - size.width) / 2.0, (bridgeSize.height - size.height) / 2.0)];
}
/*
Dispatches events that are sent to it from <objj>CPApplication</objj>.
/*!
Dispatches events that are sent to it from CPApplication.
@param anEvent the event to be dispatched
*/
- (void)sendEvent:(CPEvent)anEvent
@@ -1149,7 +1152,7 @@ CPTexturedBackgroundWindowMask
}
}
/*
/*!
Returns the window's number in the desktop's screen list
*/
- (int)windowNumber
@@ -1157,7 +1160,7 @@ CPTexturedBackgroundWindowMask
return _windowNumber;
}
/*
/*!
Called when the receiver should become the key window. It also sends
the <code>becomeKeyWindow</code> message to the first responder.
*/
@@ -1167,7 +1170,7 @@ CPTexturedBackgroundWindowMask
[_firstResponder becomeKeyWindow];
}
/*
/*!
Determines if the window can become the key window.
@return <code>YES</code> means the window can become the key window.
*/
@@ -1176,7 +1179,7 @@ CPTexturedBackgroundWindowMask
return YES;
}
/*
/*!
Returns <code>YES</code> if the window is the key window.
*/
- (BOOL)isKeyWindow
@@ -1184,7 +1187,7 @@ CPTexturedBackgroundWindowMask
return [CPApp keyWindow] == self;
}
/*
/*!
Makes the window the key window and brings it to the front of the screen list.
@param aSender the object requesting this
*/
@@ -1196,7 +1199,7 @@ CPTexturedBackgroundWindowMask
[self makeMainWindow];
}
/*
/*!
Makes this window the key window.
*/
- (void)makeKeyWindow
@@ -1211,7 +1214,7 @@ CPTexturedBackgroundWindowMask
[self becomeKeyWindow];
}
/*
/*!
Causes the window to resign it's key window status.
*/
- (void)resignKeyWindow
@@ -1223,7 +1226,7 @@ CPTexturedBackgroundWindowMask
[_delegate windowDidResignKey:self];
}
/*
/*!
Initiates a drag operation from the receiver to another view that accepts dragged data.
@param anImage the image to be dragged
@param aLocation the lower-left corner coordinate of <code>anImage</code>
@@ -1238,7 +1241,7 @@ CPTexturedBackgroundWindowMask
[[CPDragServer sharedDragServer] dragImage:anImage fromWindow:self at:[self convertBaseToBridge:imageLocation] offset:mouseOffset event:anEvent pasteboard:aPasteboard source:aSourceObject slideBack:slideBack];
}
/*
/*!
Initiates a drag operation from the receiver to another view that accepts dragged data.
@param aView the view to be dragged
@param aLocation the lower-left corner coordinate of <code>aView</code>
@@ -1255,7 +1258,7 @@ CPTexturedBackgroundWindowMask
// Accessing Editing Status
/*
/*!
Sets whether the document has been edited.
@param isDocumentEdited <code>YES</code> if the document has been edited.
*/
@@ -1269,7 +1272,7 @@ CPTexturedBackgroundWindowMask
[CPMenu _setMenuBarIconImageAlphaValue:_isDocumentEdited ? 0.5 : 1.0];
}
/*
/*!
Returns <code>YES</code> if the document has been edited.
*/
- (BOOL)isDocumentEdited
@@ -1326,20 +1329,27 @@ CPTexturedBackgroundWindowMask
// Closing Windows
/*
/*!
Simulates the user closing the window, then closes the window.
@param aSender the object making this request
*/
- (void)performClose:(id)aSender
{
if ([_delegate respondsToSelector:@selector(windowShouldClose:)] && ![_delegate windowShouldClose:self] ||
[self respondsToSelector:@selector(windowShouldClose:)] && ![self windowShouldClose:self])
// Only send ONE windowShouldClose: message.
if ([_delegate respondsToSelector:@selector(windowShouldClose:)])
{
if (![_delegate windowShouldClose:self])
return;
}
// Only check self is delegate does NOT implement this. This also ensures this when delegate == self (returns true).
else if ([self respondsToSelector:@selector(windowShouldClose:)] && ![self windowShouldClose:self])
return;
[self close];
}
/*
/*!
Closes the window. Posts a <code>CPWindowWillCloseNotification</code> to the
notification center before closing the window.
*/
@@ -1351,7 +1361,7 @@ CPTexturedBackgroundWindowMask
}
// Managing Main Status
/*
/*!
Returns <code>YES</code> if this the main window.
*/
- (BOOL)isMainWindow
@@ -1359,7 +1369,7 @@ CPTexturedBackgroundWindowMask
return [CPApp mainWindow] == self;
}
/*
/*!
Returns <code>YES</code> if the window can become the main window.
*/
- (BOOL)canBecomeMainWindow
@@ -1371,7 +1381,7 @@ CPTexturedBackgroundWindowMask
return NO;
}
/*
/*!
Makes the receiver the main window.
*/
- (void)makeMainWindow
@@ -1386,7 +1396,7 @@ CPTexturedBackgroundWindowMask
[self becomeMainWindow];
}
/*
/*!
Called to tell the receiver that it has become the main window.
*/
- (void)becomeMainWindow
@@ -1399,7 +1409,7 @@ CPTexturedBackgroundWindowMask
object:self];
}
/*
/*!
Called when the window resigns main window status.
*/
- (void)resignMainWindow
@@ -1410,7 +1420,7 @@ CPTexturedBackgroundWindowMask
}
// Managing Toolbars
/*
/*!
Return's the window's toolbar
*/
- (CPToolbar)toolbar
@@ -1418,7 +1428,7 @@ CPTexturedBackgroundWindowMask
return _toolbar;
}
/*
/*!
Sets the window's toolbar.
@param aToolbar the window's new toolbar
*/
@@ -1521,7 +1531,7 @@ CPTexturedBackgroundWindowMask
[_bridge order:CPWindowAbove window:aSheet relativeTo:self];
}
/*
/*!
Returns the window's attached sheet.
*/
- (CPWindow)attachedSheet
@@ -1529,7 +1539,7 @@ CPTexturedBackgroundWindowMask
return _attachedSheet;
}
/*
/*!
Returns <code>YES</code> if the window has ever run as a sheet.
*/
- (BOOL)isSheet
@@ -1547,7 +1557,7 @@ CPTexturedBackgroundWindowMask
return NO;
}
/*
/*!
Returns <code>YES</code> if the receiver is able to receive input events
even when a modal session is active.
*/
@@ -1662,7 +1672,7 @@ CPTexturedBackgroundWindowMask
}
// Undo and Redo Support
/*
/*!
Returns the window's undo manager.
*/
- (CPUndoManager)undoManager
@@ -1676,7 +1686,7 @@ CPTexturedBackgroundWindowMask
return _undoManager;
}
/*
/*!
Sends the undo manager an <code>undo</code> message.
@param aSender the object requesting this
*/
@@ -1685,7 +1695,7 @@ CPTexturedBackgroundWindowMask
[[self undoManager] undo];
}
/*
/*!
Sends the undo manager a <code>redo:</code> message.
@param aSender the object requesting this
*/
@@ -1747,7 +1757,7 @@ var interpolate = function(fromValue, toValue, progress)
@end
import "CPDragServer.j"
import "CPDOMWindowBridge.j"
import "_CPWindowView.j"
import "CPView.j"
@import "CPDragServer.j"
@import "CPDOMWindowBridge.j"
@import "_CPWindowView.j"
@import "CPView.j"
+27 -25
View File
@@ -20,20 +20,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
import "CPResponder.j"
import "CPWindow.j"
import "CPDocument.j"
@import "CPResponder.j"
@import "CPWindow.j"
@import "CPDocument.j"
#include "Platform/Platform.h"
/*
An instance of a <objj>CPWindowController</objj> manages a <objj>CPWindow</objj>. It has methods
/*! @class CPWindowController
An instance of a CPWindowController manages a CPWindow. It has methods
that get called when the window is loading, and after the window has loaded. In the
Model-View-Controller method of program design, the <objj>CPWindowController</objj> would be
considered the 'Controller' and the <objj>CPWindow</objj> the 'Model.'
Model-View-Controller method of program design, the CPWindowController would be
considered the 'Controller' and the CPWindow the 'Model.'
*/
@implementation CPWindowController : CPResponder
{
@@ -43,7 +45,7 @@ import "CPDocument.j"
CPString _windowCibName;
}
/*
/*!
Initializes the controller with a window.
@param aWindow the window to control
@return the initialzed window controller
@@ -62,7 +64,7 @@ import "CPDocument.j"
return self;
}
/*
/*!
Initializes the controller with a Capppuccino Interface Builder name.
@param aWindowCibName the cib name of the window to control
@return the initialized window controller
@@ -72,7 +74,7 @@ import "CPDocument.j"
return [self initWithWindowCibName:aWindowCibName owner:self];
}
/*
/*!
Initializes the controller with a cafe name.
@param aWindowCibName the cib name of the window to control
@param anOwner the owner of the cib file
@@ -93,7 +95,7 @@ import "CPDocument.j"
return self;
}
/*
/*!
Loads the window
*/
- (void)loadWindow
@@ -105,7 +107,7 @@ import "CPDocument.j"
[self windowDidLoad];
}
/*
/*!
Shows the window.
@param aSender the object requesting the show
*/
@@ -119,16 +121,16 @@ import "CPDocument.j"
[theWindow makeKeyAndOrderFront:aSender];
}
/*
/*!
Returns <code>YES</code> if the window has been loaded. Specifically,
if <objj>loadWindow</objj> has been called.
if loadWindow has been called.
*/
- (BOOL)isWindowLoaded
{
return _window;
}
/*
/*!
Returns the window this object controls.
*/
- (CPWindow)window
@@ -139,7 +141,7 @@ import "CPDocument.j"
return _window;
}
/*
/*!
Sets the window to be controlled.
@param aWindow the new window to control
*/
@@ -151,7 +153,7 @@ import "CPDocument.j"
[_window setNextResponder:self];
}
/*
/*!
The method notifies the controller that it's window has loaded.
*/
- (void)windowDidLoad
@@ -161,7 +163,7 @@ import "CPDocument.j"
[self synchronizeWindowTitleWithDocumentName];
}
/*
/*!
The method notifies the controller that it's window is about to load.
*/
- (void)windowWillLoad
@@ -169,7 +171,7 @@ import "CPDocument.j"
[_document windowControllerWillLoadNib:self];
}
/*
/*!
Sets the document that is inside the controlled window.
@param aDocument the document in the controlled window
*/
@@ -238,7 +240,7 @@ import "CPDocument.j"
[[self window] setDocumentSaving:NO];
}
/*
/*!
Returns the document in the controlled window.
*/
- (CPDocument)document
@@ -246,7 +248,7 @@ import "CPDocument.j"
return _document;
}
/*
/*!
Sets whether the document has unsaved changes. The window can use this as a hint to
@param isEdited <code>YES</code> means the document has unsaved changes.
*/
@@ -257,7 +259,7 @@ import "CPDocument.j"
// Setting and Getting Window Attributes
/*
/*!
Sets the title of the window as the name of the document.
*/
- (void)synchronizeWindowTitleWithDocumentName
@@ -269,7 +271,7 @@ import "CPDocument.j"
[_window setTitle:[self windowTitleForDocumentDisplayName:[_document displayName]]];
}
/*
/*!
Returns the window title based on the document's name.
@param aDisplayName the document's filename
*/
+17 -8
View File
@@ -20,15 +20,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPURLConnection.j>
import <Foundation/CPURLRequest.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPURLConnection.j>
@import <Foundation/CPURLRequest.j>
@import "_CPCibCustomObject.j"
@import "_CPCibCustomView.j"
@import "_CPCibKeyedUnarchiver.j"
@import "_CPCibObjectData.j"
@import "_CPCibWindowTemplate.j"
import "_CPCibCustomObject.j"
import "_CPCibCustomView.j"
import "_CPCibKeyedUnarchiver.j"
import "_CPCibObjectData.j"
import "_CPCibWindowTemplate.j"
CPCibOwner = @"CPCibOwner",
CPCibTopLevelObjects = @"CPCibTopLevelObjects";
@@ -62,6 +63,14 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
var owner = [anExternalNameTable objectForKey:CPCibOwner],
topLevelObjects = [anExternalNameTable objectForKey:CPCibTopLevelObjects];
var menu;
if ((menu = [objectData mainMenu]) != nil)
{
[CPApp setMainMenu:menu];
[CPMenu setMenuBarVisible:YES];
}
/*
// [objectData establishConnectionsWithOwner:owner topLevelObjects:topLevelObjects];
// [objectData cibInstantiateWithOwner:owner topLevelObjects:topLevelObjects];
+2 -2
View File
@@ -1,6 +1,6 @@
import <Foundation/CPObject.j>
import <Foundation/CPKeyValueCoding.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPKeyValueCoding.j>
var _CPCibConnectorSourceKey = @"_CPCibConnectorSourceKey",
+1 -1
View File
@@ -1,5 +1,5 @@
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName";
+4 -2
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPView.j"
@import "CPView.j"
/* @ignore */
@@ -73,7 +73,9 @@ var _CPCibCustomViewClassNameKey = @"_CPCibCustomViewClassNameKey";
[view setBounds:[self bounds]];
// Since the object replacement logic hasn't had a chance to kick in yet, we need to do it manually:
var subviews = [self subviews],
// we need to copy subviews since each time we add a subview to a different view its removed from the original subviews array
var subviews = [[self subviews] copy],
index = 0,
count = subviews.length;
+1 -1
View File
@@ -1,5 +1,5 @@
import <Foundation/CPKeyedUnarchiver.j>
@import <Foundation/CPKeyedUnarchiver.j>
@implementation _CPCibKeyedUnarchiver : CPKeyedUnarchiver
+3 -3
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPBundle.j>
import <Foundation/CPDictionary.j>
import <Foundation/CPString.j>
@import <Foundation/CPBundle.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPString.j>
var CPCibOwner = @"CPCibOwner";
+14 -5
View File
@@ -20,12 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
import "CPCib.j"
import "_CPCibConnector.j"
@import "CPCib.j"
@import "_CPCibConnector.j"
@implementation _CPCibObjectData : CPObject
@@ -80,6 +80,15 @@ import "_CPCibConnector.j"
return topLevelObjects;
}
- (CPMenu)mainMenu
{
var index = [_namesValues indexOfObjectIdenticalTo:"MainMenu"];
if (index === CPNotFound)
return nil;
return _namesKeys[index];
}
@end
var _CPCibObjectDataNamesKeysKey = @"_CPCibObjectDataNamesKeysKey",
+25 -15
View File
@@ -1,11 +1,12 @@
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
_CPCibWindowTemplateMaxSizeKey = @"_CPCibWindowTemplateMaxSizeKey",
_CPCibWindowTemplateViewClassKey = @"_CPCibWindowTemplateWindowClassKey",
_CPCibWindowTemplateViewClassKey = @"_CPCibWindowTemplateViewClassKey",
_CPCibWindowTemplateWindowClassKey = @"_CPCibWindowTemplateWindowClassKey",
_CPCibWindowTemplateWindowRectKey = @"_CPCibWindowTemplateWindowRectKey",
_CPCibWindowTemplateWindowStyleMaskKey = @"_CPCibWindowTempatStyleMaskKey",
@@ -18,7 +19,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
CGSize _maxSize;
//CGSize _screenRect;
CPString _viewClass;
id _viewClass;
//unsigned _wtFlags;
CPString _windowClass;
CGRect _windowRect;
@@ -34,12 +35,14 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
if (self)
{
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
if ([aCoder containsValueForKey:_CPCibWindowTemplateMinSizeKey])
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
if ([aCoder containsValueForKey:_CPCibWindowTemplateMaxSizeKey])
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
_viewClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
_windowClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
_windowClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateWindowClassKey];
_windowRect = [aCoder decodeRectForKey:_CPCibWindowTemplateWindowRectKey];
_windowStyleMask = [aCoder decodeIntForKey:_CPCibWindowTemplateWindowStyleMaskKey];
@@ -52,12 +55,14 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
if (_minSize)
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
if (_maxSize)
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
[aCoder encodeObject:_viewClass forKey:_CPCibWindowTemplateViewClassKey];
[aCoder encodeObject:_windowClass forKey:_CPCibWindowTemplateViewClassKey];
[aCoder encodeObject:_windowClass forKey:_CPCibWindowTemplateWindowClassKey];
[aCoder encodeRect:_windowRect forKey:_CPCibWindowTemplateWindowRectKey];
[aCoder encodeInt:_windowStyleMask forKey:_CPCibWindowTemplateWindowStyleMaskKey];
@@ -73,12 +78,12 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
[NSException raise:NSInvalidArgumentException format:@"Unable to locate NSWindow class %@, using NSWindow",_windowClass];
class=[NSWindow class];*/
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:CPHUDBackgroundWindowMask | CPClosableWindowMask];//styleMask:_windowStyleMask];
// alert(CPStringFromRect(_windowRect));
// alert(CPStringFromSize(_minSize));
// alert(CPStringFromSize(_maxSize));
//[theWindow setMinSize:_minSize];
//[theWindow setMaxSize:_maxSize];
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
if (_minSize)
[theWindow setMinSize:_minSize];
if (_maxSize)
[theWindow setMaxSize:_maxSize];
[theWindow setLevel:CPFloatingWindowLevel];
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
@@ -91,6 +96,11 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
[_windowView setAutoresizesSubviews:YES];
if ([_viewClass isKindOfClass:[CPToolbar class]])
{
[theWindow setToolbar:_viewClass];
}
return theWindow;
}
+23 -23
View File
@@ -20,10 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPString.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
import "CAMediaTimingFunction.j"
@import "CAMediaTimingFunction.j"
/*
This is an animation class.
@@ -33,9 +33,9 @@ import "CAMediaTimingFunction.j"
BOOL _isRemovedOnCompletion;
}
/*
Creates a new <objj>CAAnimation</objj> instance
@return a new <objj>CAAnimation</objj> instance
/*!
Creates a new CAAnimation instance
@return a new CAAnimation instance
*/
+ (id)animation
{
@@ -52,7 +52,7 @@ import "CAMediaTimingFunction.j"
return self;
}
/*
/*!
Returns <code>YES</code>
@return <code>YES</code>
*/
@@ -61,7 +61,7 @@ import "CAMediaTimingFunction.j"
return YES;
}
/*
/*!
Returns <code>nil</code>
@return <code>nil</code>
*/
@@ -70,7 +70,7 @@ import "CAMediaTimingFunction.j"
return nil;
}
/*
/*!
Specifies whether this animation should be removed after it has completed.
@param <code>YES</code> means the animation should be removed
*/
@@ -79,7 +79,7 @@ import "CAMediaTimingFunction.j"
_isRemovedOnCompletion = isRemovedOnCompletion;
}
/*
/*!
Returns <code>YES</code> if the animation is removed after completion
*/
- (BOOL)removedOnCompletion
@@ -87,7 +87,7 @@ import "CAMediaTimingFunction.j"
return _isRemovedOnCompletion;
}
/*
/*!
Returns <code>YES</code> if the animation is removed after completion
*/
- (BOOL)isRemovedOnCompletion
@@ -95,7 +95,7 @@ import "CAMediaTimingFunction.j"
return _isRemovedOnCompletion;
}
/*
/*!
Returns the animation's timing function. If <code>nil</code>, then it has a linear pacing.
*/
- (CAMediaTimingFunction)timingFunction
@@ -104,7 +104,7 @@ import "CAMediaTimingFunction.j"
return nil;
}
/*
/*!
Sets the animation delegate
@param aDelegate the new delegate
*/
@@ -113,7 +113,7 @@ import "CAMediaTimingFunction.j"
_delegate = aDelegate;
}
/*
/*!
Returns the animation's delegate
*/
- (id)delegate
@@ -190,9 +190,9 @@ import "CAMediaTimingFunction.j"
@end
/*
A <objj>CABasicAnimation</objj> is a simple animation that moves a
<objj>CALayer</objj> from one point to another over a specified
/*!
A CABasicAnimation is a simple animation that moves a
CALayer from one point to another over a specified
period of time.
*/
@implementation CABasicAnimation : CAPropertyAnimation
@@ -202,7 +202,7 @@ import "CAMediaTimingFunction.j"
id _byValue;
}
/*
/*!
Sets the starting position for the animation.
@param aValue the animation starting position
*/
@@ -211,7 +211,7 @@ import "CAMediaTimingFunction.j"
_fromValue = aValue;
}
/*
/*!
Returns the animation's starting position.
*/
- (id)fromValue
@@ -219,7 +219,7 @@ import "CAMediaTimingFunction.j"
return _fromValue;
}
/*
/*!
Sets the ending position for the animation.
@param aValue the animation ending position
*/
@@ -228,7 +228,7 @@ import "CAMediaTimingFunction.j"
_toValue = aValue;
}
/*
/*!
Returns the animation's ending position.
*/
- (id)toValue
@@ -236,7 +236,7 @@ import "CAMediaTimingFunction.j"
return _toValue;
}
/*
/*!
Sets the optional byValue for animation interpolation.
@param aValue the byValue
*/
@@ -245,7 +245,7 @@ import "CAMediaTimingFunction.j"
_byValue = aValue;
}
/*
/*!
Returns the animation's byValue.
*/
- (id)byValue
+3 -2
View File
@@ -20,11 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CGGeometry.j"
import "CPCompatibility.j"
@import "CGGeometry.j"
@import "CPCompatibility.j"
#define PIXEL(pixels) pixels + "px";
function CABackingStoreGetContext(aBackingStore)
{
return aBackingStore.context;
+2 -2
View File
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CALayer.j"
import "CPFlashMovie.j"
@import "CALayer.j"
@import "CPFlashMovie.j"
@implementation CAFlashLayer : CALayer
+58 -57
View File
@@ -20,12 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
@import <Foundation/CPObject.j>
import <AppKit/CABackingStore.j>
@import <AppKit/CABackingStore.j>
import <AppKit/CGContext.j>
import <AppKit/CGGeometry.j>
@import <AppKit/CGContext.j>
@import <AppKit/CGGeometry.j>
#include "../CoreGraphics/CGGeometry.h"
#include "../CoreGraphics/CGAffineTransform.j"
@@ -49,12 +49,13 @@ var CALayerFrameOriginUpdateMask = 1,
var CALayerRegisteredRunLoopUpdates = nil;
/*
A <objj>CALayer</objj> is similar to a <objj>CPView</objj>, but with the ability
/*! @class CALayer
A CALayer is similar to a CPView, but with the ability
to have a transform applied to it.
@delegate -(void)drawLayer:(CALayer)layer inContext:(CGContextRef)ctx;
If the delegate implements this method, the <objj>CALayer</objj> will
If the delegate implements this method, the CALayer will
call this in place of its <code>drawInContext:</code>.
@param layer the layer to draw for
@param ctx the context to draw on
@@ -118,7 +119,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
CGAffineTransform _transformFromLayer;
}
/*
/*!
Returns a new animation layer.
*/
+ (CALayer)layer
@@ -126,7 +127,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return [[[self class] alloc] init];
}
/*
/*!
Initializes the animation layer.
*/
- (id)init
@@ -172,7 +173,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
// Modifying the Layer Geometry
/*
/*!
Sets the bounds (origin and size) of the rectangle.
@param aBounds the new bounds for the layer
*/
@@ -201,7 +202,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryBoundsMask);
}
/*
/*!
Returns the layer's bound.
*/
- (CGRect)bounds
@@ -209,7 +210,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _bounds;
}
/*
/*!
Sets the layer's position.
@param aPosition the layer's new position
*/
@@ -223,7 +224,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryPositionMask);
}
/*
/*!
Returns the layer's position
*/
- (CGPoint)position
@@ -231,7 +232,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _position;
}
/*
/*!
Sets the layer's z-ordering.
@param aZPosition the layer's new z-ordering
*/
@@ -245,7 +246,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self registerRunLoopUpdateWithMask:CALayerZPositionUpdateMask];
}
/*
/*!
Sets the layer's anchor point. The default point is [0.5, 0.5].
@param anAnchorPoint the layer's new anchor point
*/
@@ -269,7 +270,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryAnchorPointMask);
}
/*
/*!
Returns the layer's anchor point.
*/
- (CGPoint)anchorPoint
@@ -277,7 +278,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _anchorPoint;
}
/*
/*!
Sets the affine transform applied to this layer.
@param anAffineTransform the new affine transform
*/
@@ -291,7 +292,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_CALayerRecalculateGeometry(self, CALayerGeometryAffineTransformMask);
}
/*
/*!
Returns the layer's affine transform.
*/
- (CGAffineTransform)affineTransform
@@ -299,7 +300,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _affineTransform;
}
/*
/*!
Sets the affine transform that gets applied to all the sublayers.
@param anAffineTransform the transform to apply to sublayers
*/
@@ -325,7 +326,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
}
/*
/*!
Returns the affine transform applied to the sublayers.
*/
- (CGAffineTransform)sublayerTransform
@@ -342,7 +343,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _transformToLayer;
}
/*
/*!
Sets the frame of the layer. The frame defines a bounding
rectangle in the superlayer's coordinate system.
@param aFrame the new frame rectangle
@@ -352,7 +353,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
alert("FIXME IMPLEMENT");
}
/*
/*!
Returns the layer's frame.
The frame defines the bounding box of the layer: the smallest
@@ -367,7 +368,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _frame;
}
/*
/*!
The Backing Store Frame specifies the frame of the actual backing
store used to contain this layer. Naturally, by default it is the
same as the frame, however, users can specify their own custom
@@ -380,7 +381,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _backingStoreFrame;
}
/*
/*!
Sets the frame's backing store.
@param aFrame the new backing store.
*/
@@ -416,8 +417,8 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
// Providing Layer Content
/*
Returns the <objj>CGImage</objj> contents of this layer.
/*!
Returns the CGImage contents of this layer.
The default contents are <code>nil</code>.
*/
- (CGImage)contents
@@ -425,7 +426,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _contents;
}
/*
/*!
Sets the image contents of this layer.
@param contents the image to display
*/
@@ -479,7 +480,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
CGContextRestoreGState(_context);
}
/*
/*!
Displays the contents of this layer.
*/
- (void)display
@@ -526,7 +527,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self composite];
}
/*
/*!
Draws this layer's contents into the specified context.
@param aContext the context to draw the layer into
*/
@@ -544,7 +545,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
// Style Attributes
/*
/*!
Returns the opacity of the layer. The value is between
<code>0.0</code> (transparent) and <code>1.0</code> (opaque).
*/
@@ -553,7 +554,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _opacity;
}
/*
/*!
Sets the opacity for the layer.
@param anOpacity the new opacity (between <code>0.0</code> (transparent) and <code>1.0</code> (opaque)).
*/
@@ -568,7 +569,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_DOMElement.style.filter = "alpha(opacity=" + anOpacity * 100 + ")";
}
/*
/*!
Sets whether the layer is hidden.
@param isHidden <code>YES</code> means the layer will be hidden. <code>NO</code> means the layer will be visible.
*/
@@ -578,7 +579,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_DOMElement.style.display = isHidden ? "none" : "block";
}
/*
/*!
Returns <code>YES</code> if the layer is hidden.
*/
- (BOOL)hidden
@@ -586,7 +587,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _isHidden;
}
/*
/*!
Returns <code>YES</code> if the layer is hidden.
*/
- (BOOL)isHidden
@@ -594,7 +595,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _isHidden;
}
/*
/*!
Sets whether content that goes lies outside the bounds is hidden or visible.
@param masksToBounds <code>YES</code> hides the excess content. <code>NO</code> makes it visible.
*/
@@ -607,7 +608,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
_DOMElement.style.overflow = _masksToBounds ? "hidden" : "visible";
}
/*
/*!
Sets the layer's background color.
@param aColor the new background color
*/
@@ -618,7 +619,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
[self setNeedsDisplay];
}
/*
/*!
Returns the layer's background color.
*/
- (CPColor)backgroundColor
@@ -627,7 +628,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
}
// Managing Layer Hierarchy
/*
/*!
Returns an array of the receiver's sublayers.
*/
- (CPArray)sublayers
@@ -635,7 +636,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _sublayers;
}
/*
/*!
Returns the receiver's superlayer.
*/
- (CALayer)superlayer
@@ -647,7 +648,7 @@ var CALayerRegisteredRunLoopUpdates = nil;
if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)\
_DOMContentsElement.style.zIndex -= 100.0;\
/*
/*!
Adds the specified layer as a sublayer of the receiver.
*/
- (void)addSublayer:(CALayer)aLayer
@@ -660,7 +661,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_DOMElement.appendChild(DOM(aLayer));
}
/*
/*!
Removes the receiver from its superlayer.
*/
- (void)removeFromSuperlayer
@@ -677,7 +678,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_superlayer = nil;
}
/*
/*!
Inserts the specified layer as a sublayer into the specified index.
@param aLayer the layer to insert
@param anIndex the index to insert the layer at
@@ -719,7 +720,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_CALayerRecalculateGeometry(aLayer, 0xFFFFFFF);
}
/*
/*!
Inserts a layer below another layer.
@param aLayer the layer to insert
@param aSublayer the layer to insert below
@@ -732,7 +733,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self insertSublayer:aLayer atIndex:index == CPNotFound ? _sublayers.length : index];
}
/*
/*!
Inserts a layer above another layer.
@param aLayer the layer to insert
@param aSublayer the layer to insert above
@@ -747,7 +748,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[_sublayers insertObject:aLayer atIndex:index == CPNotFound ? _sublayers.length : index + 1];
}
/*
/*!
Replaces a sublayer.
@param aSublayer the layer to insert
@param aLayer the layer to replace
@@ -823,7 +824,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self registerRunLoopUpdateWithMask:CALayerCompositeUpdateMask];
}
/*
/*!
Marks the layer as needing to be redrawn.
*/
- (void)setNeedsDisplay
@@ -831,7 +832,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self registerRunLoopUpdateWithMask:CALayerDisplayUpdateMask];
}
/*
/*!
Sets whether the layer needs to be redrawn when its bounds are changed.
@param needsDisplayOnBoundsChange <code>YES</code> means the display is redraw on a bounds change.
*/
@@ -840,7 +841,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
}
/*
/*!
Returns <code>YES</code> if the display should be redrawn on a bounds change.
*/
- (BOOL)needsDisplayOnBoundsChange
@@ -848,7 +849,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return _needsDisplayOnBoundsChange;
}
/*
/*!
Marks the specified rectange as needing to be redrawn.
@param aRect the area that needs to be redrawn.
*/
@@ -859,7 +860,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Mapping Between Coordinate and Time Spaces
/*
/*!
Converts the point from the specified layer's coordinate system into the receiver's coordinate system.
@param aPoint the point to convert
@param aLayer the layer coordinate system to convert from
@@ -870,7 +871,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(aLayer, self));
}
/*
/*!
Converts the point from the receiver's coordinate system to the specified layer's coordinate system.
@param aPoint the point to convert
@param aLayer the layer coordinate system to convert to
@@ -881,7 +882,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(self, aLayer));
}
/*
/*!
Converts the rectangle from the specified layer's coordinate system to the receiver's coordinate system.
@param aRect the rectangle to convert
@param aLayer the layer coordinate system to convert from
@@ -892,7 +893,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return CGRectApplyAffineTransform(aRect, _CALayerGetTransform(aLayer, self));
}
/*
/*!
Converts the rectangle from the receier's coordinate system to the specified layer's coordinate system.
@param aRect the rectange to convert
@param aLayer the layer coordinate system to convert to
@@ -904,7 +905,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Hit Testing
/*
/*!
Returns <code>YES</code> if the layer contains the point.
@param aPoint the point to test
*/
@@ -913,7 +914,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return _CGRectContainsPoint(_bounds, aPoint);
}
/*
/*!
Returns the farthest descendant of this layer that contains the specified point.
@param aPoint the point to test
@return the containing layer or <code>nil</code> if there was no hit.
@@ -941,7 +942,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
}
// Modifying the Delegate
/*
/*!
Sets the delegate for this layer.
@param aDelegate the delegate
*/
@@ -959,7 +960,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
[self setNeedsDisplay];
}
/*
/*!
Returns the layer's delegate
*/
- (id)delegate
+3 -3
View File
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPDictionary.j>
import <Foundation/CPString.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPDictionary.j>
@import <Foundation/CPString.j>
kCAMediaTimingFunctionLinear = @"kCAMediaTimingFunctionLinear";
+7 -6
View File
@@ -25,7 +25,8 @@
#define _function(inline) function inline { return _##inline; }
import "CGGeometry.j"
@import "CGGeometry.j"
_function(CGAffineTransformMake(a, b, c, d, tx, ty))
_function(CGAffineTransformMakeIdentity())
@@ -55,7 +56,7 @@ function CGAffineTransformCreateCopy(aTransform)
return _CGAffineTransformMakeCopy(aTransform);
}
/*
/*!
Returns a transform that rotates a coordinate system.
@param anAngle the amount in radians for the transform
to rotate a coordinate system
@@ -71,7 +72,7 @@ function CGAffineTransformMakeRotation(anAngle)
return _CGAffineTransformMake(cos, sin, -sin, cos, 0.0, 0.0);
}
/*
/*!
Rotates a transform.
@param aTransform the transform to rotate
@param anAngle the amount to rotate in radians
@@ -93,7 +94,7 @@ function CGAffineTransformRotate(aTransform, anAngle)
};
}
/*
/*!
Inverts a transform.
@param aTransform the transform to invert
@return CGAffineTransform an inverted transform
@@ -113,7 +114,7 @@ function CGAffineTransformInvert(aTransform)
};
}
/*
/*!
Applies a transform to the rectangle's points. The transformed rectangle
will be the smallest box that contains the transformed points.
@param aRect the rectangle to transform
@@ -139,7 +140,7 @@ function CGRectApplyAffineTransform(aRect, anAffineTransform)
return _CGRectMake(minX, minY, (maxX - minX), (maxY - minY));
}
/*
/*!
Creates and returns a string representation of an affine transform.
@param anAffineTransform the transform to represent as a string
@return CPString a string describing the transform
+30 -29
View File
@@ -21,7 +21,8 @@
*/
//import "CGPattern.j"
import "CGColorSpace.j"
@import "CGColorSpace.j"
// FIXME: Move this to Objective-J.js!!!
var CFTypeGlobalCount = 0;
@@ -45,7 +46,7 @@ function CGColorGetConstantColor(aColorName)
alert("FIX ME");
}
/*
/*!
This function is for source compatability.
*/
function CGColorRetain(aColor)
@@ -53,16 +54,16 @@ function CGColorRetain(aColor)
return aColor;
}
/*
/*!
This function is for source compatability.
*/
function CGColorRelease()
{
}
/*
Creates a new <objj>CGColor</objj>.
@param aColorSpace the <objj>CGColorSpace</objj> of the color
/*!
Creates a new CGColor.
@param aColorSpace the CGColorSpace of the color
@param components the color's intensity values plus alpha
@return CGColor the new color object
@group CGColor
@@ -84,11 +85,11 @@ function CGColorCreate(aColorSpace, components)
return _CGColorMap[UID] = { colorspace:aColorSpace, pattern:NULL, components:components };
}
/*
Creates a copy of a color... but not really. <objj>CGColor</objj>s
/*!
Creates a copy of a color... but not really. CGColors
are immutable, so to be efficient, this function will just
return the same object that was passed in.
@param aColor the <objj>CGColor</objj> to 'copy'
@param aColor the CGColor to 'copy'
@return CGColor the color copy
@group CGColor
*/
@@ -98,7 +99,7 @@ function CGColorCreateCopy(aColor)
return aColor;
}
/*
/*!
Creates a gray color object.
@param gray the value to use for the color intensities (<code>0.0-1.0</code>)
@param alpha the gray's alpha value (<code>0.0-1.0</code>)
@@ -110,7 +111,7 @@ function CGColorCreateGenericGray(gray, alpha)
return CGColorCreate(0, [gray, alpha]);
}
/*
/*!
Creates an RGB color.
@param red the red component (<code>0.0-1.0</code>)
@param green the green component (<code>0.0-1.0</code>)
@@ -124,7 +125,7 @@ function CGColorCreateGenericRGB(red, green, blue, alpha)
return CGColorCreate(0, [red, green, blue, alpha]);
}
/*
/*!
Creates a CMYK color.
@param cyan the cyan component (<code>0.0-1.0</code>)
@param magenta the magenta component (<code>0.0-1.0</code>)
@@ -139,7 +140,7 @@ function CGColorCreateGenericCMYK(cyan, magenta, yellow, black, alpha)
return CGColorCreate(0, [cyan, magenta, yellow, black, alpha]);
}
/*
/*!
Creates a copy of the color with a specified alpha.
@param aColor the color object to copy
@param anAlpha the new alpha component for the copy (<code>0.0-1.0</code>)
@@ -163,9 +164,9 @@ function CGColorCreateCopyWithAlpha(aColor, anAlpha)
return copy;
}
/*
/*!
Creates a color using the specified pattern.
@param aColorSpace the <objj>CGColorSpace</objj>
@param aColorSpace the CGColorSpace
@param aPattern the pattern image
@param components the color components plus the alpha component
@return CGColor the patterned color
@@ -179,10 +180,10 @@ function CGColorCreateWithPattern(aColorSpace, aPattern, components)
return { colorspace:aColorSpace, pattern:aPattern, components:components.slice() };
}
/*
/*!
Determines if two colors are the same.
@param lhs the first <objj>CGColor</objj>
@param rhs the second <objj>CGColor</objj>
@param lhs the first CGColor
@param rhs the second CGColor
@return <code>YES</code> if the two colors are equal.
<code>NO</code> otherwise.
*/
@@ -214,7 +215,7 @@ function CGColorEqualToColor(lhs, rhs)
return true;
}
/*
/*!
Returns the color's alpha component.
@param aColor the color
@return float the alpha component (<code>0.0-1.0</code>)
@@ -227,9 +228,9 @@ function CGColorGetAlpha(aColor)
return components[components.length - 1];
}
/*
Returns the <objj>CGColor</objj>'s color space.
@return <objj>CGColorSpace</objj>
/*!
Returns the CGColor's color space.
@return CGColorSpace
@group CGColor
*/
function CGColorGetColorSpace(aColor)
@@ -237,8 +238,8 @@ function CGColorGetColorSpace(aColor)
return aColor.colorspace;
}
/*
Returns the <objj>CGColor</objj>'s components
/*!
Returns the CGColor's components
including the alpha in an array.
@param aColor the color
@return CPArray the color's components
@@ -248,10 +249,10 @@ function CGColorGetComponents(aColor)
return aColor.components;
}
/*
/*!
Returns the number of color components
(including alpha) in the specified color.
@param aColor the <objj>CGColor</objj>
@param aColor the CGColor
@return CPNumber the number of components
@group CGColor
*/
@@ -260,9 +261,9 @@ function CGColorGetNumberOfComponents(aColor)
return aColor.components.length;
}
/*
Gets the <objj>CGColor</objj>'s pattern.
@param a <objj>CGColor</objj>
/*!
Gets the CGColor's pattern.
@param a CGColor
@return CGPatternFIXME the pattern image
@group CGColor
*/
+22 -17
View File
@@ -23,9 +23,9 @@
#include "CGGeometry.h"
#include "CGAffineTransform.h"
import "CGGeometry.j"
import "CGAffineTransform.j"
import "CGPath.j"
@import "CGGeometry.j"
@import "CGAffineTransform.j"
@import "CGPath.j"
kCGLineCapButt = 0;
kCGLineCapRound = 1;
@@ -182,7 +182,7 @@ kCGBlendModePlusDarker = 26;
*/
kCGBlendModePlusLighter = 27;
/*
/*!
This function is just here for source compatability.
It does nothing.
@group CGContext
@@ -191,7 +191,7 @@ function CGContextRelease()
{
}
/*
/*!
This function is just here for source compatability.
It does nothing.
@param aContext a CGContext
@@ -208,14 +208,14 @@ if (!CPFeatureIsCompatible(CPHTMLCanvasFeature))
function CGGStateCreate()
{
return { strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
return { alpha:1.0, strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
blendMode:kCGBlendModeNormal,
shadowOffset:_CGSizeMakeZero(), shadowBlur:0.0, shadowColor:NULL, CTM:_CGAffineTransformMakeIdentity() };
}
function CGGStateCreateCopy(aGState)
{
return { strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
return { alpha:aGState.alpha, strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
lineJoin:aGState.lineJoin, lineCap:aGState.lineCap, miterLimit:aGState.miterLimit, globalAlpha:aGState.globalAlpha,
blendMode:aGState.blendMode,
shadowOffset:aGState.shadowOffset, shadowBlur:aGState.shadowBlur, shadowColor:aGState.shadowColor, CTM:_CGAffineTransformMakeCopy(aGState.CTM) };
@@ -418,10 +418,15 @@ function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor)
gState.shadowColor = aColor;
}
function CGContextSetAlpha(aContext, anAlpha)
{
aContext.gState.alpha = MAX(MIN(anAlpha, 1.0), 0.0);
}
} // END CANVAS IF
// GOOD.
/*
/*!
Fills in the area of the current path, using the even-odd fill rule.
@param aContext the CGContext of the path
@return void
@@ -432,7 +437,7 @@ function CGContextEOFillPath(aContext)
CGContextDrawPath(aContext, kCGPathEOFill);
}
/*
/*!
Fills in the area of the current path, using the non-zero winding number rule.
@param aContext the CGContext of the path
@return void
@@ -445,7 +450,7 @@ function CGContextFillPath(aContext)
var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
/*
/*!
Draws the outline of an ellipse bounded by a rectangle.
@param aContext CGContext to draw on
@param aRect the rectangle bounding the ellipse
@@ -474,7 +479,7 @@ function CGContextAddEllipseInRect(aContext, aRect)
CGContextClosePath(aContext);
}
/*
/*!
Fills an ellipse bounded by a rectangle.
@param aContext CGContext to draw on
@param aRect the rectangle bounding the ellipse
@@ -487,7 +492,7 @@ function CGContextFillEllipseInRect(aContext, aRect)
CGContextFillPath(aContext);
}
/*
/*!
Strokes an ellipse bounded by the specified rectangle.
@param aContext CGContext to draw on
@param aRect the rectangle bounding the ellipse
@@ -500,7 +505,7 @@ function CGContextStrokeEllipseInRect(aContext, aRect)
CGContextStrokePath(aContext);
}
/*
/*!
Paints a line in the current path of the current context.
@param aContext CGContext to draw on
@return void
@@ -511,7 +516,7 @@ function CGContextStrokePath(aContext)
CGContextDrawPath(aContext, kCGPathStroke);
}
/*
/*!
Strokes multiple line segments.
@param aContext CGContext to draw on
@param points an array with an even number of points. The
@@ -543,7 +548,7 @@ function CGContextStrokeLineSegments(aContext, points, count)
//FIXME: THIS IS WRONG!!!
/*
/*!
Sets the current fill color.
@param aContext the CGContext
@param aColor the new color for the fill
@@ -557,7 +562,7 @@ function CGContextSetFillColor(aContext, aColor)
aContext.gState.fillStyle = [aColor cssString];
}
/*
/*!
Sets the current stroke color.
@param aContext the CGContext
@param aColor the new color for the stroke
@@ -570,7 +575,7 @@ function CGContextSetStrokeColor(aContext, aColor)
aContext.gState.strokeStyle = [aColor cssString];
}
/*
/*!
Fills a rounded rectangle.
@param aContext the CGContext to draw into
@param aRect the base rectangle
+16 -1
View File
@@ -333,7 +333,20 @@ function eigen(anAffineTransform)
alert("IMPLEMENT ME!");
}
function CGContextConcatCTM(aContext, anAffineTransform)
if (CPFeatureIsCompatible(CPJavaScriptCanvasTransformFeature))
{
CGContextConcatCTM = function(aContext, anAffineTransform)
{
aContext.transform(anAffineTransform.a, anAffineTransform.b, anAffineTransform.c, anAffineTransform.d, anAffineTransform.tx, anAffineTransform.ty);
}
}
else
{
CGContextConcatCTM = function(aContext, anAffineTransform)
{
var a = anAffineTransform.a,
b = anAffineTransform.b,
@@ -399,6 +412,8 @@ function CGContextConcatCTM(aContext, anAffineTransform)
CGContextRotateCTM(aContext, a2);
}
}
function CGContextDrawImage(aContext, aRect, anImage)
{
aContext.drawImage(anImage._image, _CGRectGetMinX(aRect), _CGRectGetMinY(aRect), _CGRectGetWidth(aRect), _CGRectGetHeight(aRect));
+2 -1
View File
@@ -111,7 +111,7 @@ function CGContextDrawPath(aContext, aMode)
{
if (!aContext || CGPathIsEmpty(aContext.path))
return;
var opacity = 1.0;
var elements = aContext.path.elements,
i = 0,
@@ -120,6 +120,7 @@ var opacity = 1.0;
gState = aContext.gState,
fill = (aMode == kCGPathFill || aMode == kCGPathFillStroke) ? 1 : 0,
stroke = (aMode == kCGPathStroke || aMode == kCGPathFillStroke) ? 1 : 0,
opacity = gState.alpha,
vml = [ "<cg_vml_:shape",
" fillcolor=\"", gState.fillStyle,
"\" filled=\"", VML_TRUTH_TABLE[fill],
+12 -12
View File
@@ -65,12 +65,12 @@ _function(CGRectIsNull(aRect))
_function(CGRectContainsPoint(aRect, aPoint))
/*
Returns a <code>BOOL</code> indicating whether <objj>CGRect</objj> <code>lhsRect</code>
contains <objj>CGRect</objj> <code>rhsRect</code>.
/*!
Returns a <code>BOOL</code> indicating whether CGRect <code>lhsRect</code>
contains CGRect <code>rhsRect</code>.
@group CGRect
@param lhsRect the <objj>CGRect</objj> to test if <code>rhsRect</code> is inside of
@param rhsRect the <objj>CGRect</objj> to test if it fits inside <code>lhsRect</code>.
@param lhsRect the CGRect to test if <code>rhsRect</code> is inside of
@param rhsRect the CGRect to test if it fits inside <code>lhsRect</code>.
@return BOOL <code>YES</code> if <code>rhsRect</code> fits inside <code>lhsRect</code>.
*/
function CGRectContainsRect(lhsRect, rhsRect)
@@ -80,11 +80,11 @@ function CGRectContainsRect(lhsRect, rhsRect)
return _CGRectEqualToRect(union, lhsRect);
}
/*
/*!
Returns <code>YES</code> if the two rectangles intersect
@group CGRect
@param lhsRect the first <objj>CGRect</objj>
@param rhsRect the second <objj>CGRect</objj>
@param lhsRect the first CGRect
@param rhsRect the second CGRect
@return BOOL <code>YES</code> if the two rectangles have any common spaces, and <code>NO</code>, otherwise.
*/
function CGRectIntersectsRect(lhsRect, rhsRect)
@@ -94,9 +94,9 @@ function CGRectIntersectsRect(lhsRect, rhsRect)
return !_CGRectIsEmpty(intersection);
}
/*
Makes the origin and size of a <objj>CGRect</objj> all integers. Specifically, by making
the southwest corner the origin (rounded down), and the northeast corner a <objj>CGSize</objj> (rounded up).
/*!
Makes the origin and size of a CGRect all integers. Specifically, by making
the southwest corner the origin (rounded down), and the northeast corner a CGSize (rounded up).
@param aRect the rectangle to operate on
@return CGRect the modified rectangle (same as the input)
@group CGRect
@@ -118,7 +118,7 @@ function CGRectIntegral(aRect)
return aRect;
}
/*
/*!
Returns the intersection of the two provided rectangles as a new rectangle.
@param lhsRect the first rectangle used for calculation
@param rhsRect the second rectangle used for calculation
+3 -2
View File
@@ -20,8 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CGColor.j"
import "CGColorSpace.j"
@import "CGColor.j"
@import "CGColorSpace.j"
kCGGradientDrawsBeforeStartLocation = 1 << 0;
kCGGradientDrawsAfterEndLocation = 1 << 1;
+3 -2
View File
@@ -23,8 +23,9 @@
#include "CGGeometry.h"
#include "CGAffineTransform.h"
import "CGGeometry.j"
import "CGAffineTransform.j"
@import "CGGeometry.j"
@import "CGAffineTransform.j"
kCGPathElementMoveToPoint = 0;
kCGPathElementAddLineToPoint = 1;
+1 -1
View File
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPRunLoop.j>
@import <Foundation/CPRunLoop.j>
#include "../../CoreGraphics/CGAffineTransform.h"
#include "CPDOMDisplayServer.h"
+25 -21
View File
@@ -20,13 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPObject.j>
import <Foundation/CPRunLoop.j>
@import <Foundation/CPObject.j>
@import <Foundation/CPRunLoop.j>
import "CPEvent.j"
import "CPCompatibility.j"
@import "CPEvent.j"
@import "CPCompatibility.j"
import "CPDOMWindowLayer.j"
@import "CPDOMWindowLayer.j"
#import "../../CoreGraphics/CGGeometry.h"
@@ -35,6 +35,11 @@ CPSharedDOMWindowBridge = nil;
var ExcludedDOMElements = [];
// Define up here so compressor knows about em.
var CPDOMWindowGetFrame,
CPDOMEventGetClickCount,
CPDOMEventStop;
@implementation CPDOMWindowBridge : CPObject
{
CPArray _orderedWindows;
@@ -68,7 +73,7 @@ var ExcludedDOMElements = [];
CPString _overriddenEventType;
}
/*
/*!
Returns the shared DOMWindowBridge.
*/
+ (id)sharedDOMWindowBridge
@@ -375,7 +380,7 @@ var CTRL_KEY_CODE = 17;
@implementation CPDOMWindowBridge (Events)
/*
/*!
When using command (mac) or control (windows), keys are propagated to the browser by default.
To prevent a character key from propagating (to prevent its default action, and instead use it
in your own application), use these methods. These methods are additive -- the list builds until you clear it.
@@ -388,7 +393,7 @@ var CTRL_KEY_CODE = 17;
CharacterKeysToPrevent[""+characters[i-1].toLowerCase()] = YES;
}
/*
/*!
@param character a character to stop propagating keypresses to the browser.
*/
- (void)preventCharacterKeyFromPropagating:(CPString)character
@@ -396,7 +401,7 @@ var CTRL_KEY_CODE = 17;
CharacterKeysToPrevent[character.toLowerCase()] = YES;
}
/*
/*!
Clear the list of characters for which we are not sending keypresses to the browser.
*/
- (void)clearCharacterKeysToPreventFromPropagating
@@ -404,7 +409,7 @@ var CTRL_KEY_CODE = 17;
CharacterKeysToPrevent = {};
}
/*
/*!
Prevent these keyCodes from sending their keypresses to the browser.
@param keyCodes an array of keycodes to prevent propagation.
*/
@@ -414,7 +419,7 @@ var CTRL_KEY_CODE = 17;
KeyCodesToPrevent[keyCodes[i-1]] = YES;
}
/*
/*!
Prevent this keyCode from sending its key events to the browser.
@param keyCode a keycode to prevent propagation.
*/
@@ -423,7 +428,7 @@ var CTRL_KEY_CODE = 17;
KeyCodesToPrevent[keyCode] = YES;
}
/*
/*!
Clear the list of keyCodes for which we are not sending keypresses to the browser.
*/
- (void)clearKeyCodesToPreventFromPropagating
@@ -552,8 +557,8 @@ var CTRL_KEY_CODE = 17;
if (StopDOMEventPropagation)
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
catch (anException)
{
@@ -698,8 +703,8 @@ var CTRL_KEY_CODE = 17;
if (StopDOMEventPropagation)
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
catch (anException)
{
@@ -769,8 +774,8 @@ var CTRL_KEY_CODE = 17;
if (StopDOMEventPropagation)
CPDOMEventStop(aDOMEvent);
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
catch (anException)
{
@@ -809,8 +814,7 @@ var CTRL_KEY_CODE = 17;
//window.liveResize = NO;
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
catch (anException)
{
@@ -843,7 +847,7 @@ var CTRL_KEY_CODE = 17;
_pasteboardKeyDownEvent = nil;
[[CPRunLoop currentRunLoop] performSelectors];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
catch (anException)
{
+2 -2
View File
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPArray.j>
import <Foundation/CPObject.j>
@import <Foundation/CPArray.j>
@import <Foundation/CPObject.j>
#include "CPDOMDisplayServer.h"
+58
View File
@@ -0,0 +1,58 @@
These graphics come from the Tango Desktop Project (http://tango.freedesktop.org/Tango_Desktop_Project).
They are released under the Creative Commons Attribution Share-Alike license, full text below.
(license available from CC here: http://creativecommons.org/licenses/by-sa/2.5/)
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
"Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License.
"Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License.
"Licensor" means the individual or entity that offers the Work under the terms of this License.
"Original Author" means the individual or entity who created the Work.
"Work" means the copyrightable work of authorship offered under the terms of this License.
"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
"License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works;
to create and reproduce Derivative Works;
to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works;
to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works.
For the avoidance of doubt, where the work is a musical composition:
Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work.
Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions).
Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions).
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.
4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested.
You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License.
If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
8. Miscellaneous
Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

+8 -7
View File
@@ -20,13 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import <Foundation/CPString.j>
@import <Foundation/CPString.j>
import "CPColor.j"
import "CPFont.j"
import "CPImage.j"
import "CPTextField.j"
import "CPView.j"
@import "CPColor.j"
@import "CPFont.j"
@import "CPImage.j"
@import "CPTextField.j"
@import "CPView.j"
#include "Platform/Platform.h"
#include "Platform/DOM/CPDOMDisplayServer.h"
@@ -39,7 +39,7 @@ import "CPView.j"
CPFont _font;
CPCellImagePosition _imagePosition;
CPImageScaling _imageScalng;
CPImageScaling _imageScaling;
CPImage _image;
CPString _title;
@@ -238,6 +238,7 @@ import "CPView.j"
[_titleField setAlignment:_alignment];
[_titleField setTextColor:_textColor];
[_titleField setHidden:_imagePosition == CPImageOnly];
[_titleField setHitTests:NO];
[self addSubview:_titleField];
}
+2 -2
View File
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPView.j"
import "CPImageView.j"
@import "CPView.j"
@import "CPImageView.j"
var _CPWindowViewResizeIndicatorImage = nil;
+16 -42
View File
@@ -2,58 +2,32 @@
<project name = "AppKit" default = "build" basedir = "." >
<import file = "../common.xml" />
<import file = "${environment.OBJJ_HOME}/lib/steam.xml" />
<import file = "${env.OBJJ_LIB}/steam.xml" />
<target name = "clean">
<steam-build>
<arguments>
<arg line = "-f AppKit.steam -c ${Configuration} clean" />
</arguments>
</steam-build>
</target>
<target name = "build">
<target name = "clean" depends = "steam-uptodate">
<steam-build>
<arguments>
<arg line = "-f AppKit.steam -c ${Configuration} -t AppKit" />
</arguments>
<arg line = "-f AppKit.steam -c ${Configuration} clean" />
</steam-build>
<steam-build>
<arg line = "-f AppKit.steam -c ${Configuration} -t AppKit-Rhino clean" />
</steam-build>
</target>
<target name = "build" depends = "steam-uptodate">
<steam-build>
<arg line = "-f AppKit.steam -c ${Configuration} -t AppKit" />
</steam-build>
<steam-build>
<arguments>
<arg line = "-f AppKit.steam -c ${Configuration} -t AppKit-Rhino" />
</arguments>
<arg line = "-f AppKit.steam -c ${Configuration} -t AppKit-Rhino" />
</steam-build>
<copy file = "../LICENSE" todir = "${Build}/${Configuration}/AppKit" />
</target>
<target name = "release" depends = "build">
<antcall target = "prepare-release" />
<!--<copy todir = "${Build.Cappuccino.Tools.Frameworks}/AppKit">
<fileset dir = "${Build}/${Configuration}/AppKit" />
</copy>-->
<copy todir = "${Build.Cappuccino.Tools.Lib.Frameworks}/AppKit">
<fileset dir = "${Build}/${Configuration}/AppKit" />
</copy>
<copy todir = "${Build.Cappuccino.Tools.Lib.Frameworks-Rhino}/AppKit">
<fileset dir = "${Build}/${Configuration}/AppKit-Rhino" />
</copy>
<copy todir = "${Build.Cappuccino.Starter.Frameworks}/AppKit" >
<fileset dir = "${Build}/${Configuration}/AppKit" />
</copy>
<copy todir = "${Build.Cappuccino.Starter}/NewApplication/Frameworks/AppKit" >
<fileset dir = "${Build}/${Configuration}/AppKit" />
</copy>
</target>
</project>
+228 -103
View File
@@ -20,11 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPObject.j"
import "CPRange.j"
import "CPEnumerator.j"
import "CPSortDescriptor.j"
import "CPException.j"
@import "CPObject.j"
@import "CPRange.j"
@import "CPEnumerator.j"
@import "CPSortDescriptor.j"
@import "CPException.j"
/* @ignore */
@implementation _CPArrayEnumerator : CPEnumerator
@@ -86,55 +86,55 @@ import "CPException.j"
@end
/*
/*! @class CPArray
A mutable array class backed by a JavaScript Array.
There is also a <objj>CPMutableArray</objj> class,
There is also a CPMutableArray class,
but it is just a child class of this class with an
empty implementation. All mutable functionality is
implemented directly in <objj>CPArray</objj>.
implemented directly in CPArray.
*/
@implementation CPArray : CPObject
/*
Returns a new uninitialized <objj>CPArray</objj>.
/*!
Returns a new uninitialized CPArray.
*/
+ (id)alloc
{
return [];
}
/*
Returns a new initialized <objj>CPArray</objj>.
/*!
Returns a new initialized CPArray.
*/
+ (id)array
{
return [[self alloc] init];
}
/*
/*!
Creates a new array containing the objects in <code>anArray</code>.
@param anArray Objects in this array will be added to the new array
@return a new <objj>CPArray</objj> of the provided objects
@return a new CPArray of the provided objects
*/
+ (id)arrayWithArray:(CPArray)anArray
{
return [[self alloc] initWithArray:anArray];
}
/*
/*!
Creates a new array with <code>anObject</code> in it.
@param anObject the object to be added to the array
@return a new <objj>CPArray</objj> containing a single object
@return a new CPArray containing a single object
*/
+ (id)arrayWithObject:(id)anObject
{
return [[self alloc] initWithObjects:anObject];
}
/*
Creates a new <objj>CPArray</objj> containing all the objects passed as arguments to the method.
/*!
Creates a new CPArray containing all the objects passed as arguments to the method.
@param anObject the objects that will be added to the new array
@return a new <objj>CPArray</objj> containing the argument objects
@return a new CPArray containing the argument objects
*/
+ (id)arrayWithObjects:(id)anObject, ...
{
@@ -148,19 +148,19 @@ import "CPException.j"
return array;
}
/*
Creates a <objj>CPArray</objj> from a JavaScript array of objects.
/*!
Creates a CPArray from a JavaScript array of objects.
@param objects the JavaScript Array
@param aCount the number of objects in the JS Array
@return a new <objj>CPArray</objj> containing the specified objects
@return a new CPArray containing the specified objects
*/
+ (id)arrayWithObjects:(id)objects count:(unsigned)aCount
{
return [[self alloc] initWithObjects:objects count:aCount];
}
/*
Initializes the <objj>CPArray</objj>.
/*!
Initializes the CPArray.
@return the initialized array
*/
- (id)init
@@ -169,10 +169,10 @@ import "CPException.j"
}
// Creating an Array
/*
Creates a new <objj>CPArray</objj> from <code>anArray</code>.
/*!
Creates a new CPArray from <code>anArray</code>.
@param anArray objects in this array will be added to the new array
@return a new <objj>CPArray</objj> containing the objects of <code>anArray</code>
@return a new CPArray containing the objects of <code>anArray</code>
*/
- (id)initWithArray:(CPArray)anArray
{
@@ -184,7 +184,7 @@ import "CPException.j"
return self;
}
/*
/*!
Initializes a the array with the contents of <code>anArray</code>
and optionally performs a deep copy of the objects based on <code>copyItems</code>.
@param anArray the array to copy the data from
@@ -217,10 +217,10 @@ import "CPException.j"
return self;
}
/*
initializes
/*!
initializes an array with the contents of anArray
*/
- (id)initWithObjects:(Array)anObject, ...
- (id)initWithObjects:(Array)anArray, ...
{
// The arguments array contains self and _cmd, so the first object is at position 2.
var i = 2,
@@ -232,11 +232,11 @@ import "CPException.j"
return self;
}
/*
/*!
Initializes the array with a JavaScript array of objects.
@param objects the array of objects to add to the receiver
@param aCount the number of objects in <code>objects</code>
@return the initialized <objj>CPArray</objj>
@return the initialized CPArray
*/
- (id)initWithObjects:(id)objects count:(unsigned)aCount
{
@@ -253,8 +253,8 @@ import "CPException.j"
return self;
}
/*
Returns a hash of the <objj>CPArray</objj>.
/*!
Returns a hash of the CPArray.
@return an unsigned integer hash
*/
- (unsigned)hash
@@ -266,7 +266,7 @@ import "CPException.j"
}
// Querying an array
/*
/*!
Returns <code>YES</code> if the array contains <code>anObject</code>. Otherwise, it returns <code>NO</code>.
@param anObject the method checks if this object is already in the array
*/
@@ -275,7 +275,7 @@ import "CPException.j"
return [self indexOfObject:anObject] != CPNotFound;
}
/*
/*!
Returns the number of elements in the array
*/
- (int)count
@@ -283,7 +283,7 @@ import "CPException.j"
return length;
}
/*
/*!
Returns the index of <code>anObject</code> in this array.
If the object is <code>nil</code> or not in the array,
returns <code>CPNotFound</code>. It first attempts to find
@@ -318,7 +318,7 @@ import "CPException.j"
return CPNotFound;
}
/*
/*!
Returns the index of <code>anObject</code> in the array
within <code>aRange</code>. It first attempts to find
a match using <code>isEqual:</code>, then <code>==</code>.
@@ -350,7 +350,7 @@ import "CPException.j"
return CPNotFound;
}
/*
/*!
Returns the index of <code>anObject</code> in the array. The test for equality is done using only <code>==</code>.
@param anObject the object to search for
@return the index of the object in the array. <code>CPNotFound</code> if the object is not in the array.
@@ -379,7 +379,7 @@ import "CPException.j"
return CPNotFound;
}
/*
/*!
Returns the index of <code>anObject</code> in the array
within <code>aRange</code>. The test for equality is
done using only <code>==</code>.
@@ -416,7 +416,101 @@ import "CPException.j"
return CPNotFound;
}
/*
/*!
Returns the index of <code>anObject</code> in the array, which must be sorted in the same order as
calling sortUsingSelector: with the selector passed to this method would result in.
@param anObject the object to search for
@param aSelector the comparison selector to call on each item in the list, the same
selector should have been used to sort the array (or to maintain its sorted order).
@return the index of the object, or <code>CPNotFound</code> if it was not found.
*/
- (unsigned)indexOfObject:(id)anObject sortedBySelector:(SEL)aSelector
{
return [self indexOfObject:anObject sortedByFunction: function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); }];
}
/*!
Returns the index of <code>anObject</code> in the array, which must be sorted in the same order as
calling sortUsingFunction: with the selector passed to this method would result in.
The function will be called like so:
<pre>
aFunction(anObject, currentObjectInArrayForComparison)
</pre>
@param anObject the object to search for
@param aFunction the comparison function to call on each item in the array that we search. the same
selector should have been used to sort the array (or to maintain its sorted order).
@return the index of the object, or <code>CPNotFound</code> if it was not found.
*/
- (unsigned)indexOfObject:(id)anObject sortedByFunction:(Function)aFunction
{
return [self indexOfObject:anObject sortedByFunction:aFunction context:nil];
}
/*!
Returns the index of <code>anObject</code> in the array, which must be sorted in the same order as
calling sortUsingFunction: with the selector passed to this method would result in.
The function will be called like so:
<pre>
aFunction(anObject, currentObjectInArrayForComparison, context)
</pre>
@param anObject the object to search for
@param aFunction the comparison function to call on each item in the array that we search. the same
function should have been used to sort the array (or to maintain its sorted order).
@param aContext a context object that will be passed to the sort function
@return the index of the object, or <code>CPNotFound</code> if it was not found.
*/
- (unsigned)indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
{
if (!aFunction || anObject === undefined)
return CPNotFound;
var mid, c, first = 0, last = length - 1;
while (first <= last)
{
mid = FLOOR((first + last) / 2);
c = aFunction(anObject, self[mid], aContext);
if (c > 0)
first = mid + 1;
else if (c < 0)
last = mid - 1;
else
{
while (mid < length - 1 && aFunction(anObject, self[mid+1], aContext) == CPOrderedSame)
mid++;
return mid;
}
}
return CPNotFound;
}
/*!
Returns the index of <code>anObject</code> in the array, which must be sorted in the same order as
calling sortUsingDescriptors: with the descriptors passed to this method would result in.
@param anObject the object to search for
@param descriptors the array of descriptors to use to compare each item in the array that we search. the same
descriptors should have been used to sort the array (or to maintain its sorted order).
@return the index of the object, or <code>CPNotFound</code> if it was not found.
*/
- (unsigned)indexOfObject:(id)anObject sortedByDescriptors:(CPArray)descriptors
{
[self indexOfObject:anObject sortedByFunction:function(lhs, rhs)
{
var i = 0,
count = [descriptors count],
result = CPOrderedSame;
while (i < count)
if((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
return result;
return result;
}];
}
/*!
Returns the last object in the array. If the array is empty, returns <code>nil</code>/
*/
- (id)lastObject
@@ -428,7 +522,7 @@ import "CPException.j"
return self[count - 1];
}
/*
/*!
Returns the object at index <code>anIndex</code>.
@throws CPRangeException if <code>anIndex</code> is out of bounds
*/
@@ -437,8 +531,8 @@ import "CPException.j"
return self[anIndex];
}
/*
Returns the objects at <code>indexes</code> in a new <objj>CPArray</objj>.
/*!
Returns the objects at <code>indexes</code> in a new CPArray.
@param indexes the set of indices
@throws CPRangeException if any of the indices is greater than or equal to the length of the array
*/
@@ -456,7 +550,7 @@ import "CPException.j"
return objects;
}
/*
/*!
Returns an enumerator describing the array sequentially
from the first to the last element. You should not modify
the array during enumeration.
@@ -466,7 +560,7 @@ import "CPException.j"
return [[_CPArrayEnumerator alloc] initWithArray:self];
}
/*
/*!
Returns an enumerator describing the array sequentially
from the last to the first element. You should not modify
the array during enumeration.
@@ -477,7 +571,7 @@ import "CPException.j"
}
// Sending messages to elements
/*
/*!
Sends each element in the array a message.
@param aSelector the selector of the message to send
@throws CPInvalidArgumentException if <code>aSelector</code> is <code>nil</code>
@@ -494,7 +588,7 @@ import "CPException.j"
objj_msgSend(self[index], aSelector);
}
/*
/*!
Sends each element in the array a message with an argument.
@param aSelector the selector of the message to send
@param anObject the first argument of the message
@@ -513,7 +607,7 @@ import "CPException.j"
}
// Comparing arrays
/*
/*!
Returns the first object found in the receiver (starting at index 0) which is present in the
<code>otherArray</code> as determined by using the <code>-containsObject:</code> method.
@return the first object found, or <code>nil</code> if no common object was found.
@@ -533,11 +627,14 @@ import "CPException.j"
return nil;
}
/*
/*!
Returns true if anArray contains exactly the same objects as the reciever.
*/
- (BOOL)isEqualToArray:(id)anArray
{
if (self === anArray)
return YES;
if(length != anArray.length)
return NO;
@@ -545,14 +642,31 @@ import "CPException.j"
count = [self count];
for(; index < count; ++index)
if(!self[index] || !anArray[index] || ![self[index] isEqual:anArray[index]])
{
var lhs = self[index],
rhs = anArray[index];
// If they're not equal, and either doesn't have an isa, or they're !isEqual (not isEqual)
if (lhs !== rhs && (!lhs.isa || !rhs.isa || ![lhs isEqual:rhs]))
return NO;
}
return YES;
}
- (BOOL)isEqual:(id)anObject
{
if (self === anObject)
return YES;
if(![anObject isKindOfClass:[CPArray class]])
return NO;
return [self isEqualToArray:anObject];
}
// Deriving new arrays
/*
/*!
Returns a copy of this array plus <code>anObject</code> inside the copy.
@param anObject the object to be added to the array copy
@throws CPInvalidArgumentException if <code>anObject</code> is <code>nil</code>
@@ -571,7 +685,7 @@ import "CPException.j"
return array;
}
/*
/*!
Returns a new array which is the concatenation of <code>self</code> and otherArray (in this precise order).
@param anArray the array that will be concatenated to the receiver's copy
*/
@@ -595,17 +709,17 @@ import "CPException.j"
}
*/
/*
/*!
Returns a subarray of the receiver containing the objects found in the specified range <code>aRange</code>.
@param aRange the range of objects to be copied into the subarray
@throws CPRangeException if the specified range exceeds the bounds of the array
*/
- (CPArray)subarrayWithRange:(CPRange)aRange
{
if (aRange.location < 0 || (aRange.location + CPMaxRange(aRange)) > length)
if (aRange.location < 0 || CPMaxRange(aRange) > length)
[CPException raise:CPRangeException reason:"subarrayWithRange: aRange out of bounds"];
return slice(aRange.location, maxRange);
return slice(aRange.location, CPMaxRange(aRange));
}
// Sorting arrays
@@ -621,7 +735,7 @@ import "CPException.j"
return sorted;
}
/*
/*!
Returns an array in which the objects are ordered according
to a sort with <code>aFunction</code>. This invokes
<code>-sortUsingFunction:context</code>.
@@ -638,7 +752,7 @@ import "CPException.j"
return sorted;
}
/*
/*!
Returns a new array in which the objects are ordered according to a sort with <code>aSelector</code>.
@param aSelector the selector that will perform object comparisons
*/
@@ -653,7 +767,7 @@ import "CPException.j"
// Working with string elements
/*
/*!
Returns a string formed by concatenating the objects in the
receiver, with the specified separator string inserted between each part.
If the element is a Objective-J object, then the <code>description</code>
@@ -670,7 +784,7 @@ import "CPException.j"
// Creating a description of the array
/*
/*!
Returns a human readable description of this array and it's elements.
*/
- (CPString)description
@@ -691,11 +805,11 @@ import "CPException.j"
}
// Collecting paths
/*
/*!
Returns a new array subset formed by selecting the elements that have
filename extensions from <code>filterTypes</code>. Only elements
that are of type <objj>CPString</objj> are candidates for inclusion in the returned array.
@param filterTypes an array of <objj>CPString</objj> objects that contain file extensions (without the '.')
that are of type CPString are candidates for inclusion in the returned array.
@param filterTypes an array of CPString objects that contain file extensions (without the '.')
@return a new array with matching paths
*/
- (CPArray)pathsMatchingExtensions:(CPArray)filterTypes
@@ -712,7 +826,7 @@ import "CPException.j"
}
// Key value coding
/*
/*!
Sets the key-value for each element in the array.
@param aValue the value for the coding
@param aKey the key for the coding
@@ -726,7 +840,7 @@ import "CPException.j"
[self[i] setValue:aValue forKey:aKey];
}
/*
/*!
Returns the value for <code>aKey</code> from each element in the array.
@param aKey the key to return the value for
@return an array of containing a value for each element in the array
@@ -745,9 +859,9 @@ import "CPException.j"
// Copying arrays
/*
/*!
Makes a copy of the receiver.
@return a new <objj>CPArray</objj> copy
@return a new CPArray copy
*/
- (id)copy
{
@@ -759,9 +873,9 @@ import "CPException.j"
@implementation CPArray(CPMutableArray)
// Creating arrays
/*
/*!
Creates an array able to store at least <code>aCapacity</code>
items. Because <objj>CPArray</objj> is backed by JavaScript arrays,
items. Because CPArray is backed by JavaScript arrays,
this method ends up simply returning a regular array.
*/
+ (CPArray)arrayWithCapacity:(unsigned)aCapacity
@@ -769,8 +883,8 @@ import "CPException.j"
return [[self alloc] initWithCapacity:aCapacity];
}
/*
Initializes an array able to store at least <code>aCapacity</code> items. Because <objj>CPArray</objj>
/*!
Initializes an array able to store at least <code>aCapacity</code> items. Because CPArray
is backed by JavaScript arrays, this method ends up simply returning a regular array.
*/
- (id)initWithCapacity:(unsigned)aCapacity
@@ -779,7 +893,7 @@ import "CPException.j"
}
// Adding and replacing objects
/*
/*!
Adds <code>anObject</code> to the end of the array.
@param anObject the object to add to the array
*/
@@ -788,7 +902,7 @@ import "CPException.j"
push(anObject);
}
/*
/*!
Adds the objects in <code>anArray</code> to the receiver array.
@param anArray the array of objects to add to the end of the receiver
*/
@@ -797,7 +911,7 @@ import "CPException.j"
splice.apply(self, [length, 0].concat(anArray));
}
/*
/*!
Inserts an object into the receiver at the specified location.
@param anObject the object to insert into the array
@param anIndex the location to insert <code>anObject</code> at
@@ -807,21 +921,32 @@ import "CPException.j"
splice(anIndex, 0, anObject);
}
/*
/*!
Inserts the objects in the provided array into the receiver at the indexes specified.
@param objects the objects to add to this array
@param anIndexSet the indices for the objects
*/
- (void)insertObjects:(CPArray)objects atIndexes:(CPIndexSet)anIndexSet
- (void)insertObjects:(CPArray)objects atIndexes:(CPIndexSet)indexes
{
var index = 0,
position = CPNotFound;
var indexesCount = [indexes count],
objectsCount = [objects count];
while ((position = [indexes indexGreaterThanIndex:position]) != CPNotFound)
[self insertObject:objects[index++] atindex:position];
if(indexesCount !== objectsCount)
[CPException raise:CPRangeException reason:"the counts of the passed-in array (" + objectsCount + ") and index set (" + indexesCount + ") must be identical."];
var lastIndex = [indexes lastIndex];
if(lastIndex >= [self count] + indexesCount)
[CPException raise:CPRangeException reason:"the last index (" + lastIndex + ") must be less than the sum of the original count (" + [self count] + ") and the insertion count (" + indexesCount + ")."];
var index = 0,
currentIndex = [indexes firstIndex];
for (; index < objectsCount; ++index, currentIndex = [indexes indexGreaterThanIndex:currentIndex])
[self insertObject:objects[index] atIndex:currentIndex];
}
/*
/*!
Replaces the element at <code>anIndex</code> with <code>anObject</code>.
The current element at position <code>anIndex</code> will be removed from the array.
@param anIndex the position in the array to place <code>anObject</code>
@@ -831,7 +956,7 @@ import "CPException.j"
self[anIndex] = anObject;
}
/*
/*!
Replace the elements at the indices specified by <code>anIndexSet</code> with
the objects in <code>objects</code>.
@param anIndexSet the set of indices to array positions that will be replaced
@@ -849,7 +974,7 @@ import "CPException.j"
}
}
/*
/*!
Replaces some of the receiver's objects with objects from <code>anArray</code>. Specifically, the elements of the
receiver in the range specified by <code>aRange</code>,
with the elements of <code>anArray</code> in the range specified by <code>otherRange</code>.
@@ -865,7 +990,7 @@ import "CPException.j"
splice.apply(self, [aRange.location, aRange.length].concat([anArray subarrayWithRange:otherRange]));
}
/*
/*!
Replaces some of the receiver's objects with the objects from
<code>anArray</code>. Specifically, the elements of the
receiver in the range specified by <code>aRange</code>.
@@ -877,7 +1002,7 @@ import "CPException.j"
splice.apply(self, [aRange.location, aRange.length].concat(anArray));
}
/*
/*!
Sets the contents of the receiver to be identical to the contents of <code>anArray</code>.
@param anArray the array of objects used to replace the receiver's objects
*/
@@ -889,7 +1014,7 @@ import "CPException.j"
}
// Removing Objects
/*
/*!
Removes all objects from this array.
*/
- (void)removeAllObjects
@@ -897,7 +1022,7 @@ import "CPException.j"
splice(0, length);
}
/*
/*!
Removes the last object from the array.
*/
- (void)removeLastObject
@@ -905,7 +1030,7 @@ import "CPException.j"
pop();
}
/*
/*!
Removes all entries of <code>anObject</code> from the array.
@param anObject the object whose entries are to be removed
*/
@@ -914,7 +1039,7 @@ import "CPException.j"
[self removeObject:anObject inRange:CPMakeRange(0, length)];
}
/*
/*!
Removes all entries of <code>anObject</code> from the array, in the range specified by <code>aRange</code>.
@param anObject the object to remove
@param aRange the range to search in the receiver for the object
@@ -930,7 +1055,7 @@ import "CPException.j"
}
}
/*
/*!
Removes the object at <code>anIndex</code>.
@param anIndex the location of the element to be removed
*/
@@ -939,7 +1064,7 @@ import "CPException.j"
splice(anIndex, 1);
}
/*
/*!
Removes the objects at the indices specified by <code>CPIndexSet</code>.
@param anIndexSet the indices of the elements to be removed from the array
*/
@@ -954,7 +1079,7 @@ import "CPException.j"
}
}
/*
/*!
Remove the first instance of <code>anObject</code> from the array.
The search for the object is done using <code>==</code>.
@param anObject the object to remove
@@ -964,7 +1089,7 @@ import "CPException.j"
[self removeObjectIdenticalTo:anObject inRange:CPMakeRange(0, length)];
}
/*
/*!
Remove the first instance of <code>anObject</code> from the array,
within the range specified by <code>aRange</code>.
The search for the object is done using <code>==</code>.
@@ -982,7 +1107,7 @@ import "CPException.j"
}
}
/*
/*!
Remove the objects in <code>anArray</code> from the receiver array.
@param anArray the array of objects to remove from the receiver
*/
@@ -995,7 +1120,7 @@ import "CPException.j"
[self removeObject:anArray[index]];
}
/*
/*!
Removes all the objects in the specified range from the receiver.
@param aRange the range of objects to remove
*/
@@ -1005,7 +1130,7 @@ import "CPException.j"
}
// Rearranging objects
/*
/*!
Swaps the elements at the two specified indices.
@param anIndex the first index to swap from
@param otherIndex the second index to swap from
@@ -1033,7 +1158,7 @@ import "CPException.j"
});
}
/*
/*!
Sorts the receiver array using a JavaScript function as a comparator, and a specified context.
@param aFunction a JavaScript function that will be called to compare objects
@param aContext an object that will be passed to <code>aFunction</code> with comparison
@@ -1043,7 +1168,7 @@ import "CPException.j"
sort(function(lhs, rhs) { return aFunction(lhs, rhs, aContext); });
}
/*
/*!
Sorts the receiver array using an Objective-J method as a comparator.
@param aSelector the selector for the method to call for comparison
*/
@@ -1068,9 +1193,9 @@ import "CPException.j"
@end
/*
This class is just an empty subclass of <objj>CPArray</objj>.
<objj>CPArray</objj> already implements mutable methods and
/*!
This class is just an empty subclass of CPArray.
CPArray already implements mutable methods and
this class only exists for source compatability.
*/
@implementation CPMutableArray : CPArray
+596
View File
@@ -0,0 +1,596 @@
/*
* CPAttributedString.j
* Foundation
*
* Created by Ross Boucher.
* Copyright 2008, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@import <Foundation/CPObject.j>
@import <Foundation/CPString.j>
@implementation CPAttributedString : CPObject
{
CPString _string;
CPArray _rangeEntries;
}
//Creating an NSAttributedString Object
- (id)initWithString:(CPString)aString
{
return [self initWithString:aString attributes:nil];
}
- (id)initWithAttributedString:(CPAttributedString)aString
{
var string = [self initWithString:"" attributes:nil];
[string setAttributedString:aString];
return string;
}
- (id)initWithString:(CPString)aString attributes:(CPDictionary)attributes
{
self = [super init];
if (!attributes)
attributes = [CPDictionary dictionary];
_string = ""+aString;
_rangeEntries = [makeRangeEntry(CPMakeRange(0, _string.length), attributes)];
return self;
}
//Retrieving Character Information
- (CPString)string
{
return _string;
}
- (CPString)mutableString
{
return [self string];
}
- (unsigned)length
{
return _string.length;
}
- (unsigned)_indexOfEntryWithIndex:(unsigned)anIndex
{
if (anIndex < 0 || anIndex > _string.length || anIndex === undefined)
return CPNotFound;
//find the range entry that contains anIndex.
var sortFunction = function(index, entry)
{
//index is the character index we're searching for, while range is the actual range entry we're comparing against
if (CPLocationInRange(index, entry.range))
return CPOrderedSame;
else if (CPMaxRange(entry.range) <= index)
return CPOrderedDescending;
else
return CPOrderedAscending;
}
return [_rangeEntries indexOfObject:anIndex sortedByFunction:sortFunction];
}
//Retrieving Attribute Information
- (CPDictionary)attributesAtIndex:(unsigned)anIndex effectiveRange:(CPRangePointer)aRange
{
//find the range entry that contains anIndex.
var entryIndex = [self _indexOfEntryWithIndex:anIndex];
if (entryIndex == CPNotFound)
return nil;
var matchingRange = _rangeEntries[entryIndex];
if (aRange)
{
aRange.location = matchingRange.range.location;
aRange.length = matchingRange.range.length;
}
return matchingRange.attributes;
}
- (CPDictionary)attributesAtIndex:(unsigned)anIndex longestEffectiveRange:(CPRangePointer)aRange inRange:(CPRange)rangeLimit
{
var startingEntryIndex = [self _indexOfEntryWithIndex:anIndex];
if (startingEntryIndex == CPNotFound)
return nil;
if (!aRange)
return _rangeEntries[startingEntryIndex].attributes;
if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
{
aRange.location = rangeLimit.location;
aRange.length = rangeLimit.length;
return _rangeEntries[startingEntryIndex].attributes;
}
//scan backwards
var nextRangeIndex = startingEntryIndex - 1,
currentEntry = _rangeEntries[startingEntryIndex],
comparisonDict = currentEntry.attributes;
while (nextRangeIndex >= 0)
{
var nextEntry = _rangeEntries[nextRangeIndex];
if (CPMaxRange(nextEntry.range) > rangeLimit.location && [nextEntry.attributes isEqualToDictionary:comparisonDict])
{
currentEntry = nextEntry;
nextRangeIndex--;
}
else
break;
}
aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
//scan forwards
currentEntry = _rangeEntries[startingEntryIndex];
nextRangeIndex = startingEntryIndex + 1;
while (nextRangeIndex < _rangeEntries.length)
{
var nextEntry = _rangeEntries[nextRangeIndex];
if (nextEntry.range.location < CPMaxRange(rangeLimit) && [nextEntry.attributes isEqualToDictionary:comparisonDict])
{
currentEntry = nextEntry;
nextRangeIndex++;
}
else
break;
}
aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
return comparisonDict;
}
- (id)attribute:(CPString)attribute atIndex:(unsigned)index effectiveRange:(CPRangePointer)aRange
{
if (!attribute)
{
if (aRange)
{
aRange.location = 0;
aRange.length = _string.length;
}
return nil;
}
return [[self attributesAtIndex:index effectiveRange:aRange] valueForKey:attribute];
}
- (id)attribute:(CPString)attribute atIndex:(unsigned)anIndex longestEffectiveRange:(CPRangePointer)aRange inRange:(CPRange)rangeLimit
{
//find the range entry that contains anIndex.
var startingEntryIndex = [self _indexOfEntryWithIndex:anIndex];
if (startingEntryIndex == CPNotFound || !attribute)
return nil;
if (!aRange)
return [_rangeEntries[startingEntryIndex].attributes objectForKey:attribute];
if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
{
aRange.location = rangeLimit.location;
aRange.length = rangeLimit.length;
return [_rangeEntries[startingEntryIndex].attributes objectForKey:attribute];
}
//scan backwards
var nextRangeIndex = startingEntryIndex - 1,
currentEntry = _rangeEntries[startingEntryIndex],
comparisonAttribute = [currentEntry.attributes objectForKey:attribute];
while (nextRangeIndex >= 0)
{
var nextEntry = _rangeEntries[nextRangeIndex];
if (CPMaxRange(nextEntry.range) > rangeLimit.location && isEqual(comparisonAttribute, [nextEntry.attributes objectForKey:attribute]))
{
currentEntry = nextEntry;
nextRangeIndex--;
}
else
break;
}
aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
//scan forwards
currentEntry = _rangeEntries[startingEntryIndex];
nextRangeIndex = startingEntryIndex + 1;
while (nextRangeIndex < _rangeEntries.length)
{
var nextEntry = _rangeEntries[nextRangeIndex];
if (nextEntry.range.location < CPMaxRange(rangeLimit) && isEqual(comparisonAttribute, [nextEntry.attributes objectForKey:attribute]))
{
currentEntry = nextEntry;
nextRangeIndex++;
}
else
break;
}
aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
return comparisonAttribute;
}
//Comparing Attributed Strings
- (BOOL)isEqualToAttributedString:(CPAttributedString)aString
{
if(!aString)
return NO;
if(_string != [aString string])
return NO;
var myRange = CPMakeRange(),
comparisonRange = CPMakeRange(),
myAttributes = [self attributesAtIndex:0 effectiveRange:myRange],
comparisonAttributes = [aString attributesAtIndex:0 effectiveRange:comparisonRange],
length = _string.length;
while (CPMaxRange(CPUnionRange(myRange, comparisonRange)) < length)
{
if (CPIntersectionRange(myRange, comparisonRange).length > 0 && ![myAttributes isEqualToDictionary:comparisonAttributes])
return NO;
if (CPMaxRange(myRange) < CPMaxRange(comparisonRange))
myAttributes = [self attributesAtIndex:CPMaxRange(myRange) effectiveRange:myRange];
else
comparisonAttributes = [aString attributesAtIndex:CPMaxRange(comparisonRange) effectiveRange:comparisonRange];
}
return YES;
}
- (BOOL)isEqual:(id)anObject
{
if (anObject == self)
return YES;
if ([anObject isKindOfClass:[self class]])
return [self isEqualToAttributedString:anObject];
return NO;
}
//Extracting a Substring
- (CPAttributedString)attributedSubstringFromRange:(CPRange)aRange
{
if (!aRange || CPMaxRange(aRange) > _string.length || aRange.location < 0)
[CPException raise:CPRangeException
reason:"tried to get attributedSubstring for an invalid range: "+(aRange?CPStringFromRange(aRange):"nil")];
var newString = [[CPAttributedString alloc] initWithString:_string.substring(aRange.location, CPMaxRange(aRange))],
entryIndex = [self _indexOfEntryWithIndex:aRange.location],
currentRangeEntry = _rangeEntries[entryIndex],
lastIndex = CPMaxRange(aRange);
newString._rangeEntries = [];
while (currentRangeEntry && CPMaxRange(currentRangeEntry.range) < lastIndex)
{
var newEntry = copyRangeEntry(currentRangeEntry);
newEntry.range.location -= aRange.location;
if (newEntry.range.location < 0)
{
newEntry.range.length += newEntry.range.location;
newEntry.range.location = 0;
}
newString._rangeEntries.push(newEntry);
currentRangeEntry = _rangeEntries[++entryIndex];
}
if (currentRangeEntry)
{
var newRangeEntry = copyRangeEntry(currentRangeEntry);
newRangeEntry.range.length = CPMaxRange(aRange) - newRangeEntry.range.location;
newRangeEntry.range.location -= aRange.location;
if (newRangeEntry.range.location < 0)
{
newRangeEntry.range.length += newRangeEntry.range.location;
newRangeEntry.range.location = 0;
}
newString._rangeEntries.push(newRangeEntry);
}
return newString;
}
//Changing Characters
- (void)replaceCharactersInRange:(CPRange)aRange withString:(CPString)aString
{
[self beginEditing];
if (!aString)
aString = "";
var startingIndex = [self _indexOfEntryWithIndex:aRange.location],
startingRangeEntry = _rangeEntries[startingIndex],
endingIndex = [self _indexOfEntryWithIndex:CPMaxRange(aRange)-1],
endingRangeEntry = _rangeEntries[endingIndex],
additionalLength = aString.length - aRange.length;
_string = _string.substring(0, aRange.location) + aString + _string.substring(CPMaxRange(aRange));
if (startingIndex == endingIndex)
startingRangeEntry.range.length += additionalLength;
else
{
endingRangeEntry.range.length = CPMaxRange(endingRangeEntry.range) - CPMaxRange(aRange);
endingRangeEntry.range.location = CPMaxRange(aRange);
startingRangeEntry.range.length = CPMaxRange(aRange) - startingRangeEntry.range.location;
_rangeEntries.splice(startingIndex, endingIndex - startingIndex);
}
endingIndex = startingIndex + 1;
while(endingIndex < _rangeEntries.length)
_rangeEntries[endingIndex++].range.location+=additionalLength;
[self endEditing];
}
- (void)deleteCharactersInRange:(CPRange)aRange
{
[self replaceCharactersInRange:aRange withString:nil];
}
//Changing Attributes
- (void)setAttributes:(CPDictionary)aDictionary range:(CPRange)aRange
{
[self beginEditing];
var startingEntryIndex = [self _indexOfRangeEntryForIndex:aRange.location splitOnMaxIndex:YES],
endingEntryIndex = [self _indexOfRangeEntryForIndex:CPMaxRange(aRange) splitOnMaxIndex:YES],
current = startingEntryIndex;
if (endingEntryIndex == CPNotFound)
endingEntryIndex = _rangeEntries.length;
while (current < endingEntryIndex)
_rangeEntries[current++].attributes = [aDictionary copy];
//necessary?
[self _coalesceRangeEntriesFromIndex:startingEntryIndex toIndex:endingEntryIndex];
[self endEditing];
}
- (void)addAttributes:(CPDictionary)aDictionary range:(CPRange)aRange
{
[self beginEditing];
var startingEntryIndex = [self _indexOfRangeEntryForIndex:aRange.location splitOnMaxIndex:YES],
endingEntryIndex = [self _indexOfRangeEntryForIndex:CPMaxRange(aRange) splitOnMaxIndex:YES],
current = startingEntryIndex;
if (endingEntryIndex == CPNotFound)
endingEntryIndex = _rangeEntries.length;
while (current < endingEntryIndex)
{
var keys = [aDictionary allKeys],
count = [keys count];
while (count--)
[_rangeEntries[current].attributes setObject:[aDictionary objectForKey:keys[count]] forKey:keys[count]];
current++;
}
//necessary?
[self _coalesceRangeEntriesFromIndex:startingEntryIndex toIndex:endingEntryIndex];
[self endEditing];
}
- (void)addAttribute:(CPString)anAttribute value:(id)aValue range:(CPRange)aRange
{
[self addAttributes:[CPDictionary dictionaryWithObject:aValue forKey:anAttribute] range:aRange];
}
- (void)removeAttribute:(CPString)anAttribute range:(CPRange)aRange
{
[self addAttribute:anAttribute value:nil range:aRange];
}
//Changing Characters and Attributes
- (void)appendAttributedString:(CPAttributedString)aString
{
[self insertAttributedString:aString atIndex:_string.length];
}
- (void)insertAttributedString:(CPAttributedString)aString atIndex:(CPString)anIndex
{
[self beginEditing];
if (anIndex < 0 || anIndex > [self length])
[CPException raise:CPRangeException reason:"tried to insert attributed string at an invalid index: "+anIndex];
var entryIndexOfNextEntry = [self _indexOfRangeEntryForIndex:anIndex splitOnMaxIndex:YES],
otherRangeEntries = aString._rangeEntries,
length = [aString length];
if (entryIndexOfNextEntry == CPNotFound)
entryIndexOfNextEntry = _rangeEntries.length;
_string = _string.substring(0, anIndex) + aString._string + _string.substring(anIndex);
var current = entryIndexOfNextEntry;
while (current < _rangeEntries.length)
_rangeEntries[current++].range.location += length;
var newRangeEntryCount = otherRangeEntries.length,
index = 0;
while (index < newRangeEntryCount)
{
var entryCopy = copyRangeEntry(otherRangeEntries[index++]);
entryCopy.range.location += anIndex;
_rangeEntries.splice(entryIndexOfNextEntry-1+index, 0, entryCopy);
}
//necessary?
//[self _coalesceRangeEntriesFromIndex:startingEntryIndex toIndex:startingEntryIndex+rangeEntries.length];
[self endEditing];
}
- (void)replaceCharactersInRange:(CPRange)aRange withAttributedString:(CPAttributedString)aString
{
[self beginEditing];
[self deleteCharactersInRange:aRange];
[self insertAttributedString:aString atIndex:aRange.location];
[self endEditing];
}
- (void)setAttributedString:(CPAttributedString)aString
{
[self beginEditing];
_string = aString._string;
_rangeEntries = [];
for (var i=0, count = aString._rangeEntries.length; i<count; i++)
_rangeEntries.push(copyRangeEntry(aString._rangeEntries[i]));
[self endEditing];
}
//Private methods
- (void)_indexOfRangeEntryForIndex:(unsigned)characterIndex splitOnMaxIndex:(BOOL)split
{
var index = [self _indexOfEntryWithIndex:characterIndex];
if (index < 0)
return index;
var rangeEntry = _rangeEntries[index];
if (rangeEntry.range.location == characterIndex || (CPMaxRange(rangeEntry.range) - 1 == characterIndex && !split))
return index;
var newEntries = splitRangeEntryAtIndex(rangeEntry, characterIndex);
_rangeEntries.splice(index, 1, newEntries[0], newEntries[1]);
index++;
return index;
}
- (void)_coalesceRangeEntriesFromIndex:(unsigned)start toIndex:(unsigned)end
{
var current = start;
if (end >= _rangeEntries.length)
end = _rangeEntries.length -1;
while (current < end)
{
var a = _rangeEntries[current],
b = _rangeEntries[current+1];
if ([a.attributes isEqualToDictionary:b.attributes])
{
a.range.length = CPMaxRange(b.range) - a.range.location;
_rangeEntries.splice(current+1, 1);
end--;
}
else
current++;
}
}
//Grouping Changes
- (void)beginEditing
{
//do nothing (says cocotron and gnustep)
}
- (void)endEditing
{
//do nothing (says cocotron and gnustep)
}
@end
@implementation CPMutableAttributedString : CPAttributedString {}
@end
var isEqual = function isEqual(a, b)
{
if (a == b)
return YES;
if ([a respondsToSelector:@selector(isEqual:)] && [a isEqual:b])
return YES;
return NO;
}
var makeRangeEntry = function makeRangeEntry(/*CPRange*/aRange, /*CPDictionary*/attributes)
{
return {range:aRange, attributes:[attributes copy]};
}
var copyRangeEntry = function copyRangeEntry(/*RangeEntry*/aRangeEntry)
{
return makeRangeEntry(CPCopyRange(aRangeEntry.range), [aRangeEntry.attributes copy]);
}
var splitRangeEntry = function splitRangeEntryAtIndex(/*RangeEntry*/aRangeEntry, /*unsigned*/anIndex)
{
var newRangeEntry = copyRangeEntry(aRangeEntry),
cachedIndex = CPMaxRange(aRangeEntry.range);
aRangeEntry.range.length = anIndex - aRangeEntry.range.location;
newRangeEntry.range.location = anIndex;
newRangeEntry.range.length = cachedIndex - anIndex;
newRangeEntry.attributes = [newRangeEntry.attributes copy];
return [aRangeEntry, newRangeEntry];
}
+13 -2
View File
@@ -20,8 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPObject.j"
import "CPDictionary.j"
@import "CPObject.j"
@import "CPDictionary.j"
@implementation CPBundle : CPObject
{
@@ -58,6 +59,16 @@ import "CPDictionary.j"
return [path stringByDeletingLastPathComponent];
}
- (CPString)resourcePath
{
var resourcePath = [self bundlePath];
if (resourcePath.length)
resourcePath += '/';
return resourcePath + "Resources";
}
- (Class)principalClass
{
var className = [[self infoDictionary] objectForKey:@"CPPrincipalClass"];
+16 -15
View File
@@ -20,10 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPObject.j"
import "CPException.j"
@import "CPObject.j"
@import "CPException.j"
/*
/*! @class CPCoder
Top-level class defining methods for use when archiving (encoding) objects to a byte array
or file, and when restoring (decoding) objects.
*/
@@ -32,7 +33,7 @@ import "CPException.j"
}
/*
/*!
Returns a flag indicating whether the receiver supports keyed coding. The default implementation returns
<code>NO</code>. Subclasses supporting keyed coding must override this to return <code>YES</code>.
*/
@@ -41,7 +42,7 @@ import "CPException.j"
return NO;
}
/*
/*!
Encodes a structure or object of a specified type. Usually this
is used for primitives though it can be used for objects as well.
Subclasses must override this method.
@@ -53,7 +54,7 @@ import "CPException.j"
CPInvalidAbstractInvocation();
}
/*
/*!
Encodes a data object. Subclasses must override this method.
@param aData the object to be encoded.
*/
@@ -62,7 +63,7 @@ import "CPException.j"
CPInvalidAbstractInvocation();
}
/*
/*!
Encodes an object. Subclasses must override this method.
@param anObject the object to be encoded
*/
@@ -71,7 +72,7 @@ import "CPException.j"
// [self encodeValueOfObjCType:@encode(id) at:object];
}
/*
/*!
Encodes a point
@param aPoint the point to be encoded.
*/
@@ -81,7 +82,7 @@ import "CPException.j"
[self encodeNumber:aPoint.y];
}
/*
/*!
Encodes a CGRect
@param aRect the rectangle to be encoded.
*/
@@ -91,7 +92,7 @@ import "CPException.j"
[self encodeSize:aRect.size];
}
/*
/*!
Encodes a CGSize
@param aSize the size to be encoded
*/
@@ -101,7 +102,7 @@ import "CPException.j"
[self encodeNumber:aSize.height];
}
/*
/*!
Encodes a property list. Not yet implemented.
@param aPropertyList the property list to be encoded
*/
@@ -110,7 +111,7 @@ import "CPException.j"
// [self encodeValueOfObjCType:@encode(id) at:&propertyList];
}
/*
/*!
Encodes the root object of a group of Obj-J objects.
@param rootObject the root object to be encoded.
*/
@@ -119,7 +120,7 @@ import "CPException.j"
[self encodeObject:anObject];
}
/*
/*!
Encodes an object.
@param anObject the object to be encoded.
*/
@@ -128,7 +129,7 @@ import "CPException.j"
[self encodeObject:object];
}
/*
/*!
Encodes an object.
@param anObject the object to be encoded.
*/
@@ -141,7 +142,7 @@ import "CPException.j"
@implementation CPObject (CPCoding)
/*
/*!
Called after an object is unarchived in case a different object should be used in place of it.
The defaut method returns <code>self</code>. Interested subclasses should override this.
@param aDecoder
+3 -2
View File
@@ -20,8 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPObject.j"
import "CPString.j"
@import "CPObject.j"
@import "CPString.j"
@implementation CPData : CPObject
{
+3 -2
View File
@@ -20,8 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import "CPObject.j"
import "CPString.j"
@import "CPObject.j"
@import "CPString.j"
var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
+63 -28
View File
@@ -20,10 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
//import "CPRange.j"
import "CPObject.j"
import "CPEnumerator.j"
import "CPException.j"
//@import "CPRange.j"
@import "CPObject.j"
@import "CPEnumerator.j"
@import "CPException.j"
/* @ignore */
@implementation _CPDictionaryValueEnumerator : CPEnumerator
@@ -57,15 +57,15 @@ import "CPException.j"
@end
/*
/*! @class CPDictionary
A dictionary is the standard way of passing around key-value pairs in
the Cappuccino framework. It is similar to the
<a href="http://java.sun.com/javase/6/docs/api/index.html">Java map interface</a>,
except all keys are <objj>CPString</objj>s and values can be any
except all keys are CPStrings and values can be any
Cappuccino or JavaScript object.</p>
<p>If you are familiar with dictionaries in Cocoa, you'll notice that
there is no CPMutableDictionary class. The regular <objj>CPDictionary</objj>
there is no CPMutableDictionary class. The regular CPDictionary
has <code>setObject:</code> and <code>removeObjectForKey:</code> methods.
In Cappuccino there is no distinction between immutable and mutable classes.
They are all mutable.
@@ -82,48 +82,48 @@ import "CPException.j"
return new objj_dictionary();
}
/*
Returns a new empty <objj>CPDictionary</objj>.
/*!
Returns a new empty CPDictionary.
*/
+ (id)dictionary
{
return [[self alloc] init];
}
/*
/*!
Returns a new dictionary, initialized with the contents of <code>aDictionary</code>.
@param aDictionary the dictionary to copy key-value pairs from
@return the new <objj>CPDictionary</objj>
@return the new CPDictionary
*/
+ (id)dictionaryWithDictionary:(CPDictionary)aDictionary
{
return [[self alloc] initWithDictionary:aDictionary];
}
/*
/*!
Creates a new dictionary with single key-value pair.
@param anObject the object for the paring
@param aKey the key for the pairing
@return the new <objj>CPDictionary</objj>
@return the new CPDictionary
*/
+ (id)dictionaryWithObject:(id)anObject forKey:(id)aKey
{
return [[self alloc] initWithObjects:[anObject] forKeys:[aKey]];
}
/*
/*!
Creates a dictionary with multiple key-value pairs.
@param objects the objects to place in the dictionary
@param keys the keys for each of the objects
@throws CPInvalidArgumentException if the number of objects and keys is different
@return the new <objj>CPDictionary</objj>
@return the new CPDictionary
*/
+ (id)dictionaryWithObjects:(CPArray)objects forKeys:(CPArray)keys
{
return [[self alloc] initWithObjects:objects forKeys:keys];
}
/*
/*!
Initializes the dictionary with the contents of another dictionary.
@param aDictionary the dictionary to copy key-value pairs from
@return the initialized dictionary
@@ -139,7 +139,7 @@ import "CPException.j"
return dictionary;
}
/*
/*!
Initializes the dictionary from the arrays of keys and objects.
@param objects the objects to put in the dictionary
@param keyArray the keys for the objects to put in the dictionary
@@ -164,7 +164,15 @@ import "CPException.j"
return self;
}
/*
/*!
return a copy of the receiver (does not deep copy the objects contained in the dictionary).
*/
- (CPDictionary)copy
{
return [CPDictionary dictionaryWithDictionary:self];
}
/*!
Returns the number of entries in the dictionary
*/
- (int)count
@@ -172,7 +180,7 @@ import "CPException.j"
return count;
}
/*
/*!
Returns an array of keys for all the entries in the dictionary.
*/
- (CPArray)allKeys
@@ -180,7 +188,7 @@ import "CPException.j"
return _keys;
}
/*
/*!
Returns an array of values for all the entries in the dictionary.
*/
- (CPArray)allValues
@@ -194,7 +202,7 @@ import "CPException.j"
return values;
}
/*
/*!
Returns an enumerator that enumerates over all the dictionary's keys.
*/
- (CPEnumerator)keyEnumerator
@@ -202,7 +210,7 @@ import "CPException.j"
return [_keys objectEnumerator];
}
/*
/*!
Returns an enumerator that enumerates over all the dictionary's values.
*/
- (CPEnumerator)objectEnumerator
@@ -210,6 +218,33 @@ import "CPException.j"
return [[_CPDictionaryValueEnumerator alloc] initWithDictionary:self];
}
/*!
Compare the receiver to this dictionary, and return whether or not they are equal.
*/
- (BOOL)isEqualToDictionary:(CPDictionary)aDictionary
{
if (count != [aDictionary count])
return NO;
var index = count;
while (index--)
{
var currentKey = _keys[index],
lhsObject = _buckets[currentKey],
rhsObject = aDictionary._buckets[currentKey];
if (lhsObject === rhsObject)
continue;
if ([lhsObject respondsToSelector:@selector(isEqual:)] && [lhsObject isEqual:rhsObject])
continue;
return NO;
}
return YES;
}
/*
Instance.isEqualToDictionary(aDictionary)
{
@@ -263,7 +298,7 @@ import "CPException.j"
return this._objects.objectEnumerator();
}
*/
/*
/*!
Returns the object for the entry with key <code>aKey</code>.
@param aKey the key for the object's entry
@return the object for the entry
@@ -306,7 +341,7 @@ import "CPException.j"
while(key= keyEnumerator.nextObject()) this.setObjectForKey(aDictionary.objectForKey(key), key);
}
*/
/*
/*!
Removes all the entries from the dictionary.
*/
- (void)removeAllObjects
@@ -316,7 +351,7 @@ import "CPException.j"
_buckets = {};
}
/*
/*!
Removes the entry for the specified key.
@param aKey the key of the entry to be removed
*/
@@ -351,7 +386,7 @@ import "CPException.j"
while(i--) this._dictionary[this._keys[i]]= { object: this._objects[i], index: i };
}
*/
/*
/*!
Adds an entry into the dictionary.
@param anObject the object for the entry
@param aKey the entry's key
@@ -373,7 +408,7 @@ import "CPException.j"
}
*/
/*
/*!
Returns a human readable description of the dictionary.
*/
- (CPString)description
@@ -404,7 +439,7 @@ import "CPException.j"
return [aCoder _decodeDictionaryOfObjectsForKey:@"CP.objects"];
}
/*
/*!
Archives the dictionary to a provided coder.
@param aCoder the coder to which the dictionary data will be archived.
*/

Some files were not shown because too many files have changed in this diff Show More